Esempio n. 1
0
    def __UpdateReagentRobotStatus(self):
        """Updates the reagent robot status in response to system changes"""
        # Get the reagent robot control and check words
        nControlWordX, nCheckWordX = self.__pSystemModel.model["ReagentDelivery"].getRobotXControlWords()
        nControlWordY, nCheckWordY = self.__pSystemModel.model["ReagentDelivery"].getRobotYControlWords()

        # Enable or disable the robots
        if (nControlWordX == 0x10) and not ((nCheckWordX >> ROBONET_STATUS_READY) & 1):
            self.__pHardwareComm.FakePLC_EnableReagentRobotX()
        elif (nControlWordX == 0x08) and ((nCheckWordX >> ROBONET_STATUS_READY) & 1):
            self.__pHardwareComm.FakePLC_DisableReagentRobotX()
        if (nControlWordY == 0x10) and not ((nCheckWordY >> ROBONET_STATUS_READY) & 1):
            self.__pHardwareComm.FakePLC_EnableReagentRobotY()
        elif (nControlWordY == 0x08) and ((nCheckWordX >> ROBONET_STATUS_READY) & 1):
            self.__pHardwareComm.FakePLC_DisableReagentRobotY()

        # Home the robots
        if self.__pHardwareComm.FakePLC_CheckForHomingReagentRobotX() and self.__pHardwareComm.FakePLC_CheckForHomingReagentRobotY():
            # Check either of the reagent robots movement threads are running
            if ((self.__pHomeReagentRobotThread == None) or not self.__pHomeReagentRobotThread.is_alive()) and \
               ((self.__pMoveReagentRobotThread == None) or not self.__pMoveReagentRobotThread.is_alive()):
                # No, so kick off the homing thread
                nReagentRobotActualPositionRawX, nReagentRobotActualPositionRawZ = self.__pSystemModel.model["ReagentDelivery"].getCurrentPositionRaw()
                self.__pHomeReagentRobotThread = HomeReagentRobotThread()
                self.__pHomeReagentRobotThread.SetParameters(self.__pHardwareComm, nReagentRobotActualPositionRawX, nReagentRobotActualPositionRawZ)
                self.__pHomeReagentRobotThread.setDaemon(True)
                self.__pHomeReagentRobotThread.start()

            # Clear the homing flags
            self.__pHardwareComm.FakePLC_ResetReagentRobotHoming()