PeakTech10Ascii Class Reference

Base implementation of the PeakTech 11 byte ASCII protocoll. More...

#include <peaktech10ascii.h>

Inheritance diagram for PeakTech10Ascii:

DMMClass Thread List of all members.

Public Member Functions

 PeakTech10Ascii ()
 Constructor.
virtual ~PeakTech10Ascii ()
virtual Port::Error close ()
 Close the port.
Port::Error open (const std::string &config)
 Open the port.
void setNumValues (int num)
 Set number of values this partucular multimeter provides.
int numValues ()
 Return number of values this partucular multimeter provides.
std::string mode (int i=0)
 The current measurement mode.
std::string unit (int i=0)
 String representation of the unit.
double value (int i=0)
 The measured value.
bool hasValue ()
 Do we have a measurement already?
bool overflow ()
 An overflow happened.
bool lowBat ()
 Battery is low.
void setConsoleLogging (bool on)
bool timeout () const
 Check if there was a timeout.
int start ()
 Start the thread.
void wait ()
 Wait for the thread to finish (no timeout!).
void stop ()
 Gracefully stop the thread.
void quit ()
 Forcibly stop thread.
bool running () const
 Is the thread running?

Static Public Member Functions

static DMMClasscreate ()
static DMMClasscreate_protocol (std::string protocolName)
 Create an instance of the given protocol.
static int num_protocols ()
 Return number of known protocols.
static Protocol protocol (int i)
 Return protocol description.
static std::string print_protocols ()
 Return list of known protocol names separated by '
'.
static std::string print_devices ()
 Return list of known devices separated by '
'.
static bool has_device (const std::string &deviceName)
 Test if the devicename is known.
static Device get_device (const std::string &deviceName)
 Get device description.
static std::string html_device_table ()
static std::string device_table ()

Protected Member Functions

virtual Port::Error open_impl (const std::string &config)
 Open the port (the real thing).
virtual void run ()
 The main loop.
int readData (char *data) const
int readData (Port *port, unsigned char *buffer, int syncByte, int minLen, int maxLen) const
void addValue (double value, int index)

Protected Attributes

SerialPort m_port
time_t m_openTime
 Seconds since epoch when port was opened. This is needed for the timeout.
bool m_hasValue
 Set to true if a valid value has been read.
int m_numValues
 Stores the number of values this multimeter provides.
bool m_overflow
 Set to true if an overflow happened (And clear if the overflow condition is gone).
bool m_lowBat
 Set true if multimeter indicates low battery state.
Mutex m_mutex
 Hold this mutex when reading or writing values.
std::string m_mode [8]
 The mode.
std::string m_unit [8]
 The unit.
double m_value [8]
 The value.
bool m_consoleLogging
bool m_run
pthread_t m_pthread

Static Protected Attributes

static Protocol s_protocol []
static Device s_device []

Detailed Description

Base implementation of the PeakTech 11 byte ASCII protocoll.

The multimeter continuously writes an ascii string

11 byte format description:
#VVVVVVUUUUS

#: Start character
V: Value (including sign)
U: Unit
S: Sync Byte (0x0d)

Definition at line 38 of file peaktech10ascii.h.


Constructor & Destructor Documentation

PeakTech10Ascii::PeakTech10Ascii  ) 
 

Constructor.

Definition at line 24 of file peaktech10ascii.cpp.

PeakTech10Ascii::~PeakTech10Ascii  )  [virtual]
 

Definition at line 29 of file peaktech10ascii.cpp.

References SerialPort::close(), and m_port.


Member Function Documentation

void DMMClass::addValue double  value,
int  index
[protected, inherited]
 

Definition at line 156 of file dmmclass.cpp.

References DMMClass::m_value.

Referenced by VC820::run(), run(), M9803R::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii().

Port::Error PeakTech10Ascii::close  )  [virtual]
 

Close the port.

Implements DMMClass.

Definition at line 39 of file peaktech10ascii.cpp.

References SerialPort::close(), and m_port.

static DMMClass* PeakTech10Ascii::create  )  [inline, static]
 

Definition at line 48 of file peaktech10ascii.h.

DMMClass * DMMClass::create_protocol std::string  protocolName  )  [static, inherited]
 

Create an instance of the given protocol.

Parameters:
[in] protocolName Name of the protocol. Currently implemented are:
NameProtocol class
M14PMetex14BytesPolling
M14CMetex14BytesContinuous
M15CMetex15BytesContinuous
VC820VC820
M9803RM9803R
IOCBIOCBUVMonitor
PT10APeakTech10Ascii
GDM703GDM703
ESC97Escort97
Returns:
Pointer to new instance of the requested protocol or 0 if the protocol is unknown

Definition at line 199 of file dmmclass.cpp.

References DMMClass::Protocol::createFunction, DMMClass::num_protocols(), and DMMClass::s_protocol.

std::string DMMClass::device_table  )  [static, inherited]
 

Return table with information about all known devices

Definition at line 295 of file dmmclass.cpp.

References DMMClass::Device::brand, DMMClass::Device::name, DMMClass::numValues(), DMMClass::Device::port, and DMMClass::s_device.

DMMClass::Device DMMClass::get_device const std::string &  deviceName  )  [static, inherited]
 

Get device description.

Parameters:
deviceName Name of the device ("Voltcraft ME-32")
Returns:
Device description

Definition at line 278 of file dmmclass.cpp.

References DMMClass::Device::brand, DMMClass::Device::name, DMMClass::numValues(), and DMMClass::s_device.

bool DMMClass::has_device const std::string &  deviceName  )  [static, inherited]
 

Test if the devicename is known.

Parameters:
deviceName Name of the device ("Voltcraft ME-32")
Returns:
true if device is known

Definition at line 260 of file dmmclass.cpp.

References DMMClass::Device::brand, DMMClass::Device::name, DMMClass::numValues(), and DMMClass::s_device.

bool DMMClass::hasValue  )  [inline, inherited]
 

Do we have a measurement already?

Returns:
true if something was measured

Definition at line 121 of file dmmclass.h.

References DMMClass::m_hasValue, and DMMClass::m_mutex.

std::string DMMClass::html_device_table  )  [static, inherited]
 

Return HTML table with information about all known devices

Definition at line 355 of file dmmclass.cpp.

References DMMClass::Device::brand, DMMClass::Device::name, DMMClass::numValues(), DMMClass::Device::port, and DMMClass::s_device.

bool DMMClass::lowBat  )  [inline, inherited]
 

Battery is low.

The Implementation of the multimeter class has to take care of this.

Definition at line 133 of file dmmclass.h.

References DMMClass::m_lowBat, and DMMClass::m_mutex.

std::string DMMClass::mode int  i = 0  )  [inherited]
 

The current measurement mode.

The specific implementation must set these to one of the following (The GUI QtDMM depends on this).

DCA DC measurement [V or A]
ACA AC measurement [V or A]
OHResistance [Ohm]
DIDiode "Sperrspannung" (Translators please) in V
CACapacity [Farad]
INInductance [Henry]
TETemperature [C or F]
FRFrequency [Hz]

Parameters:
[in] i Index of value [0-7]

Definition at line 144 of file dmmclass.cpp.

References DMMClass::m_mode, and DMMClass::m_mutex.

int DMMClass::num_protocols  )  [static, inherited]
 

Return number of known protocols.

Definition at line 212 of file dmmclass.cpp.

References DMMClass::count_protocols().

Referenced by DMMClass::create_protocol().

int DMMClass::numValues  )  [inline, inherited]
 

Return number of values this partucular multimeter provides.

Some multimeter may have more than on value. This class supports up to 8 values.

Returns:
The number of avail values

Definition at line 85 of file dmmclass.h.

References DMMClass::m_numValues.

Referenced by DMMClass::device_table(), DMMClass::get_device(), DMMClass::has_device(), DMMClass::html_device_table(), and DMMClass::print_devices().

Port::Error DMMClass::open const std::string &  config  )  [inherited]
 

Open the port.

See also:
Description of the parameter config can be found in the Port description

Definition at line 130 of file dmmclass.cpp.

References DMMClass::m_openTime, and DMMClass::open_impl().

Port::Error PeakTech10Ascii::open_impl const std::string &  config  )  [protected, virtual]
 

Open the port (the real thing).

See also:
Description of the parameter config can be found in the Port description

Implements DMMClass.

Definition at line 34 of file peaktech10ascii.cpp.

References m_port, and SerialPort::open().

bool DMMClass::overflow  )  [inline, inherited]
 

An overflow happened.

The Implementation of the multimeter class has to take care of this.

Definition at line 127 of file dmmclass.h.

References DMMClass::m_mutex, and DMMClass::m_overflow.

std::string DMMClass::print_devices  )  [static, inherited]
 

Return list of known devices separated by '
'.

Definition at line 244 of file dmmclass.cpp.

References DMMClass::Device::brand, DMMClass::Device::name, DMMClass::numValues(), and DMMClass::s_device.

std::string DMMClass::print_protocols  )  [static, inherited]
 

Return list of known protocol names separated by '
'.

Definition at line 228 of file dmmclass.cpp.

References DMMClass::Protocol::menuText, DMMClass::Protocol::name, and DMMClass::s_protocol.

static Protocol DMMClass::protocol int  i  )  [inline, static, inherited]
 

Return protocol description.

Parameters:
i Index of the protocol must be smaller than num_protocols())
Returns:
Protocol description

Definition at line 221 of file dmmclass.h.

References DMMClass::s_protocol.

void Thread::quit  )  [inherited]
 

Forcibly stop thread.

Not recommended as this might leak resources

Definition at line 52 of file thread.cpp.

int DMMClass::readData Port port,
unsigned char *  buffer,
int  syncByte,
int  minLen,
int  maxLen
const [protected, inherited]
 

Helper function. Read data from the given port.

Parameters:
[in] port The Port to read from
[out] buffer The data is copied into this buffer. Make shure that it is big enough to hold at least maxLen bytes.
[in] syncByte Stop reading when the sync byte has been read (and at least minLen bytes have been read.
[in] minLen Read at least minLen bytes
[in] maxLen Abort reading if maxLen bytes have been read without the occurence of the syncByte
Returns:
The number of bytes read or -1 if reading failed

Definition at line 167 of file dmmclass.cpp.

References DMMClass::m_consoleLogging, Port::Ok, and Port::readByte().

Referenced by MetexAscii::run(), M9803R::run(), GDM703::run(), and Escort97::run().

int PeakTech10Ascii::readData char *  data  )  const [protected]
 

Definition at line 73 of file peaktech10ascii.cpp.

References m_port, Port::Ok, and Port::readByte().

Referenced by run().

void PeakTech10Ascii::run  )  [protected, virtual]
 

The main loop.

Continuously read the multimeter here (And do whatever is needed to make the multimeter send values [polling]). New values have to be filled into m_value, m_mode and m_unit. Hold the mutex while doing so.

Example:

  ... we assume a 14 byte protocol ...

  unsigned char buffer[64];

  while (m_run)
  {
    int cnt = readData( buffer );

    if (-1 != cnt)
    {
      unsigned char *byte = buffer+cnt-14;

      ... decode the raw multimeter data ...

      m_mutex.lock();
      m_value[0] = ...
      m_unit[0] = ...
      m_mode[0] = ...  
      m_hasValue = true;
      m_mutex.unlock();
    }
  }
  
See also:
m_value, m_unit and m_mode

Implements DMMClass.

Definition at line 44 of file peaktech10ascii.cpp.

References DMMClass::addValue(), Util::fromString(), Mutex::lock(), DMMClass::m_hasValue, DMMClass::m_mode, DMMClass::m_mutex, Thread::m_run, DMMClass::m_unit, readData(), Util::strip_whitespace(), Mutex::unlock(), and DMMClass::value().

bool Thread::running  )  const [inline, inherited]
 

Is the thread running?

Definition at line 62 of file thread.h.

References Thread::m_run.

void DMMClass::setConsoleLogging bool  on  )  [inline, inherited]
 

Definition at line 135 of file dmmclass.h.

References DMMClass::m_consoleLogging.

void DMMClass::setNumValues int  num  )  [inline, inherited]
 

Set number of values this partucular multimeter provides.

Some multimeter may have more than on value. This class supports up to 8 values.

Parameters:
[in] num Number of parameter of this device

Definition at line 78 of file dmmclass.h.

References DMMClass::m_numValues.

Referenced by Escort97::Escort97(), and GDM703::GDM703().

int Thread::start  )  [inherited]
 

Start the thread.

Returns:
pthread_create return code

Definition at line 39 of file thread.cpp.

References Thread::m_pthread, Thread::m_run, and Thread::start_thread().

Referenced by MetexAscii::MetexAscii(), MetexAscii::run(), and GDM703::run().

void Thread::stop  )  [inline, inherited]
 

Gracefully stop the thread.

Definition at line 54 of file thread.h.

References Thread::m_run.

bool DMMClass::timeout  )  const [inherited]
 

Check if there was a timeout.

If the multimeter didn't send data for 5 seconds this goes true

Definition at line 137 of file dmmclass.cpp.

References DMMClass::m_hasValue, and DMMClass::m_openTime.

std::string DMMClass::unit int  i = 0  )  [inherited]
 

String representation of the unit.

Example: V, mV, uV, A, uA, nF, mH, MOhm, kOhm.

Parameters:
[in] i Index of value [0-7]

Definition at line 150 of file dmmclass.cpp.

References DMMClass::m_mutex, and DMMClass::m_unit.

double DMMClass::value int  i = 0  )  [inherited]
 

The measured value.

Parameters:
[in] i Index of value [0-7]

Definition at line 161 of file dmmclass.cpp.

References DMMClass::m_mutex, and DMMClass::m_value.

Referenced by run(), GDM703::setAscii(), and MetexAscii::setMetexAscii().

void Thread::wait  )  [inherited]
 

Wait for the thread to finish (no timeout!).

Definition at line 47 of file thread.cpp.

References Thread::m_pthread.


Member Data Documentation

bool DMMClass::m_consoleLogging [protected, inherited]
 

Definition at line 265 of file dmmclass.h.

Referenced by DMMClass::readData(), and DMMClass::setConsoleLogging().

bool DMMClass::m_hasValue [protected, inherited]
 

Set to true if a valid value has been read.

Definition at line 250 of file dmmclass.h.

Referenced by DMMClass::hasValue(), VC820::run(), run(), MetexAscii::run(), M9803R::run(), GDM703::run(), GDM703::setAscii(), MetexAscii::setMetexAscii(), and DMMClass::timeout().

bool DMMClass::m_lowBat [protected, inherited]
 

Set true if multimeter indicates low battery state.

Definition at line 256 of file dmmclass.h.

Referenced by DMMClass::lowBat(), and VC820::run().

std::string DMMClass::m_mode[8] [protected, inherited]
 

The mode.

See also:
mode

Definition at line 260 of file dmmclass.h.

Referenced by DMMClass::mode(), VC820::run(), run(), M9803R::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii().

Mutex DMMClass::m_mutex [protected, inherited]
 

Hold this mutex when reading or writing values.

Definition at line 258 of file dmmclass.h.

Referenced by DMMClass::hasValue(), DMMClass::lowBat(), DMMClass::mode(), DMMClass::overflow(), VC820::run(), run(), M9803R::run(), GDM703::setAscii(), MetexAscii::setMetexAscii(), DMMClass::unit(), and DMMClass::value().

int DMMClass::m_numValues [protected, inherited]
 

Stores the number of values this multimeter provides.

Definition at line 252 of file dmmclass.h.

Referenced by DMMClass::numValues(), MetexAscii::run(), and DMMClass::setNumValues().

time_t DMMClass::m_openTime [protected, inherited]
 

Seconds since epoch when port was opened. This is needed for the timeout.

Definition at line 248 of file dmmclass.h.

Referenced by DMMClass::open(), and DMMClass::timeout().

bool DMMClass::m_overflow [protected, inherited]
 

Set to true if an overflow happened (And clear if the overflow condition is gone).

Definition at line 254 of file dmmclass.h.

Referenced by DMMClass::overflow(), M9803R::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii().

SerialPort PeakTech10Ascii::m_port [protected]
 

Definition at line 51 of file peaktech10ascii.h.

Referenced by close(), open_impl(), readData(), and ~PeakTech10Ascii().

pthread_t Thread::m_pthread [protected, inherited]
 

Definition at line 66 of file thread.h.

Referenced by Thread::start(), and Thread::wait().

bool Thread::m_run [protected, inherited]
 

Definition at line 65 of file thread.h.

Referenced by VC820::run(), run(), MetexAscii::run(), M9803R::run(), GDM703::run(), Escort97::run(), Thread::running(), Thread::start(), and Thread::stop().

std::string DMMClass::m_unit[8] [protected, inherited]
 

The unit.

See also:
unit

Definition at line 262 of file dmmclass.h.

Referenced by VC820::run(), run(), M9803R::run(), GDM703::setAscii(), MetexAscii::setMetexAscii(), and DMMClass::unit().

double DMMClass::m_value[8] [protected, inherited]
 

The value.

See also:
value

Definition at line 264 of file dmmclass.h.

Referenced by DMMClass::addValue(), and DMMClass::value().

DMMClass::Device DMMClass::s_device [static, protected, inherited]
 

Definition at line 268 of file dmmclass.h.

Referenced by DMMClass::device_table(), DMMClass::get_device(), DMMClass::has_device(), DMMClass::html_device_table(), and DMMClass::print_devices().

DMMClass::Protocol DMMClass::s_protocol [static, protected, inherited]
 

Initial value:

 
{
  Protocol( &Metex14BytesPolling::create, "M14P", "Metex 14 bytes ASCII polling" ),
  Protocol( &Metex14BytesContinuous::create, "M14C", "Metex 14 bytes ASCII continuous" ),
  Protocol( &Metex15BytesContinuous::create, "M15C", "Metex 15 bytes ASCII continuous" ),
  Protocol( &VC820::create, "VC820", "VC820 14 bytes binary continuous" ),
  Protocol( &M9803R::create, "M9803R", "M9803R 12 bytes binary continuous" ),
  Protocol( &IOCBUVMonitor::create, "IOCB", "IOCB UV Monitor" ),
  Protocol( &PeakTech10Ascii::create, "PT10A", "Peaktech 11 bytes ASCII" ),
  Protocol( &GDM703::create, "GDM703", "GDM703 26 bytes binary continuous" ),
  Protocol( &Escort97::create, "ESC97", "Escort 97 binary continuous" ),
  
  Protocol( 0, "", "" ) 
}

Definition at line 267 of file dmmclass.h.

Referenced by DMMClass::count_protocols(), DMMClass::create_protocol(), DMMClass::print_protocols(), and DMMClass::protocol().


The documentation for this class was generated from the following files:
Generated on Mon Jan 22 23:24:19 2007 for cdmm by  doxygen 1.4.6