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
 
voidBkOpen (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)
 
voidBkOpen (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
 
MVOdbfOdbEq = NULL
 ODB Equipment/EQNAME.
 
MVOdbfOdbEqCommon = NULL
 ODB Equipment/EQNAME/Common.
 
MVOdbfOdbEqSettings = NULL
 ODB Equipment/EQNAME/Settings.
 
MVOdbfOdbEqVariables = NULL
 ODB Equipment/EQNAME/Variables.
 
MVOdbfOdbEqStatistics = 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 1653 of file tmfe.cxx.

1654{
1655 assert(eqname != NULL);
1656 assert(eqfilename != NULL);
1657
1658 if (TMFE::gfVerbose)
1659 printf("TMFeEquipment::ctor: equipment name [%s] file [%s]\n", eqname, eqfilename);
1660
1661 fMfe = TMFE::Instance();
1662 fEqName = eqname;
1665}
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
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~TMFeEquipment()

TMFeEquipment::~TMFeEquipment ( )
virtual

Definition at line 1667 of file tmfe.cxx.

1668{
1669 if (TMFE::gfVerbose)
1670 printf("TMFeEquipment::dtor: equipment name [%s]\n", fEqName.c_str());
1671
1673
1674 // free data and poison pointers
1675 if (fOdbEq) {
1676 delete fOdbEq;
1677 fOdbEq = NULL;
1678 }
1679 if (fOdbEqCommon) {
1680 delete fOdbEqCommon;
1682 }
1683 if (fOdbEqSettings) {
1684 delete fOdbEqSettings;
1686 }
1687 if (fOdbEqVariables) {
1688 delete fOdbEqVariables;
1690 }
1691 if (fOdbEqStatistics) {
1692 delete fOdbEqStatistics;
1694 }
1695 fMfe = NULL;
1696 fFe = NULL;
1698}
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;
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
Here is the call graph for this function:

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:2190
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16780
Here is the call graph for this function:

◆ BkClose() [2/2]

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

Definition at line 2208 of file tmfe.cxx.

2209{
2210 bk_close(event + sizeof(EVENT_HEADER), ptr);
2211 ((EVENT_HEADER*)event)->data_size = BkSize(event);
2212 return TMFeOk();
2213}
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:16469
Here is the call graph for this function:

◆ BkInit() [2/2]

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

Definition at line 2195 of file tmfe.cxx.

2196{
2197 bk_init32a(event + sizeof(EVENT_HEADER));
2198 return TMFeOk();
2199}
void bk_init32a(void *event)
Definition midas.cxx:16482
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:16561
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 2201 of file tmfe.cxx.

2202{
2203 void* ptr;
2204 bk_create(event + sizeof(EVENT_HEADER), name, tid, &ptr);
2205 return ptr;
2206}
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:16495
Here is the call graph for this function:

◆ BkSize() [2/2]

int TMFeEquipment::BkSize ( const char pevent) const

Definition at line 2190 of file tmfe.cxx.

2191{
2192 return bk_size(event + sizeof(EVENT_HEADER));
2193}
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:852
DWORD data_size
Definition midas.h:856
DWORD serial_number
Definition midas.h:854
DWORD time_stamp
Definition midas.h:855
short int trigger_mask
Definition midas.h:853
Here is the call graph for this function:

◆ ComposeEvent() [2/2]

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

Definition at line 1995 of file tmfe.cxx.

1996{
1997 EVENT_HEADER* pevent = (EVENT_HEADER*)event;
1998 pevent->event_id = fEqConfEventID;
2000 pevent->serial_number = fEqSerial;
2001 pevent->time_stamp = TMFE::GetTime();
2002 pevent->data_size = 0;
2003 return TMFeOk();
2004}
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 1700 of file tmfe.cxx.

1701{
1702 TMFeResult r;
1703
1704 r = EqPreInit();
1705 if (r.error_flag)
1706 return r;
1707
1708 r = HandleInit(args);
1709 if (r.error_flag)
1710 return r;
1711
1712 r = EqPostInit();
1713 if (r.error_flag)
1714 return r;
1715
1716 return TMFeOk();
1717}
virtual TMFeResult HandleInit(const std::vector< std::string > &args)
Definition tmfe.h:258
TMFeResult EqPreInit()
Initialize equipment, before EquipmentBase::Init()
Definition tmfe.cxx:1803
TMFeResult EqPostInit()
Initialize equipment, after EquipmentBase::Init()
Definition tmfe.cxx:1853
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 1853 of file tmfe.cxx.

1854{
1855 if (TMFE::gfVerbose)
1856 printf("TMFeEquipment::EqPostInit: for [%s]\n", fEqName.c_str());
1857
1858 if (!fEqConfEnabled) {
1859 EqSetStatus("Disabled", "yellowLight");
1860 }
1861
1862 // open event buffer
1863
1865 fMfe->fOdbRoot->RU32("Experiment/MAX_EVENT_SIZE", &odb_max_event_size, true);
1866
1867 if (fEqConfMaxEventSize == 0) {
1870 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);
1872 }
1873
1874 if (!fEqConfBuffer.empty()) {
1876
1877 if (r.error_flag)
1878 return r;
1879
1880 assert(fEqEventBuffer != NULL);
1881
1883 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);
1885 }
1886
1887 if (fEqConfWriteCacheSize > 0) {
1890
1891 if (r.error_flag)
1892 return r;
1894 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);
1896 // do nothing
1897 } else {
1898 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);
1899
1901
1902 if (r.error_flag)
1903 return r;
1904 }
1905 }
1906 }
1907
1908 if (TMFE::gfVerbose)
1909 printf("TMFeEquipment::EqPostInit: Equipment \"%s\", max event size: %d\n", fEqName.c_str(), (int)fEqConfMaxEventSize);
1910
1911 // update ODB common
1912
1914
1915 if (r.error_flag)
1916 return r;
1917
1919 fMfe->AddRpcHandler(this);
1920 }
1921
1922 return TMFeOk();
1923};
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:1526
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:2215
TMFeResult EqWriteCommon(bool create=false)
Write TMFeEqInfo to ODB /Equipment/NAME/Common.
Definition tmfe.cxx:1762
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 1803 of file tmfe.cxx.

