00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #define RPS_PORT0_BIT0 0x01
00013 #define RPS_MAINALARM 0x01
00014 #define RPS_PORT0_BIT1 0x02
00015 #define RPS_MAINWARN 0x02
00016 #define RPS_PORT0_BIT2 0x04
00017 #define RPS_VMONALARM 0x04
00018 #define RPS_PORT0_BIT3 0x08
00019 #define RPS_VMONWARN 0x08
00020 #define RPS_PORT0_BIT4 0x10
00021 #define RPS_EXTALARM 0x10
00022 #define RPS_PORT0_BIT5 0x20
00023 #define RPS_SMOKEALARM 0x20
00024 #define RPS_PORT0_BIT6 0x40
00025 #define RPS_VMONID_BIT0 0x40
00026 #define RPS_PORT0_BIT7 0x80
00027 #define RPS_FANFAIL 0x80
00028
00029 #define RPS_PORT1_BIT0 0x01
00030 #define RPS_H2OFLOWWARN 0x01
00031 #define RPS_PORT1_BIT1 0x02
00032 #define RPS_H2OFLOWALARM 0x02
00033 #define RPS_PORT1_BIT2 0x04
00034 #define RPS_H2OTEMPWARN 0x04
00035 #define RPS_PORT1_BIT3 0x08
00036 #define RPS_H2OTEMPALARM 0x08
00037 #define RPS_PORT1_BIT4 0x10
00038 #define RPS_EXTTEMP 0x10
00039 #define RPS_PORT1_BIT5 0x20
00040 #define RPS_AIRTEMPDIFFWARN 0x20
00041 #define RPS_PORT1_BIT6 0x40
00042 #define RPS_VMONID_BIT1 0x40
00043 #define RPS_PORT1_BIT7 0x80
00044 #define RPS_AIRTEMPALARM 0x80
00045
00046 #define RPS_PORT2_BIT0 0x01
00047 #define RPS_VMONID_BIT2 0x01
00048 #define RPS_PORT2_BIT1 0x02
00049 #define RPS_AIRFLOWOUT 0x02
00050 #define RPS_PORT2_BIT2 0x04
00051 #define RPS_AIRTEMPDIFFALARM 0x04
00052 #define RPS_PORT2_BIT3 0x08
00053 #define RPS_H2OLEAK 0x08
00054 #define RPS_PORT2_BIT4 0x10
00055 #define RPS_AIRTEMPWARN 0x10
00056 #define RPS_PORT2_BIT5 0x20
00057 #define RPS_HUMIDITY 0x20
00058 #define RPS_PORT2_BIT6 0x40
00059 #define RPS_VMONID_BIT3 0x40
00060 #define RPS_PORT2_BIT7 0x80
00061 #define RPS_AIRFLOWIN 0x80
00062
00063 #define RPS_PORT3_BIT0 0x01
00064 #define RPS_ALARMSILENCE 0x01
00065 #define RPS_PORT3_BIT1 0x02
00066 #define RPS_CLEARDISPLAY 0x02
00067 #define RPS_PORT3_BIT2 0x04
00068 #define RPS_OUTPUTRESET 0x04
00069 #define RPS_PORT3_BIT3 0x08
00070 #define RPS_SMOKERESET 0x08
00071 #define RPS_PORT3_BIT4 0x10
00072 #define RPS_VACRESET 0x10
00073 #define RPS_PORT3_BIT5 0x20
00074 #define RPS_SYSRESET1 0x20
00075 #define RPS_PORT3_BIT6 0x40
00076 #define RPS_SYSRESET2 0x40
00077 #define RPS_PORT3_BIT7 0x80
00078 #define RPS_SYSRESET3 0x80
00079
00080 #include "RawData/RawDcsRpsMonitorBlock.h"
00081
00082 UInt_t RawDcsRpsMonitorBlock::fgDebugFlags = 0;
00083
00084 #include "MessageService/MsgService.h"
00085 CVSID("$Id: RawDcsRpsMonitorBlock.cxx,v 1.8 2003/07/14 18:19:43 ebeall Exp $");
00086 #include "MessageService/MsgFormat.h"
00087
00088 #include "RawData/RawBlockRegistry.h"
00089 REGISTERRAWBLOCK(RawDcsRpsMonitorBlock,kMdBlockDcsRpsMonitor,kMdBlockSourceDcs);
00090
00091 ClassImp(RawDcsRpsMonitorBlock)
00092
00093 enum EDcsRpsMonitorBlkPos {
00094 indx_size = 0,
00095 indx_checksum = 1,
00096 indx_blockid = 2,
00097 zzzz_last = 3
00098 };
00099
00100 typedef enum {
00101 GREEN,
00102 YELLOW,
00103 RED,
00104 BLACK
00105 } rpsstatus;
00106
00107 rpsstatus rps_translate(unsigned char diodata[], char* linestring, unsigned short *vmon_id );
00108
00109 char initstring[1024];
00110
00111
00112 RawDcsRpsMonitorBlock::RawDcsRpsMonitorBlock()
00113 {
00114
00115 }
00116
00117
00118 RawDcsRpsMonitorBlock::RawDcsRpsMonitorBlock(const Int_t *block)
00119 : RawDataBlock(block)
00120 {
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 }
00140
00141
00142 RawDcsRpsMonitorBlock::~RawDcsRpsMonitorBlock()
00143 {
00144
00145 }
00146
00147
00148 std::ostream& RawDcsRpsMonitorBlock::FormatToOStream(ostream& os,
00149 Option_t *option) const
00150 {
00151 RawDataBlock::FormatToOStream(os,option);
00152 if (option[0] == 'X') return os;
00153
00154 Int_t numEntries=GetNumEntries();
00155 os << " Number of Entries " << numEntries
00156 << " Number of Events " << GetNumEvents() << endl;
00157 for(Int_t i = 0; i < numEntries; i++)
00158 {
00159 os << "Timestamp " << GetTimeStamp(i).AsString("c")
00160 << " Rack number " << GetRackNumber(i) << " unpacked data "
00161 << GetUnpackedRpsStruct(i) << " Status " << GetStatus(i) << endl
00162 << " String info " << GetRpsString(i) << endl;
00163 }
00164 return os;
00165 }
00166
00167 void RawDcsRpsMonitorBlock::FillRpsArray() const
00168 {
00169
00170
00171 RpsArray = 3 + GetData();
00172 }
00173
00174 Int_t RawDcsRpsMonitorBlock::GetNumEntries() const
00175 {
00176
00177
00178 if((fSize-3)%4)
00179 {
00180 MSG("RawData",Msg::kError)
00181 << " Size of Rps Block screwed up. Have: "
00182 << (fSize-3)%4 << " left over from modulo 4."
00183 << endl;
00184 return -1;
00185 }
00186 return ((fSize-3)/4);
00187 }
00188
00189 Int_t RawDcsRpsMonitorBlock::GetNumEvents() const
00190 {
00191 Int_t numEvents = 1;
00192 Int_t numEntries = GetNumEntries();
00193 FillRpsArray();
00194
00195
00196
00197
00198
00199 numEvents=numEntries;
00200 return numEvents;
00201 }
00202
00203 VldContext RawDcsRpsMonitorBlock::GetVldContext() const
00204 {
00205
00206 RawBlockId rbid = GetBlockId();
00207 return VldContext(rbid.GetDetector(),rbid.GetSimFlag(),GetTimeStamp(0));
00208 }
00209
00210 Int_t RawDcsRpsMonitorBlock::GetIsError(Int_t indx) const
00211 {
00212 Int_t mydata=GetUnpackedRpsStruct(indx);
00213 Int_t port0,port1,port2;
00214 port0=mydata&0xff;
00215 port1=(mydata>>8)&0xff;
00216 port2=(mydata>>16)&0xff;
00217 if((port0&RPS_MAINALARM)||(port0&RPS_VMONALARM)||(port0&RPS_SMOKEALARM)||(port0&RPS_EXTALARM)||(port1&RPS_EXTTEMP)||(port1&RPS_H2OFLOWALARM)||(port1&RPS_H2OTEMPALARM)||(port1&RPS_AIRTEMPALARM)||(port2&RPS_AIRFLOWOUT)||(port2&RPS_H2OLEAK)||(port2&RPS_AIRFLOWIN))
00218 return 1;
00219 return 0;
00220 }
00221
00222 Int_t RawDcsRpsMonitorBlock::GetIsWarning(Int_t indx) const
00223 {
00224 Int_t mydata=GetUnpackedRpsStruct(indx);
00225 Int_t port0,port1,port2;
00226 port0=mydata&0xff;
00227 port1=(mydata>>8)&0xff;
00228 port2=(mydata>>16)&0xff;
00229 if((port0&RPS_MAINWARN)||(port0&RPS_VMONWARN)||(port0&RPS_FANFAIL)||(port1&RPS_H2OFLOWWARN)||(port1&RPS_H2OTEMPWARN)||(port1&RPS_AIRTEMPDIFFWARN)||(port2&RPS_AIRTEMPWARN)||(port2&RPS_HUMIDITY))
00230 return 1;
00231 return 0;
00232 }
00233
00234 Int_t RawDcsRpsMonitorBlock::GetIsVoltageEvent(Int_t indx) const
00235 {
00236 Int_t mydata=GetUnpackedRpsStruct(indx);
00237 Int_t port0,port1,port2;
00238 port0=mydata&0xff;
00239 port1=(mydata>>8)&0xff;
00240 port2=(mydata>>16)&0xff;
00241 if((port0&RPS_VMONALARM)||(port0&RPS_VMONWARN))
00242 return 1;
00243 return 0;
00244 }
00245
00246 Int_t RawDcsRpsMonitorBlock::GetIsEnvEvent(Int_t indx) const
00247 {
00248 Int_t mydata=GetUnpackedRpsStruct(indx);
00249 Int_t port0,port1,port2;
00250 port0=mydata&0xff;
00251 port1=(mydata>>8)&0xff;
00252 port2=(mydata>>16)&0xff;
00253 if((port0&RPS_SMOKEALARM)||(port0&RPS_FANFAIL)||(port1&RPS_H2OFLOWWARN)||(port1&RPS_H2OFLOWALARM)||(port1&RPS_AIRTEMPDIFFWARN)||(port1&RPS_AIRTEMPALARM)||(port2&RPS_AIRTEMPDIFFALARM)||(port2&RPS_AIRTEMPWARN)||(port2&RPS_HUMIDITY)||(port2&RPS_AIRFLOWIN)||(port1&RPS_EXTTEMP))
00254 return 1;
00255 return 0;
00256 }
00257
00258 Int_t RawDcsRpsMonitorBlock::GetIsExternalEvent(Int_t indx) const
00259 {
00260 Int_t mydata=GetUnpackedRpsStruct(indx);
00261 Int_t port0,port1,port2;
00262 port0=mydata&0xff;
00263 port1=(mydata>>8)&0xff;
00264 port2=(mydata>>16)&0xff;
00265 if((port0&RPS_EXTALARM))
00266 return 1;
00267 return 0;
00268 }
00269
00270 Int_t RawDcsRpsMonitorBlock::GetIsCommandEvent(Int_t indx) const
00271 {
00272 Int_t mydata=GetUnpackedRpsStruct(indx);
00273 mydata=(mydata>>24)&0xff;
00274 if (mydata!=0)
00275 return 1;
00276 return 0;
00277 }
00278
00279 TString RawDcsRpsMonitorBlock::GetRpsString(Int_t indx) const
00280 {
00281 unsigned short vmon_id=0;
00282 unsigned char diodata[4];
00283 Int_t original=GetUnpackedRpsStruct(indx);
00284 memcpy(diodata,&original,4);
00285 rps_translate(diodata, initstring,&vmon_id);
00286 TString mystring(initstring);
00287 return mystring;
00288 }
00289
00290
00291
00292
00293
00294
00295 #include <stdio.h>
00296 #include <string.h>
00297
00298 rpsstatus rps_translate(unsigned char diodata[], char* linestring,
00299 unsigned short *vmon_id ) {
00300
00301
00302
00303 int vmon_set = 0;
00304 rpsstatus status = GREEN;
00305
00306
00307
00308
00309 linestring[0] = '\0';
00310
00311
00312
00313
00314 if (diodata[0] || diodata[1] || diodata[2]) {
00315 strcat(linestring," Alarms/warnings set: ");
00316
00317 if (diodata[0] & RPS_MAINALARM) {
00318 strcat(linestring,"(Main Alarm) ");
00319 status = RED;
00320 }
00321 if (diodata[0] & RPS_MAINWARN) {
00322 strcat(linestring,"(Main Warn) ");
00323 if (!status) status = YELLOW;
00324 }
00325 if (diodata[0] & RPS_VMONALARM) {
00326 strcat(linestring,"(Vmon Alarm) ");
00327 vmon_set = 1;
00328 status = RED;
00329 }
00330 if (diodata[0] & RPS_VMONWARN) {
00331 strcat(linestring,"(Vmon Warn) ");
00332 vmon_set = 1;
00333 if (!status) status = YELLOW;
00334 }
00335 if (diodata[0] & RPS_EXTALARM) {
00336 strcat(linestring,"(External Alarm) ");
00337 status = RED;
00338 }
00339 if (diodata[0] & RPS_SMOKEALARM) {
00340 strcat(linestring,"(Smoke Alarm) ");
00341 status = RED;
00342 }
00343 if (diodata[0] & RPS_VMONID_BIT0)
00344 *vmon_id |= 0x01;
00345 if (diodata[0] & RPS_FANFAIL) {
00346 strcat(linestring,"(Fan Failure) ");
00347 if (!status) status = YELLOW;
00348 }
00349
00350
00351 if (diodata[1] & RPS_H2OFLOWWARN) {
00352 strcat(linestring,"(H2O Flow Warn) ");
00353 if (!status) status = YELLOW;
00354 }
00355 if (diodata[1] & RPS_H2OFLOWALARM) {
00356 strcat(linestring,"(H2O Flow Alarm) ");
00357 status = RED;
00358 }
00359 if (diodata[1] & RPS_H2OTEMPWARN) {
00360 strcat(linestring,"(H2O Temp Warn) ");
00361 if (!status) status = YELLOW;
00362 }
00363 if (diodata[1] & RPS_H2OTEMPALARM) {
00364 strcat(linestring,"(H2O Temp Alarm) ");
00365 status = RED;
00366 }
00367 if (diodata[1] & RPS_EXTTEMP) {
00368 strcat(linestring,"(External Temp) ");
00369 status = RED;
00370 }
00371 if (diodata[1] & RPS_AIRTEMPDIFFWARN) {
00372 strcat(linestring,"(Air Temp Diff Warn) ");
00373 if (!status) status = YELLOW;
00374 }
00375 if (diodata[1] & RPS_VMONID_BIT1)
00376 *vmon_id |= 0x02;
00377 if (diodata[1] & RPS_AIRTEMPALARM) {
00378 strcat(linestring,"(Air Temp Alarm) ");
00379 status = RED;
00380 }
00381
00382
00383 if (diodata[2] & RPS_VMONID_BIT2)
00384 *vmon_id |= 0x04;
00385 if (diodata[2] & RPS_AIRFLOWOUT) {
00386 strcat(linestring,"(Air Flow Out) ");
00387 status = RED;
00388 }
00389 if (diodata[2] & RPS_AIRTEMPDIFFALARM)
00390 strcat(linestring,"(Air Temp Diff Alarm) ");
00391 if (diodata[2] & RPS_H2OLEAK) {
00392 strcat(linestring,"(H2O Leak) ");
00393 status = RED;
00394 }
00395 if (diodata[2] & RPS_AIRTEMPWARN) {
00396 strcat(linestring,"(Air Temp Warn) ");
00397 if (!status) status = YELLOW;
00398 }
00399 if (diodata[2] & RPS_HUMIDITY) {
00400 strcat(linestring,"(Humidity) ");
00401 if (!status) status = YELLOW;
00402 }
00403 if (diodata[2] & RPS_VMONID_BIT3)
00404 *vmon_id |= 0x08;
00405 if (diodata[2] & RPS_AIRFLOWIN) {
00406 strcat(linestring,"(Air Flow In) ");
00407 status = RED;
00408 }
00409
00410
00411 if (vmon_set) {
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 switch (*vmon_id & 0x7) {
00422 case 0 : strcat(linestring,"(+3.3V "); break;
00423 case 1 : strcat(linestring,"(+5V "); break;
00424 case 2 : strcat(linestring,"(+12V "); break;
00425 case 3 : strcat(linestring,"(-12V "); break;
00426 case 4 : strcat(linestring,"(+6V "); break;
00427 case 5 : strcat(linestring,"(-6V "); break;
00428 case 6 : strcat(linestring,"(+5VExt "); break;
00429 case 7 : strcat(linestring,"(-5VExt "); break;
00430 default: fprintf(stderr,"Case statement fallthru in rps_translate.c. If you see me it is a bug!!\n");
00431 }
00432
00433 if (*vmon_id & 0x8) {
00434 strcat(linestring,"Over) ");
00435 } else {
00436 strcat(linestring,"Under) ");
00437 }
00438 }
00439 }
00440
00441
00442 if (diodata[3]) {
00443 strcat(linestring,"\n Overrides set: ");
00444 if (diodata[3] & RPS_ALARMSILENCE)
00445 strcat(linestring,"(Alarm Silenced) ");
00446 if (diodata[3] & RPS_CLEARDISPLAY)
00447 strcat(linestring,"(Display Cleared) ");
00448 if (diodata[3] & RPS_OUTPUTRESET)
00449 strcat(linestring,"(Output Reset) ");
00450 if (diodata[3] & RPS_SMOKERESET)
00451 strcat(linestring,"(Smoke Det Reset) ");
00452 if (diodata[3] & RPS_VACRESET)
00453 strcat(linestring,"(AC Relay Held On) ");
00454 if (diodata[3] & RPS_SYSRESET1)
00455 strcat(linestring,"(System Reset bit1 on) ");
00456 if (diodata[3] & RPS_SYSRESET2)
00457 strcat(linestring,"(System Reset bit2 on) ");
00458 if (diodata[3] & RPS_SYSRESET3)
00459 strcat(linestring,"(System Reset bit3 on) ");
00460 }
00461
00462 strcat(linestring,"\n");
00463
00464 return(status);
00465 }
00466