Пример #1
0
 def __init__(self, parent):
     self.__parent = parent
     self.__cov_count = 0
     self._old_value = None
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     return
Пример #2
0
 def event_unsubscribe(self, *args):
     self._subscription_lock.acquire()
     try:
         EventProducerMixin.event_unsubscribe(self, *args)
         self._subscribers = max(0, self._subscribers - 1)
     finally:
         self._subscription_lock.release()
Пример #3
0
 def __init__(self):
     self._running = 0
     self.driver = None
     self.mac_address = None
     self.discovery_mode = 'None'
     CompositeNode.__init__(self)
     AutoDiscoveredNode.__init__(self)
     EventProducerMixin.__init__(self)
     self.device_map = {} #keyed by mac address of clients; value=Child node
     self._out_q = [] #request queue
     self._out_q_cv = threading.Condition()
     self._mutex = threading.Lock() #prevent multiple access to outbound commands
     self._registered_clients = {}
     self.transceiver_state = TransceiverState[0]
     self.cov = ChangeOfValueEvent(self, None, self.transceiver_state)
     self.debug = debug
     self.timeout = 10 #seconds
     self.who_is_interval = 10 #seconds
     self.default_discovered_protocol_module = None
     # @todo
     # initailize this through configuration
     self.default_discovered_protocol_module = feu
     self.transceiver_state = 0
     self.relay_node = '/interfaces/relay1'  #this is temporary, should be None
     self.active_devices = {}
     self.status = None
Пример #4
0
 def __init__( self ):
     ConfigurableNode.__init__( self )
     EventProducerMixin.__init__( self )
     #
     # Set old value to something which will never be valid so that
     # we always generate an event on startup.
     self.old_value = -99
Пример #5
0
 def event_subscribe(self, *args):
     self._subscribe_lock.acquire()
     try:
         self._subscribed += 1
         EventProducerMixin.event_subscribe(self, *args)
         if self._cached_result is None:
             last_value = None
         else:
             last_value = self._cached_result.value
         try:
             self.get() # throw away
         except:
             pass
         # generate initial event
         self._trigger_cov(last_value)
         if self._subscribed == 1:
             # initial subscription
             address = self._device_node.address
             cmd = self._msg_req_type
             callback = self.update
             self._protocol_node.register(
                 address, cmd, callback, self.ttl / 2
                 )
     finally:
         self._subscribe_lock.release()
Пример #6
0
 def __init__(self, parent):
     self.__parent = parent
     self.__cov_count = 0
     self._old_value = None
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     return
Пример #7
0
 def __init__(self):
     self.__group = None
     self._value = None
     self._old_value = None
     self._last_update = 0
     self.__cv = Condition()
     super(LightPoint, self).__init__()
     EventProducerMixin.__init__(self)
Пример #8
0
 def __init__(self):
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     self._drives = []
     self.isStarted = 0
     self.sched_id = None
     self.period = 15
     return
Пример #9
0
 def event_subscribe(self, *args):
     EventProducerMixin.event_subscribe(self, *args)
     self.old_value = self.get()
     # generate initial event
     self.event_generate(
         ChangeOfValueEvent(self, self.old_value, self.old_value,
                            time.time()))
     self.cache.add_callback((self.group_id, self.addr), self._trigger_cov)
Пример #10
0
 def event_subscribe(self, *args):
     EventProducerMixin.event_subscribe(self, *args)
     try:
         self._last_value = self.get()
     except:
         self._last_value = None
     # generate initial event
     self.event_generate(ChangeOfValueEvent(self, self._last_value, self._last_value, time.time()))
Пример #11
0
 def __init__(self):
     self.source = None
     self.updated = 0
     self.synclock = RLock()
     self.result = Undefined
     self.support_cov = False
     self.created = uptime.secs()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
Пример #12
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     EventConsumerMixin.__init__(self)
     self._current_id = None
     self._event_class = None
     self.start_counter = 0
     self.pnode_obj = None
     self.pnode_subscribed = 0