1804{
1805 if (TMFE::gfVerbose)
1806 printf("TMFeEquipment::PreInit: for [%s]\n", fEqName.c_str());
1807
1808 //
1809 // Apply frontend index
1810 //
1811
1812 if (fEqName.find("%") != std::string::npos) {
1813 fEqName = msprintf(fEqName.c_str(), fFe->fFeIndex);
1814 }
1815
1816 if (fEqConfBuffer.find("%") != std::string::npos) {
1818 }
1819
1820 //
1821 // create ODB /eq/name/common
1822 //
1823
1824 fOdbEq = fMfe->fOdbRoot->Chdir((std::string("Equipment/") + fEqName).c_str(), true);
1825 fOdbEqCommon = fOdbEq->Chdir("Common", false);
1826 if (!fOdbEqCommon) {
1827 if (TMFE::gfVerbose)
1828 printf("TMFeEquipment::PreInit: creating ODB common\n");
1829 fOdbEqCommon = fOdbEq->Chdir("Common", true);
1830 EqWriteCommon(true);
1831 }
1832 fOdbEqSettings = fOdbEq->Chdir("Settings", true);
1833 fOdbEqVariables = fOdbEq->Chdir("Variables", true);
1834 fOdbEqStatistics = fOdbEq->Chdir("Statistics", true);
1835
1837
1838 if (r.error_flag)
1839 return r;
1840
1841 if (rpc_is_remote()) {
1842 EqSetStatus((fMfe->fProgramName + "@" + fMfe->fHostname).c_str(), "greenLight");
1843 } else {
1844 EqSetStatus(fMfe->fProgramName.c_str(), "greenLight");
1845 }
1846
1849
1850 return TMFeOk();
1851}
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:1719
TMFeResult EqWriteStatistics()
Definition tmfe.cxx:1950
TMFeResult EqZeroStatistics()
Definition tmfe.cxx:1925
int fFeIndex
Definition tmfe.h:313
bool rpc_is_remote(void)
Definition midas.cxx:12761
std::string msprintf(const char *format,...)
Definition midas.cxx:410
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 1719 of file tmfe.cxx.

1720{
1721 if (TMFE::gfVerbose)
1722 printf("TMFeEquipment::EqReadCommon: for [%s]\n", fEqName.c_str());
1723
1724 // list of ODB Common entries always read
1725
1726 fOdbEqCommon->RB("Enabled", &fEqConfEnabled, true);
1727 fOdbEqCommon->RD("Event limit", &fEqConfEventLimit, true);
1728
1730 // list of ODB Common entries read if we want to control equipment from ODB
1731
1732 fOdbEqCommon->RU16("Event ID", &fEqConfEventID, true);
1733 fOdbEqCommon->RU16("Trigger mask", &fEqConfTriggerMask, true);
1734 fOdbEqCommon->RS("Buffer", &fEqConfBuffer, true, NAME_LENGTH);
1735 fOdbEqCommon->RI("Type", &fEqConfType, true);
1736 fOdbEqCommon->RI("Source", &fEqConfSource, true);
1737 fOdbEqCommon->RS("Format", &fEqConfFormat, true, 8);
1738 fOdbEqCommon->RI("Read on", &fEqConfReadOn, true);
1739 fOdbEqCommon->RI("Period", &fEqConfPeriodMilliSec, true);
1740 fOdbEqCommon->RU32("Num subevents", &fEqConfNumSubEvents, true);
1741 fOdbEqCommon->RI("Log history", &fEqConfLogHistory, true);
1742 fOdbEqCommon->RB("Hidden", &fEqConfHidden, true);
1743 fOdbEqCommon->RI("Write cache size", &fEqConfWriteCacheSize, true);
1744
1745 // decode data from ODB Common
1746
1749 }
1750
1751 // list of ODB Common entries we read and write back to ODB, but do not actually use.
1752
1753 //fOdbEqCommon->RS("Frontend host", &fEqConfFrontendHost, true, NAME_LENGTH);
1754 //fOdbEqCommon->RS("Frontend name", &fEqConfFrontendName, true, NAME_LENGTH);
1755 //fOdbEqCommon->RS("Frontend file name", &fEqConfFrontendFileName, true, 256);
1756 //fOdbEqCommon->RS("Status", &fEqConfStatus, true, 256);
1757 //fOdbEqCommon->RS("Status color", &fEqConfStatusColor, true, NAME_LENGTH);
1758
1759 return TMFeOk();
1760}
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 2006 of file tmfe.cxx.

2007{
2008 std::lock_guard<std::mutex> guard(fEqMutex);
2009
2010 fEqSerial++;
2011
2012 EVENT_HEADER* pevent = (EVENT_HEADER*)event;
2013 pevent->data_size = BkSize(event);
2014
2015 if (fEqEventBuffer != NULL) {
2017
2018 if (r.error_flag)
2019 return r;
2020 }
2021
2022 fEqStatEvents += 1;
2023 fEqStatBytes += sizeof(EVENT_HEADER) + pevent->data_size;
2024
2027 if (r.error_flag)
2028 return r;
2029 }
2030
2031 if (fMfe->fStateRunning) {
2032 if (fEqConfEventLimit > 0) {
2034 if (!fMfe->fRunStopRequested) {
2035 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2036 }
2037 fMfe->fRunStopRequested = true;
2038 }
2039 }
2040 }
2041
2042 return TMFeOk();
2043}
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:2169
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 2045 of file tmfe.cxx.

2046{
2047 std::lock_guard<std::mutex> guard(fEqMutex);
2048
2049 fEqSerial++;
2050
2051 if (fEqEventBuffer == NULL) {
2052 return TMFeOk();
2053 }
2054
2056
2057 if (r.error_flag)
2058 return r;
2059
2060 fEqStatEvents += 1;
2061 fEqStatBytes += event.size();
2062
2064 TMFeResult r = EqWriteEventToOdb_locked(event.data());
2065 if (r.error_flag)
2066 return r;
2067 }
2068
2069 if (fMfe->fStateRunning) {
2070 if (fEqConfEventLimit > 0) {
2072 if (!fMfe->fRunStopRequested) {
2073 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2074 }
2075 fMfe->fRunStopRequested = true;
2076 }
2077 }
2078 }
2079
2080 return TMFeOk();
2081}
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 2083 of file tmfe.cxx.

