class Interface(Core.HwInterface): Core.DEB_CLASS(Core.DebModCamera, "Interface") def __init__(self): Core.HwInterface.__init__(self) self.__comm = Communication() self.__comm.start() self.__detInfo = DetInfoCtrlObj() self.__detInfo.init() self.__buffer = BufferCtrlObj(self.__comm, self.__detInfo) self.__syncObj = SyncCtrlObj(self.__comm, self.__detInfo) self.__acquisition_start_flag = False self.__kind = 5 self.__ctSaving = None def __del__(self): self.__comm.quit() self.__buffer.quit() def quit(self): self.__comm.quit() self.__buffer.quit() @Core.DEB_MEMBER_FUNCT def getCapList(self): return [ Core.HwCap(x) for x in [self.__detInfo, self.__syncObj, self.__buffer] ] @Core.DEB_MEMBER_FUNCT def reset(self, reset_level): if reset_level == self.HardReset: self.__comm.hardReset() self.__buffer.reset() self.__comm.softReset() @Core.DEB_MEMBER_FUNCT def takeDarks(self, Texp): self.__comm.takeDarks(Texp) @Core.DEB_MEMBER_FUNCT def prepareAcq(self): self.__buffer.reset() self.__syncObj.prepareAcq() if self.__ctSaving != None: self.__comm.setCtSavingLink(self.__ctSaving) self.__comm.Configure() self.__acquisition_start_flag = False @Core.DEB_MEMBER_FUNCT def startAcq(self): self.__acquisition_start_flag = True self.__buffer.start() self.__comm.startAcquisition() @Core.DEB_MEMBER_FUNCT def stopAcq(self): self.__comm.stopAcquisition() self.__buffer.stop() self.__acquisition_start_flag = False @Core.DEB_MEMBER_FUNCT def getStatus(self): ComState = self.__comm.getState() status = Core.HwInterface.StatusType() if self.__buffer.is_error(): status.det = Core.DetFault status.acq = Core.AcqFault deb.Error("Buffer is in Fault state") elif ComState == Communication.DTC_STATE_ERROR: status.det = Core.DetFault status.acq = Core.AcqFault deb.Error("Detector is in Fault state") elif ComState == Communication.DTC_STATE_CONFIGDET or not self.__comm.darksReady( ): # elif False: status.det = Core.DetFault status.acq = Core.AcqConfig deb.Warning("Waiting for configuration") else: if ComState != Communication.DTC_STATE_IDLE: status.det = Core.DetFault status.acq = Core.AcqRunning else: status.det = Core.DetIdle lastAcquiredFrame = self.__buffer.getLastAcquiredFrame() requestNbFrame = self.__syncObj.getNbFrames() print "Frames set-rdy:", requestNbFrame, lastAcquiredFrame + 1 if (not self.__acquisition_start_flag) or \ (lastAcquiredFrame >= 0 and \ lastAcquiredFrame == (requestNbFrame - 1)): status.acq = Core.AcqReady else: status.acq = Core.AcqRunning status.det_mask = (Core.DetExposure | Core.DetFault) return status @Core.DEB_MEMBER_FUNCT def getNbAcquiredFrames(self): return self.__buffer.getLastAcquiredFrame() + 1 @Core.DEB_MEMBER_FUNCT def getNbHwAcquiredFrames(self): return self.getNbAcquiredFrames() #get lower communication def communication(self): return self.__comm #get lower buffer def buffer(self): return self.__buffer def setFilePath(self, path): self.__comm.setFilePath(path) def setFileBase(self, base): self.__comm.setFileBase(base) def setFileExtension(self, ext): self.__comm.setFileExtension(ext) def setCtSavingLink(self, CTs): self.__ctSaving = CTs
class Interface(Core.HwInterface) : Core.DEB_CLASS(Core.DebModCamera, "Interface") def __init__(self) : Core.HwInterface.__init__(self) self.__comm = Communication() self.__comm.start() self.__detInfo = DetInfoCtrlObj() self.__detInfo.init() self.__buffer = BufferCtrlObj(self.__comm,self.__detInfo) self.__syncObj = SyncCtrlObj(self.__comm,self.__detInfo) def __del__(self) : self.__comm.quit() def quit(self) : self.__comm.quit() @Core.DEB_MEMBER_FUNCT def getCapList(self) : return [Core.HwCap(x) for x in [self.__detInfo,self.__syncObj,self.__buffer]] @Core.DEB_MEMBER_FUNCT def reset(self,reset_level): pass @Core.DEB_MEMBER_FUNCT def prepareAcq(self): self.__syncObj.prepareAcq() # while self.__comm.getCurrentCommand() != Communication.COM_NONE: # time.sleep(0.1) @Core.DEB_MEMBER_FUNCT def loadConfig(self,file1,file2): self.__comm.setCalFiles(file1,file2) self.__comm.Configure() @Core.DEB_MEMBER_FUNCT def setITHLoffset(self,th) : self.__comm.setITHLoffset(th) @Core.DEB_MEMBER_FUNCT def getITHLoffset(self) : return self.__comm.getITHLoffset() @Core.DEB_MEMBER_FUNCT def setConfigId(self,Id): self.__comm.setConfigId(Id) @Core.DEB_MEMBER_FUNCT def getConfigId(self): return self.__comm.getConfigId() @Core.DEB_MEMBER_FUNCT def startAcq(self) : self.__comm.startAcquisition() @Core.DEB_MEMBER_FUNCT def stopAcq(self) : pass @Core.DEB_MEMBER_FUNCT def getStatus(self) : CommOk = self.__comm.isAlive() and self.__comm.isRunning() CommState = self.__comm.getCurrentCommand() status = Core.HwInterface.StatusType() if not CommOk: status.det = Core.DetFault status.acq = Core.AcqFault deb.Error("Detector communication is not running") elif CommState == Communication.COM_NONE: status.det = Core.DetIdle status.acq = Core.AcqReady elif not self.__comm.isConfigured() : status.det = Core.DetFault status.acq = Core.AcqConfig else: if CommState == Communication.COM_START or \ CommState == Communication.COM_TEST: status.det = Core.DetExposure else: status.det = Core.DetFault if self.__syncObj.getNbFrames() == self.__comm.getNbFramesReady(): status.acq = Core.AcqReady else: status.acq = Core.AcqRunning status.det_mask = (Core.DetExposure|Core.DetFault) return status @Core.DEB_MEMBER_FUNCT def getNbAcquiredFrames(self) : return self.__comm.getNbFramesReady() @Core.DEB_MEMBER_FUNCT def getNbHwAcquiredFrames(self): return self.getNbAcquiredFrames()
class Interface(Core.HwInterface) : Core.DEB_CLASS(Core.DebModCamera, "Interface") def __init__(self) : Core.HwInterface.__init__(self) self.__comm = Communication() self.__comm.start() self.__detInfo = DetInfoCtrlObj() self.__detInfo.init() self.__buffer = BufferCtrlObj(self.__comm,self.__detInfo) self.__syncObj = SyncCtrlObj(self.__comm,self.__detInfo) self.__acquisition_start_flag = False self.__kind = 5 self.__ctSaving = None def __del__(self) : self.__comm.quit() self.__buffer.quit() def quit(self) : self.__comm.quit() self.__buffer.quit() @Core.DEB_MEMBER_FUNCT def getCapList(self) : return [Core.HwCap(x) for x in [self.__detInfo,self.__syncObj, self.__buffer]] @Core.DEB_MEMBER_FUNCT def reset(self,reset_level): if reset_level == self.HardReset: self.__comm.hardReset() self.__buffer.reset() self.__comm.softReset() @Core.DEB_MEMBER_FUNCT def takeDarks(self,Texp): self.__comm.takeDarks(Texp) @Core.DEB_MEMBER_FUNCT def prepareAcq(self): self.__buffer.reset() self.__syncObj.prepareAcq() if self.__ctSaving != None : self.__comm.setCtSavingLink(self.__ctSaving) self.__comm.Configure() self.__acquisition_start_flag = False @Core.DEB_MEMBER_FUNCT def startAcq(self) : self.__acquisition_start_flag = True self.__buffer.start() self.__comm.startAcquisition() @Core.DEB_MEMBER_FUNCT def stopAcq(self) : self.__comm.stopAcquisition() self.__buffer.stop() self.__acquisition_start_flag = False @Core.DEB_MEMBER_FUNCT def getStatus(self) : ComState = self.__comm.getState() status = Core.HwInterface.StatusType() if self.__buffer.is_error() : status.det = Core.DetFault status.acq = Core.AcqFault deb.Error("Buffer is in Fault state") elif ComState == Communication.DTC_STATE_ERROR: status.det = Core.DetFault status.acq = Core.AcqFault deb.Error("Detector is in Fault state") elif ComState == Communication.DTC_STATE_CONFIGDET or not self.__comm.darksReady() : # elif False: status.det = Core.DetFault status.acq = Core.AcqConfig deb.Warning("Waiting for configuration") else: if ComState != Communication.DTC_STATE_IDLE: status.det = Core.DetFault status.acq = Core.AcqRunning else: status.det = Core.DetIdle lastAcquiredFrame = self.__buffer.getLastAcquiredFrame() requestNbFrame = self.__syncObj.getNbFrames() print "Frames set-rdy:",requestNbFrame,lastAcquiredFrame+1 if (not self.__acquisition_start_flag) or \ (lastAcquiredFrame >= 0 and \ lastAcquiredFrame == (requestNbFrame - 1)): status.acq = Core.AcqReady else: status.acq = Core.AcqRunning status.det_mask = (Core.DetExposure|Core.DetFault) return status @Core.DEB_MEMBER_FUNCT def getNbAcquiredFrames(self) : return self.__buffer.getLastAcquiredFrame() + 1 @Core.DEB_MEMBER_FUNCT def getNbHwAcquiredFrames(self): return self.getNbAcquiredFrames() #get lower communication def communication(self) : return self.__comm #get lower buffer def buffer(self) : return self.__buffer def setFilePath(self,path) : self.__comm.setFilePath(path) def setFileBase(self,base) : self.__comm.setFileBase(base) def setFileExtension(self,ext) : self.__comm.setFileExtension(ext) def setCtSavingLink(self,CTs): self.__ctSaving = CTs