Пример #13
0
 def __init__(self):
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     self._schedule_lock = Lock()
     self._schedule_condition = Condition()
     self._value_lock = Lock()
     self._value_condition = Condition()
     self.__schedule = None
     self.__value = None
Пример #14
0
 def __init__(self):
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     self._schedule_lock = Lock()
     self._schedule_condition = Condition()
     self._value_lock = Lock()
     self._value_condition = Condition()
     self.__schedule = None
     self.__value = None
Пример #15
0
 def __init__( self, log_id ):
     CompositeNode.__init__( self )
     ConnectionMixin.__init__( self )
     EventProducerMixin.__init__( self )
     self.critical_data = self._CriticalData()
     self._log_id = log_id
     self._service_name = None
     self._device = None
     self._port = None
Пример #16
0
 def event_unsubscribe(self, *args):
     self._subscription_lock.acquire()
     try:
         EventProducerMixin.event_unsubscribe(self, *args)
         if self.parent.can_bundle() and self.bundle:
             self.parent.unsubscribe(self.prop_name)
     finally:
         self._subscription_lock.release()
     return
Пример #17
0
 def __init__(self):
     ConfigurableNode.__init__(self)
     EventProducerMixin.__init__(self)
     EventConsumerMixin.__init__(self)
     self._current_id = None
     self._event_class = None
     self.start_counter = 0
     self.pnode_obj = None
     self.pnode_subscribed = 0
Пример #18
0
 def event_unsubscribe(self, *args):
     self._subscription_lock.acquire()
     try:
         EventProducerMixin.event_unsubscribe(self, *args)
         if self.parent.can_bundle() and self.bundle:
             self.parent.unsubscribe(self.prop_name)
     finally:
         self._subscription_lock.release()
     return
Пример #19
0
 def __init__(self, log_id):
     CompositeNode.__init__(self)
     ConnectionMixin.__init__(self)
     EventProducerMixin.__init__(self)
     self.critical_data = self._CriticalData()
     self._log_id = log_id
     self._service_name = None
     self._device = None
     self._port = None
Пример #20
0
 def __init__(self):
     self.source = None
     self.updated = 0
     self.synclock = RLock()
     self.result = Undefined
     self.support_cov = False
     self.created = uptime.secs()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
Пример #21
0
 def __init__(self):
     Calculator.__init__(self)
     EventProducerMixin.__init__(self)
     self._state = self.INITIALIZING
     self._current_id = None
     self._scheduled = None
     self._state_lock = Lock()
     self._schedule_lock = Lock()
     self.require_acknowledge = 0
     return
Пример #22
0
 def __init__(self):
     Calculator.__init__(self)
     EventProducerMixin.__init__(self)
     self._state = self.INITIALIZING
     self._current_id = None
     self._scheduled = None
     self._state_lock = Lock()
     self._schedule_lock = Lock()
     self.require_acknowledge = 0
     return
Пример #23
0
 def __init__( self ):
     CompositeNode.__init__( self )
     EventProducerMixin.__init__( self )
     #
     self.mount_point = None
     self.debug = None
     #
     # Set old value to something which will never be valid so that
     # we always generate an event on startup.
     self.old_value = -99
Пример #24
0
 def __init__(self):
     self._last_rcvd = 0
     self._subscribers = 0
     self._scheduled = None
     self._skip_cache = False
     self._cached_result = None
     self._exec_delay = _Buffer(5)
     self._subscription_lock = Lock()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
Пример #25
0
 def __init__(self):
     self._last_result = None
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     self._subscribe_lock = threading.Lock()
     self._subscribed = 0
     self._last_rcvd = 0
     self._cached_result = None
     self._msg_req_type = None
     self._device_node = None
     self._protocol_node = None
Пример #26
0
 def __init__(self):
     self._last_result = None
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     self._subscribe_lock = threading.Lock()
     self._subscribed = 0
     self._last_rcvd = 0
     self._cached_result = None
     self._msg_req_type = None
     self._device_node = None
     self._protocol_node = None
