MIDAS
Loading...
Searching...
No Matches
TMFeEquipment Class Reference

#include <tmfe.h>

Inheritance diagram for TMFeEquipment:
Collaboration diagram for TMFeEquipment:

Public Member Functions

 TMFeEquipment (const char *eqname, const char *eqfilename)
 
virtual ~TMFeEquipment ()
 
TMFeResult EqInit (const std::vector< std::string > &args)
 Initialize equipment.
 
TMFeResult EqPreInit ()
 Initialize equipment, before EquipmentBase::Init()
 
TMFeResult EqPostInit ()
 Initialize equipment, after EquipmentBase::Init()
 
TMFeResult EqReadCommon ()
 Read TMFeEqInfo from ODB /Equipment/NAME/Common.
 
TMFeResult EqWriteCommon (bool create=false)
 Write TMFeEqInfo to ODB /Equipment/NAME/Common.
 
virtual TMFeResult HandleInit (const std::vector< std::string > &args)
 
virtual void HandleUsage ()
 
virtual TMFeResult HandleBeginRun (int run_number)
 
virtual TMFeResult HandleEndRun (int run_number)
 
virtual TMFeResult HandlePauseRun (int run_number)
 
virtual TMFeResult HandleResumeRun (int run_number)
 
virtual TMFeResult HandleStartAbortRun (int run_number)
 
virtual TMFeResult HandleRpc (const char *cmd, const char *args, std::string &response)
 
virtual void HandlePeriodic ()
 
virtual bool HandlePoll ()
 
virtual void HandlePollRead ()
 
void EqPollThread ()
 
void EqStartPollThread ()
 
void EqStopPollThread ()
 
TMFeResult ComposeEvent (char *pevent, size_t size) const
 
TMFeResult BkInit (char *pevent, size_t size) const
 
void * BkOpen (char *pevent, const char *bank_name, int bank_type) const
 
TMFeResult BkClose (char *pevent, void *ptr) const
 
int BkSize (const char *pevent) const
 
TMFeResult EqSendEvent (const char *pevent, bool write_to_odb=true)
 
TMFeResult EqSendEvent (const std::vector< char > &event, bool write_to_odb=true)
 
TMFeResult EqSendEvent (const std::vector< std::vector< char > > &event, bool write_to_odb=true)
 
TMFeResult EqSendEvent (int sg_n, const char *sg_ptr[], const size_t sg_len[], bool write_to_odb=true)
 
TMFeResult EqWriteEventToOdb (const char *pevent)
 
TMFeResult EqZeroStatistics ()
 
TMFeResult EqWriteStatistics ()
 
TMFeResult EqSetStatus (const char *status, const char *color)
 
 TMFeEquipment (TMFE *mfe, const char *name, TMFeCommon *common)
 
TMFeError Init ()
 Initialize equipment.
 
TMFeError SendData (const char *data, int size)
 ...
 
TMFeError ComposeEvent (char *pevent, int size)
 
TMFeError BkInit (char *pevent, int size)
 
void * BkOpen (char *pevent, const char *bank_name, int bank_type)
 
TMFeError BkClose (char *pevent, void *ptr)
 
int BkSize (const char *pevent)
 
TMFeError SendEvent (const char *pevent)
 
TMFeError ZeroStatistics ()
 
TMFeError WriteStatistics ()
 
TMFeError SetStatus (const char *status, const char *color)
 
- Public Member Functions inherited from TMFeRpcHandlerInterface
virtual TMFeResult HandleBinaryRpc (const char *cmd, const char *args, std::vector< char > &result)
 
virtual void HandleBeginRun ()
 
virtual void HandleEndRun ()
 
virtual void HandlePauseRun ()
 
virtual void HandleResumeRun ()
 
virtual void HandleStartAbortRun ()
 
virtual std::string HandleRpc (const char *cmd, const char *args)
 

Public Attributes

std::string fEqName
 
std::string fEqFilename
 
bool fEqConfEnableRpc = true
 
bool fEqConfEnablePeriodic = true
 
bool fEqConfEnablePoll = false
 
bool fEqConfReadConfigFromOdb = true
 
bool fEqConfEnabled = true
 
uint16_t fEqConfEventID = 1
 
uint16_t fEqConfTriggerMask = 0
 
std::string fEqConfBuffer = "SYSTEM"
 
int fEqConfType = 0
 
int fEqConfSource = 0
 
std::string fEqConfFormat = "MIDAS"
 
int fEqConfReadOn = 0
 
int fEqConfPeriodMilliSec = 1000
 
double fEqConfEventLimit = 0
 
uint32_t fEqConfNumSubEvents = 0
 
int fEqConfLogHistory = 0
 
bool fEqConfHidden = false
 
int fEqConfWriteCacheSize = 10000000
 
bool fEqConfReadOnlyWhenRunning = true
 
bool fEqConfWriteEventsToOdb = false
 
double fEqConfPeriodStatisticsSec = 1.0
 
double fEqConfPollSleepSec = 0.000100
 
size_t fEqConfMaxEventSize = 0
 
size_t fEqConfBufferSize = 0
 
std::mutex fEqMutex
 
TMFEfMfe = NULL
 
TMFrontendfFe = NULL
 
MVOdb * fOdbEq = NULL
 ODB Equipment/EQNAME.
 
MVOdb * fOdbEqCommon = NULL
 ODB Equipment/EQNAME/Common.
 
MVOdb * fOdbEqSettings = NULL
 ODB Equipment/EQNAME/Settings.
 
MVOdb * fOdbEqVariables = NULL
 ODB Equipment/EQNAME/Variables.
 
MVOdb * fOdbEqStatistics = NULL
 ODB Equipment/EQNAME/Statistics.
 
TMEventBufferfEqEventBuffer = NULL
 
int fEqSerial = 0
 
double fEqStatEvents = 0
 
double fEqStatBytes = 0
 
double fEqStatEpS = 0
 
double fEqStatKBpS = 0
 
double fEqStatLastTime = 0
 
double fEqStatLastEvents = 0
 
double fEqStatLastBytes = 0
 
double fEqStatLastWrite = 0
 
double fEqStatNextWrite = 0
 
double fEqPeriodicLastCallTime = 0
 
double fEqPeriodicNextCallTime = 0
 
std::atomic_bool fEqPollThreadStarting {false}
 
std::atomic_bool fEqPollThreadRunning {false}
 
std::atomic_bool fEqPollThreadShutdownRequested {false}
 
std::thread * fEqPollThread = NULL
 
std::string fName
 
TMFeCommonfCommon
 
int fBufferHandle
 
int fSerial
 
double fStatEvents
 
double fStatBytes
 
double fStatEpS
 
double fStatKBpS
 
double fStatLastTime
 
double fStatLastEvents
 
double fStatLastBytes
 

Private Member Functions

 TMFeEquipment ()
 
TMFeResult EqWriteEventToOdb_locked (const char *pevent)
 

Detailed Description

Definition at line 156 of file tmfe.h.

Constructor & Destructor Documentation

◆ TMFeEquipment() [1/3]

TMFeEquipment::TMFeEquipment ( const char *  eqname,
const char *  eqfilename 
)

Definition at line 1710 of file tmfe.cxx.

1711{
1712 assert(eqname != NULL);
1713 assert(eqfilename != NULL);
1714
1715 if (TMFE::gfVerbose)
1716 printf("TMFeEquipment::ctor: equipment name [%s] file [%s]\n", eqname, eqfilename);
1717
1718 fMfe = TMFE::Instance();
1719 fEqName = eqname;
1720 fEqFilename = eqfilename;
1722}
static double GetTime()
return current time in seconds, with micro-second precision
Definition tmfe.cxx:1011
static bool gfVerbose
Definition tmfe.h:424
static TMFE * Instance()
Definition tmfe.cxx:57
TMFE * fMfe
Definition tmfe.h:207
double fEqStatNextWrite
Definition tmfe.h:234
std::string fEqName
Definition tmfe.h:159
std::string fEqFilename
Definition tmfe.h:160
Here is the call graph for this function:

◆ ~TMFeEquipment()

TMFeEquipment::~TMFeEquipment ( )
virtual

