Relacs  0.9.8
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Device Class Referenceabstract

#include <device.h>

Inheritance diagram for Device:
Inheritance graph
[legend]
Collaboration diagram for Device:
Collaboration graph
[legend]

Public Types

enum  DeviceTypes {
  MiscellaneousType = 0, AnalogInputType = 1, AnalogOutputType = 2, DigitalIOType = 3,
  TriggerType = 4, AttenuatorType = 5, AttenuateType = 6, ManipulatorType = 7,
  TemperatureType = 8, CameraType = 9
}
 
- Public Types inherited from Options
enum  SaveFlags {
  NoName = 1, NoType = 2, NoInclude = 4, SwitchNameType = 8,
  Embrace = 16, PrintRequest = 32, FirstOnly = 64, PrintType = 128,
  PrintStyle = 256, DontCloseSection = 512, AlwaysQuote = 1024, EscapeQuotes = 2048
}
 
typedef deque< Parameter >
::iterator 
iterator
 
typedef deque< Parameter >
::const_iterator 
const_iterator
 
typedef deque< Options * >
::iterator 
section_iterator
 
typedef deque< Options * >
::const_iterator 
const_section_iterator
 

Public Member Functions

 Device (int type=MiscellaneousType)
 
 Device (const string &deviceclass, int type=MiscellaneousType)
 
virtual ~Device (void)
 
virtual int open (const string &device)
 
virtual int open (Device &device)
 
virtual bool isOpen (void) const =0
 
virtual void close (void)=0
 
virtual int reset (void)
 
virtual const Optionsinfo (void) const
 
virtual const Optionssettings (void) const
 
int deviceType (void) const
 
string deviceTypeStr (void) const
 
string deviceClass (void) const
 
string deviceFile (void) const
 
string deviceName (void) const
 
string deviceVendor (void) const
 
string deviceIdent (void) const
 
virtual void setDeviceIdent (const string &ident)
 
virtual void clearError (void)
 
virtual string errorStr (void) const
 
void setErrorStr (const string &strg)
 
void addErrorStr (const string &strg)
 
void setErrorStr (int errnum)
 
void addErrorStr (int errnum)
 
virtual bool success (void) const
 
virtual bool failed (void) const
 
- Public Member Functions inherited from Options
 Options (void)
 
 Options (const Options &o)
 
 Options (const Options &o, int flags)
 
 Options (const string &name, const string &type, int flags, int style)
 
 Options (const Str &opttxt, const string &assignment=":=", const string &separator=",;")
 
 Options (const StrQueue &sq, const string &assignment=":=")
 
 Options (istream &str, const string &assignment=":=", const string &comment="#", const string &stop="", string *line=0)
 
virtual ~Options (void)
 
Optionsoperator= (const Options &o)
 
Optionsassign (const Options &o)
 
Optionsappend (const Options &o)
 
Optionsadd (const Options &o)
 
Optionsinsert (const Options &o, const string &atname="")
 
Optionsassign (const Options &o, int flags)
 
Optionscopy (Options &o, int flags)
 
Optionsappend (const Options &o, int flags)
 
Optionsadd (const Options &o, int flags)
 
Optionsinsert (const Options &o, int flags, const string &atname="")
 
Parameterassign (const string &name, const string &value)
 
OptionsparentSection (void)
 
const OptionsparentSection (void) const
 
void setParentSection (Options *parentsection)
 
void resetParents (void)
 
OptionsrootSection (void)
 
const OptionsrootSection (void) const
 
string name (void) const
 
virtual void setName (const string &name)
 
virtual void setName (const string &name, const string &type)
 
string type (void) const
 
void setType (const string &type)
 
string include (void) const
 
void setInclude (const string &include)
 
void setInclude (const string &url, const string &name)
 
int flag (void) const
 
bool flag (int selectflag) const
 
OptionssetFlag (int flag)
 
OptionsaddFlag (int flag)
 
OptionsdelFlag (int flag)
 
OptionsclearFlag (void)
 
int style (void) const
 
OptionssetStyle (int style)
 
OptionsaddStyle (int style)
 
OptionsdelStyle (int style)
 
OptionsclearStyle (void)
 
bool checkType (int mask) const
 
Str warning (void) const
 
iterator begin (void)
 
iterator end (void)
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
section_iterator sectionsBegin (void)
 
section_iterator sectionsEnd (void)
 
const_section_iterator sectionsBegin (void) const
 
const_section_iterator sectionsEnd (void) const
 
const_iterator find (const string &pattern, int level=-1) const
 
iterator find (const string &pattern, int level=-1)
 
