def processMessage(self, message): pause_time = random.expovariate(1.0 / self.mean_time) if (pause_time > 0.1): halModule.runWorkerTask(self, message, lambda: time.sleep(pause_time)) else: time.sleep(pause_time)
def processMessage(self, message): pause_time = random.expovariate(1.0/self.mean_time) if (pause_time > 0.1): halModule.runWorkerTask(self, message, lambda : time.sleep(pause_time)) else: time.sleep(pause_time)
def runHardwareTask(module, message, task): """ This just wraps halModule.runWorkerTask so that hardware modules do not need to also import halLib.halModule. Use this if your hardware module gets a message from HAL to do something which it cannot process immediately. This includes error handling and as well as holding onto the message so that HAL knows that is has not been fully processed. """ halModule.runWorkerTask(module, message, task)
def runHardwareTask(module, message, task): """ This just wraps halModule.runWorkerTask so that hardware modules do not need to also import halLib.halModule. Use this if your hardware module gets a message from HAL to do something which it cannot process immediately. This includes error handling and as well as holding onto the message so that HAL knows that is has not been fully processed. """ halModule.runWorkerTask(module, message, task)
def processMessage(self, message): if message.isType("start"): self.sendMessage(halMessage.HalMessage(m_type="tss1")) self.sendMessage(halMessage.HalMessage(m_type="tss2")) self.sendMessage(halMessage.HalMessage(m_type="tss3")) elif message.isType("tss1"): halModule.runWorkerTask(self, message, self.handleTSS1) elif message.isType("tss2"): halModule.runWorkerTask(self, message, self.handleTSS2) elif message.isType("tss3"): assert not ("tss2" in self.processed_messages) print(">> Okay", self.processed_messages) self.newMessage.emit( halMessage.HalMessage(source=self, m_type="tests done"))
def processMessage(self, message): if message.isType("start"): self.sendMessage(halMessage.HalMessage(m_type = "tss1")) self.sendMessage(halMessage.HalMessage(m_type = "tss2")) self.sendMessage(halMessage.HalMessage(m_type = "tss3")) elif message.isType("tss1"): halModule.runWorkerTask(self, message, self.handleTSS1) elif message.isType("tss2"): halModule.runWorkerTask(self, message, self.handleTSS2) elif message.isType("tss3"): assert not ("tss2" in self.processed_messages) print(">> Okay", self.processed_messages) self.newMessage.emit(halMessage.HalMessage(source = self, m_type = "tests done"))
def processMessage(self, message): if message.isType("configuration"): if message.sourceIs("timing"): timing_fn = message.getData()["properties"]["functionality"] is_time_base = (timing_fn.getTimeBase() == self.module_name) halModule.runWorkerTask(self, message, lambda : self.startFilm(is_time_base)) elif message.isType("configure1"): # Broadcast initial parameters. self.sendMessage(halMessage.HalMessage(m_type = "initial parameters", data = {"parameters" : self.camera_control.getParameters()})) # Send 'configuration' message with information about this camera. p_dict = {"module name" : self.module_name, "is camera" : True, "is master" : self.is_master} self.sendMessage(halMessage.HalMessage(m_type = "configuration", data = {"properties" : p_dict})) elif message.isType("current parameters"): message.addResponse(halMessage.HalMessageResponse(source = self.module_name, data = {"parameters" : self.camera_control.getParameters().copy()})) elif message.isType("get functionality"): # This message comes from display.cameraDisplay among others. if (message.getData()["name"] == self.module_name): message.addResponse(halMessage.HalMessageResponse(source = self.module_name, data = {"functionality" : self.camera_control.getCameraFunctionality()})) elif message.isType("new parameters"): # This message comes from settings.settings halModule.runWorkerTask(self, message, lambda : self.updateParameters(message)) elif message.isType("shutter clicked"): # This message comes from the shutter button. if (message.getData()["camera"] == self.module_name): halModule.runWorkerTask(self, message, self.toggleShutter) elif message.isType("start camera"): # This message comes from film.film. It is sent once for slaved # cameras and once for master cameras. if (message.getData()["master"] == self.is_master): halModule.runWorkerTask(self, message, self.startCamera) elif message.isType("start film"): # This message comes from film.film, we save the film settings # but don't actually do anything until we get a 'configuration' # message from timing.timing. self.film_settings = message.getData()["film settings"] elif message.isType("stop camera"): # This message comes from film.film. It is sent once for slaved # cameras and once for master cameras. if (message.getData()["master"] == self.is_master): halModule.runWorkerTask(self, message, self.stopCamera) elif message.isType("stop film"): # This message comes from film.film, it goes to all camera at once. self.film_length = None message.addResponse(halMessage.HalMessageResponse(source = self.module_name, data = {"parameters" : self.camera_control.getParameters()})) halModule.runWorkerTask(self, message, self.stopFilm)
def processMessage(self, message): if message.isType("configuration"): if message.sourceIs("timing"): timing_fn = message.getData()["properties"]["functionality"] is_time_base = (timing_fn.getTimeBase() == self.module_name) halModule.runWorkerTask(self, message, lambda : self.startFilm(is_time_base)) elif message.isType("configure1"): # Broadcast initial parameters. self.sendMessage(halMessage.HalMessage(m_type = "initial parameters", data = {"parameters" : self.camera_control.getParameters()})) elif message.isType("current parameters"): message.addResponse(halMessage.HalMessageResponse(source = self.module_name, data = {"parameters" : self.camera_control.getParameters().copy()})) elif message.isType("get functionality"): # This message comes from display.cameraDisplay among others. if (message.getData()["name"] == self.module_name): message.addResponse(halMessage.HalMessageResponse(source = self.module_name, data = {"functionality" : self.camera_control.getCameraFunctionality()})) elif message.isType("new parameters"): # This message comes from settings.settings halModule.runWorkerTask(self, message, lambda : self.updateParameters(message)) elif message.isType("shutter clicked"): # This message comes from the shutter button. if (message.getData()["camera"] == self.module_name): halModule.runWorkerTask(self, message, self.toggleShutter) elif message.isType("start camera"): # This message comes from film.film, it is camera specific as # slave cameras need to be started before master camera(s). if (message.getData()["camera"] == self.module_name): halModule.runWorkerTask(self, message, self.startCamera) elif message.isType("start film"): # This message comes from film.film, we save the film settings # but don't actually do anything until we get a 'configuration' # message from timing.timing. self.film_settings = message.getData()["film settings"] elif message.isType("stop camera"): # This message comes from film.film. if (message.getData()["camera"] == self.module_name): halModule.runWorkerTask(self, message, self.stopCamera) elif message.isType("stop film"): # This message comes from film.film, it goes to all camera at once. self.film_length = None message.addResponse(halMessage.HalMessageResponse(source = self.module_name, data = {"parameters" : self.camera_control.getParameters()})) halModule.runWorkerTask(self, message, self.stopFilm)
def processMessage(self, message): if message.isType("start"): halModule.runWorkerTask(self, message, self.infiniteLoop, job_time_ms=100)
def processMessage(self, message): if message.isType("start"): halModule.runWorkerTask(self, message, self.throwError)