def processDat(self, logLine, datFile): """ | Here we will decide how to process the datFile | Sample Types: | 6 - Water | 0 - Buffer | 1 - Static Sample | Sample type of DatFile is determined by the logline. We only currently care for 0 (buffer), or 1 (static Sample) | Is sample is a buffer, it needs to be passed to WorkerBufferAverage to be processed | If it is a sample it is passed to all workers to be processed by them if they want We check if the Workers need an AveragedBuffer which we then can request from WorkerBufferAverage We check for a rootname change indicating a new sample which may or may not require a new buffer average Args: logLine (LogLine Object): Latest Logline datFile (datFile Object): Corresponding DatFile from LogLine Raises: IndexError: Raised only on first pass, as we need the current user to check againse the previous user """ try: if changeInRootName( os.path.basename(self.logLines[-1].getValue("ImageLocation")), os.path.basename(self.logLines[-2].getValue("ImageLocation")), ): self.logger.info("There has been a change in the root name") self.sendCommand({"command": "root_name_change"}) if logLine.getValue("SampleType") == "0": self.logger.info("New Buffer!") self.needBuffer = True self.sendCommand({"command": "new_buffer"}) self.sendCommand({"command": "buffer", "buffer": datFile}) if logLine.getValue("SampleType") == "1": if self.needBuffer: averagedBuffer = self.requestAveragedBuffer() print "AVERAGED BUFFER" print averagedBuffer if averagedBuffer: self.sendCommand({"command": "averaged_buffer", "averaged_buffer": averagedBuffer}) self.needBuffer = False self.sendCommand({"command": "static_image", "static_image": datFile}) else: self.sendCommand({"command": "static_image", "static_image": datFile}) else: self.logger.info("So lets average with current buffer!") else: self.logger.info("No change in root name fellas") if logLine.getValue("SampleType") == "0": self.sendCommand({"command": "buffer", "buffer": datFile}) if logLine.getValue("SampleType") == "1": if self.needBuffer: averagedBuffer = self.requestAveragedBuffer() print averagedBuffer if averagedBuffer: self.sendCommand({"command": "averaged_buffer", "averaged_buffer": averagedBuffer}) self.needBuffer = False self.sendCommand({"command": "static_image", "static_image": datFile}) else: self.logger.critical("No averaged Buffer returned unable to perform subtraction") else: self.sendCommand({"command": "static_image", "static_image": datFile}) except IndexError: if self.first: self.first = False else: self.logger.info("INDEX ERROR - Should only occur on first pass!")
def processDatFile(self, datFile, logLine): """ Sample Types: 6 - Water 0 - Buffer 1 - Static Sample """ logger(self.name, "SampleType - " + str(logLine.getValue('SampleType'))) try: if (changeInRootName(os.path.basename(self.logLines[-1].getValue("ImageLocation")), os.path.basename(self.logLines[-2].getValue("ImageLocation")))): logger(self.name, "Change in root names") if (logLine.getValue("SampleType") == "0"): self.sendCommand("new_buffer") self.needBuffer = True #logger(self.name, "Buffer Received") self.sendBuffer(datFile) if (logLine.getValue("SampleType") == "1"): if (self.needBuffer): logger(self.name, "Need A Buffer") if (self.requestAverageBuffer()): self.sendAverageBuffer(self.aveBuffer) self.needBuffer = False self.sendImage(datFile) else: logger(self.name, "Request for averaged buffer failed, subtraction unable to occurr") else: self.sendImage(datFile) logger(self.name, "Just Image Sent") else: logger(self.name, "NO CHANGE in root names") if (logLine.getValue("SampleType") == "0"): self.sendBuffer(datFile) logger(self.name, "BUFFER SENT") if (logLine.getValue("SampleType") == "1"): if (self.needBuffer): logger(self.name, "Need A Buffer") if (self.requestAverageBuffer()): self.sendAverageBuffer(self.aveBuffer) self.needBuffer = False self.sendImage(datFile) else: logger(self.name, "Request for averaged buffer failed, can not subtract datfile") else: self.sendImage(datFile) logger(self.name, "No buffer needed") #send just the image except(IndexError): logger(self.name, "index error, must be first pass")