00001 #include <iostream> 00002 #include <string> 00003 #include <vector> 00004 #include <time.h> 00005 00006 //IS stuff 00007 //#include <is/isinfotmpl.h> 00008 //#include <is/isnamedinfo.h> 00009 //#include <is/isinfoany.h> 00010 #include <is/info.h> 00011 #include <is/infodictionary.h> 00012 #include <is/infoiterator.h> 00013 #include <is/inforeceiver.h> 00014 #include <is/infoT.h> 00015 00016 #include <cmdl/cmdargs.h> 00017 00018 #include "sctddc/SCTDdcCommandSender.hxx" 00019 #include "sctddc/SCTDdcRequest.hxx" 00020 #include "sctddc/SCTDCSCommand.hxx" 00021 #include <ipc/core.h> 00022 #include <unistd.h> // for sleep(5) 00023 00024 int main(int argc, char *argv[]) 00025 { 00026 SCTDCSCommand* myDaq = NULL; 00027 int controllerNumber = (argc-3)/2; 00028 cerr << "We deal with " << controllerNumber << " controllers:" << endl; 00029 00030 CmdArgStr partition_name('p', "partition", "partition-name", "partition to work in.", CmdArg::isREQ); 00031 CmdArgStr ctrl1_name('c', "controller1", "controller-id", "controller to work with", CmdArg::isREQ); 00032 CmdArgStr ctrl2_name('M', "controller2", "controller-id", "controller to work with"); 00033 CmdArgStr ctrl3_name('N', "controller3", "controller-id", "controller to work with"); 00034 CmdArgStr ctrl4_name('O', "controller4", "controller-id", "controller to work with"); 00035 00036 // 00037 // Declare command object and its argument-iterator 00038 // 00039 CmdLine cmdLine(*argv, &partition_name, &ctrl1_name, &ctrl2_name, &ctrl3_name, &ctrl4_name, NULL); 00040 CmdArgvIter arg_iter(--argc, ++argv); 00041 00042 // 00043 // Parse arguments 00044 // 00045 cmdLine.parse(arg_iter); 00046 00047 string* ctrls[5]; 00048 ctrls[0] = new string((string)ctrl1_name); 00049 cerr << *ctrls[0] << endl; 00050 if(controllerNumber > 1) { 00051 ctrls[1] = new string((string)ctrl2_name); 00052 cerr << *ctrls[1] << endl; 00053 } 00054 if(controllerNumber > 2) { 00055 ctrls[2] = new string((string)ctrl3_name); 00056 cerr << *ctrls[2] << endl; 00057 } 00058 if(controllerNumber > 3) { 00059 ctrls[3] = new string((string)ctrl4_name); 00060 cerr << *ctrls[3] << endl; 00061 } 00062 ctrls[controllerNumber] = 0; 00063 00064 00065 #warning What under ILU was "IPCCore::init(true, false)" has been changed to "IPCCore::init(argc,argv)". Check that this ascribes the correct interpretation to true and false. [NB They probably do not correspond since these old arguments are likely to specify threading policy whereas under the new ORB threading policy is specified at the object level ... but still the chage is probably correct.] 00066 IPCCore::init(argc,argv); 00067 00068 IPCPartition testPartition((const char*)partition_name); 00069 00070 myDaq = new SCTDCSCommand(testPartition, ctrls); 00071 00072 //====================================================================================================== 00073 //======================================= Here are some tests ========================================== 00074 //====================================================================================================== 00075 00076 //****************************************************************************************************** 00077 //=============================== this is for barrel environement project ============================== 00078 //****************************************************************************************************** 00079 /* 00080 if(myDaq->openDCSControl("SCTbarr1", 1)) 00081 { 00082 //int sycle = 0; 00083 //while(sycle<1000) 00084 // { 00085 cout<<"=============== control got"<< endl; 00086 myDaq->setDPStatus("SCTbarr1:HVol.Stat", 0x14, 5); 00087 // sycle++; 00088 // } 00089 //....... 00090 myDaq->closeDCSControl("SCTbarr1", 5); 00091 } 00092 else 00093 { 00094 cout << "DDC ERROR: access to DCS control failled"<<endl; 00095 } 00096 while(1) 00097 { 00098 cout<<"=============== finised"<< endl; 00099 #warning LESTER wants to know: "Is this loop REALLY designed to output the word 'finished' endlessly ??" 00100 sleep(5); 00101 } 00102 */ 00103 //****************************************************************************************************** 00104 //=========================================== Test for IV curve ======================================= 00105 //****************************************************************************************************** 00106 //the following parameters, for instance, are meaningless!! 00107 // myDaq->requestIVCurve(0, 0, 0, 100, 10, 0, 10, 4, 3, 5); 00108 //****************************************************************************************************** 00109 //================================== this is for power supply project ================================= 00110 //****************************************************************************************************** 00111 00112 //======================================= Set Channel parameters ============================ 00113 /* 00114 //set one variable in a channel 00115 string ch_para("LVch_Vcc"); 00116 00117 for(int icrate=0; icrate<1; icrate++) 00118 { 00119 float value = 15.0; 00120 for(int ichannel=0; ichannel<3; ichannel++) 00121 { 00122 myDaq->setChannelParameter(icrate, ichannel, ch_para, value, 5); 00123 value = value + 10; 00124 } 00125 } 00126 00127 //set several variables in a channel 00128 std::map<string, float> ch_dpeNamesAnddpeValues; 00129 ch_dpeNamesAnddpeValues["LVch_Vcc"] = 22; 00130 ch_dpeNamesAnddpeValues["LVch_Vdd"] = 23; 00131 ch_dpeNamesAnddpeValues["LVchPINV"] = 24; 00132 ch_dpeNamesAnddpeValues["LVchDTrp"] = 25; 00133 myDaq->setChannelParameters(0, 0, ch_dpeNamesAnddpeValues, 5); 00134 */ 00135 //======================================= Set Card parameters ============================ 00136 /* 00137 //set one variable in a card 00138 string ca_para("LVcaTrip"); 00139 00140 for(int icrate=0; icrate<1; icrate++) 00141 { 00142 float value = 15.0; 00143 for(int icard=0; icard<3; icard++) 00144 { 00145 myDaq->setCardParameter(icrate, icard, ca_para, value, 5); 00146 value = value + 10; 00147 } 00148 } 00149 00150 //set several variables in a card 00151 std::map<string, float> ca_dpeNamesAnddpeValues; 00152 00153 ca_dpeNamesAnddpeValues["LVcaTrip"] = 42; 00154 ca_dpeNamesAnddpeValues["LVcaMask"] = 43; 00155 myDaq->setCardParameters(0, 0, ca_dpeNamesAnddpeValues, 5); 00156 */ 00157 //======================================= Set Crate Controllers parameters ============================ 00158 /* 00159 //set one variable in a crate 00160 string cr_para("CC_Reset"); 00161 float cr_value = 15; 00162 for(int icrate=0; icrate<2; icrate++) 00163 { 00164 myDaq->setCrateCtrlParameter(icrate, cr_para, cr_value, 5); 00165 cr_value = cr_value + 10; 00166 } 00167 00168 //set several variables in a crate 00169 std::map<string, float> cr_dpeNamesAnddpeValues; 00170 00171 cr_dpeNamesAnddpeValues["CC_Reset"] = 52; 00172 cr_dpeNamesAnddpeValues["CCch_Set"] = 53; 00173 cr_dpeNamesAnddpeValues["CCchRead"] = 54; 00174 myDaq->setCrateCtrlParameters(0, cr_dpeNamesAnddpeValues, 5); 00175 //myDaq->setCrateCtrlParameters(1, cr_dpeNamesAnddpeValues, 5); 00176 */ 00177 //======================================= Read Channel parameters ============================ 00178 00179 // int variables 00180 string dpeNameInt("LVchStat"); 00181 int dpeValueInt = 0; 00182 myDaq->getChannelParameter(0, 0, dpeNameInt, dpeValueInt, 10); 00183 cout<<"=========== channel dpeValueInt = "<<dpeValueInt<<endl; 00184 /* 00185 //float variables 00186 std::vector<string> ch_dpeNames; 00187 ch_dpeNames.push_back(string("LVch_Vcc")); 00188 ch_dpeNames.push_back(string("LVps_Vcc")); 00189 ch_dpeNames.push_back(string("LVretVcc")); 00190 ch_dpeNames.push_back(string("LVch_Icc")); 00191 00192 std::map<string, float> ch_dpeValues; 00193 myDaq->getChannelParameters(0, 0, ch_dpeNames, ch_dpeValues, 10); 00194 map<string, float>::const_iterator map_itr; 00195 int ch_i = 0; 00196 float ch_dpeValue = 9999.9; 00197 for(map_itr=ch_dpeValues.begin(); map_itr!=ch_dpeValues.end(); map_itr++) 00198 { 00199 cout<<"========= ch_map1: "<<map_itr->first<<'\t'<<map_itr->second<<endl; 00200 myDaq->getChannelParameter(0, 0, ch_dpeNames[ch_i], ch_dpeValue, 10); ch_i++; 00201 cout<<"========= ch_map2: "<<ch_dpeValue<<endl; 00202 } 00203 */ 00204 //string variables 00205 00206 //======================================== read Card parameters ================================ 00207 /* 00208 // int variables 00209 dpeNameInt = "LVcaStat"; 00210 dpeValueInt = 0; 00211 myDaq->getCardParameter(0, 0, dpeNameInt, dpeValueInt, 10); 00212 cout<<"=========== card dpeValueInt = "<<dpeValueInt<<endl; 00213 00214 // float variables 00215 std::vector<string> ca_dpeNames; 00216 //ca_dpeNames.push_back(string("LVcaStat")); 00217 //ca_dpeNames.push_back(string("LVcaTemp")); 00218 //ca_dpeNames.push_back(string("LVcaPowr")); 00219 ca_dpeNames.push_back(string("HVcaStat")); 00220 00221 std::map<string, float> ca_dpeValues; 00222 myDaq->getCardParameters(0, 0, ca_dpeNames, ca_dpeValues, 10); 00223 //map<string, float>::const_iterator map_itr; 00224 int ca_i = 0; 00225 float ca_dpeValue = 9999.9; 00226 for(map_itr=ca_dpeValues.begin(); map_itr!=ca_dpeValues.end(); map_itr++) 00227 { 00228 cout<<"========= ca_map1: "<<map_itr->first<<'\t'<<map_itr->second<<endl; 00229 myDaq->getCardParameter(0, 0, ca_dpeNames[ca_i], ca_dpeValue, 10); ca_i++; 00230 cout<<"========= ca_map2: "<<ca_dpeValue<<endl; 00231 } 00232 */ 00233 //================================ read Crate controller parameters ============================ 00234 /* 00235 //read send value 00236 std::vector<string> ctrl_dpeNames; 00237 ctrl_dpeNames.push_back(string("CC_Reset")); 00238 ctrl_dpeNames.push_back(string("CCch_Set")); 00239 ctrl_dpeNames.push_back(string("CCchRead")); 00240 00241 std::map<string, float> ctrl_dpeValues; 00242 myDaq->getCrateCtrlParameters(0, ctrl_dpeNames, ctrl_dpeValues, 10, "Send"); 00243 int ctrl_i = 0; 00244 float ctrl_dpeValue = 9999.9; 00245 //map<string, float>::const_iterator map_itr; 00246 for(map_itr=ctrl_dpeValues.begin(); map_itr!=ctrl_dpeValues.end(); map_itr++) 00247 { 00248 cout<<"=========1 ctrl_Send: "<<map_itr->first<<'\t'<<map_itr->second<<endl; 00249 myDaq->getCrateCtrlParameter(0, ctrl_dpeNames[ctrl_i], ctrl_dpeValue, 10, "Send"); 00250 ctrl_i++; 00251 cout<<"=========2 ctrl_Send: "<<ctrl_dpeValue<<endl; 00252 } 00253 */ 00254 //======================================= read Crate parameters ================================ 00255 /* 00256 // int variables 00257 dpeNameInt = "Stat"; 00258 dpeValueInt = 0; 00259 myDaq->getCrateParameter(0, dpeNameInt, dpeValueInt, 10); 00260 cout<<"=========== crate dpeValueInt = "<<dpeValueInt<<endl; 00261 00262 // float variables 00263 std::vector<string> cr_dpeNames; 00264 cr_dpeNames.push_back(string("Stat")); 00265 00266 std::map<string, float> cr_dpeValues; 00267 myDaq->getCrateParameters(0, cr_dpeNames, cr_dpeValues, 10); 00268 int cr_i = 0; 00269 float cr_dpeValue = 9999.9; 00270 //map<string, float>::const_iterator map_itr; 00271 for(map_itr=cr_dpeValues.begin(); map_itr!=cr_dpeValues.end(); map_itr++) 00272 { 00273 cout<<"========= cr_map: "<<map_itr->first<<'\t'<<map_itr->second<<endl; 00274 myDaq->getCrateParameter(0, cr_dpeNames[cr_i], cr_dpeValue, 10); cr_i++; 00275 cout<<"========= cr_map2: "<<cr_dpeValue<<endl; 00276 } 00277 00278 */ 00279 //======================================= IV Curve Data============================================ 00280 /* 00281 float* float_array; 00282 int array_size; 00283 cout<<"==================================IV Curve 1"<<endl; 00284 myDaq->getIVCurveData(float_array, array_size, 20); 00285 cout<<"================================== array_size = "<< array_size <<endl; 00286 for(int i=0; i<array_size; i++) 00287 { 00288 cout<<"==================================float_array1 = "<< float_array[i]<<endl; 00289 } 00290 */ 00291 //========================== change state, load config and hard reset ============================= 00292 /* 00293 myDaq->changeState(0, 0, 33, 5); 00294 sleep(3); 00295 myDaq->changeState(0, "ALL", 33, 5); 00296 sleep(3); 00297 //load configuration constants for all channels in a given crate 00298 myDaq->loadConfiguration(0, 44, 5); 00299 sleep(3); 00300 //reset one module ( correponding to a channel in a PS crate) 00301 sleep(3); 00302 myDaq->hardReset(0, 26, 5); 00303 sleep(3); 00304 //reset 48 modules ( correponding to all channels in a PS crate) 00305 myDaq->hardReset(0, "ALL", 5); 00306 */ 00307 00308 //======================== change the slect line for a given crate channels ======================== 00309 myDaq->setChannelsSelectLine(0, 0, 60); 00310 sleep(15); 00311 myDaq->setChannelsSelectLine(0, 1, 60); 00312 //======================================= Read from IS ============================================ 00313 00314 //this is a test for a method that read the a varible from an IS server.. the query of this is done 00315 //via configuration file (may be useful when the required varibles are know at configuration time!) 00316 00317 float value_float = 9999.9; 00318 myDaq->readFromIS("Crate00.Channel00.MOch_Tm0.Recv", value_float); 00319 //myDaq->run(ctrls); 00320 00321 //this loop is to the program alife 00322 while(true) 00323 { 00324 cout<<"=========== value_float2 = "<<value_float<<endl; 00325 sleep(4); 00326 } 00327 00328 delete myDaq; 00329 00330 for(int i=0; ctrls[i] != 0; i++) 00331 free(ctrls[i]); 00332 00333 return(0); 00334 }