• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

roclib/src_spadic/Message.cxx (r4864/r3193)

Go to the documentation of this file.
00001 #include "spadic/Message.h"
00002 
00003 
00004 //#ifdef __SPADIC_WITHOUT_DABC__
00005 #include <stdio.h>
00006 #define SUS_ERR_OUT( args... ) \
00007 printf( args );
00008 //#else
00009 //#include "dabc/logging.h"
00010 //#define SUS_ERR_OUT( args... ) \
00011 //EOUT(( args ));
00012 //#endif
00013 
00014 const char* spadic::typeSusiboInput          = "spadic::SusiboInput";
00015 const char* spadic::nameReadoutAppClass      = "spadic::Readout";
00016 
00017 const char* spadic::xmlNumSusibo             = "NumSusibo";
00018 const char* spadic::xmlSusiboDevID           = "SusiboID-";
00019 const char* spadic::xmlHitDelay              = "HitDelay";
00020 const char* spadic::xmlEventsPerBuffer       = "EventsInBuffer";
00021 const char* spadic::xmlFormatMbs             = "SusiboMbsFormat";
00022 const char* spadic::xmlTimeout               = "PollingTimeout";
00023 const char* spadic::xmlUseInternalTrigger    = "EnableTestTrigger";
00024 const char* spadic::xmlInternalTriggerFreq   = "TriggersPerSecond";
00025 const char* spadic::xmlModuleName            = "SusiboModuleName"; // Name of readout module instance
00026 const char* spadic::xmlModuleThread          = "SusiboModuleThread"; // Name of thread for readout module
00027 
00028 
00029 
00030 spadic::Message::Message(std::vector<uint8_t> * package):
00031    fPackage(package),
00032    fField(0),
00033    fKind(packageVector)
00034 {
00035 }
00036 
00037 spadic::Message::Message(uint8_t* field):
00038    fPackage(0),
00039    fField(field),
00040    fKind(packageStruct)
00041 {
00042 }
00043 
00044 
00045 spadic::Message::~Message()
00046 {
00047 
00048 
00049 }
00050 
00051 
00052 uint32_t spadic::Message::GetEventIDNumber()
00053 {
00054     if(!CheckMessage()) return 0;
00055     uint32_t fullid = Data(360) << 16 | Data(361) << 8 | Data(362) ;
00056     return fullid;
00057 }
00058 
00059 
00060 uint16_t spadic::Message::GetStatusNumber()
00061 {
00062    if(!CheckMessage()) return 0;
00063    uint16_t stat = Data(366) << 8 | Data(367) ;
00064    return stat;
00065 }
00066 
00067 uint32_t spadic::Message::GetTimeStamp()
00068 {
00069    if(!CheckMessage()) return 0;
00070    uint32_t time = Data(363) << 16 | Data(364) << 8 | Data(365) ;
00071     return time;
00072 }
00073 
00074 
00075 bool spadic::Message::CheckMessage()
00076 {
00077    switch (fKind) {
00078    case packageVector:
00079 
00080       if (fPackage == 0)
00081       {
00082          SUS_ERR_OUT("Zero package pointer - No package referred!");
00083          return false;
00084       }
00085       if (fPackage->size() != SUSIBO_PACKAGE_LENGTH)
00086       {
00087          SUS_ERR_OUT("Wrong package length %u != %u !", (unsigned) fPackage->size(), SUSIBO_PACKAGE_LENGTH);
00088          return false;
00089       }
00090       if(Data(366) % 2 == 1)
00091       {
00092          SUS_ERR_OUT("Buffer overflow  flag in last package detected");
00093         //note: most buffer overflow markers will be ignored here...
00094         return true;
00095       }
00096       if(Data(367) != 0)
00097       {
00098          SUS_ERR_OUT("synch signal corrupted");
00099          return false;
00100       }
00101       return true;
00102 
00103    case packageStruct:
00104       if (fField == 0) {
00105             SUS_ERR_OUT("Zero package pointer - No package referred!");
00106             return false;
00107          }
00108       // TODO: should we check status number here?
00109 
00110       return true;
00111    };
00112 
00113    return false;
00114 }

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1