Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meta-elphel393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
meta-elphel393
Commits
4c93e990
Commit
4c93e990
authored
May 18, 2016
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tempmon parameters from file
parent
a4ce8e63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
init_tempmon.py
recipes-core/init-tempmon/files/init_tempmon.py
+15
-4
No files found.
recipes-core/init-tempmon/files/init_tempmon.py
View file @
4c93e990
...
@@ -84,7 +84,8 @@ class temp_monitor():
...
@@ -84,7 +84,8 @@ class temp_monitor():
except
IOError
:
except
IOError
:
print
"Failed to create file: '
%
s
%
s'"
%
(
out_path_prefix
,
out_fnames
[
"core_temp_fn"
])
print
"Failed to create file: '
%
s
%
s'"
%
(
out_path_prefix
,
out_fnames
[
"core_temp_fn"
])
try
:
try
:
self
.
core_temp_params_f
=
open
(
out_path_prefix
+
out_fnames
[
"temp_params_fn"
],
"w"
)
self
.
core_temp_params_f
=
open
(
out_path_prefix
+
out_fnames
[
"temp_params_fn"
],
"r+"
)
self
.
write_temp_params
()
except
IOError
:
except
IOError
:
self
.
core_temp_out_f
.
close
()
self
.
core_temp_out_f
.
close
()
print
"Failed to create file: '
%
s
%
s'"
%
(
out_path_prefix
,
out_fnames
[
"temp_params_fn"
])
print
"Failed to create file: '
%
s
%
s'"
%
(
out_path_prefix
,
out_fnames
[
"temp_params_fn"
])
...
@@ -187,6 +188,7 @@ class temp_monitor():
...
@@ -187,6 +188,7 @@ class temp_monitor():
# print "Core temperature: '%f', median: '%f'" % (core_temp, avg)
# print "Core temperature: '%f', median: '%f'" % (core_temp, avg)
time
.
sleep
(
self
.
params
[
"temp_sampling_time"
])
time
.
sleep
(
self
.
params
[
"temp_sampling_time"
])
self
.
read_temp_params
()
except
(
KeyboardInterrupt
,
SystemExit
):
except
(
KeyboardInterrupt
,
SystemExit
):
self
.
core_temp_out_f
.
close
()
self
.
core_temp_out_f
.
close
()
self
.
core_temp_params_f
.
close
()
self
.
core_temp_params_f
.
close
()
...
@@ -198,12 +200,21 @@ class temp_monitor():
...
@@ -198,12 +200,21 @@ class temp_monitor():
"""
"""
Read parameters from file and update local values.
Read parameters from file and update local values.
"""
"""
self
.
core_temp_params_f
.
seek
(
0
)
file_lines
=
self
.
core_temp_params_f
.
readlines
()
for
key
,
val
in
self
.
params
.
items
():
for
key
,
val
in
self
.
params
.
items
():
self
.
core_temp_params_f
.
seek
(
0
)
file_lines
=
self
.
core_temp_params_f
.
readlines
()
for
line
in
file_lines
:
for
line
in
file_lines
:
if
line
.
find
(
key
)
==
0
:
if
line
.
find
(
key
)
==
0
:
self
.
core_temp_params_f
[
key
]
=
float
(
line
.
split
(
":"
)[
1
]
.
strip
())
self
.
params
[
key
]
=
float
(
line
.
split
(
":"
)[
1
]
.
strip
())
def
write_temp_params
(
self
):
"""
Write current parameters to file.
"""
self
.
core_temp_params_f
.
seek
(
0
)
for
key
,
val
in
self
.
params
.
items
():
self
.
core_temp_params_f
.
write
(
str
(
key
)
+
": "
+
str
(
val
)
+
"
\n
"
)
self
.
core_temp_params_f
.
flush
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
if
DEBUG
:
if
DEBUG
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment