IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2008, 12:49:16 PM (18 years ago)
Author:
Paul Price
Message:

Generate mask value if possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfigMask.c

    r19442 r19870  
    1212// Private functions
    1313//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    14 
    15 static psMaskType maskGet(const psMetadata *source, // Source of masks
    16                           const char *masks // Mask values to get
    17                           )
    18 {
    19     psMaskType mask = 0;                // Mask value, to return
    20 
    21     psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names
    22     for (int i = 0; i < names->n; i++) {
    23         const char *name = names->data[i]; // Symbolic name of interest
    24         bool mdok;                      // Status of MD lookup
    25         psMaskType value = psMetadataLookupU8(&mdok, source, name);
    26         if (!mdok) {
    27             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find mask value for %s", name);
    28             psFree(names);
    29             return 0;
    30         }
    31         mask |= value;
    32     }
    33     psFree(names);
    34 
    35     return mask;
    36 }
    3714
    3815// maskSetValues examine named mask values and set the bits for maskValue and markValue.
     
    152129}
    153130
     131// Get a mask value by name(s)
     132static psMaskType maskGet(psMetadata *source, // Source of masks
     133                          const char *masks // Mask values to get
     134                          )
     135{
     136    psMaskType mask = 0;                // Mask value, to return
     137
     138    psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names
     139    for (int i = 0; i < names->n; i++) {
     140        const char *name = names->data[i]; // Symbolic name of interest
     141        bool mdok;                      // Status of MD lookup
     142        psMaskType value = psMetadataLookupU8(&mdok, source, name);
     143        if (!mdok) {
     144            // Try and generate the value if we can
     145            if (strcmp(name, "MASK.VALUE") == 0 || strcmp(name, "MARK.VALUE") == 0) {
     146                if (!maskSetValues(NULL, NULL, source)) {
     147                    psError(PS_ERR_UNKNOWN, false, "Unable to set mask bits.");
     148                    return 0;
     149                }
     150                value = psMetadataLookupU8(&mdok, source, name);
     151                psAssert(mdok, "Should have generated mask value");
     152            } else {
     153                psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find mask value for %s", name);
     154                psFree(names);
     155                return 0;
     156            }
     157        }
     158        mask |= value;
     159    }
     160    psFree(names);
     161
     162    return mask;
     163}
     164
    154165// Remove from the header keywords starting with the provided string
    155166static int maskRemoveHeader(psMetadata *header, // Header from which to remove keywords
     
    327338    PS_ASSERT_STRING_NON_EMPTY(masks, 0);
    328339
    329     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     340    bool mdok;                          // Status of MD lookup
     341    psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, "MASKS"); // The recipe
    330342    if (!recipe) {
    331343        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
Note: See TracChangeset for help on using the changeset viewer.