1 #ifndef __JRUNCONTROL__JDAQDRIVER__ 
    2 #define __JRUNCONTROL__JDAQDRIVER__ 
   57                const int          timeout_s) :
 
  125                 if (
i->isActive() && 
i->getBorn() <= 
i->getDied()) {
 
  131             return CHSM::machine::enter();
 
  134             cerr << 
"Timeout at subscription." << endl;
 
  138           cerr << error << endl;
 
  142         cerr << 
"Message server or logger not properly initialised." << endl;
 
  158       using namespace JLANG;
 
  186     virtual void enterState(
const CHSM::state& state, 
const CHSM::event& event)
 override 
  196         JWarningStream(
logger) << 
"Timeout at transition " << 
event.name() << 
" to state " << state.name(); 
 
  215       using namespace JNET;
 
  221         long long int length = 0;
 
  223         if ( no_wait && 
server->CheckHead(tag, length) <= 0) { 
return false; }
 
  224         if (!no_wait && 
server->WaitHead (tag, length) <  0) { 
return false; }
 
  226         char* 
data= 
new char[length];
 
  228         server->GetFullData(data, length);
 
  230         const string buffer(data, length);
 
  240         } 
else if (buffer.find(
getFullName()) != string::npos) {
 
  253             i->update(tag, buffer);
 
  267                 istringstream 
is(buffer);
 
  277                   client.update(tag, buffer);
 
  278                   client.setMode(JClient::ILLEGAL);
 
  368       for (
string key; in >> key; ) {
 
  372           in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  374         } 
else if (key == 
"enter") {
 
  379             cerr << 
"State machine not entered; abort." << endl;
 
  383         } 
else if (key == 
"exit") {
 
  388         } 
else if (key == 
"quit") {
 
  392         } 
else if (key == 
"sleep") {
 
  400         } 
else if (key == 
"process") {
 
  406           istringstream 
is(buffer);
 
  412             client.setMode(JClient::ACTIVE);
 
  422         } 
else if (key == 
"event" || key == 
"event*") {
 
  427           const char eol = 
'\n';
 
  429           if (in >> event >> c && c == 
'{' && 
getline(in, buffer, 
'}')) {
 
  437                 if (pev->active() || key == 
"event*") {
 
  439                   istringstream 
is(buffer);
 
  441                   for (
string tag; is >> tag; ) {
 
  451                     server->PutFullString(tag, os.str());
 
  454                   if (key != 
"event*") {
 
  474         } 
else if (key == 
"message") {
 
  479           if (in >> tag && 
getline(in, buffer, 
';'))
 
  480             server->PutFullString(tag, buffer);
 
  484         } 
else if (key == 
"print") {
 
  488                                   << 
i->getStartCommand() << 
' ' 
  489                                   << 
i->getAlive()        << 
' ' 
  490                                   << 
i->getStatename();
 
  493         } 
else if (key == 
"filter") {
 
  500           for (istringstream 
is(buffer); 
is >> 
client; ) {
 
  504         } 
else if (key == 
"sync") {
 
  512           in.ignore(numeric_limits<streamsize>::max(), 
'\n');
 
  526       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(
Main.
RunControl);
 
  528       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  530         if (state->active()) {
 
  549       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(
Main.
RunControl);
 
  551       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  553         if (state->active()) {
 
  561               if (
i->getMode() == JClient::ACTIVE) {
 
  563                 if (!
i->getAlive()) {
 
  573                       if (buffer.find(
i->getHostname()) == string::npos) {
 
  583                 if (
i->getAlive() && 
i->getStatename() != state->name()) {
 
  614       const CHSM::parent& parent = 
static_cast<const CHSM::parent&
>(
Main.
RunControl);
 
  616       for (CHSM::parent::const_iterator state = parent.begin(); state != parent.end(); ++state) {
 
  618         if (state->active()) {
 
  622             if (
target == 
"" || 
i->getName().find(
target) != std::string::npos) {
 
  624               if (!
i->getAlive() || 
i->getStatename() != state->name()) {
 
  628                 i->setMode(JClient::SLEEP);
 
  652     static void copy(std::istream& 
in, std::ostream& out, 
const char eol = 
'\n') 
 
  658       if (
getline(in, buffer, eol)) {
 
  660         for (string::size_type pos = 0; pos < buffer.length(); ) {
 
  665           if (lpos != string::npos && 
 
  666               rpos != string::npos) {
 
  668             out << buffer.substr(pos, lpos);
 
  673             ifstream 
file(buffer.substr(pos, rpos - lpos).c_str());
 
  682             out << buffer.substr(pos);
 
  684             pos  += buffer.substr(pos).length();
 
static const std::string FILENAME_PREFIX
 
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
 
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
 
ControlHost client manager. 
 
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. 
 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message. 
 
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. 
 
virtual bool exit() override
Exit the state machine. 
 
JSharedPointer< JControlHost > server
message server 
 
static const std::string TOKEN_DELIMETER
 
Simple driver for run control clients. 
 
virtual bool filter(const JTag &tag, int length, const char *buffer)
Filter message. 
 
void synchronise()
Synchronise clients. 
 
void run()
Run driver with user input. 
 
static const int SLEEP_TIME_US
 
static const std::string RUN_CONTROL_CLIENT
 
static const JNET::JTag RC_LOG
 
virtual void actionExit() override
Exit the state machine. 
 
static const JNET::JTag RC_REPLY
 
then echo Test string reversed by client(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho-r" -C fi if (( 1 ))
 
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 static information. 
 
Level specific message streamers. 
 
Exception for ControlHost. 
 
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")
 
$WORKDIR ev_configure_dqsimulator txt echo process $DQ_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DQ_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
 
JDAQDriver(const std::string &name, const std::string &server, JLogger *logger, const int level, const int timeout_s)
Constructor. 
 
int timeout_us
timeout of state transitions [us] 
 
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. 
 
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
 
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 ...
 
virtual bool enter() override
Enter the state machine.