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
ed646d5c
Commit
ed646d5c
authored
10 years ago
by
kpetersn
Browse files
Options
Downloads
Patches
Plain Diff
Handle multiple motors
parent
21ebec3a
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
+9
-6
9 additions, 6 deletions
motorHist.py
with
9 additions
and
6 deletions
motorHist.py
+
9
−
6
View file @
ed646d5c
...
...
@@ -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
"
\t
1st 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
...
...
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