Пример #27
0
 def __init__(self):
     self.running = 0
     self._children_have_been_discovered = 0
     CompositeNode.__init__(self)
     AutoDiscoveredNode.__init__(self)
     EventProducerMixin.__init__(self)
     self.csafe = None
     self._mutex = threading.Lock() #preven multiple io operations
     self.ttl = 10
     self.feu_state = None
     self.cov = ChangeOfValueEvent(self, None, self.feu_state)
     self.description = None
Пример #28
0
 def __init__(self):
     # overridden by subclasses
     self._pv_index = None
     self._last_rcvd = 0.0
     self._last_rcvd_dlta = 0.0
     self._cached_value = None
     self._cached_result = None
     self._prop_values = None
     self._subscription_lock = Lock()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     return
Пример #29
0
 def __init__(self):
     # overridden by subclasses
     self._pv_index = None
     self._last_rcvd = 0.0
     self._last_rcvd_dlta = 0.0
     self._cached_value = None
     self._cached_result = None
     self._prop_values = None
     self._subscription_lock = Lock()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
     return
Пример #30
0
 def event_unsubscribe(self, *args):
     self._subscribe_lock.acquire()
     try:
         assert self._subscribed >= 0
         self._subscribed -= 1
         EventProducerMixin.event_subscribe(self, *args)
         if self._subscribed == 0:
             address = self._device_node.address
             cmd = self._msg_req_type
             callback = self.update
             self._protocol_node.unregister(address, cmd, callback)
     finally:
         self._subscribe_lock.release()
Пример #31
0
 def event_unsubscribe(self, *args):
     self._subscribe_lock.acquire()
     try:
         assert self._subscribed >= 0
         self._subscribed -= 1
         EventProducerMixin.event_subscribe(self, *args)
         if self._subscribed == 0:
             address = self._device_node.address
             cmd = self._msg_req_type
             callback = self.update
             self._protocol_node.unregister(address, cmd, callback)
     finally:
         self._subscribe_lock.release()
Пример #32
0
 def __init__(self, device=None):
     if device is not None:
         self.device = BrivoDevice(device)
         self.brivo_id_value = device.get('id').get('value')
     else:
         self.device = None
     self.state = self.DeviceState(self)
     self.running = False
     self._last_value = None
     self.__dispatcher = None
     super(Device, self).start()
     # call __init__ on old style class
     EventProducerMixin.__init__(self)
     return
Пример #33
0
 def __init__(self, line_handler = None):
     CompositeNode.__init__(self)
     ActiveProxyAbstractClass.__init__(self)
     EventProducerMixin.__init__(self)
     self.__cov_count = 0
     self._line_handler = line_handler
     self._old_value = None
     self.__status = None
     self.proxy_lan_addr = None
     self.proxy_obj_ref = None
     self._value = None
     self._state = None
     self._get_via_cov = None
     return
Пример #34
0
 def __init__(self, line_handler=None):
     CompositeNode.__init__(self)
     ActiveProxyAbstractClass.__init__(self)
     EventProducerMixin.__init__(self)
     self.__cov_count = 0
     self._line_handler = line_handler
     self._old_value = None
     self.__status = None
     self.proxy_lan_addr = None
     self.proxy_obj_ref = None
     self._value = None
     self._state = None
     self._get_via_cov = None
     return
Пример #35
0
 def event_subscribe(self, *args):
     self._subscription_lock.acquire()
     try:
         already_subscribed = self.event_has_subscribers()
         EventProducerMixin.event_subscribe(self, *args)
         if self.parent.can_bundle() and self.bundle:
             self.parent.subscribe(self.prop_name, self.update_cache)
         elif not already_subscribed:
             self.update_continuous(None)
             if self._cached_result and \
                 (uptime.secs() - self._cached_result.timestamp) < self.ttl:
                 self._trigger_cov(self._cached_result.value,
                                   self._cached_result.value, time.time())
     finally:
         self._subscription_lock.release()
     return
Пример #36
0
 def event_subscribe(self, consumer, event, **keywords):
     self.__cov_lock.acquire()
     try:
         EventProducerMixin.event_subscribe(self, consumer, event,
                                            **keywords)
         if event is ChangeOfValueEvent:
             if self.__cov_count == 0:
                 self.__parent.event_subscribe(self, event, **keywords)
             else:
                 # Force initial COV value on parent.  Oh what a tangled
                 # web.
                 self.__parent._request_cov_callbacks()
             self.__cov_count += 1
     finally:
         self.__cov_lock.release()
     return
Пример #37
0
 def event_unsubscribe(self, consumer, event, **keywords):
     self.__cov_lock.acquire()
     try:
         EventProducerMixin.event_unsubscribe(self, consumer, event,
                                              **keywords)
         if event is ChangeOfValueEvent:
             self.__cov_count -= 1
             if self.__cov_count == 0:
                 self.__parent.event_unsubscribe(
                     self, event, **keywords)
             elif self.__cov_count < 0:
                 # @fixme add log message.
                 self.__cov_count = 0
     finally:
         self.__cov_lock.release()
     return
Пример #38
0
 def __init__(self, mac_address=None):
     self.running = 0
     self._children_have_been_discovered = 0
     Port.__init__(self)
     AutoDiscoveredNode.__init__(self)
     EventProducerMixin.__init__(self)
     if mac_address:
         self.mac_address = mac_address
     else:
         self.mac_address = REQUIRED
     self.in_range = None
     self.debug = debug
     self.transceiver_state = TransceiverState[0]
     self.cov = ChangeOfValueEvent(self, None, self.transceiver_state)
     self.from_discovery = 0 # 1: remote xcvr assoc'd with this node was discovered by Aerocomm Protocol code
     self.from_config = 0 # 1: remote xcvr assocd with this node was specified in config recvd from Client App
Пример #39
0
 def _event_subscribe(self, consumer, event, **keywords):
     EventProducerMixin.event_subscribe(self, consumer, event, **keywords)
     if event is ChangeOfValueEvent:
         if self.is_bound_proxy():
             # Cheesy HACK that ensures COV callback for bound points.
             self._line_handler.register_bound_proxy(self)
         else:
             self.__cov_lock.acquire()
             try:
                 # Always _request_cov_callbacks because we rely on the
                 # initial callback to generate an initial event.
                 self._request_cov_callbacks()
                 self.__cov_count += 1
             finally:
                 self.__cov_lock.release()
     return
Пример #40
0
 def event_unsubscribe(self, consumer, event, **keywords):
     self.__cov_lock.acquire()
     try:
         EventProducerMixin.event_unsubscribe(self, consumer, event,
                                              **keywords)
         if event is ChangeOfValueEvent:
             self.__cov_count -= 1
             if self.__cov_count == 0:
                 self.__parent.event_unsubscribe(self, event,
                                                 **keywords)
             elif self.__cov_count < 0:
                 # @fixme add log message.
                 self.__cov_count = 0
     finally:
         self.__cov_lock.release()
     return
Пример #41
0
 def event_subscribe(self, consumer, event, **keywords):
     self.__cov_lock.acquire()
     try:
         EventProducerMixin.event_subscribe(self, consumer, event,
                                            **keywords)
         if event is ChangeOfValueEvent:
             if self.__cov_count == 0:
                 self.__parent.event_subscribe(self, event, **keywords)
             else:
                 # Force initial COV value on parent.  Oh what a tangled
                 # web.
                 self.__parent._request_cov_callbacks()
             self.__cov_count += 1
     finally:
         self.__cov_lock.release()
     return
Пример #42
0
 def _event_subscribe(self, consumer, event, **keywords):
     EventProducerMixin.event_subscribe(self, consumer, event, **keywords)
     if event is ChangeOfValueEvent:
         if self.is_bound_proxy():
             # Cheesy HACK that ensures COV callback for bound points.
             self._line_handler.register_bound_proxy(self)
         else:
             self.__cov_lock.acquire()
             try:
                 # Always _request_cov_callbacks because we rely on the
                 # initial callback to generate an initial event.
                 self._request_cov_callbacks()
                 self.__cov_count += 1
             finally:
                 self.__cov_lock.release()
     return
Пример #43
0
 def event_subscribe(self, *args):
     self._subscription_lock.acquire()
     try:
         already_subscribed = self.event_has_subscribers()
         EventProducerMixin.event_subscribe(self, *args)
         if self.parent.can_bundle() and self.bundle:
             self.parent.subscribe(self.prop_name, self.update_cache)
         elif not already_subscribed:
             self.update_continuous(None)
             if self._cached_result and \
                 (uptime.secs() - self._cached_result.timestamp) < self.ttl:
                 self._trigger_cov(
                     self._cached_result.value, self._cached_result.value, time.time()
                 )
     finally:
         self._subscription_lock.release()
     return
Пример #44
0
 def __init__(self,*args, **kw):
     super(ScheduleManager, self).__init__(*args, **kw)
     EventProducerMixin.__init__(self)
     EventConsumerMixin.__init__(self, self.event_handler)
     self.remotes_loaded = False
     self.__running = False
     self._hm = None
     self._ctlsvc = None
     self._hm_scheduled = None
     self._ph_scheduled = None
     self._ph_loader_scheduled = None
     self._ph_loaded = False
     self.__last_pruned = None
     self._proxied_manager = _ProxiedScheduleManager(self)
     self.__legacy_schedules = []
     self.__legacy_needs_pruning = []
     self.__ph_legacy_needs_pruning = []
Пример #45
0
 def __init__(self, *args, **kw):
     super(ScheduleManager, self).__init__(*args, **kw)
     EventProducerMixin.__init__(self)
     EventConsumerMixin.__init__(self, self.event_handler)
     self.remotes_loaded = False
     self.__running = False
     self._hm = None
     self._ctlsvc = None
     self._hm_scheduled = None
     self._ph_scheduled = None
     self._ph_loader_scheduled = None
     self._ph_loaded = False
     self.__last_pruned = None
     self._proxied_manager = _ProxiedScheduleManager(self)
     self.__legacy_schedules = []
     self.__legacy_needs_pruning = []
     self.__ph_legacy_needs_pruning = []
Пример #46
0
 def _event_unsubscribe(self, consumer, event, **keywords):
     EventProducerMixin.event_unsubscribe(self, consumer, event, **keywords)
     if event is ChangeOfValueEvent:
         if self.is_bound_proxy():
             pass
         else:
             self.__cov_lock.acquire()
             try:
                 self.__cov_count -= 1
                 if self.__cov_count == 0:
                     self._line_handler.unregister_rznet_cov(
                         self.lan_address, self.id_number)
                 elif self.__cov_count < 0:
                     # @fixme add log message.
                     self.__cov_count = 0
             finally:
                 self.__cov_lock.release()
     return
Пример #47
0
 def __init__(self):
     self.host = None
     self.period = 30
     self.last_update = 0
     self.last_refresh = 0
     self.manage_proxies = None
     self.last_state_change = 0
     self.__proxy = None
     self.__fw_node = None
     self.__net_node = None
     self.__lic_node = None
     self.__manager = None
     self._scheduled = None
     self.__entity_root = '/'
     self.__scheme = None
     self._cached_result = None
     self.__cached_remotes = FixedSizeDict()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
Пример #48
0
 def _event_unsubscribe(self,consumer,event,**keywords):
     EventProducerMixin.event_unsubscribe(self, consumer, event, **keywords)
     if event is ChangeOfValueEvent:
         if self.is_bound_proxy():
             pass
         else:
             self.__cov_lock.acquire()
             try:
                 self.__cov_count -= 1
                 if self.__cov_count == 0:
                     self._line_handler.unregister_rznet_cov(
                         self.lan_address,
                         self.id_number
                         )
                 elif self.__cov_count < 0:
                     # @fixme add log message.
                     self.__cov_count = 0
             finally:
                 self.__cov_lock.release()
     return
Пример #49
0
 def event_subscribe(self, *args):
     self._subscription_lock.acquire()
     try:
         already_subscribed = self.event_has_subscribers()
         result = EventProducerMixin.event_subscribe(self, *args)
         self._subscribers += 1
     finally:
         self._subscription_lock.release()
     if not already_subscribed and self._cached_result:
         value = self._cached_result.value
         self._trigger_cov(value, value, time.time())
     return result