2025-07-29 13:16:30 +08:00
|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
|
|
from Model.Position import Real_Position
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MoveType(Enum):
|
|
|
|
|
AXIS = 4
|
|
|
|
|
WORLD = 10
|
|
|
|
|
Cure = 17
|
|
|
|
|
|
|
|
|
|
class DATARequest:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.dsID = 'www.hc-system.com.RemoteMonitor'
|
|
|
|
|
self.reqType = 'query'
|
|
|
|
|
self.queryAddr = []
|
|
|
|
|
def toString(self):
|
|
|
|
|
model_str = '{'+f'"dsID":"{self.dsID}","reqType":"{self.reqType}","queryAddr":[' \
|
|
|
|
|
f'{self.queryAddr[0].toString()}]'+'}'
|
|
|
|
|
return model_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DataAddress:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.version = ''
|
|
|
|
|
self.curMold = ''
|
|
|
|
|
self.counterList = ''
|
|
|
|
|
self.counter_n = ''
|
|
|
|
|
self.curMode = 0
|
|
|
|
|
self.boardIONum = ''
|
|
|
|
|
self.input_n = ''
|
|
|
|
|
self.output_n = 0
|
|
|
|
|
self.axisNum = '6'
|
|
|
|
|
self.axis_n = ''
|
|
|
|
|
self.world_0 = 0
|
|
|
|
|
self.world_1 = 0
|
|
|
|
|
self.world_2 = 0
|
|
|
|
|
self.world_3 = 0
|
|
|
|
|
self.world_4 = 0
|
|
|
|
|
self.world_5 = 0
|
|
|
|
|
self.axis_0 = 0
|
|
|
|
|
self.axis_1 = 0
|
|
|
|
|
self.axis_2 = 0
|
|
|
|
|
self.axis_3 = 0
|
|
|
|
|
self.axis_4 = 0
|
|
|
|
|
self.axis_5 = 0
|
|
|
|
|
self.curAlarm = 0
|
|
|
|
|
self.curCycle = ''
|
|
|
|
|
self.lastCycle = ''
|
|
|
|
|
self.machineName = ''
|
|
|
|
|
self.curTorque_n = ''
|
|
|
|
|
self.curSpeed_n = ''
|
|
|
|
|
self.curAccount = ''
|
|
|
|
|
self.origin = ''
|
|
|
|
|
self.moldList = ''
|
|
|
|
|
self.isMoving = False
|
|
|
|
|
self.M_n = ''
|
|
|
|
|
self.toolCoord=0
|
2025-09-28 09:48:12 +08:00
|
|
|
self.RemoteCmdLen = 0
|
2025-07-29 13:16:30 +08:00
|
|
|
|
|
|
|
|
#return
|
|
|
|
|
def setPosition(self,w0,w1,w2,w3,w4,w5,a0,a1,a2,a3,a4,a5):
|
|
|
|
|
self.world_0 = float(w0)
|
|
|
|
|
self.world_1 = float(w1)
|
|
|
|
|
self.world_2 = float(w2)
|
|
|
|
|
self.world_3 = float(w3)
|
|
|
|
|
self.world_4 = float(w4)
|
|
|
|
|
self.world_5 = float(w5)
|
|
|
|
|
self.axis_0 = float(a0)
|
|
|
|
|
self.axis_1 = float(a1)
|
|
|
|
|
self.axis_2 = float(a2)
|
|
|
|
|
self.axis_3 = float(a3)
|
|
|
|
|
self.axis_4 = float(a4)
|
|
|
|
|
self.axis_5 = float(a5)
|
|
|
|
|
|
|
|
|
|
def getRealPosition(self):
|
|
|
|
|
real_position = Real_Position().init_position(self.world_0,self.world_1,self.world_2,self.world_3,self.world_4,self.world_5)
|
|
|
|
|
return real_position
|
|
|
|
|
|
|
|
|
|
def getAnglePosition(self):
|
|
|
|
|
real_position = Real_Position().init_position(self.axis_0,self.axis_1,self.axis_2,self.axis_3,self.axis_4,self.axis_5)
|
|
|
|
|
return real_position
|
|
|
|
|
def get_IO_bits(self):
|
|
|
|
|
io_bits_str = format(self.output_n, '032b')[::-1]
|
|
|
|
|
io_bits_arry = [bit == '1' for bit in io_bits_str]
|
|
|
|
|
return io_bits_arry
|
|
|
|
|
|
|
|
|
|
def setAngle(self,a0,a1,a2,a3,a4,a5):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def toString(self):
|
|
|
|
|
model_str = f'"curMode",' \
|
|
|
|
|
f'"world-0","world-1","world-2","world-3","world-4","world-5","axis-0","axis-1","axis-2","axis-3","axis-4","axis-5",' \
|
|
|
|
|
f'"curAlarm","isMoving","RemoteCmdLen","toolCoord","input-n","output-n","curSpeed-n"'
|
|
|
|
|
return model_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DATAReply:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.dsID = ''
|
|
|
|
|
self.reqType = ''
|
|
|
|
|
self.queryData = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def JsonToObject(self):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
class CMDRequest:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.dsID = 'www.hc-system.com.RemoteMonitor'
|
|
|
|
|
self.reqType = 'command'
|
|
|
|
|
self.cmdData = []
|
|
|
|
|
return
|
|
|
|
|
def toString(self):
|
|
|
|
|
model_str = '{'+f'"dsID":"{self.dsID}","reqType":"{self.reqType}","cmdData":'
|
|
|
|
|
if len(self.cmdData) != 0:
|
|
|
|
|
model_str = model_str+"["+','.join(f'"{item}"' for item in self.cmdData)+"]"+"}"
|
|
|
|
|
else:
|
|
|
|
|
model_str = model_str+"}"
|
|
|
|
|
return model_str
|
|
|
|
|
|
|
|
|
|
class CMDReply:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.dsID = 'www.hc-system.com.RemoteMonitor'
|
|
|
|
|
self.reqType = 'command'
|
|
|
|
|
self.cmdData = []
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Instruction:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.oneshot = 1
|
|
|
|
|
self.action = 4 #4 自由路径 10 姿势直线 17 姿势曲线
|
|
|
|
|
self.m0 = 0.0
|
|
|
|
|
self.m1 = 0.0
|
|
|
|
|
self.m2 = 0.0
|
|
|
|
|
self.m3 = 0.0
|
|
|
|
|
self.m0_p = 0.0
|
|
|
|
|
self.m1_p = 0.0
|
|
|
|
|
self.m2_p = 0.0
|
|
|
|
|
self.m3_p = 0.0
|
|
|
|
|
self.m4_p = 0.0
|
|
|
|
|
self.m5_p = 0.0
|
|
|
|
|
self.ckStatus = '0x3F'
|
|
|
|
|
self.speed = 10
|
|
|
|
|
self.smooth = 0
|
|
|
|
|
self.tool=2
|
|
|
|
|
self.IO = False
|
|
|
|
|
self.type = 0
|
|
|
|
|
self.io_status=1
|
|
|
|
|
self.point = 0
|
|
|
|
|
self.delay = 0
|
|
|
|
|
|
|
|
|
|
def toString(self):
|
|
|
|
|
if not self.IO :
|
|
|
|
|
model_str = f'"oneshot":"{self.oneshot}","action":"{self.action}","m0":"{self.m0}","m1":"{self.m1}","m2":"{self.m2}",' \
|
|
|
|
|
f'"m3":"{self.m3}","ckStatus":"{self.ckStatus}","speed":"{self.speed}",' \
|
|
|
|
|
f'"delay":"{self.delay}","smooth":"{self.smooth}","tool":"{self.tool}"'
|
|
|
|
|
if self.action == 17:
|
|
|
|
|
model_str = f'"oneshot":"{self.oneshot}","action":"{self.action}","m0":"{self.m0}","m1":"{self.m1}","m2":"{self.m2}",' \
|
|
|
|
|
f'"m3":"{self.m3}","m0_p":"{self.m0_p}","m1_p":"{self.m1_p}","m2_p":"{self.m2_p}",' \
|
|
|
|
|
f'"m3_p":"{self.m3_p}","ckStatus":"{self.ckStatus}","speed":"{self.speed}",' \
|
|
|
|
|
f'"delay":"{self.delay}","smooth":"{self.smooth}","tool":"{self.tool}"'
|
|
|
|
|
else:
|
|
|
|
|
model_str = f'"oneshot":"{self.oneshot}","action":"{200}","type":"{self.type}","io_status":"{self.io_status}"' \
|
|
|
|
|
f',"point":"{self.point}","delay":"{self.delay}"'
|
|
|
|
|
return model_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CMDInstructRequest:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.dsID = 'www.hc-system.com.HCRemoteCommand'
|
|
|
|
|
self.reqType = "AddRCC"
|
|
|
|
|
self.emptyList = '0' #清空机械臂的远程命令数据
|
|
|
|
|
self.instructions = []
|
|
|
|
|
|
|
|
|
|
def toString(self):
|
|
|
|
|
model_str = '{'+f'"dsID":"{self.dsID}","reqType":"{self.reqType}","emptyList":"{self.emptyList}"'
|
|
|
|
|
if len(self.instructions) != 0:
|
|
|
|
|
model_str = model_str+',"instructions":'+"[{"+self.instructions[0].toString()+"}]"+"}"
|
|
|
|
|
else:
|
|
|
|
|
model_str = model_str+',"instructions":'+"[]"+"}" #model_str+"}"
|
|
|
|
|
return model_str
|
|
|
|
|
|
|
|
|
|
class CMDInstructReply:
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.dsID = 'www.hc-system.com.HCRemoteCommand'
|
|
|
|
|
self.reqType = 'command'
|
|
|
|
|
self.cmdReply = []
|
|
|
|
|
return
|
|
|
|
|
|