diff --git a/motorHist.py b/motorHist.py index 5166836542eeefcbd52eadc51f6ddfe7473760eb..c2426a71294e99e2b3beb53814ebafed2ba76921 100755 --- a/motorHist.py +++ b/motorHist.py @@ -25,6 +25,24 @@ msta_dict = {1 << 0 : ("Direction", ("Negative", "Positive")), #!print msta_dict +mip_dict = {1 << 0 : ("Jog forward", ("Done", "In Progress")), + 1 << 1 : ("Jog reverse", ("Done", "In Progress")), + 1 << 2 : ("Post-jog backlash", ("Done", "In Progress")), + 1 << 3 : ("Home forard", ("Done", "In Progress")), + 1 << 4 : ("Home reverse", ("Done", "In Progress")), + 1 << 5 : ("Move (NOT home/jog)", ("Done", "In Progress")), + 1 << 6 : ("Retry", ("Done", "In Progress")), + 1 << 7 : ("Load position", ("Done", "In Progress")), + 1 << 8 : ("Backlash", ("Done", "In Progress")), + 1 << 9 : ("Stoping", ("Done", "In Progress")), + 1 << 10 : ("Delay request", ("Done", "In Progress")), + 1 << 11 : ("Delay acknowledge", ("Done", "In Progress")), + 1 << 12 : ("Jog request", ("Done", "In Progress")), + 1 << 13 : ("Jog stopping", ("Done", "In Progress")), + 1 << 14 : ("External move", ("Done", "In Progress")), + } + +#!print msta_dict motor_dict = {} def msta_diff(last_msta, current_msta): @@ -43,7 +61,25 @@ def msta_diff(last_msta, current_msta): bit_state = 1 else: bit_state = 0 - print "\t%s bit (0x%X) changed to \"%s\" (0x%X)" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state) + print "MSTA:\t%s bit (0x%X) changed to \"%s\" (0x%X)" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state) + +def mip_diff(last_mip, current_mip): + if last_mip == -1: + print "\t1st MIP, No comparison possible" + return current_mip + else: + # XOR shows changed bits + changed_bits = last_mip ^ current_mip + + # Display changes + for index in range(15): + bit = 1 << index + if (bit & changed_bits): + if (current_mip & bit): + bit_state = 1 + else: + bit_state = 0 + print "MIP:\t%s bit (0x%X) changed to \"%s\" (0x%X)" % (mip_dict[bit][0], bit, mip_dict[bit][1][bit_state], bit_state) def main(log_file): @@ -76,7 +112,7 @@ def main(log_file): # Check for MSTA change if field == "MSTA": - # Maybe catch error here + # 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) @@ -86,7 +122,13 @@ def main(log_file): # Check for MIP change if field == "MIP": + # Catch error here? current_mip = int(value) + last_mip = motor_dict[name]["MIP"] + print "[%s %s] %s's %s field changed from %i (0x%X) to %i (0x%X)" % (date, time, name, field, last_mip, last_mip, current_mip, current_mip) + mip_diff(last_mip, current_mip) + motor_dict[name]["MIP"] = current_mip + print fh.close()