00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <gdm703.h>
00021
00022 #include <iostream>
00023
00024 GDM703::GDM703() :
00025 DMMClass()
00026 {
00027 setNumValues( 2 );
00028 }
00029
00030 GDM703::~GDM703()
00031 {
00032 m_port.close();
00033 }
00034
00035 Port::Error GDM703::open_impl( const std::string & config )
00036 {
00037 return m_port.open( config );
00038 }
00039
00040 Port::Error GDM703::close()
00041 {
00042 return m_port.close();
00043 }
00044
00045 void GDM703::setAscii( int start, int modeLen,
00046 const std::string & str, int index )
00047 {
00048 m_mutex.lock();
00049
00050 double value;
00051 Util::fromString( &value,
00052 Util::strip_whitespace( str.substr( start+2, 6 )));
00053 addValue( value, index );
00054 m_mode[index] = Util::strip_whitespace( str.substr( start, modeLen ));
00055 m_unit[index] = Util::strip_whitespace( str.substr( start+modeLen+6, 4 ));
00056
00057 m_hasValue = true;
00058 m_overflow=false;
00059
00060 m_mutex.unlock();
00061 }
00062
00063 void GDM703::run()
00064 {
00065 char data[26*3+1];
00066
00067 while (m_run)
00068 {
00069 int cnt = readData( &m_port, (unsigned char *)data,
00070 0x03, 26, 3*26 );
00071
00072 if (-1 != cnt)
00073 {
00074 int start = cnt-26;
00075 data[cnt-1] = 0;
00076 std::string strData = data+start;
00077
00078
00079 setAscii( 1, 2, strData, 0 );
00080 setAscii( 14, 1, strData, 1 );
00081 }
00082 else m_hasValue = false;
00083 }
00084 }