IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 13, 2006, 4:23:40 PM (20 years ago)
Author:
Paul Price
Message:

Getting code to compile; adding concept read to fpa construction and reading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsWrite.c

    r6570 r6575  
    44
    55#include "pmFPA.h"
     6#include "pmHDU.h"
     7#include "pmHDUGetLowest.h"
     8#include "pmConcepts.h"
    69#include "pmConceptsRead.h"
    710#include "psAdditionals.h"
     
    8992        return formatted;
    9093    }
     94    return NULL;
    9195}
    9296
     
    127131{
    128132    if (cell) {
    129         pmHDU *hdu = getLowestHDU(NULL, NULL, cell); // The HDU at the lowest level
     133        pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
    130134        psMetadata *cameraFormat = hdu->format; // The camera format
    131135        psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
     
    142146                psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, NULL, NULL, cell);
    143147                psString nameSource = NULL; // String with the concept name and ".SOURCE" added
    144                 psStringAppend(nameSource, "%s.SOURCE", name);
     148                psStringAppend(&nameSource, "%s.SOURCE", name);
    145149                bool mdok = true;       // Status of MD lookup
    146150                psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source
     
    149153                        if (cameraItem->type != PS_DATA_STRING) {
    150154                            psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by header, but is not "
    151                                      "of type STR --- ignored.\n", conceptItem->name)
     155                                     "of type STR --- ignored.\n", conceptItem->name);
    152156                            continue;
    153157                        }
     
    181185
    182186
    183 bool pmConceptsWriteToDefault(psMetadata *specs, // The concept specifications
    184                               pmFPA *fpa, // The FPA
    185                               pmChip *chip, // The chip
    186                               pmCell *cell, // The cell
    187                               psMetadata *concepts // The concepts
    188                              )
    189 {
    190     bool mdok = true;               // Status of MD lookup
     187bool pmConceptsWriteToDefaults(psMetadata *specs, // The concept specifications
     188                               pmFPA *fpa, // The FPA
     189                               pmChip *chip, // The chip
     190                               pmCell *cell, // The cell
     191                               psMetadata *concepts // The concepts
     192                              )
     193{
     194    pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
     195    psMetadata *cameraFormat = hdu->format; // The camera format
     196    bool mdok = true;                   // Status of MD lookup
    191197    psMetadata *defaults = psMetadataLookupMD(&mdok, cameraFormat, "DEFAULTS"); // The DEFAULTS spec
    192198    if (mdok && defaults) {
    193         pmHDU *hdu = getLowestHDU(fpa, chip, cell); // The HDU at the lowest level
     199        pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    194200        psMetadata *cameraFormat = hdu->format; // The camera format
    195201        psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
     
    202208                psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts
    203209                psMetadataItem *formatted = conceptFormat(spec, conceptItem, cameraFormat, fpa, chip, cell);
    204                 if (! compareConcepts(cameraItem, formatted)) {
     210                if (! compareConcepts(defaultItem, formatted)) {
    205211                    psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by the DEFAULTS in the camera "
    206212                             "format, but the values don't match.\n");
     
    222228                            )
    223229{
    224     bool mdok = true;               // Status of MD lookup
     230    pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
     231    psMetadata *cameraFormat = hdu->format; // The camera format
     232    bool mdok = true;                   // Status of MD lookup
    225233    psMetadata *translation = psMetadataLookupMD(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec
    226234    if (mdok && translation) {
    227         pmHDU *hdu = getLowestHDU(fpa, chip, cell); // The HDU at the lowest level
     235        pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    228236        psMetadata *cameraFormat = hdu->format; // The camera format
    229237        psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
     
    271279}
    272280
    273 
     281// XXX Warning: This code has not been tested at all
    274282bool pmConceptsWriteToDatabase(psMetadata *specs, // The concept specifications
    275283                               pmFPA *fpa, // The FPA
     
    280288                              )
    281289{
    282     bool mdok = true;               // Status of MD lookup
     290    pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
     291    psMetadata *cameraFormat = hdu->format; // The camera format
     292    bool mdok = true;                   // Status of MD lookup
    283293    psMetadata *database = psMetadataLookupMD(&mdok, cameraFormat, "DATABASE"); // The DATABASE spec
    284294    if (mdok && database) {
    285         pmHDU *hdu = getLowestHDU(fpa, chip, cell); // The HDU at the lowest level
     295        pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level
    286296        psMetadata *cameraFormat = hdu->format; // The camera format
    287297        psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
     
    291301            psString name = specItem->name; // The concept name
    292302
    293             psMetadataItem *dbItem = psMetadataLookup(&mdok, database, name); // The item from the DATABASE
     303            psMetadataItem *dbItem = psMetadataLookup(database, name); // The item from the DATABASE
    294304            if (dbItem) {
    295305                if (dbItem->type != PS_DATA_METADATA) {
     
    304314                psMetadata *dbLookup = dbItem->data.V; // How to look up the value of interest
    305315                // Name of the table
    306                 const char *tableName = psMetadataLookupStr(&mdStatus, dbLookup, "TABLE");
     316                const char *tableName = psMetadataLookupStr(&mdok, dbLookup, "TABLE");
    307317                // Name of "where" columns
    308                 const char *givenCols = psMetadataLookupStr(&mdStatus, dbLookup, "GIVENDBCOL");
     318                const char *givenCols = psMetadataLookupStr(&mdok, dbLookup, "GIVENDBCOL");
    309319                // Values for "where" columns
    310                 const char *givenPS = psMetadataLookupStr(&mdStatus, dbLookup, "GIVENPS");
     320                const char *givenPS = psMetadataLookupStr(&mdok, dbLookup, "GIVENPS");
    311321
    312322                // Now, need to get the "given"s
     
    318328                        psLogMsg(__func__, PS_LOG_WARN,
    319329                                 "The GIVENDBCOL and GIVENPS entries for %s do not have "
    320                                  "the same number of entries --- ignored.\n", concept);
     330                                 "the same number of entries --- ignored.\n", name);
    321331                    } else {
    322332                        // Iterators for the lists
     
    325335                        char *column = NULL;    // Name of the column
    326336                        while ((column = psListGetAndIncrement(colsIter))) {
    327                             char *name = psListGetAndIncrement(valuesIter); // Name for the value
     337                            char *dependName = psListGetAndIncrement(valuesIter); // Name for the value
    328338                            if (!strlen(column) || !strlen(name)) {
    329339                                psLogMsg(__func__, PS_LOG_WARN, "One of the columns or value names for %s is "
    330                                          " empty --- ignored.\n", concept);
     340                                         " empty --- ignored.\n", name);
    331341                            } else {
    332342                                // Search for the value name
    333                                 psMetadataItem *item = pmConceptReadFromHeader(fpa, chip, cell, name);
    334                                 if (! item) {
    335                                     item = pmConceptReadFromDefault(fpa, chip, cell, name);
     343                                psMetadataItem *item = NULL; // The value
     344                                if (!item && cell) {
     345                                    item = psMetadataLookup(cell->concepts, dependName);
     346                                }
     347                                if (!item && chip) {
     348                                    item = psMetadataLookup(chip->concepts, dependName);
     349                                }
     350                                if (!item && fpa) {
     351                                    item = psMetadataLookup(fpa->concepts, dependName);
    336352                                }
    337353                                if (! item) {
    338354                                    psLogMsg(__func__, PS_LOG_ERROR,
    339355                                             "Unable to find the value name %s for DB "
    340                                              " lookup on %s --- ignored.\n", name, concept);
     356                                             " lookup on %s --- ignored.\n", dependName, name);
    341357                                } else {
    342358                                    // We need to create a new psMetadataItem.  I don't think we can't simply
     
    346362                                }
    347363                            }
    348                             psFree(name);
     364                            psFree(dependName);
    349365                            psFree(column);
    350366                        } // Iterating through the columns
     
    357373                        if (! dbResult || dbResult->n == 0) {
    358374                            psLogMsg(__func__, PS_LOG_WARN, "Unable to find any rows in DB for %s --- "
    359                                      "ignored\n", concept->name);
     375                                     "ignored\n", name);
    360376                            return false;
    361377                        } else {
    362378                            if (dbResult->n > 1) {
    363379                                psLogMsg(__func__, PS_LOG_WARN, "Multiple rows returned in DB lookup for %s "
    364                                          "--- ignored.\n", concept->name);
     380                                         "--- ignored.\n", name);
    365381                            }
    366382                            // Update the DB
    367383                            psMetadata *update = psMetadataAlloc();
    368                             psMetadataAddItem(update, concept, PS_LIST_HEAD, 0);
     384                            psMetadataAddItem(update, conceptItem, PS_LIST_HEAD, 0);
    369385                            psDBUpdateRows(db, tableName, selection, update);
    370386                            psFree(update);
Note: See TracChangeset for help on using the changeset viewer.