Definition at line 1724 of file tmfe.cxx.

1725{
1726 if (TMFE::gfVerbose)
1727 printf("TMFeEquipment::dtor: equipment name [%s]\n", fEqName.c_str());
1728
1730
1731 // free data and poison pointers
1732 if (fOdbEq) {
1733 delete fOdbEq;
1734 fOdbEq = NULL;
1735 }
1736 if (fOdbEqCommon) {
1737 delete fOdbEqCommon;
1738 fOdbEqCommon = NULL;
1739 }
1740 if (fOdbEqSettings) {
1741 delete fOdbEqSettings;
1742 fOdbEqSettings = NULL;
1743 }
1744 if (fOdbEqVariables) {
1745 delete fOdbEqVariables;
1746 fOdbEqVariables = NULL;
1747 }
1748 if (fOdbEqStatistics) {
1749 delete fOdbEqStatistics;
1750 fOdbEqStatistics = NULL;
1751 }
1752 fMfe = NULL;
1753 fFe = NULL;
1754 fEqEventBuffer = NULL;
1755}
MVOdb * fOdbEqSettings
ODB Equipment/EQNAME/Settings.
Definition tmfe.h:213
TMFrontend * fFe
Definition tmfe.h:208
MVOdb * fOdbEqVariables
ODB Equipment/EQNAME/Variables.
Definition tmfe.h:214
TMEventBuffer * fEqEventBuffer
Definition tmfe.h:218
void EqStopPollThread()
Definition tmfe.cxx:665
MVOdb * fOdbEqCommon
ODB Equipment/EQNAME/Common.
Definition tmfe.h:212
MVOdb * fOdbEq
ODB Equipment/EQNAME.
Definition tmfe.h:211
MVOdb * fOdbEqStatistics
ODB Equipment/EQNAME/Statistics.
Definition tmfe.h:215
Here is the call graph for this function:

◆ TMFeEquipment() [2/3]

TMFeEquipment::TMFeEquipment ( )
inlineprivate

Definition at line 255 of file tmfe.h.

255{}; // ctor

◆ TMFeEquipment() [3/3]

TMFeEquipment::TMFeEquipment ( TMFE mfe,
const char *  name,
TMFeCommon common 
)

Definition at line 611 of file tmfe_rev0.cxx.

612{
613 fMfe = mfe;
614 fName = name;
615 fCommon = common;
616 fBufferHandle = 0;
617 fSerial = 0;
618 fStatEvents = 0;
619 fStatBytes = 0;
620 fStatEpS = 0;
621 fStatKBpS = 0;
622 fStatLastTime = 0;
623 fStatLastEvents = 0;
624 fStatLastBytes = 0;
625 fOdbEq = NULL;
626 fOdbEqCommon = NULL;
627 fOdbEqSettings = NULL;
628 fOdbEqVariables = NULL;
629}
double fStatEvents
Definition tmfe_rev0.h:151
TMFeCommon * fCommon
Definition tmfe_rev0.h:136
double fStatLastEvents
Definition tmfe_rev0.h:157
double fStatBytes
Definition tmfe_rev0.h:152
double fStatLastTime
Definition tmfe_rev0.h:156
double fStatKBpS
Definition tmfe_rev0.h:154
std::string fName
Definition tmfe_rev0.h:135
double fStatLastBytes
Definition tmfe_rev0.h:158
double fStatEpS
Definition tmfe_rev0.h:153
#define name(x)
Definition midas_macro.h:24

Member Function Documentation

◆ BkClose() [1/2]

TMFeError TMFeEquipment::BkClose ( char *  pevent,
void *  ptr 
)

Definition at line 780 of file tmfe_rev0.cxx.

781{
782 bk_close(event + sizeof(EVENT_HEADER), ptr);
783 ((EVENT_HEADER*)event)->data_size = BkSize(event);
784 return TMFeError();
785}
int BkSize(const char *pevent) const
Definition tmfe.cxx:2247
INT bk_close(void *event, void *pdata)
Definition midas.cxx:18184
Here is the call graph for this function:

◆ BkClose() [2/2]

TMFeResult TMFeEquipment::BkClose ( char *  pevent,
void *  ptr 
) const

Definition at line 2265 of file tmfe.cxx.

2266{
2267 bk_close(event + sizeof(EVENT_HEADER), ptr);
2268 ((EVENT_HEADER*)event)->data_size = BkSize(event);
2269 return TMFeOk();
2270}
TMFeResult TMFeOk()
Definition tmfe.h:106
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BkInit() [1/2]

TMFeError TMFeEquipment::BkInit ( char *  pevent,
int  size 
)

Definition at line 767 of file tmfe_rev0.cxx.

768{
769 bk_init32(event + sizeof(EVENT_HEADER));
770 return TMFeError();
771}
void bk_init32(void *event)
Definition midas.cxx:17873
Here is the call graph for this function:

◆ BkInit() [2/2]

TMFeResult TMFeEquipment::BkInit ( char *  pevent,
size_t  size 
) const

Definition at line 2252 of file tmfe.cxx.

2253{
2254 bk_init32a(event + sizeof(EVENT_HEADER));
2255 return TMFeOk();
2256}
void bk_init32a(void *event)
Definition midas.cxx:17886
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BkOpen() [1/2]

void * TMFeEquipment::BkOpen ( char *  pevent,
const char *  bank_name,
int  bank_type 
)

Definition at line 773 of file tmfe_rev0.cxx.

774{
775 void* ptr;
776 bk_create(event + sizeof(EVENT_HEADER), name, tid, &ptr);
777 return ptr;
778}
void bk_create(void *event, const char *name, WORD type, void **pdata)
Definition midas.cxx:17965
Here is the call graph for this function:

◆ BkOpen() [2/2]

void * TMFeEquipment::BkOpen ( char *  pevent,
const char *  bank_name,
int  bank_type 
) const

Definition at line 2258 of file tmfe.cxx.

2259{
2260 void* ptr;
2261 bk_create(event + sizeof(EVENT_HEADER), name, tid, &ptr);
2262 return ptr;
2263}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ BkSize() [1/2]

int TMFeEquipment::BkSize ( const char *  pevent)

Definition at line 762 of file tmfe_rev0.cxx.

763{
764 return bk_size((void*)(event + sizeof(EVENT_HEADER))); // FIXME: need const in prototype!
765}
INT bk_size(const void *event)
Definition midas.cxx:17899
Here is the call graph for this function:

◆ BkSize() [2/2]

int TMFeEquipment::BkSize ( const char *  pevent) const

Definition at line 2247 of file tmfe.cxx.

2248{
2249 return bk_size(event + sizeof(EVENT_HEADER));
2250}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComposeEvent() [1/2]

TMFeError TMFeEquipment::ComposeEvent ( char *  pevent,
int  size 
)

Definition at line 727 of file tmfe_rev0.cxx.

728{
729 EVENT_HEADER* pevent = (EVENT_HEADER*)event;
730 pevent->event_id = fCommon->EventID;
732 pevent->serial_number = fSerial;
733 pevent->time_stamp = TMFE::GetTime();
734 pevent->data_size = 0;
735 return TMFeError();
736}
uint16_t EventID
Definition tmfe_rev0.h:105
uint16_t TriggerMask
Definition tmfe_rev0.h:106
short int event_id
Definition midas.h:853
DWORD data_size
Definition midas.h:857
DWORD serial_number
Definition midas.h:855
DWORD time_stamp
Definition midas.h:856
short int trigger_mask
Definition midas.h:854
Here is the call graph for this function:

◆ ComposeEvent() [2/2]

TMFeResult TMFeEquipment::ComposeEvent ( char *  pevent,
size_t  size 
) const

Definition at line 2052 of file tmfe.cxx.

2053{
2054 EVENT_HEADER* pevent = (EVENT_HEADER*)event;
2055 pevent->event_id = fEqConfEventID;
2057 pevent->serial_number = fEqSerial;
2058 pevent->time_stamp = TMFE::GetTime();
2059 pevent->data_size = 0;
2060 return TMFeOk();
2061}
uint16_t fEqConfTriggerMask
Definition tmfe.h:172
uint16_t fEqConfEventID
Definition tmfe.h:171
int fEqSerial
Definition tmfe.h:219
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqInit()

