Commit c2f572f0 authored by marc's avatar marc
Browse files

include centralFrequency in start meas

parent 2493b139
......@@ -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()
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