Esempio n. 1
0
    def __init__(self,
                 base,
                 rspec="default",
                 rdescript="unnamed command (CA)",
                 instructions="instructions missing",
                 nexus=None):
        self.set_nexus(nexus)
        on_complete = AsynchronousAction.hmc_complete(lambda data: receive_response(data))
        AsynchronousAction.__init__(
            self, [L(S(["cancel"], on_complete))], 1, 60, rdescript,
            False)  # cannot block, if it does, it'll block its own confirm command

        self.base = base
        self.rspec = rspec
        self.instructions = instructions

        mutable_integer = {"value": 0}

        def receive_response(
                data):  # signals to the stack to cease waiting, return True terminates
            '''
            receives response from homunculus, uses it to
            stop the stack and tell the ConfirmAction how
            to execute
            '''
            mutable_integer["value"] = data["confirm"]

        self.mutable_integer = mutable_integer
Esempio n. 2
0
    def __init__(self,
                 receiver,
                 rspec="default",
                 rdescript="unnamed command (BA)",
                 repetitions=60,
                 box_type=settings.QTYPE_DEFAULT,
                 box_settings={},
                 log_failure=False):
        _ = {"tries": 0}
        self._ = _  # signals to the stack to cease waiting, return True terminates

        def check_for_response():
            try:
                _data = self.nexus().comm.get_com("hmc").get_message()
            except Exception:
                if log_failure: utilities.simple_log()
                _["tries"] += 1
                if _["tries"] > 9:
                    return True  # try 10 times max if there's no Homonculus response
                else:
                    return False
            if _data is None: return False
            try:
                _data.append(
                    _["dragonfly_data"])  # pass dragonfly data into receiver function
                _["dragonfly_data"] = None
                receiver(_data)
            except Exception:
                if log_failure: utilities.simple_log()
            return True

        AsynchronousAction.__init__(
            self,  # cannot block, if it does, it'll block its own confirm command
            [L(S(["cancel"], check_for_response))],
            1,
            repetitions,
            rdescript,
            blocking=False)
        self.rspec = rspec
        self.box_type = box_type
        self.box_settings = box_settings  # custom instructions for setting up the tk window ("Homunculus")
        self.log_failure = log_failure
Esempio n. 3
0
 def __init__(self, action, t=3):
     AsynchronousAction.__init__(self, [L(S(["cancel"], action))], t, 100, "UC", False,
                                 None)
     self.show = True