TMFeResult TMFeEquipment::EqInit ( const std::vector< std::string > &  args)

Initialize equipment.

Definition at line 1757 of file tmfe.cxx.

1758{
1759 TMFeResult r;
1760
1761 r = EqPreInit();
1762 if (r.error_flag)
1763 return r;
1764
1765 r = HandleInit(args);
1766 if (r.error_flag)
1767 return r;
1768
1769 r = EqPostInit();
1770 if (r.error_flag)
1771 return r;
1772
1773 return TMFeOk();
1774}
virtual TMFeResult HandleInit(const std::vector< std::string > &args)
Definition tmfe.h:258
TMFeResult EqPreInit()
Initialize equipment, before EquipmentBase::Init()
Definition tmfe.cxx:1860
TMFeResult EqPostInit()
Initialize equipment, after EquipmentBase::Init()
Definition tmfe.cxx:1910
bool error_flag
Definition tmfe.h:89
Here is the call graph for this function:

◆ EqPollThread()

void TMFeEquipment::EqPollThread ( )

Definition at line 621 of file tmfe.cxx.

622{
623 if (TMFE::gfVerbose)
624 printf("TMFeEquipment::EqPollThread: equipment \"%s\" poll thread started\n", fEqName.c_str());
625
627
630 bool poll = HandlePoll();
631 if (poll) {
633 } else {
634 if (fEqConfPollSleepSec > 0) {
636 }
637 }
638 } else {
639 TMFE::Sleep(0.1);
640 }
641 }
642 if (TMFE::gfVerbose)
643 printf("TMFeEquipment::EqPollThread: equipment \"%s\" poll thread stopped\n", fEqName.c_str());
644
645 fEqPollThreadRunning = false;
646}
bool fStateRunning
run state is running or paused
Definition tmfe.h:402
static void Sleep(double sleep_time_sec)
sleep, with micro-second precision
Definition tmfe.cxx:1019
std::atomic_bool fShutdownRequested
shutdown was requested by Ctrl-C or by RPC command
Definition tmfe.h:398
virtual void HandlePollRead()
Definition tmfe.h:274
std::atomic_bool fEqPollThreadShutdownRequested
Definition tmfe.h:243
virtual bool HandlePoll()
Definition tmfe.h:273
double fEqConfPollSleepSec
Definition tmfe.h:199
std::atomic_bool fEqPollThreadRunning
Definition tmfe.h:242
bool fEqConfReadOnlyWhenRunning
Definition tmfe.h:196
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqPostInit()

TMFeResult TMFeEquipment::EqPostInit ( )

Initialize equipment, after EquipmentBase::Init()

Definition at line 1910 of file tmfe.cxx.

1911{
1912 if (TMFE::gfVerbose)
1913 printf("TMFeEquipment::EqPostInit: for [%s]\n", fEqName.c_str());
1914
1915 if (!fEqConfEnabled) {
1916 EqSetStatus("Disabled", "yellowLight");
1917 }
1918
1919 // open event buffer
1920
1921 uint32_t odb_max_event_size = DEFAULT_MAX_EVENT_SIZE;
1922 fMfe->fOdbRoot->RU32("Experiment/MAX_EVENT_SIZE", &odb_max_event_size, true);
1923
1924 if (fEqConfMaxEventSize == 0) {
1925 fEqConfMaxEventSize = odb_max_event_size;
1926 } else if (fEqConfMaxEventSize > odb_max_event_size) {
1927 fMfe->Msg(MERROR, "TMFeEquipment::EqPostInit", "Equipment \"%s\" requested event size %d is bigger than ODB MAX_EVENT_SIZE %d", fEqName.c_str(), (int)fEqConfMaxEventSize, odb_max_event_size);
1928 fEqConfMaxEventSize = odb_max_event_size;
1929 }
1930
1931 if (!fEqConfBuffer.empty()) {
1933
1934 if (r.error_flag)
1935 return r;
1936
1937 assert(fEqEventBuffer != NULL);
1938
1940 fMfe->Msg(MERROR, "TMFeEquipment::EqPostInit", "Equipment \"%s\" requested event size %d is bigger than event buffer \"%s\" max event size %d", fEqName.c_str(), (int)fEqConfMaxEventSize, fEqEventBuffer->fBufName.c_str(), (int)fEqEventBuffer->fBufMaxEventSize);
1942 }
1943
1944 if (fEqConfWriteCacheSize > 0) {
1947
1948 if (r.error_flag)
1949 return r;
1951 fMfe->Msg(MERROR, "TMFeEquipment::EqPostInit", "Equipment \"%s\" requested write cache size %d for buffer \"%s\" is smaller then already set write cache size %d, ignoring it", fEqName.c_str(), (int)fEqConfWriteCacheSize, fEqEventBuffer->fBufName.c_str(), (int)fEqEventBuffer->fBufWriteCacheSize);
1953 // do nothing
1954 } else {
1955 fMfe->Msg(MERROR, "TMFeEquipment::EqPostInit", "Equipment \"%s\" requested write cache size %d for buffer \"%s\" is different from already set write cache size %d", fEqName.c_str(), (int)fEqConfWriteCacheSize, fEqEventBuffer->fBufName.c_str(), (int)fEqEventBuffer->fBufWriteCacheSize);
1956
1958
1959 if (r.error_flag)
1960 return r;
1961 }
1962 }
1963 }
1964
1965 if (TMFE::gfVerbose)
1966 printf("TMFeEquipment::EqPostInit: Equipment \"%s\", max event size: %d\n", fEqName.c_str(), (int)fEqConfMaxEventSize);
1967
1968 // update ODB common
1969
1971
1972 if (r.error_flag)
1973 return r;
1974
1976 fMfe->AddRpcHandler(this);
1977 }
1978
1979 return TMFeOk();
1980};
std::string fBufName
Definition tmfe.h:119
TMFeResult SetCacheSize(size_t read_cache_size, size_t write_cache_size)
Definition tmfe.cxx:258
size_t fBufWriteCacheSize
Definition tmfe.h:140
size_t fBufMaxEventSize
Definition tmfe.h:121
void AddRpcHandler(TMFeRpcHandlerInterface *)
Definition tmfe.cxx:1583
void Msg(int message_type, const char *filename, int line, const char *routine, const char *format,...) MATTRPRINTF(6
Definition tmfe.cxx:991
MVOdb * fOdbRoot
ODB root.
Definition tmfe.h:395
TMFeResult EventBufferOpen(TMEventBuffer **pbuf, const char *bufname, size_t bufsize=0)
Definition tmfe.cxx:413
bool fEqConfEnabled
Definition tmfe.h:170
int fEqConfWriteCacheSize
Definition tmfe.h:186
TMFeResult EqSetStatus(const char *status, const char *color)
Definition tmfe.cxx:2272
TMFeResult EqWriteCommon(bool create=false)
Write TMFeEqInfo to ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1819
bool fEqConfEnableRpc
Definition tmfe.h:164
size_t fEqConfBufferSize
Definition tmfe.h:201
std::string fEqConfBuffer
Definition tmfe.h:173
size_t fEqConfMaxEventSize
Definition tmfe.h:200
#define DEFAULT_MAX_EVENT_SIZE
Definition midas.h:254
#define MERROR
Definition tmfe_rev0.h:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqPreInit()

TMFeResult TMFeEquipment::EqPreInit ( )

Initialize equipment, before EquipmentBase::Init()

Definition at line 1860 of file tmfe.cxx.

1861{
1862 if (TMFE::gfVerbose)
1863 printf("TMFeEquipment::PreInit: for [%s]\n", fEqName.c_str());
1864
1865 //
1866 // Apply frontend index
1867 //
1868
1869 if (fEqName.find("%") != std::string::npos) {
1870 fEqName = msprintf(fEqName.c_str(), fFe->fFeIndex);
1871 }
1872
1873 if (fEqConfBuffer.find("%") != std::string::npos) {
1875 }
1876
1877 //
1878 // create ODB /eq/name/common
1879 //
1880
1881 fOdbEq = fMfe->fOdbRoot->Chdir((std::string("Equipment/") + fEqName).c_str(), true);
1882 fOdbEqCommon = fOdbEq->Chdir("Common", false);
1883 if (!fOdbEqCommon) {
1884 if (TMFE::gfVerbose)
1885 printf("TMFeEquipment::PreInit: creating ODB common\n");
1886 fOdbEqCommon = fOdbEq->Chdir("Common", true);
1887 EqWriteCommon(true);
1888 }
1889 fOdbEqSettings = fOdbEq->Chdir("Settings", true);
1890 fOdbEqVariables = fOdbEq->Chdir("Variables", true);
1891 fOdbEqStatistics = fOdbEq->Chdir("Statistics", true);
1892
1894
1895 if (r.error_flag)
1896 return r;
1897
1898 if (rpc_is_remote()) {
1899 EqSetStatus((fMfe->fProgramName + "@" + fMfe->fHostname).c_str(), "greenLight");
1900 } else {
1901 EqSetStatus(fMfe->fProgramName.c_str(), "greenLight");
1902 }
1903
1906
1907 return TMFeOk();
1908}
std::string fHostname
hostname we are running on
Definition tmfe.h:388
std::string fProgramName
frontend program name
Definition tmfe.h:387
TMFeResult EqReadCommon()
Read TMFeEqInfo from ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1776
TMFeResult EqWriteStatistics()
Definition tmfe.cxx:2007
TMFeResult EqZeroStatistics()
Definition tmfe.cxx:1982
int fFeIndex
Definition tmfe.h:313
bool rpc_is_remote(void)
Definition midas.cxx:12892
std::string msprintf(const char *format,...)
Definition midas.cxx:419
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqReadCommon()

TMFeResult TMFeEquipment::EqReadCommon ( )

Read TMFeEqInfo from ODB /Equipment/NAME/Common.

Definition at line 1776 of file tmfe.cxx.

1777{
1778 if (TMFE::gfVerbose)
1779 printf("TMFeEquipment::EqReadCommon: for [%s]\n", fEqName.c_str());
1780
1781 // list of ODB Common entries always read
1782
1783 fOdbEqCommon->RB("Enabled", &fEqConfEnabled, true);
1784 fOdbEqCommon->RD("Event limit", &fEqConfEventLimit, true);
1785
1787 // list of ODB Common entries read if we want to control equipment from ODB
1788
1789 fOdbEqCommon->RU16("Event ID", &fEqConfEventID, true);
1790 fOdbEqCommon->RU16("Trigger mask", &fEqConfTriggerMask, true);
1791 fOdbEqCommon->RS("Buffer", &fEqConfBuffer, true, NAME_LENGTH);
1792 fOdbEqCommon->RI("Type", &fEqConfType, true);
1793 fOdbEqCommon->RI("Source", &fEqConfSource, true);
1794 fOdbEqCommon->RS("Format", &fEqConfFormat, true, 8);
1795 fOdbEqCommon->RI("Read on", &fEqConfReadOn, true);
1796 fOdbEqCommon->RI("Period", &fEqConfPeriodMilliSec, true);
1797 fOdbEqCommon->RU32("Num subevents", &fEqConfNumSubEvents, true);
1798 fOdbEqCommon->RI("Log history", &fEqConfLogHistory, true);
1799 fOdbEqCommon->RB("Hidden", &fEqConfHidden, true);
1800 fOdbEqCommon->RI("Write cache size", &fEqConfWriteCacheSize, true);
1801
1802 // decode data from ODB Common
1803
1806 }
1807
1808 // list of ODB Common entries we read and write back to ODB, but do not actually use.
1809
1810 //fOdbEqCommon->RS("Frontend host", &fEqConfFrontendHost, true, NAME_LENGTH);
1811 //fOdbEqCommon->RS("Frontend name", &fEqConfFrontendName, true, NAME_LENGTH);
1812 //fOdbEqCommon->RS("Frontend file name", &fEqConfFrontendFileName, true, 256);
1813 //fOdbEqCommon->RS("Status", &fEqConfStatus, true, 256);
1814 //fOdbEqCommon->RS("Status color", &fEqConfStatusColor, true, NAME_LENGTH);
1815
1816 return TMFeOk();
1817}
bool fEqConfHidden
Definition tmfe.h:182
int fEqConfSource
Definition tmfe.h:175
int fEqConfReadOn
Definition tmfe.h:177
bool fEqConfWriteEventsToOdb
Definition tmfe.h:197
int fEqConfPeriodMilliSec
Definition tmfe.h:178
uint32_t fEqConfNumSubEvents
Definition tmfe.h:180
std::string fEqConfFormat
Definition tmfe.h:176
int fEqConfLogHistory
Definition tmfe.h:181
double fEqConfEventLimit
Definition tmfe.h:179
int fEqConfType
Definition tmfe.h:174
bool fEqConfReadConfigFromOdb
Definition tmfe.h:168
#define RO_STOPPED
Definition midas.h:427
#define RO_ODB
Definition midas.h:438
#define RO_PAUSED
Definition midas.h:428
#define NAME_LENGTH
Definition midas.h:272
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqSendEvent() [1/4]

TMFeResult TMFeEquipment::EqSendEvent ( const char *  pevent,
bool  write_to_odb = true 
)

Definition at line 2063 of file tmfe.cxx.

2064{
2065 std::lock_guard<std::mutex> guard(fEqMutex);
2066
2067 fEqSerial++;
2068
2069 EVENT_HEADER* pevent = (EVENT_HEADER*)event;
2070 pevent->data_size = BkSize(event);
2071
2072 if (fEqEventBuffer != NULL) {
2074
2075 if (r.error_flag)
2076 return r;
2077 }
2078
2079 fEqStatEvents += 1;
2080 fEqStatBytes += sizeof(EVENT_HEADER) + pevent->data_size;
2081
2082 if (fEqConfWriteEventsToOdb && write_to_odb) {
2084 if (r.error_flag)
2085 return r;
2086 }
2087
2088 if (fMfe->fStateRunning) {
2089 if (fEqConfEventLimit > 0) {
2091 if (!fMfe->fRunStopRequested) {
2092 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2093 }
2094 fMfe->fRunStopRequested = true;
2095 }
2096 }
2097 }
2098
2099 return TMFeOk();
2100}
TMFeResult SendEvent(const char *e)
Definition tmfe.cxx:326
bool fRunStopRequested
run stop was requested by equipment
Definition tmfe.h:444
std::mutex fEqMutex
Definition tmfe.h:204
TMFeResult EqWriteEventToOdb_locked(const char *pevent)
Definition tmfe.cxx:2226
double fEqStatEvents
Definition tmfe.h:222
double fEqStatBytes
Definition tmfe.h:223
#define MINFO
Definition tmfe_rev0.h:71
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqSendEvent() [2/4]

TMFeResult TMFeEquipment::EqSendEvent ( const std::vector< char > &  event,
bool  write_to_odb = true 
)

Definition at line 2102 of file tmfe.cxx.

2103{
2104 std::lock_guard<std::mutex> guard(fEqMutex);
2105
2106 fEqSerial++;
2107
2108 if (fEqEventBuffer == NULL) {
2109 return TMFeOk();
2110 }
2111
2113
2114 if (r.error_flag)
2115 return r;
2116
2117 fEqStatEvents += 1;
2118 fEqStatBytes += event.size();
2119
2120 if (fEqConfWriteEventsToOdb && write_to_odb) {
2121 TMFeResult r = EqWriteEventToOdb_locked(event.data());
2122 if (r.error_flag)
2123 return r;
2124 }
2125
2126 if (fMfe->fStateRunning) {
2127 if (fEqConfEventLimit > 0) {
2129 if (!fMfe->fRunStopRequested) {
2130 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2131 }
2132 fMfe->fRunStopRequested = true;
2133 }
2134 }
2135 }
2136
2137 return TMFeOk();
2138}
Here is the call graph for this function:

◆ EqSendEvent() [3/4]

TMFeResult TMFeEquipment::EqSendEvent ( const std::vector< std::vector< char > > &  event,
bool  write_to_odb = true 
)

