Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
marc
measurements
Commits
c2f572f0
Commit
c2f572f0
authored
Oct 29, 2017
by
marc
Browse files
include centralFrequency in start meas
parent
2493b139
Changes
1
Hide whitespace changes
Inline
Side-by-side
__init__.py
View file @
c2f572f0
...
...
@@ -15,60 +15,62 @@ class Measurements():
'''
Initializes a measurement instance.
'''
self
.
_tool
=
None
self
.
_tools
=
[]
self
.
_integrationTime
=
2
self
.
_outputFile
=
None
self
.
_radec
=
None
self
.
_startTime
=
time
.
strftime
(
"%Y%m%d-%h%m%s"
)
self
.
tool
=
None
self
.
tools
=
[]
self
.
integrationTime
=
2
self
.
centralFrequency
=
1420
self
.
outputFile
=
None
self
.
radec
=
None
self
.
startTime
=
time
.
strftime
(
"%Y%m%d-%h%m%s"
)
'''
Read keys measurement tools from ini file. Value contains the absolute path to the tools.
'''
for
key
in
config
[
'Tools'
]:
self
.
_
tools
.
append
(
key
)
self
.
tools
.
append
(
key
)
def
getTools
(
self
):
'''
read the list of tools to output measurements
'''
logging
.
info
(
'List of measurements tools: {}'
.
format
(
self
.
_
tools
))
return
(
self
.
_
tools
)
logging
.
info
(
'List of measurements tools: {}'
.
format
(
self
.
tools
))
return
(
self
.
tools
)
def
getIntegrationTime
(
self
):
'''
read the integration time
'''
logging
.
info
(
'Integration time is set to: {}'
.
format
(
self
.
_
integrationTime
))
return
(
self
.
_
integrationTime
)
logging
.
info
(
'Integration time is set to: {}'
.
format
(
self
.
integrationTime
))
return
(
self
.
integrationTime
)
def
startMeasurement
(
self
,
tool
,
integrationTime
,
outputFile
):
def
startMeasurement
(
self
,
tool
,
centralFrequency
,
integrationTime
,
outputFile
):
'''
Define the required tool to perform the measurement
'''
self
.
_tool
=
config
[
"Tools"
][
tool
]
self
.
_integrationTime
=
integrationTime
self
.
_outputFile
=
outputFile
logging
.
info
(
'Used measurement tool set to: {}'
.
format
(
self
.
_tool
))
logging
.
info
(
'Integration time set to: {}'
.
format
(
self
.
_integrationTime
))
logging
.
info
(
'Output file is: {}'
.
format
(
self
.
_outputFile
.
name
))
self
.
tool
=
config
[
"Tools"
][
tool
]
self
.
centralFrequency
=
centralFrequency
self
.
integrationTime
=
integrationTime
self
.
outputFile
=
outputFile
logging
.
info
(
'Used measurement tool set to: {}'
.
format
(
self
.
tool
))
logging
.
info
(
'Central Frequency set to: {}'
.
format
(
self
.
centralFrequency
))
logging
.
info
(
'Integration time set to: {}'
.
format
(
self
.
integrationTime
))
logging
.
info
(
'Output file is: {}'
.
format
(
self
.
outputFile
.
name
))
'''
Compile CLI and execute command
'''
measCLI
=
self
.
_tool
+
" "
+
str
(
self
.
_integrationTime
)
logging
.
info
(
'Excute CLI: {}'
.
format
(
measCLI
))
logging
.
info
(
'Excute CLI: {} {}'
.
format
(
self
.
tool
,
self
.
integrationTime
))
'''
Note: in the stub dumpwide I added /bin/bash, otherwise you get an Exec format error.
'''
self
.
measurement
=
subprocess
.
Popen
(
self
.
_
tool
,
self
.
_
integrationTime
,
stdout
=
subprocess
.
PIPE
)
self
.
measurement
.
wait
(
)
#
self.measurement = subprocess.Popen(self.tool,
self.
centralFrequency, self.
integrationTime, stdout=subprocess.PIPE)
self
.
measurement
=
subprocess
.
Popen
(
self
.
tool
+
" "
+
str
(
self
.
centralFrequency
)
+
" "
+
str
(
self
.
integrationTime
),
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
measResults
=
self
.
measurement
.
stdout
""" Write results into file"""
for
line
in
measResults
:
self
.
_
outputFile
.
write
(
line
.
decode
(
'utf-8'
))
self
.
outputFile
.
write
(
line
.
decode
(
'utf-8'
))
logging
.
info
(
'Result written to file: {}'
.
format
(
self
.
_
outputFile
.
name
))
logging
.
info
(
'Result written to file: {}'
.
format
(
self
.
outputFile
.
name
))
if
__name__
==
'__main__'
:
myMeas
=
Measurements
()
...
...
@@ -78,5 +80,5 @@ if __name__ == '__main__':
for
tool
in
myMeas
.
getTools
():
logging
.
info
(
'Defined tools in ini file are: {}'
.
format
(
tool
))
myMeas
.
startMeasurement
(
'dumpwide'
,
120
,
measFile
)
myMeas
.
startMeasurement
(
'dumpwide'
,
1420
,
120
,
measFile
)
measFile
.
close
()
Write
Preview
Supports
Markdown
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