[dss-commits] r8816 - in dss/trunk: core core/metering core/scripting core/sim tests unix

dss-commits at forum.digitalstrom.org dss-commits at forum.digitalstrom.org
Mon Oct 5 15:30:07 CEST 2009


Author: pstaehlin
Date: 2009-10-05 15:30:07 +0200 (Mon, 05 Oct 2009)
New Revision: 8816

Modified:
   dss/trunk/core/DS485Interface.h
   dss/trunk/core/dss.cpp
   dss/trunk/core/eventinterpreterplugins.cpp
   dss/trunk/core/logger.cpp
   dss/trunk/core/metering/fake_meter.cpp
   dss/trunk/core/metering/fake_meter.h
   dss/trunk/core/metering/metering.cpp
   dss/trunk/core/model.cpp
   dss/trunk/core/scripting/modeljs.cpp
   dss/trunk/core/sim/dsid_js.cpp
   dss/trunk/core/sim/dsid_plugin.cpp
   dss/trunk/core/sim/dsidsim.cpp
   dss/trunk/core/sim/dsidsim.h
   dss/trunk/core/sim/dssim.cpp
   dss/trunk/core/sim/dssim.h
   dss/trunk/core/webserver.cpp
   dss/trunk/tests/ds485tests.cpp
   dss/trunk/tests/eventtests.cpp
   dss/trunk/unix/ds485.cpp
   dss/trunk/unix/ds485proxy.cpp
   dss/trunk/unix/ds485proxy.h
   dss/trunk/unix/serialcom.cpp
   dss/trunk/unix/serialcom.h
   dss/trunk/unix/thread.cpp
Log:
- Don't send back a dSLinkPacket if it wasn't handled in the device
- Notify dSLinkSend users if no packet has been received
- Promoted some log-messages to error/fatal
- Check the result-code of bus-acctions
- Use new-style cast instead of static_cast for type conversions
- Removed some uses of "using namespace std;"

Modified: dss/trunk/core/DS485Interface.h
===================================================================
--- dss/trunk/core/DS485Interface.h	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/DS485Interface.h	2009-10-05 13:30:07 UTC (rev 8816)
@@ -25,6 +25,7 @@
 #include "ds485types.h"
 #include "unix/ds485.h"
 #include "model.h"
+#include "base.h"
 
 #include <string>
 #include <vector>
@@ -143,5 +144,12 @@
     
     virtual void setValueDevice(const Device& _device, const uint16_t _value, const uint16_t _parameterID, const int _size) = 0;
   };
+
+  class DS485ApiError : public DSSException {
+  public:
+    DS485ApiError(const std::string& _what)
+    : DSSException(_what) {}
+  }; // DS485ApiError
+
 }
 #endif /* DS485INTERFACE_H_ */

Modified: dss/trunk/core/dss.cpp
===================================================================
--- dss/trunk/core/dss.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/dss.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -60,8 +60,6 @@
 #include <csignal>
 #endif
 
-using namespace std;
-
 namespace dss {
 
   //============================================= DSS
@@ -165,7 +163,7 @@
           int val = strToInt(value);
           m_pPropertySystem->setIntValue(name, val, true);
           continue;
-        } catch(invalid_argument&) {
+        } catch(std::invalid_argument&) {
         }
 
         if(value == "true") {

Modified: dss/trunk/core/eventinterpreterplugins.cpp
===================================================================
--- dss/trunk/core/eventinterpreterplugins.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/eventinterpreterplugins.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -121,7 +121,7 @@
         Logger::getInstance()->log(string("EventInterpreterPluginJavascript::handleEvent: Could not find script: '") + scriptName + "'", lsError);
       }
     } else {
-      throw runtime_error("EventInterpreteRPluginJavascript::handleEvent: missing argument filename");
+      throw std::runtime_error("EventInterpreteRPluginJavascript::handleEvent: missing argument filename");
     }
   } // handleEvent
 

Modified: dss/trunk/core/logger.cpp
===================================================================
--- dss/trunk/core/logger.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/logger.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -25,8 +25,6 @@
 #include <cassert>
 #include <iostream>
 
-using namespace std;
-
 namespace dss {
 
   Logger* Logger::m_Instance = NULL;
@@ -53,8 +51,8 @@
   } // severityToString<const char*>
 
   template <>
-  const string SeverityToString(const aLogSeverity _severity) {
-    return string(SeverityToString<const char*>(_severity));
+  const std::string SeverityToString(const aLogSeverity _severity) {
+    return std::string(SeverityToString<const char*>(_severity));
   } // severityToString<const string>
 
   template <>
@@ -76,8 +74,8 @@
   } // severityToString<const wchar_t*>
 
   template <>
-  const wstring SeverityToString(const aLogSeverity _severity) {
-    return wstring(SeverityToString<const wchar_t*>(_severity));
+  const std::wstring SeverityToString(const aLogSeverity _severity) {
+    return std::wstring(SeverityToString<const wchar_t*>(_severity));
   } // severityToString<const wstring>
 
   Logger::Logger()
@@ -100,7 +98,7 @@
     }
   }
 
-  void Logger::log(const string& _message, const aLogSeverity _severity) {
+  void Logger::log(const std::string& _message, const aLogSeverity _severity) {
     time_t now = time( NULL );
     struct tm t;
 #ifdef WIN32
@@ -108,18 +106,18 @@
 #else
     localtime_r( &now, &t );
 #endif
-    m_logTarget->outputStream() << "[" << dateToISOString<string>(&t) << "]"
-                                << SeverityToString<const string>(_severity) 
-                                << " " << _message << endl;
+    m_logTarget->outputStream() << "[" << dateToISOString<std::string>(&t) << "]"
+                                << SeverityToString<const std::string>(_severity)
+                                << " " << _message << std::endl;
   } // log
 
   void Logger::log(const char* _message, const aLogSeverity _severity) {
-    log(string(_message), _severity);
+    log(std::string(_message), _severity);
   } // log
 
   void Logger::log(const LogChannel& _channel, const std::string& _message, const aLogSeverity _severity) {
     if(_channel.maylog(_severity)) {
-      log(string("[") + _channel.getName() + "] " + _message, _severity);
+      log(std::string("[") + _channel.getName() + "] " + _message, _severity);
     }
   } // log
 

Modified: dss/trunk/core/metering/fake_meter.cpp
===================================================================
--- dss/trunk/core/metering/fake_meter.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/metering/fake_meter.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -55,7 +55,7 @@
         m_Series.push_back(newSeries);
     }
     // stitch up chain
-    for(vector<boost::shared_ptr<Series<CurrentValue> > >::reverse_iterator iSeries = m_Series.rbegin(), e = m_Series.rend();
+    for(std::vector<boost::shared_ptr<Series<CurrentValue> > >::reverse_iterator iSeries = m_Series.rbegin(), e = m_Series.rend();
       iSeries != e; ++iSeries)
     {
       if(iSeries != m_Series.rbegin()) {
@@ -70,7 +70,7 @@
     }
     SeriesWriter<CurrentValue> writer;
 
-    string dev = getDSS().getPropertySystem().getStringValue(getConfigPropertyBasePath() + "device");
+    std::string dev = getDSS().getPropertySystem().getStringValue(getConfigPropertyBasePath() + "device");
     bool addJitter = getDSS().getPropertySystem().getBoolValue(getConfigPropertyBasePath() + "addJitter");
     int holdTime = rand() % 15;
     unsigned long holdValue = 2 + (rand() % 5) * 10000;
@@ -94,7 +94,11 @@
       DateTime now;
       unsigned long consumption = 0;
       foreach(Modulator* modulator, getDSS().getApartment().getModulators()) {
-      	consumption += modulator->getPowerConsumption();
+        try {
+      	  consumption += modulator->getPowerConsumption();
+        } catch(std::runtime_error& err) {
+          log("Could not poll modulator " + modulator->getDSID().toString() + ". Message: " + err.what());
+        }
       }
       if(addJitter) {
         consumption += holdValue;
@@ -103,7 +107,7 @@
 
       for(int iConfig = 0; iConfig < m_Config->size(); iConfig++) {
         // Write series to file
-        string fileName = m_MeteringStorageLocation + "metering_" + m_Config->getFilenameSuffix(iConfig) + ".xml";
+        std::string fileName = m_MeteringStorageLocation + "metering_" + m_Config->getFilenameSuffix(iConfig) + ".xml";
         Series<CurrentValue>* s = m_Series[iConfig].get();
         writer.writeToXML(*s, fileName);
       }

Modified: dss/trunk/core/metering/fake_meter.h
===================================================================
--- dss/trunk/core/metering/fake_meter.h	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/metering/fake_meter.h	2009-10-05 13:30:07 UTC (rev 8816)
@@ -36,7 +36,7 @@
   private:
     int m_LastValue;
     boost::shared_ptr<MeteringConfigChain> m_Config;
-    vector<boost::shared_ptr<Series<CurrentValue> > > m_Series;
+    std::vector<boost::shared_ptr<Series<CurrentValue> > > m_Series;
 
     SerialCom m_SerialCom;
     std::string m_MeteringStorageLocation;

Modified: dss/trunk/core/metering/metering.cpp
===================================================================
--- dss/trunk/core/metering/metering.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/metering/metering.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -88,8 +88,8 @@
       vector<boost::shared_ptr<Series<CurrentValue> > > series;
       for(int iConfig = 0; iConfig < _config->size(); iConfig++) {
         // Load series from file
-        string fileName = m_MeteringStorageLocation + (*ipModulator)->getDSID().toString() + "_" + _config->getFilenameSuffix(iConfig) + ".xml";
-        log(string("Metering::checkModulators: Trying to load series from '") + fileName + "'");
+        std::string fileName = m_MeteringStorageLocation + (*ipModulator)->getDSID().toString() + "_" + _config->getFilenameSuffix(iConfig) + ".xml";
+        log("Metering::checkModulators: Trying to load series from '" + fileName + "'");
         if(fileExists(fileName)) {
           Timestamp startedLoadingSingle;
           boost::shared_ptr<Series<CurrentValue> > s = boost::shared_ptr<Series<CurrentValue> >(reader.readFromXML(fileName));
@@ -99,7 +99,7 @@
           if(s.get() != NULL) {
             series.push_back(s);
           } else {
-            log(string("Metering::checkModulators: Failed to load series"));
+            log("Metering::checkModulators: Failed to load series");
             return; // TODO: another strategy would be moving the file out of our way and just create an empty one
           }
         } else {
@@ -133,10 +133,14 @@
 #ifdef LOG_TIMING
         Timestamp fetchingValue;
 #endif
-        if(_config->isEnergy()) {
-          value = (*ipModulator)->getEnergyMeterValue();
-        } else {
-          value = (*ipModulator)->getPowerConsumption();
+        try {
+          if(_config->isEnergy()) {
+            value = (*ipModulator)->getEnergyMeterValue();
+          } else {
+            value = (*ipModulator)->getPowerConsumption();
+          }
+        } catch(std::runtime_error& err) {
+          log("Could not poll modulator " + (*ipModulator)->getDSID().toString() + ". Message: " + err.what());
         }
 #ifdef LOG_TIMING
         cout << "fetching value: " << Timestamp().getDifference(fetchingValue) << endl;
@@ -157,9 +161,9 @@
           Timestamp startedWritingSingle;
 #endif
           // Write series to file
-          string fileName = m_MeteringStorageLocation + (*ipModulator)->getDSID().toString() + "_" + _config->getFilenameSuffix(iConfig) + ".xml";
+          std::string fileName = m_MeteringStorageLocation + (*ipModulator)->getDSID().toString() + "_" + _config->getFilenameSuffix(iConfig) + ".xml";
           Series<CurrentValue>* s = series[iConfig].get();
-          log(string("Metering::checkModulators: Trying to save series to '") + fileName + "'");
+          log("Metering::checkModulators: Trying to save series to '" + fileName + "'");
           writer.writeToXML(*s, fileName);
 #ifdef LOG_TIMING
           cout << "writing single: " << Timestamp().getDifference(startedWritingSingle) << endl;

Modified: dss/trunk/core/model.cpp
===================================================================
--- dss/trunk/core/model.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/model.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -66,8 +66,7 @@
     m_LastCalledScene(SceneOff),
     m_Consumption(0),
     m_pPropertyNode()
-  {
-  }
+  { } // ctor
 
   void Device::publishToPropertyTree() {
     if(m_pPropertyNode == NULL) {
@@ -85,7 +84,7 @@
         }
       }
     }
-  }
+  } // publishToPropertyTree
 
   void Device::turnOn() {
     DSS::getInstance()->getDS485Interface().sendCommand(cmdTurnOn, *this);
@@ -400,11 +399,11 @@
   } // undoScene
 
   void Set::nextScene() {
-    throw runtime_error("Not yet implemented");
+    throw std::runtime_error("Not yet implemented");
   } // nextScene
 
   void Set::previousScene() {
-    throw runtime_error("Not yet implemented");
+    throw std::runtime_error("Not yet implemented");
   } // previousScene
 
   void Set::perform(IDeviceAction& _deviceAction) {
@@ -733,16 +732,11 @@
     DS485Interface& interface = DSS::getInstance()->getDS485Interface();
     int modulatorID = _modulator.getBusID();
 
-    try {
-      ModulatorSpec_t spec = interface.getModulatorSpec(modulatorID);
-      _modulator.setSoftwareVersion(spec.get<1>());
-      _modulator.setHardwareVersion(spec.get<2>());
-      _modulator.setHardwareName(spec.get<3>());
-      _modulator.setDeviceType(spec.get<4>());
-    } catch(std::runtime_error& e) {
-      log(std::string("scanModulator: Error getting modulator spec: ") + e.what(), lsFatal);
-      return false;
-    }
+    ModulatorSpec_t spec = interface.getModulatorSpec(modulatorID);
+    _modulator.setSoftwareVersion(spec.get<1>());
+    _modulator.setHardwareVersion(spec.get<2>());
+    _modulator.setHardwareName(spec.get<3>());
+    _modulator.setDeviceType(spec.get<4>());
 
     int levelOrange, levelRed;
     if(interface.getEnergyBorder(modulatorID, levelOrange, levelRed)) {
@@ -787,31 +781,38 @@
       vector<int> groupIDs = interface.getGroups(modulatorID, zoneID);
       foreach(int groupID, groupIDs) {
         log("    Found group with id: " + intToString(groupID));
-        vector<int> devingroup = interface.getDevicesInGroup(modulatorID, zoneID, groupID);
+        try {
+          vector<int> devingroup = interface.getDevicesInGroup(modulatorID, zoneID, groupID);
 
-        foreach(int devID, devingroup) {
-          try {
-            log("     Adding device " + intToString(devID) + " to group " + intToString(groupID));
-            Device& dev = getDeviceByShortAddress(_modulator, devID);
-            dev.addToGroup(groupID);
-            if(zone.getGroup(groupID) == NULL) {
-              log("     Adding new group to zone");
-              zone.addGroup(new Group(groupID, zone.getZoneID(), *this));
-            }
-            Group* pGroup = zone.getGroup(groupID);
-            pGroup->setIsPresent(true);
+          foreach(int devID, devingroup) {
             try {
-              Group& group = getGroup(groupID);
-              group.setIsPresent(true);
-            } catch(ItemNotFoundException&) {
-              Group* pGroup = new Group(groupID, 0, *this);
-              getZone(0).addGroup(pGroup);
+              log("     Adding device " + intToString(devID) + " to group " + intToString(groupID));
+              Device& dev = getDeviceByShortAddress(_modulator, devID);
+              dev.addToGroup(groupID);
+              if(zone.getGroup(groupID) == NULL) {
+                log("     Adding new group to zone");
+                zone.addGroup(new Group(groupID, zone.getZoneID(), *this));
+              }
+              Group* pGroup = zone.getGroup(groupID);
               pGroup->setIsPresent(true);
-              log("     Adding new group to zone 0");
+              try {
+                Group& group = getGroup(groupID);
+                group.setIsPresent(true);
+              } catch(ItemNotFoundException&) {
+                Group* pGroup = new Group(groupID, 0, *this);
+                getZone(0).addGroup(pGroup);
+                pGroup->setIsPresent(true);
+                log("     Adding new group to zone 0");
+              }
+            } catch(ItemNotFoundException& e) {
+              log("Could not find device with short-address " + intToString(devID) + " on modulator " + intToString(modulatorID), lsFatal);
             }
-          } catch(ItemNotFoundException& e) {
-            Logger::getInstance()->log("Could not find device with short-address " + intToString(devID) + " on modulator " + intToString(modulatorID), lsFatal);
           }
+        } catch(DS485ApiError& e) {
+          log("Error getting devices from group " + intToString(groupID) +
+              " on zone " + intToString(zoneID) +
+              " on modulator " + intToString(modulatorID) +
+              ". Message: " + e.what(), lsFatal);
         }
 
         // get last called scene for zone, group
@@ -825,7 +826,7 @@
           } else {
             onGroupCallScene(zoneID, groupID, lastCalledScene);
           }
-        } catch(runtime_error& error) {
+        } catch(DS485ApiError& error) {
           log(string("Error getting last called scene '") + error.what() + "'", lsError);
         }
       }
@@ -882,7 +883,10 @@
       }
       Modulator& modulator = allocateModulator(modDSID);
       modulator.setBusID(modulatorID);
-      if(!scanModulator(modulator)) {
+      try {
+        scanModulator(modulator);
+      } catch(DS485ApiError& e) {
+        log(std::string("Exception caught while scanning modulator: ") + e.what(), lsFatal);
         scheduleRescan();
       }
     }
@@ -1083,7 +1087,7 @@
               if(!nameNode.getChildren().empty()) {
                 setName((nameNode.getChildren()[0]).getContent());
               }
-            } catch(runtime_error&) {
+            } catch(std::runtime_error&) {
             }
           }
         }
@@ -1464,10 +1468,10 @@
           }
         }
       } else {
-        log("OnGroupCallScene: Could not find group with id '" + intToString(_groupID) + "' in Zone '" + intToString(_zoneID) + "'");
+        log("OnGroupCallScene: Could not find group with id '" + intToString(_groupID) + "' in Zone '" + intToString(_zoneID) + "'", lsError);
       }
     } catch(ItemNotFoundException& e) {
-      log("OnGroupCallScene: Could not find zone with id '" + intToString(_zoneID) + "'");
+      log("OnGroupCallScene: Could not find zone with id '" + intToString(_zoneID) + "'", lsError);
     }
 
   } // onGroupCallScene
@@ -1486,10 +1490,10 @@
           devRef.getDevice().setLastCalledScene(_sceneID & 0x00ff);
         }
       } catch(ItemNotFoundException& e) {
-        log("OnDeviceCallScene: Could not find device with bus-id '" + intToString(_deviceID) + "' on modulator '" + intToString(_modulatorID) + "' scene:" + intToString(_sceneID));
+        log("OnDeviceCallScene: Could not find device with bus-id '" + intToString(_deviceID) + "' on modulator '" + intToString(_modulatorID) + "' scene:" + intToString(_sceneID), lsError);
       }
     } catch(ItemNotFoundException& e) {
-      log("OnDeviceCallScene: Could not find modulator with bus-id '" + intToString(_modulatorID) + "'");
+      log("OnDeviceCallScene: Could not find modulator with bus-id '" + intToString(_modulatorID) + "'", lsError);
     }
   } // onDeviceCallScene
 
@@ -1511,7 +1515,7 @@
     try {
       Modulator& oldModulator = getModulatorByBusID(dev.getModulatorID());
       oldModulator.removeDevice(devRef);
-    } catch(runtime_error&) {
+    } catch(std::runtime_error&) {
     }
 
     // remove from old zone
@@ -1519,7 +1523,7 @@
       Zone& oldZone = getZone(dev.getZoneID());
       oldZone.removeDevice(devRef);
       // TODO: check if the zone is empty on the modulator and remove it in that case
-    } catch(runtime_error&) {
+    } catch(std::runtime_error&) {
     }
 
     // update device
@@ -1595,11 +1599,11 @@
           log("unknown interrupt mode '" + mode + "'", lsError);
         }
       } catch (ItemNotFoundException& ex) {
-        log("Apartment::onDSLinkInterrupt: Unknown device with ID " + intToString(_devID));
+        log("Apartment::onDSLinkInterrupt: Unknown device with ID " + intToString(_devID), lsFatal);
         return;
       }
     } catch(ItemNotFoundException& ex) {
-      log("Apartment::onDSLinkInterrupt: Unknown Modulator with ID " + intToString(_modID));
+      log("Apartment::onDSLinkInterrupt: Unknown Modulator with ID " + intToString(_modID), lsFatal);
       return;
     }
 
@@ -1684,7 +1688,7 @@
   		try {
   		  Zone& oldZone = dev.getApartment().getZone(oldZoneID);
   		  oldZone.removeDevice(_device);
-  		} catch(runtime_error&) {
+  		} catch(std::runtime_error&) {
   		}
   	}
     if(!contains(m_Devices, _device)) {

Modified: dss/trunk/core/scripting/modeljs.cpp
===================================================================
--- dss/trunk/core/scripting/modeljs.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/scripting/modeljs.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -477,9 +477,14 @@
       if(argc > 2) {
         writeOnly = ctx->convertTo<bool>(argv[2]);
       }
-      value = ref->getDevice().dsLinkSend(value, lastByte, writeOnly);
-      *rval = INT_TO_JSVAL(value);
-      return JS_TRUE;
+      try {
+        value = ref->getDevice().dsLinkSend(value, lastByte, writeOnly);
+        *rval = INT_TO_JSVAL(value);
+        return JS_TRUE;
+      } catch(std::runtime_error&) {
+        JS_ReportError(cx, "Error receiving value");
+        return JS_FALSE;
+      }
     }
     return JS_FALSE;
   } // dev_dslink_send

Modified: dss/trunk/core/sim/dsid_js.cpp
===================================================================
--- dss/trunk/core/sim/dsid_js.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/sim/dsid_js.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -239,16 +239,20 @@
       return "";
     } // getConfigParameter
 
-    virtual uint8_t dsLinkSend(uint8_t _value, uint8_t _flags) {
+    virtual uint8_t dsLinkSend(uint8_t _value, uint8_t _flags, bool _handled) {
       if(m_pSelf != NULL) {
         try {
           ScriptFunctionParameterList param(*m_pContext);
           param.add(int(_value));
           param.add(int(_flags));
-          return m_pSelf->callFunctionByName<int>("dSLinkSend", param);
+          int res = m_pSelf->callFunctionByName<int>("dSLinkSend", param);
+          _handled = true;
+          return res;
         } catch(ScriptException& e) {
           Logger::getInstance()->log(std::string("DSIDJS: Error calling 'dSLinkSend'") + e.what(), lsError);
         }
+        _handled = false;
+        return 0;
       }
       return 0;
     } // dsLinkSend

Modified: dss/trunk/core/sim/dsid_plugin.cpp
===================================================================
--- dss/trunk/core/sim/dsid_plugin.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/sim/dsid_plugin.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -153,10 +153,12 @@
       return "";
     } // getConfigParameter
 
-    virtual uint8_t dsLinkSend(uint8_t _value, uint8_t _flags) {
+    virtual uint8_t dsLinkSend(uint8_t _value, uint8_t _flags, bool _handled) {
       if(m_Interface->udi_send != NULL) {
+        _handled = true;
         return  (*m_Interface->udi_send)(m_Handle, _value, _flags);
       }
+      _handled = false;
       return 0;
     } // dsLinkSend
 

Modified: dss/trunk/core/sim/dsidsim.cpp
===================================================================
--- dss/trunk/core/sim/dsidsim.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/sim/dsidsim.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -67,14 +67,14 @@
   void DSIDSim::increaseValue(const int _parameterNr) {
     if(m_Enabled) {
       m_CurrentValue += 10;
-      m_CurrentValue = min((uint8_t)0xff, m_CurrentValue);
+      m_CurrentValue = std::min((uint8_t)0xff, m_CurrentValue);
     }
   } // increaseValue
 
   void DSIDSim::decreaseValue(const int _parameterNr) {
     if(m_Enabled) {
       m_CurrentValue -= 10;
-      m_CurrentValue = max((uint8_t)0, m_CurrentValue);
+      m_CurrentValue = std::max((uint8_t)0, m_CurrentValue);
     }
   } // decreaseValue
 
@@ -99,16 +99,16 @@
       time_t now;
       time(&now);
       if(m_DimmingUp) {
-        m_CurrentValue = static_cast<int>(max(m_CurrentValue + difftime(m_DimmStartTime, now) * 5, 255.0));
+        m_CurrentValue = int(std::max(m_CurrentValue + difftime(m_DimmStartTime, now) * 5, 255.0));
       } else {
-        m_CurrentValue = static_cast<int>(min(m_CurrentValue - difftime(m_DimmStartTime, now) * 5, 255.0));
+        m_CurrentValue = int(std::min(m_CurrentValue - difftime(m_DimmStartTime, now) * 5, 255.0));
       }
     }
   } // endDim
 
   void DSIDSim::setValue(const double _value, int _parameterNr) {
     if(m_Enabled) {
-      m_CurrentValue = static_cast<int>(_value);
+      m_CurrentValue = int(_value);
     }
   } // setValue
 
@@ -120,11 +120,11 @@
     return FunctionIDDevice;
   } // getFunctionID
 
-  void DSIDSim::setConfigParameter(const string& _name, const string& _value) {
+  void DSIDSim::setConfigParameter(const std::string& _name, const std::string& _value) {
     m_ConfigParameter.set(_name, _value);
   } // setConfigParameter
 
-  string DSIDSim::getConfigParameter(const string& _name) const {
+  std::string DSIDSim::getConfigParameter(const std::string& _name) const {
     return m_ConfigParameter.get(_name, "");
   } // getConfigParameter
 

Modified: dss/trunk/core/sim/dsidsim.h
===================================================================
--- dss/trunk/core/sim/dsidsim.h	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/sim/dsidsim.h	2009-10-05 13:30:07 UTC (rev 8816)
@@ -33,9 +33,9 @@
     bool m_Dimming;
     time_t m_DimmStartTime;
     bool m_DimmingUp;
-    vector<int> m_Parameters;
+    std::vector<int> m_Parameters;
     DSModulatorSim* m_Modulator;
-    vector<uint8_t> m_ValuesForScene;
+    std::vector<uint8_t> m_ValuesForScene;
     uint8_t m_CurrentValue;
     int m_DimTimeMS;
     int m_SimpleConsumption;
@@ -64,8 +64,8 @@
 
     virtual uint16_t getFunctionID();
     void setSimpleConsumption(const int _value) { m_SimpleConsumption = _value; }
-    virtual void setConfigParameter(const string& _name, const string& _value);
-    virtual string getConfigParameter(const string& _name) const;
+    virtual void setConfigParameter(const std::string& _name, const std::string& _value);
+    virtual std::string getConfigParameter(const std::string& _name) const;
   }; // DSIDSim
 
 

Modified: dss/trunk/core/sim/dssim.cpp
===================================================================
--- dss/trunk/core/sim/dssim.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/sim/dssim.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -137,7 +137,7 @@
               modulator = new DSModulatorSim(this);
               modulator->initializeFromNode(node);
               m_Modulators.push_back(modulator);
-            } catch(runtime_error&) {
+            } catch(std::runtime_error&) {
               delete modulator;
             }
           }
@@ -202,7 +202,7 @@
         }
       }
     } catch(const std::exception& ex) {
-      log(string("Error loading plugins: '") + ex.what() + "'");
+      log(std::string("Error loading plugins: '") + ex.what() + "'");
     }
   } // loadPlugins
 
@@ -325,7 +325,7 @@
               m_DeviceNames[busid] = iParam.getChildren()[0].getContent();
             }
           }
-        } catch(runtime_error&) {
+        } catch(std::runtime_error&) {
         }
         if(newDSID != NULL) {
           m_SimulatedDevices.push_back(newDSID);
@@ -414,7 +414,7 @@
 
   void DSModulatorSim::groupCallScene(const int _zoneID, const int _groupID, const int _sceneID) {
 	vector<DSIDInterface*> dsids;
-	m_LastCalledSceneForZoneAndGroup[make_pair(_zoneID, _groupID)] = _sceneID;
+	m_LastCalledSceneForZoneAndGroup[std::make_pair(_zoneID, _groupID)] = _sceneID;
 	if(_groupID == GroupIDBroadcast) {
 	  if(_zoneID == 0) {
 	    dsids = m_SimulatedDevices;
@@ -695,8 +695,8 @@
             case FunctionModulatorGetZoneIdForInd:
               {
                 uint8_t index = pd.get<uint16_t>();
-                map< const int, std::vector<DSIDInterface*> >::iterator it = m_Zones.begin();
-                advance(it, index);
+                std::map< const int, std::vector<DSIDInterface*> >::iterator it = m_Zones.begin();
+                std::advance(it, index);
                 response = createResponse(cmdFrame, cmdNr);
                 response->getPayload().add<uint16_t>(it->first);
                 distributeFrame(response);
@@ -769,7 +769,7 @@
                 int zoneID = pd.get<uint16_t>();
                 int groupID = pd.get<uint16_t>();
                 response = createResponse(cmdFrame, cmdNr);
-                response->getPayload().add<uint16_t>(m_LastCalledSceneForZoneAndGroup[make_pair(zoneID, groupID)]);
+                response->getPayload().add<uint16_t>(m_LastCalledSceneForZoneAndGroup[std::make_pair(zoneID, groupID)]);
                 distributeFrame(response);
               }
               break;
@@ -895,7 +895,7 @@
                 uint16_t zoneID = pd.get<uint16_t>();
                 response = createResponse(cmdFrame, cmdNr);
                 bool isValid = true;
-                for(map< const int, std::vector<DSIDInterface*> >::iterator iZoneEntry = m_Zones.begin(), e = m_Zones.end();
+                for(std::map< const int, std::vector<DSIDInterface*> >::iterator iZoneEntry = m_Zones.begin(), e = m_Zones.end();
                     iZoneEntry != e; ++iZoneEntry)
                 {
                   if(iZoneEntry->first == zoneID) {
@@ -944,8 +944,9 @@
                 uint16_t valueToSend = pd.get<uint16_t>();
                 uint16_t flags = pd.get<uint16_t>();    
                 
-                uint8_t value = dev.dsLinkSend(valueToSend, flags);
-                if((flags & DSLinkSendWriteOnly) == 0) {
+                bool handled = false;
+                uint8_t value = dev.dsLinkSend(valueToSend, flags, handled);
+                if(handled && ((flags & DSLinkSendWriteOnly) == 0)) {
                   response = createReply(cmdFrame);
                   response->setCommand(CommandRequest);
                   response->getPayload().add<uint8_t>(FunctionDSLinkReceive);
@@ -961,8 +962,8 @@
           }
         }
       }
-    } catch(runtime_error& e) {
-      Logger::getInstance()->log(string("DSModulatorSim: Exeption while processing packet. Message: '") + e.what() + "'");
+    } catch(std::runtime_error& e) {
+      Logger::getInstance()->log(std::string("DSModulatorSim: Exeption while processing packet. Message: '") + e.what() + "'");
     }
   } // process
 
@@ -1011,7 +1012,7 @@
         return **ipSimDev;
       }
     }
-    throw runtime_error(string("could not find device with id: ") + intToString(_shortAddress));
+    throw std::runtime_error(std::string("could not find device with id: ") + intToString(_shortAddress));
   } // lookupDevice
 
   int DSModulatorSim::getID() const {
@@ -1049,8 +1050,8 @@
       }
       ++iCreator;
     }
-    Logger::getInstance()->log(string("Could not find creator for DSID type '") + _identifier + "'");
-    throw runtime_error(string("Could not find creator for DSID type '") + _identifier + "'");
+    Logger::getInstance()->log(std::string("Could not find creator for DSID type '") + _identifier + "'");
+    throw std::runtime_error(std::string("Could not find creator for DSID type '") + _identifier + "'");
   } // createDSID
 
   void DSIDFactory::registerCreator(DSIDCreator* _creator) {

Modified: dss/trunk/core/sim/dssim.h
===================================================================
--- dss/trunk/core/sim/dssim.h	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/sim/dssim.h	2009-10-05 13:30:07 UTC (rev 8816)
@@ -40,12 +40,12 @@
 
   class DSIDCreator {
   private:
-    string m_Identifier;
+    std::string m_Identifier;
   public:
-    DSIDCreator(const string& _identifier);
+    DSIDCreator(const std::string& _identifier);
     virtual ~DSIDCreator() {};
 
-    const string& getIdentifier() const { return m_Identifier; }
+    const std::string& getIdentifier() const { return m_Identifier; }
     virtual DSIDInterface* createDSID(const dsid_t _dsid, const devid_t _shortAddress, const DSModulatorSim& _modulator) = 0;
   };
 
@@ -53,7 +53,7 @@
   private:
     boost::ptr_vector<DSIDCreator> m_RegisteredCreators;
   public:
-    DSIDInterface* createDSID(const string& _identifier, const dsid_t _dsid, const devid_t _shortAddress, const DSModulatorSim& _modulator);
+    DSIDInterface* createDSID(const std::string& _identifier, const dsid_t _dsid, const devid_t _shortAddress, const DSModulatorSim& _modulator);
 
     void registerCreator(DSIDCreator* _creator);
   };
@@ -86,7 +86,7 @@
     DSIDInterface* getSimulatedDevice(const dsid_t& _dsid);
   }; // DSSim
 
-  typedef std::map< const pair<const int, const int>,  std::vector<DSIDInterface*> > IntPairToDSIDSimVector;
+  typedef std::map< const std::pair<const int, const int>,  std::vector<DSIDInterface*> > IntPairToDSIDSimVector;
 
   class DSModulatorSim {
   private:
@@ -102,9 +102,9 @@
     std::map<const DSIDInterface*, int> m_ButtonToGroupMapping;
     std::map<const DSIDInterface*, int> m_DeviceZoneMapping;
     std::map<const int, std::vector<int> > m_GroupsPerDevice;
-    std::map<const int, string> m_DeviceNames;
-    std::map< const pair<const int, const int>, int> m_LastCalledSceneForZoneAndGroup;
-    string m_Name;
+    std::map<const int, std::string> m_DeviceNames;
+    std::map< const std::pair<const int, const int>, int> m_LastCalledSceneForZoneAndGroup;
+    std::string m_Name;
   private:
     void addDeviceToGroup(DSIDInterface* _device, int _groupID);
     void loadDevices(XMLNodeList& _nodes, const int _zoneID);
@@ -131,7 +131,7 @@
     void groupSetValue(const int _zoneID, const int _groupID, const int _value);
   protected:
     virtual void doStart() {}
-    void log(const string& _message, aLogSeverity _severity = lsDebug);
+    void log(const std::string& _message, aLogSeverity _severity = lsDebug);
   public:
     DSModulatorSim(DSSim* _pSimulator);
     virtual ~DSModulatorSim() {}
@@ -188,12 +188,15 @@
 
     virtual uint16_t getFunctionID() = 0;
 
-    virtual void setConfigParameter(const string& _name, const string& _value) = 0;
-    virtual string getConfigParameter(const string& _name) const = 0;
+    virtual void setConfigParameter(const std::string& _name, const std::string& _value) = 0;
+    virtual std::string getConfigParameter(const std::string& _name) const = 0;
 
     virtual void setZoneID(const int _value) { m_ZoneID = _value; }
     virtual int getZoneID() const { return m_ZoneID; }
-    virtual uint8_t dsLinkSend(uint8_t _value, uint8_t _flags) { return 0; }
+    virtual uint8_t dsLinkSend(uint8_t _value, uint8_t _flags, bool& _handled) {
+      _handled = false;
+      return 0;
+    }
 
     /** Signals the modulator that a interrupt has occurred */
     void dSLinkInterrupt() {

Modified: dss/trunk/core/webserver.cpp
===================================================================
--- dss/trunk/core/webserver.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/core/webserver.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -90,7 +90,7 @@
     WebServerPlugin* plugin = new WebServerPlugin(pURINode->getStringValue(), pFileNode->getStringValue());
     try {
       plugin->load();
-    } catch(runtime_error& e) {
+    } catch(std::runtime_error& e) {
       delete plugin;
       plugin = NULL;
       log(string("Cought exception while loading: ") + e.what(), lsError);
@@ -490,7 +490,7 @@
   } // toJSONValue(const char*)
 
   string WebServer::ResultToJSON(const bool _ok, const string& _message) {
-    stringstream sstream;
+    std::stringstream sstream;
     sstream << "{ " << ToJSONValue("ok") << ":" << ToJSONValue(_ok);
     if(!_message.empty()) {
       sstream << ", " << ToJSONValue("message") << ":" << ToJSONValue(_message);
@@ -503,7 +503,7 @@
   } // resultToJSON
 
   string JSONOk(const string& _innerResult = "") {
-    stringstream sstream;
+    std::stringstream sstream;
     sstream << "{ " << ToJSONValue("ok") << ":" << ToJSONValue(true);
     if(!_innerResult.empty()) {
       sstream << ", " << ToJSONValue("result")<<  ": " << _innerResult;
@@ -752,7 +752,7 @@
         try {
           Group& grp = getDSS().getApartment().getGroup(groupName);
           interface = &grp;
-        } catch(runtime_error& e) {
+        } catch(std::runtime_error& e) {
           errorMessage = "Could not find group with name '" + groupName + "'";
           ok = false;
         }
@@ -766,7 +766,7 @@
             errorMessage = "Could not parse group id '" + groupIDString + "'";
             ok = false;
           }
-        } catch(runtime_error& e) {
+        } catch(std::runtime_error& e) {
           errorMessage = "Could not find group with ID '" + groupIDString + "'";
           ok = false;
         }
@@ -777,7 +777,7 @@
         }
         return callDeviceInterface(_method, _parameter, _connection, interface, _session);
       } else {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ ok: " << ToJSONValue(ok) << ", message: " << ToJSONValue(errorMessage) << " }";
         return sstream.str();
       }
@@ -799,7 +799,7 @@
         m_Sessions[token] = Session(token);
         return "{" + ToJSONValue("token") + ": " + ToJSONValue(token) + "}";
       } else if(endsWith(_method, "/getCircuits")) {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("circuits") << ": [";
         bool first = true;
         vector<Modulator*>& modulators = getDSS().getApartment().getModulators();
@@ -821,7 +821,7 @@
         sstream << "]}";
         return JSONOk(sstream.str());
       } else if(endsWith(_method, "/getName")) {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{" << ToJSONValue("name") << ":" << ToJSONValue(getDSS().getApartment().getName()) << "}";
         return JSONOk(sstream.str());
       } else if(endsWith(_method, "/setName")) {
@@ -847,7 +847,7 @@
         try {
           Zone& zone = getDSS().getApartment().getZone(zoneID);
           pZone = &zone;
-        } catch(runtime_error& e) {
+        } catch(std::runtime_error& e) {
           ok = false;
           errorMessage = "Could not find zone with id '" + zoneIDString + "'";
         }
@@ -859,7 +859,7 @@
       try {
         Zone& zone = getDSS().getApartment().getZone(zoneName);
         pZone = &zone;
-      } catch(runtime_error& e) {
+      } catch(std::runtime_error& e) {
         ok = false;
         errorMessage = "Could not find zone named '" + zoneName + "'";
       }
@@ -876,9 +876,9 @@
           pGroup = pZone->getGroup(groupName);
           if(pGroup == NULL) {
             // TODO: this might better be done by the zone
-            throw runtime_error("dummy");
+            throw std::runtime_error("dummy");
           }
-        } catch(runtime_error& e) {
+        } catch(std::runtime_error& e) {
           errorMessage = "Could not find group with name '" + groupName + "'";
           ok = false;
         }
@@ -889,13 +889,13 @@
             pGroup = pZone->getGroup(groupID);
             if(pGroup == NULL) {
               // TODO: this might better be done by the zone
-              throw runtime_error("dummy");
+              throw std::runtime_error("dummy");
             }
           } else {
             errorMessage = "Could not parse group id '" + groupIDString + "'";
             ok = false;
           }
-        } catch(runtime_error& e) {
+        } catch(std::runtime_error& e) {
           errorMessage = "Could not find group with ID '" + groupIDString + "'";
           ok = false;
         }
@@ -922,11 +922,11 @@
             // should never reach here because ok, would be false
             assert(false);
           }
-          stringstream sstream;
+          std::stringstream sstream;
           sstream << "{" << ToJSONValue("scene") << ":" << ToJSONValue(lastScene) << "}";
           return JSONOk(sstream.str());
         } else if(endsWith(_method, "/getName")) {
-          stringstream sstream;
+          std::stringstream sstream;
           sstream << "{" << ToJSONValue("name") << ":" << ToJSONValue(pZone->getName()) << "}";
           return JSONOk(sstream.str());
         } else if(endsWith(_method, "/setName")) {
@@ -958,7 +958,7 @@
         try {
           Device& device = getDSS().getApartment().getDeviceByDSID(deviceDSID);
           pDevice = &device;
-        } catch(runtime_error& e) {
+        } catch(std::runtime_error& e) {
           ok = false;
           errorMessage = "Could not find device with dsid '" + deviceDSIDString + "'";
         }
@@ -970,7 +970,7 @@
       try {
         Device& device = getDSS().getApartment().getDeviceByName(deviceName);
         pDevice = &device;
-      } catch(runtime_error&  e) {
+      } catch(std::runtime_error&  e) {
         ok = false;
         errorMessage = "Could not find device named '" + deviceName + "'";
       }
@@ -983,7 +983,7 @@
         return callDeviceInterface(_method, _parameter, _connection, pDevice, _session);
       } else if(beginsWith(_method, "device/getGroups")) {
         int numGroups = pDevice->getGroupsCount();
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("groups") << ": [";
         bool first = true;
         for(int iGroup = 0; iGroup < numGroups; iGroup++) {
@@ -997,7 +997,7 @@
             if(!group.getName().empty()) {
               sstream << ", " << ToJSONValue("name") << ":" << ToJSONValue(group.getName());
             }
-          } catch (runtime_error&) {
+          } catch(std::runtime_error&) {
             log("Group only present at device level");
           }
           sstream << "}";
@@ -1005,11 +1005,11 @@
         sstream << "]}";
         return sstream.str();
       } else if(beginsWith(_method, "device/getState")) {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("isOn") << ":" << ToJSONValue(pDevice->isOn()) << " }";
         return JSONOk(sstream.str());
       } else if(beginsWith(_method, "device/getName")) {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("name") << ":" << ToJSONValue(pDevice->getName()) << " }";
         return JSONOk(sstream.str());
       } else if(beginsWith(_method, "device/setName")) {
@@ -1047,11 +1047,16 @@
         if(_parameter["lastValue"] == "true") {
           lastValue = true;
         }
-        uint8_t result = pDevice->dsLinkSend(iValue, lastValue, writeOnly);
+        uint8_t result;
+        try {
+          result = pDevice->dsLinkSend(iValue, lastValue, writeOnly);
+        } catch(std::runtime_error& e) {
+          return ResultToJSON(false, std::string("Error: ") + e.what());
+        }
         if(writeOnly) {
           return ResultToJSON(true);
         } else {
-          stringstream sstream;
+          std::stringstream sstream;
           sstream << "{" << ToJSONValue("value") << ":" << ToJSONValue(result) << "}";
           return JSONOk(sstream.str());
         }
@@ -1082,7 +1087,7 @@
         modulator.setName(_parameter["newName"]);
         return ResultToJSON(true);
       } else if(endsWith(_method, "circuit/getEnergyBorder")) {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{" << ToJSONValue("orange") << ":" << ToJSONValue(modulator.getEnergyLevelOrange());
         sstream << "," << ToJSONValue("red") << ":" << ToJSONValue(modulator.getEnergyLevelRed());
         sstream << "}";
@@ -1094,7 +1099,7 @@
       } else {
         _handled = false;
       }
-    } catch(runtime_error&) {
+    } catch(std::runtime_error&) {
       return ResultToJSON(false, "could not find modulator with given dsid");
     }
     return "";
@@ -1215,7 +1220,7 @@
         return ResultToJSON(false, "Could not find node named '" + propName + "'");
       }
       try {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("value") << ": " << ToJSONValue(node->getStringValue()) << "}";
         return JSONOk(sstream.str());
       } catch(PropertyTypeMismatch& ex) {
@@ -1226,7 +1231,7 @@
         return ResultToJSON(false, "Could not find node named '" + propName + "'");
       }
       try {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("value") << ": " << ToJSONValue(node->getIntegerValue()) << "}";
         return JSONOk(sstream.str());
       } catch(PropertyTypeMismatch& ex) {
@@ -1237,7 +1242,7 @@
         return ResultToJSON(false, "Could not find node named '" + propName + "'");
       }
       try {
-        stringstream sstream;
+        std::stringstream sstream;
         sstream << "{ " << ToJSONValue("value") << ": " << ToJSONValue(node->getBoolValue()) << "}";
         return JSONOk(sstream.str());
       } catch(PropertyTypeMismatch& ex) {
@@ -1294,7 +1299,7 @@
       if(node == NULL) {
         return ResultToJSON(false, "Could not find node named '" + propName + "'");
       }
-      stringstream sstream;
+      std::stringstream sstream;
       sstream << "[";
       bool first = true;
       for(int iChild = 0; iChild < node->getChildCount(); iChild++) {
@@ -1313,7 +1318,7 @@
       if(node == NULL) {
         return ResultToJSON(false, "Could not find node named '" + propName + "'");
       }
-      stringstream sstream;
+      std::stringstream sstream;
       sstream << ":" << ToJSONValue("type") << ":" << ToJSONValue(getValueTypeAsString(node->getValueType())) << "}";
       return JSONOk(sstream.str());
     } else {
@@ -1375,7 +1380,7 @@
             } catch(ItemNotFoundException&) {
               return ResultToJSON(false, "Could not find zone");
             }
-          } catch(runtime_error&) {
+          } catch(std::runtime_error&) {
             ok = false;
           }
         }
@@ -1468,7 +1473,7 @@
           default:
             return ResultToJSON(false, "Invalid button nr (range is 1..9)");
           }