Definition at line 2140 of file tmfe.cxx.

2141{
2142 std::lock_guard<std::mutex> guard(fEqMutex);
2143
2144 fEqSerial++;
2145
2146 if (fEqEventBuffer == NULL) {
2147 return TMFeOk();
2148 }
2149
2151
2152 if (r.error_flag)
2153 return r;
2154
2155 fEqStatEvents += 1;
2156 for (auto v: event) {
2157 fEqStatBytes += v.size();
2158 }
2159
2160 //if (fEqConfWriteEventsToOdb && write_to_odb) {
2161 // TMFeResult r = EqWriteEventToOdb_locked(event.data());
2162 // if (r.error_flag)
2163 // return r;
2164 //}
2165
2166 if (fMfe->fStateRunning) {
2167 if (fEqConfEventLimit > 0) {
2169 if (!fMfe->fRunStopRequested) {
2170 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2171 }
2172 fMfe->fRunStopRequested = true;
2173 }
2174 }
2175 }
2176
2177 return TMFeOk();
2178}
Here is the call graph for this function:

◆ EqSendEvent() [4/4]

TMFeResult TMFeEquipment::EqSendEvent ( int  sg_n,
const char *  sg_ptr[],
const size_t  sg_len[],
bool  write_to_odb = true 
)

Definition at line 2180 of file tmfe.cxx.

2181{
2182 std::lock_guard<std::mutex> guard(fEqMutex);
2183
2184 fEqSerial++;
2185
2186 if (fEqEventBuffer == NULL) {
2187 return TMFeOk();
2188 }
2189
2190 TMFeResult r = fEqEventBuffer->SendEvent(sg_n, sg_ptr, sg_len);
2191
2192 if (r.error_flag)
2193 return r;
2194
2195 fEqStatEvents += 1;
2196 for (int i=0; i<sg_n; i++) {
2197 fEqStatBytes += sg_len[i];
2198 }
2199
2200 //if (fEqConfWriteEventsToOdb && write_to_odb) {
2201 // TMFeResult r = EqWriteEventToOdb_locked(event.data());
2202 // if (r.error_flag)
2203 // return r;
2204 //}
2205
2206 if (fMfe->fStateRunning) {
2207 if (fEqConfEventLimit > 0) {
2209 if (!fMfe->fRunStopRequested) {
2210 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2211 }
2212 fMfe->fRunStopRequested = true;
2213 }
2214 }
2215 }
2216
2217 return TMFeOk();
2218}
INT i
Definition mdump.cxx:32
Here is the call graph for this function:

◆ EqSetStatus()

TMFeResult TMFeEquipment::EqSetStatus ( const char *  status,
const char *  color 
)

Definition at line 2272 of file tmfe.cxx.

2273{
2274 if (eq_status) {
2275 fOdbEqCommon->WS("Status", eq_status, 256);
2276 }
2277
2278 if (eq_color) {
2279 fOdbEqCommon->WS("Status color", eq_color, NAME_LENGTH);
2280 }
2281
2282 return TMFeOk();
2283}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqStartPollThread()

void TMFeEquipment::EqStartPollThread ( )

Definition at line 648 of file tmfe.cxx.

649{
650 // NOTE: this is thread safe
651
652 std::lock_guard<std::mutex> guard(fEqMutex);
653
655 fMfe->Msg(MERROR, "TMFeEquipment::EqStartPollThread", "Equipment \"%s\": poll thread is already running", fEqName.c_str());
656 return;
657 }
658
661
662 fEqPollThread = new std::thread(&TMFeEquipment::EqPollThread, this);
663}
void EqPollThread()
Definition tmfe.cxx:621
std::thread * fEqPollThread
Definition tmfe.h:277
std::atomic_bool fEqPollThreadStarting
Definition tmfe.h:241
Here is the call graph for this function:

◆ EqStopPollThread()

void TMFeEquipment::EqStopPollThread ( )

Definition at line 665 of file tmfe.cxx.

666{
667 // NOTE: this is thread safe
668 fEqPollThreadStarting = false;
670 for (int i=0; i<100; i++) {
672 std::lock_guard<std::mutex> guard(fEqMutex);
673 if (fEqPollThread) {
674 fEqPollThread->join();
675 delete fEqPollThread;
676 fEqPollThread = NULL;
677 }
678 return;
679 }
680 TMFE::Sleep(0.1);
681 }
683 fMfe->Msg(MERROR, "TMFeEquipment::EqStopPollThread", "Equipment \"%s\": timeout waiting for shutdown of poll thread", fEqName.c_str());
684 }
685}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqWriteCommon()

TMFeResult TMFeEquipment::EqWriteCommon ( bool  create = false)

Write TMFeEqInfo to ODB /Equipment/NAME/Common.

Definition at line 1819 of file tmfe.cxx.

1820{
1821 if (TMFE::gfVerbose)
1822 printf("TMFeEquipment::EqWriteCommon: for [%s]\n", fEqName.c_str());
1823
1824 // encode data for ODB Common
1825
1826 fEqConfReadOn = 0;
1829 else
1833
1834 // write to ODB
1835
1836 fOdbEqCommon->WU16("Event ID", fEqConfEventID);
1837 fOdbEqCommon->WU16("Trigger mask", fEqConfTriggerMask);
1838 fOdbEqCommon->WS("Buffer", fEqConfBuffer.c_str(), NAME_LENGTH);
1839 fOdbEqCommon->WI("Type", fEqConfType);
1840 fOdbEqCommon->WI("Source", fEqConfSource);
1841 fOdbEqCommon->WS("Format", fEqConfFormat.c_str(), 8);
1842 fOdbEqCommon->WB("Enabled", fEqConfEnabled);
1843 fOdbEqCommon->WI("Read on", fEqConfReadOn);
1844 fOdbEqCommon->WI("Period", fEqConfPeriodMilliSec);
1845 fOdbEqCommon->WD("Event limit", fEqConfEventLimit);
1846 fOdbEqCommon->WU32("Num subevents", fEqConfNumSubEvents);
1847 fOdbEqCommon->WI("Log history", fEqConfLogHistory);
1848 fOdbEqCommon->WS("Frontend host", fMfe->fHostname.c_str(), NAME_LENGTH);
1849 fOdbEqCommon->WS("Frontend name", fMfe->fProgramName.c_str(), NAME_LENGTH);
1850 fOdbEqCommon->WS("Frontend file name", fEqFilename.c_str(), 256);
1851 if (create) {
1852 fOdbEqCommon->WS("Status", "", 256);
1853 fOdbEqCommon->WS("Status color", "", NAME_LENGTH);
1854 }
1855 fOdbEqCommon->WB("Hidden", fEqConfHidden);
1856 fOdbEqCommon->WI("Write cache size", fEqConfWriteCacheSize);
1857 return TMFeOk();
1858}
#define RO_RUNNING
Definition midas.h:426
BOOL create
Definition mchart.cxx:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqWriteEventToOdb()

TMFeResult TMFeEquipment::EqWriteEventToOdb ( const char *  pevent)

Definition at line 2220 of file tmfe.cxx.

2221{
2222 std::lock_guard<std::mutex> guard(fEqMutex);
2223 return EqWriteEventToOdb_locked(event);
2224}
Here is the call graph for this function:

◆ EqWriteEventToOdb_locked()

TMFeResult TMFeEquipment::EqWriteEventToOdb_locked ( const char *  pevent)
private

Definition at line 2226 of file tmfe.cxx.

