From 75092eb63a326ffa7b2ae3ce228c4434d3cca329 Mon Sep 17 00:00:00 2001 From: afisher1 Date: Thu, 17 Feb 2022 10:32:55 -0800 Subject: [PATCH 01/19] Providing proper CIM difference support for RegulatingControl.enabled, RegulatingControlModeKind, and RegulatingControl.mode attributes and enumerations for capacitors and regulators in the helics_goss_bridge. --- .../service/helics_goss_bridge.py | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/services/helicsgossbridge/service/helics_goss_bridge.py b/services/helicsgossbridge/service/helics_goss_bridge.py index ab70c36b..3efe2b41 100644 --- a/services/helicsgossbridge/service/helics_goss_bridge.py +++ b/services/helicsgossbridge/service/helics_goss_bridge.py @@ -45,6 +45,7 @@ import argparse import cmath from datetime import datetime +from enum import IntEnum import gzip import inspect import json @@ -104,6 +105,17 @@ #logging.config.dictConfig(logConfig) #log = logging.getLogger(__name__) +class RegulatingControlModeKind(IntEnum): + voltage = 0 + activePower = 1 + reactivePower = 2 + currentFlow = 3 + admittance = 4 + timeScheduled = 5 + temperature = 6 + powerFactor = 7 + + class HelicsGossBridge(object): ''' ClassDocs @@ -131,6 +143,16 @@ class HelicsGossBridge(object): _object_mrid_to_name = None _model_mrid = None _difference_attribute_map = { + "RegulatingControl.enabled" : { + "capacitor" : { + "property" : ["control"], + "prefix" : "cap_" + }, + "regulator" : { + "property" : ["Control"], + "prefix" : "rcon_" + } + }, "RegulatingControl.mode" : { "capacitor" : { "property" : ["control"], @@ -749,19 +771,24 @@ def _publish_to_helics_bus(self, goss_message, command_filter): if (object_name_prefix + object_name) not in helics_input_message.keys(): helics_input_message[object_name_prefix + object_name] = {} if cim_attribute == "RegulatingControl.mode": - val = int(x.get("value")) - if val == 0: + try: + val = RegulatingControlModeKind(int(x.get("value"))) + except: + val = RegulatingControlModeKind[x.get("value","").replace("RegulatingControlModeKind.","",1)] + if val == RegulatingControlModeKind.voltage: helics_input_message[object_name_prefix + object_name][object_property_list[0]] = "VOLT" - if val == 1: - helics_input_message[object_name_prefix + object_name][object_property_list[0]] = "MANUAL" - elif val == 2: + elif val == RegulatingControlModeKind.reactivePower: helics_input_message[object_name_prefix + object_name][object_property_list[0]] = "VAR" - elif val == 3: + elif val == RegulatingControlModeKind.currentFlow: helics_input_message[object_name_prefix + object_name][object_property_list[0]] = "CURRENT" else: helics_input_message[object_name_prefix + object_name][object_property_list[0]] = "MANUAL" - log.warning("Unsupported capacitor control mode requested. The only supported control modes for capacitors are voltage, VAr, volt/VAr, and current. Setting control mode to MANUAL.") - self._gad_connection.send_simulation_status("RUNNING", "Unsupported capacitor control mode requested. The only supported control modes for capacitors are voltage, VAr, volt/VAr, and current. Setting control mode to MANUAL.","WARN") + log.warning(f"Unsupported capacitor control mode requested. The only supported control modes for capacitors are RegulatingControlModeKind.voltage: 0, RegulatingControlModeKind.reactivePower: 2, and RegulatingControlModeKind.currentFlow: 3.\nSetting control mode to MANUAL.\nThe invalid control mode was {x.get('value')}") + self._gad_connection.send_simulation_status("RUNNING", f"Unsupported capacitor control mode requested. The only supported control modes for capacitors are RegulatingControlModeKind.voltage: 0, RegulatingControlModeKind.reactivePower: 2, and RegulatingControlModeKind.currentFlow: 3.\nSetting control mode to MANUAL.\nThe invalid control mode was {x.get('value')}","WARN") + elif cim_attribute == "RegulatingControl.enabled": + val = x.get("value") + if val == False: + helics_input_message[object_name_prefix + object_name][object_property_list[0]] = "MANUAL" elif cim_attribute == "RegulatingControl.targetDeadband": for y in self._difference_attribute_map[cim_attribute][object_type]["property"]: helics_input_message[object_name_prefix + object_name][y] = float(x.get("value")) From ccf959df510a376c662c8ee22151df25aa5419e2 Mon Sep 17 00:00:00 2001 From: afisher1 Date: Tue, 29 Mar 2022 17:35:40 -0700 Subject: [PATCH 02/19] Making necessary modifications for handling measurements for instances of the TransformerTank conducting equipment type --- .../GLDSimulationOutputConfigurationHandler.java | 4 ++-- services/helicsgossbridge/service/helics_goss_bridge.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java index 7def678b..5b6e216c 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java @@ -341,7 +341,7 @@ void parseMeasurement(Map measurements, JsonObject measuremen } else { throw new JsonParseException(String.format("CimMeasurementsToGldPubs::parseMeasurement: The value of measurementType is not a valid type.\nValid types for LinearShuntCompensators are VA, Pos, and PNV.\nmeasurementType = %s.",measurementType)); } - } else if (conductingEquipmentType.contains("PowerTransformer")) { + } else if (conductingEquipmentType.contains("PowerTransformer") || conductingEquipmentType.contains("TransformerTank")) { if(measurementType.equals("VA")) { objectName = conductingEquipmentName; propertyName = "power_in_" + phases; @@ -352,7 +352,7 @@ void parseMeasurement(Map measurements, JsonObject measuremen objectName = conductingEquipmentName; propertyName = "current_in_" + phases; } else { - throw new JsonParseException(String.format("CimMeasurementsToGldPubs::parseMeasurement: The value of measurementType is not a valid type.\nValid types for PowerTransformers are VA, PNV, and A.\nmeasurementType = %s.",measurementType)); + throw new JsonParseException(String.format("CimMeasurementsToGldPubs::parseMeasurement: The value of measurementType is not a valid type.\nValid types for PowerTransformers and TransformerTanks are VA, PNV, and A.\nmeasurementType = %s.",measurementType)); } } else if (conductingEquipmentType.contains("RatioTapChanger")) { if(measurementType.equals("VA")) { diff --git a/services/helicsgossbridge/service/helics_goss_bridge.py b/services/helicsgossbridge/service/helics_goss_bridge.py index 3efe2b41..cf217467 100644 --- a/services/helicsgossbridge/service/helics_goss_bridge.py +++ b/services/helicsgossbridge/service/helics_goss_bridge.py @@ -1044,7 +1044,7 @@ def _get_helics_bus_messages(self, measurement_filter): measurement["value"] = 0 else: measurement["value"] = 1 - elif conducting_equipment_type == "PowerTransformer": + elif conducting_equipment_type in ["PowerTransformer","TransformerTank","ACLineSegment"]: if property_name in ["power_in_"+phases,"voltage_"+phases,"current_in_"+phases]: val = complex(val_str) (mag,ang_rad) = cmath.polar(val) @@ -1053,7 +1053,7 @@ def _get_helics_bus_messages(self, measurement_filter): measurement["angle"] = ang_deg else: measurement["value"] = int(val_str) - elif conducting_equipment_type in ["ACLineSegment","EnergyConsumer","PowerElectronicsConnection","SynchronousMachine"]: + elif conducting_equipment_type in ["EnergyConsumer","PowerElectronicsConnection","SynchronousMachine"]: if property_name == "state_of_charge": measurement["value"] = float(val_str)*100.0 else: @@ -1180,7 +1180,7 @@ def _create_cim_object_map(self,map_file=None): property_name = "voltage_" + phases; else: raise RuntimeError(f"_create_cim_object_map: The value of measurement_type is not a valid type.\nValid types for LinearShuntCompensators are VA, Pos, and PNV.\nmeasurement_type = {measurement_type}.") - elif "PowerTransformer" in conducting_equipment_type: + elif conducting_equipment_type in ["PowerTransformer","TransformerTank"]: if measurement_type == "VA": object_name = conducting_equipment_name; property_name = "power_in_" + phases; @@ -1191,7 +1191,7 @@ def _create_cim_object_map(self,map_file=None): object_name = conducting_equipment_name; property_name = "current_in_" + phases; else: - raise RuntimeError(f"_create_cim_object_map: The value of measurement_type is not a valid type.\nValid types for PowerTransformer are VA, PNV, and A.\nmeasurement_type = {measurement_type}.") + raise RuntimeError(f"_create_cim_object_map: The value of measurement_type is not a valid type.\nValid types for PowerTransformer and TransformerTank are VA, PNV, and A.\nmeasurement_type = {measurement_type}.") elif "RatioTapChanger" in conducting_equipment_type: if measurement_type == "VA": object_name = conducting_equipment_name; From 512af8bc8a479fef5e9fbfda88209cb7c01328eb Mon Sep 17 00:00:00 2001 From: Tonya Martin Date: Mon, 9 May 2022 14:05:40 -0700 Subject: [PATCH 03/19] Copy topology processor daemon config file to services directory. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index b299c75d..01ddc675 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,7 @@ RUN mkdir ${TEMP_DIR} \ && rm .git -rf \ && cp -r * /gridappsd/services/gridappsd-topology-processor \ && cp /gridappsd/services/gridappsd-topology-processor/gridappsd-topology-service.config /gridappsd/services/ \ + && cp /gridappsd/services/gridappsd-topology-processor/gridappsd-topology-daemon.config /gridappsd/services/ \ && cd \ && rm -rf ${TEMP_DIR} From 468f28d8d3a9abad2f133c138b515fc12e1d495c Mon Sep 17 00:00:00 2001 From: Tonya Martin Date: Tue, 10 May 2022 08:53:27 -0700 Subject: [PATCH 04/19] Add gridappsd-toolbox to Dockerfile --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 01ddc675..bb6ffa24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,6 +66,18 @@ RUN mkdir ${TEMP_DIR} \ && cd \ && rm -rf ${TEMP_DIR} +# Get the gridappsd-toolbox from the proper repository +RUN mkdir ${TEMP_DIR} \ + && cd ${TEMP_DIR} \ + && git clone https://github.com/GRIDAPPSD/gridappsd-toolbox -b main \ + && cd gridappsd-toolbox \ + && mkdir -p /gridappsd/services/gridappsd-toolkit \ + && rm .git -rf \ + && cp -r * /gridappsd/services/gridappsd-toolkit \ + && cp /gridappsd/services/gridappsd-toolkit/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ + && cp /gridappsd/services/gridappsd-toolkit/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ + && cd \ + && rm -rf ${TEMP_DIR} # Copy initial applications and services into the container. # From 1a86afc6fc8df334cfa94f62da72f233f684cee1 Mon Sep 17 00:00:00 2001 From: Tonya Martin Date: Tue, 10 May 2022 13:24:48 -0700 Subject: [PATCH 05/19] Update to gridappsd-toolbox --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb6ffa24..eb16c221 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,11 +71,11 @@ RUN mkdir ${TEMP_DIR} \ && cd ${TEMP_DIR} \ && git clone https://github.com/GRIDAPPSD/gridappsd-toolbox -b main \ && cd gridappsd-toolbox \ - && mkdir -p /gridappsd/services/gridappsd-toolkit \ + && mkdir -p /gridappsd/services/gridappsd-toolbox \ && rm .git -rf \ - && cp -r * /gridappsd/services/gridappsd-toolkit \ - && cp /gridappsd/services/gridappsd-toolkit/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ - && cp /gridappsd/services/gridappsd-toolkit/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ + && cp -r * /gridappsd/services/gridappsd-toolbox \ + && cp /gridappsd/services/gridappsd-toolbox/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ + && cp /gridappsd/services/gridappsd-toolbox/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ && cd \ && rm -rf ${TEMP_DIR} From 64d2e63bedfdad3a288ea2a73eeddbb9e424fa7e Mon Sep 17 00:00:00 2001 From: afisher1 Date: Wed, 18 May 2022 15:45:43 -0700 Subject: [PATCH 06/19] correcting issue where bridge was not checking conducting_equipment_type correctly --- .../configuration/GLDSimulationOutputConfigurationHandler.java | 2 +- services/helicsgossbridge/service/helics_goss_bridge.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java index 5b6e216c..afd5d404 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDSimulationOutputConfigurationHandler.java @@ -462,7 +462,7 @@ void parseMeasurement(Map measurements, JsonObject measuremen throw new JsonParseException(String.format("CimMeasurementsToGldPubs::parseMeasurement: The value of measurementType is not a valid type.\nValid types for SynchronousMachine are VA, A, and PNV.\nmeasurementType = %s.",measurementType)); } } else { - throw new JsonParseException(String.format("CimMeasurementsToGldPubs::parseMeasurement: The value of ConductingEquipment_type is not a recognized object type.\nValid types are ACLineSegment, LinearShuntCompesator, RatioTapChanger, LoadBreakSwitch, EnergyConsumer, PowerElectronicsConnection, and PowerTransformer.\nConductingEquipment_type = %s.",conductingEquipmentType)); + throw new JsonParseException(String.format("CimMeasurementsToGldPubs::parseMeasurement: The value of ConductingEquipment_type is not a recognized object type.\nValid types are ACLineSegment, LinearShuntCompesator, RatioTapChanger, LoadBreakSwitch, EnergyConsumer, PowerElectronicsConnection, TransformerTank, and PowerTransformer.\nConductingEquipment_type = %s.",conductingEquipmentType)); } if(measurements.containsKey(objectName)) { diff --git a/services/helicsgossbridge/service/helics_goss_bridge.py b/services/helicsgossbridge/service/helics_goss_bridge.py index cf217467..223306b4 100644 --- a/services/helicsgossbridge/service/helics_goss_bridge.py +++ b/services/helicsgossbridge/service/helics_goss_bridge.py @@ -1180,7 +1180,7 @@ def _create_cim_object_map(self,map_file=None): property_name = "voltage_" + phases; else: raise RuntimeError(f"_create_cim_object_map: The value of measurement_type is not a valid type.\nValid types for LinearShuntCompensators are VA, Pos, and PNV.\nmeasurement_type = {measurement_type}.") - elif conducting_equipment_type in ["PowerTransformer","TransformerTank"]: + elif "PowerTransformer" in conducting_equipment_type or "TransformerTank" in conducting_equipment_type: if measurement_type == "VA": object_name = conducting_equipment_name; property_name = "power_in_" + phases; From 37b4eed591ef46e1c9038d4ab429d09d78f34276 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Wed, 22 Jun 2022 13:21:05 -0700 Subject: [PATCH 07/19] Update FieldBusManagerImpl.java Corrected switch are index --- .../pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java index 4584aeda..25cff379 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java @@ -373,13 +373,13 @@ public void run() { int switch_area_index = 0; for (SwitchArea switchArea : root.feeders.switch_areas) { switchArea.message_bus_id = root.feeders.feeder_id + "." + switch_area_index; - switch_area_index++; int secondary_area_index = 0; for (SecondaryArea secondaryArea : switchArea.secondary_areas) { secondaryArea.message_bus_id = root.feeders.feeder_id + "." + switch_area_index + "." + secondary_area_index; secondary_area_index++; } + switch_area_index++; } this.getFieldMeasurementIds(fieldModelMrid); From e7b67418e7e76101e053495e6c6017fc52242da6 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Thu, 23 Jun 2022 10:16:20 -0700 Subject: [PATCH 08/19] Update FieldBusManagerImpl.java Updated to get measurements in the message bud list correctly. --- .../distributed/FieldBusManagerImpl.java | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java index 25cff379..9612bcf6 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java @@ -161,35 +161,35 @@ public Serializable handleRequest(String request_queue, Serializable request) { public void getFieldMeasurementIds(String modelId) { PowergridModelDataRequest request = new PowergridModelDataRequest(); - request.modelId = modelId; + request.modelId = fieldModelMrid; request.requestType = PowergridModelDataRequest.RequestType.QUERY_OBJECT_MEASUREMENTS.toString(); Response response = null; - List measurementList = new ArrayList(); try { // Get Feeder level measurement ids - for (String equipmentId : topology.root.feeders.addressable_equipment) { + List feederMeasurementList = new ArrayList(); + for (String equipmentId : root.feeders.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, securityConfig.getManagerUser()); if (response != null && (response instanceof DataResponse)) { String str = ((DataResponse) response).getData().toString(); JSONArray array = new JSONArray(str); - measurementList.clear(); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); - measId_messageBus_map.put(measid, topology.root.feeders.message_bus_id); - measurementList.add(measid); + measId_messageBus_map.put(measid, root.feeders.message_bus_id); + feederMeasurementList.add(measid); } - messageBus_measIds_map.put(topology.root.feeders.message_bus_id, measurementList); + } - } - + messageBus_measIds_map.put(root.feeders.message_bus_id, feederMeasurementList); + // Get switch level measurement ids - for (SwitchArea switchArea : topology.root.feeders.switch_areas) { + for (SwitchArea switchArea : root.feeders.switch_areas) { + List switchAreaMeasurementList = new ArrayList(); for (String equipmentId : switchArea.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, @@ -197,36 +197,38 @@ public void getFieldMeasurementIds(String modelId) { if (response != null && (response instanceof DataResponse)) { String str = ((DataResponse) response).getData().toString(); JSONArray array = new JSONArray(str); - measurementList.clear(); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); measId_messageBus_map.put(measid, switchArea.message_bus_id); - measurementList.add(measid); + switchAreaMeasurementList.add(measid); } - messageBus_measIds_map.put(switchArea.message_bus_id, measurementList); + } + } + + messageBus_measIds_map.put(switchArea.message_bus_id, switchAreaMeasurementList); - // Get Secondary level measurement ids - for (SecondaryArea secondaryArea : switchArea.secondary_areas) { - for (String equipmentid : secondaryArea.addressable_equipment) { - request.objectId = equipmentid; - response = dataManager.processDataRequest(request, "powergridmodel", null, null, - securityConfig.getManagerUser()); - if (response != null && (response instanceof DataResponse)) { - String str = ((DataResponse) response).getData().toString(); - JSONArray array = new JSONArray(str); - measurementList.clear(); - for (int i = 0; i < array.length(); i++) { - JSONObject object = array.getJSONObject(i); - String measid = object.getString("measid"); - measId_messageBus_map.put(measid, secondaryArea.message_bus_id); - measurementList.add(measid); - } - messageBus_measIds_map.put(secondaryArea.message_bus_id, measurementList); + // Get Secondary level measurement ids + for (SecondaryArea secondaryArea : switchArea.secondary_areas) { + List secondaryAreaMeasurementList = new ArrayList(); + for (String equipmentId : secondaryArea.addressable_equipment) { + request.objectId = equipmentId; + response = dataManager.processDataRequest(request, "powergridmodel", null, null, + securityConfig.getManagerUser()); + if (response != null && (response instanceof DataResponse)) { + String str = ((DataResponse) response).getData().toString(); + JSONArray array = new JSONArray(str); + for (int i = 0; i < array.length(); i++) { + JSONObject object = array.getJSONObject(i); + String measid = object.getString("measid"); + measId_messageBus_map.put(measid, secondaryArea.message_bus_id); + secondaryAreaMeasurementList.add(measid); } + } } + messageBus_measIds_map.put(secondaryArea.message_bus_id, secondaryAreaMeasurementList); } } } catch (Exception e) { From ac4c3a68186bdbb963f02bec4bab73cc0a4a258a Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Fri, 29 Jul 2022 10:01:36 -0700 Subject: [PATCH 09/19] resolved error --- .../gridappsd/distributed/FieldBusManagerImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java index 9612bcf6..0292eb94 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java @@ -161,7 +161,7 @@ public Serializable handleRequest(String request_queue, Serializable request) { public void getFieldMeasurementIds(String modelId) { PowergridModelDataRequest request = new PowergridModelDataRequest(); - request.modelId = fieldModelMrid; + request.modelId = modelId; request.requestType = PowergridModelDataRequest.RequestType.QUERY_OBJECT_MEASUREMENTS.toString(); Response response = null; @@ -169,7 +169,7 @@ public void getFieldMeasurementIds(String modelId) { // Get Feeder level measurement ids List feederMeasurementList = new ArrayList(); - for (String equipmentId : root.feeders.addressable_equipment) { + for (String equipmentId : topology.root.feeders.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, securityConfig.getManagerUser()); @@ -179,16 +179,16 @@ public void getFieldMeasurementIds(String modelId) { for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); - measId_messageBus_map.put(measid, root.feeders.message_bus_id); + measId_messageBus_map.put(measid, topology.root.feeders.message_bus_id); feederMeasurementList.add(measid); } } } - messageBus_measIds_map.put(root.feeders.message_bus_id, feederMeasurementList); + messageBus_measIds_map.put(topology.root.feeders.message_bus_id, feederMeasurementList); // Get switch level measurement ids - for (SwitchArea switchArea : root.feeders.switch_areas) { + for (SwitchArea switchArea : topology.root.feeders.switch_areas) { List switchAreaMeasurementList = new ArrayList(); for (String equipmentId : switchArea.addressable_equipment) { request.objectId = equipmentId; From 6fdb984a33b0c21250d9085fdbfdac84241a19c5 Mon Sep 17 00:00:00 2001 From: afisher1 Date: Tue, 9 Aug 2022 13:25:46 -0700 Subject: [PATCH 10/19] adding support to read excell sheet with list of load names that should be denoted as being modeled separately from the main powerflow simulator. --- .../configuration/GLDAllConfigurationHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java index e41c26e1..41f4b691 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java @@ -119,6 +119,7 @@ public class GLDAllConfigurationHandler extends BaseConfigurationHandler impleme public static final String ENDTIME_FILTER = "endTime"; public static final String MODEL_STATE = "model_state"; public static final String SIMULATOR = "simulator"; + public static final String SEPARATED_LOADS = "separated_loads"; public static final int TIMEFILTER_YEAR = 2013; // public static final String CONFIGTARGET = "glm"; @@ -164,6 +165,7 @@ public void start(){ public void generateConfig(Properties parameters, PrintWriter out, String processId, String username) throws Exception { boolean bWantZip = true; boolean bWantSched = false; + List separateLoads = new ArrrayList(); logManager.info(ProcessStatus.RUNNING,processId,"Generating all GridLAB-D configuration files using parameters: "+parameters); @@ -244,11 +246,17 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces boolean useClimate = true;//GridAppsDConstants.getBooleanProperty(parameters, USECLIMATE, false); boolean bHaveEventGen = true; + + String separatedLoadsFile = GridAppsDConstants.getStringProperty(parameters, SEPARATED_LOADS, null); + //TODO parse xlsx spreadsheet specified in separatedLoadsFile + //if(separatedLoadsFile!=null) { + + //} //cimhub utility uses CIMImporter cimImporter = new CIMImporter(); CIMQuerySetter qs = new CIMQuerySetter(); - cimImporter.start(queryHandler, qs, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState, false); + cimImporter.start(queryHandler, qs, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState, false, separatedLoads); String tempDataPath = dir.getAbsolutePath(); //If use climate, then generate gridlabd weather data file From 7499e89ef5571d8e095df87a67cbf5317ba0bbd5 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Wed, 10 Aug 2022 22:43:40 -0700 Subject: [PATCH 11/19] added libraries and function to read xls file to get load names --- gov.pnnl.goss.gridappsd/bnd.bnd | 7 ++- gov.pnnl.goss.gridappsd/run.bnd.bndrun | 10 ++-- .../GLDAllConfigurationHandler.java | 52 +++++++++++++++++-- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index 35868fe4..fdf68ab5 100644 --- a/gov.pnnl.goss.gridappsd/bnd.bnd +++ b/gov.pnnl.goss.gridappsd/bnd.bnd @@ -38,7 +38,12 @@ proven-client;version=0.2.5,\ proven-message;version=0.5,\ com.nimbusds.nimbus-jose-jwt-dependencies,\ - + poi;version=5.2,\ + poi-ooxml;version=5.2,\ + poi-ooxml-full;version=5.2,\ + xmlbeans;version=5.0,\ + org.apache.commons.commons-collections4;version=4.4,\ + org.apache.commons.commons-compress;version=1.21 -plugin org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index 68558308..e5b27012 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -107,9 +107,13 @@ org.apache.felix.http.servlet-api,\ com.fasterxml.jackson.jaxrs.jackson-jaxrs-base,\ javax.ws.rs.jsr311-api,\ - javax.ws.rs-api - - + javax.ws.rs-api,\ + poi;version=5.2,\ + poi-ooxml;version=5.2,\ + poi-ooxml-full;version=5.2,\ + xmlbeans;version=5.0,\ + org.apache.commons.commons-collections4;version=4.4,\ + org.apache.commons.commons-compress;version=1.21 # Add broker name to the properties defined in shared.runprops -runproperties: ${shared.runprops},\ diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java index e41c26e1..4bf0fa20 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java @@ -40,11 +40,16 @@ package gov.pnnl.goss.gridappsd.configuration; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -53,16 +58,17 @@ import org.apache.felix.dm.annotation.api.Start; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.ResultSet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; -import gov.pnnl.gridappsd.cimhub.CIMImporter; -import gov.pnnl.gridappsd.cimhub.CIMQuerySetter; -import gov.pnnl.gridappsd.cimhub.dto.ModelState; -import gov.pnnl.gridappsd.cimhub.queryhandler.QueryHandler; import gov.pnnl.goss.gridappsd.api.ConfigurationHandler; import gov.pnnl.goss.gridappsd.api.ConfigurationManager; import gov.pnnl.goss.gridappsd.api.DataManager; @@ -73,9 +79,12 @@ import gov.pnnl.goss.gridappsd.data.conversion.ProvenWeatherToGridlabdWeatherConverter; import gov.pnnl.goss.gridappsd.data.handlers.BlazegraphQueryHandler; import gov.pnnl.goss.gridappsd.dto.LogMessage.ProcessStatus; -import gov.pnnl.goss.gridappsd.dto.RequestTimeseriesData; import gov.pnnl.goss.gridappsd.dto.RequestTimeseriesDataBasic; import gov.pnnl.goss.gridappsd.utils.GridAppsDConstants; +import gov.pnnl.gridappsd.cimhub.CIMImporter; +import gov.pnnl.gridappsd.cimhub.CIMQuerySetter; +import gov.pnnl.gridappsd.cimhub.dto.ModelState; +import gov.pnnl.gridappsd.cimhub.queryhandler.QueryHandler; import pnnl.goss.core.Client; import pnnl.goss.core.DataResponse; @@ -512,5 +521,38 @@ protected void generateStartupFile(Properties parameters, String tempDataPath, P } + private List getSaperatedLoadNames(String fileName) { + + List loadNames = new ArrayList(); + boolean isHeader = true; + + try { + FileInputStream fis = new FileInputStream(fileName); + Workbook workbook = null; + if(fileName.toLowerCase().endsWith("xlsx")){ + workbook = new XSSFWorkbook(fis); + }else if(fileName.toLowerCase().endsWith("xls")){ + workbook = new HSSFWorkbook(fis); + } + + Sheet sheet = workbook.getSheetAt(0); + Iterator rowIterator = sheet.iterator(); + while (rowIterator.hasNext()) + { + + Row row = rowIterator.next(); + if(!isHeader){ + loadNames.add(row.getCell(5).getStringCellValue()); + } + isHeader=false; + } + fis.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + + return loadNames; + } } From bff90618466f4a4c072908ff509b97f6f3c2b5aa Mon Sep 17 00:00:00 2001 From: Andy Fisher Date: Thu, 11 Aug 2022 11:31:54 -0700 Subject: [PATCH 12/19] Revert "Ochre load modeling" --- Dockerfile | 8 +-- gov.pnnl.goss.gridappsd/bnd.bnd | 7 +-- gov.pnnl.goss.gridappsd/run.bnd.bndrun | 10 +--- .../GLDAllConfigurationHandler.java | 52 ++--------------- .../distributed/FieldBusManagerImpl.java | 56 +++++++++---------- 5 files changed, 40 insertions(+), 93 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb16c221..bb6ffa24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,11 +71,11 @@ RUN mkdir ${TEMP_DIR} \ && cd ${TEMP_DIR} \ && git clone https://github.com/GRIDAPPSD/gridappsd-toolbox -b main \ && cd gridappsd-toolbox \ - && mkdir -p /gridappsd/services/gridappsd-toolbox \ + && mkdir -p /gridappsd/services/gridappsd-toolkit \ && rm .git -rf \ - && cp -r * /gridappsd/services/gridappsd-toolbox \ - && cp /gridappsd/services/gridappsd-toolbox/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ - && cp /gridappsd/services/gridappsd-toolbox/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ + && cp -r * /gridappsd/services/gridappsd-toolkit \ + && cp /gridappsd/services/gridappsd-toolkit/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ + && cp /gridappsd/services/gridappsd-toolkit/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ && cd \ && rm -rf ${TEMP_DIR} diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index fdf68ab5..35868fe4 100644 --- a/gov.pnnl.goss.gridappsd/bnd.bnd +++ b/gov.pnnl.goss.gridappsd/bnd.bnd @@ -38,12 +38,7 @@ proven-client;version=0.2.5,\ proven-message;version=0.5,\ com.nimbusds.nimbus-jose-jwt-dependencies,\ - poi;version=5.2,\ - poi-ooxml;version=5.2,\ - poi-ooxml-full;version=5.2,\ - xmlbeans;version=5.0,\ - org.apache.commons.commons-collections4;version=4.4,\ - org.apache.commons.commons-compress;version=1.21 + -plugin org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index e5b27012..68558308 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -107,13 +107,9 @@ org.apache.felix.http.servlet-api,\ com.fasterxml.jackson.jaxrs.jackson-jaxrs-base,\ javax.ws.rs.jsr311-api,\ - javax.ws.rs-api,\ - poi;version=5.2,\ - poi-ooxml;version=5.2,\ - poi-ooxml-full;version=5.2,\ - xmlbeans;version=5.0,\ - org.apache.commons.commons-collections4;version=4.4,\ - org.apache.commons.commons-compress;version=1.21 + javax.ws.rs-api + + # Add broker name to the properties defined in shared.runprops -runproperties: ${shared.runprops},\ diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java index b0ef2691..41f4b691 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java @@ -40,16 +40,11 @@ package gov.pnnl.goss.gridappsd.configuration; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.IOException; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Properties; @@ -58,17 +53,16 @@ import org.apache.felix.dm.annotation.api.Start; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.ResultSet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; +import gov.pnnl.gridappsd.cimhub.CIMImporter; +import gov.pnnl.gridappsd.cimhub.CIMQuerySetter; +import gov.pnnl.gridappsd.cimhub.dto.ModelState; +import gov.pnnl.gridappsd.cimhub.queryhandler.QueryHandler; import gov.pnnl.goss.gridappsd.api.ConfigurationHandler; import gov.pnnl.goss.gridappsd.api.ConfigurationManager; import gov.pnnl.goss.gridappsd.api.DataManager; @@ -79,12 +73,9 @@ import gov.pnnl.goss.gridappsd.data.conversion.ProvenWeatherToGridlabdWeatherConverter; import gov.pnnl.goss.gridappsd.data.handlers.BlazegraphQueryHandler; import gov.pnnl.goss.gridappsd.dto.LogMessage.ProcessStatus; +import gov.pnnl.goss.gridappsd.dto.RequestTimeseriesData; import gov.pnnl.goss.gridappsd.dto.RequestTimeseriesDataBasic; import gov.pnnl.goss.gridappsd.utils.GridAppsDConstants; -import gov.pnnl.gridappsd.cimhub.CIMImporter; -import gov.pnnl.gridappsd.cimhub.CIMQuerySetter; -import gov.pnnl.gridappsd.cimhub.dto.ModelState; -import gov.pnnl.gridappsd.cimhub.queryhandler.QueryHandler; import pnnl.goss.core.Client; import pnnl.goss.core.DataResponse; @@ -529,38 +520,5 @@ protected void generateStartupFile(Properties parameters, String tempDataPath, P } - private List getSaperatedLoadNames(String fileName) { - - List loadNames = new ArrayList(); - boolean isHeader = true; - - try { - FileInputStream fis = new FileInputStream(fileName); - Workbook workbook = null; - if(fileName.toLowerCase().endsWith("xlsx")){ - workbook = new XSSFWorkbook(fis); - }else if(fileName.toLowerCase().endsWith("xls")){ - workbook = new HSSFWorkbook(fis); - } - - Sheet sheet = workbook.getSheetAt(0); - Iterator rowIterator = sheet.iterator(); - while (rowIterator.hasNext()) - { - - Row row = rowIterator.next(); - if(!isHeader){ - loadNames.add(row.getCell(5).getStringCellValue()); - } - isHeader=false; - } - fis.close(); - - } catch (IOException e) { - e.printStackTrace(); - } - - return loadNames; - } } diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java index 0292eb94..4584aeda 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java @@ -164,11 +164,11 @@ public void getFieldMeasurementIds(String modelId) { request.modelId = modelId; request.requestType = PowergridModelDataRequest.RequestType.QUERY_OBJECT_MEASUREMENTS.toString(); Response response = null; + List measurementList = new ArrayList(); try { // Get Feeder level measurement ids - List feederMeasurementList = new ArrayList(); for (String equipmentId : topology.root.feeders.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, @@ -176,20 +176,20 @@ public void getFieldMeasurementIds(String modelId) { if (response != null && (response instanceof DataResponse)) { String str = ((DataResponse) response).getData().toString(); JSONArray array = new JSONArray(str); + measurementList.clear(); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); measId_messageBus_map.put(measid, topology.root.feeders.message_bus_id); - feederMeasurementList.add(measid); + measurementList.add(measid); } - + messageBus_measIds_map.put(topology.root.feeders.message_bus_id, measurementList); } + } - messageBus_measIds_map.put(topology.root.feeders.message_bus_id, feederMeasurementList); - + // Get switch level measurement ids for (SwitchArea switchArea : topology.root.feeders.switch_areas) { - List switchAreaMeasurementList = new ArrayList(); for (String equipmentId : switchArea.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, @@ -197,38 +197,36 @@ public void getFieldMeasurementIds(String modelId) { if (response != null && (response instanceof DataResponse)) { String str = ((DataResponse) response).getData().toString(); JSONArray array = new JSONArray(str); + measurementList.clear(); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); measId_messageBus_map.put(measid, switchArea.message_bus_id); - switchAreaMeasurementList.add(measid); + measurementList.add(measid); } - + messageBus_measIds_map.put(switchArea.message_bus_id, measurementList); } - } - - messageBus_measIds_map.put(switchArea.message_bus_id, switchAreaMeasurementList); - // Get Secondary level measurement ids - for (SecondaryArea secondaryArea : switchArea.secondary_areas) { - List secondaryAreaMeasurementList = new ArrayList(); - for (String equipmentId : secondaryArea.addressable_equipment) { - request.objectId = equipmentId; - response = dataManager.processDataRequest(request, "powergridmodel", null, null, - securityConfig.getManagerUser()); - if (response != null && (response instanceof DataResponse)) { - String str = ((DataResponse) response).getData().toString(); - JSONArray array = new JSONArray(str); - for (int i = 0; i < array.length(); i++) { - JSONObject object = array.getJSONObject(i); - String measid = object.getString("measid"); - measId_messageBus_map.put(measid, secondaryArea.message_bus_id); - secondaryAreaMeasurementList.add(measid); + // Get Secondary level measurement ids + for (SecondaryArea secondaryArea : switchArea.secondary_areas) { + for (String equipmentid : secondaryArea.addressable_equipment) { + request.objectId = equipmentid; + response = dataManager.processDataRequest(request, "powergridmodel", null, null, + securityConfig.getManagerUser()); + if (response != null && (response instanceof DataResponse)) { + String str = ((DataResponse) response).getData().toString(); + JSONArray array = new JSONArray(str); + measurementList.clear(); + for (int i = 0; i < array.length(); i++) { + JSONObject object = array.getJSONObject(i); + String measid = object.getString("measid"); + measId_messageBus_map.put(measid, secondaryArea.message_bus_id); + measurementList.add(measid); + } + messageBus_measIds_map.put(secondaryArea.message_bus_id, measurementList); } - } } - messageBus_measIds_map.put(secondaryArea.message_bus_id, secondaryAreaMeasurementList); } } } catch (Exception e) { @@ -375,13 +373,13 @@ public void run() { int switch_area_index = 0; for (SwitchArea switchArea : root.feeders.switch_areas) { switchArea.message_bus_id = root.feeders.feeder_id + "." + switch_area_index; + switch_area_index++; int secondary_area_index = 0; for (SecondaryArea secondaryArea : switchArea.secondary_areas) { secondaryArea.message_bus_id = root.feeders.feeder_id + "." + switch_area_index + "." + secondary_area_index; secondary_area_index++; } - switch_area_index++; } this.getFieldMeasurementIds(fieldModelMrid); From 80a09c6d53c15f25fc0b3ac5fd147c935f81726c Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Thu, 11 Aug 2022 11:38:38 -0700 Subject: [PATCH 13/19] updated libraries for poi --- gov.pnnl.goss.gridappsd/bnd.bnd | 8 ++------ gov.pnnl.goss.gridappsd/run.bnd.bndrun | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index fdf68ab5..a1d4e61a 100644 --- a/gov.pnnl.goss.gridappsd/bnd.bnd +++ b/gov.pnnl.goss.gridappsd/bnd.bnd @@ -38,12 +38,8 @@ proven-client;version=0.2.5,\ proven-message;version=0.5,\ com.nimbusds.nimbus-jose-jwt-dependencies,\ - poi;version=5.2,\ - poi-ooxml;version=5.2,\ - poi-ooxml-full;version=5.2,\ - xmlbeans;version=5.0,\ - org.apache.commons.commons-collections4;version=4.4,\ - org.apache.commons.commons-compress;version=1.21 + org.apache.servicemix.bundles.poi;version=3.17,\ + org.apache.commons.commons-collections4;version=4.4 -plugin org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index e5b27012..674dc30a 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -107,13 +107,8 @@ org.apache.felix.http.servlet-api,\ com.fasterxml.jackson.jaxrs.jackson-jaxrs-base,\ javax.ws.rs.jsr311-api,\ - javax.ws.rs-api,\ - poi;version=5.2,\ - poi-ooxml;version=5.2,\ - poi-ooxml-full;version=5.2,\ - xmlbeans;version=5.0,\ - org.apache.commons.commons-collections4;version=4.4,\ - org.apache.commons.commons-compress;version=1.21 + org.apache.servicemix.bundles.poi;version=3.17,\ + org.apache.commons.commons-collections4;version=4.4 # Add broker name to the properties defined in shared.runprops -runproperties: ${shared.runprops},\ From 20a21875ec309464ac87e15849a21be70adbaa0a Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Thu, 11 Aug 2022 13:04:59 -0700 Subject: [PATCH 14/19] Update GLDAllConfigurationHandler.java added function to read load names from ochre xls file --- .../GLDAllConfigurationHandler.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java index 41f4b691..1ba6c720 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java @@ -40,11 +40,16 @@ package gov.pnnl.goss.gridappsd.configuration; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -53,6 +58,13 @@ import org.apache.felix.dm.annotation.api.Start; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.ResultSet; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -520,5 +532,39 @@ protected void generateStartupFile(Properties parameters, String tempDataPath, P } + private static List getSaperatedLoadNames(String fileName) { + + List loadNames = new ArrayList(); + boolean isHeader = true; + + try { + FileInputStream fis = new FileInputStream(fileName); + Workbook workbook = null; + if(fileName.toLowerCase().endsWith("xlsx")){ + workbook = new XSSFWorkbook(fis); + }else if(fileName.toLowerCase().endsWith("xls")){ + workbook = new HSSFWorkbook(fis); + } + + Sheet sheet = workbook.getSheetAt(0); + Iterator rowIterator = sheet.iterator(); + while (rowIterator.hasNext()) + { + + Row row = rowIterator.next(); + if(!isHeader){ + loadNames.add(row.getCell(5).getStringCellValue()); + System.out.println(row.getCell(5).getStringCellValue()); + } + isHeader=false; + } + fis.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + + return loadNames; + } } From 7284318d15d275ae113b0c1a900d49d427affb6a Mon Sep 17 00:00:00 2001 From: afisher1 Date: Thu, 11 Aug 2022 15:53:48 -0700 Subject: [PATCH 15/19] adding processing of a separate_loads_file in the simulation request. --- cnf/ext/repositories.bnd | 2 +- gov.pnnl.goss.gridappsd/bnd.bnd | 4 ++-- gov.pnnl.goss.gridappsd/run.bnd.bndrun | 5 ++--- .../GLDAllConfigurationHandler.java | 20 +++++++++++-------- .../gridappsd/dto/ModelCreationConfig.java | 7 +++++++ .../process/ProcessNewSimulationRequest.java | 5 +++++ 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/cnf/ext/repositories.bnd b/cnf/ext/repositories.bnd index 8f5d2f0e..b62246f0 100644 --- a/cnf/ext/repositories.bnd +++ b/cnf/ext/repositories.bnd @@ -1,7 +1,7 @@ -plugin: \ aQute.bnd.deployer.repository.FixedIndexedRepo;name=GOSS Core;locations=https://raw.githubusercontent.com/GridOptics/GOSS/master/cnf/releaserepo/index.xml,\ aQute.bnd.deployer.repository.FixedIndexedRepo; name=GOSS Dependencies; locations=https://github.com/GridOptics/GOSS-Repository/raw/master/dependencies/index.xml.gz,\ - aQute.bnd.deployer.repository.FixedIndexedRepo;name=CIMHub;locations=https://raw.githubusercontent.com/GRIDAPPSD/CIMHub/master/cnf/release/index.xml,\ + aQute.bnd.deployer.repository.FixedIndexedRepo;name=CIMHub;locations=https://raw.githubusercontent.com/GRIDAPPSD/CIMHub/feature/separatedLoads/cnf/release/index.xml,\ aQute.bnd.deployer.repository.LocalIndexedRepo;name=Local;local=${workspace}/cnf/Local;pretty=true,\ aQute.bnd.deployer.repository.FixedIndexedRepo;name=BND Hub;locations=https://raw.githubusercontent.com/bndtools/bundle-hub/master/index.xml.gz,\ aQute.lib.deployer.FileRepo;name=Build;location=${workspace}/cnf/buildrepo;latest=false diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index a1d4e61a..2043dc9a 100644 --- a/gov.pnnl.goss.gridappsd/bnd.bnd +++ b/gov.pnnl.goss.gridappsd/bnd.bnd @@ -29,7 +29,7 @@ osgi.enroute.base.api,\ org.mockito.mockito-all,\ httpcore,\ - cimhub.lib;version=0.2.4,\ + cimhub.lib;version=1.0.0,\ httpclient,\ com.bigdata.rdf,\ org.glassfish.jersey.core.jersey-client;version=2.26,\ @@ -40,7 +40,7 @@ com.nimbusds.nimbus-jose-jwt-dependencies,\ org.apache.servicemix.bundles.poi;version=3.17,\ org.apache.commons.commons-collections4;version=4.4 - + -plugin org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug -sub: *.bnd diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index dfc6849f..a73bc3f3 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -76,7 +76,7 @@ httpcore,\ httpclient,\ xml-apis,\ - cimhub.lib;version=0.2.4,\ + cimhub.lib;version=1.0.0,\ org.eclipse.jetty.aggregate.jetty-all-server;version=7.6.9,\ com.bigdata.rdf,\ proven-message;version=0.5,\ @@ -108,8 +108,7 @@ com.fasterxml.jackson.jaxrs.jackson-jaxrs-base,\ javax.ws.rs.jsr311-api,\ org.apache.servicemix.bundles.poi;version=3.17,\ - org.apache.commons.commons-collections4;version=4.4,\ - javax.ws.rs-api + org.apache.commons.commons-collections4;version=4.4 # Add broker name to the properties defined in shared.runprops diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java index 1ba6c720..03199b73 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDAllConfigurationHandler.java @@ -131,7 +131,7 @@ public class GLDAllConfigurationHandler extends BaseConfigurationHandler impleme public static final String ENDTIME_FILTER = "endTime"; public static final String MODEL_STATE = "model_state"; public static final String SIMULATOR = "simulator"; - public static final String SEPARATED_LOADS = "separated_loads"; + public static final String SEPARATED_LOADS_FILE = "separated_loads_file"; public static final int TIMEFILTER_YEAR = 2013; // public static final String CONFIGTARGET = "glm"; @@ -177,7 +177,7 @@ public void start(){ public void generateConfig(Properties parameters, PrintWriter out, String processId, String username) throws Exception { boolean bWantZip = true; boolean bWantSched = false; - List separateLoads = new ArrrayList(); + List separateLoads = new ArrayList(); logManager.info(ProcessStatus.RUNNING,processId,"Generating all GridLAB-D configuration files using parameters: "+parameters); @@ -259,16 +259,20 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces boolean bHaveEventGen = true; - String separatedLoadsFile = GridAppsDConstants.getStringProperty(parameters, SEPARATED_LOADS, null); + String separatedLoadsFile = GridAppsDConstants.getStringProperty(parameters, SEPARATED_LOADS_FILE, null); + String simulator = GridAppsDConstants.getStringProperty(parameters, SIMULATOR, null); //TODO parse xlsx spreadsheet specified in separatedLoadsFile - //if(separatedLoadsFile!=null) { - - //} + if(separatedLoadsFile!=null && simulator.equalsIgnoreCase("ochre")) { + separateLoads = getSeparatedLoadNames(separatedLoadsFile); + } else if(separatedLoadsFile==null && simulator.equalsIgnoreCase("ochre")) { + logManager.error(ProcessStatus.ERROR,processId,"No "+SEPARATED_LOADS_FILE+" parameter provided"); + throw new Exception("Missing parameter "+SEPARATED_LOADS_FILE); + } //cimhub utility uses CIMImporter cimImporter = new CIMImporter(); CIMQuerySetter qs = new CIMQuerySetter(); - cimImporter.start(queryHandler, qs, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, bHaveEventGen, modelState, false, separatedLoads); + cimImporter.start(queryHandler, qs, CONFIGTARGET, fRoot, scheduleName, loadScale, bWantSched, bWantZip, bWantRandomFractions, useHouses, zFraction, iFraction, pFraction, -1, bHaveEventGen, modelState, false, separateLoads); String tempDataPath = dir.getAbsolutePath(); //If use climate, then generate gridlabd weather data file @@ -532,7 +536,7 @@ protected void generateStartupFile(Properties parameters, String tempDataPath, P } - private static List getSaperatedLoadNames(String fileName) { + private List getSeparatedLoadNames(String fileName) { List loadNames = new ArrayList(); boolean isHeader = true; diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/ModelCreationConfig.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/ModelCreationConfig.java index 7e8428da..fd22b29c 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/ModelCreationConfig.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/ModelCreationConfig.java @@ -64,6 +64,7 @@ public class ModelCreationConfig implements Serializable{ public boolean randomize_zipload_fractions = false; // should randomize the zipload fraction values (eg. z, i, p_fractions) public boolean use_houses = false; public ModelState model_state; + public String separated_loads_file; // option xslx file containing loads names that will be modeled separate from the main powerflow simulator. @@ -159,6 +160,12 @@ public ModelState getModel_state() { public void setModel_state(ModelState model_state) { this.model_state = model_state; } + public String getSeparateLoadsFile() { + return separated_loads_file; + } + public void setSeparateLoadsFile(String fileName) { + this.separated_loads_file = fileName; + } public static ModelCreationConfig parse(String jsonString){ Gson gson = new Gson(); diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java index 073f138b..92c1833b 100755 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java @@ -367,6 +367,11 @@ Properties generateSimulationParameters(RequestSimulation requestSimulation){ } params.put(GLDAllConfigurationHandler.SIMULATOR, requestSimulation.getSimulation_config().getSimulator()); + if(modelConfig.separated_loads_file!=null){ + params.put(GLDAllConfigurationHandler.SEPARATED_LOADS_FILE, modelConfig.separated_loads_file); + } else { + params.put(GLDAllConfigurationHandler.SEPARATED_LOADS_FILE, ""); + } return params; } From 337b972063672cf4ba5ebe6f4849a00c6105e091 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Mon, 22 Aug 2022 17:37:28 +0000 Subject: [PATCH 16/19] updated after testing separated load for gridlab-d --- gov.pnnl.goss.gridappsd/bnd.bnd | 2 +- gov.pnnl.goss.gridappsd/run.bnd.bndrun | 2 +- services/helicsgossbridge/service/helics_goss_bridge.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index 2043dc9a..2377e4b3 100644 --- a/gov.pnnl.goss.gridappsd/bnd.bnd +++ b/gov.pnnl.goss.gridappsd/bnd.bnd @@ -29,7 +29,7 @@ osgi.enroute.base.api,\ org.mockito.mockito-all,\ httpcore,\ - cimhub.lib;version=1.0.0,\ + cimhub.lib;version=1.0.1,\ httpclient,\ com.bigdata.rdf,\ org.glassfish.jersey.core.jersey-client;version=2.26,\ diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index a73bc3f3..098e99a2 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -76,7 +76,7 @@ httpcore,\ httpclient,\ xml-apis,\ - cimhub.lib;version=1.0.0,\ + cimhub.lib;version=1.0.1,\ org.eclipse.jetty.aggregate.jetty-all-server;version=7.6.9,\ com.bigdata.rdf,\ proven-message;version=0.5,\ diff --git a/services/helicsgossbridge/service/helics_goss_bridge.py b/services/helicsgossbridge/service/helics_goss_bridge.py index 223306b4..1df160cd 100644 --- a/services/helicsgossbridge/service/helics_goss_bridge.py +++ b/services/helicsgossbridge/service/helics_goss_bridge.py @@ -1044,7 +1044,7 @@ def _get_helics_bus_messages(self, measurement_filter): measurement["value"] = 0 else: measurement["value"] = 1 - elif conducting_equipment_type in ["PowerTransformer","TransformerTank","ACLineSegment"]: + elif conducting_equipment_type in ["PowerTransformer","TransformerTank"]: if property_name in ["power_in_"+phases,"voltage_"+phases,"current_in_"+phases]: val = complex(val_str) (mag,ang_rad) = cmath.polar(val) @@ -1053,7 +1053,7 @@ def _get_helics_bus_messages(self, measurement_filter): measurement["angle"] = ang_deg else: measurement["value"] = int(val_str) - elif conducting_equipment_type in ["EnergyConsumer","PowerElectronicsConnection","SynchronousMachine"]: + elif conducting_equipment_type in ["ACLineSegment", "EnergyConsumer","PowerElectronicsConnection","SynchronousMachine"]: if property_name == "state_of_charge": measurement["value"] = float(val_str)*100.0 else: From 82e1f6fe1f81edcaffd2e878b97f9102cdf7b859 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Mon, 22 Aug 2022 17:51:01 +0000 Subject: [PATCH 17/19] reverting unnecessary changes --- Dockerfile | 9 +-- cnf/ext/repositories.bnd | 2 +- .../distributed/FieldBusManagerImpl.java | 58 ++++++++++--------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb6ffa24..487c6741 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,16 +66,17 @@ RUN mkdir ${TEMP_DIR} \ && cd \ && rm -rf ${TEMP_DIR} +# Get the gridappsd-toolbox from the proper repository # Get the gridappsd-toolbox from the proper repository RUN mkdir ${TEMP_DIR} \ && cd ${TEMP_DIR} \ && git clone https://github.com/GRIDAPPSD/gridappsd-toolbox -b main \ && cd gridappsd-toolbox \ - && mkdir -p /gridappsd/services/gridappsd-toolkit \ + && mkdir -p /gridappsd/services/gridappsd-toolbox \ && rm .git -rf \ - && cp -r * /gridappsd/services/gridappsd-toolkit \ - && cp /gridappsd/services/gridappsd-toolkit/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ - && cp /gridappsd/services/gridappsd-toolkit/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ + && cp -r * /gridappsd/services/gridappsd-toolbox \ + && cp /gridappsd/services/gridappsd-toolbox/static-ybus/gridappsd-static-ybus-service.config /gridappsd/services/ \ + && cp /gridappsd/services/gridappsd-toolbox/dynamic-ybus/gridappsd-dynamic-ybus-service.config /gridappsd/services/ \ && cd \ && rm -rf ${TEMP_DIR} diff --git a/cnf/ext/repositories.bnd b/cnf/ext/repositories.bnd index b62246f0..8f5d2f0e 100644 --- a/cnf/ext/repositories.bnd +++ b/cnf/ext/repositories.bnd @@ -1,7 +1,7 @@ -plugin: \ aQute.bnd.deployer.repository.FixedIndexedRepo;name=GOSS Core;locations=https://raw.githubusercontent.com/GridOptics/GOSS/master/cnf/releaserepo/index.xml,\ aQute.bnd.deployer.repository.FixedIndexedRepo; name=GOSS Dependencies; locations=https://github.com/GridOptics/GOSS-Repository/raw/master/dependencies/index.xml.gz,\ - aQute.bnd.deployer.repository.FixedIndexedRepo;name=CIMHub;locations=https://raw.githubusercontent.com/GRIDAPPSD/CIMHub/feature/separatedLoads/cnf/release/index.xml,\ + aQute.bnd.deployer.repository.FixedIndexedRepo;name=CIMHub;locations=https://raw.githubusercontent.com/GRIDAPPSD/CIMHub/master/cnf/release/index.xml,\ aQute.bnd.deployer.repository.LocalIndexedRepo;name=Local;local=${workspace}/cnf/Local;pretty=true,\ aQute.bnd.deployer.repository.FixedIndexedRepo;name=BND Hub;locations=https://raw.githubusercontent.com/bndtools/bundle-hub/master/index.xml.gz,\ aQute.lib.deployer.FileRepo;name=Build;location=${workspace}/cnf/buildrepo;latest=false diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java index 4584aeda..9eba9b6f 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/distributed/FieldBusManagerImpl.java @@ -164,11 +164,11 @@ public void getFieldMeasurementIds(String modelId) { request.modelId = modelId; request.requestType = PowergridModelDataRequest.RequestType.QUERY_OBJECT_MEASUREMENTS.toString(); Response response = null; - List measurementList = new ArrayList(); try { // Get Feeder level measurement ids + List feederMeasurementList = new ArrayList(); for (String equipmentId : topology.root.feeders.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, @@ -176,20 +176,20 @@ public void getFieldMeasurementIds(String modelId) { if (response != null && (response instanceof DataResponse)) { String str = ((DataResponse) response).getData().toString(); JSONArray array = new JSONArray(str); - measurementList.clear(); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); measId_messageBus_map.put(measid, topology.root.feeders.message_bus_id); - measurementList.add(measid); + feederMeasurementList.add(measid); } - messageBus_measIds_map.put(topology.root.feeders.message_bus_id, measurementList); + } - } - + messageBus_measIds_map.put(topology.root.feeders.message_bus_id, feederMeasurementList); + // Get switch level measurement ids for (SwitchArea switchArea : topology.root.feeders.switch_areas) { + List switchAreaMeasurementList = new ArrayList(); for (String equipmentId : switchArea.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, @@ -197,36 +197,38 @@ public void getFieldMeasurementIds(String modelId) { if (response != null && (response instanceof DataResponse)) { String str = ((DataResponse) response).getData().toString(); JSONArray array = new JSONArray(str); - measurementList.clear(); for (int i = 0; i < array.length(); i++) { JSONObject object = array.getJSONObject(i); String measid = object.getString("measid"); measId_messageBus_map.put(measid, switchArea.message_bus_id); - measurementList.add(measid); + switchAreaMeasurementList.add(measid); } - messageBus_measIds_map.put(switchArea.message_bus_id, measurementList); + } + } + + messageBus_measIds_map.put(switchArea.message_bus_id, switchAreaMeasurementList); - // Get Secondary level measurement ids - for (SecondaryArea secondaryArea : switchArea.secondary_areas) { - for (String equipmentid : secondaryArea.addressable_equipment) { - request.objectId = equipmentid; - response = dataManager.processDataRequest(request, "powergridmodel", null, null, - securityConfig.getManagerUser()); - if (response != null && (response instanceof DataResponse)) { - String str = ((DataResponse) response).getData().toString(); - JSONArray array = new JSONArray(str); - measurementList.clear(); - for (int i = 0; i < array.length(); i++) { - JSONObject object = array.getJSONObject(i); - String measid = object.getString("measid"); - measId_messageBus_map.put(measid, secondaryArea.message_bus_id); - measurementList.add(measid); - } - messageBus_measIds_map.put(secondaryArea.message_bus_id, measurementList); + // Get Secondary level measurement ids + for (SecondaryArea secondaryArea : switchArea.secondary_areas) { + List secondaryAreaMeasurementList = new ArrayList(); + for (String equipmentId : secondaryArea.addressable_equipment) { + request.objectId = equipmentId; + response = dataManager.processDataRequest(request, "powergridmodel", null, null, + securityConfig.getManagerUser()); + if (response != null && (response instanceof DataResponse)) { + String str = ((DataResponse) response).getData().toString(); + JSONArray array = new JSONArray(str); + for (int i = 0; i < array.length(); i++) { + JSONObject object = array.getJSONObject(i); + String measid = object.getString("measid"); + measId_messageBus_map.put(measid, secondaryArea.message_bus_id); + secondaryAreaMeasurementList.add(measid); } + } } + messageBus_measIds_map.put(secondaryArea.message_bus_id, secondaryAreaMeasurementList); } } } catch (Exception e) { @@ -373,13 +375,13 @@ public void run() { int switch_area_index = 0; for (SwitchArea switchArea : root.feeders.switch_areas) { switchArea.message_bus_id = root.feeders.feeder_id + "." + switch_area_index; - switch_area_index++; int secondary_area_index = 0; for (SecondaryArea secondaryArea : switchArea.secondary_areas) { secondaryArea.message_bus_id = root.feeders.feeder_id + "." + switch_area_index + "." + secondary_area_index; secondary_area_index++; } + switch_area_index++; } this.getFieldMeasurementIds(fieldModelMrid); @@ -467,4 +469,4 @@ public void getFieldMeasurementIds(String fieldModelMrid) { } -} +} \ No newline at end of file From f3ffc93e9881627fc07240ad94ad03958e16b578 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Mon, 22 Aug 2022 17:52:00 +0000 Subject: [PATCH 18/19] reverting unnecessary changes --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 487c6741..eb16c221 100644 --- a/Dockerfile +++ b/Dockerfile @@ -66,7 +66,6 @@ RUN mkdir ${TEMP_DIR} \ && cd \ && rm -rf ${TEMP_DIR} -# Get the gridappsd-toolbox from the proper repository # Get the gridappsd-toolbox from the proper repository RUN mkdir ${TEMP_DIR} \ && cd ${TEMP_DIR} \ From bb0d972d65cdddb5b5c296d5971ae79dc8b4e994 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Mon, 22 Aug 2022 14:46:33 -0700 Subject: [PATCH 19/19] passing load file sto ochre and number of load federated to helics --- .../OchreAllConfigurationHandler.java | 14 +++- .../data/ProvenTimeSeriesDataManagerImpl.java | 8 +- .../process/ProcessNewSimulationRequest.java | 73 +++++++++++++++++-- .../simulation/SimulationProcess.java | 5 +- 4 files changed, 84 insertions(+), 16 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/OchreAllConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/OchreAllConfigurationHandler.java index 2678b0de..de24b7b8 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/OchreAllConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/OchreAllConfigurationHandler.java @@ -147,6 +147,14 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces throw new Exception("Missing parameter "+MODEL_ID); } + String separated_loads_file = GridAppsDConstants.getStringProperty(parameters, GLDAllConfigurationHandler.SEPARATED_LOADS_FILE, null); + if(separated_loads_file==null || separated_loads_file.trim().length()==0){ + logManager.error(ProcessStatus.ERROR,processId,"No "+GLDAllConfigurationHandler.SEPARATED_LOADS_FILE+" parameter provided"); + throw new Exception("Missing parameter "+GLDAllConfigurationHandler.SEPARATED_LOADS_FILE); + } + + + try{ File tmpDir = new File(tempDataPath); RunCommandLine.runCommand("cp -r /gridappsd/services/gridappsd-ochre/inputs/ "+tempDataPath); @@ -160,14 +168,16 @@ public void generateConfig(Properties parameters, PrintWriter out, String proces CONFIG_FILENAME+" "+ simulationBrokerPort+" "+ processId+" "+ - model_id); + model_id+ " "+ + separated_loads_file); logManager.info(ProcessStatus.RUNNING, processId, "python /gridappsd/services/gridappsd-ochre/bin/make_config_file.py "+ simulationBrokerHost+" "+ tempDataPath+" "+ CONFIG_FILENAME+" "+ simulationBrokerPort+" "+ processId+" "+ - model_id); + model_id+" "+ + separated_loads_file); }catch(Exception e){ log.warn("Could not create OCHRE HELICS config file"); diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/data/ProvenTimeSeriesDataManagerImpl.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/data/ProvenTimeSeriesDataManagerImpl.java index a138dda3..623f4369 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/data/ProvenTimeSeriesDataManagerImpl.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/data/ProvenTimeSeriesDataManagerImpl.java @@ -217,9 +217,11 @@ public void onMessage(Serializable message) { JsonElement data = parser.parse(event.getData().toString()); if (data.isJsonObject()) { JsonObject dataObj = data.getAsJsonObject(); - String datatype = dataObj.get("datatype").getAsString(); - if(datatype!=null) - provenWriteProducer.sendBulkMessage(event.getData().toString(), datatype, instanceId, simulationId, new Date().getTime()); + if(dataObj.get("datatype")!=null){ + String datatype = dataObj.get("datatype").getAsString(); + if(datatype!=null) + provenWriteProducer.sendBulkMessage(event.getData().toString(), datatype, instanceId, simulationId, new Date().getTime()); + } } } else{ diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java index 92c1833b..999a598c 100755 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/process/ProcessNewSimulationRequest.java @@ -40,16 +40,24 @@ package gov.pnnl.goss.gridappsd.process; import java.io.File; +import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + import com.google.gson.Gson; import gov.pnnl.goss.gridappsd.api.AppManager; @@ -138,6 +146,14 @@ public void process(ConfigurationManager configurationManager, if(!tempDataPathDir.exists()){ tempDataPathDir.mkdirs(); } + + + Map simulationContext = new HashMap(); + simulationContext.put("request",simRequest); + simulationContext.put("simulationId",simulationId); + simulationContext.put("simulationHost","127.0.0.1"); + simulationContext.put("simulationPort",simulationPort); + simulationContext.put("simulationDir",simulationConfigDir); SimulationContext simContext = new SimulationContext(); @@ -183,10 +199,21 @@ else if(simRequest.getSimulation_config().getSimulator().equals("OCHRE")) configurationManager.generateConfiguration(DSSAllConfigurationHandler.TYPENAME, simulationParams, new PrintWriter(new StringWriter()), simulationId, username); } else if(simulator.equalsIgnoreCase(OchreAllConfigurationHandler.TYPENAME)){ - numFederates = 42; Properties simulationParams = generateSimulationParameters(simRequest); simulationParams.put(DSSAllConfigurationHandler.SIMULATIONID, simulationId); simulationParams.put(DSSAllConfigurationHandler.DIRECTORY, tempDataPathDir.getAbsolutePath()); + + if(simRequest.simulation_config.model_creation_config.separated_loads_file!=null){ + numFederates = getSeparatedLoadNames(simRequest.simulation_config.model_creation_config.separated_loads_file).size()+2; + simulationParams.put(GLDAllConfigurationHandler.SEPARATED_LOADS_FILE, simRequest.simulation_config.model_creation_config.separated_loads_file); + } + else{ + logManager.error(ProcessStatus.ERROR,simulationId,"No "+GLDAllConfigurationHandler.SEPARATED_LOADS_FILE+" parameter provided"); + throw new Exception("Missing parameter "+GLDAllConfigurationHandler.SEPARATED_LOADS_FILE); + } + + + if(gldInterface!=null){ simulationParams.put(GridAppsDConstants.GRIDLABD_INTERFACE, gldInterface); } @@ -208,14 +235,9 @@ else if(simulator.equalsIgnoreCase(OchreAllConfigurationHandler.TYPENAME)){ // Start Apps and Services - Map simulationContext = new HashMap(); - simulationContext.put("request",simRequest); - simulationContext.put("simulationId",simulationId); - simulationContext.put("simulationHost","127.0.0.1"); - simulationContext.put("simulationPort",simulationPort); - simulationContext.put("simulationDir",simulationConfigDir); simulationContext.put("numFederates",numFederates); - + simContext.numFederates = numFederates; + if(simRequest.getSimulation_config().getSimulator().equals("GridLAB-D")) simulationContext.put("simulationFile",tempDataPathDir.getAbsolutePath()+File.separator+"model_startup.glm"); else if(simRequest.getSimulation_config().getSimulator().equals("OCHRE")) @@ -374,6 +396,41 @@ Properties generateSimulationParameters(RequestSimulation requestSimulation){ } return params; } + + private List getSeparatedLoadNames(String fileName) { + + List loadNames = new ArrayList(); + boolean isHeader = true; + + try { + FileInputStream fis = new FileInputStream(fileName); + Workbook workbook = null; + if(fileName.toLowerCase().endsWith("xlsx")){ + workbook = new XSSFWorkbook(fis); + }else if(fileName.toLowerCase().endsWith("xls")){ + workbook = new HSSFWorkbook(fis); + } + + Sheet sheet = workbook.getSheetAt(0); + Iterator rowIterator = sheet.iterator(); + while (rowIterator.hasNext()) + { + + Row row = rowIterator.next(); + if(!isHeader){ + loadNames.add(row.getCell(5).getStringCellValue()); + System.out.println(row.getCell(5).getStringCellValue()); + } + isHeader=false; + } + fis.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + + return loadNames; + } /** diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/simulation/SimulationProcess.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/simulation/SimulationProcess.java index c30bc18f..3bfab0f3 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/simulation/SimulationProcess.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/simulation/SimulationProcess.java @@ -116,9 +116,8 @@ public void run() { List commands = new ArrayList(); if(simulationConfig.getSimulator().equals(OchreAllConfigurationHandler.TYPENAME)){ - simContext.setNumFederates(42); - logManager.info(ProcessStatus.RUNNING, simulationId, "Setting num federates "); - + + //Start gridlabd // simulationContext.put("simulationFile",tempDataPathDir.getAbsolutePath()+File.separator+"model_startup.glm"); //File gldStartupFile = new File(simContext.simulationDir+File.separator+"inputs"+File.separator+"gridlabd"+File.separator+"IEEE-13"+File.separator+"IEEE-13_Houses.glm");