diff --git a/framework.yaml b/framework.yaml index ad466d1..49437a3 100644 --- a/framework.yaml +++ b/framework.yaml @@ -8,5 +8,5 @@ spec: package: requirements.txt # 설치할 Python 패키지 정보 파일입니다.(기본 값은 requirement.txt 입니다.) runtime: python3.9 stackbase: - tagName: v2.0.0 # Stackbase(gitea)에 릴리즈 태그명 입니다. + tagName: v2.0.1 # Stackbase(gitea)에 릴리즈 태그명 입니다. repoName: aquarack-sensor-collector # Satackbase(gitea)에 저장될 저장소 이릅니다. diff --git a/main.py b/main.py index ca6ae60..42853de 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,8 @@ def get_modbus(evt, serial_obj, file_path): evt.wait() evt.clear() - with open(os.path.join(file_path, 'control.json'), 'r') as f: + # with open(os.path.join(file_path, 'control.json'), 'r') as f: + with open('./control.json', 'r') as f: control_data = json.load(f) pre_dict = control_data.copy() @@ -42,7 +43,8 @@ def get_modbus(evt, serial_obj, file_path): # print(f'cdu_digital:{cdu_digital.bits}') if control_data['set_zero_temperature'] == 'y': - with open(os.path.join(file_path, 'config.json'), 'r') as f: + # with open(os.path.join(file_path, 'config.json'), 'r') as f: + with open('./config.json', 'r') as f: config_data = json.load(f) for i, j in enumerate(a_col): @@ -51,7 +53,8 @@ def get_modbus(evt, serial_obj, file_path): control_data['set_zero_temperature'] = 'n' - with open(os.path.join(path, 'config.json'), 'w') as f: + # with open(os.path.join(path, 'config.json'), 'w') as f: + with open('./config.json', 'w') as f: json.dump(config_data, f, indent=4) g_zero_point[0] = config_data['ref_zero_point']['oilInFlowRate'] @@ -95,7 +98,7 @@ def get_modbus(evt, serial_obj, file_path): try: if control_data['mode'] == 'auto': - if control_data['cmd'] == 'init': + if control_data['cmd'] == 'init': # 방어코드 필요 if cmd_sub_status == 'None': valve_status[0], valve_status[1] = True, True res = serial_obj.write_coils(address=0, values=valve_status, slave=5) @@ -256,7 +259,7 @@ def get_modbus(evt, serial_obj, file_path): cmd_sub_status = 'None' control_data['cmd'] = 'None' - elif control_data['cmd'] == 'emer': + elif control_data['cmd'] == 'emer': # 어느 조건에서든 입력되면 바로 수행 if cmd_sub_status == 'None': valve_status[0], valve_status[1] = False, False res = serial_obj.write_coils(address=0, values=valve_status, slave=5) @@ -325,7 +328,8 @@ def get_modbus(evt, serial_obj, file_path): print(f'Device Setting Error: {e}') if pre_dict != control_data: - with open(os.path.join(path, 'control.json'), 'w') as f: + # with open(os.path.join(path, 'control.json'), 'w') as f: + with open('./control.json', 'w') as f: json.dump(control_data, f, indent=4) def get_sensor(evt, serial_obj): @@ -393,8 +397,8 @@ def runAction(): time.sleep(sleep_time) if __name__ == "__main__": - os.system(f'sudo chmod 777 /dev/ttyS0') - os.system(f'sudo chmod 777 /dev/ttyS1') + os.system(f'chmod 777 /dev/ttyS0') + os.system(f'chmod 777 /dev/ttyS1') port_name_1 = '/dev/ttyS0' client1 = ModbusClient(port=port_name_1, baudrate=19200, parity='N', stopbits=1, bytesize=8, timeout=0.25) port_name_2 = '/dev/ttyS1' @@ -408,11 +412,13 @@ if __name__ == "__main__": g_zero_point = [0] * 2 - path = '/home/ecn-2u/Aquarack/21u' - with open(os.path.join(path, 'config.json'), 'r') as config: + # path = '/home/ecn-2u/Aquarack/21u' + # with open(os.path.join(path, 'config.json'), 'r') as config: + with open('./config.json', 'r') as config: cfg_data = json.load(config) - with open(os.path.join(path, 'control.json'), 'r') as control: + # with open(os.path.join(path, 'control.json'), 'r') as control: + with open('./control.json', 'r') as control: ctl_data = json.load(control) len_a_col = len(cfg_data['cdu_analog_list'])