Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Instrument Class Reference

#include <instrument.h>

Inheritance diagram for Instrument:

ATInstrument PseudoInstrument List of all members.

Detailed Description

This class represents a basic electronic instrument.

An instrument has at least one MonitorPoint and may have one or more ControlPoint s. Monitor points are read automatically at their allocated time interval by a thread and the data passed to a DumpServer to allow network acccess. Similarly, control points may be written-to over the network via a CmdServer. An instrument may be available (online) or unavailable (offline) at any one time.

Author:
Simon Hoyle
Date:
July 2002
Version:
1.0

Definition at line 32 of file instrument.h.

Public Types

typedef std::vector< ControlPoint * > ControlPointVect
typedef std::vector< Instrument * > InstrumentVect
typedef std::vector< MonitorPoint * > MonitorPointVect
enum  State { IDLE, OFFLINE, ONLINE }
 Enum constants for the Instrument state.

Public Member Functions

void add (Instrument *sub)
 Adds a sub-instrument.
void add (DumpServer *ds)
 Adds a DumpServer.
void add (CmdServer *cs)
 Adds a command server.
void add (ControlPoint *cp)
 Adds a ControlPoint.
void add (MonitorPoint *mp)
 Adds a MonitorPoint.
CmdServergetCmdServer ()
 Retrieves the CommandServer.
ControlPointgetControlPoint (const char *id)
 Retrieves a ControlPoint.
const char * getID ()
 Retrieves the short identifier.
MonitorPointgetMonitorPoint (const char *id)
 Retrieves a MonitorPoint.
State getState ()
 Retrieves the current state.
bool hasControlPoint (const char *id)
 Tests for the presence of a ControlPoint.
bool hasMonitorPoint (const char *id)
 Tests for the presence of a MonitorPoint.
void init ()
 Initialiser.
 Instrument (const char *id, const char *name)
 Constructor.
void printState ()
 Writes a string equivalent of the current state to stdout.
virtual const char * read (const char *monitorPointID)
 Reads a MonitorPoint.
void setCheckPoint (MonitorPoint *checkPt)
 Assigns a check point.
void setDebug (bool onOff)
 Enables/disables printing of debug statements for a single object.
void setEnabled (bool onOff)
 Enables/disables the Instrument.
void startMonitorThread ()
 Starts the monitor thread.
void stopMonitorThread ()
 Stops the monitor thread.
virtual const char * write (const char *controlPointID, const char *val)
 Writes to a ControlPoint.
virtual ~Instrument ()
 Destructor.

Static Public Member Functions

static void blockOn ()
 Blocks the calling thread indefinitely.
static const char * getUT ()
 Retrieves Universal Coordinated Time.
static void setDebugAll (bool onOff)
 Enables/disables printing of debug statements for the class.

Protected Member Functions

virtual State checkState ()
 Checks the state of the instrument by reading the check point.
virtual int fiveSecRead (char *buf)
 Reads all MonitorPoints in the five second list.
virtual void onPowerUp ()
 Performs any actions necessary when the instrument comes ONLINE.
void prependMonitorPointIDs (const char *str)
virtual int tenSecRead (char *buf)
 Reads all MonitorPoints in the ten second list.
virtual int thirtySecRead (char *buf)
 Reads all MonitorPoints in the thirty second list.
void updateMonitor (const char *dataStr)

Static Protected Member Functions

static const char * force (void *obj, int argc, char **argv)
 Standard command added to the CmdServer.
static const char * get (void *obj, int argc, char **argv)
 Standard command added to the CmdServer.
static const char * help (void *obj, int argc, char **argv)
 Standard command added to the CmdServer.
static void * monitorThread (void *arg)
 Monitor thread.
static const char * set (void *obj, int argc, char **argv)
 Standard command added to the CmdServer.

Protected Attributes

ControlPointVect allControlPoints
MonitorPointVect allMonitorPoints
MonitorPointcheckPt
CmdServercmdServer
 The command server.
DumpServerdumpServer
char endStr [50]
MonitorPointVect fiveSecPoints
const char * id
 The short identifier.
InstrumentVect::const_iterator iit
char monitorPage [8000]
pthread_mutex_t monitorPageMutex
pthread_t monitorThreadID
bool moreToDo
const char * name
 The long identifier.
MonitorPointVect onceOnlyPoints
char startStr [50]
PseudoMonitorPointstat
State state
InstrumentVect subInstruments
MonitorPointVect tenSecPoints
MonitorPointVect thirtySecPoints
char updateEndStr [50]
char updateStartStr [50]


Constructor & Destructor Documentation

Instrument::Instrument const char *  id,
const char *  name
 

Constructor.

Parameters:
id A short identifier.
The full instrument name.

Definition at line 32 of file instrument.cc.

References PseudoMonitorPoint::add(), allMonitorPoints, checkPt, cmdServer, dumpServer, endStr, PseudoMonitorPoint::init(), monitorPage, monitorPageMutex, startStr, stat, state, updateEndStr, and updateStartStr.


Member Function Documentation

void Instrument::add DumpServer ds  ) 
 

Adds a DumpServer.

Parameters:
ds The DumpServer to add.

Definition at line 360 of file instrument.cc.

References dumpServer.

void Instrument::add CmdServer cs  ) 
 

Adds a command server.

Parameters:
cs The CmdServer to add.

Definition at line 352 of file instrument.cc.

References CmdServer::addCtlCmd(), CmdServer::addMonCmd(), cmdServer, get(), help(), and set().

void Instrument::add ControlPoint cp  ) 
 

Adds a ControlPoint.

Parameters:
cp The ControlPoint to add.

Definition at line 347 of file instrument.cc.

References allControlPoints.

void Instrument::add MonitorPoint mp  ) 
 

Adds a MonitorPoint.

Parameters:
mp The MonitorPoint to add.

Definition at line 328 of file instrument.cc.

References allMonitorPoints, fiveSecPoints, MonitorPoint::getInterval(), onceOnlyPoints, tenSecPoints, and thirtySecPoints.

Referenced by ATInstrument::init().

Instrument::State Instrument::checkState  )  [protected, virtual]
 

Checks the state of the instrument by reading the check point.

Returns:
The current state.

Reimplemented in PseudoInstrument.

Definition at line 64 of file instrument.cc.

References allMonitorPoints, checkPt, checkState(), MonitorPoint::getCommsDev(), MonitorPoint::getState(), iit, MonitorPoint::initComms(), onPowerUp(), state, and subInstruments.

Referenced by checkState(), and monitorThread().

CmdServer * Instrument::getCmdServer  ) 
 

Retrieves the CommandServer.

Returns:
A pointer to the CommandServer.

Definition at line 639 of file instrument.cc.

References cmdServer.

ControlPoint * Instrument::getControlPoint const char *  id  ) 
 

Retrieves a ControlPoint.

Parameters:
id The short id of the ControlPoint.
Returns:
A pointer to the ControlPoint.

Definition at line 400 of file instrument.cc.

References allControlPoints, getControlPoint(), ControlPoint::hasID(), iit, and subInstruments.

Referenced by getControlPoint(), read(), and write().

MonitorPoint * Instrument::getMonitorPoint const char *  id  ) 
 

Retrieves a MonitorPoint.

Parameters:
id The short id of the MonitorPoint.
Returns:
A pointer to the MonitorPoint.

Definition at line 375 of file instrument.cc.

References allMonitorPoints, getMonitorPoint(), MonitorPoint::hasID(), iit, and subInstruments.

Referenced by add(), getMonitorPoint(), and read().

Instrument::State Instrument::getState  ) 
 

Retrieves the current state.

See also:
State.

Definition at line 629 of file instrument.cc.

References state.

bool Instrument::hasControlPoint const char *  id  ) 
 

Tests for the presence of a ControlPoint.

Parameters:
id The short id of the ControlPoint.

Definition at line 449 of file instrument.cc.

References allControlPoints, hasControlPoint(), ControlPoint::hasID(), iit, and subInstruments.

Referenced by hasControlPoint().

bool Instrument::hasMonitorPoint const char *  id  ) 
 

Tests for the presence of a MonitorPoint.

Parameters:
id The short id of the MonitorPoint.

Definition at line 425 of file instrument.cc.

References allControlPoints, allMonitorPoints, MonitorPoint::hasID(), hasMonitorPoint(), iit, and subInstruments.

Referenced by hasMonitorPoint().

void * Instrument::monitorThread void *  arg  )  [static, protected]
 

Monitor thread.

Reads MonitorPoints and passes the data to the DumpServer. Must be static to conform to signature specified by Posix Threads.

Parameters:
arg Pointer to the Instrument object.

Definition at line 244 of file instrument.cc.

References checkState(), debug, dumpServer, endStr, fiveSecRead(), id, monitorPage, monitorPageMutex, moreToDo, DumpServer::send(), startStr, state, tenSecRead(), and thirtySecRead().

Referenced by startMonitorThread().

virtual void Instrument::onPowerUp  )  [inline, protected, virtual]
 

Performs any actions necessary when the instrument comes ONLINE.

Called automatically by method checkState. This method is a NOP in this class. It should be implemented to suit a particular instrument in the inheriting class.

See also:
checkState.

Definition at line 224 of file instrument.h.

Referenced by checkState().

void Instrument::printState  ) 
 

Writes a string equivalent of the current state to stdout.

See also:
State.

Definition at line 667 of file instrument.cc.

References state.

const char * Instrument::read const char *  monitorPointID  )  [virtual]
 

Reads a MonitorPoint.

Parameters:
monitorPointID The short id of the MonitorPoint.
Returns:
The MonitorPoint data.

Definition at line 473 of file instrument.cc.

References allControlPoints, allMonitorPoints, getControlPoint(), getMonitorPoint(), iit, MonitorPoint::read(), ControlPoint::read(), and subInstruments.

Referenced by get().

void Instrument::setCheckPoint MonitorPoint checkPt  ) 
 

Assigns a check point.

A check point is a MonitorPoint that is used to determine if the instrument is ONLINE. When the instrument is OFFLINE, a single successful read of the check point places it in an ONLINE state. The check point is read automatically by the monitor thread.

Parameters:
checkPt The check point to assign.
See also:
monitorThread

Definition at line 553 of file instrument.cc.

Referenced by ATInstrument::init().

const char * Instrument::write const char *  controlPointID,
const char *  val
[virtual]
 

Writes to a ControlPoint.

Parameters:
controlPointID The short id of the ControlPoint.
val The value to write.

Definition at line 504 of file instrument.cc.

References getControlPoint(), ControlPoint::getUpdate(), ControlPoint::hasUpdate(), updateMonitor(), and ControlPoint::write().

Referenced by set().


The documentation for this class was generated from the following files:
Generated on Mon Apr 30 13:32:44 2007 for Parkes M & C - PKMC C++ library API by  doxygen 1.4.4