[dss-commits] digitalSTROM Server branch, master, updated. aadf9ade9ed5dfedbd674f1c3ff0a8fe630b488d
git version control
dss-commits at forum.digitalstrom.org
Thu Jan 7 10:38:07 CET 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".
The branch, master has been updated
via aadf9ade9ed5dfedbd674f1c3ff0a8fe630b488d (commit)
via 3840a0f8f6e0498e1a522db6e7958c0952a2387f (commit)
via 8909b071c6c65b9446a3a1f6daecf1c3874d23cf (commit)
from 6a3fde853a2a5e0e5b8bff55b8c0c8e281d20c65 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit aadf9ade9ed5dfedbd674f1c3ff0a8fe630b488d
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Thu Jan 7 10:37:27 2010 +0100
Actually start DS485Controller
commit 3840a0f8f6e0498e1a522db6e7958c0952a2387f
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Thu Jan 7 10:17:28 2010 +0100
ModelMaintenance needs to exist before Apartment
commit 8909b071c6c65b9446a3a1f6daecf1c3874d23cf
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Thu Jan 7 09:22:45 2010 +0100
Use boost::function instead of callback interface
-----------------------------------------------------------------------
Changes:
diff --git a/core/ds485/businterfacehandler.cpp b/core/ds485/businterfacehandler.cpp
index 44e89c6..670d219 100644
--- a/core/ds485/businterfacehandler.cpp
+++ b/core/ds485/businterfacehandler.cpp
@@ -40,7 +40,8 @@ namespace dss {
//================================================== BusInterfaceHandler
BusInterfaceHandler::BusInterfaceHandler(DSS* _pDSS, ModelMaintenance& _apartment)
- : Subsystem(_pDSS, "BusInterfaceHandler"),
+ : Thread("BusInterfaceHandler"),
+ Subsystem(_pDSS, "BusInterfaceHandler"),
m_ModelMaintenance(_apartment)
{}
diff --git a/core/ds485/ds485.cpp b/core/ds485/ds485.cpp
index 50841ec..8aa3e0e 100644
--- a/core/ds485/ds485.cpp
+++ b/core/ds485/ds485.cpp
@@ -158,8 +158,7 @@ namespace dss {
DS485Controller::DS485Controller()
: Thread("DS485Controller"),
m_State(csInitial),
- m_RS485DeviceName("/dev/ttyUSB0"),
- m_pBusReadyCallback(NULL)
+ m_RS485DeviceName("/dev/ttyUSB0")
{
m_DSID.upper = DSIDHeader;
m_DSID.lower = 0xDEADBEEF;
@@ -618,8 +617,8 @@ namespace dss {
m_NextStationID = 0xFF;
m_StationID = 0xFF;
} else if((m_State == csSlave) || (m_State == csMaster)) {
- if(m_pBusReadyCallback != NULL) {
- m_pBusReadyCallback->busReady();
+ if(m_BusReadyCallback) {
+ m_BusReadyCallback();
}
}
}
diff --git a/core/ds485/ds485.h b/core/ds485/ds485.h
index 9e5f839..e645325 100644
--- a/core/ds485/ds485.h
+++ b/core/ds485/ds485.h
@@ -32,6 +32,7 @@
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/function.hpp>
namespace dss {
@@ -209,12 +210,6 @@ namespace dss {
int getNumberOfCRCErrors() const { return m_NumberOfCRCErrors; }
}; // FrameReader
- class BusReadyCallbackInterface {
- public:
- virtual ~BusReadyCallbackInterface() {}
- virtual void busReady() = 0;
- };
-
class DS485Controller : public Thread,
public DS485FrameProvider {
private:
@@ -230,7 +225,8 @@ namespace dss {
Mutex m_PendingFramesGuard;
boost::shared_ptr<SerialCom> m_SerialCom;
dsid_t m_DSID;
- BusReadyCallbackInterface* m_pBusReadyCallback;
+ typedef boost::function<void()> BusReadyCallback;
+ BusReadyCallback m_BusReadyCallback;
private:
DS485Frame* getFrameFromWire();
bool putFrameOnWire(const DS485Frame* _pFrame, bool _freeFrame = true);
@@ -264,7 +260,7 @@ namespace dss {
void setDSID(const dsid_t& _value) { m_DSID = _value; }
- void setBusReadyCallback(BusReadyCallbackInterface* _value) { m_pBusReadyCallback = _value; }
+ void setBusReadyCallback(BusReadyCallback _value) { m_BusReadyCallback = _value; }
}; // DS485Controller
class IDS485FrameCollector {
diff --git a/core/ds485/ds485proxy.cpp b/core/ds485/ds485proxy.cpp
index 29d2437..6742ae6 100644
--- a/core/ds485/ds485proxy.cpp
+++ b/core/ds485/ds485proxy.cpp
@@ -22,6 +22,9 @@
#include "ds485proxy.h"
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+
#include "core/dss.h"
#include "core/logger.h"
#include "core/ds485const.h"
@@ -83,7 +86,7 @@ namespace dss {
#else
true;
#endif
- bool selfReady = m_pBusInterfaceHandler != NULL ? m_pBusInterfaceHandler->isRunning() : true;
+ bool selfReady = (m_pBusInterfaceHandler != NULL) ? m_pBusInterfaceHandler->isRunning() : true;
bool controllerReady =
((m_DS485Controller.getState() == csSlave) ||
(m_DS485Controller.getState() == csDesignatedMaster) ||
@@ -861,13 +864,14 @@ namespace dss {
}
#endif
}
- }
+ } // initialize
void DS485Proxy::doStart() {
if(m_InitializeDS485Controller) {
try {
m_DS485Controller.setDSID(dsid_t::fromString(getDSS().getPropertySystem().getStringValue(getConfigPropertyBasePath() + "dsid")));
- m_DS485Controller.setBusReadyCallback(this);
+ m_DS485Controller.setBusReadyCallback(boost::bind(&DS485Proxy::busReady,this));
+ m_DS485Controller.run();
} catch (const std::runtime_error& _ex) {
log(std::string("Caught exception while starting DS485Controller: ") + _ex.what(), lsFatal);
}
diff --git a/core/ds485/ds485proxy.h b/core/ds485/ds485proxy.h
index 40ad94e..6003663 100644
--- a/core/ds485/ds485proxy.h
+++ b/core/ds485/ds485proxy.h
@@ -66,8 +66,7 @@ namespace dss {
public StructureQueryBusInterface,
public MeteringBusInterface,
public StructureModifyingBusInterface,
- public FrameSenderInterface,
- private BusReadyCallbackInterface {
+ public FrameSenderInterface {
private:
#ifdef WITH_SIM
bool isSimAddress(const uint8_t _addr);
@@ -86,7 +85,7 @@ namespace dss {
DSMeterSpec_t dsMeterSpecFromFrame(boost::shared_ptr<DS485CommandFrame> _frame);
void checkResultCode(const int _resultCode);
- virtual void busReady();
+ void busReady();
protected:
virtual void doStart();
public:
diff --git a/core/dss.cpp b/core/dss.cpp
index eb1dba6..a89be29 100644
--- a/core/dss.cpp
+++ b/core/dss.cpp
@@ -158,10 +158,10 @@ const char* WebrootDirectory = "data/webroot";
bool DSS::initialize(const vector<std::string>& _properties) {
m_State = ssCreatingSubsystems;
- m_pApartment = boost::shared_ptr<Apartment>(new Apartment(this));
-
m_pModelMaintenance = boost::shared_ptr<ModelMaintenance>(new ModelMaintenance(this));
m_Subsystems.push_back(m_pModelMaintenance.get());
+
+ m_pApartment = boost::shared_ptr<Apartment>(new Apartment(this));
m_pModelMaintenance->setApartment(m_pApartment.get());
m_pDS485Interface = boost::shared_ptr<DS485Proxy>(new DS485Proxy(this, m_pModelMaintenance.get()));
hooks/post-receive
--
digitalSTROM Server
More information about the dss-commits
mailing list