From fa8e1d2c1fa6f18c71a2c4ebec188bc87b4345ad Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Wed, 15 Apr 2020 07:40:34 -0700 Subject: [PATCH 1/7] updated cim2glm version to 18.0.2 --- gov.pnnl.goss.gridappsd/bnd.bnd | 2 +- gov.pnnl.goss.gridappsd/run.bnd.bndrun | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index 34ac757d6..665c28e7d 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,\ - blazegraph.cim2glm;version=18.0.1,\ + blazegraph.cim2glm;version=18.0.2,\ httpclient,\ com.bigdata.rdf,\ proven-client;version=0.2.3,\ diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index 3e6fd730b..d728c83f4 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -74,7 +74,7 @@ httpcore,\ httpclient,\ xml-apis,\ - blazegraph.cim2glm;version=18.0.1,\ + blazegraph.cim2glm;version=18.0.2,\ org.eclipse.jetty.aggregate.jetty-all-server;version=7.6.9,\ javax.servlet-api,\ com.bigdata.rdf,\ From 89039ceac1b9cf2ad6ee1cdda6ed6a1cdd62528b Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Thu, 16 Apr 2020 15:26:51 -0700 Subject: [PATCH 2/7] Added git status --- .../GLDLimitsConfigurationHandler.java | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java new file mode 100644 index 000000000..39bb50569 --- /dev/null +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java @@ -0,0 +1,172 @@ +/******************************************************************************* + * Copyright 2017, Battelle Memorial Institute All rights reserved. + * Battelle Memorial Institute (hereinafter Battelle) hereby grants permission to any person or entity + * lawfully obtaining a copy of this software and associated documentation files (hereinafter the + * Software) to redistribute and use the Software in source and binary forms, with or without modification. + * Such person or entity may use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and may permit others to do so, subject to the following conditions: + * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimers. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * Other than as used herein, neither the name Battelle Memorial Institute or Battelle may be used in any + * form whatsoever without the express written consent of Battelle. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * BATTELLE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * General disclaimer for use with OSS licenses + * + * This material was prepared as an account of work sponsored by an agency of the United States Government. + * Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any + * of their employees, nor any jurisdiction or organization that has cooperated in the development of these + * materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for + * the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process + * disclosed, or represents that its use would not infringe privately owned rights. + * + * Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, + * or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United + * States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed + * herein do not necessarily state or reflect those of the United States Government or any agency thereof. + * + * PACIFIC NORTHWEST NATIONAL LABORATORY operated by BATTELLE for the + * UNITED STATES DEPARTMENT OF ENERGY under Contract DE-AC05-76RL01830 + ******************************************************************************/ +package gov.pnnl.goss.gridappsd.configuration; + +import java.io.File; +import java.io.PrintWriter; +import java.util.Properties; + +import org.apache.felix.dm.annotation.api.Component; +import org.apache.felix.dm.annotation.api.ServiceDependency; +import org.apache.felix.dm.annotation.api.Start; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import gov.pnnl.goss.cim2glm.CIMImporter; +import gov.pnnl.goss.cim2glm.OperationalLimits; +import gov.pnnl.goss.cim2glm.queryhandler.QueryHandler; +import gov.pnnl.goss.gridappsd.api.ConfigurationHandler; +import gov.pnnl.goss.gridappsd.api.ConfigurationManager; +import gov.pnnl.goss.gridappsd.api.DataManager; +import gov.pnnl.goss.gridappsd.api.LogManager; +import gov.pnnl.goss.gridappsd.api.PowergridModelDataManager; +import gov.pnnl.goss.gridappsd.api.SimulationManager; +import gov.pnnl.goss.gridappsd.data.handlers.BlazegraphQueryHandler; +import gov.pnnl.goss.gridappsd.dto.LogMessage.LogLevel; +import gov.pnnl.goss.gridappsd.dto.SimulationContext; +import gov.pnnl.goss.gridappsd.utils.GridAppsDConstants; +import pnnl.goss.core.Client; + + +@Component +public class GLDLimitsConfigurationHandler extends BaseConfigurationHandler implements ConfigurationHandler { + + private static Logger log = LoggerFactory.getLogger(GLDLimitsConfigurationHandler.class); + Client client = null; + + @ServiceDependency + private volatile ConfigurationManager configManager; + @ServiceDependency + private volatile PowergridModelDataManager powergridModelManager; + @ServiceDependency + private volatile SimulationManager simulationManager; + @ServiceDependency + volatile LogManager logManager; + @ServiceDependency + volatile DataManager dataManager; + + + public static final String TYPENAME = "GridLAB-D Limits"; + public static final String RANDOMIZEFRACTIONS = "randomize_zipload_fractions"; + public static final String MODELID = "model_id"; + public static final String SIMULATIONID = "simulation_id"; + public static final String CIM2GLM_PREFIX = "model"; + public static final String LIMITS_FILENAME = CIM2GLM_PREFIX+"_limits.glm"; + + public GLDLimitsConfigurationHandler() { + } + + public GLDLimitsConfigurationHandler(LogManager logManager, DataManager dataManager) { + this.logManager = logManager; + this.dataManager = dataManager; + } + + @Override + @Start + public void start(){ + if(configManager!=null) { + configManager.registerConfigurationHandler(TYPENAME, this); + } + else { + //TODO send log message and exception + log.warn("No Config manager avilable for "+getClass()); + } + + if(powergridModelManager == null){ + //TODO send log message and exception + } + } + + @Override + public void generateConfig(Properties parameters, PrintWriter out, String processId, String username) throws Exception { + + String simulationId = GridAppsDConstants.getStringProperty(parameters, SIMULATIONID, null); + File configFile = null; + if(simulationId!=null){ + SimulationContext simulationContext = simulationManager.getSimulationContextForId(simulationId); + if(simulationContext!=null){ + configFile = new File(simulationContext.getSimulationDir()+File.separator+GLDLimitsConfigurationHandler.LIMITS_FILENAME); + //If the config file already has been created for this simulation then return it + if(configFile.exists()){ + printFileToOutput(configFile, out); + logRunning("Limits file for simulation "+simulationId+" already exists.", processId, username, logManager); + return; + } + } else { + logRunning("No simulation context found for simulation_id: "+simulationId, processId, username, logManager, LogLevel.WARN); + } + } + + logRunning("Generating limits file using parameters: "+parameters, processId, username, logManager); + + String modelId = GridAppsDConstants.getStringProperty(parameters, MODELID, null); + if(modelId==null || modelId.trim().length()==0){ + logError("No "+MODELID+" parameter provided", processId, username, logManager); + throw new Exception("Missing parameter "+MODELID); + } + String bgHost = configManager.getConfigurationProperty(GridAppsDConstants.BLAZEGRAPH_HOST_PATH); + if(bgHost==null || bgHost.trim().length()==0){ + bgHost = BlazegraphQueryHandler.DEFAULT_ENDPOINT; + } + + QueryHandler queryHandler = new BlazegraphQueryHandler(bgHost, logManager, processId, username); + queryHandler.addFeederSelection(modelId); + + //CIM2GLM utility uses + CIMImporter cimImporter = new CIMImporter(); + + OperationalLimits oLimits = new OperationalLimits(); + oLimits.BuildLimitMaps (cimImporter, queryHandler); + out.println("{\"limits\":{"); + out.println("\"voltages\":["); + oLimits.VoltageMapToJSON (out); + out.println("],"); + out.println("\"currents\":["); + oLimits.CurrentMapToJSON (out); + out.println("]"); + out.println("}}"); + out.close(); + + logRunning("Finished generating GridLAB-D limits file.", processId, username, logManager); + + } + + +} From 58436cf714cb672992d840ccb628ee64505109f7 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Tue, 21 Apr 2020 09:40:24 -0700 Subject: [PATCH 3/7] corrected file name --- .../gridappsd/configuration/GLDLimitsConfigurationHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java index 39bb50569..4ce071165 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/configuration/GLDLimitsConfigurationHandler.java @@ -88,7 +88,7 @@ public class GLDLimitsConfigurationHandler extends BaseConfigurationHandler impl public static final String MODELID = "model_id"; public static final String SIMULATIONID = "simulation_id"; public static final String CIM2GLM_PREFIX = "model"; - public static final String LIMITS_FILENAME = CIM2GLM_PREFIX+"_limits.glm"; + public static final String LIMITS_FILENAME = CIM2GLM_PREFIX+"_limits.json"; public GLDLimitsConfigurationHandler() { } From a1288940e3060960b76871cb0ef0240883358fdd Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Tue, 21 Apr 2020 14:03:47 -0700 Subject: [PATCH 4/7] increased size for websocket text message --- gov.pnnl.goss.gridappsd/conf/pnnl.goss.core.server.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gov.pnnl.goss.gridappsd/conf/pnnl.goss.core.server.cfg b/gov.pnnl.goss.gridappsd/conf/pnnl.goss.core.server.cfg index aac9fe9e9..16d3d2d3f 100644 --- a/gov.pnnl.goss.gridappsd/conf/pnnl.goss.core.server.cfg +++ b/gov.pnnl.goss.gridappsd/conf/pnnl.goss.core.server.cfg @@ -7,7 +7,7 @@ # The following are used for the core-client connection. goss.openwire.uri = tcp://0.0.0.0:61616 goss.stomp.uri = stomp://0.0.0.0:61613 -goss.ws.uri = ws://0.0.0.0:61614 +goss.ws.uri = ws://0.0.0.0:61614?websocket.maxTextMessageSize=999999 goss.ssl.uri = ssl://0.0.0.0:61443 goss.start.broker = true From ac0f78b2244592e59977401b4aa139cb7c2a1c34 Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Mon, 27 Apr 2020 11:56:57 -0700 Subject: [PATCH 5/7] update cim2gom to 18.0.3 --- gov.pnnl.goss.gridappsd/bnd.bnd | 2 +- gov.pnnl.goss.gridappsd/run.bnd.bndrun | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/bnd.bnd b/gov.pnnl.goss.gridappsd/bnd.bnd index 665c28e7d..c677be226 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,\ - blazegraph.cim2glm;version=18.0.2,\ + blazegraph.cim2glm;version=18.0.3,\ httpclient,\ com.bigdata.rdf,\ proven-client;version=0.2.3,\ diff --git a/gov.pnnl.goss.gridappsd/run.bnd.bndrun b/gov.pnnl.goss.gridappsd/run.bnd.bndrun index d728c83f4..cb4174a7d 100644 --- a/gov.pnnl.goss.gridappsd/run.bnd.bndrun +++ b/gov.pnnl.goss.gridappsd/run.bnd.bndrun @@ -74,7 +74,7 @@ httpcore,\ httpclient,\ xml-apis,\ - blazegraph.cim2glm;version=18.0.2,\ + blazegraph.cim2glm;version=18.0.3,\ org.eclipse.jetty.aggregate.jetty-all-server;version=7.6.9,\ javax.servlet-api,\ com.bigdata.rdf,\ From 7847b1ceb9363b1be1eadb051480478addf5824a Mon Sep 17 00:00:00 2001 From: afisher1 Date: Mon, 27 Apr 2020 14:27:58 -0700 Subject: [PATCH 6/7] correcting issue where phase count is incorrect for phase s1, s2 loads. --- services/fncsgossbridge/service/fncs_goss_bridge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/fncsgossbridge/service/fncs_goss_bridge.py b/services/fncsgossbridge/service/fncs_goss_bridge.py index d188b27f6..69cf79787 100644 --- a/services/fncsgossbridge/service/fncs_goss_bridge.py +++ b/services/fncsgossbridge/service/fncs_goss_bridge.py @@ -749,9 +749,9 @@ def _publish_to_fncs_bus(simulation_id, goss_message, command_filter): elif cim_attribute == "EnergyConsumer.p": phase_count = len(object_phases) if "s1" in object_phases: - fncs_input_message["{}".format(simulation_id)][object_name_prefix + object_name][object_property_list[0].format("1")] = float(x.get("value"))/phase_count + fncs_input_message["{}".format(simulation_id)][object_name_prefix + object_name][object_property_list[0].format("1")] = float(x.get("value"))/2.0 if "s2" in object_phases: - fncs_input_message["{}".format(simulation_id)][object_name_prefix + object_name][object_property_list[0].format("2")] = float(x.get("value"))/phase_count + fncs_input_message["{}".format(simulation_id)][object_name_prefix + object_name][object_property_list[0].format("2")] = float(x.get("value"))/2.0 if "A" in object_phases: fncs_input_message["{}".format(simulation_id)][object_name_prefix + object_name][object_property_list[0].format("A")] = float(x.get("value"))/phase_count if "B" in object_phases: From cb0a48f7966796d1fe573c6d693d5e6fea7a91dd Mon Sep 17 00:00:00 2001 From: poorva1209 Date: Thu, 30 Apr 2020 13:44:34 -0700 Subject: [PATCH 7/7] updated timeseries parse method to not use gson --- .../gridappsd/dto/RequestTimeseriesData.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/RequestTimeseriesData.java b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/RequestTimeseriesData.java index 5bd5e7c85..e9fcd3ca3 100644 --- a/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/RequestTimeseriesData.java +++ b/gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/RequestTimeseriesData.java @@ -1,10 +1,15 @@ package gov.pnnl.goss.gridappsd.dto; +import java.io.IOException; + //import gov.pnnl.goss.gridappsd.api.TimeseriesDataManager.ResultFormat; import java.io.Serializable; import java.util.Map; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; @@ -58,8 +63,17 @@ public String toString() { } public static RequestTimeseriesData parse(String jsonString){ - Gson gson = new Gson(); - RequestTimeseriesData obj = gson.fromJson(jsonString, RequestTimeseriesData.class); + ObjectMapper objectMapper = new ObjectMapper(); + RequestTimeseriesData obj = null; + try { + obj = objectMapper.readValue(jsonString, RequestTimeseriesData.class); + } catch (JsonParseException e) { + e.printStackTrace(); + } catch (JsonMappingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } if(obj.queryMeasurement.equals("simulation")) if(obj.queryFilter==null || !obj.queryFilter.containsKey("simulation_id")) throw new JsonSyntaxException("Expected filter simulation_id not found.");