Beispiel #1
0
def get_object_list(device_instance_number):
        answer = []
        if debug: print 'ion.device.get_object_list from device'
        prop = (8, device_instance_number, 76)
        try:
            r = read_property_g3(device_instance_number, prop)
            answer = r.property_value #a list of tags
        except:
            if debug: print 'reading entire list did not work, try one element at a time'
            answer = []
            #get length of list
            len = read_property_g3(device_instance_number, prop+(0,))
            len = len.property_value[0].value
            if len > 1:
                for i in range(1, len+1):
                    obj_tag = read_property_g3(device_instance_number, prop+(i,)).property_value[0]
                    answer.append(obj_tag)
            msglog.log('bacnet', msglog.types.INFO, 'ObjectList(76) retrieved by individual elements from: %s' % device_instance_number)
        return answer
Beispiel #2
0
def get_object_list(device):
        answer = []
        if debug: print 'ion.device.get_object_list from device'
        prop = (8, device, 76)
        try:
            r = read_property_g3(device, prop)
            answer = r.property_value #a list of tags
        except:
            if debug: print 'reading entire list did not work, try one element at a time'
            try:
                answer = []
                #get length of list
                len = read_property_g3(device, prop+(0,))
                len = len.property_value[0].value
                if len > 1:
                    for i in range(1, len):
                        obj_tag = read_property_g3(device, prop+(i,)).property_value[0]
                        answer.append(obj_tag)
            except:
                if self.debug: print 'unable to read individual list elements'
                answer = []
        return answer
Beispiel #3
0
def get_object_list(device_instance_number):
    answer = []
    if debug: print 'ion.device.get_object_list from device'
    prop = (8, device_instance_number, 76)
    try:
        r = read_property_g3(device_instance_number, prop)
        answer = r.property_value  #a list of tags
    except:
        if debug:
            print 'reading entire list did not work, try one element at a time'
        answer = []
        #get length of list
        len = read_property_g3(device_instance_number, prop + (0, ))
        len = len.property_value[0].value
        if len > 1:
            for i in range(1, len + 1):
                obj_tag = read_property_g3(device_instance_number,
                                           prop + (i, )).property_value[0]
                answer.append(obj_tag)
        msglog.log(
            'bacnet', msglog.types.INFO,
            'ObjectList(76) retrieved by individual elements from: %s' %
            device_instance_number)
    return answer
Beispiel #4
0
 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
Beispiel #5
0
 def _discover_children(self): #find any new devices
     ## disble discovery
     self.discover = 'never'
     ## disble discovery
     answer = {}
     if self.discover == 'never' or not self.running:
         return answer
     try:
         result = {} #start fresh
         if self.debug: print 'Discover network children'
         self.found_devices = dict(network._device_table)
         dts = len(self.found_devices)
         #if dts == self._device_table_size: #nothing new to discover
             #return answer #short circuit the search
         self._device_table_size = dts
         existing_devices = self._child_device_instance_numbers()
         existing_networks = self._existing_network_numbers()
         if self.debug: 
             print 'found devices: ', self.found_devices
             print 'existing devices: ', existing_devices
             print 'existing networks: ', existing_networks
         for d in self.found_devices.values():  #I would iterate by keys (device instance) but we may change to a different key
             if d.network == self.network: #new device on our network
                 if d.instance_number not in existing_devices:
                     if self.debug: 'new device found: ', str(d)
                     if (vendor_mods.has_key(d.vendor_id)): #vendor modules
                         dev_mod = vendor_mods[d.vendor_id].ion_dev
                         bn_dev = getattr(dev_mod, 'BACnetDevice')
                         new_device = bn_dev()
                     else:
                         from mpx.ion.bacnet import device
                         new_device = device.BACnetDevice() #create new device node from this device
                     new_device.device_info = d
                     try: # to get name of device
                         device_name = new_device._get_device_name()
                     except:
                         device_name = 'Unknown device (%d)' % d.instance_number
                     if d.vendor_id == 2: #trane
                         if self.bcu_list:
                             if d.instance_number not in self.bcu_list:
                                 continue #do not insert black listed work station
                         else: #we do not yet have the list
                             #try and read the list
                             try:
                                 #read site object work station list
                                 bculist = read_property_g3(d.instance_number, (132,1,1126)).property_value #site layout, ws list
                                 for bcu in bculist: #loop through tags
                                     self.bcu_list.append(bcu.value.instance_number)
                                 #must be bcu so add it
                             except:
                                 #only add devices we can talk with
                                 continue #better luck next time
                         #if device_name != 'Tracer Summit Workstation': #filter out the annoying workstations....
                     result[device_name] = new_device
                     continue #get next found device
             if d.network not in existing_networks:
                 if self.debug: print 'new network found: ', str(d.network)
                 #create new network node to hold this device
                 new_network = Network()
                 if self.debug: print 'nw 1'
                 new_network._network_number = d.network
                 if self.debug: print 'nw 2'
                 network_name = 'Network (%d)' % d.network
                 if self.debug: print 'nw 3'
                 result[network_name] = new_network
                 if self.debug: print 'nw 4'
                 continue
         answer = result
     except:
         msglog.exception()
         if self.debug: print 'error during bacnet network discover'
     return answer
Beispiel #6
0
 def _get_name_property(self, device, object, instance):
     prop = (object, instance, 77)
     r = read_property_g3(device, prop)
     answer = string.join(r.property_value[0].value.character_string.split())
     return answer.replace('-','_')