def pdcThread(pmuID, pmu_ip, port, buffSize): pdc = Pdc(pdc_id=int(pmuID), pmu_ip=pmu_ip, pmu_port=int(port), buffer_size=buffSize) # pdc.logger.setLevel("DEBUG") pdc.run() # Connect to PMU dt_buffer = list() try: header = pdc.get_header() # Get header message from PMU config = pdc.get_config() # Get configuration from PMU except BrokenPipeError as e: pdc.quit() sys.exit() pdc.start() # Request to start sending measurements while True: data = pdc.get() # Keep receiving data if data is None: data = pdc.get() # Try again receiving data if type(data) == DataFrame: outData = data.get_measurements() yield outData if not data: pdc.quit() # Close connection break
except EnvironmentError as e: print(e) sys.exit() pmu.join() if exec_type == "PDC": pdc = Pdc(pdc_id=int(pmuID), pmu_ip=pmu_ip, pmu_port=int(port)) pdc.logger.setLevel("DEBUG") pdc.run() # Connect to PMU try: header = pdc.get_header() # Get header message from PMU config = pdc.get_config() # Get configuration from PMU except BrokenPipeError as e: pdc.quit() sys.exit() pdc.start() # Request to start sending measurements while True: data = pdc.get() # Keep receiving data if type(data) == DataFrame: print(data.get_measurements()) if not data: pdc.quit() # Close connection break
if n == 0: print("Child process : ", os.getpid()) pdc = Pdc(pdc_id=idd, pmu_ip=ip, pmu_port=1420) pdc.logger.setLevel("DEBUG") pdc.run() header = pdc.get_header() config = pdc.get_config() pdc.start() while True: data = pdc.get() if type(data) == DataFrame: print(data.get_measurements()) if not data: pdc.quit() break else: print("Parent process: ", os.getpid()) p = os.wait() # pdc.run() # Connect to PMU # pdc1.run() # header = pdc.get_header() # Get header message from PMU # header1 = pdc1.get_header() # Get header message from PMU2 # config = pdc.get_config() # Get configuration from PMU # config1 = pdc1.get_config() # Get config from PMU2 # pdc.start() # Request to start sending measurements # pdc1.start() # while True:
from synchrophasor.pdc import Pdc """ tinyPDC will connect to pmu_ip:pmu_port and send request for header message, configuration and eventually to start sending measurements. ONLY FOR TCP """ pdc = Pdc(pdc_id=7, pmu_ip='127.0.0.1', pmu_port=4712) pdc.run() # Connect to PMU header = pdc.get_header() # Get header message from PMU config = pdc.get_config() # Get configuration from PMU pdc.start() # Request to start sending measurements while True: data = pdc.get() # Keep receiving data if not data: pdc.quit() # Close connection break