2227{
2228 std::string path = "";
2229 path += "/Equipment/";
2230 path += fEqName;
2231 path += "/Variables";
2232
2233 HNDLE hKeyVar = 0;
2234
2235 int status = db_find_key(fMfe->fDB, 0, path.c_str(), &hKeyVar);
2236 if (status != DB_SUCCESS) {
2237 return TMFeMidasError(msprintf("Cannot find \"%s\" in ODB", path.c_str()), "db_find_key", status);
2238 }
2239
2240 status = cm_write_event_to_odb(fMfe->fDB, hKeyVar, (const EVENT_HEADER*) event, FORMAT_MIDAS);
2241 if (status != SUCCESS) {
2242 return TMFeMidasError("Cannot write event to ODB", "cm_write_event_to_odb", status);
2243 }
2244 return TMFeOk();
2245}
int fDB
ODB database handle.
Definition tmfe.h:394
#define DB_SUCCESS
Definition midas.h:632
#define SUCCESS
Definition mcstd.h:54
#define FORMAT_MIDAS
Definition midas.h:311
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4256
int cm_write_event_to_odb(HNDLE hDB, HNDLE hKey, const EVENT_HEADER *pevent, INT format)
Definition midas.cxx:19127
INT HNDLE
Definition midas.h:132
DWORD status
Definition odbhist.cxx:39
TMFeResult TMFeMidasError(const std::string &message, const char *midas_function_name, int midas_status)
Definition tmfe.cxx:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqWriteStatistics()

TMFeResult TMFeEquipment::EqWriteStatistics ( )

Definition at line 2007 of file tmfe.cxx.

2008{
2009 fEqMutex.lock();
2010
2011 if (TMFE::gfVerbose)
2012 printf("TMFeEquipment::EqWriteStatistics: write statistics for [%s]\n", fEqName.c_str());
2013
2014 double now = TMFE::GetTime();
2015 double elapsed = now - fEqStatLastTime;
2016
2017 if (elapsed > 0.9 || fEqStatLastTime == 0) {
2019 fEqStatKBpS = (fEqStatBytes - fEqStatLastBytes) / elapsed / 1000.0;
2020
2021 fEqStatLastTime = now;
2024 }
2025
2026 //printf("TMFeEquipment::EqWriteStatistics: write statistics for [%s], now %f, elapsed %f, sent %f, eps %f, kps %f\n", fEqName.c_str(), now, elapsed, fEqStatEvents, fEqStatEpS, fEqStatKBpS);
2027
2028 fOdbEqStatistics->WD("Events sent", fEqStatEvents);
2029 fOdbEqStatistics->WD("Events per sec.", fEqStatEpS);
2030 fOdbEqStatistics->WD("kBytes per sec.", fEqStatKBpS);
2031
2032 fEqStatLastWrite = now;
2033
2035 // avoid creep of NextWrite: we start it at
2036 // time of initialization, then increment it strictly
2037 // by the period value, regardless of when it is actually
2038 // written to ODB (actual period is longer than requested
2039 // period because we only over-sleep, never under-sleep). K.O.
2040 while (fEqStatNextWrite <= now) {
2042 }
2043 } else {
2044 fEqStatNextWrite = now;
2045 }
2046
2047 fEqMutex.unlock();
2048
2049 return TMFeOk();
2050}
double fEqStatKBpS
Definition tmfe.h:225
double fEqStatLastTime
Definition tmfe.h:228
double fEqStatLastWrite
Definition tmfe.h:233
double fEqConfPeriodStatisticsSec
Definition tmfe.h:198
double fEqStatEpS
Definition tmfe.h:224
double fEqStatLastEvents
Definition tmfe.h:229
double fEqStatLastBytes
Definition tmfe.h:230
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqZeroStatistics()

TMFeResult TMFeEquipment::EqZeroStatistics ( )

Definition at line 1982 of file tmfe.cxx.

1983{
1984 fEqMutex.lock();
1985
1986 if (TMFE::gfVerbose)
1987 printf("TMFeEquipment::EqZeroStatistics: zero statistics for [%s]\n", fEqName.c_str());
1988
1989 double now = TMFE::GetTime();
1990
1991 fEqStatEvents = 0;
1992 fEqStatBytes = 0;
1993 fEqStatEpS = 0;
1994 fEqStatKBpS = 0;
1995
1996 fEqStatLastTime = now;
1998 fEqStatLastBytes = 0;
1999
2000 fEqStatNextWrite = now; // force immediate update
2001
2002 fEqMutex.unlock();
2003
2004 return TMFeOk();
2005}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleBeginRun()

virtual TMFeResult TMFeEquipment::HandleBeginRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeRpcHandlerInterface.

Reimplemented in EqRpc, EqEverything, EqTrigger, and Myfe.

Definition at line 262 of file tmfe.h.

262{ return TMFeOk(); };
Here is the call graph for this function:

◆ HandleEndRun()

virtual TMFeResult TMFeEquipment::HandleEndRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeRpcHandlerInterface.

Reimplemented in EqRpc, EqEverything, EqTrigger, and Myfe.

Definition at line 263 of file tmfe.h.

263{ return TMFeOk(); };
Here is the call graph for this function:

◆ HandleInit()

virtual TMFeResult TMFeEquipment::HandleInit ( const std::vector< std::string > &  args)
inlinevirtual

Reimplemented in EqRandom, EqSlow, EqRare, EqBulk, EqRpc, EqEverything, and EqTrigger.

Definition at line 258 of file tmfe.h.

258{ return TMFeOk(); };
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandlePauseRun()

virtual TMFeResult TMFeEquipment::HandlePauseRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeRpcHandlerInterface.

Reimplemented in EqRpc, and EqEverything.

Definition at line 264 of file tmfe.h.

264{ return TMFeOk(); };
Here is the call graph for this function:

◆ HandlePeriodic()

virtual void TMFeEquipment::HandlePeriodic ( )
inlinevirtual

Reimplemented in EqRandom, EqSlow, EqRare, Myfe, Myfe, EqEverything, EqPeriodic, EqPeriodic, and Myfe.

Definition at line 270 of file tmfe.h.

270{};

◆ HandlePoll()

virtual bool TMFeEquipment::HandlePoll ( )
inlinevirtual

Reimplemented in EqEverything, and EqTrigger.

Definition at line 273 of file tmfe.h.

273{ return false; };
Here is the caller graph for this function:

◆ HandlePollRead()

virtual void TMFeEquipment::HandlePollRead ( )
inlinevirtual

Reimplemented in EqEverything, and EqTrigger.

Definition at line 274 of file tmfe.h.

274{};
Here is the caller graph for this function:

◆ HandleResumeRun()

virtual TMFeResult TMFeEquipment::HandleResumeRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeRpcHandlerInterface.

Reimplemented in EqRpc, and EqEverything.

Definition at line 265 of file tmfe.h.

265{ return TMFeOk(); };
Here is the call graph for this function:

◆ HandleRpc()

virtual TMFeResult TMFeEquipment::HandleRpc ( const char *  cmd,
const char *  args,
std::string &  response 
)
inlinevirtual

Reimplemented from TMFeRpcHandlerInterface.

Reimplemented in EqRpc, EqEverything, EqTrigger, and Myfe.

Definition at line 267 of file tmfe.h.

267{ return TMFeOk(); };
Here is the call graph for this function:

◆ HandleStartAbortRun()

virtual TMFeResult TMFeEquipment::HandleStartAbortRun ( int  run_number)
inlinevirtual

Reimplemented from TMFeRpcHandlerInterface.

Reimplemented in EqRpc, and EqEverything.

Definition at line 266 of file tmfe.h.

266{ return TMFeOk(); };
Here is the call graph for this function:

◆ HandleUsage()

virtual void TMFeEquipment::HandleUsage ( )
inlinevirtual

Reimplemented in EqEverything, and EqTrigger.

Definition at line 259 of file tmfe.h.

259{};

◆ Init()

TMFeError TMFeEquipment::Init ( )

Initialize equipment.

Definition at line 631 of file tmfe_rev0.cxx.

