Commit f65dc204 authored by bliss administrator's avatar bliss administrator

Add tool to convert SPEC config for ICEPAP

parent 25608d14
Pipeline #7138 canceled with stages
#python3 ./SPEC2BLISS.py /users/blissadm/local/spec/spec.d/fipcontrol/config
with open('config', 'r') as config_file:
config = config_file.read()
#Get List Off Nodes
headerNodes="# Device nodes"
nodes=list(filter(None,config.split(headerNodes)[1].split("# ")[0].split("\n")))
# Motor cntrl steps sign slew base backl accel nada flags mne name
headerMotors="# Motor cntrl steps sign slew base backl accel nada flags mne name"
motors=list(filter(None,config.split(headerMotors)[1].split("# ")[0].split("\n")))
#extract icepap from nodes
icepapIP=[]
icepapID=[]
for idx,node in enumerate(nodes):
infoNode=node.split()
if(infoNode[2]=="icepap"):
icepapIP.append(infoNode[4])
icepapID.append(idx)
#extract motors with corresponding to icepap
#init icepapMOTOR 2d list -> icepapMOTOR[icepap_node][icepap_motor]
icepapMOTOR=[None]*len(icepapID)
for i in range(len(icepapMOTOR)):
icepapMOTOR[i]=[]
#fill the list
for motor in motors:
idNode=-1
try:
idNode=int(motor.split("MAC_MOT:")[1].split("/")[0])
idx = icepapID.index(idNode)
icepapMOTOR[idx].append(motor)
except:
pass
#convert icepap motors to bliss motor
for idx,ip in enumerate(icepapIP):
print("-")
print("\tcontroller:")
print("\t\tclass: IcePAP")
print("\t\thost: %s"%ip)
print("\t\taxes:")
for motor in icepapMOTOR[idx]:
motorInfo = motor.split()
motorNodeInfo = motorInfo[2].split(":")[1].split("/")
icepapCrate = int(motorNodeInfo[1])
icepapCard = int(motorNodeInfo[2])
steps_per_unit = int(motorInfo[3])
sign = int(motorInfo[4])
accelTime = int(motorInfo[8])
speed = int(motorInfo[6])
backlash = int(motorInfo[7])
mne = motorInfo[11]
print("\t\t\t-")
print("\t\t\t\tname: %s"%mne)
print("\t\t\t\taddress: %d"%(icepapCrate*10+icepapCard))
print("\t\t\t\tsign: %d"%(sign))
print("\t\t\t\tsteps_per_unit: %d"%steps_per_unit)
print("\t\t\t\tvelocity: %f"%(speed/(float(steps_per_unit))))
print("\t\t\t\tacceleration: %f"%((speed/(float(steps_per_unit))/(float(accelTime)/1000.))))
print("\t\t\t\tbacklash: %f"%(backlash/(float(steps_per_unit))))
print("\t\t\t\tlow_limit: -inf")
print("\t\t\t\thigh_limit: inf")
print("\t\t\t\toffset: 0")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment