def gridappsd_client(request, docker_dependencies): with run_gridappsd_container(stop_after=STOP_CONTAINER_AFTER_TEST): gappsd = GridAPPSD() gappsd.connect() assert gappsd.connected models = gappsd.query_model_names() assert models is not None if request.cls is not None: request.cls.gridappsd_client = gappsd yield gappsd gappsd.disconnect()
# print(gapps.query_object_types(model_id=None)) # print("Alka3") #print(gapps.query_data( query,database_type=POWERGRID_MODEL, timeout=30 )) # # with open("power2.json", 'r') as g: # # print(gapps.get_response(request_topic, json.load(g), timeout=30)) # print("Alka4") # print(gapps.query_object_dictionary('_0f6f3735-b297-46aa-8861-547d3cd0dee9', object_type='http://iec.ch/TC57/CIM100#ACLineSegment', object_id=None)) # with open("./weather_data.json", 'r') as g: # print(gapps.get_response(t.TIMESERIES, json.load(g), timeout=30)) # # with open("./query.json", 'r') as f: # query = json.load(f) # query["queryFilter"]["simulation_id"] = opts.simulation_id # print(query["queryFilter"]["simulation_id"]) # print("Alka") # print(gapps.get_response(t.TIMESERIES, query, timeout=30)) # For testing Alarms topic uncomment the below lines alarms_topic = t.service_output_topic('gridappsd-alarms', simulation_id) print(alarms_topic) print(simulation_id) print("Alka") print(gapps.subscribe(alarms_topic, Subscribe.on_message)) print(gapps.query_model_names(model_id=None)) #For testing the Logging API uncomment the below line #print(gapps.subscribe(simulation_log_topic(simulation_id), Subscribe.on_message)) while True: time.sleep(30)
result = get_input( "Press enter to send json.dumps(dict(bim='bash')) to topic /topic/foo") print("Sending data") gapps.send('/topic/foo', json.dumps(dict(bim='bash'))) sleep(1) get_input("Press enter to receive platform status") resp = gapps.get_platform_status() pprint(resp) get_input("Press enter to query model info") resp = gapps.query_model_info() pprint(resp) get_input("Press enter to query model names") resp = gapps.query_model_names() pprint(resp) get_input("Press enter to query object types") resp = gapps.query_object_types() pprint(resp) get_input("Press enter to run ad-hoc query") # list all the connectivity nodes by feeder - CIMImporter when building GldNodes sparql = """ PREFIX r: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX c: <http://iec.ch/TC57/2012/CIM-schema-cim17#> SELECT ?feeder ?name WHERE { VALUES ?fdrid {"_49AD8E07-3BF9-A4E2-CB8F-C3722F837B62"} # 13 bus ?fdr c:IdentifiedObject.mRID ?fdrid. ?s c:ConnectivityNode.ConnectivityNodeContainer ?fdr.