IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2009, 12:07:42 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301/psModules
Files:
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301/psModules

  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/Makefile.am

    r18905 r23351  
    11noinst_LTLIBRARIES = libpsmodulesconfig.la
    22
    3 libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS)
     3# PSMODULES_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
     4# PSMODULES_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
     5# PSMODULES_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
     6
     7# Force recompilation of pmVersion.c, since it gets the version information
     8# pmVersion.c: FORCE
     9#       touch pmVersion.c
     10# FORCE: ;
     11
     12libpsmodulesconfig_la_CPPFLAGS = $(SRCINC) $(PSMODULES_CFLAGS) -DPSMODULES_VERSION=$(SVN_VERSION) -DPSMODULES_BRANCH=$(SVN_BRANCH) -DPSMODULES_SOURCE=$(SVN_SOURCE)
    413libpsmodulesconfig_la_LDFLAGS  = -release $(PACKAGE_VERSION)
    514libpsmodulesconfig_la_SOURCES  = \
     
    1019        pmConfigMask.c \
    1120        pmConfigDump.c \
     21        pmConfigRun.c \
    1222        pmVersion.c \
    1323        pmErrorCodes.c
     
    2030        pmConfigMask.h \
    2131        pmConfigDump.h \
     32        pmConfigRun.h \
    2233        pmVersion.h \
    2334        pmErrorCodes.h
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfig.c

    r21314 r23351  
    1313
    1414#include <stdio.h>
     15#include <stdlib.h>
    1516#include <string.h>
    1617#include <strings.h>            /* for strn?casecmp */
     
    2425#include <pslib.h>
    2526
    26 #include "pmConfig.h"
    2727#include "pmErrorCodes.h"
    2828#include "pmFPALevel.h"
    2929#include "pmConfigRecipes.h"
    3030#include "pmConfigCamera.h"
     31#include "pmConfigRun.h"
     32
     33#include "pmConfig.h"
    3134
    3235#ifdef HAVE_NEBCLIENT
     
    142145    config->format = NULL;
    143146    config->formatName = NULL;
    144     config->recipes = psMetadataAlloc();
     147    config->recipes = NULL;
    145148    config->recipesRead = PM_RECIPE_SOURCE_NONE;
    146149    config->recipesCamera = psMetadataAlloc();
     
    432435    // variable will contain the name of the configuration file.
    433436
    434     char *configFile = NULL;
    435     //
     437    char *configFile = NULL;            // Name of configuration file
     438
    436439    // First, try command line
    437     //
    438440    psS32 argNum = psArgumentGet(*argc, argv, "-ipprc");
    439441    if (argNum != 0) {
     
    447449        }
    448450    }
    449     //
     451
    450452    // Next, try environment variable
    451     //
    452453    if (!configFile) {
    453454        configFile = getenv(IPPRC_ENV);
    454455        if (configFile) {
    455             configFile = psStringCopy (configFile);
    456         }
    457     }
    458 
    459     //
     456            configFile = psStringCopy(configFile);
     457        }
     458    }
     459
    460460    // Last chance is ~/.ipprc
    461     //
    462461    if (!configFile) {
    463462        char *home = getenv("HOME");
     
    466465    }
    467466
    468     // We have the configuration filename; now we read and parse the config
    469     // file and store in psMetadata struct user.
     467    // Read and parse the config file and store in struct user.
    470468    // XXX move this section to pmConfigReadUser.c ?
    471 
    472469    if (!pmConfigFileRead(&config->user, configFile, "user")) {
    473470        psFree(config);
     
    477474    psFree(configFile);
    478475
    479     // XXX why was this being called here?  Is someone calling pmConfigRead multiple times?
    480     // pmConfigDone();
    481     assert (configPath == NULL);
     476    pmConfigRunCommand(config, *argc, argv);
    482477
    483478    // define the config-file search path (configPath).
     479    psAssert(configPath == NULL, "Configuration path is already defined.");
    484480    psString path = psMetadataLookupStr(NULL, config->user, "PATH");
    485     pmConfigSet (path);
     481    pmConfigSet(path);
    486482
    487483    // read the SITE file
     
    525521            psLogSetLevel(logLevel);
    526522        }
    527 
    528523
    529524        // Set logging format
     
    648643    }
    649644
     645    // Set the random number generator seed
     646    {
     647        psU64 seed = 0;                 // RNG seed
     648        int argNum = psArgumentGet(*argc, argv, "-seed"); // Argument number
     649        if (argNum > 0) {
     650            psArgumentRemove(argNum, argc, argv);
     651            if (argNum >= *argc) {
     652                psWarning("-seed command-line switch provided without the required seed value --- ignored.");
     653            } else {
     654                char *end = NULL;       // Pointer to end of consumed string
     655                seed = strtoll(argv[argNum], &end, 0);
     656                if (strlen(end) > 0) {
     657                    psError(PS_ERR_IO, true, "Unable to read random number generator seed: %s", argv[argNum]);
     658                    psFree(config);
     659                    return NULL;
     660                }
     661                psArgumentRemove(argNum, argc, argv);
     662            }
     663        }
     664        pmConfigRunSeed(config, seed);
     665    }
     666
    650667    // Next, we do a similar thing for the camera configuration file.  The
    651668    // file is read and parsed into psMetadata struct "camera".
     
    11101127// camera.  If we are discovering the camera (config->camera == NULL), then we also load the
    11111128// recipe files for the camera.
    1112 psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName, 
    1113                                            pmConfig *config, const psMetadata *header, bool readRecipes)
     1129psMetadata *pmConfigCameraFormatFromHeader(psMetadata **camera, psString *cameraName, psString *formatName,
     1130                                           pmConfig *config, const psMetadata *header, bool readRecipes)
    11141131{
    11151132    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    16721689                // if the object does not exist and create isn't set, then we
    16731690                // should puke
    1674                 psError(PM_ERR_SYS, true, "Unable to access file %s", filename);
     1691                psError(PM_ERR_SYS, true, "Unable to access file %s: %s", filename, nebErr(server));
    16751692                nebServerFree(server);
    16761693                return NULL;
     
    16851702        if (trunc) {
    16861703            if(truncate(path, 0) != 0) {
    1687                 psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n", filename, path);
     1704                psError(PS_ERR_IO, true, "Failed to truncate Nebulous file %s (real name %s)\n",
     1705                        filename, path);
    16881706                return NULL;
    16891707            }
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigCamera.c

    r22700 r23351  
    213213    psStringAppend(&newName, "_%s-SKYCELL", name);
    214214    if (psMetadataLookup(oldCameras, newName)) {
     215        psFree(newName);
    215216        return true;
    216217    }
     
    469470    psStringAppend(&newName, "_%s-%s", name, mosaicLevel == PM_FPA_LEVEL_CHIP ? "CHIP" : "FPA");
    470471    if (psMetadataLookup(oldCameras, newName)) {
     472        psFree(newName);
    471473        return true;
    472474    }
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigDump.c

    r19399 r23351  
    5454    psArray *keep = psStringSplitArray(save, " ,;", false); // List of items to keep
    5555
    56     bool result = configCull(config->recipes, keep); // Result of culling
     56    if (!configCull(config->recipes, keep)) {
     57        psError(PS_ERR_UNKNOWN, false, "Unable to cull system recipes.");
     58        psFree(keep);
     59        return false;
     60    }
    5761    psFree(keep);
    5862
    59     return result;
     63    // Need to cull recipes from all cameras as well
     64    psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // Known cameras
     65    if (!cameras) {
     66        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find CAMERAS in the system configuration.\n");
     67        return false;
     68    }
     69
     70    psMetadataIterator *iter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator for cameras
     71    psMetadataItem *item;               // Item from iteration
     72    keep = psArrayAllocEmpty(1);
     73    while ((item = psMetadataGetAndIncrement(iter))) {
     74        psAssert(item->type == PS_DATA_METADATA, "Should only be metadata types on the camera list.");
     75        psMetadata *camera = item->data.md; // Camera configuration
     76        bool mdok;                      // Status of MD lookup
     77        psMetadata *recipes = psMetadataLookupMetadata(&mdok, camera, "RECIPES"); // Recipe overrides
     78        if (!recipes) {
     79            continue;
     80        }
     81        if (!configCull(recipes, keep)) {
     82            psError(PS_ERR_UNKNOWN, false, "Unable to cull recipes for camera %s", item->name);
     83            psFree(iter);
     84            psFree(keep);
     85            return false;
     86        }
     87    }
     88    psFree(iter);
     89    psFree(keep);
     90
     91    return true;
    6092}
    6193
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRecipes.c

    r21387 r23351  
    1111#include "pmConfigRecipes.h"
    1212
    13 static bool loadRecipeSystem(bool *status, pmConfig *config, psMetadata *source);
     13static bool loadRecipeSystem(bool *status, pmConfig *config);
    1414static bool loadRecipeCamera(bool *status, pmConfig *config, psMetadata *source);
    1515static bool loadRecipeSymbols(bool *status, pmConfig *config, pmRecipeSource source);
     
    5656    PS_ASSERT_PTR_NON_NULL(config, false);
    5757
    58     if (!config->recipes) {
    59         config->recipes = psMetadataAlloc();
    60     }
    61 
    6258    // Read the recipe file names from the system configuration and camera configuration
    6359    // It is an error for config->system:recipes not to exist.  all programs install their
    6460    // master recipe files in the system:recipe location when they are built.
    6561    psAssert(config->system, "base config data defined");
    66     if (source & PM_RECIPE_SOURCE_SYSTEM) {
    67         if (!loadRecipeSystem(&status, config, config->system)) {
     62    if (!config->recipes || (source & PM_RECIPE_SOURCE_SYSTEM)) {
     63        if (!loadRecipeSystem(&status, config)) {
    6864            psError(PS_ERR_IO, false, "Failed to read recipes from system config");
    6965            return false;
     
    321317// Load the recipe files for SYSTEM : REQUIRED
    322318static bool loadRecipeSystem(bool *status,
    323                            pmConfig *config, // The configuration into which to read the recipes
    324                            psMetadata *source // The source configuration, from which to read the filenames
     319                           pmConfig *config // The configuration into which to read the recipes
    325320    )
    326321{
     
    329324    *status = false;
    330325
    331     if (!source) {
     326    if (!config->system) {
    332327        psError(PS_ERR_IO, true,
    333328                "The system configuration has not been read --- cannot read recipes from this location.\n");
     
    336331    }
    337332
    338     psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes
    339     if (!recipes) {
    340         psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
    341         return false;
    342     }
    343 
    344     // Copy contents of the filenames to config->recipes from the "RECIPES" metadata in the source.
    345     // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type.
    346     // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
    347     psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
     333    if (!config->recipes) {
     334        config->recipes = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->system, "RECIPES")); // The list of recipes
     335        if (!config->recipes) {
     336            psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
     337            return false;
     338        }
     339    }
     340
     341    // Read in the component recipes
     342    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipes, PS_LIST_HEAD, NULL); // Iterator
    348343    psMetadataItem *item = NULL;        // MD item containing the filename, from recipe iteration
    349344    while ((item = psMetadataGetAndIncrement(recipesIter))) {
     
    353348            psFree(recipesIter);
    354349            return false;
    355         }
    356 
    357         // add the contents of this recipe file to config->recipes
    358         psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
    359                       item->comment, item->data.md);
     350        }
    360351    }
    361352    psFree(recipesIter);
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmConfigRecipes.h

    r12916 r23351  
    11/*  @file pmConfigRecipes.h
    22 *  @brief Configuration Recipe functions
    3  * 
     3 *
    44 *  @author ?, MHPCC
    55 *  @author Paul Price, IfA
    66 *  @author Eugene Magnier, IfA
    7  * 
     7 *
    88 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    99 *  @date $Date: 2007-04-19 02:10:12 $
     
    1313#ifndef PM_CONFIG_RECIPES_H
    1414#define PM_CONFIG_RECIPES_H
     15
     16#include <pmConfig.h>
    1517
    1618/// @addtogroup Config Configuration System
     
    2628
    2729
    28 bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config);
    29 bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag);
    30 psMetadata *pmConfigRecipeOptions (pmConfig *config, char *recipe);
     30bool pmConfigLoadRecipeArguments(int *argc, char **argv, pmConfig *config);
     31bool pmConfigLoadRecipeOptions(int *argc, char **argv, pmConfig *config, char *flag);
     32psMetadata *pmConfigRecipeOptions(pmConfig *config, char *recipe);
    3133
    3234/// @}
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmVersion.c

    r10291 r23351  
    88#include "pmVersion.h"
    99
    10 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
     10#ifndef PSMODULES_VERSION
     11#error "PSMODULES_VERSION is not set"
     12#endif
     13#ifndef PSMODULES_BRANCH
     14#error "PSMODULES_BRANCH is not set"
     15#endif
     16#ifndef PSMODULES_SOURCE
     17#error "PSMODULES_SOURCE is not set"
     18#endif
     19
     20#define xstr(s) str(s)
     21#define str(s) #s
    1122
    1223psString psModulesVersion(void)
    1324{
    14     psString version = NULL;            // Version, to return
    15     psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
    16     return version;
     25    char *value = NULL;
     26    psStringAppend(&value, "%s@%s", xstr(PSMODULES_BRANCH), xstr(PSMODULES_VERSION));
     27    return value;
    1728}
     29
     30psString psModulesSource(void)
     31{
     32    return psStringCopy(xstr(PSMODULES_SOURCE));
     33}
     34
    1835
    1936psString psModulesVersionLong(void)
    2037{
    21     psString version = psModulesVersion(); // Version, to return
    22     psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
     38    psString version = psModulesVersion();  // Version, to return
     39    psString source = psModulesSource();    // Source
    2340
    24     psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
     41    psStringPrepend(&version, "psModules ");
     42    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
     43    psFree(source);
    2544
    26     psFree(tag);
     45#ifdef __OPTIMIZE__
     46    psStringAppend(&version, " optimised");
     47#else
     48    psStringAppend(&version, " unoptimised");
     49#endif
     50
     51#ifdef HAVE_NEBCLIENT
     52    psStringAppend(&version, " with nebclient");
     53#else
     54    psStringAppend(&version, " without nebclient");
     55#endif
     56
    2757    return version;
     58};
     59
     60
     61bool psModulesVersionHeader(psMetadata *header)
     62{
     63    PS_ASSERT_METADATA_NON_NULL(header, false);
     64
     65    psString version = psModulesVersion(); // Software version
     66    psString source = psModulesSource();   // Software source
     67
     68    psStringPrepend(&version, "psModules version: ");
     69    psStringPrepend(&source, "psModules source: ");
     70
     71    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version);
     72    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source);
     73
     74    psFree(version);
     75    psFree(source);
     76
     77    return true;
    2878}
  • branches/cnb_branches/cnb_branch_20090301/psModules/src/config/pmVersion.h

    r12696 r23351  
    11/*  @file pmVersion.h
    22 *  @brief Version functions
    3  * 
     3 *
    44 *  @author Paul Price, IfA
    55 *  @author Eugene Magnier, IfA
    6  * 
     6 *
    77 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    88 *  @date $Date: 2007-03-30 21:12:56 $
     
    2222 *  @return psString: String with version name.
    2323 */
    24 psString psModulesVersion(
    25     void
    26 );
     24psString psModulesVersion(void);
     25
     26/** Get current psModules source
     27 *
     28 *  Returns the current psModules source as a string.
     29 *
     30 *  @return psString: String with source.
     31 */
     32psString psModulesSource(void);
    2733
    2834/** Get current psModules version (full identification)
     
    3440psString psModulesVersionLong(void);
    3541
     42/// Populate a header with version information
     43bool psModulesVersionHeader(
     44    psMetadata *header                  ///< Header to populate
     45    );
     46
     47
    3648/// @}
    3749#endif
Note: See TracChangeset for help on using the changeset viewer.