def connect(self): root.info("Connecting to {0}".format(self.device_name)) if self.device is not None: self.disconnect() try: dev_future = ptf.DeviceProxy(self.device_name, wait=False) except pt.DevFailed as e: root.error("DeviceProxy returned error {0}".format(str(e))) return False dev_future.add_done_callback(self.connected_cb)
def connect(self): self.disconnect() root.info("Connecting to {0}".format(self.device_name)) self.device = None self.set_state(pt.DevState.UNKNOWN) try: dev_future = ptf.DeviceProxy(self.device_name, wait=False) except pt.DevFailed as e: root.error("DeviceProxy returned error {0}".format(str(e))) return False dev_future.add_done_callback(self.connected_cb)
def connect(self): """ Disconnect from camera by cancelling all outstanding commands. Then create new deviceproxy object. :return: """ self.disconnect() root.info("Connecting to {0}".format(self.device_name)) self.device = None self.set_state(pt.DevState.UNKNOWN) try: dev_future = ptf.DeviceProxy(self.device_name, wait=False) except pt.DevFailed as e: root.error("DeviceProxy returned error {0}".format(str(e))) return False dev_future.add_done_callback(self.connected_cb)
def startFactory(self): self.logger.info("Starting TangoAttributeFactory") self.d = deferred_from_future( tangof.DeviceProxy(self.device_name, wait=False)) self.d.addCallbacks(self.connection_success, self.connection_fail) return self.d
subscriber, str(e))) for rem_sub in remove_list: self.remove_subscriber(rem_sub) def get_attribute(self): return self.attr_result def set_attribute(self, attr): if type(attr) in [DeviceCommand, AttributeWrapper]: self.attr_result = attr.get_attribute() else: self.attr_result = attr root.debug("set attribute \"{0}\" to value {1}".format( self.name, self.attr_result.value)) self.notify_subscribers() if __name__ == "__main__": dev = ptf.DeviceProxy("sys/tg_test/1") state_dc = DeviceCommand("state", "read", dev, recurrent=False, period=1.0) state_at = AttributeWrapper("state") state_dc.add_subscriber(state_at.set_attribute) delay_dc = DeviceCommand("delay01", "delay", dev, 2.0) state_dc.add_condition(delay_dc) gain_dc = DeviceCommand("double_scalar", "read", dev) gain_dc.add_condition( state_at, invalid_range=[pt.DevState.UNKNOWN, pt.DevState.FAULT]) state_dc.start() delay_dc.start() gain_dc.start()