Commit 711a56a3 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Update with last changes in old repository

parent c89c8fac
......@@ -7,6 +7,7 @@ from PyQt5 import QtGui
from PyQt5.QtCore import QThread, QRunnable, QObject, pyqtSignal, pyqtSlot, QThreadPool
from PyQt5.QtWidgets import (QFileDialog, QApplication, QMainWindow, QTableWidgetItem)
from ui.dtobswindow import Ui_mainWindow
import subprocess
import traceback
import time
......@@ -32,10 +33,11 @@ class WorkerSignals(QObject):
`int` inicating % progress
"""
finished = pyqtSignal(int)
error = pyqtSignal(tuple)
result = pyqtSignal(object)
progress = pyqtSignal(int)
finished = pyqtSignal(int, str)
allfinished = pyqtSignal()
# error = pyqtSignal(tuple)
# result = pyqtSignal(object)
# progress = pyqtSignal(int)
class Worker(QRunnable):
""" Execute a function asynchronously, connect to signals """
......@@ -54,9 +56,8 @@ class Worker(QRunnable):
def run(self):
""" Initialize the runner function with passed args, kwargs """
fnresult = self.function_to_run(*self.args, **self.kwargs)
self.signals.result.emit(fnresult)
# self.signals.finished.emit(42)
self.function_to_run(*self.args, **self.kwargs)
self.signals.allfinished.emit()
class DTObservationProgram(Ui_mainWindow):
def __init__(self, mainWindow):
......@@ -80,9 +81,8 @@ class DTObservationProgram(Ui_mainWindow):
if fileName:
reader = csv.reader(open(fileName),delimiter='\t')
rowPosition = self.tableWidgetPointings.rowCount()
for meas, ra, dec in reader:
#pointing = SkyCoord(ra=float(RA)*u.degree, dec=float(Dec)*u.degree)
#print(pointing.to_string('hms'))
self.radec = SkyCoord(float(ra)*u.degree, float(dec)*u.degree, frame='icrs')
(raStr, decStr) = self.radec.to_string('hmsdms').split()
......@@ -90,45 +90,62 @@ class DTObservationProgram(Ui_mainWindow):
#measurement = '{:3d}\t {:3.5f}\t {:3.5f}'.format(int(meas),float(RA), float(Dec))
self.tableWidgetPointings.setItem(rowPosition, 0, QTableWidgetItem(raStr))
self.tableWidgetPointings.setItem(rowPosition, 1, QTableWidgetItem(decStr))
self.tableWidgetPointings.setItem(rowPosition, 2, QTableWidgetItem("Scheduled"))
self.tableWidgetPointings.setItem(rowPosition, 2, QTableWidgetItem(""))
rowPosition += 1
for column in range(3):
self.tableWidgetPointings.item(rowPosition,column).setBackground(QtGui.QColor('cyan'))
rowPosition=+1
self.tableWidgetPointings.resizeColumnsToContents()
def measCompleted(self, meas_num):
def allCompleted(self):
""" Callback function when all pointings completed """
print("All pointings completed")
def measCompleted(self, meas_num, status):
""" Make the meas_num-th row of the table green """
print("One setpoint complete, namely", meas_num)
print("One setpoint complete, namely", meas_num, status)
colors = {'Completed': QtGui.QColor('green'),
'Slewing' : QtGui.QColor('yellow'),
'Measuring': QtGui.QColor('cyan')}
for column in range(3):
self.tableWidgetPointings.setItem(meas_num, 2, QTableWidgetItem("Completed"))
self.tableWidgetPointings.item(meas_num,column).setBackground(QtGui.QColor('green'))
self.tableWidgetPointings.setItem(meas_num, 2, QTableWidgetItem(status))
self.tableWidgetPointings.item(meas_num,column).setBackground(colors[status])
self.tableWidgetPointings.resizeColumnsToContents()
def goToSetpoints(self, setpoints, oneSetpointCompleteSignal=None):
""" Send a list of setpoints to the telescope """
for setpoint_nr, setpoint in enumerate(setpoints):
self.myDT.setRaDec(setpoint)
oneSetpointCompleteSignal.emit(setpoint_nr, 'Slewing')
time.sleep(2)
self.myDT.waitUntilThere()
oneSetpointCompleteSignal.emit(setpoint_nr)
oneSetpointCompleteSignal.emit(setpoint_nr, 'Measuring')
time.sleep(2) # Todo: call function here
self.startMeasure()
oneSetpointCompleteSignal.emit(setpoint_nr, 'Completed')
def startMeasure(self):
""" Dumping data into file including meta-data"""
print("start dump-wide")
data = subprocess.Popen(["cat","/home_local/camrasdemo/test-001.txt"], stdout=subprocess.PIPE).stdout
def startMeasurement(self):
print("Measurement started")
setpoints = []
for meas in range(0,self.tableWidgetPointings.rowCount()):
ra = self.tableWidgetPointings.item(meas, 0).text()
ra = self.tableWidgetPointings.item(meas, 0).text()
dec = self.tableWidgetPointings.item(meas, 1).text()
self.tableWidgetPointings.setItem(meas, 2, QTableWidgetItem("In Progress"))
self.tableWidgetPointings.setItem(meas, 2, QTableWidgetItem("Scheduled"))
for column in range(3):
self.tableWidgetPointings.item(meas,column).setBackground(QtGui.QColor('yellow'))
self.tableWidgetPointings.item(meas,column).setBackground(QtGui.QColor('gray'))
self.tableWidgetPointings.resizeColumnsToContents()
setpoint = SkyCoord(ra, dec, frame='icrs')
setpoints.append(setpoint)
worker = Worker(self.goToSetpoints, setpoints)
worker.signals.finished.connect(self.measCompleted)
worker.signals.allfinished.connect(self.allCompleted)
self.threadpool.start(worker)
def stopMeasurement(self):
......
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