-        } catch(runtime_error&) {
+        } catch(std::runtime_error&) {
           return ResultToJSON(false, "Could not find zone");
         }
       } else {
@@ -1509,10 +1514,10 @@
       frame->setCommand(command);
       for(int iByte = 0; iByte < length; iByte++) {
         uint8_t byte = strToIntDef(_parameter[string("payload_") + intToString(iByte+1)], 0xFF);
-        cout << "b" << dec << iByte << ": " << hex << (int)byte << "\n";
+        std::cout << "b" << std::dec << iByte << ": " << std::hex << (int)byte << "\n";
         frame->getPayload().add<uint8_t>(byte);
       }
-      cout << dec <<"done" << endl;
+      std::cout << std::dec << "done" << std::endl;
       DS485Interface* intf = &DSS::getInstance()->getDS485Interface();
       DS485Proxy* proxy = dynamic_cast<DS485Proxy*>(intf);
       if(proxy != NULL) {
@@ -1531,7 +1536,7 @@
     if(endsWith(_method, "/getResolutions")) {
       _handled = true;
       std::vector<boost::shared_ptr<MeteringConfigChain> > meteringConfig = getDSS().getMetering().getConfig();
-      stringstream sstream;
+      std::stringstream sstream;
       sstream << "{" << ToJSONValue("resolutions") << ":" << "[";
       for(unsigned int iConfig = 0; iConfig < meteringConfig.size(); iConfig++) {
         boost::shared_ptr<MeteringConfigChain> cConfig = meteringConfig[iConfig];
@@ -1548,7 +1553,7 @@
       return JSONOk(sstream.str());
     } else if(endsWith(_method, "/getSeries")) {
       _handled = true;
-      stringstream sstream;
+      std::stringstream sstream;
       sstream << "{ " << ToJSONValue("series") << ": [";
       bool first = true;
       vector<Modulator*>& modulators = getDSS().getApartment().getModulators();
@@ -1582,7 +1587,7 @@
         if(!(deviceDSID == NullDSID)) {
           try {
             getDSS().getApartment().getModulatorByDSID(deviceDSID);
-          } catch(runtime_error& e) {
+          } catch(std::runtime_error& e) {
             return ResultToJSON(false, "Could not find device with dsid '" + deviceDSIDString + "'");
           }
         } else {
@@ -1627,7 +1632,7 @@
             boost::shared_ptr<Series<CurrentValue> > s = boost::shared_ptr<Series<CurrentValue> >(reader.readFromXML(seriesPath));
             std::deque<CurrentValue>* values = s->getExpandedValues();
             bool first = true;
-            stringstream sstream;
+            std::stringstream sstream;
             sstream << "{ " ;
             sstream << ToJSONValue("dsmid") << ":" << ToJSONValue(deviceDSIDString) << ",";
             sstream << ToJSONValue("type") << ":" << ToJSONValue(typeString) << ",";

Modified: dss/trunk/tests/ds485tests.cpp
===================================================================
--- dss/trunk/tests/ds485tests.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/tests/ds485tests.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -34,7 +34,7 @@
 BOOST_AUTO_TEST_CASE(testFrameReader) {
   boost::scoped_ptr<DS485FrameReader> reader(new DS485FrameReader());
   boost::shared_ptr<SerialComSim> simPort(new SerialComSim());
-  string frame;
+  std::string frame;
 /*
   frame.push_back('\xFD');
   frame.push_back('\x05');
@@ -123,7 +123,7 @@
 
   simPort->putSimData(frame);
   reader->setSerialCom(simPort);
-  //reader->execute();
+  delete reader->getFrame(1000);
 } // testFrameReader
 
 BOOST_AUTO_TEST_SUITE_END()

Modified: dss/trunk/tests/eventtests.cpp
===================================================================
--- dss/trunk/tests/eventtests.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/tests/eventtests.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -118,7 +118,7 @@
 
   try {
     interpreter.loadFromXML("data/iwillnever_be_a_subscription.xml");
-  } catch(runtime_error& e) {
+  } catch(std::runtime_error& e) {
   }
 
   BOOST_CHECK_EQUAL(interpreter.getNumberOfSubscriptions(), 0);
@@ -139,7 +139,7 @@
 
   try {
     interpreter.loadFromXML("data/testsubscriptions.xml");
-  } catch(runtime_error& e) {
+  } catch(std::runtime_error& e) {
   }
 
   BOOST_CHECK_EQUAL(interpreter.getNumberOfSubscriptions(), 2);
@@ -239,7 +239,7 @@
 
   try {
     interpreter.loadFromXML("data/testsubscriptions_DS485.xml");
-  } catch(runtime_error& e) {
+  } catch(std::runtime_error& e) {
   }
 
   BOOST_CHECK_EQUAL(interpreter.getNumberOfSubscriptions(), 3);

Modified: dss/trunk/unix/ds485.cpp
===================================================================
--- dss/trunk/unix/ds485.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/unix/ds485.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -34,8 +34,6 @@
 
 #include <boost/scoped_ptr.hpp>
 
-using namespace std;
-
 namespace dss {
 
   const unsigned char FrameStart = 0xFD;
@@ -83,15 +81,15 @@
     return m_Data.size();
   } // size
 
-  const vector<unsigned char>& DS485Payload::toChar() const {
+  const std::vector<unsigned char>& DS485Payload::toChar() const {
     return m_Data;
   } // getData
 
 
   //================================================== DS485Header
 
-  vector<unsigned char> DS485Header::toChar() const {
-    vector<unsigned char> result;
+  std::vector<unsigned char> DS485Header::toChar() const {
+    std::vector<unsigned char> result;
     result.push_back(FrameStart);
     unsigned char tmp = (m_Destination << 2) | ((m_Broadcast & 0x01) << 1) | (m_Type & 0x01);
     result.push_back(tmp);
@@ -103,7 +101,7 @@
 
   void DS485Header::fromChar(const unsigned char* _data, const int _len) {
     if(_len < 3) {
-      throw invalid_argument("_len must be > 3");
+      throw std::invalid_argument("_len must be > 3");
     }
     setDestination((_data[1] >> 2) & 0x3F);
     setBroadcast((_data[1] & 0x02) == 0x02);
@@ -114,8 +112,8 @@
 
   //================================================== DS485Frame
 
-  vector<unsigned char> DS485Frame::toChar() const {
-    vector<unsigned char> result = m_Header.toChar();
+  std::vector<unsigned char> DS485Frame::toChar() const {
+    std::vector<unsigned char> result = m_Header.toChar();
     return result;
   } // toChar
 
@@ -136,8 +134,8 @@
     getHeader().setType(1);
   } // ctor
 
-  vector<unsigned char> DS485CommandFrame::toChar() const {
-    vector<unsigned char> result = DS485Frame::toChar();
+  std::vector<unsigned char> DS485CommandFrame::toChar() const {
+    std::vector<unsigned char> result = DS485Frame::toChar();
     unsigned char tmp;
     if(m_Length == 0xFF) {
       tmp = (m_Command << 4) | (getPayload().size() & 0x0F);
@@ -146,7 +144,7 @@
     }
     result.push_back(tmp);
 
-    const vector<unsigned char>& payload = getPayload().toChar();
+    const std::vector<unsigned char>& payload = getPayload().toChar();
     result.insert(result.end(), payload.begin(), payload.end());
     return result;
   } // toChar
@@ -183,8 +181,8 @@
         //Logger::getInstance()->log(string("length:  ") + intToString((cmdFrame->getLength())));
         //Logger::getInstance()->log(string("msg nr:  ") + intToString(cmdFrame->getHeader().getCounter()));
       } else {
-        //cout << "+";
-        //flush(cout);
+        //std::cout << "+";
+        //flush(std::cout);
         //Logger::getInstance()->log("token received");
       }
     }
@@ -202,7 +200,7 @@
   } // putCharOnWire
 
   bool DS485Controller::putFrameOnWire(const DS485Frame* _pFrame, bool _freeFrame) {
-    vector<unsigned char> chars = _pFrame->toChar();
+    std::vector<unsigned char> chars = _pFrame->toChar();
     uint16_t crc = 0x0000;
 
     unsigned int numChars = chars.size();
@@ -237,8 +235,8 @@
       m_SerialCom->open(m_RS485DeviceName.c_str());
       m_FrameReader.setSerialCom(m_SerialCom);
       return true;
-    } catch(const runtime_error& _ex) {
-      Logger::getInstance()->log(string("Caught exception while opening serial port: ") + _ex.what(), lsFatal);
+    } catch(const std::runtime_error& _ex) {
+      Logger::getInstance()->log(std::string("Caught exception while opening serial port: ") + _ex.what(), lsFatal);
       return false;
     }
   } // resetSerialLine
@@ -281,7 +279,7 @@
         continue;
       } else if(m_State == csCommError) {
         sleepMS(comErrorSleepTimeScaler++ * 500);
-        comErrorSleepTimeScaler = min(comErrorSleepTimeScaler, 60);
+        comErrorSleepTimeScaler = std::min(comErrorSleepTimeScaler, 60);
         if(resetSerialLine()) {
           doChangeState(csInitial);
         }
@@ -298,7 +296,7 @@
             doChangeState(csDesignatedMaster);
           }
           comErrorSleepTimeScaler = 1;
-        } catch(const runtime_error&) {
+        } catch(const std::runtime_error&) {
           doChangeState(csCommError);
         }
         continue;
@@ -307,17 +305,17 @@
       boost::scoped_ptr<DS485Frame> frame;
       try {
         frame.reset(getFrameFromWire());
-      } catch(const runtime_error&) {
+      } catch(const std::runtime_error&) {
         doChangeState(csCommError);
         continue;
       }
       if(frame.get() == NULL) {
         if(m_State != csDesignatedMaster) {
-          cout << "§";
+          std::cout << "§";
           missedFramesCounter++;
           if(missedFramesCounter == 50) {
             missedFramesCounter = 0;
-            cout << "haven't received any frames for 50 iterations, restarting..." << endl;
+            std::cout << "haven't received any frames for 50 iterations, restarting..." << std::endl;
             doChangeState(csInitial);
           }
         } else {
@@ -327,9 +325,9 @@
         if(lastSentWasToken) {
           putFrameOnWire(token.get(), false);
           lastSentWasToken = false;
-          cout << "t(#)";
+          std::cout << "t(#)";
         }
-        flush(cout);
+        flush(std::cout);
       } else {
         DS485Header& header = frame->getHeader();
         DS485CommandFrame* cmdFrame = dynamic_cast<DS485CommandFrame*>(frame.get());
@@ -345,10 +343,10 @@
         {
 /*
           Logger::getInstance()->log("packet not for me, discarding");
-          cout << "dest: " << (int)header.getDestination() << endl;
-          cout << "src:  " << (int)header.getSource() << endl;
+          std::cout << "dest: " << (int)header.getDestination() << std::endl;
+          std::cout << "src:  " << (int)header.getSource() << std::endl;
           if(cmdFrame != NULL) {
-            cout << "cmd:  " << CommandToString(cmdFrame->getCommand()) << endl;
+            std::cout << "cmd:  " << CommandToString(cmdFrame->getCommand()) << std::endl;
           }
 */
           continue;
@@ -364,9 +362,9 @@
               frameToSend->setCommand(CommandGetAddressResponse);
               putFrameOnWire(frameToSend);
               if(header.isBroadcast()) {
-                cerr << "Get address request with bc-flag set" << endl;
+                std::cerr << "Get address request with bc-flag set" << std::endl;
               } else {
-                cout << "sent response to get address thingie" << endl;
+                std::cout << "sent response to get address thingie" << std::endl;
               }
               continue;
             }
@@ -391,17 +389,17 @@
                     // don’t wait forever if we’re in slow-joining mode
                     numberOfJoinPacketsToWait = rand() % 10;
                   }
-                  cout << "** Waiting for " << numberOfJoinPacketsToWait << endl;
+                  std::cout << "** Waiting for " << numberOfJoinPacketsToWait << std::endl;
                 } else {
                   numberOfJoinPacketsToWait--;
                   if(numberOfJoinPacketsToWait == 0) {
                     m_StationID = 0x3F;
                     putFrameOnWire(solicitSuccessorResponseFrame.get(), false);
-                    //cout << "******* FRAME AWAY ******" << endl;
+                    //std::cout << "******* FRAME AWAY ******" << std::endl;
                     doChangeState(csSlaveJoining);
                     time(&responseSentAt);
                   }
-                  //cout << numberOfJoinPacketsToWait << endl;
+                  //std::cout << numberOfJoinPacketsToWait << std::endl;
                 }
               }
             }
@@ -416,7 +414,7 @@
               frameToSend->getHeader().setSource(m_StationID);
               frameToSend->setCommand(CommandSetDeviceAddressResponse);
               putFrameOnWire(frameToSend);
-              cout << "### new address " << m_StationID << "\n";
+              std::cout << "### new address " << m_StationID << "\n";
             } else if(cmdFrame->getCommand() == CommandSetSuccessorAddressRequest) {
               if(header.getDestination() == m_StationID) {
                 handleSetSuccessor(cmdFrame);
@@ -427,7 +425,7 @@
               time(&now);
               if((now - responseSentAt) > 1) {
                 doChangeState(csSlaveWaitingToJoin);
-                cerr << "çççççççççç haven't received my address" << endl;
+                std::cerr << "çççççççççç haven't received my address" << std::endl;
               }
             }
             if((m_StationID != 0x3F) && (m_NextStationID != 0xFF)) {
@@ -444,7 +442,7 @@
           break;
         case csSlave:
           if(cmdFrame == NULL) {
-//            cout << "+";
+//            std::cout << "+";
             // it's a token
             if(!m_PendingFrames.empty() && (m_TokenCounter > 10)) {
 
@@ -452,7 +450,7 @@
               m_PendingFramesGuard.lock();
               DS485CommandFrame& frameToSend = m_PendingFrames.front();
               putFrameOnWire(&frameToSend, false);
-              cout << "p%" << (int)frameToSend.getCommand() << "%e" << endl;
+              std::cout << "p%" << (int)frameToSend.getCommand() << "%e" << std::endl;
 
               // if not a broadcast, wait for ack, etc
               if(frameToSend.getHeader().isBroadcast()) {
@@ -463,22 +461,22 @@
                 if(cmdAckFrame != NULL) {
                   if(cmdAckFrame->getCommand() == CommandAck) {
                     m_PendingFrames.erase(m_PendingFrames.begin());
-                    cout << "\ngot ack" << endl;
+                    std::cout << "\ngot ack" << std::endl;
                   } else {
                     m_PendingFrames.erase(m_PendingFrames.begin());
-                    cout << "\n&&&&got other" << endl;
+                    std::cout << "\n&&&&got other" << std::endl;
                     addToReceivedQueue(cmdAckFrame);
                   }
                 } else {
                   m_PendingFrames.erase(m_PendingFrames.begin());
-                  cout << "no ack received" << endl;
+                  std::cout << "no ack received" << std::endl;
                 }
               }
             }
             m_PendingFramesGuard.unlock();
             putFrameOnWire(token.get(), false);
-//            cout << ".";
-//            flush(cout);
+//            std::cout << ".";
+//            flush(std::cout);
             time(&tokenReceivedAt);
             m_TokenEvent.broadcast();
             m_TokenCounter++;
@@ -489,11 +487,11 @@
             time_t now;
             time(&now);
             if((now - tokenReceivedAt) > 15) {
-              cerr << "restarting" << endl;
+              std::cerr << "restarting" << std::endl;
               doChangeState(csInitial);
               continue;
             }
-            cout << "f*" << (int)cmdFrame->getCommand() << "*";
+            std::cout << "f*" << (int)cmdFrame->getCommand() << "*";
 
             bool keep = false;
 
@@ -505,9 +503,9 @@
                 ack->getHeader().setDestination(cmdFrame->getHeader().getSource());
                 ack->setCommand(CommandAck);
                 putFrameOnWire(ack);
-                cout << "a(res)";
+                std::cout << "a(res)";
               } else {
-                cout << "b";
+                std::cout << "b";
               }
               keep = true;
             } else if(cmdFrame->getCommand() == CommandRequest || cmdFrame->getCommand() == CommandEvent) {
@@ -517,7 +515,7 @@
                 ack->getHeader().setDestination(cmdFrame->getHeader().getSource());
                 ack->setCommand(CommandAck);
                 putFrameOnWire(ack);
-                cout << "a(req)";
+                std::cout << "a(req)";
               }
               keep = true;
             } else if(cmdFrame->getCommand() == CommandSetSuccessorAddressRequest) {
@@ -526,14 +524,14 @@
                 token->getHeader().setDestination(m_NextStationID);
               }
             } else {
-              cout << "&&&&&&&&&& unknown frame id: " << (int)cmdFrame->getCommand() << endl;
+              std::cout << "&&&&&&&&&& unknown frame id: " << (int)cmdFrame->getCommand() << std::endl;
             }
             if(keep) {
               // put in into the received queue
               addToReceivedQueue(cmdFrame);
-              cout << "k";
+              std::cout << "k";
             }
