From 37237a138a0f5dd8e321b85588248644d51d08f0 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Tue, 7 Feb 2023 09:42:58 -0800 Subject: [PATCH 1/4] resolved incorrect mapping of measurements --- .../distributed/FieldBusManagerImpl.java | 731 ++++++++---------- 1 file changed, 327 insertions(+), 404 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 e137def5..ad7dee39 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 @@ -1,421 +1,321 @@ -package gov.pnnl.goss.gridappsd.distributed; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Dictionary; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.felix.dm.annotation.api.Component; -import org.apache.felix.dm.annotation.api.ConfigurationDependency; -import org.apache.felix.dm.annotation.api.ServiceDependency; -import org.apache.felix.dm.annotation.api.Start; -import org.apache.http.auth.Credentials; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.json.JSONArray; -import org.json.JSONObject; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import gov.pnnl.goss.gridappsd.api.DataManager; -import gov.pnnl.goss.gridappsd.api.FieldBusManager; -import gov.pnnl.goss.gridappsd.api.LogManager; -import gov.pnnl.goss.gridappsd.api.PowergridModelDataManager; -import gov.pnnl.goss.gridappsd.api.ServiceManager; -import gov.pnnl.goss.gridappsd.dto.LogMessage.ProcessStatus; -import gov.pnnl.goss.gridappsd.dto.PowergridModelDataRequest; -import gov.pnnl.goss.gridappsd.dto.ServiceInfo; -import gov.pnnl.goss.gridappsd.dto.field.Feeder; -import gov.pnnl.goss.gridappsd.dto.field.RequestFieldContext; -import gov.pnnl.goss.gridappsd.dto.field.Root; -import gov.pnnl.goss.gridappsd.dto.field.SecondaryArea; -import gov.pnnl.goss.gridappsd.dto.field.SwitchArea; -import gov.pnnl.goss.gridappsd.utils.GridAppsDConstants; -import pnnl.goss.core.Client; -import pnnl.goss.core.Client.PROTOCOL; -import pnnl.goss.core.ClientFactory; -import pnnl.goss.core.DataResponse; -import pnnl.goss.core.GossResponseEvent; -import pnnl.goss.core.Request.RESPONSE_FORMAT; -import pnnl.goss.core.Response; -import pnnl.goss.core.security.SecurityConfig; - -@Component -public class FieldBusManagerImpl implements FieldBusManager { - - private static final String CONFIG_PID = "pnnl.goss.gridappsd"; - private Dictionary configurationProperties; - - String topology_reponse; - String topicPrefix = "goss.gridappsd.process.request.field"; - String topicContext = topicPrefix + ".context"; - - @ServiceDependency - ClientFactory clientFactory; - - @ServiceDependency - private volatile DataManager dataManager; - - @ServiceDependency - private volatile ServiceManager serviceManager; - - @ServiceDependency - private volatile LogManager logManager; - - private volatile TopologyRequestProcess topology; - - @ServiceDependency - SecurityConfig securityConfig; - - @ServiceDependency - PowergridModelDataManager powergridModelDataManager; - - Client client; - - Map> messageBus_measIds_map = new HashMap>(); - Map measId_messageBus_map = new HashMap(); - - String fieldModelId = null; - - // FileWriter writer = null; - - public FieldBusManagerImpl() { - System.out.println("Starting FieldBusManager"); - } - - @Start - public void start() { - - try { - - Credentials credentials = new UsernamePasswordCredentials(securityConfig.getManagerUser(), - securityConfig.getManagerPassword()); - client = clientFactory.create(PROTOCOL.STOMP, credentials, true); - - ServiceInfo serviceInfo = serviceManager.getService("gridappsd-topology-daemon"); - if (serviceInfo == null) { - logManager.warn(ProcessStatus.RUNNING, null, - "Topology deamon service is not available. Stopping FieldBusManager."); - return; - } - - fieldModelId = getFieldModelMrid(); - if (fieldModelId == null) { - logManager.warn(ProcessStatus.RUNNING, null, - "Field model mrid is not available. Stopping FieldBusManager. " - + "Check conf/pnnl.goss.gridappsd.cfg file and add field.model.mrid key with value of deployed field model mrid. "); - return; - } - - topology = new TopologyRequestProcess(fieldModelId, client, dataManager, securityConfig); - topology.start(); - - this.publishDeviceOutput(); - - } catch (Exception e) { - e.printStackTrace(); + package gov.pnnl.goss.gridappsd.distributed; + + import java.io.Serializable; + import java.util.ArrayList; + import java.util.Dictionary; + import java.util.HashMap; + import java.util.List; + import java.util.Map; + import java.util.stream.Collectors; + + import org.apache.felix.dm.annotation.api.Component; + import org.apache.felix.dm.annotation.api.ConfigurationDependency; + import org.apache.felix.dm.annotation.api.ServiceDependency; + import org.apache.felix.dm.annotation.api.Start; + import org.apache.http.auth.Credentials; + import org.apache.http.auth.UsernamePasswordCredentials; + import org.json.JSONArray; + import org.json.JSONObject; + + import com.google.gson.Gson; + import com.google.gson.JsonElement; + import com.google.gson.JsonObject; + import com.google.gson.JsonParser; + + import gov.pnnl.goss.gridappsd.api.DataManager; + import gov.pnnl.goss.gridappsd.api.FieldBusManager; + import gov.pnnl.goss.gridappsd.api.LogManager; + import gov.pnnl.goss.gridappsd.api.PowergridModelDataManager; + import gov.pnnl.goss.gridappsd.api.ServiceManager; + import gov.pnnl.goss.gridappsd.dto.LogMessage.ProcessStatus; + import gov.pnnl.goss.gridappsd.dto.PowergridModelDataRequest; + import gov.pnnl.goss.gridappsd.dto.ServiceInfo; + import gov.pnnl.goss.gridappsd.dto.field.Feeder; + import gov.pnnl.goss.gridappsd.dto.field.RequestFieldContext; + import gov.pnnl.goss.gridappsd.dto.field.Root; + import gov.pnnl.goss.gridappsd.dto.field.SecondaryArea; + import gov.pnnl.goss.gridappsd.dto.field.SwitchArea; + import gov.pnnl.goss.gridappsd.utils.GridAppsDConstants; + import pnnl.goss.core.Client; + import pnnl.goss.core.Client.PROTOCOL; + import pnnl.goss.core.ClientFactory; + import pnnl.goss.core.DataResponse; + import pnnl.goss.core.GossResponseEvent; + import pnnl.goss.core.Request.RESPONSE_FORMAT; + import pnnl.goss.core.Response; + import pnnl.goss.core.security.SecurityConfig; + + @Component + public class FieldBusManagerImpl implements FieldBusManager { + + private static final String CONFIG_PID = "pnnl.goss.gridappsd"; + private Dictionary configurationProperties; + + String topology_reponse; + String topicPrefix = "goss.gridappsd.process.request.field"; + String topicContext = topicPrefix + ".context"; + + @ServiceDependency + ClientFactory clientFactory; + + @ServiceDependency + private volatile DataManager dataManager; + + @ServiceDependency + private volatile ServiceManager serviceManager; + + @ServiceDependency + private volatile LogManager logManager; + + private volatile TopologyRequestProcess topology; + + @ServiceDependency + SecurityConfig securityConfig; + + @ServiceDependency + PowergridModelDataManager powergridModelDataManager; + + Client client; + + Map> messageBus_measIds_map = new HashMap>(); + //Map measId_messageBus_map = new HashMap(); + + String fieldModelId = null; + + // FileWriter writer = null; + + public FieldBusManagerImpl() { + System.out.println("Starting FieldBusManager"); } - - } - - @Override - public Serializable handleRequest(String request_queue, Serializable request) { - - Feeder responseFeeder = null; - - if (request_queue.endsWith("context")) { - - RequestFieldContext requestFieldContext = RequestFieldContext.parse(request.toString()); - if (requestFieldContext.areaId == null) - return topology.root.feeders; - else { - for (SwitchArea switchArea : topology.root.feeders.switch_areas) { - if (requestFieldContext.areaId.equals(switchArea.message_bus_id)) - return switchArea; - for (SecondaryArea secondaryArea : switchArea.secondary_areas) { - if (requestFieldContext.areaId.equals(secondaryArea.message_bus_id)) - return secondaryArea; - } + + @Start + public void start() { + + try { + + Credentials credentials = new UsernamePasswordCredentials(securityConfig.getManagerUser(), + securityConfig.getManagerPassword()); + client = clientFactory.create(PROTOCOL.STOMP, credentials, true); + + ServiceInfo serviceInfo = serviceManager.getService("gridappsd-topology-daemon"); + if (serviceInfo == null) { + logManager.warn(ProcessStatus.RUNNING, null, + "Topology deamon service is not available. Stopping FieldBusManager."); + return; + } + + fieldModelId = getFieldModelMrid(); + if (fieldModelId == null) { + logManager.warn(ProcessStatus.RUNNING, null, + "Field model mrid is not available. Stopping FieldBusManager. " + + "Check conf/pnnl.goss.gridappsd.cfg file and add field.model.mrid key with value of deployed field model mrid. "); + return; } + + topology = new TopologyRequestProcess(fieldModelId, client, dataManager, securityConfig); + topology.start(); + + this.publishDeviceOutput(); + + } catch (Exception e) { + e.printStackTrace(); } - + } - - return responseFeeder; - } - - public void getFieldMeasurementIds(String modelId) { - - PowergridModelDataRequest request = new PowergridModelDataRequest(); - request.modelId = modelId; - request.requestType = PowergridModelDataRequest.RequestType.QUERY_OBJECT_MEASUREMENTS.toString(); - Response response = null; - - 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, - 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, topology.root.feeders.message_bus_id); - feederMeasurementList.add(measid); + + @Override + public Serializable handleRequest(String request_queue, Serializable request) { + + Feeder responseFeeder = null; + + if (request_queue.endsWith("context")) { + + RequestFieldContext requestFieldContext = RequestFieldContext.parse(request.toString()); + if (requestFieldContext.areaId == null) + return topology.root.feeders; + else { + for (SwitchArea switchArea : topology.root.feeders.switch_areas) { + if (requestFieldContext.areaId.equals(switchArea.message_bus_id)) + return switchArea; + for (SecondaryArea secondaryArea : switchArea.secondary_areas) { + if (requestFieldContext.areaId.equals(secondaryArea.message_bus_id)) + return secondaryArea; + } } - } + } - 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, - 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, switchArea.message_bus_id); - switchAreaMeasurementList.add(measid); - } - + + return responseFeeder; + } + + public void publishDeviceOutput() { + + client.subscribe(GridAppsDConstants.topic_simulationOutput + ".>", new GossResponseEvent() { + + @Override + public void onMessage(Serializable response) { + + DataResponse event = (DataResponse) response; + String simulationId = event.getDestination().substring(event.getDestination().lastIndexOf(".") + 1, + event.getDestination().length()); + String simOutputStr = event.getData().toString(); + JsonObject simOutputJsonObj = null; + + JsonParser parser = new JsonParser(); + JsonElement simOutputObject = parser.parse(simOutputStr); + + if (simOutputObject.isJsonObject()) { + simOutputJsonObj = simOutputObject.getAsJsonObject(); } - } - - 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); - } + + JsonObject tempObj = simOutputJsonObj.getAsJsonObject("message"); + Map expectedOutputMap = tempObj.getAsJsonObject("measurements").entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue())); + + try { + + for (String measurementMrid : expectedOutputMap.keySet()) { + String messageBusId = null; + if (topology.measId_messageBus_map.get(measurementMrid) != null) { + messageBusId = "goss.gridappsd.field.simulation.output." + simulationId + "." + + topology.measId_messageBus_map.get(measurementMrid); + } else { + messageBusId = "goss.gridappsd.field.simulation.output." + simulationId + "." + + topology.root.feeders.message_bus_id; + } + + JsonObject obj = new JsonObject(); + obj.add(measurementMrid, expectedOutputMap.get(measurementMrid)); + + client.publish(messageBusId, obj.toString()); + } + + } catch (Exception e1) { + e1.printStackTrace(); } - messageBus_measIds_map.put(secondaryArea.message_bus_id, secondaryAreaMeasurementList); + + } - } - } catch (Exception e) { - e.printStackTrace(); + + }); + } - - } - - public void publishDeviceOutput() { - - client.subscribe(GridAppsDConstants.topic_simulationOutput + ".>", new GossResponseEvent() { - - @Override - public void onMessage(Serializable response) { - - DataResponse event = (DataResponse) response; - String simulationId = event.getDestination().substring(event.getDestination().lastIndexOf(".") + 1, - event.getDestination().length()); - String simOutputStr = event.getData().toString(); - JsonObject simOutputJsonObj = null; - - JsonParser parser = new JsonParser(); - JsonElement simOutputObject = parser.parse(simOutputStr); - - if (simOutputObject.isJsonObject()) { - simOutputJsonObj = simOutputObject.getAsJsonObject(); - } - - JsonObject tempObj = simOutputJsonObj.getAsJsonObject("message"); - Map expectedOutputMap = tempObj.getAsJsonObject("measurements").entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue())); - - try { - - for (String measurementMrid : expectedOutputMap.keySet()) { - - String messageBusId = null; - if (measId_messageBus_map.get(measurementMrid) != null) { - messageBusId = "goss.gridappsd.field.simulation.output." + simulationId + "." - + measId_messageBus_map.get(measurementMrid); - } else { - messageBusId = "goss.gridappsd.field.simulation.output." + simulationId + "." - + topology.root.feeders.message_bus_id; - } - - JsonObject obj = new JsonObject(); - obj.add(measurementMrid, expectedOutputMap.get(measurementMrid)); - - client.publish(messageBusId, obj.toString()); - } - - } catch (Exception e1) { - e1.printStackTrace(); - } - - + @ConfigurationDependency(pid = CONFIG_PID) + public synchronized void updated(Dictionary config) { + this.configurationProperties = config; + } + + public String getFieldModelMrid() { + if (this.configurationProperties != null) { + Object value = this.configurationProperties.get("field.model.mrid"); + if (value != null) + return value.toString(); } - - }); - - } - - @ConfigurationDependency(pid = CONFIG_PID) - public synchronized void updated(Dictionary config) { - this.configurationProperties = config; - } - - public String getFieldModelMrid() { - if (this.configurationProperties != null) { - Object value = this.configurationProperties.get("field.model.mrid"); - if (value != null) - return value.toString(); + return null; } - return null; - } - -} - -class TopologyRequest implements Serializable { - - private static final long serialVersionUID = 4279262793871885409L; - - String requestType = "GET_SWITCH_AREAS"; - String modelID = null; - String resultFormat = "JSON"; - - @Override - public String toString() { - Gson gson = new Gson(); - return gson.toJson(this); - } - -} - -class TopologyRequestProcess extends Thread { - - String fieldModelMrid; - Client client; - DataManager dataManager; - SecurityConfig securityConfig; - Root root = null; - Map> messageBus_measIds_map = new HashMap>(); - Map measId_messageBus_map = new HashMap(); - - public TopologyRequestProcess(String fieldModelMrid, Client client, DataManager dataManager, - SecurityConfig securityConfig) { - this.fieldModelMrid = fieldModelMrid; - this.client = client; - this.dataManager = dataManager; - this.securityConfig = securityConfig; + } - - @Override - public void run() { - try { + + class TopologyRequest implements Serializable { + + private static final long serialVersionUID = 4279262793871885409L; + + String requestType = "GET_SWITCH_AREAS"; + String modelID = null; + String resultFormat = "JSON"; + + @Override + public String toString() { Gson gson = new Gson(); - TopologyRequest request = new TopologyRequest(); - request.modelID = fieldModelMrid; - Serializable topoResponse = client.getResponse(request.toString(), "goss.gridappsd.request.data.topology", - RESPONSE_FORMAT.JSON); - int attempt = 1; - if (topoResponse == null && attempt < 6) { - // May have to wait for Topology processor to initialize - topoResponse = client.getResponse(request.toString(), "goss.gridappsd.request.data.topology", - RESPONSE_FORMAT.JSON); - Thread.sleep(1000); - attempt++; - } - if (topoResponse != null && (topoResponse instanceof DataResponse)) { - String str = ((DataResponse) topoResponse).getData().toString(); - root = gson.fromJson(str, Root.class); - } else { - root = gson.fromJson(topoResponse.toString(), Root.class); - } - - /* - * feederList = root.feeders; if(root == null || feederList == null - * || feederList.size() == 0){ throw new - * Exception("No Feeder available to create field message bus"); } - */ - - root.feeders.message_bus_id = root.feeders.feeder_id; - int switch_area_index = 0; - for (SwitchArea switchArea : root.feeders.switch_areas) { - switchArea.message_bus_id = root.feeders.feeder_id + "." + 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); - - } catch (Exception e) { - e.printStackTrace(); + return gson.toJson(this); } - + } - - public void getFieldMeasurementIds(String fieldModelMrid) { - - PowergridModelDataRequest request = new PowergridModelDataRequest(); - 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 : 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, root.feeders.message_bus_id); - measurementList.add(measid); + + class TopologyRequestProcess extends Thread { + + String fieldModelMrid; + Client client; + DataManager dataManager; + SecurityConfig securityConfig; + Root root = null; + Map> messageBus_measIds_map = new HashMap>(); + Map measId_messageBus_map = new HashMap(); + + public TopologyRequestProcess(String fieldModelMrid, Client client, DataManager dataManager, + SecurityConfig securityConfig) { + this.fieldModelMrid = fieldModelMrid; + this.client = client; + this.dataManager = dataManager; + this.securityConfig = securityConfig; + } + + @Override + public void run() { + try { + Gson gson = new Gson(); + TopologyRequest request = new TopologyRequest(); + request.modelID = fieldModelMrid; + Serializable topoResponse = client.getResponse(request.toString(), "goss.gridappsd.request.data.topology", + RESPONSE_FORMAT.JSON); + int attempt = 1; + if (topoResponse == null && attempt < 6) { + // May have to wait for Topology processor to initialize + topoResponse = client.getResponse(request.toString(), "goss.gridappsd.request.data.topology", + RESPONSE_FORMAT.JSON); + Thread.sleep(1000); + attempt++; + } + if (topoResponse != null && (topoResponse instanceof DataResponse)) { + String str = ((DataResponse) topoResponse).getData().toString(); + root = gson.fromJson(str, Root.class); + } else { + root = gson.fromJson(topoResponse.toString(), Root.class); + } + + /* + * feederList = root.feeders; if(root == null || feederList == null + * || feederList.size() == 0){ throw new + * Exception("No Feeder available to create field message bus"); } + */ + + root.feeders.message_bus_id = root.feeders.feeder_id; + int switch_area_index = 0; + for (SwitchArea switchArea : root.feeders.switch_areas) { + switchArea.message_bus_id = root.feeders.feeder_id + "." + 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++; } - messageBus_measIds_map.put(root.feeders.message_bus_id, measurementList); + switch_area_index++; } - + + this.getFieldMeasurementIds(fieldModelMrid); + + } catch (Exception e) { + e.printStackTrace(); } - - // Get switch level measurement ids - for (SwitchArea switchArea : root.feeders.switch_areas) { - for (String equipmentId : switchArea.addressable_equipment) { + + } + + public void getFieldMeasurementIds(String fieldModelMrid) { + + PowergridModelDataRequest request = new PowergridModelDataRequest(); + 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 : root.feeders.addressable_equipment) { request.objectId = equipmentId; response = dataManager.processDataRequest(request, "powergridmodel", null, null, securityConfig.getManagerUser()); @@ -426,12 +326,35 @@ public void getFieldMeasurementIds(String fieldModelMrid) { 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); + measId_messageBus_map.put(measid, root.feeders.message_bus_id); measurementList.add(measid); } - messageBus_measIds_map.put(switchArea.message_bus_id, measurementList); + messageBus_measIds_map.put(root.feeders.message_bus_id, measurementList); } - + + } + + // Get switch level measurement ids + for (SwitchArea switchArea : root.feeders.switch_areas) { + + for (String equipmentId : switchArea.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, switchArea.message_bus_id); + measurementList.add(measid); + } + messageBus_measIds_map.put(switchArea.message_bus_id, measurementList); + } + } + // Get Secondary level measurement ids for (SecondaryArea secondaryArea : switchArea.secondary_areas) { for (String equipmentid : secondaryArea.addressable_equipment) { @@ -452,12 +375,12 @@ public void getFieldMeasurementIds(String fieldModelMrid) { } } } + } + } catch (Exception e) { + e.printStackTrace(); } - } catch (Exception e) { - e.printStackTrace(); + } - - } - -} \ No newline at end of file + + } \ No newline at end of file From fdf59bb793ede22be7a73e6188c5bc68a104ccb5 Mon Sep 17 00:00:00 2001 From: Tonya Martin Date: Fri, 10 Feb 2023 12:08:23 -0800 Subject: [PATCH 2/4] Updated path for topology-processor --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eb16c221..d5fe6b96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -57,7 +57,7 @@ RUN mkdir ${TEMP_DIR} \ RUN mkdir ${TEMP_DIR} \ && cd ${TEMP_DIR} \ && git clone https://github.com/GRIDAPPSD/topology-processor -b main \ - && cd topology-processor/topology_processor \ + && cd topology-processor/ \ && mkdir -p /gridappsd/services/gridappsd-topology-processor \ && rm .git -rf \ && cp -r * /gridappsd/services/gridappsd-topology-processor \ From d00342897f1ae1d21d7e00f567ca4a7e9fb864e4 Mon Sep 17 00:00:00 2001 From: Tonya Martin Date: Fri, 10 Feb 2023 16:06:52 -0800 Subject: [PATCH 3/4] Update branch for topology-processor --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d5fe6b96..1dca06ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,7 +56,7 @@ RUN mkdir ${TEMP_DIR} \ # Get the topology-processor from the proper repository RUN mkdir ${TEMP_DIR} \ && cd ${TEMP_DIR} \ - && git clone https://github.com/GRIDAPPSD/topology-processor -b main \ + && git clone https://github.com/GRIDAPPSD/topology-processor -b develop \ && cd topology-processor/ \ && mkdir -p /gridappsd/services/gridappsd-topology-processor \ && rm .git -rf \ From 578dd735687f3c14de7c54c515fc0e7896198164 Mon Sep 17 00:00:00 2001 From: Tonya Martin Date: Fri, 10 Feb 2023 16:33:20 -0800 Subject: [PATCH 4/4] Update topology_processor --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1dca06ef..618eaf0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,8 +61,8 @@ RUN mkdir ${TEMP_DIR} \ && mkdir -p /gridappsd/services/gridappsd-topology-processor \ && 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/ \ + && cp /gridappsd/services/gridappsd-topology-processor/topology_processor/gridappsd-topology-service.config /gridappsd/services/ \ + && cp /gridappsd/services/gridappsd-topology-processor/topology_processor/gridappsd-topology-daemon.config /gridappsd/services/ \ && cd \ && rm -rf ${TEMP_DIR}