00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00025 #include <is/infodictionary.h>
00026
00027 int main(int argc, char ** argv)
00028 {
00029 IPCCore::init(argc, argv);
00030
00031
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
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, &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
00066 switch (s) {
00067 case ISInfo::CommFailure:
00068 std::cout << OWLTime() << "Inserting/Update \"RunParams.Conditions\" FAILED: CommFailure !" << std::endl;
00069 break;
00070
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
00099 }