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

include/spadic/Message.h (r4864/r3233)

Go to the documentation of this file.
00001 #ifndef SPADIC_MESSAGE_H
00002 #define SPADIC_MESSAGE_H
00003 
00004 #include <vector>
00005 #include <stdint.h>
00006 #include <list>
00007 #include <cstring>
00008 
00009 /*
00010  * Susibo/Spadic Message wrapper for DABC and Go4
00011  * First version 21-October-2010 by JAM
00012  */
00013 
00014 // switches debug output between dabc logger and iostream:
00015 // set this define to use Message class without dabc (Go4 Unpacker!)
00016 //#define __SPADIC_WITHOUT_DABC__ 1
00017 
00018 #define SUSIBO_PACKAGE_LENGTH 368
00019 #define SUSIBO_MAX_CHANNEL 8
00020 #define SUSIBO_MAX_SAMPLE 45
00021 
00022 namespace spadic {
00023 
00024    extern const char* typeSusiboInput;
00025    extern const char* nameReadoutAppClass;
00026    extern const char* xmlNumSusibo;
00027    extern const char* xmlSusiboDevID;
00028    extern const char* xmlHitDelay;
00029    extern const char* xmlEventsPerBuffer;
00030    extern const char* xmlFormatMbs;
00031    extern const char* xmlTimeout;
00032    extern const char* xmlUseInternalTrigger;
00033    extern const char* xmlInternalTriggerFreq;
00034    extern const char* xmlModuleName;
00035    extern const char* xmlModuleThread;
00036 
00037    enum { bt_Spadic = 104 };
00038 
00039 
00040    /* this class wraps the susibo message contained in the external byte vector*/
00041    class Message {
00042       public:
00043 
00044          enum PackageKind {
00045             packageNone      = 0,
00046             packageVector    = 1,  // message stored in std vector
00047             packageStruct    = 2  // message expanded to structure in memory
00048          };
00049 
00050          /* external data package from susibo will be wrapped into this object*/
00051          Message(std::vector<uint8_t> * package);
00052 
00053          /* external data field will be wrapped into this object*/
00054          Message(uint8_t* field);
00055 
00056          virtual ~Message();
00057 
00058          /* evaluate the event id (trigger message) number from the current package*/
00059          uint32_t GetEventIDNumber();
00060 
00061          /* evaluate the status from the package*/
00062          uint16_t GetStatusNumber();
00063 
00064          /* evaluate susibo timestamp*/
00065          uint32_t GetTimeStamp();
00066 
00067          /* Check if current message has correct length and format*/
00068          bool CheckMessage();
00069 
00070          /* Direct access to message data with general index*/
00071          uint8_t Data(size_t ix)
00072          {
00073             switch (fKind) {
00074                case packageVector:
00075                   return (fPackage->at(ix));
00076                case packageStruct:
00077                   return fField[ix];
00078                default:
00079                   return 0;
00080             };
00081             return 0;
00082          }
00083 
00084          /* access sample data of channel*/
00085          uint8_t Sample(size_t channel, size_t bin)
00086          {
00087             if (channel>=SUSIBO_MAX_CHANNEL) return 0;
00088             size_t ix=channel*SUSIBO_MAX_SAMPLE + bin;
00089             if(ix>=SUSIBO_PACKAGE_LENGTH) return 0;
00090             return Data(ix);
00091          }
00092 
00093       protected:
00094 
00095          /* reference to the package containing the current message*/
00096          std::vector<uint8_t> * fPackage;
00097 
00098          /* reference to the package containing the current message*/
00099          uint8_t* fField;
00100 
00101          PackageKind fKind;
00102 
00103    };
00104 
00105 }
00106 
00107 #endif
00108 

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