2084{
2085 std::lock_guard<std::mutex> guard(fEqMutex);
2086
2087 fEqSerial++;
2088
2089 if (fEqEventBuffer == NULL) {
2090 return TMFeOk();
2091 }
2092
2094
2095 if (r.error_flag)
2096 return r;
2097
2098 fEqStatEvents += 1;
2099 for (auto v: event) {
2100 fEqStatBytes += v.size();
2101 }
2102
2103 //if (fEqConfWriteEventsToOdb && write_to_odb) {
2104 // TMFeResult r = EqWriteEventToOdb_locked(event.data());
2105 // if (r.error_flag)
2106 // return r;
2107 //}
2108
2109 if (fMfe->fStateRunning) {
2110 if (fEqConfEventLimit > 0) {
2112 if (!fMfe->fRunStopRequested) {
2113 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2114 }
2115 fMfe->fRunStopRequested = true;
2116 }
2117 }
2118 }
2119
2120 return TMFeOk();
2121}
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 2123 of file tmfe.cxx.

2124{
2125 std::lock_guard<std::mutex> guard(fEqMutex);
2126
2127 fEqSerial++;
2128
2129 if (fEqEventBuffer == NULL) {
2130 return TMFeOk();
2131 }
2132
2134
2135 if (r.error_flag)
2136 return r;
2137
2138 fEqStatEvents += 1;
2139 for (int i=0; i<sg_n; i++) {
2140 fEqStatBytes += sg_len[i];
2141 }
2142
2143 //if (fEqConfWriteEventsToOdb && write_to_odb) {
2144 // TMFeResult r = EqWriteEventToOdb_locked(event.data());
2145 // if (r.error_flag)
2146 // return r;
2147 //}
2148
2149 if (fMfe->fStateRunning) {
2150 if (fEqConfEventLimit > 0) {
2152 if (!fMfe->fRunStopRequested) {
2153 fMfe->Msg(MINFO, "TMFeEquipment::EqSendEvent", "Equipment \"%s\" sent %.0f events out of %.0f requested, run will stop now", fEqName.c_str(), fEqStatEvents, fEqConfEventLimit);
2154 }
2155 fMfe->fRunStopRequested = true;
2156 }
2157 }
2158 }
2159
2160 return TMFeOk();
2161}
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 2215 of file tmfe.cxx.

2216{
2217 if (eq_status) {
2218 fOdbEqCommon->WS("Status", eq_status, 256);
2219 }
2220
2221 if (eq_color) {
2222 fOdbEqCommon->WS("Status color", eq_color, NAME_LENGTH);
2223 }
2224
2225 return TMFeOk();
2226}
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;
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 1762 of file tmfe.cxx.

1763{
1764 if (TMFE::gfVerbose)
1765 printf("TMFeEquipment::EqWriteCommon: for [%s]\n", fEqName.c_str());
1766
1767 // encode data for ODB Common
1768
1769 fEqConfReadOn = 0;
1772 else
1776
1777 // write to ODB
1778
1779 fOdbEqCommon->WU16("Event ID", fEqConfEventID);
1780 fOdbEqCommon->WU16("Trigger mask", fEqConfTriggerMask);
1781 fOdbEqCommon->WS("Buffer", fEqConfBuffer.c_str(), NAME_LENGTH);
1782 fOdbEqCommon->WI("Type", fEqConfType);
1783 fOdbEqCommon->WI("Source", fEqConfSource);
1784 fOdbEqCommon->WS("Format", fEqConfFormat.c_str(), 8);
1785 fOdbEqCommon->WB("Enabled", fEqConfEnabled);
1786 fOdbEqCommon->WI("Read on", fEqConfReadOn);
1787 fOdbEqCommon->WI("Period", fEqConfPeriodMilliSec);
1788 fOdbEqCommon->WD("Event limit", fEqConfEventLimit);
1789 fOdbEqCommon->WU32("Num subevents", fEqConfNumSubEvents);
1790 fOdbEqCommon->WI("Log history", fEqConfLogHistory);
1791 fOdbEqCommon->WS("Frontend host", fMfe->fHostname.c_str(), NAME_LENGTH);
1792 fOdbEqCommon->WS("Frontend name", fMfe->fProgramName.c_str(), NAME_LENGTH);
1793 fOdbEqCommon->WS("Frontend file name", fEqFilename.c_str(), 256);
1794 if (create) {
1795 fOdbEqCommon->WS("Status", "", 256);
1796 fOdbEqCommon->WS("Status color", "", NAME_LENGTH);
1797 }
1798 fOdbEqCommon->WB("Hidden", fEqConfHidden);
1799 fOdbEqCommon->WI("Write cache size", fEqConfWriteCacheSize);
1800 return TMFeOk();
1801}
#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 2163 of file tmfe.cxx.

2164{
2165 std::lock_guard<std::mutex> guard(fEqMutex);
2166 return EqWriteEventToOdb_locked(event);
2167}
Here is the call graph for this function:

◆ EqWriteEventToOdb_locked()

TMFeResult TMFeEquipment::EqWriteEventToOdb_locked ( const char pevent)
private

Definition at line 2169 of file tmfe.cxx.

2170{
2171 std::string path = "";
2172 path += "/Equipment/";
2173 path += fEqName;
2174 path += "/Variables";
2175
2176 HNDLE hKeyVar = 0;
2177
2178 int status = db_find_key(fMfe->fDB, 0, path.c_str(), &hKeyVar);
2179 if (status != DB_SUCCESS) {
2180 return TMFeMidasError(msprintf("Cannot find \"%s\" in ODB", path.c_str()), "db_find_key", status);
2181 }
2182
2183 status = cm_write_event_to_odb(fMfe->fDB, hKeyVar, (const EVENT_HEADER*) event, FORMAT_MIDAS);
2184 if (status != SUCCESS) {
2185 return TMFeMidasError("Cannot write event to ODB", "cm_write_event_to_odb", status);
2186 }
2187 return TMFeOk();
2188}
int fDB
ODB database handle.
Definition tmfe.h:394
#define DB_SUCCESS
Definition midas.h:631
#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:4079
int cm_write_event_to_odb(HNDLE hDB, HNDLE hKey, const EVENT_HEADER *pevent, INT format)
Definition midas.cxx:17723
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 1950 of file tmfe.cxx.

1951{
1952 fEqMutex.lock();
1953
1954 if (TMFE::gfVerbose)
1955 printf("TMFeEquipment::EqWriteStatistics: write statistics for [%s]\n", fEqName.c_str());
1956
1957 double now = TMFE::GetTime();
1958 double elapsed = now - fEqStatLastTime;
1959
1960 if (elapsed > 0.9 || fEqStatLastTime == 0) {
1963
1967 }
1968
1969 //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);
1970
1971 fOdbEqStatistics->WD("Events sent", fEqStatEvents);
1972 fOdbEqStatistics->WD("Events per sec.", fEqStatEpS);
1973 fOdbEqStatistics->WD("kBytes per sec.", fEqStatKBpS);
1974
1976
1978 // avoid creep of NextWrite: we start it at
1979 // time of initialization, then increment it strictly
1980 // by the period value, regardless of when it is actually
1981 // written to ODB (actual period is longer than requested
1982 // period because we only over-sleep, never under-sleep). K.O.
1983 while (fEqStatNextWrite <= now) {
1985 }
1986 } else {
1988 }
1989
1990 fEqMutex.unlock();
1991
1992 return TMFeOk();
1993}
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 1925 of file tmfe.cxx.

1926{
1927 fEqMutex.lock();
1928
1929 if (TMFE::gfVerbose)
1930 printf("TMFeEquipment::EqZeroStatistics: zero statistics for [%s]\n", fEqName.c_str());
1931
1932 double now = TMFE::GetTime();
1933
1934 fEqStatEvents = 0;
1935 fEqStatBytes = 0;
1936 fEqStatEpS = 0;
1937 fEqStatKBpS = 0;
1938
1941 fEqStatLastBytes = 0;
1942
1943 fEqStatNextWrite = now; // force immediate update
1944
1945 fEqMutex.unlock();
1946
1947 return TMFeOk();
1948}
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:6717
#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:9678
#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:3011
#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) {
714
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: