feeding
This commit is contained in:
@ -3,44 +3,66 @@ import socket
|
||||
import binascii
|
||||
from pymodbus.client import ModbusTcpClient
|
||||
from pymodbus.exceptions import ModbusException
|
||||
from config.settings import Settings
|
||||
|
||||
|
||||
class RelayController:
|
||||
# 继电器映射
|
||||
DOOR_UPPER = 'door_upper' # DO0 - 上料斗滑动
|
||||
DOOR_LOWER_1 = 'door_lower_1' # DO1 - 上料斗出砼门
|
||||
DOOR_LOWER_2 = 'door_lower_2' # DO2 - 下料斗出砼门
|
||||
BREAK_ARCH_UPPER = 'break_arch_upper' # DO3 - 上料斗破拱
|
||||
BREAK_ARCH_LOWER = 'break_arch_lower' # DO4 - 下料斗破拱
|
||||
FAST_STOP = 'fast_stop' # DO1 - 急停
|
||||
UPPER_TO_JBL = 'upper_to_jbl' # DO2 - 上料斗到搅拌楼
|
||||
UPPER_TO_ZD = 'upper_to_zd' # DO3 - 上料斗到振捣室
|
||||
# DOOR_UPPER = 'door_upper' # DO0 - 上料斗滑动
|
||||
DOOR_LOWER_OPEN = 'door_lower_open' # DO1 - 下料斗出砼门开角度
|
||||
DOOR_LOWER_CLOSE = 'door_lower_close' # DO2 - 下料斗出砼门关角度(角度在7.5以下可关闭信号)
|
||||
DOOR_UPPER_OPEN = 'door_upper_open' # DO3 - 上料斗开
|
||||
DOOR_UPPER_CLOSE = 'door_upper_close' # DO4 - 上料斗关
|
||||
BREAK_ARCH_UPPER = 'break_arch_upper' # DO3 - 上料斗震动
|
||||
BREAK_ARCH_LOWER = 'break_arch_lower' # DO4 - 下料斗震动
|
||||
DIRECT_LOWER_FRONT = 'direct_lower_front' # DO5 - 下料斗前
|
||||
DIRECT_LOWER_BEHIND = 'direct_lower_behind' # DO6 - 下料斗后
|
||||
DIRECT_LOWER_LEFT = 'direct_lower_left' # DO7 - 下料斗左
|
||||
DIRECT_LOWER_RIGHT = 'direct_lower_right' # DO8 - 下料斗右
|
||||
|
||||
def __init__(self, host='192.168.0.18', port=50000):
|
||||
def __init__(self, host='192.168.250.62', port=50000):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.modbus_client = ModbusTcpClient(host, port=port)
|
||||
|
||||
#遥1 DO 7 左 DO8 右 角度 摇2:DO 12上 13下 14 往后 15往前
|
||||
# 继电器命令(原始Socket)
|
||||
self.relay_commands = {
|
||||
self.DOOR_UPPER: {'open': '00000000000601050000FF00', 'close': '000000000006010500000000'},
|
||||
self.DOOR_LOWER_1: {'open': '00000000000601050001FF00', 'close': '000000000006010500010000'},
|
||||
self.DOOR_LOWER_2: {'open': '00000000000601050002FF00', 'close': '000000000006010500020000'},
|
||||
self.BREAK_ARCH_UPPER: {'open': '00000000000601050003FF00', 'close': '000000000006010500030000'},
|
||||
self.BREAK_ARCH_LOWER: {'open': '00000000000601050004FF00', 'close': '000000000006010500040000'}
|
||||
self.FAST_STOP: {'open': '00000000000601050000FF00', 'close': '000000000006010500000000'},
|
||||
self.UPPER_TO_JBL: {'open': '00000000000601050001FF00', 'close': '000000000006010500010000'},
|
||||
self.UPPER_TO_ZD: {'open': '00000000000601050002FF00', 'close': '000000000006010500020000'},
|
||||
self.DOOR_LOWER_OPEN: {'open': '00000000000601050006FF00', 'close': '00000000000601050006FF00'},
|
||||
self.DOOR_LOWER_CLOSE: {'open': '00000000000601050007FF00', 'close': '000000000006010500070000'},
|
||||
self.DOOR_UPPER_OPEN: {'open': '00000000000601050003FF00', 'close': '000000000006010500030000'},
|
||||
self.DOOR_UPPER_CLOSE: {'open': '00000000000601050004FF00', 'close': '000000000006010500040000'},
|
||||
self.BREAK_ARCH_UPPER: {'open': '0000000000060105000AFF00', 'close': '0000000000060105000A0000'},
|
||||
self.BREAK_ARCH_LOWER: {'open': '00000000000601050005FF00', 'close': '000000000006010500050000'},
|
||||
self.DIRECT_LOWER_FRONT: {'open': '00000000000601050005FF00', 'close': '000000000006010500050000'},
|
||||
self.DIRECT_LOWER_BEHIND: {'open': '00000000000601050005FF00', 'close': '000000000006010500050000'},
|
||||
self.DIRECT_LOWER_LEFT: {'open': '00000000000601050005FF00', 'close': '000000000006010500050000'},
|
||||
self.DIRECT_LOWER_RIGHT: {'open': '00000000000601050005FF00', 'close': '000000000006010500050000'}
|
||||
}
|
||||
|
||||
self.settings = Settings()
|
||||
# 读取状态命令
|
||||
self.read_status_command = '000000000006010100000008'
|
||||
|
||||
# 设备位映射
|
||||
self.device_bit_map = {
|
||||
self.DOOR_UPPER: 0,
|
||||
self.DOOR_LOWER_1: 1,
|
||||
self.DOOR_LOWER_2: 2,
|
||||
self.FAST_STOP: 0,
|
||||
self.UPPER_TO_JBL: 1,
|
||||
self.UPPER_TO_ZD: 2,
|
||||
self.BREAK_ARCH_UPPER: 3,
|
||||
self.BREAK_ARCH_LOWER: 4
|
||||
}
|
||||
|
||||
def send_command(self, command_hex):
|
||||
"""发送原始Socket命令"""
|
||||
if not self.settings.debug_feeding:
|
||||
return None
|
||||
|
||||
try:
|
||||
byte_data = binascii.unhexlify(command_hex)
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
|
||||
Reference in New Issue
Block a user