format
This commit is contained in:
parent
4ce9f773e7
commit
a18e28f8ca
|
@ -12,7 +12,9 @@ s.connect((host, port))
|
||||||
# print(s)
|
# print(s)
|
||||||
def send_data(data):
|
def send_data(data):
|
||||||
response = None
|
response = None
|
||||||
# if data["reqType"] != 'AddRCC':
|
if data["reqType"] == 'AddRCC':
|
||||||
|
return
|
||||||
|
pass
|
||||||
s.send(str.encode(json.dumps(data)))
|
s.send(str.encode(json.dumps(data)))
|
||||||
response_data = s.recv(1024)
|
response_data = s.recv(1024)
|
||||||
response = json.loads(response_data)
|
response = json.loads(response_data)
|
||||||
|
@ -23,12 +25,14 @@ def send_data(data):
|
||||||
elif data["reqType"] == 'command':
|
elif data["reqType"] == 'command':
|
||||||
# pprint({"request":data["cmdData"], "response":response["cmdReply"]})
|
# pprint({"request":data["cmdData"], "response":response["cmdReply"]})
|
||||||
return response["cmdReply"]
|
return response["cmdReply"]
|
||||||
|
elif data["reqType"] == 'AddRCC':
|
||||||
|
return response["cmdReply"]
|
||||||
else:
|
else:
|
||||||
pprint(response)
|
pprint(response)
|
||||||
|
|
||||||
def make_addrcc_data(q, e="1"):
|
def make_addrcc_data(q, emptyList=0):
|
||||||
# print(q)
|
# print(q)
|
||||||
return {"dsID": "www.hc-system.com.HCRemoteCommand","reqType":"AddRCC","emptyList":e,"packID":"0","instructions":q}
|
return {"dsID": "www.hc-system.com.HCRemoteCommand","reqType":"AddRCC","emptyList":str(emptyList),"packID":"0","instructions":q}
|
||||||
def make_command_data(q):
|
def make_command_data(q):
|
||||||
return {"dsID": "www.hc-system.com.RemoteMonitor","reqType":"command","packID":"0","cmdData":q}
|
return {"dsID": "www.hc-system.com.RemoteMonitor","reqType":"command","packID":"0","cmdData":q}
|
||||||
def make_query_data(q):
|
def make_query_data(q):
|
||||||
|
@ -49,14 +53,24 @@ print('axis', axis_coord)
|
||||||
print('world', world_coord)
|
print('world', world_coord)
|
||||||
print('remote command count', send_data(make_query_data(['RemoteCmdLen'])))
|
print('remote command count', send_data(make_query_data(['RemoteCmdLen'])))
|
||||||
|
|
||||||
|
line_speed = 80.0
|
||||||
|
line_smooth = 9
|
||||||
|
line_tool = 1
|
||||||
|
|
||||||
|
global_speed = 50
|
||||||
|
physical_speed = 8
|
||||||
|
# laser_id = 15
|
||||||
|
laser_id = 14
|
||||||
|
filename = 'half-sphere-no-angle'
|
||||||
|
|
||||||
|
pass_size = 2
|
||||||
|
|
||||||
def make_world_step(type, p):
|
def make_world_step(type, p):
|
||||||
speed= 80.0
|
|
||||||
smooth= 9
|
|
||||||
step = {
|
step = {
|
||||||
"oneshot": "0",
|
"oneshot": "0",
|
||||||
"delay":"0.0",
|
"delay":"0.0",
|
||||||
"speed":str(speed),"smooth":str(smooth),
|
"speed":str(line_speed),"smooth":str(line_smooth),
|
||||||
"coord":"0","tool":"1",
|
"coord":"0","tool":str(line_tool),
|
||||||
"ckStatus":"0x3F",
|
"ckStatus":"0x3F",
|
||||||
}
|
}
|
||||||
if type == 'line':
|
if type == 'line':
|
||||||
|
@ -71,19 +85,20 @@ def make_world_step(type, p):
|
||||||
m0,m1,m2,m3,m4,m5, m0_p, m1_p,m2_p,m3_p,m4_p,m5_p=p
|
m0,m1,m2,m3,m4,m5, m0_p, m1_p,m2_p,m3_p,m4_p,m5_p=p
|
||||||
step.update({
|
step.update({
|
||||||
"action": "17",
|
"action": "17",
|
||||||
"m0": x + m0, "m1": y + m1, "m2": z + m2,
|
"m0": round(x + m0,3), "m1": round(y + m1,3), "m2": round(z + m2,3),
|
||||||
"m3": u + m3, "m4": v + m4, "m5": w + m5,
|
"m3": round(u + m3,3), "m4": round(v + m4,3), "m5": round(w + m5,3),
|
||||||
"m6": 0, "m7": 0,
|
"m6": 0, "m7": 0,
|
||||||
"m0_p": x + m0_p, "m1_p": y + m1_p, "m2_p": z + m2_p,
|
"m0_p": round(x + m0_p,3), "m1_p": round(y + m1_p,3), "m2_p": round(z + m2_p,3),
|
||||||
"m3_p": u + m3_p, "m4_p": v + m4_p, "m5_p": w + m3_p,
|
"m3_p": round(u + m3_p,3), "m4_p": round(v + m4_p,3), "m5_p": round(w + m3_p,3),
|
||||||
"m6_p": 0, "m7_p": 0,
|
"m6_p": 0, "m7_p": 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
for s in step:
|
for s in step:
|
||||||
step[s] = str(step[s])
|
step[s] = str(step[s])
|
||||||
return step
|
return step
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
with open('data/half-sphere.nc.result', 'r') as fp:
|
with open(f'data/{filename}.nc.result', 'r') as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
data = line.strip().split(' ')
|
data = line.strip().split(' ')
|
||||||
prep = {}
|
prep = {}
|
||||||
|
@ -98,24 +113,25 @@ with open('data/half-sphere.nc.result', 'r') as fp:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Изменили глобальную скорость на 11%
|
|
||||||
send_data(make_command_data(['modifyGSPD', str(50 * 10)]))
|
# Изменили глобальную скорость на global_speed%
|
||||||
# Поставили Y026 в TRUE
|
send_data(make_command_data(['modifyGSPD', str(global_speed * 10)]))
|
||||||
# send_data(make_addrcc_data([
|
|
||||||
# {"oneshot":"0", "action":"200","type":"0","io_status":"0", "point":"15"},
|
|
||||||
# {"oneshot":"0", "action":"200","type":"0","io_status":"0", "point":"15", "delay":"1"},
|
|
||||||
# ]))
|
|
||||||
send_data(make_addrcc_data([
|
send_data(make_addrcc_data([
|
||||||
{"oneshot":"0", "action":"200","type":"0","io_status":"1", "point":"14"},
|
# Включили физическую скорость
|
||||||
# {"oneshot":"0", "action":"51","isUse":"1","speed":str(8*1000)}
|
{"oneshot":"0", "action":"51","isUse":"1","speed":str(physical_speed*1000)},
|
||||||
|
# Поставили Y026 (laser id + 11) в TRUE -- ЛАЗЕР!!!!
|
||||||
|
{"oneshot":"0", "action":"200","type":"0","io_status":"1", "point":str(laser_id)},
|
||||||
|
], 1))
|
||||||
|
|
||||||
|
for i in range(pass_size, len(result) + 1, pass_size):
|
||||||
|
print(f"Отправили на устройство команды {i - pass_size} ... {i}")
|
||||||
|
send_data(make_addrcc_data(result[i-pass_size:i]))
|
||||||
|
|
||||||
|
send_data(make_addrcc_data([
|
||||||
|
{"oneshot":"0", "action":"51","isUse":"0"},
|
||||||
|
{"oneshot":"0", "action":"200","type":"0","io_status":"0", "point":str(laser_id)},
|
||||||
]))
|
]))
|
||||||
for r in result:
|
|
||||||
send_data(make_addrcc_data([r], '0'))
|
|
||||||
# send_data(make_addrcc_data(result[10:20]))
|
|
||||||
send_data(make_addrcc_data([
|
|
||||||
{"oneshot":"0", "action":"200","type":"0","io_status":"0", "point":"14"},
|
|
||||||
# {"oneshot":"0", "action":"51","isUse":"0"},
|
|
||||||
], '0'))
|
|
||||||
print('remote command count', send_data(make_query_data(['RemoteCmdLen'])))
|
print('remote command count', send_data(make_query_data(['RemoteCmdLen'])))
|
||||||
send_data(make_command_data(['actionSingleCycle']))
|
send_data(make_command_data(['actionSingleCycle']))
|
||||||
# send_data(make_command_data(['actionStop']))
|
# send_data(make_command_data(['actionStop']))
|
Loading…
Reference in New Issue