''' test dssNet load ''' import pipe import sys import time import logging Load_ID = sys.argv[1] logging.basicConfig(filename='%s.log'%Load_ID,level=logging.DEBUG) pipeout=pipe.setup_pipe_l(Load_ID) pipin = pipe.setup_pipe_w() # send to control center def send_netCoord(val): update = 'update n p controllable_load post_controllable_load %s %s 1 %s\n' %(time.time(),Load_ID, val) pipe.send_sync_event(update.encode('UTF-8'), pipin) while 1: time.sleep(1.5) send_netCoord(10700)
''' test dssNet load ''' import pipe import sys import time import logging Load_ID = sys.argv[1] logging.basicConfig(filename='%s.log' % Load_ID, level=logging.DEBUG) pipeout = pipe.setup_pipe_l(Load_ID) pipin = pipe.setup_pipe_w() # send to control center def send_netCoord(val): update = 'update n p controllable_load post_controllable_load %s %s 1 %s\n' % ( time.time(), Load_ID, val) pipe.send_sync_event(update.encode('UTF-8'), pipin) while 1: time.sleep(1.5) send_netCoord(10700)
#!/usr/bin/python3.4 ##################### # [email protected] # ##################### #pmu.py import pipe import time import sys import threading pipout = pipe.setup_pipe_l(sys.argv[1]) pipin = pipe.setup_pipe_w() from ctypes import * #from numpy import array libpmu=cdll.LoadLibrary('./models/libpmu.so') class PMU: def __init__(self, idcode, message_time_quality, stn, data_format, phnmr, annmr, dgnmr, chnam, phunit, anunit, digunit, fnom, cfgcnt, data_rate, time_base, pdc_IP, pdc_port): self.idcode = idcode self.message_time_quality = message_time_quality self.time_base = time_base
import zmq import time import sys import os import pipe import gtod import logging es_ID = sys.argv[1] myIP = sys.argv[2] myPort = sys.argv[3] logging.basicConfig(filename='%s.log' % es_ID, level=logging.DEBUG) pipout = pipe.setup_pipe_l(es_ID) pipin = pipe.setup_pipe_w() #setup ports contextIn = zmq.Context() serverIn = contextIn.socket(zmq.REP) print("tcp://%s:%s" % (myIP, myPort)) serverIn.bind("tcp://*:%s" % (myPort)) def openDSS(info): line = info.split() time_sent = float(line[3]) ph1 = line[0] ph2 = line[1] ph3 = line[2]
''' test dssNet energyStorage ''' import pipe import sys import time import logging Es_ID = sys.argv[1] logging.basicConfig(filename='%s.log' % Es_ID, level=logging.DEBUG) pipeout = pipe.setup_pipe_l(Es_ID) pipin = pipe.setup_pipe_w() # send to control center def send_netCoord(val1, val2, val3): update = 'update b p storage post_storage %s %s 3 %s %s %s\n' % ( time.time(), Es_ID, val1, val2, val3) pipe.send_sync_event(update.encode('UTF-8'), pipin) time.sleep(0.8) send_netCoord(1950, 2050, -500) while 1: time.sleep(1)
# every 100 ms # run function # difference = gen - total load # if difference is positive # send message to energy storage to charge the difference # else difference is negitive # send message to energy storage to discharge battery ''' logging.basicConfig(filename='%s.log'%Gen_ID,level=logging.DEBUG) ''' contextOut = zmq.Context() clientOut = contextOut.socket(zmq.REQ) clientOut.connect("tcp://%s:%s" % (server_IP,server_Port)) print('talking on %s:%s'%(server_IP,server_Port)) # open pipe to communicate to opendss ''' pipeout=pipe.setup_pipe_l(Gen_ID) pipin = pipe.setup_pipe_w() # send to control center while 1: time.sleep(TIME_INT) print'a'
''' test dssNet fault ''' import pipe import sys import time import logging Fault_ID = sys.argv[1] logging.basicConfig(filename='%s.log'%Fault_ID,level=logging.DEBUG) pipeout=pipe.setup_pipe_l(Fault_ID) pipin = pipe.setup_pipe_w() # send to control center def send_netCoord(): update = 'update n p fault post_fault %s %s 3 1 b24 a\n' %(time.time(),Fault_ID) pipe.send_sync_event(update.encode('UTF-8'), pipin) time.sleep(1) send_netCoord() while 1: time.sleep(1)
server_IP = sys.argv[2] server_Port = sys.argv[3] com_lock=thread.allocate_lock() logging.basicConfig(filename='%s.log'%Gen_ID,level=logging.DEBUG) contextOut = zmq.Context() clientOut = contextOut.socket(zmq.REQ) clientOut.connect("tcp://%s:%s" % (server_IP,server_Port)) print('talking on %s:%s'%(server_IP,server_Port)) # open pipe to communicate to opendss pipeout=pipe.setup_pipe_l(Gen_ID) pipin = pipe.setup_pipe_w() # send to control center def send_cc(val): global gen_val1 global gen_val2 global gen_val3 gens = val.split() print gens
import pipe import logging import gtod cc_ID = sys.argv[1] myIP = sys.argv[2] ListenPort = sys.argv[3] es_IP = sys.argv[4] es_port = sys.argv[5] logging.basicConfig(filename='%s.log' % cc_ID, level=logging.DEBUG) #start logging.debug('new run') pipeout = pipe.setup_pipe_l(cc_ID) pipin = pipe.setup_pipe_w() com_lock = thread.allocate_lock() # listen to Loads/Generator contextIn = zmq.Context() serverIn = contextIn.socket(zmq.REP) print("tcp://%s:%s" % (myIP, ListenPort)) serverIn.bind("tcp://%s:%s" % (myIP, ListenPort)) # sent to Energy Storage Device contextOut = zmq.Context() clientOut = contextOut.socket(zmq.REQ) print("tcp://%s:%s" % (es_IP, es_port)) clientOut.connect("tcp://%s:%s" % (es_IP, es_port))
# listen for message from control center # if message update OpenDSS value import zmq import time import sys import os import pipe import logging es_ID = sys.argv[1] myIP = sys.argv[2] myPort = sys.argv[3] pipout = pipe.setup_pipe_l(es_ID) #pipin = pipe.setup_pipe_w() logging.basicConfig(filename='%s.log'%es_ID,level=logging.DEBUG) #setup ports contextIn =zmq.Context() serverIn = contextIn.socket(zmq.REP) print("tcp://%s:%s" % (myIP,myPort)) serverIn.bind("tcp://*:%s" % (myPort)) time.sleep(4) while 1: requestIn_bytes = serverIn.recv() requestIn_str = requestIn_bytes.decode('utf-8')
''' test dssNet monitor ''' import pipe import sys import time import logging Mon_ID = sys.argv[1] logging.basicConfig(filename='%s.log'%Mon_ID,level=logging.DEBUG) pipeout=pipe.setup_pipe_l(Mon_ID) pipin = pipe.setup_pipe_w() def send_netCoord(): update = 'update b p monitor_1 post_monitor_1 %s %s 0 \n' %(time.time(),Mon_ID) pipe.send_sync_event(update.encode('UTF-8'), pipin) def listen(): message=pipe.listen(pipeout) logging.debug(message) while 1: time.sleep(1.35) send_netCoord() listen()
import pipe import logging import gtod cc_ID = sys.argv[1] myIP = sys.argv[2] ListenPort = sys.argv[3] es_IP = sys.argv[4] es_port = sys.argv[5] logging.basicConfig(filename='%s.log'%cc_ID,level=logging.DEBUG) #start logging.debug('new run') pipeout=pipe.setup_pipe_l(cc_ID) pipin = pipe.setup_pipe_w() com_lock = thread.allocate_lock() # listen to Loads/Generator contextIn = zmq.Context() serverIn = contextIn.socket(zmq.REP) print("tcp://%s:%s" % (myIP,ListenPort)) serverIn.bind("tcp://%s:%s" % (myIP,ListenPort)) # sent to Energy Storage Device contextOut = zmq.Context() clientOut = contextOut.socket(zmq.REQ) print("tcp://%s:%s" % (es_IP,es_port)) clientOut.connect("tcp://%s:%s" % (es_IP,es_port))
''' test dssNet energyStorage ''' import pipe import sys import time import logging Es_ID = sys.argv[1] logging.basicConfig(filename='%s.log'%Es_ID,level=logging.DEBUG) pipeout=pipe.setup_pipe_l(Es_ID) pipin = pipe.setup_pipe_w() # send to control center def send_netCoord(val1, val2, val3): update = 'update b p storage post_storage %s %s 3 %s %s %s\n' %(time.time(),Es_ID, val1, val2, val3) pipe.send_sync_event(update.encode('UTF-8'), pipin) time.sleep(0.8) send_netCoord(1950, 2050, -500) while 1: time.sleep(1)