class Measure: meter = meter.Meter(4, 4) duration = 1 def __init__(self, meter=None): if meter is not None: self.meter = meter self.clean() def clean(self): self.duration = self.meter.duration()
def main(): conn = create_connection(DATABASE) if (conn is None): print("Could not connect to database") exit() print("Successfully Connected to " + DATABASE) print(run_sql(conn, "SELECT * from meters")) #run_sql(conn, "DROP TABLE IF EXISTS meters;") run_sql( conn, "CREATE TABLE IF NOT EXISTS meters(id integer PRIMARY KEY, meterIP string, active string check(active = 'running' or active = 'stopped'));" ) metersList = run_sql(conn, "SELECT * from meters") meterObjects = [] metersList = json.loads(metersList) for m in metersList: print(m) meterObjects.append(meter.Meter(m['id'], m['meterIP'], m['active'])) dt_string = datetime.now().strftime("%m.%d.%Y.%H:%M") print(dt_string) starttime = time.time() while (True): metersList = run_sql(conn, "SELECT * from meters") meterObjects = [] metersList = json.loads(metersList) dt_string = datetime.now().strftime("%m.%d.%Y.%H:%M") for m in metersList: print(m) meterObjects.append(meter.Meter(m['id'], m['meterIP'], m['active'])) for m in meterObjects: m.generateData(dt_string) print(str(m.id) + ": " + str(m.getData(dt_string))) time.sleep(60.0 - ((time.time() - starttime) % 60.0)) conn.close()
def __init__(self, master, *args, **kwargs): super(Mainframe, self).__init__(master, *args, **kwargs) self.meter = m.Meter(self, height=300, width=300) self.meter.setrange(20, 90) self.meter.pack() tk.Scale(self, width=15, from_=20, to=90, orient=tk.HORIZONTAL, command=self.setmeter).pack() tk.Button(self, text='Quit', width=15, command=master.destroy).pack()
def __init__(self, master): self.master = master master.title("Virtual Plant") cactus = " \n" cactus += " *-*,\n" cactus += " ,*\/|`| \ \n" cactus += " \' |'**, -\n" cactus += " \ `| | |/ ) \n" cactus += " | |'| , / \n" cactus += " |'| |, / \n" cactus += " __|_|_|_|__ \n" cactus += " [___________] \n" cactus += " | | \n" cactus += " | | \n" cactus += " | | \n" cactus += " |__________| \n" cactus += " |________| \n" self.label = Label(master, text=cactus, font=("Courier", 20)) self.label.pack() #create a function that creates functions that check each gauge self.example = Label(master, text="Hi there! Press enter to talk to me.") self.example.pack() self.water_meter = meter.Meter("Water") self.fert_meter = meter.Meter("Fertilizer") self.sun_meter = meter.Meter("Sunlight") self.love_meter = meter.Meter("Love") self.i = 0 self.user = "******" self.plant = "PLANT"
def __init__(self, master, id, text='', scale=(0, 300), *args, **kwargs): tk.Frame.__init__(self, master, *args, **kwargs) width = kwargs.get('width', 100) height = kwargs.get('height', 100) self.meter = m.Meter(self, width=width, height=height) meters[id]['meter'] = self.meter self.meter.setrange(scale[0], scale[1]) self.meter.pack()
def analysis(strDir): # 创建一个4列的表格 df = pd.DataFrame( columns=["meterid", "category", "similary", "exceptionnum"]) # 空列表 emptyGas = [] # os.listdir(strDir)返回指定的文件夹包含的文件或文件夹的名字的列表 for f in os.listdir(strDir): try: if f[-4:] == ".csv": idName = f[:-4] # 把目录和文件名合成一个路径 strPath = os.path.join(strDir, f) # 初始化Meter对象(表具单元对象) objMeter = meter.Meter(idName, strPath, '', '', True) # 加载数据 objMeter.loadData() if objMeter.isEmptyGas(): emptyGas.append(idName) # 计算相似性 objMeter.computeSimilaryByDTW() # 计算可能的异常点个数 objMeter.getExceptions() objMeter.getSmallFlowRatio() tmp = pd.DataFrame( { "meterid": idName, "category": objMeter._category, "similary": objMeter._similar, "exceptionnum": objMeter._exceptionNum, "smallratio": objMeter._smallRatio }, index=["0"]) df = df.append(tmp, ignore_index=True) except: print("error:" + f) return df, emptyGas
def __init__(self, master, *args, **kwargs): tk.Frame.__init__(self, master) meter_min = 0 meter_max = 1023 #Meter 1 col = 0 self.meter1 = m.Meter(self, height=600, width=600, label='Big Meter') self.meter1.setrange(meter_min, meter_max) self.meter1.grid(row=0, rowspan=2, column=col, sticky='nsew') ''' tk.Scale(self, width = 15, length = 500 ,from_ = meter_min, to = meter_max ,orient = tk.HORIZONTAL ,command = lambda(value): self.setmeter(value, self.meter1), ).grid(row=2, column=col) ''' tk.Button(self, command=self.sweep, text='sweep').grid(row=2, column=col) #Meter 2 col = 1 self.meter2 = m.Meter(self, height=300, width=300, label='Small Meter', tickcolor='black', face='white', needle='red', center='black', labelcolor='black') self.meter2.setrange(meter_min, meter_max) self.meter2.grid(row=0, column=col, sticky='nsew') #Meter 3 self.meter3 = m.Meter(self, height=300, width=300, label='Small Meter', tickcolor='yellow', face='#000066', needle='red', center='black', labelcolor='yellow') self.meter3.setrange(meter_min, meter_max) self.meter3.grid(row=1, column=col, sticky='nsew') tk.Scale( self, width=15, length=250, from_=meter_min, to=meter_max, orient=tk.HORIZONTAL, command=lambda (value): self.setmeters(value, self.meter2, self.meter3), ).grid(row=2, column=col) #Quit button tk.Button(self, text='Quit', width=30, command=master.destroy).grid(row=3, column=0, columnspan=2, pady=5)
def __init__(self, master, arg=None, *args, **kwargs): #super(Mainframe,self).__init__(master,*args,**kwargs) tk.Frame.__init__(self, master, *args, **kwargs) self.ip_address = None # ip address of current remote server self.arg = arg self.master = master self.google_api_key = '' if self.arg.google_api_key is not None: self.print('using google api key: %s' % self.arg.google_api_key) self.google_api_key = '&key=%s' % self.arg.google_api_key else: try: from PIL import ImageTk, Image import io self.ImageTk = ImageTk self.Image = Image self.io = io self.print('no google API key, using PIL and Yandex') except ImportError: self.print( 'No Google API key, or PIL library, maps are disabled') self.arg.geography = False self.ip_info = {} self.distance = 0 self.local_ip = self.arg.local_ip if self.local_ip is None: self.local_ip = self.get_local_ip( ) #get local external ip if we can self.meter_size = 300 #meter is square self.no_response = 'No Response from iperf3 Server' self.server_list = [ 'iperf.he.net', 'bouygues.iperf.fr', 'ping.online.net', 'ping-90ms.online.net', 'iperf.eenet.ee', 'iperf.volia.net', 'iperf.it-north.net', 'iperf.biznetnetworks.com', #speedtest.wtnet.de, 'iperf.scottlinux.com' ] self.server_list[0:0] = self.arg.ip_address self.port_list = [ '5200', '5201', '5202', '5203', '5204', '5205', '5206', '5207', '5208', '5209' ] self.max_options = ['OFF', 'Track Needle', 'Hold Peak'] self.max_range = 1000 self.min_range = 10 self.resolution = 10 #self.ranges = list(range(self.min_range, self.max_range+self.resolution, self.resolution)) self.ranges = [10, 30, 50, 100, 200, 400, 600, 800, 1000] self.duration = tk.Variable() self.threads = tk.Variable() self.server = tk.Variable() #self.server.trace('w', self.servercalback) self.server_port = tk.Variable() self.range = tk.Variable() self.reset_range = tk.Variable() self.threads.set('16') self.reset_range.set(self.arg.reset_range) self.read_config_file() #load data if config file exists self.get_ip_info(self.local_ip) #add any new servers in config file for k in self.ip_info.keys(): new_server = self.ip_info[k].get('server', None) self.print('Checking server: %s' % new_server) if new_server not in self.server_list and new_server is not None and new_server != self.local_ip: self.print('Adding new server to list: %s' % new_server) self.server_list.append(new_server) self.msg_label = tk.Label(self, text="Ping:") self.msg_label.grid(row=0, sticky=tk.E) self.ping_label = tk.Label(self, anchor='w', width=60) self.ping_label.grid(row=0, column=1, columnspan=3, sticky=tk.W) tk.Label(self, text="Download:").grid(row=2, sticky=tk.E) self.download_label = tk.Label(self, anchor='w', width=60) self.download_label.grid(row=2, column=1, columnspan=3, sticky=tk.W) tk.Label(self, text="Upload:").grid(row=3, sticky=tk.E) self.upload_label = tk.Label(self, anchor='w', width=60) self.upload_label.grid(row=3, column=1, columnspan=3, sticky=tk.W) self.map = None self.map_panel = tk.Label(self) tk.Label(self, text="Destination:").grid(row=4, sticky=tk.E) self.geography_label = tk.Label(self, anchor='w', width=60) self.geography_label.grid(row=4, column=1, columnspan=3, sticky=tk.W) self.geography = tk.Variable() self.geography.set(self.arg.geography) self.geography.trace( 'w', self.updategeography) #update range when value changes self.no_map = ''' R0lGODlhGAEYAXAAACH5BAEAAPwALAAAAAAYARgBhwAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwAr ZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCq mQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMA zDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzN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fIwx768Icu QAyiEIdIxCIa8YhITKISl8jEJjrxiVCMohSnSMUqWvGKWMyiFrfIxS568YtgDCGjGMdIxjKa8Yxo TKMa18jGNrrxjXCMoxznSMc62rE1AQEAOw== ''' self.meter = m.Meter(self, height=self.meter_size, width=self.meter_size) self.range.trace('w', self.updaterange) #update range when value changes self.range.set(self.arg.range) self.meter.set(0) self.meter.grid(row=5, column=0, columnspan=4) tk.Label(self, text="Server:").grid(row=6, sticky=tk.E) self.ipaddress = ttk.Combobox(self, textvariable=self.server, values=self.server_list, width=39) self.ipaddress.current(0) self.ipaddress.bind("<<ComboboxSelected>>", self.servercalback) self.ipaddress.grid(row=6, column=1, columnspan=2, sticky=tk.W) self.servercalback() #update current displayed map (if enabled) self.port = ttk.Combobox(self, textvariable=self.server_port, values=self.port_list, width=4) if self.arg.port in self.port_list: self.port.current(self.port_list.index(self.arg.port)) else: self.port_list.insert(0, self.arg.port) self.port.config(values=self.port_list, width=len(self.arg.port)) self.port.current(0) self.port.grid(row=6, column=3, sticky=tk.W) tk.Label(self, text="Progress:").grid(row=7, sticky=tk.E) self.progress_bar = ttk.Progressbar(self, orient="horizontal", length=325, mode="determinate") self.progress_bar.grid(row=7, column=1, columnspan=3, sticky=tk.W) tk.Label(self, text="Peak Mode:").grid(row=8, sticky=tk.E) self.max_mode_value = tk.StringVar() try: self.max_mode_value.set(self.max_options[arg.max_mode_index]) except ValueError: self.max_mode_value.set(self.max_options[0]) # default value self.max_mode = tk.OptionMenu(self, self.max_mode_value, *self.max_options) self.max_mode.grid(row=8, column=1, columnspan=2, sticky=tk.W) self.reset_range_box = tk.Checkbutton(self, text="Reset Range for Upload", variable=self.reset_range) self.reset_range_box.grid(row=8, column=2, sticky=tk.W) self.show_message( 'see https://iperf.fr/iperf-servers.php for details of servers') if self.local_ip == '' and self.arg.geography: self.geography.set(0) self.show_message( 'Unable to get local external IP address, maps are disabled', True) elif self.arg.geography: self.map_box = tk.Checkbutton(self, text="Show Map", variable=self.geography) self.map_box.grid(row=8, column=3, sticky=tk.W) tk.Label(self, text="Range:").grid(row=9, sticky=tk.W) self.range_box = ttk.Combobox(self, textvariable=self.range, values=self.ranges, width=4) self.range_box.grid(row=10, column=0, rowspan=2) self.duration_scale = tk.Scale(self, width=15, from_=10, to=30, orient=tk.HORIZONTAL, label='Test Duration', variable=self.duration) self.duration_scale.grid(row=9, column=1, rowspan=2) self.threads_scale = tk.Scale(self, width=15, from_=1, to=30, orient=tk.HORIZONTAL, label='Threads', variable=self.threads) self.threads_scale.grid(row=9, column=2, rowspan=2) self.start_button = tk.Button(self, text='Start', width=15, command=self.run_iperf) self.start_button.grid(row=9, column=3) self.quit = tk.Button(self, text='Quit', width=15, command=self.quit) self.quit.grid(row=10, column=3)
def __init__(self, master, *args, **kwargs): super(Window, self).__init__(master, *args, **kwargs) #display area #variable containers #self.cmsg1 = tk.StringVar() #self.cmsg1.set('0') #self.cmsg2 = tk.StringVar() #self.cmsg2.set('0') self.cmsg3 = tk.StringVar() self.cmsg3.set('0') #self.cmsg4 = tk.StringVar() #self.cmsg4.set('') self.dash = tk.LabelFrame(self, text="Notification Panel") self.dash.pack(fill="both", expand="yes") #speed notification self.speedNtf = tk.LabelFrame(self.dash, text="SPEED (km/h)") self.speedNtf.pack(fill="both", expand="yes", side=tk.LEFT) #speed meter self.meter1 = m.Meter(self.speedNtf, height=300, width=300) self.meter1.setrange(20, 90) self.meter1.pack() #speed label nofication #self.nlabel1 = tk.Label(self.speedNtf, font=("Helvetica", 80) #, fg = "red",textvariable = self.cmsg1 ) #self.nlabel1.pack() #temperature notification self.tempNtf = tk.LabelFrame(self.dash, text="TEMPERATURE (Degree Celsius)") self.tempNtf.pack(fill="both", expand="yes", side=tk.LEFT) #temperature meter self.meter2 = m.Meter(self.tempNtf, height=300, width=300) self.meter2.setrange(20, 90) self.meter2.pack() #temperature label notification #self.nlabel2 = tk.Label(self.tempNtf, font=("Helvetica", 80) #, fg = "red", textvariable = self.cmsg2) #self.nlabel2.pack() self.inNtf = tk.LabelFrame(self.dash, text="OTHER INTERNAL DATA") self.inNtf.pack(fill="both", expand="yes", side=tk.BOTTOM) self.nlabel3 = tk.Label(self.inNtf, font=("Helvetica", 40), fg="red", textvariable=self.cmsg3) self.nlabel3.pack(anchor=tk.CENTER) #notification from external eviron e.g traffic light self.xNtf = tk.LabelFrame(self.dash, text="TRAFFIC") self.xNtf.pack(fill="both", expand="yes", side=tk.BOTTOM) self.traf_indicator = tk.Canvas(self.xNtf, width=100, height=150) self.traf_indicator.pack(anchor=tk.CENTER) self.circle_ind = self.traf_indicator.create_oval(10, 50, 85, 125, fill='red') #traffic notification label #self.nlabel4 = tk.Label(self.xNtf, font=("Helvetica", 80) #, fg = "red", textvariable = self.cmsg4) #self.nlabel4.pack() #button area to initiate data reception self.ctrlArea = tk.LabelFrame(self.dash, text="Control") self.ctrlArea.pack(fill="both", expand="yes", side=tk.BOTTOM) self.ctrlBtn = tk.Button(self.ctrlArea, text="START", fg="red", command=self.canNotify) self.ctrlBtn.pack(anchor=tk.CENTER) #CAN Transmission setup self.bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
def setup_players(self): self.meters = {} # Make a civ for each player for i in range(self.num_players): uipos = UI_POSITIONS[self.num_players][i] if uipos.x == 1: uipos.x = self.game.game_resolution.x - 104 if uipos.y == 1: uipos.y = self.game.game_resolution.y - 60 c = civ.MultiplayerCiv(self, uipos) c.worker_loss = 1 c.color = PLAYER_COLORS[i] c.name = PLAYER_NAMES[i] self.player_civs.append(c) self.player_input_sms[i] = states.Machine( inputstates.CursorState(self, c, self.game.player_inputs[i].input_type)) self.player_game_speed_inputs[c] = 0 self.meters[c] = {} for j, r in enumerate(['iron', 'ice', 'gas']): self.meters[c][r] = meter.Meter(V2(uipos.x + 19, uipos.y + 3 + j * 14), 80, 9, economy.RESOURCE_COLORS[r], c.upgrade_limits.data[r], tick_x=120) self.meters[c][r].stay = True self.ui_group.add( simplesprite.SimpleSprite( V2(uipos.x + 6, uipos.y + 2 + j * 14), "assets/i-%s.png" % r)) self.ui_group.add(self.meters[c][r]) bp = None if uipos.x < self.game.game_resolution.x / 2: bp = V2(uipos.x + 110, uipos.y + 5) else: bp = V2(uipos.x - 50, uipos.y + 5) ub = button.Button( bp, "Up", "small", (lambda c: (lambda: self.player_mouse_click_upgrade(c)) )(c), # Closure to capture civ None, None, "assets/i-iron.png", PICO_LIGHTGRAY, fixed_width=46) ub.visible = False self.ui_group.add(ub) self.player_upgrade_buttons[i] = ub ut = text.Text("", "small", bp + V2(24, 22), shadow=PICO_BLACK) ut.offset = (0.5, 0) self.ui_group.add(ut) self.player_upgrade_texts[i] = ut # target target = text.Text("", "small", uipos + V2(6, 44), shadow=PICO_BLACK, multiline_width=200) self.ui_group.add(target) self.player_targets[i] = target self.radar = Explosion(V2(300, 180), [PICO_GREEN], 1.25, self.game.game_resolution.x) self.ui_group.add(self.radar)
def test_constructor(self): log_obj = log.Log() met = meter.Meter(log_obj) self.assertIsInstance(met.log, logging.Logger)
async def produce() -> None: broker_address = cfg.BROKER_ADDRESS broker_exchange_name = cfg.EXCHANGE_NAME broker_queue_name = cfg.QUEUE_NAME # Creating a broker client to connect to RabbitMQ broker_client = BrokerClient(broker_address, broker_exchange_name, broker_queue_name) meter_log.info( "Created Broker Client using address %s, exchange %s, queue %s" % (broker_address, broker_exchange_name, broker_queue_name)) # Creating meters mocking few houses in a neighbourhood meter_house_a = meter.Meter("HOUSE_A") meter_house_b = meter.Meter("HOUSE_B") meter_house_c = meter.Meter("HOUSE_C") # Publisher which publishes the message to the RabbitMQ queue publisher = Publisher(broker_client) try: # Connect to the broker using the broker client await publisher.connect_to_broker() # publish messages after every PRODUCER_TIME_INTERVAL while True: meter_log.info("Sleeping for %d seconds" % cfg.PRODUCER_TIME_INTERVAL) time.sleep(cfg.PRODUCER_TIME_INTERVAL) pv_house_a = await meter_house_a.generate_power_value() meter_log.info( "Sending message to broker from house meter HOUSE_A") await publisher.publish(pv_house_a) meter_log.info("Sleeping for %d seconds" % cfg.PRODUCER_TIME_INTERVAL) time.sleep(cfg.PRODUCER_TIME_INTERVAL) pv_house_b = await meter_house_b.generate_power_value() meter_log.info( "Sending message to broker from house meter HOUSE_B") await publisher.publish(pv_house_b) meter_log.info("Sleeping for %d seconds" % cfg.PRODUCER_TIME_INTERVAL) time.sleep(cfg.PRODUCER_TIME_INTERVAL) pv_house_c = await meter_house_c.generate_power_value() meter_log.info( "Sending message to broker from house meter HOUSE_C") await publisher.publish(pv_house_c) except KeyboardInterrupt: meter_log.info("key board interrupted, Exiting the program") except AMQPConnectionError as e: meter_log.error(e) except Exception as e: meter_log.error(e) finally: meter_log.info("Orchestrator disconnecting from the publisher") await publisher.disconnect_from_broker() meter_log.info( "Finished: Orchestrator disconnected from the publisher") sys.exit(0)
def __init__(self, master, *args, **kwargs): super(Window, self).__init__(master, *args, **kwargs) #display the meters self.dialsPanel = tk.LabelFrame(self, text="Monitor Panel") self.dialsPanel.pack(fill="both", expand="yes") #Label for meter1 self.mlabel1 = tk.Label(self.dialsPanel, text="SPEED") self.mlabel1.pack(side=tk.LEFT) #Label for meter2 self.mlabel2 = tk.Label(self.dialsPanel, text="TEMPERATURE") self.mlabel2.pack(side=tk.RIGHT) #speed meter self.meter1 = m.Meter(self.dialsPanel, height=300, width=300) self.meter1.setrange(20, 90) self.meter1.pack(side=tk.LEFT) #temperature meter self.meter2 = m.Meter(self.dialsPanel, height=300, width=300) self.meter2.setrange(20, 90) self.meter2.pack(side=tk.RIGHT) #display the controllers self.controlPanel = tk.LabelFrame(self, text="Control Panel") self.controlPanel.pack(fill="both", expand="yes") #variables for collecting set values self.var1 = tk.DoubleVar() self.var2 = tk.DoubleVar() #slider controls self.speedCtrl = tk.Scale(self.controlPanel, label="SPEED", fg="red", width=15, variable=self.var1, from_=20, to=90, orient=tk.HORIZONTAL, command=self.setSpeed) self.speedCtrl.pack(side=tk.LEFT) self.tempCtrl = tk.Scale(self.controlPanel, label="TEMPERATURE", fg="red", width=15, variable=self.var2, from_=20, to=90, orient=tk.HORIZONTAL, command=self.setTemp) self.tempCtrl.pack(side=tk.LEFT) #button for sending data on network self.tempBtn = tk.Button(self.controlPanel, text="SEND TEMPERATURE", fg="red", command=self.sendTemp) self.tempBtn.pack(side=tk.RIGHT) self.speedBtn = tk.Button(self.controlPanel, text="SEND SPEED", fg="red", command=self.sendSpeed) self.speedBtn.pack(side=tk.RIGHT) #labels - temporal self.label1 = tk.Label(self) self.label1.pack() self.label2 = tk.Label(self) self.label2.pack()