#include <dmmclass.h>
Inheritance diagram for DMMClass:
Public Member Functions | |
DMMClass () | |
virtual | ~DMMClass () |
Port::Error | open (const std::string &config) |
Open the port. | |
virtual Port::Error | close ()=0 |
Close 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 DMMClass * | create_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 void | run ()=0 |
The main loop. | |
int | readData (Port *port, unsigned char *buffer, int syncByte, int minLen, int maxLen) const |
void | addValue (double value, int index) |
virtual Port::Error | open_impl (const std::string &config)=0 |
Open the port (the real thing). | |
Protected Attributes | |
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 [] |
Static Private Member Functions | |
static int | count_protocols () |
Classes | |
class | Device |
Information structure for a multimeter device. More... | |
class | Protocol |
Information structure for a multimeter protocol. More... |
DMMClass is the base class for a multimeter type. It provides the API to the multimeter. It is a thread that has to countinuously read the value(s) from the multimeter. Another thread can retrieve the last values from the multimeter by calling the member function value including unit and mode.
Create a class derived from DMMClass. This new class is responsible for reading and decoding of the data sent by the multimeter.
Most probably the device is connected through a serial port (or USB serial). Use the SerialPort class to handle the serial port. If you have special needs it's a good idea to create a new subclass of Port for this purpose.
Implement: open_impl, close and run.
Implement a static create function (DMMClass *create( void ))
Definition at line 56 of file dmmclass.h.
|
Definition at line 117 of file dmmclass.cpp. |
|
Definition at line 126 of file dmmclass.cpp. |
|
Definition at line 156 of file dmmclass.cpp. References m_value. Referenced by VC820::run(), PeakTech10Ascii::run(), M9803R::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii(). |
|
Close the port.
Implemented in Escort97, GDM703, M9803R, MetexAscii, PeakTech10Ascii, and VC820. |
|
Definition at line 219 of file dmmclass.cpp. References s_protocol. Referenced by num_protocols(). |
|
Create an instance of the given protocol.
Definition at line 199 of file dmmclass.cpp. References DMMClass::Protocol::createFunction, num_protocols(), and s_protocol. |
|
Return table with information about all known devices Definition at line 295 of file dmmclass.cpp. References DMMClass::Device::brand, DMMClass::Device::name, numValues(), DMMClass::Device::port, and s_device. |
|
Get device description.
Definition at line 278 of file dmmclass.cpp. References DMMClass::Device::brand, DMMClass::Device::name, numValues(), and s_device. |
|
Test if the devicename is known.
Definition at line 260 of file dmmclass.cpp. References DMMClass::Device::brand, DMMClass::Device::name, numValues(), and s_device. |
|
Do we have a measurement already?
Definition at line 121 of file dmmclass.h. References m_hasValue, and m_mutex. |
|
Return HTML table with information about all known devices Definition at line 355 of file dmmclass.cpp. References DMMClass::Device::brand, DMMClass::Device::name, numValues(), DMMClass::Device::port, and s_device. |
|
Battery is low. The Implementation of the multimeter class has to take care of this. Definition at line 133 of file dmmclass.h. |
|
The current measurement mode. The specific implementation must set these to one of the following (The GUI QtDMM depends on this).
Definition at line 144 of file dmmclass.cpp. |
|
Return number of known protocols.
Definition at line 212 of file dmmclass.cpp. References count_protocols(). Referenced by create_protocol(). |
|
Return number of values this partucular multimeter provides. Some multimeter may have more than on value. This class supports up to 8 values.
Definition at line 85 of file dmmclass.h. References m_numValues. Referenced by device_table(), get_device(), has_device(), html_device_table(), and print_devices(). |
|
Open the port.
Definition at line 130 of file dmmclass.cpp. References m_openTime, and open_impl(). |
|
Open the port (the real thing).
Implemented in Escort97, GDM703, M9803R, MetexAscii, PeakTech10Ascii, and VC820. Referenced by open(). |
|
An overflow happened. The Implementation of the multimeter class has to take care of this. Definition at line 127 of file dmmclass.h. References m_mutex, and m_overflow. |
|
Return list of known devices separated by '
Definition at line 244 of file dmmclass.cpp. References DMMClass::Device::brand, DMMClass::Device::name, numValues(), and s_device. |
|
Return list of known protocol names separated by '
Definition at line 228 of file dmmclass.cpp. References DMMClass::Protocol::menuText, DMMClass::Protocol::name, and s_protocol. |
|
Return protocol description.
Definition at line 221 of file dmmclass.h. References s_protocol. |
|
Forcibly stop thread. Not recommended as this might leak resources Definition at line 52 of file thread.cpp. |
|
Helper function. Read data from the given port.
Definition at line 167 of file dmmclass.cpp. References m_consoleLogging, Port::Ok, and Port::readByte(). Referenced by MetexAscii::run(), M9803R::run(), GDM703::run(), and Escort97::run(). |
|
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(); } } Implements Thread. Implemented in Escort97, GDM703, M9803R, MetexAscii, PeakTech10Ascii, and VC820. |
|
Is the thread running?
Definition at line 62 of file thread.h. References Thread::m_run. |
|
Definition at line 135 of file dmmclass.h. References m_consoleLogging. |
|
Set number of values this partucular multimeter provides. Some multimeter may have more than on value. This class supports up to 8 values.
Definition at line 78 of file dmmclass.h. References m_numValues. Referenced by Escort97::Escort97(), and GDM703::GDM703(). |
|
Start the thread.
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(). |
|
Gracefully stop the thread.
Definition at line 54 of file thread.h. References Thread::m_run. |
|
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 m_hasValue, and m_openTime. |
|
String representation of the unit. Example: V, mV, uV, A, uA, nF, mH, MOhm, kOhm.
Definition at line 150 of file dmmclass.cpp. |
|
The measured value.
Definition at line 161 of file dmmclass.cpp. References m_mutex, and m_value. Referenced by PeakTech10Ascii::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii(). |
|
Wait for the thread to finish (no timeout!).
Definition at line 47 of file thread.cpp. References Thread::m_pthread. |
|
Definition at line 265 of file dmmclass.h. Referenced by readData(), and setConsoleLogging(). |
|
Set to true if a valid value has been read.
Definition at line 250 of file dmmclass.h. Referenced by hasValue(), VC820::run(), PeakTech10Ascii::run(), MetexAscii::run(), M9803R::run(), GDM703::run(), GDM703::setAscii(), MetexAscii::setMetexAscii(), and timeout(). |
|
Set true if multimeter indicates low battery state.
Definition at line 256 of file dmmclass.h. Referenced by lowBat(), and VC820::run(). |
|
The mode.
Definition at line 260 of file dmmclass.h. Referenced by mode(), VC820::run(), PeakTech10Ascii::run(), M9803R::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii(). |
|
Hold this mutex when reading or writing values.
Definition at line 258 of file dmmclass.h. Referenced by hasValue(), lowBat(), mode(), overflow(), VC820::run(), PeakTech10Ascii::run(), M9803R::run(), GDM703::setAscii(), MetexAscii::setMetexAscii(), unit(), and value(). |
|
Stores the number of values this multimeter provides.
Definition at line 252 of file dmmclass.h. Referenced by numValues(), MetexAscii::run(), and setNumValues(). |
|
Seconds since epoch when port was opened. This is needed for the timeout.
Definition at line 248 of file dmmclass.h. |
|
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 overflow(), M9803R::run(), GDM703::setAscii(), and MetexAscii::setMetexAscii(). |
|
Definition at line 66 of file thread.h. Referenced by Thread::start(), and Thread::wait(). |
|
Definition at line 65 of file thread.h. Referenced by VC820::run(), PeakTech10Ascii::run(), MetexAscii::run(), M9803R::run(), GDM703::run(), Escort97::run(), Thread::running(), Thread::start(), and Thread::stop(). |
|
The unit.
Definition at line 262 of file dmmclass.h. Referenced by VC820::run(), PeakTech10Ascii::run(), M9803R::run(), GDM703::setAscii(), MetexAscii::setMetexAscii(), and unit(). |
|
The value.
Definition at line 264 of file dmmclass.h. Referenced by addValue(), and value(). |
|
Definition at line 268 of file dmmclass.h. Referenced by device_table(), get_device(), has_device(), html_device_table(), and print_devices(). |
|
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 count_protocols(), create_protocol(), print_protocols(), and protocol(). |