Small modification to be able to work with city clusters for the sensors.

This commit is contained in:
Guille Gutierrez 2021-06-02 11:24:53 -04:00
parent 4d821880a4
commit 3e179e9dff
3 changed files with 14 additions and 13 deletions

View File

@ -1,8 +1,9 @@
{
"sensors": [
{ "building" : "EV",
{ "city_object" : "EV",
"sensors": ["TOTKWCH3.IC","TOTKWEV.IC","COMPTEUR.SQD.017.IC:POWER 3P", "COMPTEUR.SQD.B1.IC:POWER 3P", "COMPTEUR.SQD.B2.IC:POWER 3P",
"TOTKWEV-MB.IC"]
}
]
}

View File

@ -12,20 +12,20 @@ class ConcordiaEnergyConsumption(ConcordiaFileReport):
def __init__(self, city, end_point, base_path):
super().__init__(city, end_point, base_path, 'concordia_energy_db.json')
for building in city.buildings:
for i in range(len(self._buildings)):
if self._buildings[i] == building.name and self._sensors[i] in self._sensor_point:
for city_object in city.city_objects:
for i in range(len(self._city_object)):
if self._city_object[i] == city_object.name and self._sensors[i] in self._sensor_point:
building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]]
building_headers = ["Date time", "Energy consumption"]
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
sensor = ConcordiaEnergySensor(self._sensors[i])
sensor_exist = False
for j in range(len(building.sensors)):
if building.sensors[j].name is sensor.name:
building.sensors[j].add_period(building_energy_consumption)
for j in range(len(city_object.sensors)):
if city_object.sensors[j].name is sensor.name:
city_object.sensors[j].add_period(building_energy_consumption)
sensor_exist = True
break
if not sensor_exist:
sensor.add_period(building_energy_consumption)
building.sensors.append(sensor)
city_object.sensors.append(sensor)

View File

@ -13,7 +13,7 @@ from city_model_structure.attributes.concordia_energy_sensor import ConcordiaEne
class ConcordiaFileReport:
def __init__(self, city, end_point, base_path, db_file):
self._buildings = []
self._city_object = []
self._sensors = []
self._sensor_point = {}
self._city = city
@ -24,10 +24,10 @@ class ConcordiaFileReport:
with open(Path(base_path / db_file).resolve()) as concordia_db:
self._sensor_database = json.load(concordia_db)
for building in self._sensor_database['sensors']:
building_name = building['building']
for sensor in building['sensors']:
self._buildings.append(building_name)
for city_object in self._sensor_database['sensors']:
city_object_name = city_object['city_object']
for sensor in city_object['sensors']:
self._city_object.append(city_object_name)
self._sensors.append(sensor)
buffer = ""