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

SctApiDDC.cxx

00001 
00007 using namespace std;
00008 #include <vector>
00009 // This needs using std before it!
00010 #include "sctddc/SCTDCSCommand.hxx"
00011 
00012 #include "sctConf/configuration.h"
00013 
00014 #include "SctApi.h"
00015 
00016 #include "utility.h"
00017 using namespace SctApi::Utility;
00018 
00019 namespace SctApi {
00020 
00021 void SctApi::initDDC() 
00022 {
00023   // Initialise DDC command
00024   ddcPartition = new IPCPartition("SCT");
00025   ddcCtrls[0] = new string("ddc_ct1");
00026   ddcCtrls[1] = 0;
00027 
00028   ddcCmd = new SCTDCSCommand(*ddcPartition, ddcCtrls);
00029 }
00030 
00031 void SctApi::requestHardResetAll() 
00032 {
00033   cout << "Unimplemented!\n";
00034 }
00035 
00036 void SctApi::requestHardReset(UINT32 mid)
00037 {
00038   unsigned int MUR, module;
00039 
00040   unsigned int partition, crate, rod, channel;
00041   getpcrc(mid, partition, crate, rod, channel);
00042 
00043   config->translateFromROD(partition, crate, rod, channel,
00044                            MUR, module);
00045 
00046   unsigned int ppartition, pcrate, pchannel;
00047 
00048   config->translateToPowerSupply(MUR, module, 
00049                                  ppartition, pcrate, pchannel);
00050 
00051   std::cout << "Should do hard reset on module in " 
00052             << " partition: " << ppartition 
00053             << " crate: " << pcrate 
00054             << " channel: " << pchannel << std::endl;
00055 }
00056 
00057 void SctApi::requestIVCurve(UINT32 mid, FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim)
00058 {
00059   log << "requestIVCurve: " << mid << ", " << start << ", " << stop << ", " 
00060       << step << " " << delay << " " << currentLim << std::endl;
00061 
00062   unsigned int MUR, module;
00063 
00064   unsigned int partition, crate, rod, channel;
00065   getpcrc(mid, partition, crate, rod, channel);
00066 
00067   config->translateFromROD(partition, crate, rod, channel,
00068                            MUR, module);
00069 
00070   unsigned int ppartition, pcrate, pchannel;
00071 
00072   config->translateToPowerSupply(MUR, module, 
00073                                  ppartition, pcrate, pchannel);
00074 
00075   if(!ddcCmd) initDDC();
00076 
00077   log << "ddc->requestIVCurve: " << crate << ", " << channel 
00078       << ", " << start << ", " << stop << ", " << step 
00079       << " " << 0 << " " << currentLim << " " << delay << " 10" << std::endl;
00080 
00081 #warning "End voltage and current should be changeable"
00082   float Vend = 0.0;
00083   float Iwarn = currentLim;
00084 
00085   bool result = ddcCmd->requestIVCurve(crate, channel, start, stop, step, Vend, 
00086                                        Iwarn, currentLim, delay, 10);
00087 
00088   log << "iv curve success got: " << result << std::endl;
00089   
00090 }
00091 
00092 void SctApi::requestIVCurveAll(FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim)
00093 {
00094 }
00095 
00096 
00097 void SctApi::setSelect(UINT32 mid, bool value)
00098 {
00099   unsigned int MUR, module;
00100 
00101   unsigned int partition, crate, rod, channel;
00102   getpcrc(mid, partition, crate, rod, channel);
00103 
00104   config->translateFromROD(partition, crate, rod, channel,
00105                            MUR, module);
00106 
00107   unsigned int ppartition, pcrate, pchannel;
00108 
00109   config->translateToPowerSupply(MUR, module, 
00110                                  ppartition, pcrate, pchannel);
00111 
00112   ddcSetChannelParameter(pcrate, pchannel, "LVchCLKS", value?1.0:0.0);
00113 }
00114 
00115 void SctApi::setSelectAllInCrate(int crate, bool value, int timeout)
00116 {
00117   if(!ddcCmd) initDDC();
00118 
00119   ddcCmd->setChannelsSelectLine(crate, value, timeout);
00120 }
00121 
00122 void SctApi::changeRunState(int state)
00123 {
00124   throw SctApiException("changeRunState not implemented!");
00125 }
00126 
00127 // void SctApi::ddcGetChannelParameter(int crate, int channel, string dpeName,
00128 //                                     int& dpeValue, int timeout) 
00129 // {
00130 //   log << "ddcGetChannelParameter: " << crate << ", " << channel << ", (" << dpeName << "), " << dpeName.size() << " " << timeout << std::endl;
00131 
00132 //   if(!ddcCmd) initDDC();
00133 
00134 //   ddcCmd->getChannelParameter(crate, channel, dpeName, dpeValue, timeout);
00135 
00136 //   log << "channel parameter got: " << dpeValue << std::endl;
00137 // }
00138 
00139 void SctApi::ddcChangeState (int crate, int channel, short state, int timeout) 
00140 {
00141   if(!ddcCmd) initDDC();
00142 
00143   ddcCmd->changeState(crate, channel, state, timeout);
00144 }
00145 
00146 void SctApi::ddcChangeStateAll (int crate, short state, int timeout)
00147 {
00148   if(!ddcCmd) initDDC();
00149 
00150   ddcCmd->changeState(crate, "all", state, timeout);
00151 }
00152 
00153 void SctApi::ddcLoadConfiguration (int crate, short state, int timeout)
00154 {
00155   if(!ddcCmd) initDDC();
00156 
00157   ddcCmd->loadConfiguration(crate, state, timeout);
00158 }
00159 
00160 void SctApi::ddcHardReset (int crate, int channel, int timeout)
00161 {
00162   if(!ddcCmd) initDDC();
00163 
00164   ddcCmd->hardReset(crate, channel, timeout);
00165 }
00166 
00167 void SctApi::ddcHardResetAll (int crate, int timeout)
00168 {
00169   if(!ddcCmd) initDDC();
00170 
00171   ddcCmd->hardReset(crate, "all", timeout);
00172 }
00173 
00174 int SctApi::ddcGetChannelParameterInt (int crate, int channel, string name, int timeout)
00175 {
00176   log << "ddcGetChannelParameterInt: " << crate << ", " << channel 
00177       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00178 
00179   if(!ddcCmd) initDDC();
00180 
00181   int dpeValue;
00182   ddcCmd->getChannelParameter(crate, channel, name, dpeValue, timeout);
00183   log << "channel parameter got: " << dpeValue << std::endl;
00184 
00185   return dpeValue;
00186 }
00187 
00188 float SctApi::ddcGetChannelParameterFloat (int crate, int channel, string name, int timeout)
00189 {
00190   log << "ddcGetChannelParameterFloat: " << crate << ", " << channel 
00191       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00192 
00193   if(!ddcCmd) initDDC();
00194 
00195   float dpeValue;
00196   ddcCmd->getChannelParameter(crate, channel, name, dpeValue, timeout);
00197   log << "channel parameter got: " << dpeValue << std::endl;
00198 
00199   return dpeValue;
00200 }
00201 
00202 string SctApi::ddcGetChannelParameterString (int crate, int channel, string name, int timeout)
00203 {
00204   log << "ddcGetChannelParameterString: " << crate << ", " << channel 
00205       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00206 
00207   if(!ddcCmd) initDDC();
00208 
00209   string dpeValue;
00210   ddcCmd->getChannelParameter(crate, channel, name, dpeValue, timeout);
00211   log << "channel parameter got: " << dpeValue << std::endl;
00212 
00213   return dpeValue;
00214 }
00215 
00216 int SctApi::ddcGetCardParameterInt (int crate, int card, string name, int timeout)
00217 {
00218   log << "ddcGetCardParameterInt: " << crate << ", " << card 
00219       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00220 
00221   if(!ddcCmd) initDDC();
00222 
00223   int dpeValue;
00224   ddcCmd->getCardParameter(crate, card, name, dpeValue, timeout);
00225   log << "card parameter got: " << dpeValue << std::endl;
00226 
00227   return dpeValue;
00228 }
00229 
00230 float SctApi::ddcGetCardParameterFloat (int crate, int card, string name, int timeout)
00231 {
00232   log << "ddcGetCardParameterFloat: " << crate << ", " << card 
00233       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00234 
00235   if(!ddcCmd) initDDC();
00236 
00237   float dpeValue;
00238   ddcCmd->getCardParameter(crate, card, name, dpeValue, timeout);
00239   log << "card parameter got: " << dpeValue << std::endl;
00240 
00241   return dpeValue;
00242 }
00243 
00244 string SctApi::ddcGetCardParameterString (int crate, int card, string name, int timeout)
00245 {
00246   log << "ddcGetCardParameterString: " << crate << ", " << card 
00247       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00248 
00249   if(!ddcCmd) initDDC();
00250 
00251   string dpeValue;
00252   ddcCmd->getCardParameter(crate, card, name, dpeValue, timeout);
00253   log << "card parameter got: " << dpeValue << std::endl;
00254 
00255   return dpeValue;
00256 }
00257 
00258 int SctApi::ddcGetCrateParameterInt (int crate, string name, int timeout)
00259 {
00260   log << "ddcGetCrateParameterInt: " << crate 
00261       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00262 
00263   if(!ddcCmd) initDDC();
00264 
00265   int dpeValue;
00266   ddcCmd->getCrateCtrlParameter(crate, name, dpeValue, timeout);
00267   log << " crate parameter got: " << dpeValue << std::endl;
00268 
00269   return dpeValue;
00270 }
00271 
00272 float SctApi::ddcGetCrateParameterFloat (int crate, string name, int timeout)
00273 {
00274   log << "ddcGetCrateParameterFloat: " << crate 
00275       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00276 
00277   if(!ddcCmd) initDDC();
00278 
00279   float dpeValue;
00280   ddcCmd->getCrateCtrlParameter(crate, name, dpeValue, timeout);
00281   log << " crate parameter got: " << dpeValue << std::endl;
00282 
00283   return dpeValue;
00284 }
00285 
00286 string SctApi::ddcGetCrateParameterString (int crate, string name, int timeout)
00287 {
00288   log << "ddcGetCrateParameterString: " << crate 
00289       << ", (" << name << "), " << name.size() << " " << timeout << std::endl;
00290 
00291   if(!ddcCmd) initDDC();
00292 
00293   string dpeValue;
00294   ddcCmd->getCrateCtrlParameter(crate, name, dpeValue, timeout);
00295   log << " crate parameter got: " << dpeValue << std::endl;
00296 
00297   return dpeValue;
00298 }
00299 
00300 void SctApi::ddcGetCrateParameters(int crate, std::vector<std::string> names, 
00301                                    std::map<std::string, float>& nameValues, int timeout)
00302 {
00303   log << "ddcGetCrateParameters: " << crate << " " << timeout << std::endl;
00304   if(!ddcCmd) initDDC();
00305 
00306   ddcCmd->getCrateParameters(crate, names, nameValues, timeout);
00307 }
00308 
00309 void SctApi::ddcSetChannelParameter (int crate, int channel, std::string name, float value, int timeout)
00310 {
00311   log << "ddcSetChannelParameter: " << crate << " " << channel
00312       << ", (" << name << "), " << value << " " << timeout << std::endl;
00313 
00314   if(!ddcCmd) initDDC();
00315 
00316   ddcCmd->setChannelParameter(crate, channel, name, value, timeout);
00317 }
00318 
00319 void SctApi::ddcSetCardParameter (int crate, int card, std::string name, float value, int timeout)
00320 {
00321   log << "ddcSetCardParameter: " << crate << " " << card
00322       << ", (" << name << "), " << value << " " << timeout << std::endl;
00323 
00324   if(!ddcCmd) initDDC();
00325 
00326   ddcCmd->setCardParameter(crate, card, name, value, timeout);
00327 }
00328 
00329 void SctApi::ddcSetCrateParameter (int crate, std::string name, float value, int timeout)
00330 {
00331   log << "ddcSetCrateParameter: " << crate 
00332       << ", (" << name << "), " << value << " " << timeout << std::endl;
00333 
00334   if(!ddcCmd) initDDC();
00335 
00336   ddcCmd->setCrateCtrlParameter(crate, name, value, timeout);
00337 }
00338 
00339 }

Generated on Thu Feb 3 17:37:42 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5