diff --git a/AR4.py b/AR4.py index 1affaee..1ffd9ee 100644 --- a/AR4.py +++ b/AR4.py @@ -1146,6 +1146,80 @@ def executeRow(): else: displayPosition(response) + ##Offs L Command## + ## Linear offset + if (cmdType == "OFF L "): + if (moveInProc == 0): + moveInProc == 1 + + SPnewInex = command.find("[ PR: ") + SPendInex = command.find(" ] [") + xIndex = command.find(" X ") + yIndex = command.find(" Y ") + zIndex = command.find(" Z ") + rzIndex = command.find(" Rz ") + ryIndex = command.find(" Ry ") + rxIndex = command.find(" Rx ") + J7Index = command.find(" J7 ") + J8Index = command.find(" J8 ") + J9Index = command.find(" J9 ") + SpeedIndex = command.find(" S") + ACCspdIndex = command.find(" Ac ") + DECspdIndex = command.find(" Dc ") + ACCrampIndex = command.find(" Rm ") + + RoundingIndex = command.find(" Rnd ") + + WristConfIndex = command.find(" $") + + SP = str(command[SPnewInex+6:SPendInex]) + cx = eval("SP_"+SP+"_E1_EntryField").get() + cy = eval("SP_"+SP+"_E2_EntryField").get() + cz = eval("SP_"+SP+"_E3_EntryField").get() + crz = eval("SP_"+SP+"_E4_EntryField").get() + cry = eval("SP_"+SP+"_E5_EntryField").get() + crx = eval("SP_"+SP+"_E6_EntryField").get() + xVal = str(float(cx) + float(command[xIndex+3:yIndex])) + yVal = str(float(cy) + float(command[yIndex+3:zIndex])) + zVal = str(float(cz) + float(command[zIndex+3:rzIndex])) + rzVal = str(float(crz) + float(command[rzIndex+4:ryIndex])) + ryVal = str(float(cry) + float(command[ryIndex+4:rxIndex])) + rxVal = str(float(crx) + float(command[rxIndex+4:J7Index])) + J7Val = command[J7Index+4:J8Index] + J8Val = command[J8Index+4:J9Index] + J9Val = command[J9Index+4:SpeedIndex] + speedPrefix = command[SpeedIndex+1:SpeedIndex+3] + Speed = command[SpeedIndex+4:ACCspdIndex] + ACCspd = command[ACCspdIndex+4:DECspdIndex] + DECspd = command[DECspdIndex+4:ACCrampIndex] + + ACCramp = command[ACCrampIndex+4:RoundingIndex] + Rounding = command[RoundingIndex+5:WristConfIndex] + + WC = command[WristConfIndex+3:] + LoopMode = str(J1OpenLoopStat.get())+str(J2OpenLoopStat.get())+str(J3OpenLoopStat.get())+str(J4OpenLoopStat.get())+str(J5OpenLoopStat.get())+str(J6OpenLoopStat.get()) + DisWrist = str(DisableWristRot.get()) + command = "ML"+"X"+xVal+"Y"+yVal+"Z"+zVal+"Rz"+rzVal+"Ry"+ryVal+"Rx"+rxVal+"J7"+J7Val+"J8"+J8Val+"J9"+J9Val+speedPrefix+Speed+"Ac"+ACCspd+"Dc"+DECspd+"Rm"+ACCramp+"Rnd"+Rounding+"W"+WC+"Lm"+LoopMode+"Q"+DisWrist+"\n" + + #tab8.ElogView.insert(END, command) + #value=tab8.ElogView.get(0,END) + #pickle.dump(value,open("ErrorLog","wb")) + start = time.time() + cmdSentEntryField.delete(0, 'end') + cmdSentEntryField.insert(0,command) + ser.write(command.encode()) + ser.flushInput() + time.sleep(.1) + response = str(ser.readline().strip(),'utf-8') + end = time.time() + #manEntryField.delete(0, 'end') + #manEntryField.insert(0,end-start) + + if (response[:1] == 'E'): + ErrorHandler(response) + else: + displayPosition(response) + ##Move Vis Command## if (cmdType == "Move V"): if (moveInProc == 0): @@ -4140,6 +4214,19 @@ def teachInsertBelSelected(): f.write(str(item.strip(), encoding='utf-8')) f.write('\n') f.close() + elif(movetype == "OFF L"): + movetype = movetype+" [ PR: "+str(SavePosEntryField.get())+" ]" + newPos = movetype + " [*] X "+XcurPos+" Y "+YcurPos+" Z "+ZcurPos+" Rz "+RzcurPos+" Ry "+RycurPos+" Rx "+RxcurPos+" J7 "+str(J7PosCur)+" J8 "+str(J8PosCur)+" J9 "+str(J9PosCur)+" "+speedPrefix+" "+Speed+" Ac "+ACCspd+ " Dc "+DECspd+" Rm "+ACCramp+" Rnd "+Rounding+" $ "+WC + tab1.progView.insert(selRow, bytes(newPos + '\n', 'utf-8')) + tab1.progView.selection_clear(0, END) + tab1.progView.select_set(selRow) + items = tab1.progView.get(0,END) + file_path = path.relpath(ProgEntryField.get()) + with open(file_path,'w', encoding='utf-8') as f: + for item in items: + f.write(str(item.strip(), encoding='utf-8')) + f.write('\n') + f.close() elif(movetype == "Move R"): newPos = movetype + " [*] J1 "+J1AngCur+" J2 "+J2AngCur+" J3 "+J3AngCur+" J4 "+J4AngCur+" J5 "+J5AngCur+" J6 "+J6AngCur+" J7 "+str(J7PosCur)+" J8 "+str(J8PosCur)+" J9 "+str(J9PosCur)+" "+speedPrefix+" "+Speed+" Ac "+ACCspd+ " Dc "+DECspd+" Rm "+ACCramp+" $ "+WC tab1.progView.insert(selRow, bytes(newPos + '\n', 'utf-8')) @@ -8954,7 +9041,7 @@ speedMenu.place(x=412, y=76) #single buttons options=StringVar(tab1) -menu=OptionMenu(tab1, options, "Move J", "Move J", "OFF J", "Move L", "Move R", "Move A Mid", "Move A End", "Move C Center", "Move C Start", "Move C Plane", "Start Spline", "End Spline", "Move PR", "OFF PR ", "Teach PR", "Move Vis", command=posRegFieldVisible) +menu=OptionMenu(tab1, options, "Move J", "Move J", "OFF J", "Move L", "OFF L", "Move R", "Move A Mid", "Move A End", "Move C Center", "Move C Start", "Move C Plane", "Start Spline", "End Spline", "Move PR", "OFF PR ", "Teach PR", "Move Vis", command=posRegFieldVisible) menu.grid(row=2,column=2) menu.config(width=18) menu.place(x=700, y=180)