Commit 40b9848d authored by marc's avatar marc
Browse files

Added logging and button outputDir selection and measProgramma

parent 2974a6f8
......@@ -3,9 +3,11 @@
import sys
import csv
import logging
from configparser import ConfigParser
import subprocess
import traceback
import time
import os.path
import numpy as np
from PyQt5 import QtGui
......@@ -16,6 +18,20 @@ from ui.dtobswindow import Ui_mainWindow
from telescope import telescope
from astropy import units as u
from astropy.coordinates import SkyCoord
from docutils.nodes import option
'''
Setup logging
'''
config = ConfigParser()
config.readfp(open(os.path.join(os.path.dirname(__file__), 'dtobsgui.ini')))
logging.basicConfig(level=logging.DEBUG)
#Define logging
if config['Application']['LogLevel']=='DEBUG':
logging.basicConfig(format='%(asctime)s:%(name)s:%(message)s',filename='dtobsgui.log',filemode='w' ,level=logging.DEBUG)
else:
logging.basicConfig(format='%(asctime)s:%(name)s:%(message)s',filename='dtobsgui.log',filemode='w' ,level=logging.INFO)
class WorkerSignals(QObject):
"""
......@@ -65,8 +81,8 @@ class Worker(QRunnable):
class DTObservationProgram(Ui_mainWindow):
def __init__(self, mainWindow):
logging.info('Initialization of DTObsGUI')
self.radec = None
Ui_mainWindow.__init__(self)
self.setupUi(mainWindow)
self.actionOpen.triggered.connect(self.openFileNameDialog)
......@@ -74,6 +90,7 @@ class DTObservationProgram(Ui_mainWindow):
self.actionQuit.triggered.connect(self.quitDTObs)
self.pushButtonStartMeasurement.clicked.connect(self.startMeasurement)
self.pushButtonStopMeasurement.clicked.connect(self.stopMeasurement)
self.pushButtonOutputDirectory.clicked.connect(self.selectOutputDirectory)
self.myDT = telescope(setmode='J2000', consoleHost='consoledemo.dmz.camras.nl')
......@@ -83,7 +100,7 @@ class DTObservationProgram(Ui_mainWindow):
'''
Clear tableWidget and read pointings from file
'''
fileName,_ = QFileDialog.getOpenFileName(None, 'Open File', '~/')
fileName,_ = QFileDialog.getOpenFileName(None, 'Open File', "","Meas Files (*.dat);;All Files (*)")
if fileName:
reader = csv.reader(open(fileName),delimiter='\t')
rowPosition = self.tableWidgetPointings.rowCount()
......@@ -100,12 +117,22 @@ class DTObservationProgram(Ui_mainWindow):
rowPosition += 1
self.tableWidgetPointings.resizeColumnsToContents()
def selectOutputDirectory(self):
'''
Select the output directory to store the measurements
'''
dialog = QFileDialog()
folder_path = dialog.getExistingDirectory(None, "Select Folder")
self.lineEditOutputDir.setText(folder_path)
def closeMeasurement(self):
for rowPosition in range(self.tableWidgetPointings.rowCount(),-1,-1):
self.tableWidgetPointings.removeRow(rowPosition)
def quitDTObs(self):
logging.shutdown()
sys.exit(app.exec_())
def allCompleted(self):
......@@ -178,7 +205,7 @@ class DTObservationProgram(Ui_mainWindow):
measFile.write("#Integration time: " + str(integrationTime) + "\n")
measFile.write("#Programme: " + measProgramme + "\n")
self.measprog = subprocess.Popen(["cat", "test.dat", str(integrationTime)], stdout=subprocess.PIPE)
self.measprog = subprocess.Popen([measProgramme, str(integrationTime)], stdout=subprocess.PIPE)
for sec in range(integrationTime):
remainstring = str(int((integrationTime-sec)/60)) + ":"
remainstring += "{:02}".format((integrationTime-sec)%60)
......
[Application]
LogLevel: INFO
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'dtobswindow.ui'
# Form implementation generated from reading ui file 'ui/dtobswindow.ui'
#
# Created by: PyQt5 UI code generator 5.5.1
#
......@@ -83,6 +83,7 @@ class Ui_mainWindow(object):
self.toolBox.setFrameShape(QtWidgets.QFrame.NoFrame)
self.toolBox.setObjectName("toolBox")
self.toolBoxMetaData = QtWidgets.QWidget()
self.toolBoxMetaData.setGeometry(QtCore.QRect(0, 0, 96, 26))
self.toolBoxMetaData.setObjectName("toolBoxMetaData")
self.groupBox_3 = QtWidgets.QGroupBox(self.toolBoxMetaData)
self.groupBox_3.setGeometry(QtCore.QRect(10, 10, 271, 351))
......@@ -106,7 +107,7 @@ class Ui_mainWindow(object):
self.gridLayout_3.addWidget(self.textEditDescription, 1, 1, 1, 1)
self.toolBox.addItem(self.toolBoxMetaData, "")
self.toolBoxMeasurement = QtWidgets.QWidget()
self.toolBoxMeasurement.setGeometry(QtCore.QRect(0, 0, 280, 418))
self.toolBoxMeasurement.setGeometry(QtCore.QRect(0, 0, 280, 426))
self.toolBoxMeasurement.setObjectName("toolBoxMeasurement")
self.groupBox_2 = QtWidgets.QGroupBox(self.toolBoxMeasurement)
self.groupBox_2.setGeometry(QtCore.QRect(0, 0, 280, 261))
......@@ -120,11 +121,9 @@ class Ui_mainWindow(object):
self.gridLayout_2.setHorizontalSpacing(7)
self.gridLayout_2.setObjectName("gridLayout_2")
self.lineEditOutputDir = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.lineEditOutputDir.setText("")
self.lineEditOutputDir.setObjectName("lineEditOutputDir")
self.gridLayout_2.addWidget(self.lineEditOutputDir, 1, 1, 1, 1)
self.label = QtWidgets.QLabel(self.gridLayoutWidget)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 1, 0, 1, 1)
self.label_2 = QtWidgets.QLabel(self.gridLayoutWidget)
self.label_2.setObjectName("label_2")
self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1)
......@@ -133,6 +132,7 @@ class Ui_mainWindow(object):
self.comboBoxProgramma.addItem("")
self.comboBoxProgramma.addItem("")
self.comboBoxProgramma.addItem("")
self.comboBoxProgramma.addItem("")
self.gridLayout_2.addWidget(self.comboBoxProgramma, 0, 1, 1, 1)
self.spinBoxIntTime = QtWidgets.QSpinBox(self.gridLayoutWidget)
self.spinBoxIntTime.setMinimum(1)
......@@ -143,6 +143,9 @@ class Ui_mainWindow(object):
self.label_3 = QtWidgets.QLabel(self.gridLayoutWidget)
self.label_3.setObjectName("label_3")
self.gridLayout_2.addWidget(self.label_3, 2, 0, 1, 1)
self.pushButtonOutputDirectory = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButtonOutputDirectory.setObjectName("pushButtonOutputDirectory")
self.gridLayout_2.addWidget(self.pushButtonOutputDirectory, 1, 0, 1, 1)
self.verticalLayoutWidget = QtWidgets.QWidget(self.groupBox_2)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 160, 261, 80))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
......@@ -156,7 +159,7 @@ class Ui_mainWindow(object):
self.verticalLayout_2.addWidget(self.checkBoxCorrection)
self.toolBox.addItem(self.toolBoxMeasurement, "")
self.toolBoxBackEnd = QtWidgets.QWidget()
self.toolBoxBackEnd.setGeometry(QtCore.QRect(0, 0, 280, 418))
self.toolBoxBackEnd.setGeometry(QtCore.QRect(0, 0, 96, 26))
self.toolBoxBackEnd.setObjectName("toolBoxBackEnd")
self.groupBox = QtWidgets.QGroupBox(self.toolBoxBackEnd)
self.groupBox.setEnabled(True)
......@@ -201,7 +204,7 @@ class Ui_mainWindow(object):
self.gridLayout.addWidget(self.toolBox, 6, 0, 1, 1)
mainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(mainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 856, 30))
self.menubar.setGeometry(QtCore.QRect(0, 0, 856, 29))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
......@@ -310,14 +313,14 @@ class Ui_mainWindow(object):
self.label_5.setText(_translate("mainWindow", "Observer(s):"))
self.label_8.setText(_translate("mainWindow", "Desciption: "))
self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxMetaData), _translate("mainWindow", "Meta Data"))
self.lineEditOutputDir.setText(_translate("mainWindow", "~/Obs"))
self.label.setText(_translate("mainWindow", " Result directory: "))
self.label_2.setText(_translate("mainWindow", " Programme: "))
self.comboBoxProgramma.setCurrentText(_translate("mainWindow", "dumpwide"))
self.comboBoxProgramma.setItemText(0, _translate("mainWindow", "dumpwide"))
self.comboBoxProgramma.setItemText(1, _translate("mainWindow", "int32bit"))
self.comboBoxProgramma.setItemText(2, _translate("mainWindow", "rawrecord"))
self.comboBoxProgramma.setItemText(2, _translate("mainWindow", "pulsarrecord"))
self.comboBoxProgramma.setItemText(3, _translate("mainWindow", "rawrecord"))
self.label_3.setText(_translate("mainWindow", " Integration Time: "))
self.pushButtonOutputDirectory.setText(_translate("mainWindow", "Output Dir"))
self.checkBoxDTModel.setText(_translate("mainWindow", "Refraction enabled"))
self.checkBoxCorrection.setText(_translate("mainWindow", "DT Model enagled"))
self.toolBox.setItemText(self.toolBox.indexOf(self.toolBoxMeasurement), _translate("mainWindow", "Measurement Settings"))
......@@ -356,3 +359,13 @@ class Ui_mainWindow(object):
self.actionM31_2.setText(_translate("mainWindow", "&M31"))
self.actionM101.setText(_translate("mainWindow", "M&101"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
mainWindow = QtWidgets.QMainWindow()
ui = Ui_mainWindow()
ui.setupUi(mainWindow)
mainWindow.show()
sys.exit(app.exec_())
......@@ -201,6 +201,14 @@
<number>1</number>
</property>
<widget class="QWidget" name="toolBoxMetaData">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<height>26</height>
</rect>
</property>
<attribute name="label">
<string>Meta Data</string>
</attribute>
......@@ -256,7 +264,7 @@
<x>0</x>
<y>0</y>
<width>280</width>
<height>418</height>
<height>426</height>
</rect>
</property>
<attribute name="label">
......@@ -296,14 +304,7 @@
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditOutputDir">
<property name="text">
<string>~/Obs</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string> Result directory: </string>
<string/>
</property>
</widget>
</item>
......@@ -329,6 +330,11 @@
<string>int32bit</string>
</property>
</item>
<item>
<property name="text">
<string>pulsarrecord</string>
</property>
</item>
<item>
<property name="text">
<string>rawrecord</string>
......@@ -356,6 +362,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButtonOutputDirectory">
<property name="text">
<string>Output Dir</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
......@@ -391,8 +404,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>280</width>
<height>418</height>
<width>96</width>
<height>26</height>
</rect>
</property>
<attribute name="label">
......@@ -506,7 +519,7 @@
<x>0</x>
<y>0</y>
<width>856</width>
<height>30</height>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......
Markdown is supported
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