-            flush(cout);
+            flush(std::cout);
           }
           break;
         case csSlaveWaitingForFirstToken:
@@ -543,8 +541,8 @@
               m_TokenCounter = 0;
               doChangeState(csSlave);
               time(&tokenReceivedAt);
-//              cout << ">";
-//              flush(cout);
+//              std::cout << ">";
+//              flush(std::cout);
             }
           }
           break;
@@ -553,7 +551,7 @@
           doChangeState(csInitial);
           break;
         default:
-          throw runtime_error("invalid value for m_State");
+          throw std::runtime_error("invalid value for m_State");
         }
       }
     }
@@ -566,7 +564,7 @@
     frameToSend->getHeader().setSource(m_StationID);
     frameToSend->setCommand(CommandSetSuccessorAddressResponse);
     putFrameOnWire(frameToSend);
-    cout << "### successor " << m_NextStationID << "\n";
+    std::cout << "### successor " << m_NextStationID << "\n";
   } // handleSetSuccessor
 
   // TODO: look into boost::weak_ptr
@@ -669,7 +667,7 @@
       gettimeofday(&now, 0);
       int diffMS = (now.tv_sec - timeStarted.tv_sec) * 1000 + (now.tv_usec - timeStarted.tv_usec) / 1000;
       if(diffMS > _timeoutMS) {
-        flush(cout);
+        flush(std::cout);
         if(m_State == rsSynchronizing || m_ValidBytes == 0) {
           break;
         }
@@ -713,7 +711,7 @@
             if(((unsigned char)currentChar == FrameStart) && !m_IsEscaped) {
               m_State = rsReadingHeader;
             } else {
-              cout << "?";
+              std::cout << "?";
             }
             break;
           }
@@ -742,8 +740,8 @@
                 frame->getHeader().fromChar(m_ReceiveBuffer, m_ValidBytes);
                 m_NumberOfFramesReceived++;
 
-                //cout << "-";
-                //flush(cout);
+                //std::cout << "-";
+                //flush(std::cout);
                 m_State = rsSynchronizing;
                 return frame;
               }
@@ -773,7 +771,7 @@
                 m_NumberOfCRCErrors++;
               } else {
                 //Logger::getInstance()->log("received packet, crc ok");
-                //cout << "#";
+                //std::cout << "#";
                 m_NumberOfFramesReceived++;
               }
               DS485CommandFrame* frame = new DS485CommandFrame();
@@ -783,8 +781,8 @@
               for(int iByte = 0; iByte < m_MessageLength; iByte++) {
                 frame->getPayload().add<uint8_t>(static_cast<uint8_t>(m_ReceiveBuffer[iByte + 4]));
               }
-              //cout << "*" << frame->getCommand() << "*";
-              //flush(cout);
+              //std::cout << "*" << frame->getCommand() << "*";
+              //flush(std::cout);
 
               // the show must go on...
               m_MessageLength = -1;
@@ -805,14 +803,14 @@
   } // addFrameCollector
 
   void DS485FrameProvider::removeFrameCollector(IDS485FrameCollector* _collector) {
-    vector<IDS485FrameCollector*>::iterator iCollector = find(m_FrameCollectors.begin(), m_FrameCollectors.end(), _collector);
+    std::vector<IDS485FrameCollector*>::iterator iCollector = find(m_FrameCollectors.begin(), m_FrameCollectors.end(), _collector);
     if(iCollector != m_FrameCollectors.end()) {
       m_FrameCollectors.erase(iCollector);
     }
   } // removeFrameCollector
 
   void DS485FrameProvider::distributeFrame(boost::shared_ptr<DS485CommandFrame> _frame) {
-    for(vector<IDS485FrameCollector*>::iterator iCollector = m_FrameCollectors.begin(), e = m_FrameCollectors.end();
+    for(std::vector<IDS485FrameCollector*>::iterator iCollector = m_FrameCollectors.begin(), e = m_FrameCollectors.end();
         iCollector != e; ++iCollector)
     {
       (*iCollector)->collectFrame(_frame);
@@ -869,7 +867,7 @@
 
   //================================================== DS485FrameSniffer
 #ifndef __APPLE__
-  DS485FrameSniffer::DS485FrameSniffer(const string& _deviceName)
+  DS485FrameSniffer::DS485FrameSniffer(const std::string& _deviceName)
   {
      m_SerialCom.reset(new SerialCom());
      m_SerialCom->open(_deviceName.c_str());
@@ -889,21 +887,21 @@
           double diffMS = ((thisFrame.tv_sec*1000.0 + thisFrame.tv_nsec/1000.0/1000.0) -
                            (lastFrame.tv_sec*1000.0 + lastFrame.tv_nsec/1000.0/1000.0));
 
-          cout << "+" << diffMS << "\n";
+          std::cout << "+" << diffMS << "\n";
 
           DS485CommandFrame* cmdFrame = dynamic_cast<DS485CommandFrame*>(frame.get());
           if(cmdFrame != NULL) {
             uint8_t cmd = cmdFrame->getCommand();
-            cout << "Command Frame: " << commandToString(cmd) <<  " " << "(" <<  (int)cmd << ") " << (int)frame->getHeader().getSource() << " -> " << (int)frame->getHeader().getDestination()  << "\n";
+            std::cout << "Command Frame: " << commandToString(cmd) <<  " " << "(" <<  (int)cmd << ") " << (int)frame->getHeader().getSource() << " -> " << (int)frame->getHeader().getDestination()  << "\n";
 
             if(cmd == CommandRequest || cmd == CommandResponse) {
               PayloadDissector pd(cmdFrame->getPayload());
-              cout << (int)pd.get<uint8_t>() << "\n";
+              std::cout << (int)pd.get<uint8_t>() << "\n";
             }
           } else {
-            cout << "token " << (int)frame->getHeader().getSource() << " -> " << (int)frame->getHeader().getDestination()  << "\n";
+            std::cout << "token " << (int)frame->getHeader().getSource() << " -> " << (int)frame->getHeader().getDestination()  << "\n";
           }
-          cout << "seq: " << (int)frame->getHeader().getCounter() << endl;
+          std::cout << "seq: " << (int)frame->getHeader().getCounter() << std::endl;
 
           lastFrame = thisFrame;
         }

Modified: dss/trunk/unix/ds485proxy.cpp
===================================================================
--- dss/trunk/unix/ds485proxy.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/unix/ds485proxy.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -49,7 +49,7 @@
   } // splitByModulator
 
 
-  typedef map<const Zone*, Set> HashMapZoneSet;
+  typedef std::map<const Zone*, Set> HashMapZoneSet;
 
   HashMapZoneSet splitByZone(const Set& _set) {
     HashMapZoneSet result;
@@ -78,97 +78,97 @@
     }
 
 
-	if(_zone.getDevices().length() == _set.length()) {
-	  Logger::getInstance()->log(string("Optimization: Set contains all devices of zone ") + intToString(_zone.getZoneID()));
-      std::bitset<63> possibleGroups;
-      possibleGroups.set();
-      for(int iDevice = 0; iDevice < _set.length(); iDevice++) {
-        possibleGroups &= _set[iDevice].getDevice().getGroupBitmask();
-	  }
-	  if(possibleGroups.any()) {
-        for(unsigned int iGroup = 0; iGroup < possibleGroups.size(); iGroup++) {
-          if(possibleGroups.test(iGroup)) {
-            Logger::getInstance()->log("Sending the command to group " + intToString(iGroup + 1));
-            fittingGroups.push_back(_zone.getGroup(iGroup + 1));
-            break;
+    if(_zone.getDevices().length() == _set.length()) {
+      Logger::getInstance()->log(string("Optimization: Set contains all devices of zone ") + intToString(_zone.getZoneID()));
+        std::bitset<63> possibleGroups;
+        possibleGroups.set();
+        for(int iDevice = 0; iDevice < _set.length(); iDevice++) {
+          possibleGroups &= _set[iDevice].getDevice().getGroupBitmask();
+      }
+      if(possibleGroups.any()) {
+          for(unsigned int iGroup = 0; iGroup < possibleGroups.size(); iGroup++) {
+            if(possibleGroups.test(iGroup)) {
+              Logger::getInstance()->log("Sending the command to group " + intToString(iGroup + 1));
+              fittingGroups.push_back(_zone.getGroup(iGroup + 1));
+              break;
+            }
           }
+        } else {
+          Logger::getInstance()->log("Sending the command to broadcast group");
+          fittingGroups.push_back(_zone.getGroup(GroupIDBroadcast));
         }
       } else {
-        Logger::getInstance()->log("Sending the command to broadcast group");
-  	    fittingGroups.push_back(_zone.getGroup(GroupIDBroadcast));
-  	  }
-    } else {
-	    std::vector<Group*> unsuitableGroups;
-	    Set workingCopy = _set;
+        std::vector<Group*> unsuitableGroups;
+        Set workingCopy = _set;
 
-		while(!workingCopy.isEmpty()) {
-		  DeviceReference& ref = workingCopy.get(0);
-		  workingCopy.removeDevice(ref);
+      while(!workingCopy.isEmpty()) {
+        DeviceReference& ref = workingCopy.get(0);
+        workingCopy.removeDevice(ref);
 
-		  if(OptimizerDebug) {
-		    Logger::getInstance()->log("Working with device " + ref.getDSID().toString());
-		  }
+        if(OptimizerDebug) {
+          Logger::getInstance()->log("Working with device " + ref.getDSID().toString());
+        }
 
-		  bool foundGroup = false;
-		  for(int iGroup = 0; iGroup < ref.getDevice().getGroupsCount(); iGroup++) {
-			Group& g = ref.getDevice().getGroupByIndex(iGroup);
+        bool foundGroup = false;
+        for(int iGroup = 0; iGroup < ref.getDevice().getGroupsCount(); iGroup++) {
+        Group& g = ref.getDevice().getGroupByIndex(iGroup);
 
-  		    if(OptimizerDebug) {
-		      Logger::getInstance()->log("  Checking Group " + intToString(g.getID()));
-		    }
-			// continue if already found unsuitable
-			if(find(unsuitableGroups.begin(), unsuitableGroups.end(), &g) != unsuitableGroups.end()) {
-  		      if(OptimizerDebug) {
-		        Logger::getInstance()->log("  Group discarded before, continuing search");
-		      }
-			  continue;
-			}
+            if(OptimizerDebug) {
+            Logger::getInstance()->log("  Checking Group " + intToString(g.getID()));
+          }
+        // continue if already found unsuitable
+        if(find(unsuitableGroups.begin(), unsuitableGroups.end(), &g) != unsuitableGroups.end()) {
+              if(OptimizerDebug) {
+              Logger::getInstance()->log("  Group discarded before, continuing search");
+            }
+          continue;
+        }
 
-			// see if we've got a fit
-			bool groupFits = true;
-			Set devicesInGroup = _zone.getDevices().getByGroup(g);
-  		    if(OptimizerDebug) {
-		      Logger::getInstance()->log("    Group has " + intToString(devicesInGroup.length()) + " devices");
-		    }
-			for(int iDevice = 0; iDevice < devicesInGroup.length(); iDevice++) {
-			  if(!_set.contains(devicesInGroup.get(iDevice))) {
-				unsuitableGroups.push_back(&g);
-				groupFits = false;
-   		        if(OptimizerDebug) {
-		          Logger::getInstance()->log("    Original set does _not_ contain device " + devicesInGroup.get(iDevice).getDevice().getDSID().toString());
-		        }
-				break;
-			  }
-   		      if(OptimizerDebug) {
-		        Logger::getInstance()->log("    Original set contains device " + devicesInGroup.get(iDevice).getDevice().getDSID().toString());
-		      }
-			}
-			if(groupFits) {
-  		      if(OptimizerDebug) {
-		        Logger::getInstance()->log("  Found a fit " + intToString(g.getID()));
-		      }
-			  foundGroup = true;
-			  fittingGroups.push_back(&g);
-   		      if(OptimizerDebug) {
-		        Logger::getInstance()->log("  Removing devices from working copy");
-		      }
-			  while(!devicesInGroup.isEmpty()) {
-				workingCopy.removeDevice(devicesInGroup.get(0));
-			    devicesInGroup.removeDevice(devicesInGroup.get(0));
-			  }
-   		      if(OptimizerDebug) {
-		        Logger::getInstance()->log("  Done. (Removing devices from working copy)");
-		      }
-			  break;
-			}
-		  }
+        // see if we've got a fit
+        bool groupFits = true;
+        Set devicesInGroup = _zone.getDevices().getByGroup(g);
+            if(OptimizerDebug) {
+            Logger::getInstance()->log("    Group has " + intToString(devicesInGroup.length()) + " devices");
+          }
+        for(int iDevice = 0; iDevice < devicesInGroup.length(); iDevice++) {
+          if(!_set.contains(devicesInGroup.get(iDevice))) {
+          unsuitableGroups.push_back(&g);
+          groupFits = false;
+                if(OptimizerDebug) {
+                Logger::getInstance()->log("    Original set does _not_ contain device " + devicesInGroup.get(iDevice).getDevice().getDSID().toString());
+              }
+          break;
+          }
+              if(OptimizerDebug) {
+              Logger::getInstance()->log("    Original set contains device " + devicesInGroup.get(iDevice).getDevice().getDSID().toString());
+            }
+        }
+        if(groupFits) {
+              if(OptimizerDebug) {
+              Logger::getInstance()->log("  Found a fit " + intToString(g.getID()));
+            }
+          foundGroup = true;
+          fittingGroups.push_back(&g);
+              if(OptimizerDebug) {
+              Logger::getInstance()->log("  Removing devices from working copy");
+            }
+          while(!devicesInGroup.isEmpty()) {
+          workingCopy.removeDevice(devicesInGroup.get(0));
+            devicesInGroup.removeDevice(devicesInGroup.get(0));
+          }
+              if(OptimizerDebug) {
+              Logger::getInstance()->log("  Done. (Removing devices from working copy)");
+            }
+          break;
+        }
+      }
 
 		  // if no fitting group found
 		  if(!foundGroup) {
-			singleDevices.addDevice(ref);
+  	    singleDevices.addDevice(ref);
 		  }
-		}
-	}
+    }
+  }
     return FittingResultPerModulator(fittingGroups, singleDevices);
   }
 
@@ -218,7 +218,7 @@
       }
     }
     return FittingResultPerModulator(fittingGroups, singleDevices);
-  }
+  } // bestFit
 
   DS485Proxy::DS485Proxy(DSS* _pDSS)
   : Thread("DS485Proxy"),
@@ -510,6 +510,57 @@
     }
   } // isSimAddress
 
+  void DS485Proxy::checkResultCode(const int _resultCode) {
+    if(_resultCode < 0) {
+      std::string message = "Unknown Error";
+      switch(_resultCode) {
+      case kDS485NoIDForIndexFound:
+        message = "No ID for index found";
+        break;
+      case kDS485ZoneNotFound:
+        message = "Zone not found";
+        break;
+      case kDS485IndexOutOfBounds:
+        message = "Index out of bounds";
+        break;
+      case kDS485GroupIDOutOfBounds:
+        message = "Group ID out of bounds";
+        break;
+      case kDS485ZoneCannotBeDeleted:
+        message = "Zone can not be deleted";
+        break;
+      case kDS485OutOfMemory:
+        message = "dSM is out of memory";
+        break;
+      case kDS485RoomAlreadyExists:
+        message = "Room already exists";
+        break;
+      case kDS485InvalidDeviceID:
+        message = "Invalid device id";
+        break;
+      case kDS485CannotRemoveFromStandardGroup:
+        message = "Cannot remove device from standard group";
+        break;
+      case kDS485CannotDeleteStandardGroup:
+        message = "Cannot delete standard group";
+        break;
+      case kDS485DSIDIsNull:
+        message = "DSID is null";
+        break;
+      case kDS485ReservedRoomNumber:
+        message = "Room number is reserved";
+        break;
+      case kDS485DeviceNotFound:
+        message = "Device not found";
+        break;
+      case kDS485GroupNotFound:
+        message = "Group not found";
+        break;
+      }
+      throw DS485ApiError(message);
+    }
+  } // checkResultCode
+
   void DS485Proxy::setValueDevice(const Device& _device, const uint16_t _value, const uint16_t _parameterID, const int _size) {
     DS485CommandFrame frame;
     frame.getHeader().setDestination(_device.getModulatorID());
@@ -546,7 +597,7 @@
 
     std::string name;
     for(int i = 0; i < 6; i++) {
-      char c = static_cast<char>(pd.get<uint8_t>());
+      char c = char(pd.get<uint8_t>());
       if(c != '\0') {
         name += c;
       }
@@ -569,7 +620,7 @@
     boost::shared_ptr<FrameBucketCollector> bucket = sendFrameAndInstallBucket(cmdFrame, FunctionGetTypeRequest);
     bucket->waitForFrames(1000);
 
-    map<int, bool> resultFrom;
+    std::map<int, bool> resultFrom;
 
     std::vector<ModulatorSpec_t> result;
     while(true) {
@@ -600,7 +651,7 @@
     boost::shared_ptr<ReceivedFrame> recFrame = receiveSingleFrame(cmdFrame, FunctionGetTypeRequest);
 
     if(recFrame.get() == NULL) {
-      throw runtime_error("No frame received");
+      throw DS485ApiError("No frame received");
     }
 
     ModulatorSpec_t result = modulatorSpecFromFrame(recFrame->getFrame());
@@ -614,13 +665,13 @@
     cmdFrame.setCommand(CommandRequest);
     cmdFrame.getPayload().add<uint8_t>(FunctionModulatorGetGroupsSize);
     cmdFrame.getPayload().add<uint16_t>(_zoneID);
-    int8_t res = static_cast<int8_t>(receiveSingleResult(cmdFrame, FunctionModulatorGetGroupsSize));
+    int8_t res = int8_t(receiveSingleResult(cmdFrame, FunctionModulatorGetGroupsSize));
     if(res < 0) {
       log("GetGroupCount: Negative group count received '" + intToString(res) +
           " on modulator " + intToString(_modulatorID) +
           " with zone " + intToString(_zoneID));
-      res = 0;
     }
+    checkResultCode(res);
     return res;
   } // getGroupCount
 
@@ -637,12 +688,13 @@
       cmdFrame.getPayload().add<uint16_t>(_zoneID);
       cmdFrame.getPayload().add<uint16_t>(iGroup);
 
-      int8_t res = static_cast<int8_t>(receiveSingleResult(cmdFrame, FunctionZoneGetGroupIdForInd));
+      int8_t res = int8_t(receiveSingleResult(cmdFrame, FunctionZoneGetGroupIdForInd));
       if(res < 0) {
         log("GetGroups: Negative index received '" + intToString(res) + "' for index " + intToString(iGroup));
       } else {
         result.push_back(res);
       }
+      checkResultCode(res);
     }
 
     return result;
@@ -656,13 +708,14 @@
     cmdFrame.getPayload().add<uint16_t>(_zoneID);
     cmdFrame.getPayload().add<uint16_t>(_groupID);
 
-    int16_t res = static_cast<int16_t>(receiveSingleResult16(cmdFrame, FunctionGroupGetDeviceCount));
+    int16_t res = int16_t(receiveSingleResult16(cmdFrame, FunctionGroupGetDeviceCount));
     if(res < 0) {
       log("GetDevicesInGroupCount: Negative count received '" + intToString(res) +
           "' on modulator " + intToString(_modulatorID) +
           " with zoneID " + intToString(_zoneID) + " in group " + intToString(_groupID));
-      res = 0;
     }
+    checkResultCode(res);
+
     return res;
   } // getDevicesInGroupCount
 
@@ -678,12 +731,13 @@
       cmdFrame.getPayload().add<uint16_t>(_zoneID);
       cmdFrame.getPayload().add<uint16_t>(_groupID);
       cmdFrame.getPayload().add<uint16_t>(iDevice);
-      int16_t res = static_cast<int16_t>(receiveSingleResult16(cmdFrame, FunctionGroupGetDevKeyForInd));
+      int16_t res = int16_t(receiveSingleResult16(cmdFrame, FunctionGroupGetDevKeyForInd));
       if(res < 0) {
         log("GetDevicesInGroup: Negative device id received '" + intToString(res) + "' for index " + intToString(iDevice));
       } else {
         result.push_back(res);
       }
+      checkResultCode(res);
     }
 
     return result;
@@ -736,13 +790,14 @@
       cmdFrame.getPayload().add<uint8_t>(FunctionModulatorGetZoneIdForInd);
       cmdFrame.getPayload().add<uint16_t>(iZone);
       log("GetZoneID");
-      int16_t tempResult = static_cast<int16_t>(receiveSingleResult16(cmdFrame, FunctionModulatorGetZoneIdForInd));
+      int16_t tempResult = int16_t(receiveSingleResult16(cmdFrame, FunctionModulatorGetZoneIdForInd));
       if(tempResult < 0) {
         log("GetZones: Negative zone id " + intToString(tempResult) + " received. Modulator: " + intToString(_modulatorID) + " index: " + intToString(iZone), lsError);
       } else {
         result.push_back(tempResult);
       }
-      log("receive ZoneID: " + uintToString((unsigned int)tempResult));
+      checkResultCode(tempResult);
+      log("received ZoneID: " + uintToString((unsigned int)tempResult));
     }
     return result;
   } // getZones
@@ -754,8 +809,9 @@
     cmdFrame.getPayload().add<uint8_t>(FunctionModulatorGetZonesSize);
     log("GetZoneCount");
 
-    // TODO: check result-code
-    uint8_t result = receiveSingleResult(cmdFrame, FunctionModulatorGetZonesSize);
+    int8_t result = int8_t(
+        receiveSingleResult(cmdFrame, FunctionModulatorGetZonesSize));
+    checkResultCode(result);
     return result;
   } // getZoneCount
 
@@ -769,11 +825,11 @@
 
     log(intToString(_modulatorID) + " " + intToString(_zoneID));
 
-    int16_t result = static_cast<int16_t>(receiveSingleResult16(cmdFrame, FunctionModulatorCountDevInZone));
+    int16_t result = int16_t(receiveSingleResult16(cmdFrame, FunctionModulatorCountDevInZone));
     if(result < 0) {
       log("GetDevicesCountInZone: negative count '" + intToString(result) + "'", lsError);
-      result = 0;
     }
+    checkResultCode(result);
 
     return result;
   } // getDevicesCountInZone
@@ -791,7 +847,9 @@
       cmdFrame.getPayload().add<uint16_t>(_zoneID);
       cmdFrame.getPayload().add<uint16_t>(iDevice);
 
-      result.push_back(receiveSingleResult16(cmdFrame, FunctionModulatorDevKeyInZone));
+      uint16_t devID = receiveSingleResult16(cmdFrame, FunctionModulatorDevKeyInZone);
+      checkResultCode(int16_t(devID));
+      result.push_back(devID);
     }
     return result;
   } // getDevicesInZone
@@ -804,8 +862,8 @@
     cmdFrame.getPayload().add<devid_t>(_deviceID);
     cmdFrame.getPayload().add<uint16_t>(_zoneID);
 
-    // TODO: check result-code
-    receiveSingleResult(cmdFrame, FunctionDeviceSetZoneID);
+    int16_t res = int16_t(receiveSingleResult(cmdFrame, FunctionDeviceSetZoneID));
+    checkResultCode(res);
   } // setZoneID
 
   void DS485Proxy::createZone(const int _modulatorID, const int _zoneID) {
@@ -815,8 +873,8 @@
     cmdFrame.getPayload().add<uint8_t>(FunctionModulatorAddZone);
     cmdFrame.getPayload().add<uint16_t>(_zoneID);
 
-    // TODO: check result-code
-    receiveSingleResult(cmdFrame, FunctionModulatorAddZone);
+    int16_t res = int16_t(receiveSingleResult(cmdFrame, FunctionModulatorAddZone));
+    checkResultCode(res);
   } // createZone
 
   void DS485Proxy::removeZone(const int _modulatorID, const int _zoneID) {
@@ -826,8 +884,8 @@
     cmdFrame.getPayload().add<uint8_t>(FunctionModulatorRemoveZone);
     cmdFrame.getPayload().add<uint16_t>(_zoneID);
 
-    // TODO: check result-code
-    receiveSingleResult(cmdFrame, FunctionModulatorAddZone);
+    int16_t res = int16_t(receiveSingleResult(cmdFrame, FunctionModulatorAddZone));
+    checkResultCode(res);
   } // removeZone
 
   dsid_t DS485Proxy::getDSIDOfDevice(const int _modulatorID, const int _deviceID) {
@@ -840,14 +898,15 @@
 
     boost::shared_ptr<ReceivedFrame> recFrame = receiveSingleFrame(cmdFrame, FunctionDeviceGetDSID);
     if(recFrame.get() == NULL) {
-      return NullDSID;
+      throw DS485ApiError("No frame received");
     }
 
     PayloadDissector pd(recFrame->getFrame()->getPayload());
     pd.get<uint8_t>(); // discard the function id
-    pd.get<uint16_t>(); // function result
+    int16_t res = int16_t(pd.get<uint16_t>());
+    checkResultCode(res);
     return pd.get<dsid_t>();
-  }
+  } // getDSIDOfDevice
 
   dsid_t DS485Proxy::getDSIDOfModulator(const int _modulatorID) {
     DS485CommandFrame cmdFrame;
@@ -859,12 +918,11 @@
     boost::shared_ptr<ReceivedFrame> recFrame = receiveSingleFrame(cmdFrame, FunctionModulatorGetDSID);
     if(recFrame.get() == NULL) {
       log("GetDSIDOfModulator: received no result from " + intToString(_modulatorID), lsError);
-      return NullDSID;
+      throw DS485ApiError("No frame received");
     }
 
     PayloadDissector pd(recFrame->getFrame()->getPayload());
     pd.get<uint8_t>(); // discard the function id
-    //pd.get<uint8_t>(); // function result, don't know if that's sent though
     return pd.get<dsid_t>();
   } // getDSIDOfModulator
 
@@ -877,10 +935,11 @@
     cmdFrame.getPayload().add<uint16_t>(_zoneID);
     cmdFrame.getPayload().add<uint16_t>(_groupID);
 
-    int16_t res = static_cast<int16_t>(receiveSingleResult16(cmdFrame, FunctionGroupGetLastCalledScene));
+    int16_t res = int16_t(receiveSingleResult16(cmdFrame, FunctionGroupGetLastCalledScene));
     if(res < 0) {
       log("DS485Proxy::getLastCalledScene: negative result received: " + intToString(res));
     }
+    checkResultCode(res);
     return res;
   } // getLastCalledScene
 
@@ -894,7 +953,7 @@
     boost::shared_ptr<ReceivedFrame> recFrame = receiveSingleFrame(cmdFrame, FunctionModulatorGetPowerConsumption);
     if(recFrame.get() == NULL) {
       log("DS485Proxy::getPowerConsumption: received no results", lsError);
-      return 0;
+      throw DS485ApiError("No frame received");
     }
     if(recFrame->getFrame()->getHeader().getSource() != _modulatorID) {
       log("GetPowerConsumption: received result from wrong source");
@@ -914,7 +973,7 @@
     boost::shared_ptr<ReceivedFrame> recFrame = receiveSingleFrame(cmdFrame, FunctionModulatorGetEnergyMeterValue);
     if(recFrame.get() == NULL) {
       log("DS485Proxy::getEnergyMeterValue: received no results", lsError);
-      return 0;
+      throw DS485ApiError("No frame received");
     }
     PayloadDissector pd(recFrame->getFrame()->getPayload());
     pd.get<uint8_t>(); // discard the function id
@@ -933,7 +992,7 @@
 
     boost::shared_ptr<ReceivedFrame> recFrame = bucket->popFrame();
     if(recFrame.get() == NULL) {
-      return false;
+      throw DS485ApiError("No frame received");
     }
 
     PayloadDissector pd(recFrame->getFrame()->getPayload());
@@ -957,21 +1016,24 @@
       bucket->waitForFrame(10000);
       boost::shared_ptr<ReceivedFrame> recFrame = bucket->popFrame();
       if(recFrame.get() == NULL) {
-        log("dsLinkSend: No packet received");
-        return 0;
+        log("dsLinkSend: No packet received", lsError);
+        throw DS485ApiError("No frame received");
       }
       PayloadDissector pd(recFrame->getFrame()->getPayload());
       pd.get<uint8_t>(); // discard the function id
       pd.get<uint16_t>(); // garbage
       devid_t devAddress = pd.get<uint16_t>(); // device address
       if(devAddress != _devAdr) {
-        log("dSLinkSend: Received answer for wrong device expected: " 
-            + intToString(_devAdr, true) + 
-            " got: " + intToString(devAddress, true));
+        std::string errStr =
+            "dSLinkSend: Received answer for wrong device expected: "+
+            intToString(_devAdr, true) +
+            " got: " + intToString(devAddress, true);
+        log(errStr, lsError);
+        throw DS485ApiError(errStr);
       }
       return pd.get<uint16_t>();
     }
-    log("dsLinkSend: Not waiting for response (waitOnly is set)");
+    log("dsLinkSend: Not waiting for response (writeOnly is set)");
     return 0;
   } // dsLinkSend
 
@@ -1009,7 +1071,7 @@
     if(recFrame.get() != NULL) {
       return recFrame;
     } else {
-      throw runtime_error("received frame is NULL but bucket->isEmpty() returns false");
+      throw std::runtime_error("received frame is NULL but bucket->isEmpty() returns false");
     }
   } // receiveSingleFrame
 
@@ -1062,8 +1124,8 @@
     try {
       m_DS485Controller.setDSID(dsid_t::fromString(getDSS().getPropertySystem().getStringValue(getConfigPropertyBasePath() + "dsid")));
       m_DS485Controller.run();
-    } catch (const runtime_error& _ex) {
-    	log(string("Caught exception while starting DS485Controlle: ") + _ex.what(), lsFatal);
+    } catch (const std::runtime_error& _ex) {
+    	log(string("Caught exception while starting DS485Controller: ") + _ex.what(), lsFatal);
     }
     // call Thread::run()
     run();

Modified: dss/trunk/unix/ds485proxy.h
===================================================================
--- dss/trunk/unix/ds485proxy.h	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/unix/ds485proxy.h	2009-10-05 13:30:07 UTC (rev 8816)
@@ -52,8 +52,6 @@
 #include <boost/ptr_container/ptr_map.hpp>
 #include <boost/shared_ptr.hpp>
 
-using namespace std;
-
 namespace dss {
 
   class DS485Proxy;
@@ -99,7 +97,7 @@
     */
   class FrameBucketCollector : public FrameBucketBase {
   private:
-    deque<boost::shared_ptr<ReceivedFrame> > m_Frames;
+    std::deque<boost::shared_ptr<ReceivedFrame> > m_Frames;
     SyncEvent m_PacketHere;
     Mutex m_FramesMutex;
     bool m_SingleFrame;
@@ -152,6 +150,7 @@
     CommandFrameSharedPtrVector m_IncomingFrames;
 
     ModulatorSpec_t modulatorSpecFromFrame(boost::shared_ptr<DS485CommandFrame> _frame);
+    void checkResultCode(const int _resultCode);
   protected:
     virtual void execute();
     virtual void doStart();
@@ -224,6 +223,6 @@
     DS485Controller& getController() { return m_DS485Controller; }
   }; // DS485Proxy
 
-}
+} // namespace dss
 
 #endif

Modified: dss/trunk/unix/serialcom.cpp
===================================================================
--- dss/trunk/unix/serialcom.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/unix/serialcom.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -55,7 +55,7 @@
     m_Handle = ::open(_serialPort, flags);
     if(m_Handle == -1) {
       perror("serial");
-      throw std::runtime_error(string("could not open port ") + m_PortDevName);
+      throw std::runtime_error(std::string("could not open port ") + m_PortDevName);
     }
 
 
@@ -81,22 +81,22 @@
     }
     if(cfsetispeed(&m_CommSettings, rate) == -1) {
       perror("cfsetispeed");
-      throw std::runtime_error(string("could not set input speed of port ") + m_PortDevName);
+      throw std::runtime_error(std::string("could not set input speed of port ") + m_PortDevName);
     }
     if(cfsetospeed(&m_CommSettings, rate) == -1) {
       perror("cfsetospeed");
-      throw std::runtime_error(string("could not set ouput speed of port ") + m_PortDevName);
+      throw std::runtime_error(std::string("could not set ouput speed of port ") + m_PortDevName);
     }
 
     // flush remaining characters
     if(tcflush(m_Handle, TCIOFLUSH) == -1) {
       perror("tcflush");
-      throw std::runtime_error(string("could not flush port ") + m_PortDevName);
+      throw std::runtime_error(std::string("could not flush port ") + m_PortDevName);
     }
 
     if(tcsetattr(m_Handle, TCSANOW, &m_CommSettings) == -1) {
       perror("tcsetattr");
-      throw std::runtime_error(string("could not set attributes of port ") + m_PortDevName);
+      throw std::runtime_error(std::string("could not set attributes of port ") + m_PortDevName);
     }
     return true;
   } // open
@@ -173,12 +173,12 @@
     return true;
   } // open
 
-  deque<char>& SerialComSim::getWrittenData() {
+  std::deque<char>& SerialComSim::getWrittenData() {
     return m_OutgoingData;
   } // getWrittenData
 
   void SerialComSim::putSimData(const std::string& _data) {
-    for(string::const_iterator iChar = _data.begin(), e = _data.end();
+    for(std::string::const_iterator iChar = _data.begin(), e = _data.end();
         iChar != e; ++iChar)
     {
       m_IncomingData.push_back(*iChar);

Modified: dss/trunk/unix/serialcom.h
===================================================================
--- dss/trunk/unix/serialcom.h	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/unix/serialcom.h	2009-10-05 13:30:07 UTC (rev 8816)
@@ -29,8 +29,6 @@
 
 #include "../core/mutex.h"
 
-using namespace std;
-
 namespace dss {
 
   class SerialComBase {

Modified: dss/trunk/unix/thread.cpp
===================================================================
--- dss/trunk/unix/thread.cpp	2009-10-05 13:22:00 UTC (rev 8815)
+++ dss/trunk/unix/thread.cpp	2009-10-05 13:30:07 UTC (rev 8816)
@@ -29,8 +29,6 @@
 #include <signal.h>
 #endif
 
-using namespace std;
-
 namespace dss {
 
 #ifndef WIN32
@@ -44,7 +42,7 @@
 	thObj->execute();
 
   if(thObj->getThreadIdentifier() != NULL) {
-    Logger::getInstance()->log(string("Destroying thread: ") + thObj->getThreadIdentifier());
+    Logger::getInstance()->log(std::string("Destroying thread: ") + thObj->getThreadIdentifier());
   } else {
     Logger::getInstance()->log("Destroying thread: (no name)");
   }
@@ -79,7 +77,7 @@
   assert( !m_Running );
   m_Running = true;
   if( m_Name != NULL ) {
-    Logger::getInstance()->log(string("creating thread for \"") + m_Name + "\"");
+    Logger::getInstance()->log(std::string("creating thread for \"") + m_Name + "\"");
   }
 #ifndef WIN32
   pthread_create( &m_ThreadHandle, NULL, ThreadStarterHelperFunc, this );



More information about the dss-commits mailing list