1
0
Fork 0

최신 코드 2

This commit is contained in:
yjchu 2023-10-17 19:26:48 +09:00
parent 32615cdbda
commit 6a5545676f
1 changed files with 12 additions and 12 deletions

View File

@ -212,7 +212,7 @@ def cwt_thread(evt, chip_index, port_a_ai_id , port_a_do_id, port_b_ai_id , port
# PORT A # PORT A
port_a_do_value = [] port_a_do_value = []
for i in list(b[:16]): for i in list(do_value[:16]):
port_a_do_value.append(int(i)) port_a_do_value.append(int(i))
port_a_do_value = list(do_value[:16]) port_a_do_value = list(do_value[:16])
#print("port a do: ", port_a_do_value) #print("port a do: ", port_a_do_value)
@ -238,7 +238,7 @@ def cwt_thread(evt, chip_index, port_a_ai_id , port_a_do_id, port_b_ai_id , port
# PORT B # PORT B
port_b_do_value = [] port_b_do_value = []
for i in list(b[16:32]): for i in list(do_value[16:32]):
port_b_do_value.append(int(i)) port_b_do_value.append(int(i))
#print("port b do: ", port_b_do_value) #print("port b do: ", port_b_do_value)
try: try:
@ -442,7 +442,7 @@ def data_process_thread(data_queue, ch, chamber):
for i, value in enumerate(calculated_voltage_list): for i, value in enumerate(calculated_voltage_list):
if value <= 20000 and do[i] == 1: if value <= 20000 and do[i] == 1:
print(f"Updating count for index {i}") #print(f"Updating count for index {i}")
#element_counts = [x + 1 if y == 1 else x for x, y in zip(element_counts, do)] #element_counts = [x + 1 if y == 1 else x for x, y in zip(element_counts, do)]
@ -455,16 +455,16 @@ def data_process_thread(data_queue, ch, chamber):
#mult_element_count = [element_count[i] * do[i] for i in range(len(do))] #mult_element_count = [element_count[i] * do[i] for i in range(len(do))]
#이건 아닌거 같다 카운트는 계속 올라갈 거고 10일 때 DO가 켜지면 또 에러 발생임 #이건 아닌거 같다 카운트는 계속 올라갈 거고 10일 때 DO가 켜지면 또 에러 발생임
print("check do : " ,do) #print("check do : " ,do)
print("voltage list : ", calculated_voltage_list) #print("voltage list : ", calculated_voltage_list)
print("element cosunts : ", element_counts,"\r\n") #print("element cosunts : ", element_counts,"\r\n")
cycle_counts += 1 cycle_counts += 1
error_cnt_1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] error_cnt_1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for index, count in element_counts.items(): for index, count in element_counts.items():
if cycle_counts % 10 == 0: if cycle_counts % 10 == 0:
if count == 10: if count == 10:
print(f"Updating e_count for index {index}") #print(f"Updating e_count for index {index}")
#print(f"Error elements: {index}") #print(f"Error elements: {index}")
error_cnt_1[index] += 1 error_cnt_1[index] += 1
#error_cnt_1 = [error_cnt_1[index] +1 * do[index] for index in range(len(error_cnt_1))] #error_cnt_1 = [error_cnt_1[index] +1 * do[index] for index in range(len(error_cnt_1))]
@ -473,7 +473,7 @@ def data_process_thread(data_queue, ch, chamber):
#mult_error_cnt_1 = [x + 1 * y for x,y in zip(error_cnt_1, do)] //zip 함수 사용법 #mult_error_cnt_1 = [x + 1 * y for x,y in zip(error_cnt_1, do)] //zip 함수 사용법
print("check error_cnt_1 : ", error_cnt_1) #print("check error_cnt_1 : ", error_cnt_1)
#print("check multed value to do index : ", mult_error_cnt_1) #print("check multed value to do index : ", mult_error_cnt_1)
global do_dict global do_dict
@ -548,7 +548,7 @@ def data_process_thread(data_queue, ch, chamber):
print("data empty") print("data empty")
mqtt_msg = { mqtt_msg = {
"modelCode":"test4", "modelCode":"test4",
"assetCode":"NQ-R04-TEST-003", #나중에는 config에서 셋팅되는 값, or model 값으로 변경 (asset) "assetCode":"S0NQR0423090001", #나중에는 config에서 셋팅되는 값, or model 값으로 변경 (asset)
"dataType":"DATA", "dataType":"DATA",
"data": { "data": {
"channel": ch, # 채널 입력 <20> "channel": ch, # 채널 입력 <20>
@ -562,7 +562,7 @@ def data_process_thread(data_queue, ch, chamber):
else: else:
mqtt_msg = { mqtt_msg = {
"modelCode":"test4", "modelCode":"test4",
"assetCode":"NQ-R04-TEST-003", #나중에는 config에서 셋팅되는 값, or model 값으로 변경 (asset) "assetCode":"S0NQR0423090001", #나중에는 config에서 셋팅되는 값, or model 값으로 변경 (asset)
"dataType":"DATA", "dataType":"DATA",
"data": { "data": {
"channel": ch, # 채널 입력 <20> "channel": ch, # 채널 입력 <20>
@ -578,7 +578,7 @@ def data_process_thread(data_queue, ch, chamber):
# print(type(mqtt_msg['data']['list'][0]['do'][0])) # print(type(mqtt_msg['data']['list'][0]['do'][0]))
data_json_str = json.dumps(mqtt_msg, indent=4) data_json_str = json.dumps(mqtt_msg, indent=4)
print(data_json_str) #print(data_json_str)
publish_json_message(client, data_json_str) publish_json_message(client, data_json_str)
@ -599,7 +599,7 @@ def timer_event_loop(e1, e2):
e1.set() e1.set()
e2.set() e2.set()
time.sleep(1) time.sleep(0.1)
exit() exit()