00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #include <fesa-core/DataStore/EquipmentData.h> 00004 00005 00006 namespace fesa 00007 { 00008 00009 EquipmentData* EquipmentData::instance_ = NULL; 00010 00011 00012 EquipmentData::EquipmentData() : 00013 isInitialize_(0), 00014 notificationIDreadoutFlag_(0), 00015 srvProcessPid_(0), 00016 notificationFailure_(0), 00017 hasRt_(0), 00018 rtUp_(0), 00019 serverUp_(0), 00020 rtProcessID_(0), 00021 serverProcessID_(0) 00022 { 00023 } 00024 00025 EquipmentData::~EquipmentData() 00026 { 00027 00028 } 00029 00030 void EquipmentData::initialize() 00031 { 00032 if (notificationIDreadoutFlag_ == 0) 00033 { 00034 throw; 00035 } 00036 *isInitialize_ = false; 00037 *notificationIDreadoutFlag_ = false; 00038 *notificationFailure_ = false; 00039 } 00040 00041 int32_t EquipmentData::getSizeOfAdditionalFields() 00042 { 00043 int32_t size = DataStore::getSizeOfAdditionalFields(); 00044 size += static_cast<int32_t>(sizeof(bool)); //isInitialize_ 00045 size += static_cast<int32_t>(sizeof(bool)); // notificationIDreadoutFlag_ 00046 size += static_cast<int32_t>(sizeof(int32_t)); // srvProcessPid_ 00047 size += static_cast<int32_t>(sizeof(bool)); // notificationFailure_ 00048 size += static_cast<int32_t>(sizeof(bool)); // hasRt_ 00049 size += static_cast<int32_t>(sizeof(bool)); // rtUp_ 00050 size += static_cast<int32_t>(sizeof(bool)); // serverUp_ 00051 size += static_cast<int32_t>((sizeof(pid_t))); //rtProcessID_ 00052 size += static_cast<int32_t>((sizeof(pid_t))); //serverProcessID_ 00053 return size; 00054 } 00055 00056 void EquipmentData::mapAdditionalFields(char* p) 00057 { 00058 DataStore::mapAdditionalFields(p); 00059 p += DataStore::getSizeOfAdditionalFields(); 00060 00061 isInitialize_ = (bool*) p; 00062 p += sizeof(bool); 00063 00064 notificationIDreadoutFlag_ = (bool*) p; 00065 p += sizeof(bool); 00066 00067 srvProcessPid_ = (int32_t*)p; 00068 p += sizeof(int32_t); 00069 00070 notificationFailure_ = (bool*)p; 00071 p += sizeof(bool); 00072 00073 hasRt_ = (bool*)p; 00074 p += sizeof(bool); 00075 00076 rtUp_ = (bool*)p; 00077 p += sizeof(bool); 00078 00079 serverUp_ = (bool*)p; 00080 p += sizeof(bool); 00081 00082 rtProcessID_= (pid_t*)p; 00083 p += sizeof(pid_t); 00084 00085 serverProcessID_= (pid_t*)p; 00086 } 00087 00088 EquipmentData* EquipmentData::getInstance() 00089 { 00090 00091 if (!instance_) 00092 { 00093 instance_ = new EquipmentData(); 00094 } 00095 return instance_; 00096 } 00097 00098 } // fesa