const_iterator rfind (const string &pattern, int level=-1) const
 
iterator rfind (const string &pattern, int level=-1)
 
const_section_iterator findSection (const string &pattern, int level=-1) const
 
section_iterator findSection (const string &pattern, int level=-1)
 
const_section_iterator rfindSection (const string &pattern, int level=-1) const
 
section_iterator rfindSection (const string &pattern, int level=-1)
 
const Parameteroperator[] (int i) const
 
Parameteroperator[] (int i)
 
const Parameteroperator[] (const string &name) const
 
Parameteroperator[] (const string &name)
 
const Optionssection (int i) const
 
Optionssection (int i)
 
const Optionssection (const string &name) const
 
Optionssection (const string &name)
 
Str request (const string &name) const
 
ParametersetRequest (const string &name, const string &request)
 
Parameter::ValueType valueType (const string &name) const
 
ParametersetValueType (const string &name, Parameter::ValueType type)
 
int flags (const string &name) const
 
bool flags (const string &name, int flag) const
 
ParametersetFlags (const string &name, int flags)
 
ParameteraddFlags (const string &name, int flags)
 
ParameterdelFlags (const string &name, int flags)
 
ParameterclearFlags (const string &name)
 
bool changed (const string &name)
 
int style (const string &name) const
 
ParametersetStyle (const string &name, int style)
 
ParameteraddStyle (const string &name, int style)
 
ParameterdelStyle (const string &name, int style)
 
Str format (const string &name) const
 
ParametersetFormat (const string &name, int width=0, int prec=-1, char fmt='g')
 
ParametersetFormat (const string &name, const string &format)
 
int formatWidth (const string &name) const
 
int size (const string &name) const
 
Parameteradd (const Parameter &np)
 
Parameterinsert (const Parameter &np, const string &atname="")
 
ParameteraddText (const string &name, const string &request, const string &dflt, int flags=0, int style=0)
 
ParameteraddText (const string &name, const string &dflt="", int flags=0, int style=0)
 
ParameterinsertText (const string &name, const string &atname, const string &request, const string &dflt, int flags=0, int style=0)
 
ParameterinsertText (const string &name, const string &atname="", const string &dflt="", int flags=0, int style=0)
 
Str text (const string &name, int index, const string &dflt="", const string &format="", const string &unit="") const
 
Str text (const string &name, const string &dflt="", const string &format="", const string &unit="") const
 
void texts (const string &name, vector< string > &s, const string &format="", const string &unit="") const
 
Str allText (const string &name, const string &dflt="", const string &format="", const string &unit="", const string &separator=", ") const
 
ParametersetText (const string &name, const string &strg)
 
ParametersetText (const string &name, const Parameter &p)
 
ParameterpushText (const string &name, const string &strg)
 
Str defaultText (const string &name, const string &format="", const string &unit="") const
 
ParametersetDefaultText (const string &name, const string &dflt)
 
ParameteraddSelection (const string &name, const string &request, const string &selection, int flags=0, int style=0)
 
ParameteraddSelection (const string &name, const string &selection="", int flags=0, int style=0)
 
ParameterinsertSelection (const string &name, const string &atname, const string &request, const string &selection, int flags=0, int style=0)
 
ParameterinsertSelection (const string &name, const string &atname="", const string &selection="", int flags=0, int style=0)
 
ParameterselectText (const string &name, const string &strg, int add=0)
 
ParameterselectText (const string &name, int index)
 
int index (const string &name) const
 
int index (const string &name, const string &strg) const
 
ParameteraddNumber (const string &name, const string &request, double dflt, double minimum, double maximum=MAXDOUBLE, double step=1.0, const string &unit="", const string &outputunit="", const string &format="", int flags=0, int style=0)
 
ParameteraddNumber (const string &name, const string &request, double dflt, const string &unit="", const string &format="", int flags=0, int style=0)
 
ParameteraddNumber (const string &name, double dflt, const string &unit="", const string &format="", int flags=0, int style=0)
 
ParameteraddNumber (const string &name, double dflt, const string &unit, int flags, int style=0)
 
ParameteraddNumber (const string &name, double dflt, double error, const string &unit="", const string &format="", int flags=0, int style=0)
 
ParameteraddNumber (const string &name, const string &unit="", const string &format="", int flags=0, int style=0)
 
ParameterinsertNumber (const string &name, const string &atname, const string &request, double dflt, double minimum, double maximum=MAXDOUBLE, double step=1.0, const string &unit="", const string &outputunit="", const string &format="", int flags=0, int style=0)
 
ParameterinsertNumber (const string &name, const string &atname, const string &request, double dflt, const string &unit="", const string &format="", int flags=0, int style=0)
 
ParameterinsertNumber (const string &name, const string &atname, double dflt, const string &unit="", const string &format="", int flags=0, int style=0)
 
ParameterinsertNumber (const string &name, const string &atname, const string &unit="", const string &format="", int flags=0, int style=0)
 
double number (const string &name, double dflt=0.0, const string &unit="", int index=0) const
 
double number (const string &name, const string &unit, double dflt=0.0, int index=0) const
 
double number (const string &name, int index, double dflt=0.0, const string &unit="") const
 
double number (const string &name, int index, const string &unit, double dflt=0.0) const
 
void numbers (const string &name, vector< double > &n, const string &unit="") const
 
double error (const string &name, const string &unit="", int index=0) const
 
double error (const string &name, int index, const string &unit="") const
 
void errors (const string &name, vector< double > &n, const string &unit="") const
 
ParametersetNumber (const string &name, double number, double error, const string &unit="")
 
ParametersetNumber (const string &name, double number, const string &unit="")
 
ParameterpushNumber (const string &name, double number, double error=-1.0, const string &unit="")
 
ParameterpushNumber (const string &name, double number, const string &unit)
 
ParametersetNumber (const string &name, const Parameter &p)
 
double defaultNumber (const string &name, const string &unit="") const
 
ParametersetDefaultNumber (const string &name, double dflt, const string &unit="")
 
double minimum (const string &name, const string &unit="") const
 
double maximum (const string &name, const string &unit="") const
 
double step (const string &name, const string &unit="") const
 
ParametersetStep (const string &name, double step, const string &unit="")
 
ParametersetMinMax (const string &name, double minimum=-MAXDOUBLE, double maximum=MAXDOUBLE, double step=1.0, const string &unit="")
 
Str unit (const string &name) const
 
Str outUnit (const string &name) const
 
ParametersetUnit (const string &name, const string &internunit, const string &outunit="")
 
ParametersetOutUnit (const string &name, const string &outputunit)
 
ParameterchangeUnit (const string &name, const string &internunit)
 
ParameteraddInteger (const string &name, const string &request, long dflt, long minimum=LONG_MIN, long maximum=LONG_MAX, long step=1, const string &unit="", const string &outputunit="", int width=0, int flags=0, int style=0)
 
ParameteraddInteger (const string &name, long dflt, const string &unit="", int width=0, int flags=0, int style=0)
 
ParameteraddInteger (const string &name, const string &unit="")
 
ParameterinsertInteger (const string &name, const string &atname, const string &request, long dflt, long minimum=LONG_MIN, long maximum=LONG_MAX, long step=1, const string &unit="", const string &outputunit="", int width=0, int flags=0, int style=0)
 
ParameterinsertInteger (const string &name, const string &atname, long dflt, const string &unit="", int width=0, int flags=0, int style=0)
 
ParameterinsertInteger (const string &name, const string &atname, const string &unit="", int width=0, int flags=0, int style=0)
 
long integer (const string &name, const string &unit="", long dflt=0, int index=0) const
 
long integer (const string &name, int index, long dflt=0, const string &unit="") const
 
long integer (const string &name, int index, const string &unit, long dflt=0) const
 
void integers (const string &name, vector< long > &n, const string &unit="") const
 
void integers (const string &name, vector< int > &n, const string &unit="") const
 
ParametersetInteger (const string &name, long number, long error, const string &unit="")
 
ParametersetInteger (const string &name, long number, const string &unit="")
 
ParameterpushInteger (const string &name, long number, long error, const string &unit="")
 
ParameterpushInteger (const string &name, long number, const string &unit="")
 
ParametersetInteger (const string &name, const Parameter &p)
 
long defaultInteger (const string &name, const string &unit="") const
 
ParametersetDefaultInteger (const string &name, long dflt, const string &unit="")
 
ParametersetMinMax (const string &name, long minimum=LONG_MIN, long maximum=LONG_MAX, long step=1, const string &unit="")
 
ParametersetMinMax (const string &name, int minimum, int maximum, int step=1, const string &unit="")
 
ParameteraddBoolean (const string &name, const string &request, bool dflt, int flags=0, int style=0)
 
ParameteraddBoolean (const char *name, const char *request, bool dflt, int flags=0, int style=0)
 
ParameteraddBoolean (const string &name, bool dflt, int flags=0, int style=0)
 
ParameteraddBoolean (const char *name, bool dflt, int flags=0, int style=0)
 
ParameterinsertBoolean (const string &name, const string &atname="", const string &request="", bool dflt=false, int flags=0, int style=0)
 
ParameterinsertBoolean (const string &name, const string &atname, int flags=0, int style=0)
 
bool boolean (const string &name, bool dflt=false, int index=0) const
 
bool boolean (const string &name, int index, bool dflt=false) const
 
void booleans (const string &name, vector< bool > &n) const
 
ParametersetBoolean (const string &name, bool b)
 
ParametersetBoolean (const string &name, const Parameter &p)
 
bool defaultBoolean (const string &name) const
 
ParametersetDefaultBoolean (const string &name, bool dflt)
 
ParameteraddDate (const string &name, const string &request, int year=0, int month=0, int day=0, int flags=0, int style=0)
 
ParameteraddDate (const string &name, int year, int month, int day, int flags=0, int style=0)
 
ParameteraddDate (const string &name, int flags=0, int style=0)
 
ParameterinsertDate (const string &name, const string &atname="", const string &request="", int year=0, int month=0, int day=0, int flags=0, int style=0)
 
ParameterinsertDate (const string &name, const string &atname, int year=0, int month=0, int day=0, int flags=0, int style=0)
 
ParameterinsertDate (const string &name, const string &atname, int flags=0, int style=0)
 
const Parameterdate (const string &name, int index, int &year, int &month, int &day) const
 
ParametersetDate (const string &name, int year, int month, int day)
 
ParametersetDate (const string &name, const string &date)
 
ParametersetDate (const string &name, const struct tm &date)
 
ParametersetDate (const string &name, const time_t &time)
 
ParametersetCurrentDate (const string &name)
 
ParametersetDate (const string &name, const Parameter &p)
 
const ParameterdefaultDate (const string &name, int index, int &year, int &month, int &day) const
 
ParametersetDefaultDate (const string &name, int year, int month, int day)
 
ParameteraddTime (const string &name, const string &request, int hour=0, int minutes=0, int seconds=0, int milliseconds=0, int flags=0, int style=0)
 
ParameteraddTime (const string &name, int hour, int minutes, int seconds, int milliseconds=0, int flags=0, int style=0)
 
ParameteraddTime (const string &name, int flags=0, int style=0)
 
ParameterinsertTime (const string &name, const string &atname="", const string &request="", int hour=0, int minutes=0, int seconds=0, int milliseconds=0, int flags=0, int style=0)
 
ParameterinsertTime (const string &name, const string &atname, int hour=0, int minutes=0, int seconds=0, int milliseconds=0, int flags=0, int style=0)
 
ParameterinsertTime (const string &name, const string &atname, int flags=0, int style=0)
 
const Parametertime (const string &name, int index, int &hour, int &minutes, int &seconds, int &milliseconds) const
 
ParametersetTime (const string &name, int hour, int minutes, int seconds, int milliseconds=0)
 
ParametersetTime (const string &name, const string &time)
 
ParametersetTime (const string &name, const struct tm &time)
 
ParametersetTime (const string &name, const time_t &time)
 
ParametersetCurrentTime (const string &name)
 
ParametersetTime (const string &name, const Parameter &p)
 
const ParameterdefaultTime (const string &name, int index, int &hour, int &minutes, int &seconds, int &milliseconds) const
 
ParametersetDefaultTime (const string &name, int hour, int minutes, int seconds, int milliseconds=0)
 
OptionsnewSection (int level, const string &name, const string &type="", int flag=0, int style=0)
 
OptionsnewSection (int level, const string &name, int flag, int style=0)
 
OptionsnewSection (const string &name, const string &type="", int flag=0, int style=0)
 
OptionsnewSection (const string &name, int flag, int style=0)
 
OptionsnewSubSection (const string &name, const string &type="", int flag=0, int style=0)
 
OptionsnewSubSection (const string &name, int flag, int style=0)
 
OptionsnewSubSubSection (const string &name, const string &type="", int flag=0, int style=0)
 
OptionsnewSubSubSection (const string &name, int flag, int style=0)
 
OptionsaddSection (const string &name, const string &type="", int flag=0, int style=0)
 
OptionsaddSection (const string &name, int flag, int style=0)
 
OptionsinsertSection (const string &name, const string &atpattern, const string &type="", int flag=0, int style=0)
 
OptionsinsertSection (const string &name, const string &atpattern, int flag, int style=0)
 
