def displaySeriesImage(self, msg): msg = msg.split(",") imNum = int(msg[0]) print type(imNum) time = float(msg[1]) path = msg[2] print "Got:", msg # no abort then display the image if(self.abort and imNum <= int(self.seriesImageNumber)): print "Entered to display series image" # add a new deffered object d = self.protocol.addDeferred("seriesSent") d.addCallback(self.displaySeriesImage_thread) if(self.timer.IsRunning()): self.timer.Stop() self.parent.parent.parent.expGauge.SetValue(self.endTimer) # get stats data = als.getData(path) stats_list = als.calcStats(data) # change the gui with thread safety wx.CallAfter(self.safePlot, data, stats_list) self.parent.parent.parent.expGauge.SetValue(0) self.startTimer = 0 if(self.seriesImageNumber != None): if(imNum < int(self.seriesImageNumber)): thread.start_new_thread(self.exposeTimer, (time,))
def displayRealImage(self, msg): path = msg # no abort then display the image if self.abort: # add a new deffered object d = self.protocol.addDeferred("realSent") d.addCallback(self.displayRealImage_thread) if(self.timer.IsRunning()): self.timer.Stop() self.parent.parent.parent.expGauge.SetValue(self.endTimer) # get stats data = als.getData(path) stats_list = als.calcStats(data) # change the gui with thread safety wx.CallAfter(self.safePlot, data, stats_list) self.parent.parent.parent.expGauge.SetValue(0) self.startTimer = 0 thread.start_new_thread(self.exposeTimer, (self.timeToSend,))
def displayRealImage_callback(self, msg): path = msg # path to image (/tmp/image_date.fits) if(msg != "None"): # get data data = als.getData(path) stats_list = als.calcStats(data) # change the gui with thread safety wx.CallAfter(self.safePlot, data, stats_list)
def exposeCallback(self, msg): ### May need to thread to a different method if to slow results = msg.split(",") # immediatly reset button self.abort = False self.expButton.Enable(True) if(self.stopExp.IsEnabled()): self.stopExp.Enable(False) ## complete progress bar for image acquisition # check to see if timer is still going and stop it (callback might come in early) if(self.timer.IsRunning()): self.timer.Stop() # finish out gauge and then reset it self.parent.parent.parent.expGauge.SetValue(self.endTimer) # get success; success = int(results[0]) # 1 for true 0 for false #print success # at the end of the callback reset the gauge (signifies a reset for exposure) self.parent.parent.parent.expGauge.SetValue(0) self.startTimer = 0 print self.parent.parent.parent.imageOpen print "opened window" if(success == 1): # get name of image and path filePath = results[1].split("/") name = filePath[-1].rstrip() path = "" for i in filePath[:-1]: path += i + "/" print path, name # get data data = als.getData(path+name) stats_list = als.calcStats(data) # change the gui with thread safety wx.CallAfter(self.safePlot, data, stats_list) else: print "Successfully Aborted" pass
def onOpen(self, event): """ Opens when user selects to load an image. Allows user to select a load a saved fits/fit image. """ logger.info("Trying to open image") openFileDialog = wx.FileDialog(self, "Open Image File", "", "", "Image (*.fits;*.fit)|*.fits.*;*.fits;*.fit", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if openFileDialog.ShowModal() == wx.ID_CANCEL: return fileName = openFileDialog.GetFilename() fileName = fileName.split(".") if fileName[-1] in ["fits", "fit"]: data = als.getData(openFileDialog.GetPath()) stats_list = als.calcStats(data) self.parent.takeImage.exposureInstance.safePlot(data, stats_list)