cdi_set_conditions.cxx

00001 
00002 //    cdi_set_condition  
00003 //
00004 //    Application to set up CDI with the proper ISServers.Information
00005 //    that will be used to store data in the ConditionsDatabaes
00006 //
00007 //    Luís Pedro,  March 2004
00008 //    Nuno Barros, January 2005
00009 //
00010 //    description:
00011 //          Set up the IS information RunParams.Conditions with the 
00012 //          Informations to be stored in the Conditions Database
00013 //          By default RunParams.RunParams and RunParams.RunInfo
00014 //      
00016 
00017 #include <unistd.h>
00018 #include <iostream>
00019 #include <ipc/partition.h>
00020 #include <ipc/core.h>
00021 #include <cmdl/cmdargs.h>
00022 #include <list>
00023 #include "rc/Conditions.h"
00024 //changes after new IS api
00025 #include <is/infodictionary.h>
00026 
00027 int main(int argc, char ** argv)
00028 {
00029   IPCCore::init(argc, argv);
00030     
00031   // Declare arguments
00032    CmdArgStr            partition_name('p', "partition", "partition-name", "partition to work in.", CmdArg::isREQ);
00033    CmdArgInt            verb_level('v', "verbose", "verbosity-level", "0:Silent, 1:Normal, 2:Trace (defaults to 0).");
00034    //   CmdArgStr            backend('B',"backend","Choose the ConditionsDB API (COOL,CONDDB)");
00035    CmdArgStrList    isexpr('I', "isnames", "is-names", "list of ISServer.ISInformation names to be taken by CDI.", 
00036                    CmdArg::isREQ | CmdArg::isLIST);
00037          
00038    CmdLine  cmd(*argv, &partition_name, &verb_level/*, &backend */, &isexpr,NULL);
00039    CmdArgvIter  arg_iter(--argc, ++argv);
00040                 
00041    cmd.description("This program implements the functionality to store IS the name of IServers and its\n"
00042            "Informations (ISServers.ISInformation) in the RunParams.Conditions Information.\n"
00043            "The RunParams.Conditions information will then be used by cdi_daq to collect data\n"
00044            "to the Conditions Database.\n");
00045    
00046    verb_level=0;
00047    cmd.parse(arg_iter); 
00048         
00049    IPCPartition     p(partition_name);
00050    ISInfoDictionary dict(p); 
00051   
00052    Conditions conditions;
00053    
00054    for( size_t i = 0; i < isexpr.count(); i++ )
00055      conditions.isservers.push_back( std::string(isexpr[i]) );
00056    
00057    ISInfo::Status s = dict.insert( "RunParams.Conditions", conditions );
00058    
00059    if ( s == ISInfo::AlreadyExist )
00060      {
00061        s = dict.update( "RunParams.Conditions", conditions );
00062      }
00063    
00064    if (s!=ISInfo::Success) {
00065      // let's try to get more information
00066      switch (s) {
00067      case ISInfo::CommFailure:
00068        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: CommFailure !" << std::endl;
00069        break;
00070         // nbarros new additions
00071      case ISInfo::NotFound:
00072        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: NotFound !" << std::endl;
00073        break;
00074      case ISInfo::InvalidInfo:
00075        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: InvalidInfo !" << std::endl;
00076        break;
00077      case ISInfo::IncompatibleType:
00078        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: IncompatibleType !" << std::endl;
00079        break;
00080      case ISInfo::InvalidCriteria:
00081        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: InvalidExpression !" << std::endl;
00082        break;
00083      case ISInfo::RepositoryNotFound:
00084        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: RepositoryNotFound !" << std::endl;
00085        break;
00086      case ISInfo::ProviderNotFound:
00087        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: ProviderNotFound !" << std::endl;
00088        break;
00089      case ISInfo::InvalidName:
00090        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: InvalidName !" << std::endl;
00091        break;
00092      default:
00093        std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: Unknown error !" << std::endl;
00094        break;
00095      }
00096    }
00097    return !(s==ISInfo::Success);
00098    //return s;
00099 }

Generated on Mon Feb 6 14:01:17 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6