[dss-commits] r8845 - dss/trunk/unix
dss-commits at forum.digitalstrom.org
dss-commits at forum.digitalstrom.org
Thu Oct 15 12:08:30 CEST 2009
Author: pstaehlin
Date: 2009-10-15 12:08:30 +0200 (Thu, 15 Oct 2009)
New Revision: 8845
Modified:
dss/trunk/unix/ds485proxy.cpp
dss/trunk/unix/ds485proxy.h
Log:
Compiles again using WITH_SIM=NO
Closes #132
Modified: dss/trunk/unix/ds485proxy.cpp
===================================================================
--- dss/trunk/unix/ds485proxy.cpp 2009-10-15 10:08:13 UTC (rev 8844)
+++ dss/trunk/unix/ds485proxy.cpp 2009-10-15 10:08:30 UTC (rev 8845)
@@ -25,11 +25,14 @@
#include "core/dss.h"
#include "core/logger.h"
#include "core/ds485const.h"
-#include "core/sim/dssim.h"
#include "core/event.h"
#include "core/propertysystem.h"
#include "core/foreach.h"
+#ifdef WITH_SIM
+#include "core/sim/dssim.h"
+#endif
+
#include <sstream>
namespace dss {
@@ -250,10 +253,12 @@
bool DS485Proxy::isReady() {
return isRunning()
+#ifdef WITH_SIM
+ && DSS::getInstance()->getSimulation().isReady() // allow the simulation to run on it's own
+#endif
&& ((m_DS485Controller.getState() == csSlave) ||
(m_DS485Controller.getState() == csDesignatedMaster) ||
- (m_DS485Controller.getState() == csError)) // allow the simulation to run on it's own
- && DSS::getInstance()->getSimulation().isReady();
+ (m_DS485Controller.getState() == csError));
} // isReady
FittingResult DS485Proxy::bestFit(const Set& _set) {
@@ -460,15 +465,19 @@
} // sendCommand(device)
void DS485Proxy::sendFrame(DS485CommandFrame& _frame) {
+ _frame.setFrameSource(fsDSS);
bool broadcast = _frame.getHeader().isBroadcast();
+#ifdef WITH_SIM
bool sim = isSimAddress(_frame.getHeader().getDestination());
- _frame.setFrameSource(fsDSS);
if(broadcast || sim) {
log("Sending packet to sim");
if(DSS::hasInstance()) {
getDSS().getSimulation().process(_frame);
}
}
+#else
+ bool sim = false;
+#endif
if(broadcast || !sim) {
if((m_DS485Controller.getState() == csSlave) || (m_DS485Controller.getState() == csMaster)) {
log("Sending packet to hardware");
@@ -500,8 +509,9 @@
boost::shared_ptr<FrameBucketCollector> result(new FrameBucketCollector(this, _functionID, sourceID));
sendFrame(_frame);
return result;
- }
+ } // sendFrameAndInstallBucket
+#ifdef WITH_SIM
bool DS485Proxy::isSimAddress(const uint8_t _addr) {
if(DSS::hasInstance()) {
return getDSS().getSimulation().isSimAddress(_addr);
@@ -509,6 +519,7 @@
return true;
}
} // isSimAddress
+#endif
void DS485Proxy::checkResultCode(const int _resultCode) {
if(_resultCode < 0) {
@@ -1119,9 +1130,11 @@
void DS485Proxy::initialize() {
Subsystem::initialize();
m_DS485Controller.addFrameCollector(this);
+#ifdef WITH_SIM
if(DSS::hasInstance()) {
getDSS().getSimulation().addFrameCollector(this);
}
+#endif
}
void DS485Proxy::doStart() {
@@ -1321,9 +1334,11 @@
PayloadDissector pd(frame->getPayload());
+#ifdef WITH_SIM
if(frame->getFrameSource() == fsWire) {
getDSS().getSimulation().process(*frame.get());
}
+#endif
if(functionID == FunctionZoneAddDevice) {
log("New device");
pd.get<uint8_t>(); // function id
Modified: dss/trunk/unix/ds485proxy.h
===================================================================
--- dss/trunk/unix/ds485proxy.h 2009-10-15 10:08:13 UTC (rev 8844)
+++ dss/trunk/unix/ds485proxy.h 2009-10-15 10:08:30 UTC (rev 8845)
@@ -22,6 +22,10 @@
#ifndef _DS485_PROXY_H_INCLUDED
#define _DS485_PROXY_H_INCLUDED
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <bitset>
#include "core/model.h"
@@ -130,7 +134,9 @@
public IDS485FrameCollector {
private:
FittingResult bestFit(const Set& _set);
+#ifdef WITH_SIM
bool isSimAddress(const uint8_t _addr);
+#endif
/** Returns a single frame or NULL if none should arrive within the timeout (1000ms) */
boost::shared_ptr<ReceivedFrame> receiveSingleFrame(DS485CommandFrame& _frame, uint8_t _functionID);
More information about the dss-commits
mailing list