Skip to content
Snippets Groups Projects
Commit ed646d5c authored by kpetersn's avatar kpetersn
Browse files

Handle multiple motors

parent 21ebec3a
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,10 @@ msta_dict = {1 << 0 : ("Direction", ("Negative", "Positive")),
1 << 14 : ("Homed", ("Not homed", "Homed")),
}
#!print msta_dict
motor_dict = {}
def msta_diff(last_msta, current_msta):
if last_msta == -1:
print "\t1st MSTA, No comparison possible"
......@@ -42,7 +43,7 @@ def msta_diff(last_msta, current_msta):
bit_state = 1
else:
bit_state = 0
print "\t%s (0x%X) bit changed to \"%s\"" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state])
print "\t%s bit (0x%X) changed to \"%s\" (0x%X)" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state)
def main(log_file):
......@@ -53,9 +54,6 @@ def main(log_file):
print "%s doesn't exist." % log_file
sys.exit(1)
last_msta = -1
last_mip = -1
for line in fh:
#!print line[:-1]
......@@ -71,14 +69,19 @@ def main(log_file):
date = line_list[1]
time = line_list[2]
value = line_list[3]
# Assume every record name is a motor, add to list if name is new
if name not in motor_dict.keys():
motor_dict[name] = {"MSTA" : -1, "MIP" : -1}
# Check for MSTA change
if field == "MSTA":
# Maybe catch error here
current_msta = int(value)
last_msta = motor_dict[name]["MSTA"]
print "[%s %s] %s's %s field changed from %i (0x%X) to %i (0x%X)" % (date, time, name, field, last_msta, last_msta, current_msta, current_msta)
msta_diff(last_msta, current_msta)
last_msta = current_msta
motor_dict[name]["MSTA"] = current_msta
print
# Check for MIP change
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment