|
|
@@ -1,6 +1,5 @@
|
|
|
#!/usr/bin/env python
|
|
|
# -*- coding: utf-8 -*-
|
|
|
-
|
|
|
from Stats.DeviceStats import DeviceStats as _DeviceStats
|
|
|
from Stats.HouseStats import HouseStats as _HouseStats
|
|
|
from Stats.MicLevel import MicLevel as _MicLevel
|
|
|
@@ -20,7 +19,7 @@ from lib.RepeatTimer import RepeatTimer
|
|
|
import lib.MoonPhase as mp
|
|
|
import random
|
|
|
|
|
|
-class Stats(object):
|
|
|
+class Stats:
|
|
|
|
|
|
instance = None
|
|
|
@staticmethod
|
|
|
@@ -29,18 +28,16 @@ class Stats(object):
|
|
|
Stats.instance = Stats()
|
|
|
return Stats.instance
|
|
|
|
|
|
- deviceStats = _DeviceStats()
|
|
|
- houseStats = _HouseStats()
|
|
|
- micLevel = _MicLevel()
|
|
|
- outdoorStats = _OutdoorStats()
|
|
|
- ownerStats = _OwnerStats()
|
|
|
- talkingStats = _TalkingStats()
|
|
|
- adminStats = _AdminStats()
|
|
|
-
|
|
|
- weather = OpenWeatherMap.OpenWeatherMap()
|
|
|
+ #deviceStats:_DeviceStats = _DeviceStats()
|
|
|
+ #houseStats:_HouseStats = _HouseStats()
|
|
|
+ #micLevel:_MicLevel = _MicLevel()
|
|
|
+ #outdoorStats = _OutdoorStats()
|
|
|
+ #ownerStats = _OwnerStats()
|
|
|
+ #talkingStats = _TalkingStats()
|
|
|
+ #adminStats = _AdminStats()
|
|
|
|
|
|
|
|
|
- UPDATE_EMOTION_DELAY_MINUTE = 1.66
|
|
|
+ UPDATE_EMOTION_DELAY_MINUTE = 0.2
|
|
|
UPDATE_HOMEMATIC_DELAY_MINUTE = 1
|
|
|
UPDATE_DATETIME_DELAY_MINUTE = 10
|
|
|
UPDATE_OUTDOOR_DELAY_MINUTE = 2.1
|
|
|
@@ -52,56 +49,30 @@ class Stats(object):
|
|
|
Thread_OutDoor = None
|
|
|
Thread_Mic = None
|
|
|
lastUpdate = 0.0
|
|
|
- homematic = None
|
|
|
|
|
|
- moonPhase = None
|
|
|
Mic = MicCapture.MicCapture()
|
|
|
|
|
|
def __init__(self):
|
|
|
print("Init Stats")
|
|
|
-
|
|
|
+
|
|
|
print("- Read Config")
|
|
|
try:
|
|
|
config = configparser.ConfigParser()
|
|
|
- config.read('config.ini')
|
|
|
+ config.read('config/stats.ini')
|
|
|
except:
|
|
|
print("Failed to get Config")
|
|
|
config = dict
|
|
|
- if "Homematic" not in config:
|
|
|
- config.add_section("Homematic")
|
|
|
- config["Homematic"]["url"]=""
|
|
|
- config["Homematic"]["SwitchList"]=""
|
|
|
- config["Homematic"]["LightList"]=""
|
|
|
- config["Homematic"]["TermoList"]=""
|
|
|
- config["Homematic"]["DoorList"]=""
|
|
|
- config["Homematic"]["WindowList"]=""
|
|
|
-
|
|
|
- self.moonPhase = mp.phase(time=datetime.datetime.now())
|
|
|
-
|
|
|
- self.deviceStats.lastUpdate = time.time()
|
|
|
-
|
|
|
- print("- Init Homematic")
|
|
|
- if config["Homematic"]["url"]!="":
|
|
|
- self.homematic = Homematic(config["Homematic"]["url"], {
|
|
|
- "SwitchList":config["Homematic"]["SwitchList"],
|
|
|
- "LightList":config["Homematic"]["LightList"],
|
|
|
- "TermoList":config["Homematic"]["TermoList"],
|
|
|
- "DoorList":config["Homematic"]["DoorList"],
|
|
|
- "WindowList":config["Homematic"]["WindowList"]
|
|
|
- })
|
|
|
-
|
|
|
- if self.homematic.bConnected:
|
|
|
- print("- - Homematic conected")
|
|
|
- print("- - Update HomeMatic")
|
|
|
- self.__UpdateHomematic()
|
|
|
- print("- - Start Homematic-Timer")
|
|
|
- self.Thread_Homematic = RepeatTimer(self.UPDATE_HOMEMATIC_DELAY_MINUTE*60, self.__UpdateHomematic)
|
|
|
- self.Thread_Homematic.start()
|
|
|
- else:
|
|
|
- print("- - No homatic")
|
|
|
- print("- - HomeMatic Done")
|
|
|
- else:
|
|
|
- print("- - Homematic failed")
|
|
|
+
|
|
|
+ self._weather = OpenWeatherMap.OpenWeatherMap()
|
|
|
+ self._deviceStats:_DeviceStats = _DeviceStats()
|
|
|
+ self._houseStats:_HouseStats = _HouseStats()
|
|
|
+ self._micLevel:_MicLevel = _MicLevel()
|
|
|
+ self._outdoorStats = _OutdoorStats()
|
|
|
+ self._ownerStats = _OwnerStats()
|
|
|
+ self._talkingStats = _TalkingStats()
|
|
|
+ self._adminStats = _AdminStats()
|
|
|
+ self._outdoorStats.MoonPhase = mp.phase(time=datetime.datetime.now())
|
|
|
+ self._deviceStats.lastUpdate = time.time()
|
|
|
|
|
|
self.__UpdateDateTime()
|
|
|
self.Thread_DateTime = RepeatTimer(self.UPDATE_DATETIME_DELAY_MINUTE*60, self.__UpdateDateTime)
|
|
|
@@ -120,85 +91,112 @@ class Stats(object):
|
|
|
self.Thread_Emotion.start()
|
|
|
|
|
|
print("- - Init Stats done")
|
|
|
- return super().__init__()
|
|
|
+
|
|
|
+ @property
|
|
|
+ def HouseStats(self) -> _HouseStats:
|
|
|
+ return self._houseStats
|
|
|
+
|
|
|
+ @property
|
|
|
+ def DeviceStats(self) -> _DeviceStats:
|
|
|
+ return self._deviceStats
|
|
|
+
|
|
|
+ @property
|
|
|
+ def OutdoorStats(self) -> _OutdoorStats:
|
|
|
+ return self._outdoorStats
|
|
|
+
|
|
|
+ @property
|
|
|
+ def OwnerStats(self) -> _OwnerStats:
|
|
|
+ return self._ownerStats
|
|
|
+
|
|
|
+ @property
|
|
|
+ def TalkingStats(self) -> _TalkingStats:
|
|
|
+ return self._talkingStats
|
|
|
+
|
|
|
+ @property
|
|
|
+ def AdminStats(self) -> _AdminStats:
|
|
|
+ return self._adminStats
|
|
|
+
|
|
|
+ @property
|
|
|
+ def WeatherInfo(self) -> OpenWeatherMap.OpenWeatherMap:
|
|
|
+ return self._weather
|
|
|
|
|
|
def __UpdateMic(self):
|
|
|
self.Mic.Update()
|
|
|
self.micLevel.Volume_Min = self.Mic.LastResult["min"]
|
|
|
self.micLevel.Volume_Max = self.Mic.LastResult["max"]
|
|
|
self.micLevel.Volume_Avg = self.Mic.LastResult["avg"]
|
|
|
- print(self.micLevel.getJson())
|
|
|
+ #print(self.micLevel.getJson())
|
|
|
|
|
|
def __UpdateDateTime(self):
|
|
|
- self.moonPhase = mp.phase(time=datetime.datetime.now())
|
|
|
+ self._outdoorStats.MoonPhase = mp.phase(time=datetime.datetime.now())
|
|
|
|
|
|
def __UpdateOutdoor(self):
|
|
|
- self.weather.Update()
|
|
|
- self.outdoorStats.bRaining = self.weather.CurrentLocation.Rain.PerHour>0.1
|
|
|
- self.outdoorStats.bSnowing = self.weather.CurrentLocation.Rain.PerHour>0.1 and self.weather.CurrentLocation.Main.TempMax<1
|
|
|
- self.outdoorStats.bWindy = self.weather.CurrentLocation.Wind.Speed>20
|
|
|
- self.outdoorStats.Clouds = self.weather.CurrentLocation.Clouds.All
|
|
|
- self.outdoorStats.Humidity = self.weather.CurrentLocation.Main.Humidity
|
|
|
- self.outdoorStats.Pressure = self.weather.CurrentLocation.Main.Pressure
|
|
|
- self.outdoorStats.Temperature = self.weather.CurrentLocation.Main.Temperature
|
|
|
- self.outdoorStats.WindDegree = self.weather.CurrentLocation.Wind.Deg
|
|
|
- self.outdoorStats.WindSpeed = self.weather.CurrentLocation.Wind.Speed
|
|
|
-
|
|
|
- def __UpdateHomematic(self):
|
|
|
- print("Update Homematic")
|
|
|
- self.homematic.updateDevices()
|
|
|
- # Check open/closed windows
|
|
|
- self.houseStats.bAllWindowOpen = True
|
|
|
- self.houseStats.bAllWindowClosed = True
|
|
|
- for ise in self.homematic.favWindowList:
|
|
|
- if self.homematic.windowList[ise]["value"]==False:
|
|
|
- self.houseStats.bAllWindowOpen = False
|
|
|
- else:
|
|
|
- self.houseStats.bAllWindowClosed = False
|
|
|
- # Check open/closed doors
|
|
|
- self.houseStats.bAllDoorOpen = True
|
|
|
- self.houseStats.bAllDoorClosed = True
|
|
|
- for ise in self.homematic.favDoorList:
|
|
|
- if self.homematic.doorList[ise]["value"]==False:
|
|
|
- self.houseStats.bAllDoorOpen = False
|
|
|
- else:
|
|
|
- self.houseStats.bAllDoorClosed = False
|
|
|
- # Check all Lights
|
|
|
- self.houseStats.bAllLightOn = True
|
|
|
- self.houseStats.bAllLightOff = True
|
|
|
- for ise in self.homematic.favLightList:
|
|
|
- if self.homematic.lightList[ise]["value"]==False:
|
|
|
- self.houseStats.bAllLightOn = False
|
|
|
- else:
|
|
|
- self.houseStats.bAllLightOff = False
|
|
|
- # Termo
|
|
|
- temp_min=40.0
|
|
|
- temp_max=0.0
|
|
|
- temp_avg_add=0.0
|
|
|
- temp_avg_count=0
|
|
|
- for ise in self.homematic.favThermoList:
|
|
|
- if self.homematic.thermoList[ise]["value"] > temp_max:
|
|
|
- temp_max = self.homematic.thermoList[ise]["value"]
|
|
|
- if self.homematic.thermoList[ise]["value"] < temp_min:
|
|
|
- temp_min = self.homematic.thermoList[ise]["value"]
|
|
|
- temp_avg_add += self.homematic.thermoList[ise]["value"]
|
|
|
- temp_avg_count += 1
|
|
|
- self.houseStats.temp_avg = temp_avg_add / temp_avg_count
|
|
|
- self.houseStats.temp_coldest = temp_min
|
|
|
- self.houseStats.temp_hottest = temp_max
|
|
|
+ self._weather.Update()
|
|
|
+ self._outdoorStats.bRaining = self._weather.CurrentLocation.Rain.PerHour>0.1
|
|
|
+ self._outdoorStats.bSnowing = self._weather.CurrentLocation.Rain.PerHour>0.1 and self.weather.CurrentLocation.Main.TempMax<1
|
|
|
+ self._outdoorStats.bWindy = self._weather.CurrentLocation.Wind.Speed>20
|
|
|
+ self._outdoorStats.Clouds = self._weather.CurrentLocation.Clouds.All
|
|
|
+ self._outdoorStats.Humidity = self._weather.CurrentLocation.Main.Humidity
|
|
|
+ self._outdoorStats.Pressure = self._weather.CurrentLocation.Main.Pressure
|
|
|
+ self._outdoorStats.Temperature = self._weather.CurrentLocation.Main.Temperature
|
|
|
+ self._outdoorStats.WindDegree = self._weather.CurrentLocation.Wind.Deg
|
|
|
+ self._outdoorStats.WindSpeed = self._weather.CurrentLocation.Wind.Speed
|
|
|
+
|
|
|
+ #def __UpdateHomematic(self):
|
|
|
+ # print("Update Homematic")
|
|
|
+ # self.homematic.updateDevices()
|
|
|
+ # # Check open/closed windows
|
|
|
+ # self.houseStats.bAllWindowOpen = True
|
|
|
+ # self.houseStats.bAllWindowClosed = True
|
|
|
+ # for ise in self.homematic.favWindowList:
|
|
|
+ # if self.homematic.windowList[ise]["value"]==False:
|
|
|
+ # self.houseStats.bAllWindowOpen = False
|
|
|
+ # else:
|
|
|
+ # self.houseStats.bAllWindowClosed = False
|
|
|
+ # # Check open/closed doors
|
|
|
+ # self.houseStats.bAllDoorOpen = True
|
|
|
+ # self.houseStats.bAllDoorClosed = True
|
|
|
+ # for ise in self.homematic.favDoorList:
|
|
|
+ # if self.homematic.doorList[ise]["value"]==False:
|
|
|
+ # self.houseStats.bAllDoorOpen = False
|
|
|
+ # else:
|
|
|
+ # self.houseStats.bAllDoorClosed = False
|
|
|
+ # # Check all Lights
|
|
|
+ # self.houseStats.bAllLightOn = True
|
|
|
+ # self.houseStats.bAllLightOff = True
|
|
|
+ # for ise in self.homematic.favLightList:
|
|
|
+ # if self.homematic.lightList[ise]["value"]==False:
|
|
|
+ # self.houseStats.bAllLightOn = False
|
|
|
+ # else:
|
|
|
+ # self.houseStats.bAllLightOff = False
|
|
|
+ # # Termo
|
|
|
+ # temp_min=40.0
|
|
|
+ # temp_max=0.0
|
|
|
+ # temp_avg_add=0.0
|
|
|
+ # temp_avg_count=0
|
|
|
+ # for ise in self.homematic.favThermoList:
|
|
|
+ # if self.homematic.thermoList[ise]["value"] > temp_max:
|
|
|
+ # temp_max = self.homematic.thermoList[ise]["value"]
|
|
|
+ # if self.homematic.thermoList[ise]["value"] < temp_min:
|
|
|
+ # temp_min = self.homematic.thermoList[ise]["value"]
|
|
|
+ # temp_avg_add += self.homematic.thermoList[ise]["value"]
|
|
|
+ # temp_avg_count += 1
|
|
|
+ # self.houseStats.temp_avg = temp_avg_add / temp_avg_count
|
|
|
+ # self.houseStats.temp_coldest = temp_min
|
|
|
+ # self.houseStats.temp_hottest = temp_max
|
|
|
|
|
|
def __UpdateEmotion(self):
|
|
|
print("Update Emotion")
|
|
|
newTime = int(time.time())
|
|
|
- updateDur = float(self.deviceStats.MAX_VALUE * ((newTime - self.deviceStats.lastUpdate) / 3600)) # Per Thausend
|
|
|
- self.deviceStats.lastUpdate = newTime
|
|
|
+ updateDur = float(self._deviceStats.MAX_VALUE * ((newTime - self._deviceStats.lastUpdate) / 3600)) # Per Thausend
|
|
|
+ self._deviceStats.lastUpdate = newTime
|
|
|
#curHour = ((newTime % 86400) / 3600)
|
|
|
curHour = datetime.datetime.now().hour
|
|
|
moonImpact = 1.0
|
|
|
|
|
|
# Define MoonPhase Impact
|
|
|
- if self.moonPhase["phase"]==4:
|
|
|
- if self.outdoorStats.Clouds>80:
|
|
|
+ if self._outdoorStats.MoonPhase["phase"]==4:
|
|
|
+ if self._outdoorStats.Clouds>80:
|
|
|
if curHour>23 or curHour<6:
|
|
|
moonImpact += random.randint(0,9)/60
|
|
|
else:
|
|
|
@@ -212,194 +210,195 @@ class Stats(object):
|
|
|
# Calculate impact for stats calculation
|
|
|
impact = moonImpact
|
|
|
|
|
|
- if time.time() - self.deviceStats.lastTimeToLoud > 600:
|
|
|
- self.deviceStats.toLoud += float(updateDur / 8) * impact
|
|
|
- if time.time() - self.deviceStats.lastTimeToQuiet > 600:
|
|
|
- self.deviceStats.toQuiet += float(updateDur / 8) * impact
|
|
|
+ if time.time() - self._deviceStats.lastTimeToLoud > 600:
|
|
|
+ self._deviceStats.toLoud += float(updateDur / 8) * impact
|
|
|
+ if time.time() - self._deviceStats.lastTimeToQuiet > 600:
|
|
|
+ self._deviceStats.toQuiet += float(updateDur / 8) * impact
|
|
|
|
|
|
# Home depended
|
|
|
- if self.houseStats.temp_avg > 25.0 or self.houseStats.temp_hottest > 28.0:
|
|
|
- self.deviceStats.hot += float(updateDur / 12) * impact
|
|
|
+ if self._houseStats.Temperature.avg > 25.0 or self._houseStats.Temperature.hottest > 28.0:
|
|
|
+ self._deviceStats.hot += float(updateDur / 12) * impact
|
|
|
else:
|
|
|
- self.deviceStats.hot -= float(updateDur / 38) * impact
|
|
|
- if self.houseStats.temp_avg < 17.0 or self.houseStats.temp_hottest < 15.0:
|
|
|
- self.deviceStats.freezy += float(updateDur / 12) * impact
|
|
|
+ self._deviceStats.hot -= float(updateDur / 38) * impact
|
|
|
+ if self._houseStats.Temperature.avg < 17.0 or self._houseStats.Temperature.coldest < 15.0:
|
|
|
+ self._deviceStats.freezy += float(updateDur / 12) * impact
|
|
|
else:
|
|
|
- self.deviceStats.freezy -= float(updateDur / 38) * impact
|
|
|
+ self._deviceStats.freezy -= float(updateDur / 38) * impact
|
|
|
|
|
|
- if self.deviceStats.hot <200 and self.deviceStats.freezy < 200:
|
|
|
- self.deviceStats.temperate -= float(updateDur / 12) * impact
|
|
|
+ if self._deviceStats.hot <200 and self._deviceStats.freezy < 200:
|
|
|
+ self._deviceStats.temperate -= float(updateDur / 12) * impact
|
|
|
else:
|
|
|
- self.deviceStats.temperate += float(updateDur / 48) * impact
|
|
|
+ self._deviceStats.temperate += float(updateDur / 48) * impact
|
|
|
|
|
|
- self.deviceStats.toLoud -= (float)(updateDur / 48)
|
|
|
- if self.houseStats.bAtHome == True and self.houseStats.AtSleep == False:
|
|
|
- self.deviceStats.toQuiet -= (float)(updateDur / 48)
|
|
|
+ self._deviceStats.toLoud -= (float)(updateDur / 48)
|
|
|
+ if self._ownerStats.bIsAtHome == True and self._ownerStats.bSleeping == False:
|
|
|
+ self._deviceStats.toQuiet -= (float)(updateDur / 48)
|
|
|
|
|
|
# substractive
|
|
|
- self.deviceStats.angry -= (float)(updateDur / 48) * impact # 48std to 1000
|
|
|
- self.deviceStats.annoyed -= (float)(updateDur / 50)
|
|
|
- self.deviceStats.aroused -= (float)(updateDur / 72) * impact
|
|
|
- if self.houseStats.bSleeping:
|
|
|
- self.deviceStats.exhausted -= (float)(updateDur / 18)
|
|
|
+ self._deviceStats.angry -= (float)(updateDur / 48) * impact # 48std to 1000
|
|
|
+ self._deviceStats.annoyed -= (float)(updateDur / 50)
|
|
|
+ self._deviceStats.aroused -= (float)(updateDur / 72) * impact
|
|
|
+ if self._ownerStats.bSleeping:
|
|
|
+ self._deviceStats.exhausted -= (float)(updateDur / 18)
|
|
|
else:
|
|
|
- self.deviceStats.exhausted -= (float)(updateDur / 48)
|
|
|
- self.deviceStats.humanity -= (float)(updateDur / 48)
|
|
|
- self.deviceStats.naiv -= (float)(updateDur / 48)
|
|
|
- self.deviceStats.shy -= (float)(updateDur / 500)
|
|
|
- self.deviceStats.soziality -= (float)(updateDur / 48) * impact
|
|
|
- self.deviceStats.usefull -= (float)(updateDur / 48)
|
|
|
+ self._deviceStats.exhausted -= (float)(updateDur / 48)
|
|
|
+ self._deviceStats.humanity -= (float)(updateDur / 48)
|
|
|
+ self._deviceStats.naiv -= (float)(updateDur / 48)
|
|
|
+ self._deviceStats.shy -= (float)(updateDur / 500)
|
|
|
+ self._deviceStats.soziality -= (float)(updateDur / 48) * impact
|
|
|
+ self._deviceStats.usefull -= (float)(updateDur / 48)
|
|
|
|
|
|
# Additive
|
|
|
- self.deviceStats.bored += (float)(updateDur / 50)
|
|
|
- if self.houseStats.bSleeping:
|
|
|
- self.deviceStats.energy += (float)(updateDur / 14) * impact
|
|
|
+ self._deviceStats.bored += (float)(updateDur / 50)
|
|
|
+ if self._ownerStats.bSleeping:
|
|
|
+ self._deviceStats.energy += (float)(updateDur / 14) * impact
|
|
|
else:
|
|
|
- self.deviceStats.energy += (float)(updateDur / 30) * impact
|
|
|
- self.deviceStats.useless += (float)(updateDur / 168) # 168 = 1 Woche
|
|
|
+ self._deviceStats.energy += (float)(updateDur / 30) * impact
|
|
|
+ self._deviceStats.useless += (float)(updateDur / 168) # 168 = 1 Woche
|
|
|
|
|
|
- if self.deviceStats.angry>500 or self.deviceStats.annoyed>400 or self.deviceStats.depressive>300 or self.deviceStats.energy<100 or self.deviceStats.sleepy>500 or self.deviceStats.toLoud>300:
|
|
|
- self.deviceStats.exhausted += (float)(updateDur / 18)
|
|
|
+ if self._deviceStats.angry>500 or self._deviceStats.annoyed>400 or self._deviceStats.depressive>300 or self._deviceStats.energy<100 or self._deviceStats.sleepy>500 or self._deviceStats.toLoud>300:
|
|
|
+ self._deviceStats.exhausted += (float)(updateDur / 18)
|
|
|
|
|
|
- if self.deviceStats.toQuiet > 50:
|
|
|
- if self.deviceStats.toQuiet > 150:
|
|
|
- if self.deviceStats.toQuiet > 450:
|
|
|
- if self.deviceStats.toQuiet > 600:
|
|
|
- self.deviceStats.lonely+= (float)(updateDur / 5)
|
|
|
+ if self._deviceStats.toQuiet > 50:
|
|
|
+ if self._deviceStats.toQuiet > 150:
|
|
|
+ if self._deviceStats.toQuiet > 450:
|
|
|
+ if self._deviceStats.toQuiet > 600:
|
|
|
+ self._deviceStats.lonely+= (float)(updateDur / 5)
|
|
|
else:
|
|
|
- self.deviceStats.lonely+=(float)(updateDur / 8)
|
|
|
+ self._deviceStats.lonely+=(float)(updateDur / 8)
|
|
|
else:
|
|
|
- self.deviceStats.lonely+=(float)(updateDur / 32)
|
|
|
+ self._deviceStats.lonely+=(float)(updateDur / 32)
|
|
|
else:
|
|
|
- self.deviceStats.lonely+=(float)(updateDur / 64)
|
|
|
+ self._deviceStats.lonely+=(float)(updateDur / 64)
|
|
|
|
|
|
# Dependend
|
|
|
- if self.deviceStats.usefull > 600:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 20) * impact
|
|
|
- elif self.deviceStats.usefull > 400:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 40) * impact
|
|
|
- elif self.deviceStats.usefull > 300 and self.deviceStats.useless < 300:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 50) * impact
|
|
|
+ if self._deviceStats.usefull > 600:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 20) * impact
|
|
|
+ elif self._deviceStats.usefull > 400:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 40) * impact
|
|
|
+ elif self._deviceStats.usefull > 300 and self._deviceStats.useless < 300:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 50) * impact
|
|
|
else:
|
|
|
- self.deviceStats.happyness -= (float)(updateDur / 20)
|
|
|
+ self._deviceStats.happyness -= (float)(updateDur / 20)
|
|
|
|
|
|
- if self.deviceStats.temperate > 300:
|
|
|
- self.deviceStats.angry += (float)(updateDur / 60) * impact
|
|
|
- if self.deviceStats.freezy > 400 or self.deviceStats.hot > 400:
|
|
|
- self.deviceStats.angry += (float)(updateDur / 50) * impact
|
|
|
- if self.deviceStats.toLoud > 300 or self.deviceStats.toQuiet > 500:
|
|
|
- self.deviceStats.angry += (float)(updateDur / 30) * impact
|
|
|
+ if self._deviceStats.temperate > 300:
|
|
|
+ self._deviceStats.angry += (float)(updateDur / 60) * impact
|
|
|
+ if self._deviceStats.freezy > 400 or self._deviceStats.hot > 400:
|
|
|
+ self._deviceStats.angry += (float)(updateDur / 50) * impact
|
|
|
+ if self._deviceStats.toLoud > 300 or self._deviceStats.toQuiet > 500:
|
|
|
+ self._deviceStats.angry += (float)(updateDur / 30) * impact
|
|
|
|
|
|
- if self.houseStats.bSleeping:
|
|
|
- self.deviceStats.sleepy -= (float)(updateDur / 15) * impact
|
|
|
+ if self._ownerStats.bSleeping:
|
|
|
+ self._deviceStats.sleepy -= (float)(updateDur / 15) * impact
|
|
|
else:
|
|
|
- if self.deviceStats.toQuiet > 300:
|
|
|
- self.deviceStats.sleepy += (float)(updateDur / 24);
|
|
|
+ if self._deviceStats.toQuiet > 300:
|
|
|
+ self._deviceStats.sleepy += (float)(updateDur / 24);
|
|
|
if curHour > 21 or curHour < 8:
|
|
|
- self.deviceStats.sleepy += (float)(updateDur / 48)
|
|
|
+ self._deviceStats.sleepy += (float)(updateDur / 48)
|
|
|
|
|
|
- if self.outdoorStats.bRaining == True:
|
|
|
- if self.outdoorStats.bWindy:
|
|
|
- self.deviceStats.depressive += (float)(updateDur / 10)
|
|
|
+ if self._outdoorStats.bRaining == True:
|
|
|
+ if self._outdoorStats.bWindy:
|
|
|
+ self._deviceStats.depressive += (float)(updateDur / 10)
|
|
|
else:
|
|
|
- self.deviceStats.depressive += (float)(updateDur / 20)
|
|
|
- elif self.deviceStats.angry > 650:
|
|
|
- self.deviceStats.depressive += (float)(updateDur / 40) * impact
|
|
|
- elif self.deviceStats.angry > 500:
|
|
|
- self.deviceStats.depressive += (float)(updateDur / 50) * impact
|
|
|
- elif self.deviceStats.angry > 300:
|
|
|
- self.deviceStats.depressive += (float)(updateDur / 90) * impact
|
|
|
+ self._deviceStats.depressive += (float)(updateDur / 20)
|
|
|
+ elif self._deviceStats.angry > 650:
|
|
|
+ self._deviceStats.depressive += (float)(updateDur / 40) * impact
|
|
|
+ elif self._deviceStats.angry > 500:
|
|
|
+ self._deviceStats.depressive += (float)(updateDur / 50) * impact
|
|
|
+ elif self._deviceStats.angry > 300:
|
|
|
+ self._deviceStats.depressive += (float)(updateDur / 90) * impact
|
|
|
else:
|
|
|
- self.deviceStats.depressive -= (float)(updateDur / 50)
|
|
|
+ self._deviceStats.depressive -= (float)(updateDur / 50)
|
|
|
|
|
|
- self.deviceStats.excited += (float)(updateDur / 50)
|
|
|
- if self.deviceStats.depressive > 70:
|
|
|
- if self.deviceStats.angry < 100:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 120)
|
|
|
- if self.deviceStats.compfortable > 300:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 120)
|
|
|
+ self._deviceStats.excited += (float)(updateDur / 50)
|
|
|
+ if self._deviceStats.depressive > 70:
|
|
|
+ if self._deviceStats.angry < 100:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 120)
|
|
|
+ if self._deviceStats.compfortable > 300:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 120)
|
|
|
else:
|
|
|
- if self.deviceStats.angry < 120:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 120)
|
|
|
- if self.deviceStats.angry < 80:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 45)
|
|
|
- if self.deviceStats.compfortable > 300:
|
|
|
- self.deviceStats.happyness += (float)(updateDur / 90)
|
|
|
+ if self._deviceStats.angry < 120:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 120)
|
|
|
+ if self._deviceStats.angry < 80:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 45)
|
|
|
+ if self._deviceStats.compfortable > 300:
|
|
|
+ self._deviceStats.happyness += (float)(updateDur / 90)
|
|
|
|
|
|
- if self.deviceStats.happyness > 150:
|
|
|
- self.deviceStats.funny += (float)(updateDur / 48) # Depends on happyness (>100) and other stats
|
|
|
- if self.deviceStats.happyness > 300:
|
|
|
- self.deviceStats.funny += (float)(updateDur / 48) # Depends on happyness (>100) and other stats
|
|
|
+ if self._deviceStats.happyness > 150:
|
|
|
+ self._deviceStats.funny += (float)(updateDur / 48) # Depends on happyness (>100) and other stats
|
|
|
+ if self._deviceStats.happyness > 300:
|
|
|
+ self._deviceStats.funny += (float)(updateDur / 48) # Depends on happyness (>100) and other stats
|
|
|
else:
|
|
|
- self.deviceStats.funny -= (float)(updateDur / 90) # Depends on other stats
|
|
|
- if self.deviceStats.hot < 100 and self.deviceStats.freezy < 100:
|
|
|
- self.deviceStats.compfortable += (float)(updateDur / 90) # Depends on other stats
|
|
|
- if self.deviceStats.toLoud < 200 and self.deviceStats.toQuiet < 400:
|
|
|
- self.deviceStats.compfortable += (float)(updateDur / 120) # Depends on other stats
|
|
|
+ self._deviceStats.funny -= (float)(updateDur / 90) # Depends on other stats
|
|
|
+ if self._deviceStats.hot < 100 and self._deviceStats.freezy < 100:
|
|
|
+ self._deviceStats.compfortable += (float)(updateDur / 90) # Depends on other stats
|
|
|
+ if self._deviceStats.toLoud < 200 and self._deviceStats.toQuiet < 400:
|
|
|
+ self._deviceStats.compfortable += (float)(updateDur / 120) # Depends on other stats
|
|
|
|
|
|
|
|
|
- if self.deviceStats.hot > 800 or self.deviceStats.freezy > 800:
|
|
|
- self.deviceStats.compfortable -= (float)(updateDur / 20) # Depends on other stats
|
|
|
- self.deviceStats.playful -= (float)(updateDur / 20) * impact # Depends on other stats
|
|
|
- self.deviceStats.energy -= (float)(updateDur / 15) * impact
|
|
|
- elif self.deviceStats.hot > 400 or self.deviceStats.freezy > 350:
|
|
|
- self.deviceStats.compfortable -= (float)(updateDur / 80) # Depends on other stats
|
|
|
- self.deviceStats.energy -= (float)(updateDur / 30)
|
|
|
- elif self.deviceStats.hot > 200 or self.deviceStats.freezy > 100:
|
|
|
- self.deviceStats.compfortable -= (float)(updateDur / 150) # Depends on other stats
|
|
|
+ if self._deviceStats.hot > 800 or self._deviceStats.freezy > 800:
|
|
|
+ self._deviceStats.compfortable -= (float)(updateDur / 20) # Depends on other stats
|
|
|
+ self._deviceStats.playful -= (float)(updateDur / 20) * impact # Depends on other stats
|
|
|
+ self._deviceStats.energy -= (float)(updateDur / 15) * impact
|
|
|
+ elif self._deviceStats.hot > 400 or self._deviceStats.freezy > 350:
|
|
|
+ self._deviceStats.compfortable -= (float)(updateDur / 80) # Depends on other stats
|
|
|
+ self._deviceStats.energy -= (float)(updateDur / 30)
|
|
|
+ elif self._deviceStats.hot > 200 or self._deviceStats.freezy > 100:
|
|
|
+ self._deviceStats.compfortable -= (float)(updateDur / 150) # Depends on other stats
|
|
|
|
|
|
|
|
|
- if self.deviceStats.toLoud > 800 or self.deviceStats.toQuiet > 800:
|
|
|
- self.deviceStats.compfortable -= (float)(updateDur / 20) # Depends on other stats
|
|
|
- self.deviceStats.angry += (float)(updateDur / 20) * impact
|
|
|
- self.deviceStats.sleepy += (float)(updateDur / 20)
|
|
|
- self.deviceStats.lonely -= (float)(updateDur / 100) * impact
|
|
|
- self.deviceStats.happyness -= (float)(updateDur / 100)
|
|
|
- self.deviceStats.bored -= (float)(updateDur / 100)
|
|
|
- self.deviceStats.annoyed += (float)(updateDur / 100)
|
|
|
- elif self.deviceStats.toLoud > 400 or self.deviceStats.toQuiet > 80:
|
|
|
- self.deviceStats.compfortable -= (float)(updateDur / 80) # Depends on other stats
|
|
|
- self.deviceStats.angry += (float)(updateDur / 80)
|
|
|
- self.deviceStats.sleepy += (float)(updateDur / 80) * impact
|
|
|
- self.deviceStats.annoyed += (float)(updateDur / 150) * impact
|
|
|
- elif self.deviceStats.toLoud > 200 or self.deviceStats.toQuiet > 100:
|
|
|
- self.deviceStats.compfortable -= (float)(updateDur / 150) # Depends on other stats
|
|
|
- self.deviceStats.sleepy += (float)(updateDur / 100)
|
|
|
+ if self._deviceStats.toLoud > 800 or self._deviceStats.toQuiet > 800:
|
|
|
+ self._deviceStats.compfortable -= (float)(updateDur / 20) # Depends on other stats
|
|
|
+ self._deviceStats.angry += (float)(updateDur / 20) * impact
|
|
|
+ self._deviceStats.sleepy += (float)(updateDur / 20)
|
|
|
+ self._deviceStats.lonely -= (float)(updateDur / 100) * impact
|
|
|
+ self._deviceStats.happyness -= (float)(updateDur / 100)
|
|
|
+ self._deviceStats.bored -= (float)(updateDur / 100)
|
|
|
+ self._deviceStats.annoyed += (float)(updateDur / 100)
|
|
|
+ elif self._deviceStats.toLoud > 400 or self._deviceStats.toQuiet > 80:
|
|
|
+ self._deviceStats.compfortable -= (float)(updateDur / 80) # Depends on other stats
|
|
|
+ self._deviceStats.angry += (float)(updateDur / 80)
|
|
|
+ self._deviceStats.sleepy += (float)(updateDur / 80) * impact
|
|
|
+ self._deviceStats.annoyed += (float)(updateDur / 150) * impact
|
|
|
+ elif self._deviceStats.toLoud > 200 or self._deviceStats.toQuiet > 100:
|
|
|
+ self._deviceStats.compfortable -= (float)(updateDur / 150) # Depends on other stats
|
|
|
+ self._deviceStats.sleepy += (float)(updateDur / 100)
|
|
|
|
|
|
|
|
|
- if self.deviceStats.happyness > 650 and self.deviceStats.funny > 500:
|
|
|
- self.deviceStats.playful += (float)(updateDur / 8) # Depends on naiv, funny and other stats
|
|
|
- elif self.deviceStats.happyness > 500 and self.deviceStats.funny > 500:
|
|
|
- self.deviceStats.playful += (float)(updateDur / 12) * impact # Depends on naiv, funny and other stats
|
|
|
- elif self.deviceStats.happyness > 300 and self.deviceStats.funny > 300:
|
|
|
- self.deviceStats.playful += (float)(updateDur / 18) # Depends on naiv, funny and other stats
|
|
|
- elif self.deviceStats.happyness > 150 and self.deviceStats.funny > 150:
|
|
|
- self.deviceStats.playful += (float)(updateDur / 48) # Depends on naiv, funny and other stats
|
|
|
+ if self._deviceStats.happyness > 650 and self._deviceStats.funny > 500:
|
|
|
+ self._deviceStats.playful += (float)(updateDur / 8) # Depends on naiv, funny and other stats
|
|
|
+ elif self._deviceStats.happyness > 500 and self._deviceStats.funny > 500:
|
|
|
+ self._deviceStats.playful += (float)(updateDur / 12) * impact # Depends on naiv, funny and other stats
|
|
|
+ elif self._deviceStats.happyness > 300 and self._deviceStats.funny > 300:
|
|
|
+ self._deviceStats.playful += (float)(updateDur / 18) # Depends on naiv, funny and other stats
|
|
|
+ elif self._deviceStats.happyness > 150 and self._deviceStats.funny > 150:
|
|
|
+ self._deviceStats.playful += (float)(updateDur / 48) # Depends on naiv, funny and other stats
|
|
|
else:
|
|
|
- self.deviceStats.playful -= (float)(updateDur / 48) * impact # Depends on naiv, funny and other stats
|
|
|
+ self._deviceStats.playful -= (float)(updateDur / 48) * impact # Depends on naiv, funny and other stats
|
|
|
|
|
|
|
|
|
- if self.deviceStats.angry > 800:
|
|
|
- self.deviceStats.sad += (float)(updateDur / 12)
|
|
|
- elif self.deviceStats.angry > 600:
|
|
|
- self.deviceStats.sad += (float)(updateDur / 18)
|
|
|
- elif self.deviceStats.angry > 450:
|
|
|
- self.deviceStats.sad += (float)(updateDur / 24)
|
|
|
- elif self.deviceStats.angry > 250:
|
|
|
- self.deviceStats.sad += (float)(updateDur / 30)
|
|
|
+ if self._deviceStats.angry > 800:
|
|
|
+ self._deviceStats.sad += (float)(updateDur / 12)
|
|
|
+ elif self._deviceStats.angry > 600:
|
|
|
+ self._deviceStats.sad += (float)(updateDur / 18)
|
|
|
+ elif self._deviceStats.angry > 450:
|
|
|
+ self._deviceStats.sad += (float)(updateDur / 24)
|
|
|
+ elif self._deviceStats.angry > 250:
|
|
|
+ self._deviceStats.sad += (float)(updateDur / 30)
|
|
|
else:
|
|
|
- self.deviceStats.sad -= (float)(updateDur / 48)
|
|
|
- self.deviceStats.Save()
|
|
|
+ self._deviceStats.sad -= (float)(updateDur / 48)
|
|
|
+ self._deviceStats.Save()
|
|
|
+ print(self.getJson())
|
|
|
|
|
|
|
|
|
def getJson(self):
|
|
|
return {
|
|
|
- "DeviceStats": self.deviceStats.getJson(),
|
|
|
- "HouseStats": self.houseStats.getJson(),
|
|
|
- "MicLevel": self.micLevel.getJson(),
|
|
|
- "OutdoorStats": self.outdoorStats.getJson(),
|
|
|
- "OwnerStats": self.ownerStats.getJson(),
|
|
|
- "TalkingStats": self.talkingStats.getJson()
|
|
|
+ "DeviceStats": self._deviceStats.getJson(),
|
|
|
+ "HouseStats": self._houseStats.getJson(),
|
|
|
+ "MicLevel": self._micLevel.getJson(),
|
|
|
+ "OutdoorStats": self._outdoorStats.getJson(),
|
|
|
+ "OwnerStats": self._ownerStats.getJson(),
|
|
|
+ "TalkingStats": self._talkingStats.getJson()
|
|
|
}
|
|
|
|
|
|
def __del__(self):
|
|
|
@@ -417,9 +416,9 @@ class Stats(object):
|
|
|
del self.Thread_OutDoor
|
|
|
del self.Thread_Mic
|
|
|
|
|
|
- del self.deviceStats
|
|
|
- del self.HouseStats
|
|
|
- del self.MicLevel
|
|
|
- del self.OutdoorStats
|
|
|
- del self.OwnerStats
|
|
|
- del self.TalkingStats
|
|
|
+ del self._deviceStats
|
|
|
+ del self._HouseStats
|
|
|
+ del self._MicLevel
|
|
|
+ del self._OutdoorStats
|
|
|
+ del self._OwnerStats
|
|
|
+ del self._TalkingStats
|