[dss-commits] digitalSTROM Server branch, master, updated. b08a7e7698999e286bb3c03f7d5d17c901909be6

git version control dss-commits at forum.digitalstrom.org
Wed Jan 20 17:55:59 CET 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".

The branch, master has been updated
       via  b08a7e7698999e286bb3c03f7d5d17c901909be6 (commit)
       via  0b802769a782a5cdc01dcfabb03b349166aff52b (commit)
      from  eae12c4bf95936310736828618b30ae835113f27 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b08a7e7698999e286bb3c03f7d5d17c901909be6
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Wed Jan 20 17:53:48 2010 +0100

    Write last zone/modulator to apartment.xml
    
    Closes #124

commit 0b802769a782a5cdc01dcfabb03b349166aff52b
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date:   Wed Jan 20 16:32:00 2010 +0100

    Store the last known zone id on the device
    
    References #124

-----------------------------------------------------------------------

Changes:
diff --git a/core/model/device.cpp b/core/model/device.cpp
index f271646..c297a1e 100644
--- a/core/model/device.cpp
+++ b/core/model/device.cpp
@@ -43,6 +43,7 @@ namespace dss {
     m_DSID(_dsid),
     m_ShortAddress(ShortAddressStaleDevice),
     m_ZoneID(0),
+    m_LastKnownZoneID(0),
     m_DSMeterID(-1),
     m_LastKnownMeterDSID(NullDSID),
     m_FunctionID(0),
@@ -159,6 +160,10 @@ namespace dss {
     return m_DSMeterID;
   } // getDSMeterID
 
+  void Device::setLastKnownDSMeterDSID(const dsid_t& _value) {
+    m_LastKnownMeterDSID = _value;
+  } // setLastKnownDSMeterDSID
+
   const dsid_t& Device::getLastKnownDSMeterDSID() const {
     return m_LastKnownMeterDSID;
   } // getLastKnownDSMeterDSID
@@ -174,6 +179,9 @@ namespace dss {
 
   void Device::setZoneID(const int _value) {
     if(_value != m_ZoneID) {
+      if(_value != 0) {
+        m_LastKnownZoneID = _value;
+      }
       m_ZoneID = _value;
       if((m_pPropertyNode != NULL) && (m_pApartment->getPropertyNode() != NULL)) {
         std::string basePath = "zones/zone" + intToString(m_ZoneID);
@@ -200,6 +208,14 @@ namespace dss {
     }
   } // setZoneID
 
+  int Device::getLastKnownZoneID() const {
+    return m_LastKnownZoneID;
+  } // getLastKnownZoneID
+
+  void Device::setLastKnownZoneID(const int _value) {
+    m_LastKnownZoneID = _value;
+  } // setLastKnownZoneID
+
   int Device:: getGroupIdByIndex(const int _index) const {
     return m_Groups[_index];
   } // getGroupIdByIndex
diff --git a/core/model/device.h b/core/model/device.h
index 5525a94..098f8e6 100644
--- a/core/model/device.h
+++ b/core/model/device.h
@@ -48,6 +48,7 @@ namespace dss {
     dsid_t m_DSID;
     devid_t m_ShortAddress;
     int m_ZoneID;
+    int m_LastKnownZoneID;
     int m_DSMeterID;
     dsid_t m_LastKnownMeterDSID;
     std::bitset<63> m_GroupBitmask;
@@ -141,12 +142,15 @@ namespace dss {
     /** Returns the id of the dsMeter the device is connected to */
     int getDSMeterID() const;
     const dsid_t& getLastKnownDSMeterDSID() const;
+    void setLastKnownDSMeterDSID(const dsid_t& _value);
     void setDSMeter(const DSMeter& _dsMeter);
 
     /** Returns the zone ID the device resides in. */
     int getZoneID() const;
     /** Sets the zone ID of the device. */
     void setZoneID(const int _value);
+    int getLastKnownZoneID() const;
+    void setLastKnownZoneID(const int _value);
     /** Returns the apartment the device resides in. */
     Apartment& getApartment() const;
 
diff --git a/core/model/modelpersistence.cpp b/core/model/modelpersistence.cpp
index cecdea4..c58c229 100644
--- a/core/model/modelpersistence.cpp
+++ b/core/model/modelpersistence.cpp
@@ -132,11 +132,23 @@ namespace dss {
             firstSeen = DateTime(dateFromISOString(elem->getAttribute("firstSeen").c_str()));
           }
 
+          dsid_t lastKnownDsMeter = NullDSID;
+          if(elem->hasAttribute("lastKnownDSMeter")) {
+            lastKnownDsMeter = dsid_t::fromString(elem->getAttribute("lastKnownDSMeter"));
+          }
+
+          int lastKnownZoneID = 0;
+          if(elem->hasAttribute("lastKnownZoneID")) {
+            lastKnownZoneID = strToIntDef("lastKnownZoneID", 0);
+          }
+
           Device& newDevice = m_Apartment.allocateDevice(dsid);
           if(!name.empty()) {
             newDevice.setName(name);
           }
           newDevice.setFirstSeen(firstSeen);
+          newDevice.setLastKnownDSMeterDSID(lastKnownDsMeter);
+          newDevice.setLastKnownZoneID(lastKnownZoneID);
           Element* propertiesElem = elem->getChildElement("properties");
           if(propertiesElem != NULL) {
             newDevice.publishToPropertyTree();
@@ -202,6 +214,12 @@ namespace dss {
       pDeviceNode->appendChild(pNameNode);
     }
     pDeviceNode->setAttribute("firstSeen", _pDevice->getFirstSeen());
+    if(_pDevice->getLastKnownDSMeterDSID() != NullDSID) {
+      pDeviceNode->setAttribute("lastKnownDSMeter", _pDevice->getLastKnownDSMeterDSID().toString());
+    }
+    if(_pDevice->getLastKnownZoneID() != 0) {
+      pDeviceNode->setAttribute("lastKnownZoneID", intToString(_pDevice->getLastKnownZoneID()));
+    }
     if(_pDevice->getPropertyNode() != NULL) {
       AutoPtr<Element> pPropertiesNode = _pDocument->createElement("properties");
       pDeviceNode->appendChild(pPropertiesNode);


hooks/post-receive
-- 
digitalSTROM Server


More information about the dss-commits mailing list