def executeCommand(self, runList): """ This will take the known order of runList from the command and then send it to the server while also displaying pertanent information. It will essentially be reusing methods, whenever possible from the acquisitionClasses.py file. Returns: Nothing is returned through this method. """ val = self.parent.scriptStatus.activityText.GetValue() print(val) if type(runList) == list: self.parent.scriptStatus.activityText.SetValue(val + str(runList) + "\n") self.parent.scriptStatus.activityText.SetInsertionPointEnd() print(runList) print("sending command") # surround in str to get rid of unicode, otherwise fails at sending sendCommand = str(runList[0]) if sendCommand == "series": imtype = str(runList[1]) number = str(runList[2]) exposeClass = self.parent.parent.parent.takeImage.exposureInstance exposeClass.seriesImageNumber = int(number) exposeClass.logFunction = ( self.logScript ) # point to the correct log function that prints to log tab and script status # example runList (['series', 'bias', int(number), 'basename']) if imtype == "bias": basename = str(runList[3]) exposeClass.currentImage = basename overwrite = None if als.checkForFile("/data/copyfile/" + self.currentImage + "_001.fits"): dialog = wx.MessageDialog( None, "Do you want to change temperature during exposure?", "", wx.OK | wx.CANCEL | wx.ICON_QUESTION, ) overwrite = dialog.ShowModal() dialog.Destroy() if overwrite is not None or overwrite == wx.ID_OK: d = self.protocol.addDeferred("seriesSent") d.addCallback(exposeClass.displaySeriesImage_thread) d = self.protocol.sendCommand( sendCommand + " " + imtype + " " + number + " 0 " + str(self.parent.parent.parent.binning) ) d.addCallback(exposeClass.seriesCallback) # start timer thread.start_new_thread(exposeClass.exposeTimer, (0,)) if imtype in ["flat", "object", "dark"]: exposeClass.expButton.Enable(False) exposeClass.stopExp.Enable(True) exposeClass.abort = True itime = str(runList[3]) basename = str(runList[4]) exposeClass.currentImage = basename overwrite = None if als.checkForFile("/data/copyfile/" + self.currentImage + "_001.fits"): dialog = wx.MessageDialog( None, "Do you want to change temperature during exposure?", "", wx.OK | wx.CANCEL | wx.ICON_QUESTION, ) overwrite = dialog.ShowModal() dialog.Destroy() if overwrite is not None or overwrite == wx.ID_OK: for i in range(int(number)): d = self.protocol.addDeferred("seriesSent" + str(i + 1)) d.addCallback(exposeClass.displaySeriesImage_thread) d = self.protocol.sendCommand( sendCommand + " " + imtype + " " + number + " " + itime + " " + str(self.parent.parent.parent.binning) ) d.addCallback(exposeClass.seriesCallback) # start timer thread.start_new_thread(exposeClass.exposeTimer, (float(itime),)) if sendCommand == "abort": exposeClass = self.parent.parent.parent.takeImage.exposureInstance exposeClass.onStop(None) if sendCommand == "expose" and runList[1] == "help": # report on all the help options helpString = "" if runList[2] == "abort": helpString += ( '"expose abort" is used to stop the current exposure. This can be ' + "an exposure started through the imaging or scripting tab. Invoke with " + '"expose abort".' ) if runList[2] == "bias": helpString += ( '"expose bias" is used to take a number of biases in one command. Invoke this ' + 'command with "expose bias arg1 arg2", where arg1 and arg2, in no particular ' + "order, are time=XX in seconds and basename=imagename." ) if runList[2] == "dark": helpString += ( '"expose dark" is used to take a number of darks in one command. Invoke this ' + 'command with "expose dark arg1 arg2 arg3", where arg1, arg2, and arg3, in no particular ' + "order, are time=XX in seconds, number=XX as an int, and basename=imagename." ) if runList[2] == "flat": helpString += ( '"expose flat" is used to take a number of darks in one command. Invoke this ' + 'command with "expose flat arg1 arg2 arg3", where arg1, arg2, and arg3, in no particular ' + "order, are time=XX in seconds, number=XX as an int, and basename=imagename." ) if runList[2] == "object": helpString += ( '"expose object" is used to take a number of darks in one command. Invoke this ' + 'command with "expose object arg1 arg2 arg3", where arg1, arg2, and arg3, in no particular ' + "order, are time=XX in seconds, number=XX as an int, and basename=imagename." ) self.sendToStatus(helpString) ### Deal with set commands # command: set temp XX if sendCommand == "setTEC": temp = int(runList[1]) tempClass = self.parent.parent.parent.takeImage.tempInstance tempClass.tempToSend = temp tempClass.onCool(None) # command: set temp warmup if sendCommand == "warmup": tempClass = self.parent.parent.parent.takeImage.tempInstance tempClass.onStopCooling(None) # command: set filter X if sendCommand == "set": if runList[1] == "filter": pos = int(runList[2]) # command: set binning X if sendCommand == "set": if runList[1] == "binning": topInstance = self.parent.parent.parent bin = str(runList[2]) if bin == "1": topInstance.on1x1(None) file = topInstance.menuBar.GetMenu(0) file.FindItemById(1120).Check(check=True) else: topInstance.on2x2(None) file = topInstance.menuBar.GetMenu(0) file.FindItemById(1121).Check(check=True) # command: set help binning # set help temp # set help filter if sendCommand == "set": if runList[1] == "help": if runList[2] == "binning": helpBinning = ( '"set binning" is used to set the binning type of the CCD. To invoke use the following ' + 'command: "set binning arg1", where arg1 is the binning type of 1 or 2.' ) self.sendToStatus(helpBinning) if runList[2] == "temp": helpTemp = ( '"set temp" is used to set the temperature of the CCD. To invoke use the following ' + 'command: "set temp arg1", where arg1 is an int between -80 to -10 ' + "or warmup." ) self.sendToStatus(helpTemp) if runList[2] == "filter": helpFilter = ( '"set filter" is used to set the filter wheel position. To invoke use the following ' + 'command: "set filter arg1", where arg1 is an int between 1 and 6.' ) self.sendToStatus(helpFilter) # command: help expose # help set # help filter if sendCommand == "help": if runList[1] == "expose": helpExpose = '"expose" command is explicitely for taking several images in one command. ' helpExpose += 'This is invoked by typing "expose imageType" where imageType is either ' helpExpose += 'bias, dark, flat, or object. Use "expose help" followed by image type to ' helpExpose += 'see what arguments are needed (e.g. "expose help bias").' self.sendToStatus(helpExpose) if runList[1] == "set": helpSet = '"set" command is used to set the camera attributes of binning, temperature, and ' helpSet += 'filter position. Use "set help" followed by one of the attributes (binning, temp, ' helpSet += 'filter) to get info on the need arguements (e.g. "set help temp").' self.sendToStatus(helpSet) if runList[1] == "filter": helpFilter = '"filter" command is used to control the filter attributes.' self.sendToStatus(helpFilter) else: print("something went wrong") print(runList) dialog = wx.MessageDialog(None, runList, "", wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() self.commandBox.SetFocus()