OptionsnewSection (int level, const Options &opt, int selectmask, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSection (int level, const Options &opt, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSection (int level, const Options &opt, const string &name, int flag, int style=0)
 
OptionsnewSection (const Options &opt, int selectmask, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSection (const Options &opt, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSection (const Options &opt, const string &name, int flag, int style=0)
 
OptionsnewSubSection (const Options &opt, int selectmask, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSubSection (const Options &opt, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSubSection (const Options &opt, const string &name, int flag, int style=0)
 
OptionsnewSubSubSection (const Options &opt, int selectmask, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSubSubSection (const Options &opt, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsnewSubSubSection (const Options &opt, const string &name, int flag, int style=0)
 
OptionsaddSection (const Options &opt, int selectmask, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsaddSection (const Options &opt, const string &name="", const string &type="", int flag=0, int style=0)
 
OptionsaddSection (const Options &opt, const string &name, int flag, int style=0)
 
OptionsinsertSection (const Options &opt, int selectmask, const string &name, const string &atpattern, const string &type="", int flag=0, int style=0)
 
OptionsinsertSection (const Options &opt, const string &name, const string &atpattern, const string &type="", int flag=0, int style=0)
 
OptionsinsertSection (const Options &opt, const string &name, const string &atpattern, int flag, int style=0)
 
OptionsnewSection (Options *opt, bool newparent=false)
 
OptionsaddSection (Options *opt, bool newparent=false)
 
OptionsinsertSection (Options *opt, const string &atpattern, bool newparent=false)
 
OptionsnewSections (Options *opt, bool newparent=false)
 
void endSection (void)
 
void clearSections (void)
 
void setSection (Options &opt)
 
void lastSection (void)
 
int up (void)
 
int down (void)
 
ParametersetDefault (const string &name)
 
OptionssetDefaults (int flags=0)
 
ParametersetToDefault (const string &name)
 
OptionssetToDefaults (int flags=0)
 
Optionserase (iterator p)
 
Optionserase (section_iterator p)
 
Optionserase (Options *s)
 
Optionserase (const string &pattern)
 
Optionserase (int selectflag)
 
Optionspop (void)
 
OptionspopSection (void)
 
Optionsflatten (Options *root=0)
 
Optionsclear (bool revert=true)
 
int size (void) const
 
int size (int selectflag) const
 
bool empty (void) const
 
int parameterSize (void) const
 
int parameterSize (int flags) const
 
int sectionsSize (void) const
 
int sectionsSize (int flags) const
 
bool exist (const string &pattern) const
 
bool existSection (const string &pattern) const
 
OptionssetFlags (int flags, int selectflag=0)
 
OptionsaddFlags (int flags, int selectflag=0)
 
OptionsdelFlags (int flags, int selectflag=0)
 
OptionssetValueTypeFlags (int flags, int typemask)
 
OptionsaddValueTypeFlags (int flags, int typemask)
 
OptionsdelValueTypeFlags (int flags, int typemask)
 
OptionssetStyles (int style, int selectflag=0)
 
OptionsaddStyles (int style, int selectflag=0)
 
OptionsdelStyles (int style, int selectflag=0)
 
int styleSize (int style) const
 
OptionssetValueTypeStyles (int style, int typemask)
 
OptionsaddValueTypeStyles (int style, int typemask)
 
OptionsdelValueTypeStyles (int style, int typemask)
 
int nameWidth (int selectmask=0, bool detailed=false, bool escape=false) const
 
string save (int selectmask=0, int flags=0) const
 
ostream & save (ostream &str, const string &start="", int selectmask=0, int flags=0, int width=-1) const
 
ostream & save (ostream &str, const string &textformat, const string &numberformat, const string &boolformat="%i=%b", const string &dateformat="%i=%04Y-%02m-%02d", const string &timeformat="%i=%02H:%02M:%02S", const string &sectionformat="%i", int selectmask=0, const string &start="") const
 
ostream & saveXML (ostream &str, int selectmask=0, int flags=0, int level=0, int indent=4) const
 
Optionsread (const string &opttxt, int flag, const string &assignment=":=", const string &separator=",;", int *indent=0)
 
Optionsread (const string &opttxt, const string &assignment=":=", const string &separator=",;")
 
istream & read (istream &str, int flag, const string &assignment=":=", const string &comment="#", const string &stop="", Str *line=0)
 
istream & read (istream &str, const string &assignment=":=", const string &comment="#", const string &stop="", Str *line=0)
 
Optionsread (const StrQueue &sq, int flag=0, const string &assignment=":=")
 
bool read (const Parameter &p, int flag=0)
 
Optionsread (const Options &o, int flags=0, int flag=0)
 
bool readAppend (const Parameter &p)
 
OptionsreadAppend (const Options &o, int flags=0)
 
Optionsload (const Str &opttxt, const string &assignment=":=", const string &separator=",;", int *indent=0, int *indentspacing=0, int *level=0)
 
istream & load (istream &str, const string &assignment=":=", const string &comment="#", const string &stop="", string *line=0)
 
Optionsload (const StrQueue &sq, const string &assignment=":=")
 
virtual void notify (void)
 
void callNotifies (void)
 
bool setNotify (bool notify=true)
 
bool unsetNotify (void)
 
bool notifying (void) const
 

Static Public Member Functions

static int deviceTypes (void)
 
static string deviceTypeStr (int type)
 
static string getErrorStr (int ern)
 
- Static Public Member Functions inherited from Options
static double floorLog10 (double v)
 
static double floor10 (double v, double scale=1.0)
 
static double ceil10 (double v, double scale=1.0)
 

Static Public Attributes

static const int NotOpen = -1
 
static const int InvalidDevice = -2
 
static const int ReadError = -3
 
static const int WriteError = -4
 
static const int InvalidParam = -5
 
- Static Public Attributes inherited from Options
static const int NonDefault = Parameter::NonDefault
 
static const long TabSection = 0x04000000
 

Protected Member Functions

void setDeviceType (int type)
 
void setDeviceClass (const string &deviceclass)
 
void setDeviceFile (const string &devicefile)
 
void setDeviceName (const string &devicename)
 
void setDeviceVendor (const string &devicevendor)
 
void addInfo (void)
 
void lock (void) const
 
void unlock (void) const
 
QMutex * mutex (void) const
 
virtual void initOptions (void)
 

Protected Attributes

Options Info
 
Options Settings
 

Friends

ostream & operator<< (ostream &str, const Device &d)
 

Detailed Description

Basic interface for accessing a device.

Author
Jan Benda
Todo:
Options as part of the device

The Device class defines the interface for the basic operations open(), close(), and reset() of a device. You have to implement at least the isOpen(), close() and one of the two open() functions.

In case you want to use a device within RELACS, your Device implementation needs to provide a void default constructor (i.e. with no parameters) that does not open the device. Make sure your constructor calls initOptions() once which registers configuation options, do not forget to also call the base class implementation. Also, include the header file <relacs/relacsplugin.h> and make the Device known to RELACS with the addDevice( ClassNameOfYourDeviceImplementation, PluginSetName ) macro or one of the derived macros for any specialized DeviceType.

A subclass of Device can be identified by its deviceType(). For example, the Temperature class provides a uniqe interface for measuring temperatures. All classes derived from the Temperature class then share the same deviceType(). The type of a Device class should be set in the constructor of the interface class either directly using setDeviceType() or by passing the type to the constructor of the Device class.

A name for class of devices a particular implementation of the Device class is handling is returned by deviceClass(). Usually deviceClass() is the name of the class derived from Device. Set the class-name for the devices in the constructor with setDeviceClass() or by passing the name to the constructor of the Device class.

Each individual physical device may have an unique identifier string deviceIdent() that can be set by setDeviceIdent(). The identifier string should be unique for each instance of a device class. The name and the vendor of the physical device is returned by deviceName() and deviceVendor(). Both should be set from within the open() function using setDeviceName() and setDeviceVendor(). The device file on which the device was opened is returned by deviceFile().

The info() function returns Options that contain some usefull information about the capabilities of the specific device. The settings() functions returns Options containing information about the current settings of the specific device. You should fill in both info() and settings() in an implementation of the Device class.

There are four flags for indicating errors with handling the device: NotOpen, InvalidDevice, ReadError, and WriteError. In addition an arbitrary error string errorStr() can be set with setErrorStr() and addErrorStr() to indicate a failure in detail.

Each device has its own mutex() for locking critical sections. Use lock() and unlock() for locking the device.

Member Enumeration Documentation

Predefined device types.

See Also
deviceType(), setDeviceType()
Enumerator
MiscellaneousType 
AnalogInputType 
AnalogOutputType 
DigitalIOType 
TriggerType 
AttenuatorType 
AttenuateType 
ManipulatorType 
TemperatureType 
CameraType 

Constructor & Destructor Documentation

Device ( int  type = MiscellaneousType)

Construct a Device of type type. This constructor is used by the more specific but still abstract device classes like AnalogInput, AnalogOutput, etc.

See Also
setDeviceType()
Device ( const string &  deviceclass,
int  type = MiscellaneousType 
)

Construct a Device with class-name deviceclass and type type. Use this constructor if your device does not fit in the predefined DeviceTypes.

See Also
setDeviceClass(), setDeviceType()
~Device ( void  )
virtual

Destroy a Device. In case the associated device is open, close it.

Member Function Documentation

int open ( const string &  device)
virtual

Open the device specified by device with options opts. On success, in your implementation device should be passed to setDeviceFile() and the name and the vendor of the device should be set with setDeviceName() and setDeviceVendor(). The info() should be set in the implementation of open() by the info().addNumber(), info().addText(), etc. functions. For adding some default information to info() you may use addInfo(). Returns zero on success, or InvalidDevice (or any other negative number indicating the error).

See Also
isOpen(), close(), reset()

Reimplemented in Attenuate, AnalogOutput, DigitalIO, AnalogInput, DIOSim, AISim, AttSim, and AOSim.

References Device::InvalidDevice, Device::setDeviceFile(), and Device::setErrorStr().

Referenced by DeviceList< T, PluginID >::create().

int open ( Device device)
virtual

Open the device specified by device with options opts. On success, in your implementation device should be passed to setDeviceFile() and the name and the vendor of the device should be set with setDeviceName() and setDeviceVendor(). The info() should be set in the implementation of open() by the info().addNumber(), info().addText(), etc. functions. For adding some default information to info() you may use addInfo(). Returns zero on success, or InvalidDevice (or any other negative number indicating the error).

See Also
isOpen(), close(), reset()

Reimplemented in Attenuate, AnalogOutput, DigitalIO, AnalogInput, DIOSim, AISim, and AOSim.

References Device::deviceClass(), Device::deviceIdent(), Device::InvalidDevice, Device::setDeviceFile(), and Device::setErrorStr().

virtual bool isOpen ( void  ) const
pure virtual
virtual void close ( void  )
pure virtual

Close the device. info() should be cleared in an implementation of close() by caling Info.clear().

See Also
open(), isOpen(), reset()

Implemented in Attenuate, AnalogOutput, DigitalIO, AnalogInput, DIOSim, AISim, AttSim, and AOSim.

Referenced by Attenuate::close().

int reset ( void  )
virtual

Reset the device. Returns zero on success, otherwise one of the flags NotOpen, InvalidDevice, WriteError. An implementation should not clear the error string and should onlyadd error strings using addErrorStr().

See Also
close(), open(), isOpen()

Reimplemented in Trigger, AnalogOutput, AnalogInput, AISim, and AOSim.

const Options & info ( void  ) const
virtual

Returns some information about the capabilities of the device (for example, maximum possible sampling rate). This function can be reimplemented to set the the infos right before returning them.

See Also
settings()

References Device::Info.

Referenced by SaveFiles::ODMLFiles::open(), and relacs::operator<<().

const Options & settings ( void  ) const
virtual

Returns some information about the current settings of the device (for example, the currently used sampling rate). This function can be reimplemented to set the the settings right before returning them.

See Also
info()

Reimplemented in DigitalIO, DIOSim, and AttSim.

References Device::Settings.

int deviceType ( void  ) const
string deviceTypeStr ( void  ) const
int deviceTypes ( void  )
static
Returns
the number of known device types.
See Also
deviceTypeStr(), deviceType()
string deviceTypeStr ( int  type)
static
Returns
a string naming the device type type.
See Also
deviceType(), deviecTypes()

References Options::type().

string deviceClass ( void  ) const

The name for the device(s) a particular implementation of the Device class is handling.

See Also
setDeviceClass(), deviceIdent(), deviceType(), deviceFile(), deviceName(), deviceVendor()

Referenced by Device::addInfo(), and Device::open().

string deviceFile ( void  ) const

The name of the device file on which the device was opened.

See Also
setDeviceFile(), deviceIdent(), deviceClass(), deviceType(), deviceName(), deviceVendor()

Referenced by Device::addInfo(), and AOSim::getAISyncDevice().

string deviceName ( void  ) const

The name of the particular physical device that is handled by this instance of the Device class.

See Also
setDeviceName(), deviceIdent(), deviceClass(), deviceType(), deviceFile(), deviceVendor()

Referenced by Device::addInfo().

string deviceVendor ( void  ) const

The vendor of the particular physical device that is handled by this instance of the Device class.

See Also
setDeviceVendor(), deviceIdent(), deviceClass(), deviceType(), deviceFile(), deviceName()

Referenced by Device::addInfo().

string deviceIdent ( void  ) const
void setDeviceIdent ( const string &  ident)
virtual

Set the identifier string of an individual physical device to ident.

See Also
deviceIdent(), setDeviceClass(), setDeviceType(), setDeviceFile(), setDeviceName(), setDeviceVendor()

References Device::Info, and Options::setText().

void clearError ( void  )
virtual

Clear the error string.

See Also
setErrorStr(), addErrorStr()

Referenced by AnalogOutput::setErrorStr().

string errorStr ( void  ) const
virtual

Return error string of the last operation.

See Also
setErrorStr(), addErrorStr()
void setErrorStr ( const string &  strg)

Set error string to strg.

See Also
addErrorStr(), errorStr()

Referenced by Device::open(), and AnalogOutput::setErrorStr().

void addErrorStr ( const string &  strg)

Add strg to the error string.

See Also
setErrorStr(), errorStr()

Referenced by AnalogOutput::addErrorStr(), and AnalogInput::run().

void setErrorStr ( int  errnum)

Set error string to the string describing the standard C error code errnum (from errno).

See Also
addErrorStr(), errorStr()
void addErrorStr ( int  errnum)

Add the string describing the standard C error code errnum (from errno) to the error string.

See Also
setErrorStr(), errorStr()
string getErrorStr ( int  ern)
static

Translates the error code ern returned by open(), reset(), etc. into a string.

References Device::InvalidDevice, Device::NotOpen, Device::ReadError, and Device::WriteError.

Referenced by AnalogInput::run(), and AnalogOutput::run().

bool success ( void  ) const
virtual

Return true if the last operation was successfull and did not set an error string, i.e. errorStr().empty().

bool failed ( void  ) const
virtual

Return true if the last operation failed and did set an error string, i.e. not errorStr().empty().

void setDeviceType ( int  type)
protected

Set id of the device class to type. This function should be called in the constructor of an device interface class.

See Also
deviceType(), setDeviceClass(), setDeviceFile(), setDeviceIdent(), setDeviceName(), setDeviceVendor()

References Options::type().

void setDeviceClass ( const string &  deviceclass)
protected

Set the name for the class of devices a particular implementation of the Devive class is handling to deviceclass. This function should be called in the constructor and/or the open function of the Device class implementation.

See Also
deviceClass(), setDeviceFile(), setDeviceIdent(), setDeviceType(), setDeviceName(), setDeviceVendor()
void setDeviceFile ( const string &  devicefile)
protected
void setDeviceName ( const string &  devicename)
protected

Set the name of the particular physical device that is handled by this instance of the Device class to devicename.

See Also
deviceName(), setDeviceIdent(), setDeviceClass(), setDeviceType(), setDeviceFile(), setDeviceVendor()

Referenced by AOSim::open(), AttSim::open(), and AISim::open().

void setDeviceVendor ( const string &  devicevendor)
protected

Set the vendor of the particular physical device that is handled by this instance of the Device class to devicevendor.

See Also
deviceName(), setDeviceIdent(), setDeviceClass(), setDeviceType(), setDeviceFile(), setDeviceName()

Referenced by AOSim::open(), AttSim::open(), and AISim::open().

void addInfo ( void  )
protected
void lock ( void  ) const
protected

Lock the mutex of this device.

See Also
unlock(), mutex()

Referenced by AnalogInput::run(), AnalogOutput::run(), AnalogInput::stopRead(), and AnalogOutput::stopWrite().

void unlock ( void  ) const
protected

Unlock the mutex of this device.

See Also
lock(), mutex()

Referenced by AnalogInput::run(), AnalogOutput::run(), AnalogInput::stopRead(), and AnalogOutput::stopWrite().

QMutex * mutex ( void  ) const
protected
Returns
A pointer to the mutex of this device.
See Also
lock(), unlock()
void initOptions ( void  )
protectedvirtual

Intializes available options

Reimplemented in Attenuate, Trigger, AISim, and AOSim.

References Options::addText().

Referenced by AttSim::AttSim(), AOSim::initOptions(), AISim::initOptions(), and Attenuate::initOptions().

Friends And Related Function Documentation

ostream& operator<< ( ostream &  str,
const Device d 
)
friend

Write info() to str.

Member Data Documentation

const int NotOpen = -1
static
const int InvalidDevice = -2
static
const int ReadError = -3
static

Return code indicating a failure in reading from the device.

Referenced by Device::getErrorStr().

const int WriteError = -4
static

Return code indicating a failure in writing to the device.

Referenced by DigitalIO::allocateLine(), DigitalIO::configureLine(), and Device::getErrorStr().

const int InvalidParam = -5
static

Return code indicating an invalid parameter.

Options Info
mutableprotected
Options Settings
mutableprotected

The documentation for this class was generated from the following files: