def startRoutine(self): state = int(self.counter.get()) if state > 1: state = state - 1 self.lbl.configure(text=str(state)) self.counter.set(state) self.lbl.after(1000, self.startRoutine) elif state == 1: state = state - 1 self.lbl.configure(text="Messung läuft", font=('Arial',24)) self.counter.set(state) self.lbl.after(100, self.startRoutine) else: # arduino alcohol/sensor detection global sensorData arduinoI2C.sendData(11) time.sleep(10) sensorData = arduinoI2C.readSensors() sensorData.pop(0) print(sensorData) self.btn1.place_forget() self.btn2.place(relx=0.338, rely=0.688, height=81, width=261) self.lbl.configure(text="Messung fertig") # send all data to NN client = apiclient.nnclient("192.168.178.29", 10000) # CHANGE TO IP data_query = client.formatdata(sensorData[2], sensorData[3],sensorData[0], sensorData[1], emoData) global nnvalues nnvalues = client.senddata(data_query,"query",1024) print(nnvalues)
def drinkC(self): self.btn1.place_forget() self.btn2.place_forget() self.btn3.place_forget() self.btn4.place(relx=0.725, rely=0.625, height=81, width=181) auswahl = helper.zahlZuordnung(self.auswahlC) #SEND TO ARDUINO arduinoI2C.sendData(auswahl) client = apiclient.nnclient("192.168.178.29", 10000) # CHANGE TO IP client.senddata(auswahl, "training", 1024)
def clientfirst(port, net): client1 = client.nnclient("localhost", port) i = 0 count_0 = 0 count_1 = 0 count_2 = 0 count_3 = 0 count_4 = 0 count_5 = 0 count_6 = 0 count_7 = 0 count_8 = 0 count_9 = 0 while i < inrange: emotion = random.randrange(7) ran_floats = [emotion for _ in range(50)] temp_temperature = random.randrange(256) print("Random Temperature:", temp_temperature) temp_hum = random.randrange(256) print("Random Humidity", temp_hum) temp_alc = random.randrange(256) print("Random Alcohol", temp_alc) temp_dist = random.randrange(256) print("Random Distance", temp_dist) temp_choose = random.randrange(10) print("Random Choosing", temp_choose) data_query = client1.formatdata(temp_temperature, temp_hum, temp_alc, temp_dist, ran_floats) nnvalues = client1.senddata(data_query, "query", 1024) time.sleep(0.1) client1.senddata(temp_choose, "training", 1024) nnvalues_short = nnvalues[:3] if 0 in nnvalues_short: count_0 = count_0 + 1 if 1 in nnvalues_short: count_1 = count_1 + 1 if 2 in nnvalues_short: count_2 = count_2 + 1 if 3 in nnvalues_short: count_3 = count_3 + 1 if 4 in nnvalues_short: count_4 = count_4 + 1 if 5 in nnvalues_short: count_5 = count_5 + 1 if 6 in nnvalues_short: count_6 = count_6 + 1 if 7 in nnvalues_short: count_7 = count_7 + 1 if 8 in nnvalues_short: count_8 = count_8 + 1 if 9 in nnvalues_short: count_9 = count_9 + 1 i = i + 1 print(i) plt.plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [ count_0, count_1, count_2, count_3, count_4, count_5, count_6, count_7, count_8, count_9 ], "ro") plt.ylabel(net) plt.show()
elif wfall == "9": question = namee.fall9 elif wfall == "0": question = namee.fall0 elif wfall == "custom": print("Choose your stats...") question = [0,0,0,0,0,0] question[1] = int(input("Temperature 0-255:")) question[2] = int(input("Humidity 0-255:")) question[3] = int(input("Alcohol 0-255:")) question[4] = int(input("Distance 0-255:")) question[5] = int(input("Main Emotion 0-6:")) else: print("dont know what. So, choose fall1.") question = namee.fall1 ran_floats = [(question[5]) for _ in range(50)] temp_temperature = question[1] print("Random Temperature:", temp_temperature) temp_hum = question[2] print("Random Humidity", temp_hum) temp_alc = question[3] print("Random Alcohol", temp_alc) temp_dist = question[4] print("Random Distance", temp_dist) client = api_client_cocktail_nn.nnclient("localhost", 10000) data_query = client.formatdata(temp_temperature, temp_hum, temp_alc, temp_dist, ran_floats) nnvalues = client.senddata(data_query, "query", 1024) time.sleep(2) client.senddata((question[0]), "training", 1024)