コード例 #1
0
    def __init__(self,
                 protocol_xml_path="default_config.xml",
                 command_xml_path="default_config.xml",
                 verbose=False):
        super(KilroyProtocols, self).__init__()

        # Initialize internal attributes
        self.verbose = verbose
        self.protocol_xml_path = protocol_xml_path
        self.command_xml_path = command_xml_path
        self.protocol_names = []
        self.protocol_commands = []  # [Instrument Type, command_info]
        self.protocol_durations = []
        self.num_protocols = 0
        self.status = [-1, -1]  # Protocol ID, command ID within protocol
        self.issued_command = []
        self.received_message = None

        print(
            "----------------------------------------------------------------------"
        )

        # Create instance of ValveCommands class
        print('creating valveCommands')
        self.valveCommands = ValveCommands(xml_file_path=self.command_xml_path,
                                           verbose=self.verbose)

        # Connect valve command issue signal
        self.valveCommands.change_command_signal.connect(
            self.issueValveCommand)
        print(self.issueValveCommand)

        # Create instance of PumpCommands class
        self.pumpCommands = PumpCommands(xml_file_path=self.command_xml_path,
                                         verbose=self.verbose)

        # Connect pump commands issue signal
        self.pumpCommands.change_command_signal.connect(self.issuePumpCommand)

        # Create GUI
        self.createGUI()

        # Load configurations
        self.loadProtocols(xml_file_path=self.protocol_xml_path)

        # Create protocol timer--controls when commands are issued
        self.protocol_timer = QtCore.QTimer()
        self.protocol_timer.setSingleShot(True)
        self.protocol_timer.timeout.connect(self.advanceProtocol)

        # Create elapsed time timer--determines time between command calls
        self.elapsed_timer = QtCore.QElapsedTimer()
        self.poll_elapsed_time_timer = QtCore.QTimer()
        self.poll_elapsed_time_timer.setInterval(1000)
        self.poll_elapsed_time_timer.timeout.connect(self.updateElapsedTime)