Commit 827ed46e authored by marc's avatar marc
Browse files

created startMeasurement method in measurements

parent 5bfff69b
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.6</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
......@@ -2,8 +2,8 @@ from __future__ import print_function
import logging
from configparser import ConfigParser
import os.path
import subprocess
import time
from idlelib.dynOptionMenuWidget import _dyn_option_menu
config = ConfigParser()
config.readfp(open(os.path.join(os.path.dirname(__file__), 'measurements.ini')))
......@@ -11,31 +11,29 @@ config.readfp(open(os.path.join(os.path.dirname(__file__), 'measurements.ini')))
class measurements():
def __init__(self,tool=None, integrationTime=None, outputFile=None, radec=None, metaData=None):
def __init__(self):
Initializes a measurement instance.
self._tool = tool
self._tool = None
self._tools = []
self._integrationTime = integrationTime
self._outputFile = outputFile
self._radec = radec
self._integrationTime = 2
self._outputFile = None
self._radec = None
self._startTime = time.strftime("%Y%m%d-%h%m%s")
self._staticMetaData = {"Observer":"CAMRAS","Date" : self._startTime, "RaDEC" : self._radec}
self._dynamicMetaData = {}
Read tools from ini file
Read keys measurement tools from ini file. Value contains the absolute path to the tools.
for key in config['Tools']:
def getTools(self):
read the list of tools to output measurememnts
read the list of tools to output measurements
''''List of measument tools: {}'.format(self._tools))'List of measurements tools: {}'.format(self._tools))
def getIntegrationTime(self):
......@@ -56,27 +54,47 @@ class measurements():'Meta data is: {}'.format(metaData))
def setTool(self, measProg):
def setMetaData(self,metaData):
self._staticMetaData = metaData
self._dynamicMetaData = None
def startMeasurement(self, tool, integrationTime, outputFile, metaData):
Define the required tool to perform the measurement
self._tool = measProg'Used measument tool set to: {}'.format(self._tool))
def setIntegrationTime(self, integrationTime):
self._tool = config["Tools"][tool]
self._integrationTime = integrationTime'Integration time set to: {}'.format(self._integrationTime))
def setMetaData(self,metaData):
self._outputFile = outputFile
self._staticMetaData = metaData
self._dynamicMetaData = None'Used measument tool set to: {}'.format(self._tool))'Integration time set to: {}'.format(self._integrationTime))'Output file is: {}'.format(self._outputFile))
Compile CLI and execute command
measCLI = self._tool +" "+ str(self._integrationTime)'Excute CLI: {}'.format(measCLI))
Note: in the stub dumpwide I added /bin/bash, otherwise you get an Exec format error.
self.measurement = subprocess.Popen(self._tool, stdout=subprocess.PIPE)
measResults = self.measurement.stdout
""" Write results into file"""
for line in measResults:
if __name__ == '__main__':
myMeas = measurements()
measnum = 123
measFile = open('/tmp/DT-' + '{:03d}'.format(measnum) + "-" + time.strftime("%Y%m%d") + ".dat",'w')"Output to file: {}".format(measFile))
for tool in myMeas.getTools():
\ No newline at end of file
myMeas.startMeasurement('dumpwide', 120, measFile, metaData=None)
\ No newline at end of file
DumpWide: dumpwide
Int32Bin: int32bin
PulsarRecord: pulsarrecord
RawRecord: rawrecord
\ No newline at end of file
dumpwide: /home/marc/bin/dumpwide
int32bin: /usr/bin/int32bin
pulsarrecord: /usr/bin/pulsarrecord
rawrecord: /usr/bin/rawrecord
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment