1 #ifndef __JRUNCONTROL__JDAQDRIVER__ 
    2 #define __JRUNCONTROL__JDAQDRIVER__ 
   54       timeout_s (timeout_s),
 
   70       using namespace JLANG;
 
  111                 if (i->isActive() && i->getBorn() <= i->getDied()) {
 
  117             return CHSM::machine::enter();
 
  120             cerr << 
"Timeout at subscription." << endl;
 
  124           cerr << error << endl;
 
  128         cerr << 
"Message server or logger not properly initialised." << endl;
 
  144       using namespace JLANG;
 
  172     virtual void enterState(
const CHSM::state& state, 
const CHSM::event& event)
 override 
  182         JWarningStream(
logger) << 
"Timeout at transition " << 
event.name() << 
" to state " << state.name(); 
 
  201       using namespace JNET;
 
  207         long long int length = 0;
 
  209         if ( no_wait && 
server->CheckHead(tag, length) <= 0) { 
return false; }
 
  210         if (!no_wait && 
server->WaitHead (tag, length) <  0) { 
return false; }
 
  212         char* data= 
new char[length];
 
  214         server->GetFullData(data, length);
 
  216         const string buffer(data, length);
 
  226         } 
else if (buffer.find(
getFullName()) != string::npos) {
 
  235           JClientList::iterator i = 
clientList.find(buffer);
 
  239             i->update(tag, buffer);
 
  253                 istringstream 
is(buffer);
 
  263                   client.update(tag, buffer);
 
  264                   client.setMode(JClient::ILLEGAL);
 
  354       for (
string key; in >> key; ) {
 
  358           in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  360         } 
else if (key == 
"enter") {
 
  365             cerr << 
"State machine not entered; abort." << endl;
 
  369         } 
else if (key == 
"exit") {
 
  374         } 
else if (key == 
"quit") {
 
  378         } 
else if (key == 
"sleep") {
 
  386         } 
else if (key == 
"process") {
 
  392           istringstream 
is(buffer);
 
  398             client.setMode(JClient::ACTIVE);
 
  408         } 
else if (key == 
"event" || key == 
"event*") {
 
  413           const char eol = 
'\n';
 
  415           if (in >> event >> c && c == 
'{' && 
getline(in, buffer, 
'}')) {
 
  423                 if (pev->active() || key == 
"event*") {
 
  425                   istringstream 
is(buffer);
 
  427                   for (
string tag; is >> tag; ) {
 
  435                     server->PutFullString(tag, os.str());
 
  438                   if (key != 
"event*") {
 
  458         } 
else if (key == 
"message") {
 
  463           if (in >> tag && 
getline(in, buffer, 
';'))
 
  464             server->PutFullString(tag, buffer);
 
  468         } 
else if (key == 
"print") {
 
  472                                   << i->getStartCommand() << 
' ' 
  473                                   << i->getAlive()        << 
' ' 
  474                                   << i->getStatename();
 
  477         } 
else if (key == 
"filter") {
 
  484           for (istringstream 
is(buffer); 
is >> 
client; ) {
 
  488         } 
else if (key == 
"sync") {
 
  496           in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  510       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(
Main.
RunControl);
 
  512       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  514         if (state->active()) {
 
  533       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(
Main.
RunControl);
 
  535       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  537         if (state->active()) {
 
  545               if (i->getMode() == JClient::ACTIVE) {
 
  547                 if (!i->getAlive()) {
 
  557                       if (buffer.find(i->getHostname()) == string::npos) {
 
  558                         JErrorStream(
logger) << i->getFullName() << 
" running on " << buffer << 
" but not alive.";
 
  567                 if (i->getAlive() && i->getStatename() != state->name()) {
 
  598       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(
Main.
RunControl);
 
  600       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  602         if (state->active()) {
 
  606             if (
target == 
"" || i->getName().find(
target) != std::string::npos) {
 
  608               if (!i->getAlive() || i->getStatename() != state->name()) {
 
  612                 i->setMode(JClient::SLEEP);
 
  636     static void copy(std::istream& 
in, std::ostream& out, 
const char eol = 
'\n') 
 
  642       if (
getline(in, buffer, eol)) {
 
  644         for (string::size_type pos = 0; pos < buffer.length(); ) {
 
  649           if (lpos != string::npos && 
 
  650               rpos != string::npos) {
 
  652             out << buffer.substr(pos, lpos);
 
  657             ifstream 
file(buffer.substr(pos, rpos - lpos).c_str());
 
  666             out << buffer.substr(pos);
 
  668             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")
JDAQEvent_t * findEvent(const JTag &tag, const std::string &event_name)
Find event in event table. 
static const std::string FILENAME_POSTFIX
ControlHost client manager. 
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null if do_usage *then usage $script fi SERVER
JDAQStateMachine::state_Main Main
JTag getUniqueTag(const std::string &hostname, const std::string &name)
Get unique tag of run control client. 
List of ControlHost client managers. 
virtual void actionStart(int, const char *) override
Interface for logging messages. 
static void copy(std::istream &in, std::ostream &out, const char eol= '\n')
Copy data from input to output stream. 
JSharedPointer< JControlHost > server
message server 
then usage $script< string identifier >< detectorfile > input file(toashort file)+" "\nNote that the input files and toashort files should be one-to-one related." fi if (( $
static const std::string TOKEN_DELIMETER
Simple driver for run control clients. 
void synchronise()
Synchronise clients. 
then echo Test string reversed by client(hit< return > to continue)." JProcess -c "JEcho-r" -C fi if (( 1 ))
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. 
virtual void actionStop(int, const char *) override
virtual void enterState(const CHSM::state &state, const CHSM::event &event) override
Action when entering state. 
JDAQStateMachine::ev_check_event ev_check
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. 
const std::string & getFullName() const 
Get full name of this run control client. 
Control unit 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::state_Main::state_RunControl RunControl
void update()
Update client list with incoming ControlHost messages until the client list is synchronised with the ...
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
virtual bool enter() override
Enter the state machine.