1 #ifndef __JRUNCONTROL__JDAQDRIVER__ 
    2 #define __JRUNCONTROL__JDAQDRIVER__ 
   54       timeout_s (timeout_s),
 
   70       using namespace JLANG;
 
  116                 if (i->isActive() && i->getBorn() <= i->getDied()) {
 
  122             return CHSM::machine::enter();
 
  125             cerr << 
"Timeout at subscription." << endl;
 
  129           cerr << error << endl;
 
  133         cerr << 
"Message server or logger not properly initialised." << endl;
 
  149       using namespace JLANG;
 
  192         JWarningStream(
logger) << 
"Timeout at transition " << 
event.name() << 
" to state " << state.name(); 
 
  211       using namespace JNET;
 
  219         if ( no_wait && 
server->CheckHead(tag, length) <= 0) { 
return false; }
 
  220         if (!no_wait && 
server->WaitHead (tag, length) <  0) { 
return false; }
 
  222         char* data= 
new char[length];
 
  224         server->GetFullData(data, length);
 
  226         const string buffer(data, length);
 
  236         } 
else if (buffer.find(
getFullName()) != string::npos) {
 
  245           JClientList::iterator i = 
clientList.find(buffer);
 
  249             i->update(tag, buffer);
 
  263                 istringstream is(buffer);
 
  271                   JClient client(name, hostname);
 
  273                   client.update(tag, buffer);
 
  274                   client.setMode(JClient::ILLEGAL);
 
  360     void run(std::istream& in)
 
  364       for (
string key; in >> key; ) {
 
  368           in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  370         } 
else if (key == 
"enter") {
 
  375             cerr << 
"State machine not entered; abort." << endl;
 
  379         } 
else if (key == 
"exit") {
 
  384         } 
else if (key == 
"quit") {
 
  388         } 
else if (key == 
"sleep") {
 
  396         } 
else if (key == 
"process") {
 
  402           istringstream is(buffer);
 
  408             client.setMode(JClient::ACTIVE);
 
  418         } 
else if (key == 
"event" || key == 
"event*") {
 
  423           const char eol = 
'\n';
 
  425           if (in >> event >> c && c == 
'{' && 
getline(in, buffer, 
'}')) {
 
  431               if (pev->active() || key == 
"event*") {
 
  433                 istringstream is(buffer);
 
  435                 for (
string tag; is >> tag; ) {
 
  443                   server->PutFullString(tag, os.str());
 
  446                 if (key != 
"event*") {
 
  462         } 
else if (key == 
"print") {
 
  466                                   << i->getStartCommand() << 
' ' 
  467                                   << i->getAlive()        << 
' ' 
  468                                   << i->getStatename();
 
  471         } 
else if (key == 
"filter") {
 
  478           for (istringstream is(buffer); is >> client; ) {
 
  482         } 
else if (key == 
"sync") {
 
  490           in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  504       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(Main.RunControl);
 
  506       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  508         if (state->active()) {
 
  527       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(Main.RunControl);
 
  529       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  531         if (state->active()) {
 
  539               if (i->getMode() == JClient::ACTIVE) {
 
  541                 if (!i->getAlive()) {
 
  551                       if (buffer.find(i->getHostname()) == string::npos) {
 
  552                         JErrorStream(
logger) << i->getFullName() << 
" running on " << buffer << 
" but not alive.";
 
  561                 if (i->getAlive() && i->getStatename() != state->name()) {
 
  592       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(Main.RunControl);
 
  594       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  596         if (state->active()) {
 
  600             if (
target == 
"" || i->getName().find(
target) != std::string::npos) {
 
  602               if (!i->getAlive() || i->getStatename() != state->name()) {
 
  606                 i->setMode(JClient::SLEEP);
 
  630     static void copy(std::istream& in, std::ostream& out, 
const char eol = 
'\n') 
 
  636       if (
getline(in, buffer, eol)) {
 
  638         for (string::size_type pos = 0; pos < buffer.length(); ) {
 
  643           if (lpos != string::npos && 
 
  644               rpos != string::npos) {
 
  646             out << buffer.substr(pos, lpos);
 
  651             ifstream file(buffer.substr(pos, rpos - lpos).c_str());
 
  653             copy(file, out, 
'\0');
 
  660             out << buffer.substr(pos);
 
  662             pos  += buffer.substr(pos).length();
 
static const std::string FILENAME_PREFIX
 
int timeout_s
timeout of state transitions [s] 
 
const std::string & getName() const 
Get event name. 
 
static const JTag DISPTAG_Died("Died")
 
static const std::string FILENAME_POSTFIX
 
ControlHost client manager. 
 
virtual bool enter()
Enter the state machine. 
 
JTag getUniqueTag(const std::string &hostname, const std::string &name)
Get unique tag of run control client. 
 
virtual void actionStop(int, const char *)
 
List of ControlHost client managers. 
 
virtual void actionStart(int, const char *)
 
Interface for logging messages. 
 
static void copy(std::istream &in, std::ostream &out, const char eol= '\n')
Copy data from input to output stream. 
 
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
 
JSharedPointer< JControlHost > server
message server 
 
static const std::string TOKEN_DELIMETER
 
Simple driver for run control clients. 
 
void enterState(const CHSM::state &state, const CHSM::event &event)
Action when entering state. 
 
void synchronise()
Synchronise clients. 
 
void run()
Run driver with user input. 
 
static const std::string RUN_CONTROL_CLIENT
 
void actionExit()
Exit the state machine. 
 
static const JNET::JTag RC_LOG
 
static const JNET::JTag RC_REPLY
 
bool update(const bool no_wait)
Update client list with incoming ControlHost message. 
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line. 
 
Auxiliary class for handling event name and optional number. 
 
Level specific message streamers. 
 
Exception for ControlHost. 
 
virtual bool exit()
Exit the state machine. 
 
char getTokenDelimeter()
Get the token delimeter for command messages. 
 
Auxiliary class for all subscription. 
 
void run(std::istream &in)
Run driver. 
 
static const JTag DISPTAG_Born("Born")
 
JDAQDriver(const std::string &name, const std::string &server, JLogger *logger, const int level, const int timeout_s)
Constructor. 
 
bool is_valid() const 
Check validity of logger object. 
 
Auxiliary class to specify white space character(s) in currect locale. 
 
Run control client base class. 
 
void filter(const std::string &target="")
Filter client list by putting failing clients to sleep. 
 
JMessageLogger logger
message logger 
 
static const JNET::JTag RC_CMD
 
static int WhereIs(const std::string &host_name, const std::string &nick_name, std::string &answer)
Locate ControlHost client(s). 
 
JDAQStateMachine::ev_daq_event JDAQEvent_t
Type definition of a DAQ event. 
 
const std::string & getFullName() const 
Get full name of this run control client. 
 
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
 
JDAQEvent_t * findEvent(const JNET::JTag &tag, const std::string &event_name)
Find event in event table.