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
21ebec3a
Commit
21ebec3a
authored
10 years ago
by
kpetersn
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit of script. Shows MSTA changes. Assumes only one motor in the log file.
parents
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
+94
-0
94 additions, 0 deletions
motorHist.py
with
94 additions
and
0 deletions
motorHist.py
0 → 100755
+
94
−
0
View file @
21ebec3a
#!/usr/bin/env python
#
# Interpret motor changes in camonitor log
#
import
sys
#!print sys.argv
msta_dict
=
{
1
<<
0
:
(
"
Direction
"
,
(
"
Negative
"
,
"
Positive
"
)),
1
<<
1
:
(
"
Done
"
,
(
"
Moving
"
,
"
Done
"
)),
1
<<
2
:
(
"
Plus limit
"
,
(
"
Off
"
,
"
On
"
)),
1
<<
3
:
(
"
Home limit
"
,
(
"
Off
"
,
"
On
"
)),
1
<<
4
:
(
"
Unused
"
,
(
"
0
"
,
"
1
"
)),
1
<<
5
:
(
"
Closed-loop
"
,
(
"
Enabled
"
,
"
Disabled
"
)),
1
<<
6
:
(
"
Slip/stall
"
,
(
"
OK
"
,
"
Stalled
"
)),
1
<<
7
:
(
"
Home
"
,
(
"
Not Home
"
,
"
Home
"
)),
1
<<
8
:
(
"
Encoder present
"
,
(
"
No
"
,
"
Yes
"
)),
1
<<
9
:
(
"
Problem
"
,
(
"
No
"
,
"
Yes
"
)),
1
<<
10
:
(
"
Moving
"
,
(
"
Done
"
,
"
Moving
"
)),
1
<<
11
:
(
"
Gain support
"
,
(
"
No
"
,
"
Yes
"
)),
1
<<
12
:
(
"
Comm error
"
,
(
"
OK
"
,
"
Error
"
)),
1
<<
13
:
(
"
Minus limit
"
,
(
"
Off
"
,
"
On
"
)),
1
<<
14
:
(
"
Homed
"
,
(
"
Not homed
"
,
"
Homed
"
)),
}
#!print msta_dict
def
msta_diff
(
last_msta
,
current_msta
):
if
last_msta
==
-
1
:
print
"
\t
1st MSTA, No comparison possible
"
return
current_msta
else
:
# XOR shows changed bits
changed_bits
=
last_msta
^
current_msta
# Display changes
for
index
in
range
(
15
):
bit
=
1
<<
index
if
(
bit
&
changed_bits
):
if
(
current_msta
&
bit
):
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
])
def
main
(
log_file
):
# Try to open the log file
try
:
fh
=
open
(
log_file
,
'
r
'
)
except
IOError
:
print
"
%s doesn
'
t exist.
"
%
log_file
sys
.
exit
(
1
)
last_msta
=
-
1
last_mip
=
-
1
for
line
in
fh
:
#!print line[:-1]
# Break line into list of values: PV name, date, time, value
line_list
=
line
[:
-
1
].
split
()
if
len
(
line_list
)
!=
4
:
# Line is not valid, continue to the next
continue
else
:
# split line into PV name and field
name
,
field
=
line_list
[
0
].
split
(
'
.
'
)
date
=
line_list
[
1
]
time
=
line_list
[
2
]
value
=
line_list
[
3
]
# Check for MSTA change
if
field
==
"
MSTA
"
:
# Maybe catch error here
current_msta
=
int
(
value
)
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
print
# Check for MIP change
if
field
==
"
MIP
"
:
current_mip
=
int
(
value
)
fh
.
close
()
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
!=
2
:
print
"
Usage: motorHist.py <log_file>
"
else
:
main
(
sys
.
argv
[
1
])
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