Connection thread to a DASCube device. More...
#include <CubeDevice.h>
Public Member Functions | |
bool | autoStart () const |
CubeDevice (const std::string &stationName, const std::string &devicePath, CubeTcpServer *server) | |
unsigned int | frequency () const |
unsigned int | hardwareGain () const |
bool | isConnected () const |
bool | isRunning () const |
bool | mutexWrite (const char *buf, ssize_t byteCount) |
unsigned long int | runningTime () const |
void | setAutoStart (bool as) |
unsigned int | softwareGain () const |
const std::string | stationName () const |
unsigned int | timeMode () const |
bool | write (const char *buf, ssize_t byteCount) |
~CubeDevice () |
Connection thread to a DASCube device.
Independent thread that maintain connection to DASCube device. Whenever the connection goes down it is logged and every 10 seconds a try to connect is sent. A CubeBuffer is created once connection is successful. CubeBuffer handles the details of DASCube protole.
A user interrupt is the only way to stop the connection loop.
CubeDevice::CubeDevice | ( | const std::string & | stationName, |
const std::string & | devicePath, | ||
CubeTcpServer * | server | ||
) |
Description of constructor still missing
References CubeTcpServer::setDevice(), stationName(), and TRACE.
{ TRACE; _stationName=stationName; _server=server; _server->setDevice(this); _buffer=new CubeBuffer(0, _server, this); _serial=new CubeSerial(devicePath, B57600, _buffer); }
Description of destructor still missing
References CubeTcpServer::sendState(), TRACE, and write().
{ TRACE; ScreenClient::write(0, 2, " "); _server->sendState(); }
bool CubeDevice::autoStart | ( | ) | const [inline] |
References CubeSerial::autoStart().
{return _serial->autoStart();}
unsigned int CubeDevice::frequency | ( | ) | const [inline] |
References CubeBuffer::frequency().
{return _buffer->frequency();}
unsigned int CubeDevice::hardwareGain | ( | ) | const [inline] |
References CubeBuffer::hardwareGain().
{return _buffer->hardwareGain();}
bool CubeDevice::isConnected | ( | ) | const [inline] |
References GpCoreTools::Serial::isConnected().
Referenced by CubeTcpServer::sendState().
{return _serial->isConnected();}
bool CubeDevice::isRunning | ( | ) | const [inline] |
References CubeBuffer::isRunning().
Referenced by CubeTcpServer::sendState().
{return _buffer->isRunning();}
bool CubeDevice::mutexWrite | ( | const char * | buf, |
ssize_t | byteCount | ||
) |
References GpCoreTools::Serial::tryLock(), GpCoreTools::Serial::unlock(), write(), and GpCoreTools::Serial::write().
{ bool ret; if(_serial->tryLock()) { ret=_serial->write(buf, byteCount); //Log::write(10, "wrote %i bytes %s\n", byteCount, ret ? "successfully" : "failed"); _serial->unlock(); } else { ret=false; Log::write(0, "write: serial connection no available\n"); } return ret; }
unsigned long int CubeDevice::runningTime | ( | ) | const [inline] |
References CubeBuffer::runningTime().
Referenced by CubeTcpServer::sendState().
{return _buffer->runningTime();}
void CubeDevice::setAutoStart | ( | bool | as | ) | [inline] |
unsigned int CubeDevice::softwareGain | ( | ) | const [inline] |
References CubeBuffer::softwareGain().
{return _buffer->softwareGain();}
const std::string CubeDevice::stationName | ( | ) | const [inline] |
Referenced by CubeDevice().
{return _stationName;}
unsigned int CubeDevice::timeMode | ( | ) | const [inline] |
References CubeBuffer::timeMode().
{return _buffer->timeMode();}
bool CubeDevice::write | ( | const char * | buf, |
ssize_t | byteCount | ||
) | [inline] |
References GpCoreTools::Serial::write().
Referenced by mutexWrite(), and ~CubeDevice().
{ return _serial->write(buf, byteCount); }