IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18939


Ignore:
Timestamp:
Aug 5, 2008, 5:40:45 PM (18 years ago)
Author:
Paul Price
Message:

Don't get rid of derivative cameras when culling in preparation for dump.

Location:
trunk/psModules/src/config
Files:
3 edited

Legend:

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

    r17993 r18939  
    2323static void removeChipConceptsSources(psMetadata *source);
    2424
    25 // Generate the skycell version of a named camera configuration
    26 bool pmConfigCameraSkycellVersion(psMetadata *system, // The system configuration
    27                                   const char *name // Name of the un-mosaicked camera
    28                                   )
    29 {
    30     PS_ASSERT_METADATA_NON_NULL(system, false);
    31     PS_ASSERT_STRING_NON_EMPTY(name, false);
    32 
    33     bool mdok;                          // Status of MD lookup
    34     psMetadata *cameras = psMetadataLookupMetadata(&mdok, system, "CAMERAS"); // List of cameras
    35     if (!mdok || !cameras) {
    36         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find CAMERAS in the system configuration.\n");
    37         return false;
    38     }
    39     if (!pmConfigGenerateSkycellVersion(cameras, cameras, name, system)) {
    40         psError(PS_ERR_UNKNOWN, true, "Failed to build skycell camera description for %s\n", name);
    41         return false;
    42     }
    43     return true;
     25psString pmConfigCameraRootName(const char *name)
     26{
     27    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     28
     29    if (name[0] != '_') {
     30        // It's an original
     31        return psStringCopy(name);
     32    }
     33
     34    psString root = psStringCopy(name + 1); // Camera name
     35    int length = strlen(name);                     // Length of camera name
     36    if (strcmp(root + length - 9, "-SKYCELL") == 0) {
     37        length -= 9;
     38    } else if (strcmp(root + length - 6, "-CHIP") == 0) {
     39        length -= 6;
     40    } else if (strcmp(root + length - 5, "-FPA") == 0) {
     41        length -= 5;
     42    } else {
     43        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised derivative camera: %s", name);
     44        psFree(root);
     45        return NULL;
     46    }
     47
     48    // Truncate the string
     49    root[length] = '\0';
     50
     51    return root;
     52}
     53
     54psString pmConfigCameraSkycellName(const char *name)
     55{
     56    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     57
     58    psString root = pmConfigCameraRootName(name); // Root name of camera
     59    if (!root) {
     60        return NULL;
     61    }
     62
     63    psStringAppend(&root, "-SKYCELL");
     64    psStringPrepend(&root, "_");
     65
     66    return root;
     67}
     68
     69psString pmConfigCameraChipName(const char *name)
     70{
     71    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     72
     73    psString root = pmConfigCameraRootName(name); // Root name of camera
     74    if (!root) {
     75        return NULL;
     76    }
     77
     78    psStringAppend(&root, "-CHIP");
     79    psStringPrepend(&root, "_");
     80
     81    return root;
     82}
     83
     84psString pmConfigCameraFPAName(const char *name)
     85{
     86    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     87
     88    psString root = pmConfigCameraRootName(name); // Root name of camera
     89    if (!root) {
     90        return NULL;
     91    }
     92
     93    psStringAppend(&root, "-FPA");
     94    psStringPrepend(&root, "_");
     95
     96    return root;
    4497}
    4598
  • trunk/psModules/src/config/pmConfigCamera.h

    r14475 r18939  
    55 *  @author Eugene Magnier, IfA
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-08-14 00:17:40 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-08-06 03:40:45 $
    99 *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    1515/// @addtogroup Config Configuration System
    1616/// @{
     17
     18// Return the name of the original ("root") camera
     19//
     20// The root name is the name of the camera before it was made into a derivative (e.g., skycell, chip, fpa).
     21psString pmConfigCameraRootName(const char *name // Name of camera
     22    );
     23
     24// Return the name of the Skycell derivative camera
     25psString pmConfigCameraSkycellName(const char *name // Name of camera
     26    );
     27
     28// Return the name of the Chip derivative camera
     29psString pmConfigCameraChipName(const char *name // Name of camera
     30    );
     31
     32// Return the name of the FPA derivative camera
     33psString pmConfigCameraFPAName(const char *name // Name of camera
     34    );
    1735
    1836// Generate a skycell version of a camera configuration
  • trunk/psModules/src/config/pmConfigDump.c

    r18908 r18939  
    1313#include "pmFPAview.h"
    1414#include "pmFPAfile.h"
     15#include "pmConfigCamera.h"
    1516
    1617#include "pmConfigDump.h"
     
    1819// Cull entries in the metadata, ignoring the ones listed.
    1920static bool configCull(psMetadata *md,  // Configuration metadata from which to cull
    20                        const char *list // List of items NOT to cull
     21                       const psArray *list // List of items NOT to cull
    2122    )
    2223{
    2324    PS_ASSERT_METADATA_NON_NULL(md, false);
     25    PS_ASSERT_ARRAY_NON_NULL(list, false);
    2426
    25     if (!list || strlen(list) == 0) {
    26         // Save everything if nothing is listed
    27         return true;
     27    psHash *keep = psHashAlloc(list->n); // Hash with strings to keep
     28    for (int i = 0; i < keep->n; i++) {
     29        psHashAdd(keep, list->data[i], list->data[i]);
    2830    }
    29 
    30     psArray *keepList = psStringSplitArray(list, " ,;", false); // List of items to keep
    31     psHash *keep = psHashAlloc(keepList->n); // Hash with strings to keep
    32     for (int i = 0; i < keep->n; i++) {
    33         psHashAdd(keep, keepList->data[i], keepList->data[i]);
    34     }
    35     psFree(keepList);
    3631
    3732    psMetadataIterator *iter = psMetadataIteratorAlloc(md, PS_LIST_HEAD, NULL); // Iterator
     
    5752    }
    5853
    59     return configCull(config->recipes, save);
     54    psArray *keep = psStringSplitArray(save, " ,;", false); // List of items to keep
     55
     56    bool result = configCull(config->recipes, keep); // Result of culling
     57    psFree(keep);
     58
     59    return result;
    6060}
    6161
     
    7070      }
    7171
    72       return configCull(cameras, config->cameraName);
     72      // Get names of the root camera and its derivatives
     73      psArray *keep = psArrayAlloc(4);
     74      keep->data[0] = pmConfigCameraRootName(config->cameraName);
     75      keep->data[1] = pmConfigCameraChipName(config->cameraName);
     76      keep->data[2] = pmConfigCameraFPAName(config->cameraName);
     77      keep->data[3] = pmConfigCameraSkycellName(config->cameraName);
     78
     79      bool result = configCull(cameras, keep); // Result of culling
     80      psFree(keep);
     81
     82      return result;
    7383}
    7484
Note: See TracChangeset for help on using the changeset viewer.