import json import socket import struct from configparser import ConfigParser import time import modbus_tk.defines as cst import modbus_tk.modbus_tcp as modbus_tcp import snap7 from lib.logger.log import Logger # 日志对象 logger = Logger(file_name='communication') # 导入配置文件 config = ConfigParser() config.read("../config.ini", encoding='UTF-8') mis_host = config.get('STATES', 'mis_host') # MIS-Server的ip mis_port = config.getint('STATES', 'mis_port') # MIS-Server的端口 one_car_host = config.get('L2', 'one_car_host') # 1号行车的ip two_car_host = config.get('L2', 'two_car_host') # 1号行车的ip h3u_host = config.get('STATES', 'h3u_host') # h3u的ip h3u_port = config.getint('STATES', 'h3u_port') # h3u的端口号 # 程序接口 local_port = 1101 # 本程序端口号 default = 65535 # 默认数值 one_s7_slot_number = 0 # s7-1500的槽号 one_s7_rack_number = 0 # s7-1500的机架号 one_s7_data_type = 132 # s7-1500的数据类型:DB块、M区、I区、Q区 one_s7_db_number = 1 # s7-1500的DB块号 one_s7_db_start = 0 # s7-1500的起始地址
import socket import struct from configparser import ConfigParser import snap7 from lib.logger.log import Logger # 日志对象 logger = Logger(file_name='StatesClient') # 导入配置文件 config = ConfigParser() config.read("../config.ini", encoding='UTF-8') mis_host = config.get('STATES', 'mis_host') # MIS-Server的ip mis_port = config.getint('STATES', 'mis_port') # MIS-Server的端口 s7_host = config.get('STATES', 's7_host') # s7-1500的ip h3u_host = config.get('STATES', 'h3u_host') # h3u的ip h3u_port = config.getint('STATES', 'h3u_port') # h3u的端口号 # 程序修改参数 s7_slot_number = 0 # s7-1500的槽号 s7_rack_number = 0 # s7-1500的机架号 s7_data_type = 132 # s7-1500的数据类型:DB块、M区、I区、Q区 s7_db_number = 1 # s7-1500的DB块号 s7_db_start = 0 # s7-1500的起始地址 s7_db_size = 44 # s7-1500的DB块数据量,单位:字节 class GetStates: def __init__(self): """
import time import uuid from l3.dust_warehouse_listening import DustWarehouseListening from l3.feed_port_listening import ListenFeeding from l3.generate_task import GenerateTask from l3.upload_port_listening import ListenUploading from l3.utils.modbus_client import ModbusClient from l3.utils.variables import feed_communication_address, upload_communication_address, tri_d_status_address, \ feed_communication_status_dict, upload_communication_status_dict, tri_d_status_dict, mode_address, \ control_command_address, control_command_dict, mode_dict, feed_port_num, \ task_priority, active, status_port, l2_port, upload_port_num, dust_warehouse_num, sub_warehouse_type_dict from lib.logger.log import Logger # 日志对象 logger = Logger(file_name='l3') def get_status_pool(): """ 判断各外围设备的状态 :return: bool,状态是否OK """ status_reader = ModbusClient(port=status_port) # 建立状态池连接 all_status_address = [ feed_communication_address, upload_communication_address, tri_d_status_address ] code = status_reader.mget(all_status_address) # 读取所有的设备状态 status = [ feed_communication_status_dict[code[0]],