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

Switched to None for all starting values. Changed output slightly (square...

Switched to None for all starting values. Changed output slightly (square brackets for hex values, parentheses for hex bits
parent 08ccf531
No related branches found
No related tags found
No related merge requests found
......@@ -46,14 +46,13 @@ mip_dict = {1 << 0 : ("Jog forward", ("Done", "In Progress")),
motor_dict = {}
def msta_diff(last_msta, current_msta):
if last_msta == -1:
if last_msta == None:
# Display starting state
for index in range(15):
bit = 1 << index
if (current_msta & bit):
bit_state = 1
print "\t%s bit (0x%X) starting value is \"%s\" (0x%X)" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state)
print "\t%s bit (0x%X) starting value is \"%s\" [0x%X]" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state)
else:
# XOR shows changed bits
changed_bits = last_msta ^ current_msta
......@@ -66,17 +65,16 @@ def msta_diff(last_msta, current_msta):
bit_state = 1
else:
bit_state = 0
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)
print "MSTA:\t%s bit (0x%X) changed to \"%s\" [%i]" % (msta_dict[bit][0], bit, msta_dict[bit][1][bit_state], bit_state)
def mip_diff(last_mip, current_mip):
if last_mip == -1:
if last_mip == None:
# Display starting state
for index in range(15):
bit = 1 << index
if (current_mip & bit):
bit_state = 1
print "\t%s bit (0x%X) starting value is \"%s\" (0x%X)" % (mip_dict[bit][0], bit, mip_dict[bit][1][bit_state], bit_state)
print "\t%s bit (0x%X) starting value is \"%s\" [0x%X]" % (mip_dict[bit][0], bit, mip_dict[bit][1][bit_state], bit_state)
else:
# XOR shows changed bits
changed_bits = last_mip ^ current_mip
......@@ -89,7 +87,7 @@ def mip_diff(last_mip, current_mip):
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)
print "MIP:\t%s bit (0x%X) changed to \"%s\" [%i]" % (mip_dict[bit][0], bit, mip_dict[bit][1][bit_state], bit_state)
def main(log_file):
......@@ -118,7 +116,7 @@ def main(log_file):
# 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, "VAL" : None}
motor_dict[name] = {"MSTA" : None, "MIP" : None, "VAL" : None}
# Check for VAL change
if field == "VAL":
......@@ -137,10 +135,10 @@ def main(log_file):
# Catch error here?
current_msta = int(value)
last_msta = motor_dict[name]["MSTA"]
if last_msta == -1:
print "[%s %s] %s's %s field starts at %i (0x%X)" % (date, time, name, field, current_msta, current_msta)
if last_msta == None:
print "[%s %s] %s's %s field starts at %i [0x%X]" % (date, time, name, field, current_msta, current_msta)
else:
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)
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)
motor_dict[name]["MSTA"] = current_msta
print
......@@ -150,10 +148,10 @@ def main(log_file):
# Catch error here?
current_mip = int(value)
last_mip = motor_dict[name]["MIP"]
if last_mip == -1:
print "[%s %s] %s's %s field starts at %i (0x%X)" % (date, time, name, field, current_mip, current_mip)
if last_mip == None:
print "[%s %s] %s's %s field starts at %i [0x%X]" % (date, time, name, field, current_mip, current_mip)
else:
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)
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
......
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