Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

ddc_sendcmd.cxx

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

Generated on Fri Sep 16 18:01:50 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5