|
From: <rus...@us...> - 2008-06-01 02:53:11
|
Revision: 143
http://gearbox.svn.sourceforge.net/gearbox/?rev=143&view=rev
Author: russo2503v
Date: 2008-05-31 19:53:19 -0700 (Sat, 31 May 2008)
Log Message:
-----------
not using subystemthread. using safethread instead with custom substatus
Modified Paths:
--------------
gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.cpp
gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.h
Modified: gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.cpp
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.cpp 2008-06-01 02:52:34 UTC (rev 142)
+++ gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.cpp 2008-06-01 02:53:19 UTC (rev 143)
@@ -47,16 +47,15 @@
gbxutilacfr::Tracer &tracer,
gbxutilacfr::Status &status,
int unparsedBytesWarnThreshold )
- : gbxiceutilacfr::SubsystemThread( tracer, status, subsysName ),
+ : gbxiceutilacfr::SafeThread( tracer ),
serial_(serialPort),
responseParser_(responseParser),
responseBuffer_(-1,gbxiceutilacfr::BufferTypeCircular),
unparsedBytesWarnThreshold_(unparsedBytesWarnThreshold),
tracer_(tracer),
- status_(status)
+ subStatus_( status, subsysName )
{
- status_.setMaxHeartbeatInterval( subsysName, 60 );
- status_.initialising( subsysName );
+ subStatus_.setMaxHeartbeatInterval( 60 );
}
SerialDeviceHandler::~SerialDeviceHandler()
@@ -65,7 +64,7 @@
// The component may outlive this subsystem.
// So tell status that it might not hear from us for a while.
//
- status_.setMaxHeartbeatInterval( subsysName(), 1e9 );
+ subStatus_.setMaxHeartbeatInterval( 1e9 );
}
void
@@ -89,7 +88,8 @@
void
SerialDeviceHandler::walk()
{
- status_.setMaxHeartbeatInterval( subsysName(), 2 );
+ // TODO: this max heartbeat interval should reflect the actual timeout of the serial device.
+ subStatus_.setMaxHeartbeatInterval( 2 );
while ( !isStopping() )
{
@@ -109,7 +109,7 @@
try {
bool statusOK = processBuffer( timeStampSec, timeStampUsec );
if ( statusOK )
- status_.ok( subsysName() );
+ subStatus_.ok();
}
catch ( std::exception &e )
{
@@ -121,7 +121,7 @@
}
else
{
- status_.ok( subsysName() );
+ subStatus_.ok();
}
}
catch ( std::exception &e )
@@ -136,19 +136,19 @@
{
stringstream ss;
ss << "SerialDeviceHandler: Caught Ice exception: " << e;
- status_.fault( subsysName(), ss.str() );
+ subStatus_.fault( ss.str() );
}
catch ( std::exception &e )
{
stringstream ss;
ss << "SerialDeviceHandler: Caught exception: " << e.what();
- status_.fault( subsysName(), ss.str() );
+ subStatus_.fault( ss.str() );
}
catch ( ... )
{
stringstream ss;
ss << "SerialDeviceHandler: Caught unknown exception.";
- status_.fault( subsysName(), ss.str() );
+ subStatus_.fault( ss.str() );
}
}
}
@@ -241,7 +241,7 @@
{
stringstream ss;
ss << "SerialDeviceHandler: Received abnormal response: " << response->toString();
- status_.warning( subsysName(), ss.str() );
+ subStatus_.warning( ss.str() );
statusOK = false;
}
else
Modified: gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.h
===================================================================
--- gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.h 2008-06-01 02:52:34 UTC (rev 142)
+++ gearbox/trunk/src/gbxsickacfr/gbxserialdeviceacfr/serialdevicehandler.h 2008-06-01 02:53:19 UTC (rev 143)
@@ -11,7 +11,8 @@
#define GBXSERIALDEVICEACFR_SERIALDEVICEHANDLER_H
#include <gbxserialacfr/serial.h>
-#include <gbxsickacfr/gbxiceutilacfr/subsystemthread.h>
+#include <gbxsickacfr/gbxutilacfr/substatus.h>
+#include <gbxsickacfr/gbxiceutilacfr/safethread.h>
#include <gbxsickacfr/gbxiceutilacfr/buffer.h>
#include <IceUtil/IceUtil.h>
@@ -85,7 +86,7 @@
//!
//! @author Alex Brooks
//!
-class SerialDeviceHandler : public gbxiceutilacfr::SubsystemThread
+class SerialDeviceHandler : public gbxiceutilacfr::SafeThread
{
public:
@@ -95,8 +96,6 @@
// - unparsedBytesWarnThreshold: if we get more than this many un-parsed bytes packed into the
// receive buffer, flag a warning.
// - serialPort_: must have timeouts enabled
- // - serialTimeout: the timout to use when reading fromt he serial port
- // (controls the frequency of the loop)
SerialDeviceHandler( const std::string &subsysName,
gbxserialacfr::Serial &serialPort,
IResponseParser &responseParser,
@@ -139,7 +138,7 @@
int unparsedBytesWarnThreshold_;
gbxutilacfr::Tracer& tracer_;
- gbxutilacfr::Status& status_;
+ gbxutilacfr::SubStatus subStatus_;
};
//////////////////////////////////////////////////////////////////////
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|