def main(): """ Main function """ ups = galaxy_3500.Galaxy3500('b312-ups') reader = UpsReader(ups) reader.daemon = True reader.start() time.sleep(5) codenames = [ 'b312_ups_temperature', 'b312_ups_kVAPh1', 'b312_ups_kVAPh2', 'b312_ups_kVAPh3', 'b312_ups_output_current_Ph1', 'b312_ups_output_current_Ph2', 'b312_ups_output_current_Ph3', 'b312_ups_input_frequency', 'b312_ups_input_voltage_Ph1', 'b312_ups_input_voltage_Ph2', 'b312_ups_input_voltage_Ph3', 'b312_ups_output_voltage_Ph1', 'b312_ups_output_voltage_Ph2', 'b312_ups_output_voltage_Ph3', 'b312_ups_battery_voltage', 'b312_ups_battery_current', 'b312_ups_battery_state_of_charge', 'b312_ups_output_frequency' ] loggers = {} for i in range(0, len(codenames)): loggers[codenames[i]] = ValueLogger(reader, comp_val=0.1, channel=i) loggers[codenames[i]].start() socket = DateDataPullSocket('UPS status', codenames, timeouts=[5.0] * len(codenames)) socket.start() live_socket = LiveSocket('UPS Status', codenames) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ups_b312', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ ups = galaxy_3500.Galaxy3500('b312-ups') reader = UpsReader(ups) reader.daemon = True reader.start() time.sleep(5) codenames = ['b312_ups_temperature', 'b312_ups_kVAPh1', 'b312_ups_kVAPh2', 'b312_ups_kVAPh3', 'b312_ups_output_current_Ph1', 'b312_ups_output_current_Ph2', 'b312_ups_output_current_Ph3', 'b312_ups_input_frequency', 'b312_ups_input_voltage_Ph1', 'b312_ups_input_voltage_Ph2', 'b312_ups_input_voltage_Ph3', 'b312_ups_output_voltage_Ph1', 'b312_ups_output_voltage_Ph2', 'b312_ups_output_voltage_Ph3', 'b312_ups_battery_voltage', 'b312_ups_battery_current', 'b312_ups_battery_state_of_charge', 'b312_ups_output_frequency'] loggers = {} for i in range(0, len(codenames)): loggers[codenames[i]] = ValueLogger(reader, comp_val=0.1, channel=i) loggers[codenames[i]].start() socket = DateDataPullSocket('UPS status', codenames, timeouts=[5.0] * len(codenames)) socket.start() live_socket = LiveSocket('UPS Status', codenames) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ups_b312', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def loop(): global data data = "" socket = thread_socket() socket.start() dc = dcmotor_thread() while True: if(isstr(data)==True): # print("Input Mode (Start: 1, Suspend: 2, Resume: 3, Exit: 4) \n") if(data == 'start'): data = str_to_float(data) dc.start() # float_to_str(data) elif(data == 'suspend'): dc.Suspend() elif(data == 'resume'): dc.Resume() elif(data == 'exit'): time.sleep(1) dc.Exit() else: None
def run(self): self.pword = self.get_pass() socket = SocketThread(self) socket.connect() socket.start() time.sleep(1) print '' BufferThread(self).start() try: while not self.event_close.is_set(): time.sleep(0.1) except (KeyboardInterrupt,SystemExit): pass except BaseException: print traceback.format_exc(e) self.event_close.set() if socket.is_alive(): socket.join()
def run(self): self.pword = self.get_pass() socket = SocketThread(self) socket.connect() socket.start() time.sleep(1) print('') BufferThread(self).start() try: while not self.event_close.is_set(): time.sleep(0.1) except (KeyboardInterrupt,SystemExit): pass except BaseException: print(traceback.format_exc()) self.event_close.set() if socket.is_alive(): socket.join()
def run(self): socket = SocketThread(self) socket.connect() socket.start() cmd = self.args.execute or sys.stdin.read() self.send_queue.put(cmd) self.send_queue.put('echo '+self.delim) start = time.time() try: while (not self.response or self.delim not in [x[1] for x in self.response]): if time.time()-start>self.args.timeout: raise TimeoutError time.sleep(0.1) except TimeoutError: self.error('Timed out waiting for response.') except KeyboardInterrupt: pass except BaseException as e: print traceback.format_exc(e) self.event_close.set() if socket.is_alive(): socket.join() for (err,s) in self.response: if err: sys.stderr.write(s+'\n') sys.stderr.flush() elif s!=self.delim: print s if self.errors: sys.exit(1)
def run(self): socket = SocketThread(self) socket.connect() socket.start() cmd = self.args.execute or sys.stdin.read() self.send_queue.put(cmd) self.send_queue.put('echo '+self.delim) start = time.time() try: while (not self.response or self.delim not in [x[1] for x in self.response]): if time.time()-start>self.args.timeout: raise TimeoutError time.sleep(0.1) except TimeoutError: self.error('Timed out waiting for response.') except KeyboardInterrupt: pass except BaseException as e: print(traceback.format_exc(e)) self.event_close.set() if socket.is_alive(): socket.join() for (err,s) in self.response: if err: sys.stderr.write(s+'\n') sys.stderr.flush() elif s!=self.delim: print(s) if self.errors: sys.exit(1)
print(" ", end="") for j in range(0, col): print("%2d" % j, end="") print() print(" ", end="") for j in range(0, 2 * col + 3): print("-", end="") print() for i in range(0, row): print("%d |" % i, end="") for j in range(0, col): c = board[i][j] if c == 0: print(" +", end="") elif c == 1: print(" 0", end="") elif c == 2: print(" @", end="") else: print("ERROR", end="") print(" |") print(" ", end="") for j in range(0, 2 * col + 3): print("-", end="") print() if __name__ == '__main__': socket = Client() socket.start()
def run(self): print(f'Server running on {self.serverHost} with ports: {Server.portMap[self.serverHost]}\n') for socket in self.sockets: socket.start()
self.has_logger = True self.db_logger = db_logger def add_socket(self, socket): """ adding the comm socket""" self.has_socket = True self.socket = socket def update_socket_logger(self,): """ update values""" if self.has_logger == True: pass if self.has_socket == True: for element in ['filament bias', 'filemant current', 'filament power', 'emission current', 'anode voltage', 'anode power', 'water flow']: socket.set_point_now(element,self.status[element]) if __name__ == '__main__': print('Program start') socket.deamon = True socket.start() sc = XRC1000(port='/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0') sc.daemon = True sc.start() tui = CursesTui(sc) #tui.daemon = True tui.start()