def get_rp(self, prop, timeout=3.0): if debug: print 'reading a property' now = time.time() result = Result() result.timestamp = now result.cached = 1 try: if debug: print self.device, prop.property_tuple r = read_property_g3(self.device, prop.property_tuple, timeout) v = r.property_value self.v = v prop.decode(v) except BACnetError, e: prop._value = e result.timestamp = now - prop.ttl
def update_cache(self, prop): if debug: print 'update cache: ' #, prop, prop.ttl #age_group = self.find_age_group_for(prop) rpm = device_accepts_rpm(self.device) if debug: print 'does device RPM? :', str(rpm) if rpm: if debug: print 'device accepts rpm' age_group = self.predicted_next_nodes_to_expire(prop) keys = age_group.keys() properties = [] for x in keys: #go through this to guarentee having the same order in the results as the properties properties.append(age_group[x]) if debug: print ' rpm: ', x if debug: print 'RPM for :', self.device, properties r = read_property_multiple_g3(self.device, properties) if debug: print ' RPM result: ', r now = time.time() for x in keys: result = Result() result.timestamp = now result.cached = 1 v = r.pop(0) if debug: print ' RPM decode: ', v #, x try: pv = v.list_of_results[0].property_value x.decode(pv) result.value = x._value except sequence.ETagMissing, e: result.value = sequence.ETagMissing('ETagMissing():\n ' + \ str(e)) if debug: print ' add to cache: ', result.value self.cache[x] = result x.last_result = result
def get_result(self, skipCache=0, **keywords): result = Result() result.timestamp = time.time() _module_lock.acquire() try: if self.value is None: if not self.buffer is None: #only affects _Register classes #convert the buffer bytes to our value self.convert_buffer_to_value() result.value = self.value return result finally: _module_lock.release()
def get_result(self, skipCache=0): cache = self.cache cache.lock.acquire() try: if skipCache or (cache.response is None) or \ ((cache.timestamp + cache.ttl) < time()): cached = 0 cache._refresh() else: cached = 1 result = Result() result.timestamp = cache.timestamp result.cached = cached result.value = apply( self.read, [cache.response, self.offset, cache.start, self.orders]) finally: cache.lock.release() return result
def get_result(self, skipCache=0): cache = self.cache cache.lock.acquire() try: if skipCache or (cache.response is None) or \ ((cache.timestamp + cache.ttl) < time()): cached = 0 cache._refresh() else: cached = 1 result = Result() result.timestamp = cache.timestamp result.cached = cached result.value = apply(self.read, [cache.response, self.offset, cache.start, self.orders]) finally: cache.lock.release() return result
def get(self, manager, **keywords): if debug: print 'Start of Batch:%s' % (self.properties) now = time.time() self.last_get_time = now answer = {} #return a dictionary of ids and results cache = self.cache cache.lock.acquire() try: try: if (cache.response is None) or \ ((cache.timestamp + cache.ttl) < time.time()): cached = 0 cache._refresh() else: cached = 1 for id in self.ids: ion = self.map[id] result = Result() result.timestamp = cache.timestamp result.cached = cached result.value = apply( ion.read, [cache.response, ion.offset, cache.start, ion.orders]) answer[id] = result self._error_counter = 0 except ETimeout, e: return e #subscription manager will re-raise the timeout, not cause for bad batch except: msglog.exception() self._error_counter += 1 if self._error_counter > 15: #catch run away thrashing for id in self.ids: nr = self.map[id] nr.set_batch_manager( None) #none of these points can batch raise EBadBatch('bacnet', self, 'error threshold exceeded')
def get(self, manager, **keywords): if debug: print 'Start of Batch:%s' % (self.properties) now = time.time() self.last_get_time = now answer = {} #return a dictionary of ids and results cache = self.cache cache.lock.acquire() try: try: if (cache.response is None) or \ ((cache.timestamp + cache.ttl) < time.time()): cached = 0 cache._refresh() else: cached = 1 for id in self.ids: ion = self.map[id] result = Result() result.timestamp = cache.timestamp result.cached = cached result.value = apply(ion.read, [cache.response, ion.offset, cache.start, ion.orders]) answer[id]=result self._error_counter = 0 except ETimeout, e: return e #subscription manager will re-raise the timeout, not cause for bad batch except: msglog.exception() self._error_counter += 1 if self._error_counter > 15: #catch run away thrashing for id in self.ids: nr = self.map[id] nr.set_batch_manager(None) #none of these points can batch raise EBadBatch('bacnet', self, 'error threshold exceeded')
def get_result(self, skipCache=0, **keywords): result = Result() result.value = len(self.children_nodes()) result.timestamp = time.time() return result
def get_result(self,skipCache=0, **keywords): result = Result() result.value = len(self.children_nodes()) result.timestamp = time.time() return result