632{
633 //
634 // create ODB /eq/name/common
635 //
636
637 fOdbEq = fMfe->fOdbRoot->Chdir((std::string("Equipment/") + fName).c_str(), true);
638 fOdbEqCommon = fOdbEq->Chdir("Common", true);
639 fOdbEqSettings = fOdbEq->Chdir("Settings", true);
640 fOdbEqVariables = fOdbEq->Chdir("Variables", true);
641 fOdbEqStatistics = fOdbEq->Chdir("Statistics", true);
642
643 fOdbEqCommon->RU16("Event ID", &fCommon->EventID, true);
644 fOdbEqCommon->RU16("Trigger mask", &fCommon->TriggerMask, true);
645 fOdbEqCommon->RS("Buffer", &fCommon->Buffer, true, NAME_LENGTH);
646 fOdbEqCommon->RI("Type", &fCommon->Type, true);
647 fOdbEqCommon->RI("Source", &fCommon->Source, true);
648 fOdbEqCommon->RS("Format", &fCommon->Format, true, 8);
649 fOdbEqCommon->RB("Enabled", &fCommon->Enabled, true);
650 fOdbEqCommon->RI("Read on", &fCommon->ReadOn, true);
651 fOdbEqCommon->RI("Period", &fCommon->Period, true);
652 fOdbEqCommon->RD("Event limit", &fCommon->EventLimit, true);
653 fOdbEqCommon->RU32("Num subevents", &fCommon->NumSubEvents, true);
654 fOdbEqCommon->RI("Log history", &fCommon->LogHistory, true);
655 fOdbEqCommon->RS("Frontend host", &fCommon->FrontendHost, true, NAME_LENGTH);
656 fOdbEqCommon->RS("Frontend name", &fCommon->FrontendName, true, NAME_LENGTH);
657 fOdbEqCommon->RS("Frontend file name", &fCommon->FrontendFileName, true, 256);
658 fOdbEqCommon->RS("Status", &fCommon->Status, true, 256);
659 fOdbEqCommon->RS("Status color", &fCommon->StatusColor, true, NAME_LENGTH);
660 fOdbEqCommon->RB("Hidden", &fCommon->Hidden, true);
661 fOdbEqCommon->RI("Write cache size", &fCommon->WriteCacheSize, true);
662
666
667 fCommon->Status = "";
669 fCommon->Status += "@";
671 fCommon->StatusColor = "greenLight";
672
673 if (fCommon->Buffer.length() > 0) {
675 if (status != BM_SUCCESS) {
676 return TMFeError(status, "bm_open_buffer");
677 }
678 }
679
680 fOdbEqCommon->WS("Frontend host", fCommon->FrontendHost.c_str(), NAME_LENGTH);
681 fOdbEqCommon->WS("Frontend name", fCommon->FrontendName.c_str(), NAME_LENGTH);
682 fOdbEqCommon->WS("Frontend file name", fCommon->FrontendFileName.c_str(), 256);
683 fOdbEqCommon->WS("Status", fCommon->Status.c_str(), 256);
684 fOdbEqCommon->WS("Status color", fCommon->StatusColor.c_str(), NAME_LENGTH);
685
688
689 return TMFeError();
690};
std::string fFrontendFilename
frontend program file name
Definition tmfe_rev0.h:214
std::string fFrontendHostname
frontend hostname
Definition tmfe_rev0.h:213
std::string fFrontendName
frontend program name
Definition tmfe_rev0.h:212
std::string Status
Definition tmfe_rev0.h:120
int WriteCacheSize
Definition tmfe_rev0.h:123
double EventLimit
Definition tmfe_rev0.h:114
bool Enabled
Definition tmfe_rev0.h:111
int LogHistory
Definition tmfe_rev0.h:116
uint32_t NumSubEvents
Definition tmfe_rev0.h:115
std::string FrontendHost
Definition tmfe_rev0.h:117
std::string FrontendFileName
Definition tmfe_rev0.h:119
bool Hidden
Definition tmfe_rev0.h:122
std::string FrontendName
Definition tmfe_rev0.h:118
std::string Format
Definition tmfe_rev0.h:110
std::string StatusColor
Definition tmfe_rev0.h:121
std::string Buffer
Definition tmfe_rev0.h:107
TMFeError ZeroStatistics()
TMFeError WriteStatistics()
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
Definition midas.cxx:6728
#define BM_SUCCESS
Definition midas.h:605
#define DEFAULT_BUFFER_SIZE
Definition midas.h:255
Here is the call graph for this function:

◆ SendData()

TMFeError TMFeEquipment::SendData ( const char *  data,
int  size 
)

...

Definition at line 738 of file tmfe_rev0.cxx.

739{
740 if (fBufferHandle == 0) {
741 return TMFeError();
742 }
743 int status = bm_send_event(fBufferHandle, (const EVENT_HEADER*)buf, size, BM_WAIT);
744 if (status == BM_CORRUPTED) {
745 TMFE::Instance()->Msg(MERROR, "TMFeEquipment::SendData", "bm_send_event() returned %d, event buffer is corrupted, shutting down the frontend", status);
747 return TMFeError(status, "bm_send_event: event buffer is corrupted, shutting down the frontend");
748 } else if (status != BM_SUCCESS) {
749 return TMFeError(status, "bm_send_event");
750 }
751 fStatEvents += 1;
752 fStatBytes += size;
753 return TMFeError();
754}
INT bm_send_event(INT buffer_handle, const EVENT_HEADER *pevent, int unused, int timeout_msec)
Definition midas.cxx:9689
#define BM_CORRUPTED
Definition midas.h:623
#define BM_WAIT
Definition midas.h:365
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendEvent()

TMFeError TMFeEquipment::SendEvent ( const char *  pevent)

Definition at line 756 of file tmfe_rev0.cxx.

757{
758 fSerial++;
759 return SendData(event, sizeof(EVENT_HEADER) + BkSize(event));
760}
TMFeError SendData(const char *data, int size)
...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetStatus()

TMFeError TMFeEquipment::SetStatus ( const char *  status,
const char *  color 
)

Definition at line 787 of file tmfe_rev0.cxx.

788{
789 HNDLE hDB;
790 int status;
791
793 if (status != CM_SUCCESS) {
794 return TMFeError(status, "cm_get_experiment_database");
795 }
796
797 if (eq_status) {
798 fOdbEqCommon->WS("Status", eq_status, 256);
799 }
800
801 if (eq_color) {
802 fOdbEqCommon->WS("Status color", eq_color, NAME_LENGTH);
803 }
804
805 return TMFeError();
806}
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
Definition midas.cxx:3027
#define CM_SUCCESS
Definition midas.h:582
HNDLE hDB
main ODB handle
Definition mana.cxx:207
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteStatistics()

TMFeError TMFeEquipment::WriteStatistics ( )

Definition at line 706 of file tmfe_rev0.cxx.

707{
708 double now = TMFE::GetTime();
709 double elapsed = now - fStatLastTime;
710
711 if (elapsed > 0.9 || fStatLastTime == 0) {
712 fStatEpS = (fStatEvents - fStatLastEvents) / elapsed;
713 fStatKBpS = (fStatBytes - fStatLastBytes) / elapsed / 1000.0;
714
715 fStatLastTime = now;
718 }
719
720 fOdbEqStatistics->WD("Events sent", fStatEvents);
721 fOdbEqStatistics->WD("Events per sec.", fStatEpS);
722 fOdbEqStatistics->WD("kBytes per sec.", fStatKBpS);
723
724 return TMFeError();
725}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZeroStatistics()

TMFeError TMFeEquipment::ZeroStatistics ( )

Definition at line 692 of file tmfe_rev0.cxx.

693{
694 fStatEvents = 0;
695 fStatBytes = 0;
696 fStatEpS = 0;
697 fStatKBpS = 0;
698
699 fStatLastTime = 0;
700 fStatLastEvents = 0;
701 fStatLastBytes = 0;
702
703 return TMFeError();
704}
Here is the caller graph for this function:

Member Data Documentation

◆ fBufferHandle

int TMFeEquipment::fBufferHandle

Definition at line 140 of file tmfe_rev0.h.

◆ fCommon

TMFeCommon* TMFeEquipment::fCommon

Definition at line 136 of file tmfe_rev0.h.

◆ fEqConfBuffer

std::string TMFeEquipment::fEqConfBuffer = "SYSTEM"

Definition at line 173 of file tmfe.h.

◆ fEqConfBufferSize

size_t TMFeEquipment::fEqConfBufferSize = 0

Definition at line 201 of file tmfe.h.

◆ fEqConfEnabled

bool TMFeEquipment::fEqConfEnabled = true

Definition at line 170 of file tmfe.h.

◆ fEqConfEnablePeriodic

bool TMFeEquipment::fEqConfEnablePeriodic = true

Definition at line 165 of file tmfe.h.

◆ fEqConfEnablePoll

