[dss-commits] r8889 - dss/trunk/core/sim

dss-commits at forum.digitalstrom.org dss-commits at forum.digitalstrom.org
Thu Nov 5 18:24:10 CET 2009


Author: rkoehler
Date: 2009-11-05 18:24:10 +0100 (Thu, 05 Nov 2009)
New Revision: 8889

Modified:
   dss/trunk/core/sim/dsidsim.cpp
Log:
Fixes Redmine #208 and #207

adding interpretation for 
 * SimpleConsumption   : simple Consumption randomizing. the Parameter serves as Basevalue for that calculation, there are automaticly added some jittering
 * MinConsumption      : minimal Consumption (Off-Value) of a simulated Device - standby consumption
 * MaxConsumption      : maximal Consumption (On-Value) of a simulated Device
 * JitterConsumption   : Jittering Consumption, which added on every Consumption Value. the Parameter serves as Max jitting Value, min jitting Value is 0

all simulated Consumption are added (with the exception of Min and Max Value) when the consumption is been queried

Example definition in sim.xml:

      <device dsid="11" busid="11" type="standard.simple">
	<parameter name="MaxConsumption">20000</parameter>
	<parameter name="MinConsumption">3000</parameter>
	<parameter name="JitterConsumption">2000</parameter>
      </device>


Modified: dss/trunk/core/sim/dsidsim.cpp
===================================================================
--- dss/trunk/core/sim/dsidsim.cpp	2009-11-05 15:13:29 UTC (rev 8888)
+++ dss/trunk/core/sim/dsidsim.cpp	2009-11-05 17:24:10 UTC (rev 8889)
@@ -28,7 +28,7 @@
   : DSIDInterface(_simulator, _dsid, _shortAddress),
     m_Enabled(true),
     m_CurrentValue(0),
-    m_SimpleConsumption(25 * 1000)
+    m_SimpleConsumption(0)
   {
     m_ValuesForScene.resize(255);
     m_ValuesForScene[SceneOff] = 0;
@@ -43,7 +43,26 @@
   } // ctor
 
   int DSIDSim::getConsumption() {
-    return (int) 0; //((m_CurrentValue / 255.0) * m_SimpleConsumption) + (rand() % 100);
+	int _simpleConsumption=0;
+	int _minConsumption=0;
+	int _maxConsumption=0;
+	int _jitterConsumption=0;
+	// simple consumption calculation: just provide an max value, interpolated by currentvalue and some jitter
+	// only for backward compatiliby
+	if (getConfigParameter("SimpleConsumption")!="")
+		_simpleConsumption= (int) ((m_CurrentValue / 255.0) * strToInt(getConfigParameter("SimpleConsumption"))) + (rand() % 100);
+	  
+	if (getConfigParameter("MinConsumption")!="")
+		_minConsumption=strToInt(getConfigParameter("MinConsumption"));
+		
+	if (getConfigParameter("MaxConsumption")!="")
+		_maxConsumption= (int) ((m_CurrentValue / 255.0) * (strToInt(getConfigParameter("MaxConsumption")) - _minConsumption) );
+
+	if (getConfigParameter("JitterConsumption")!="")
+		_jitterConsumption= (int) (rand() % strToInt(getConfigParameter("JitterConsumption")));
+	_jitterConsumption =_jitterConsumption - (_jitterConsumption/2);
+	
+    return (int) _simpleConsumption + _minConsumption + _maxConsumption + _jitterConsumption; //((m_CurrentValue / 255.0) * m_SimpleConsumption) + (rand() % 100);
   }
 
   void DSIDSim::callScene(const int _sceneNr) {



More information about the dss-commits mailing list