File tree Expand file tree Collapse file tree 3 files changed +12
-22
lines changed
stream_simulator/controllers Expand file tree Collapse file tree 3 files changed +12
-22
lines changed Original file line number Diff line number Diff line change 55#!/usr/bin/python
66# -*- coding: utf-8 -*-
77
8- import statistics
98import random
109
1110from stream_simulator .base_classes import BasicSensor
@@ -89,14 +88,9 @@ def get_simulation_value(self):
8988 for a in affections :
9089 vs .append ((1 - affections [a ]['distance' ] / affections [a ]['range' ]) * \
9190 affections [a ]['info' ]['humidity' ])
92- affections = statistics . mean (vs )
91+ affections = max (vs )
9392
94- if ambient > affections :
95- ambient += affections * 0.1
96- else :
97- ambient = affections - (affections - ambient ) * 0.1
98-
99- final_value = ambient
93+ final_value = ambient if affections < ambient else affections
10094 if self .dynamic_value is None :
10195 self .dynamic_value = final_value
10296 else :
Original file line number Diff line number Diff line change 55#!/usr/bin/python
66# -*- coding: utf-8 -*-
77
8- import statistics
98import random
109from stream_simulator .base_classes import BasicSensor
1110
@@ -98,17 +97,18 @@ def get_simulation_value(self):
9897 if affections is None :
9998 return amb
10099
100+ print (affections )
101101 for a in affections :
102102 r = (1 - affections [a ]['distance' ] / affections [a ]['range' ]) * \
103103 affections [a ]['info' ]['temperature' ]
104104 temps .append (r )
105105
106106 mms = 0
107- temps . append ( amb )
107+ print ( temps )
108108 if len (temps ) > 0 :
109- mms = statistics . mean (temps )
109+ mms = max (temps )
110110
111- final_value = mms
111+ final_value = mms if mms > amb else amb
112112 if self .dynamic_value is None :
113113 self .dynamic_value = final_value
114114 else :
Original file line number Diff line number Diff line change 99import logging
1010import threading
1111import random
12- import statistics
1312
1413from stream_simulator .base_classes import BaseThing
1514
@@ -176,10 +175,10 @@ def sensor_read(self):
176175 r = (1 - tem_aff [a ]['distance' ] / tem_aff [a ]['range' ]) * \
177176 tem_aff [a ]['info' ]['temperature' ]
178177 temps .append (r )
179- temps .append (amb )
180- final_temp = amb
178+
181179 if len (temps ) != 0 :
182- final_temp = statistics .mean (temps )
180+ final_temp = max (temps )
181+ final_temp = amb if amb > final_temp else final_temp
183182 if self .dynamic_value ['temperature' ] is None :
184183 self .dynamic_value ['temperature' ] = final_temp
185184 else :
@@ -192,17 +191,14 @@ def sensor_read(self):
192191 if len (hum_aff ) == 0 :
193192 val ["humidity" ] = ambient + random .uniform (- 0.5 , 0.5 )
194193 vs = []
194+ affections = 0
195195 for a in hum_aff :
196196 vs .append ((1 - hum_aff [a ]['distance' ] / hum_aff [a ]['range' ]) * \
197197 hum_aff [a ]['info' ]['humidity' ])
198198 if len (vs ) > 0 :
199- affections = statistics .mean (vs )
200- if ambient > affections :
201- ambient += affections * 0.1
202- else :
203- ambient = affections - (affections - ambient ) * 0.1
199+ affections = max (vs )
204200
205- final_hum = ambient
201+ final_hum = ambient if ambient > affections else affections
206202 if self .dynamic_value ['humidity' ] is None :
207203 self .dynamic_value ['humidity' ] = final_hum
208204 else :
You can’t perform that action at this time.
0 commit comments