Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
motorHistory
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kpetersn
motorHistory
Commits
d891a93e
Commit
d891a93e
authored
10 years ago
by
kpetersn
Browse files
Options
Downloads
Patches
Plain Diff
Better handle starting values.
parent
e4652e31
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
motorHist.py
+22
-6
22 additions, 6 deletions
motorHist.py
with
22 additions
and
6 deletions
motorHist.py
+
22
−
6
View file @
d891a93e
...
...
@@ -47,8 +47,13 @@ motor_dict = {}
def
msta_diff
(
last_msta
,
current_msta
):
if
last_msta
==
-
1
:
print
"
\t
1st MSTA, No comparison possible
"
return
current_msta
# 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
)
else
:
# XOR shows changed bits
changed_bits
=
last_msta
^
current_msta
...
...
@@ -65,8 +70,13 @@ def msta_diff(last_msta, current_msta):
def
mip_diff
(
last_mip
,
current_mip
):
if
last_mip
==
-
1
:
print
"
\t
1st MIP, No comparison possible
"
return
current_mip
# 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
)
else
:
# XOR shows changed bits
changed_bits
=
last_mip
^
current_mip
...
...
@@ -127,7 +137,10 @@ def main(log_file):
# 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
)
if
last_msta
==
-
1
:
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
)
msta_diff
(
last_msta
,
current_msta
)
motor_dict
[
name
][
"
MSTA
"
]
=
current_msta
print
...
...
@@ -137,7 +150,10 @@ def main(log_file):
# 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
)
if
last_mip
==
-
1
:
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
)
mip_diff
(
last_mip
,
current_mip
)
motor_dict
[
name
][
"
MIP
"
]
=
current_mip
print
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment