#!/home/kyle/anaconda3/bin/python import names from device import Device import time import tkinter as tk if __name__ == "__main__": dev = Device(names.JOE, FLOAT=3.1415, INT=4) dev.start() gui_running = True top = tk.Tk() def on_closing(): global gui_running gui_running = False top.protocol("WM_DELETE_WINDOW", on_closing) top.geometry("200x100") float_lbl = tk.Label(top, text="FLOAT:") float_lbl.grid(row=0, column=0) float_val = tk.Label(top, text=str(dev.params['FLOAT'])) float_val.grid(row=0, column=1) int_lbl = tk.Label(top, text="INT:") int_lbl.grid(row=1, column=0) int_val = tk.Label(top, text=str(dev.params['INT'])) int_val.grid(row=1, column=1) while gui_running:
self.timerSALEVE.pulse() elif notification.isSource('KEQ0194126:1'): # parking jura self.timerJURA.pulse() self.timerROUTE.pulse() self.timerVOIRONS.pulse() elif notification.key=='error' or notification.key=='sticky_unreach': if notification.value: ccu.logger.error(notification) self.timerCCUError.pulse() else: ccu.logger.debug(notification) else: ccu.logger.debug(notification) except: ccu.logger.error("exception occured while processing ccu event") ccu.stop() dev=Device('https://192.168.2.1/rws/api/dcf', 's_112_alarming', 'BFEBB90A6F1876531F14225D6AAF3BE0', MyIOManager, '192.168.0.84', logging.DEBUG) dev.addFileToScriptUpdateMonitor(__file__) dev.enableShutdownOnScriptUpdate() dev.start()
def create_device_and_loop(dev, num): create_config(dev, num, BATTERY_TIME, MESSAGE_TIME, BIN_CAPACITY) device = Device(CONFIGURATION) device.start()
from device import Device from ip_package import * import sys if __name__ == '__main__': port = int(sys.argv[1]) next_port = int(sys.argv[2]) flag = int(sys.argv[3]) device = Device('127.0.0.1', port, '127.0.0.1', next_port) device.start() if flag == 1: device.create_tunnel() inner_ip_package = Inner_IP_Package('127.0.0.1', '127.0.0.1', "Hello World!") device.send(inner_ip_package) device.close_tunnel()
result = [] for i in range(len(datastore)): keys = datastore[i].keys() temp = {} for key in keys: temp[key.encode('utf-8')] = datastore[i][key].encode('utf-8') result.append(Device(ip=temp['ip'], name=temp['name'], interval=1000)) return result # finally: # return datastore if (__name__ == '__main__'): mongoSRV = MongoServer('localhost') mongoSRV.database('network-monitor') array = mongoSRV.retrive('test') threads = [] for device in array: thread = Device(ip=device['ip'], name=device['name'], interval=1000) thread.bind(mongoSRV) thread.start() threads.append(thread) # time.sleep(2) # for thread in threads: # thread.stop()