bool TMFeEquipment::fEqConfEnablePoll = false

Definition at line 166 of file tmfe.h.

◆ fEqConfEnableRpc

bool TMFeEquipment::fEqConfEnableRpc = true

Definition at line 164 of file tmfe.h.

◆ fEqConfEventID

uint16_t TMFeEquipment::fEqConfEventID = 1

Definition at line 171 of file tmfe.h.

◆ fEqConfEventLimit

double TMFeEquipment::fEqConfEventLimit = 0

Definition at line 179 of file tmfe.h.

◆ fEqConfFormat

std::string TMFeEquipment::fEqConfFormat = "MIDAS"

Definition at line 176 of file tmfe.h.

◆ fEqConfHidden

bool TMFeEquipment::fEqConfHidden = false

Definition at line 182 of file tmfe.h.

◆ fEqConfLogHistory

int TMFeEquipment::fEqConfLogHistory = 0

Definition at line 181 of file tmfe.h.

◆ fEqConfMaxEventSize

size_t TMFeEquipment::fEqConfMaxEventSize = 0

Definition at line 200 of file tmfe.h.

◆ fEqConfNumSubEvents

uint32_t TMFeEquipment::fEqConfNumSubEvents = 0

Definition at line 180 of file tmfe.h.

◆ fEqConfPeriodMilliSec

int TMFeEquipment::fEqConfPeriodMilliSec = 1000

Definition at line 178 of file tmfe.h.

◆ fEqConfPeriodStatisticsSec

double TMFeEquipment::fEqConfPeriodStatisticsSec = 1.0

Definition at line 198 of file tmfe.h.

◆ fEqConfPollSleepSec

double TMFeEquipment::fEqConfPollSleepSec = 0.000100

Definition at line 199 of file tmfe.h.

◆ fEqConfReadConfigFromOdb

bool TMFeEquipment::fEqConfReadConfigFromOdb = true

Definition at line 168 of file tmfe.h.

◆ fEqConfReadOn

int TMFeEquipment::fEqConfReadOn = 0

Definition at line 177 of file tmfe.h.

◆ fEqConfReadOnlyWhenRunning

bool TMFeEquipment::fEqConfReadOnlyWhenRunning = true

Definition at line 196 of file tmfe.h.

◆ fEqConfSource

int TMFeEquipment::fEqConfSource = 0

Definition at line 175 of file tmfe.h.

◆ fEqConfTriggerMask

uint16_t TMFeEquipment::fEqConfTriggerMask = 0

Definition at line 172 of file tmfe.h.

◆ fEqConfType

int TMFeEquipment::fEqConfType = 0

Definition at line 174 of file tmfe.h.

◆ fEqConfWriteCacheSize

int TMFeEquipment::fEqConfWriteCacheSize = 10000000

Definition at line 186 of file tmfe.h.

◆ fEqConfWriteEventsToOdb

bool TMFeEquipment::fEqConfWriteEventsToOdb = false

Definition at line 197 of file tmfe.h.

◆ fEqEventBuffer

TMEventBuffer* TMFeEquipment::fEqEventBuffer = NULL

Definition at line 218 of file tmfe.h.

◆ fEqFilename

std::string TMFeEquipment::fEqFilename

Definition at line 160 of file tmfe.h.

◆ fEqMutex

std::mutex TMFeEquipment::fEqMutex

Definition at line 204 of file tmfe.h.

◆ fEqName

std::string TMFeEquipment::fEqName

Definition at line 159 of file tmfe.h.

◆ fEqPeriodicLastCallTime

double TMFeEquipment::fEqPeriodicLastCallTime = 0

Definition at line 237 of file tmfe.h.

◆ fEqPeriodicNextCallTime

double TMFeEquipment::fEqPeriodicNextCallTime = 0

Definition at line 238 of file tmfe.h.

◆ fEqPollThread

std::thread* TMFeEquipment::fEqPollThread = NULL

Definition at line 277 of file tmfe.h.

◆ fEqPollThreadRunning

std::atomic_bool TMFeEquipment::fEqPollThreadRunning {false}

Definition at line 242 of file tmfe.h.

242{false};

◆ fEqPollThreadShutdownRequested

std::atomic_bool TMFeEquipment::fEqPollThreadShutdownRequested {false}

Definition at line 243 of file tmfe.h.

243{false};

◆ fEqPollThreadStarting

std::atomic_bool TMFeEquipment::fEqPollThreadStarting {false}

Definition at line 241 of file tmfe.h.

241{false};

◆ fEqSerial

int TMFeEquipment::fEqSerial = 0

Definition at line 219 of file tmfe.h.

◆ fEqStatBytes

double TMFeEquipment::fEqStatBytes = 0

Definition at line 223 of file tmfe.h.

◆ fEqStatEpS

double TMFeEquipment::fEqStatEpS = 0

Definition at line 224 of file tmfe.h.

◆ fEqStatEvents

double TMFeEquipment::fEqStatEvents = 0

Definition at line 222 of file tmfe.h.

◆ fEqStatKBpS

double TMFeEquipment::fEqStatKBpS = 0

Definition at line 225 of file tmfe.h.

◆ fEqStatLastBytes

double TMFeEquipment::fEqStatLastBytes = 0

Definition at line 230 of file tmfe.h.

◆ fEqStatLastEvents

double TMFeEquipment::fEqStatLastEvents = 0

Definition at line 229 of file tmfe.h.

◆ fEqStatLastTime

double TMFeEquipment::fEqStatLastTime = 0

Definition at line 228 of file tmfe.h.

◆ fEqStatLastWrite

double TMFeEquipment::fEqStatLastWrite = 0

Definition at line 233 of file tmfe.h.

◆ fEqStatNextWrite

double TMFeEquipment::fEqStatNextWrite = 0

Definition at line 234 of file tmfe.h.

◆ fFe

TMFrontend* TMFeEquipment::fFe = NULL

Definition at line 208 of file tmfe.h.

◆ fMfe

TMFE * TMFeEquipment::fMfe = NULL

Definition at line 207 of file tmfe.h.

◆ fName

std::string TMFeEquipment::fName

Definition at line 135 of file tmfe_rev0.h.

◆ fOdbEq

MVOdb * TMFeEquipment::fOdbEq = NULL

ODB Equipment/EQNAME.

Definition at line 211 of file tmfe.h.

◆ fOdbEqCommon

MVOdb * TMFeEquipment::fOdbEqCommon = NULL

ODB Equipment/EQNAME/Common.

Definition at line 212 of file tmfe.h.

◆ fOdbEqSettings

MVOdb * TMFeEquipment::fOdbEqSettings = NULL

ODB Equipment/EQNAME/Settings.

Definition at line 213 of file tmfe.h.

◆ fOdbEqStatistics

MVOdb * TMFeEquipment::fOdbEqStatistics = NULL

ODB Equipment/EQNAME/Statistics.

Definition at line 215 of file tmfe.h.

◆ fOdbEqVariables

MVOdb * TMFeEquipment::fOdbEqVariables = NULL

ODB Equipment/EQNAME/Variables.

Definition at line 214 of file tmfe.h.

◆ fSerial

int TMFeEquipment::fSerial

Definition at line 141 of file tmfe_rev0.h.

◆ fStatBytes

double TMFeEquipment::fStatBytes

Definition at line 152 of file tmfe_rev0.h.

◆ fStatEpS

double TMFeEquipment::fStatEpS

Definition at line 153 of file tmfe_rev0.h.

◆ fStatEvents

double TMFeEquipment::fStatEvents

Definition at line 151 of file tmfe_rev0.h.

◆ fStatKBpS

double TMFeEquipment::fStatKBpS

Definition at line 154 of file tmfe_rev0.h.

◆ fStatLastBytes

double TMFeEquipment::fStatLastBytes

Definition at line 158 of file tmfe_rev0.h.

◆ fStatLastEvents

double TMFeEquipment::fStatLastEvents

Definition at line 157 of file tmfe_rev0.h.

◆ fStatLastTime

double TMFeEquipment::fStatLastTime

Definition at line 156 of file tmfe_rev0.h.


The documentation for this class was generated from the following files: