Ejemplo n.º 1
0
    def test_enumerated_int(self):
        if _debug: TestEnumerated._debug("test_enumerated_int")

        obj = Enumerated(1)
        assert obj.value == 1
        assert str(obj) == "Enumerated(1)"

        with self.assertRaises(ValueError):
            Enumerated(-1)
Ejemplo n.º 2
0
    def test_enumerated(self):
        if _debug: TestEnumerated._debug("test_enumerated")

        obj = Enumerated()
        assert obj.value == 0

        with self.assertRaises(ValueError):
            Enumerated("label")
        with self.assertRaises(TypeError):
            Enumerated(1.0)
Ejemplo n.º 3
0
    def __init__(self, *args):
        BIPSimpleApplication.__init__(Mock())
        self.elementService = Mock()
        #self.ResponseQueue = Mock()
        #self.ResponseQueue.get.return_value = ([21, 'degreesCelcius'], Event())
        iocb = IOCB()
        apdu = ReadPropertyMultipleACK(listOfReadAccessResults=[
            ReadAccessResult(
                objectIdentifier=('analogValue', 1),
                listOfResults=[
                    ReadAccessResultElement(
                        propertyIdentifier='presentValue',
                        readResult=ReadAccessResultElementChoice(
                            propertyValue=Any(Real(21.0)), )),
                    ReadAccessResultElement(
                        propertyIdentifier='units',
                        readResult=ReadAccessResultElementChoice(
                            propertyValue=Any(Enumerated(62)), )),
                ],
            )
        ])

        iocb.complete(apdu)
        self.request = Mock()
        self.request.return_value = iocb
Ejemplo n.º 4
0
def enumerated_decode(tag):
    """Decode an enumerated application tag into an enumerated."""
    if _debug: enumerated_decode._debug("enumerated_decode %r", tag)

    obj = Enumerated(tag)
    if _debug: enumerated_decode._debug("    - obj: %r", obj)

    return obj
Ejemplo n.º 5
0
    def test_enumerated_tag(self):
        if _debug: TestEnumerated._debug("test_enumerated_tag")

        tag = Tag(Tag.applicationTagClass, Tag.enumeratedAppTag, 1, xtob('01'))
        obj = Enumerated(tag)
        assert obj.value == 1

        tag = Tag(Tag.applicationTagClass, Tag.booleanAppTag, 0, xtob(''))
        with self.assertRaises(InvalidTag):
            Enumerated(tag)

        tag = Tag(Tag.contextTagClass, 0, 1, xtob('ff'))
        with self.assertRaises(InvalidTag):
            Enumerated(tag)

        tag = Tag(Tag.openingTagClass, 0)
        with self.assertRaises(InvalidTag):
            Enumerated(tag)
Ejemplo n.º 6
0
def enumerated_endec(v, x):
    """Pass the value to Enumerated, construct a tag from the hex string,
    and compare results of encode and decoding each other."""
    if _debug: enumerated_endec._debug("enumerated_endec %r %r", v, x)

    tag = enumerated_tag(x)
    if _debug: enumerated_endec._debug("    - tag: %r, %r", tag, tag.tagData)

    obj = Enumerated(v)
    if _debug: enumerated_endec._debug("    - obj: %r, %r", obj, obj.value)

    assert enumerated_encode(obj) == tag
    assert enumerated_decode(tag) == obj
Ejemplo n.º 7
0
    def _process_enumerated(self, object_type, obj):
        units = ''
        units_details = ''
        notes = ''

        units = 'Enum'
        present_value_type = get_datatype(object_type, 'presentValue')
        values = present_value_type.enumerations.values()
        min_value = min(values)
        max_value = max(values)

        vendor_range = ''
        if hasattr(present_value_type, 'vendor_range'):
            vendor_min, vendor_max = present_value_type.vendor_range
            vendor_range = ' (vendor {min}-{max})'.format(min=vendor_min,
                                                          max=vendor_max)

        units_details = '{min}-{max}{vendor}'.format(min=min_value,
                                                     max=max_value,
                                                     vendor=vendor_range)

        if not object_type.endswith('Input'):
            default_value = obj.get("relinquishDefault")
            if default_value:
                self._log.debug('DEFAULT VALUE IS: {}'.format(default_value))
                self._log.debug('ENUMERATION VALUES: {}'.format(
                    present_value_type.enumerations))
                for k, v in present_value_type.enumerations.items():
                    if v == default_value:
                        units_details += ' (default {default})'.format(
                            default=k)

        if not notes:
            enum_strings = []
            for name in Enumerated.keylist(present_value_type(0)):
                value = present_value_type.enumerations[name]
                enum_strings.append(str(value) + '=' + name)

            notes = present_value_type.__name__ + ': ' + ', '.join(
                enum_strings)

        return units, units_details, notes
Ejemplo n.º 8
0
    def _process_enumerated(self, object_type, obj):
        units = 'Enum'
        units_details = ''
        notes = obj.get('description', '').strip()

        present_value_type = get_datatype(object_type, 'presentValue')
        values = present_value_type.enumerations.values()
        min_value = min(values)
        max_value = max(values)

        vendor_range = ''
        if hasattr(present_value_type, 'vendor_range'):
            vendor_min, vendor_max = present_value_type.vendor_range
            vendor_range = ' (vendor {min}-{max})'.format(min=vendor_min,
                                                          max=vendor_max)

        units_details = '{min}-{max}{vendor}'.format(min=min_value,
                                                     max=max_value,
                                                     vendor=vendor_range)

        if not object_type.endswith('Input'):
            if "relinquishDefault" in obj:
                default_value = obj['relinquishDefault']
                _log.debug('DEFAULT VALUE IS: {}'.format(default_value))
                _log.debug('ENUMERATION VALUES: {}'.format(
                    present_value_type.enumerations))
                for k, v in present_value_type.enumerations.items():
                    if v == default_value:
                        units_details += ' (default {default})'.format(
                            default=default_value)
                        break

        if not notes:
            enum_strings = []
            for name in Enumerated.keylist(present_value_type(0)):
                value = present_value_type.enumerations[name]
                enum_strings.append(str(value) + '=' + name)

            notes = present_value_type.__name__ + ': ' + ', '.join(
                enum_strings)

        return units, units_details, notes
Ejemplo n.º 9
0
    def test_enumerated_endec(self):
        if _debug: TestEnumerated._debug("test_enumerated_endec")

        with self.assertRaises(InvalidTag):
            obj = Enumerated(enumerated_tag(''))

        enumerated_endec(0, '00')
        enumerated_endec(1, '01')
        enumerated_endec(127, '7f')
        enumerated_endec(128, '80')
        enumerated_endec(255, 'ff')

        enumerated_endec(32767, '7fff')
        enumerated_endec(32768, '8000')

        enumerated_endec(8388607, '7fffff')
        enumerated_endec(8388608, '800000')

        enumerated_endec(2147483647, '7fffffff')
        enumerated_endec(2147483648, '80000000')
Ejemplo n.º 10
0
    def test_boolean_application_to_object(self):
        if _debug:
            TestApplicationTag._debug("test_boolean_application_to_object")

        # null
        obj_endec(Null(), '00')

        # boolean
        obj_endec(Boolean(True), '11')
        obj_endec(Boolean(False), '10')

        # unsigned
        obj_endec(Unsigned(0), '2100')
        obj_endec(Unsigned(1), '2101')
        obj_endec(Unsigned(127), '217F')
        obj_endec(Unsigned(128), '2180')

        # integer
        obj_endec(Integer(0), '3100')
        obj_endec(Integer(1), '3101')
        obj_endec(Integer(-1), '31FF')
        obj_endec(Integer(128), '320080')
        obj_endec(Integer(-128), '3180')

        # real
        obj_endec(Real(0), '4400000000')
        obj_endec(Real(1), '443F800000')
        obj_endec(Real(-1), '44BF800000')
        obj_endec(Real(73.5), '4442930000')

        # double
        obj_endec(Double(0), '55080000000000000000')
        obj_endec(Double(1), '55083FF0000000000000')
        obj_endec(Double(-1), '5508BFF0000000000000')
        obj_endec(Double(73.5), '55084052600000000000')

        # octet string
        obj_endec(OctetString(xtob('')), '60')
        obj_endec(OctetString(xtob('01')), '6101')
        obj_endec(OctetString(xtob('0102')), '620102')
        obj_endec(OctetString(xtob('010203040506')), '6506010203040506')

        # character string
        obj_endec(CharacterString(''), '7100')
        obj_endec(CharacterString('a'), '720061')
        obj_endec(CharacterString('abcde'), '7506006162636465')

        # bit string
        obj_endec(BitString([]), '8100')
        obj_endec(BitString([0]), '820700')
        obj_endec(BitString([1]), '820780')
        obj_endec(BitString([1, 1, 1, 1, 1]), '8203F8')
        obj_endec(BitString([1] * 10), '8306FFC0')

        # enumerated
        obj_endec(Enumerated(0), '9100')
        obj_endec(Enumerated(1), '9101')
        obj_endec(Enumerated(127), '917F')
        obj_endec(Enumerated(128), '9180')

        # date
        obj_endec(Date((1, 2, 3, 4)), 'A401020304')
        obj_endec(Date((255, 2, 3, 4)), 'A4FF020304')
        obj_endec(Date((1, 255, 3, 4)), 'A401FF0304')
        obj_endec(Date((1, 2, 255, 4)), 'A40102FF04')
        obj_endec(Date((1, 2, 3, 255)), 'A4010203FF')

        # time
        obj_endec(Time((1, 2, 3, 4)), 'B401020304')
        obj_endec(Time((255, 2, 3, 4)), 'B4FF020304')
        obj_endec(Time((1, 255, 3, 4)), 'B401FF0304')
        obj_endec(Time((1, 2, 255, 4)), 'B40102FF04')
        obj_endec(Time((1, 2, 3, 255)), 'B4010203FF')

        # object identifier
        obj_endec(ObjectIdentifier(0, 0), 'C400000000')
        obj_endec(ObjectIdentifier(1, 0), 'C400400000')
        obj_endec(ObjectIdentifier(0, 2), 'C400000002')
        obj_endec(ObjectIdentifier(3, 4), 'C400C00004')
Ejemplo n.º 11
0
                min=min_value, max=max_value, vendor=vendor_range)

            if not obj_type.endswith('Input'):
                try:
                    default_value = read_prop(this_application, target_address,
                                              obj_type, index,
                                              "relinquishDefault")
                    object_units_details += ' (default {default})'.format(
                        default=present_value_type.enumerations[default_value])
                    #writable = 'TRUE'
                except TypeError:
                    pass

            if not object_notes:
                enum_strings = []
                for name in Enumerated.keylist(present_value_type(0)):
                    value = present_value_type.enumerations[name]
                    enum_strings.append(str(value) + '=' + name)

                object_notes = present_value_type.__name__ + ': ' + ', '.join(
                    enum_strings)

        elif issubclass(present_value_type, Boolean):
            object_units = 'Boolean'

        elif get_datatype(obj_type, 'units') is None:
            if obj_type.startswith('multiState'):
                object_units = 'State'
                try:
                    state_count = read_prop(this_application, target_address,
                                            obj_type, index, "numberOfStates")
Ejemplo n.º 12
0
def process_object(address, obj_type, index, max_range_report, config_writer):
    _log.debug('obj_type = ' + repr(obj_type))
    _log.debug('bacnet_index = ' + repr(index))
    
    writable = 'FALSE'
    
    # TODO: Eventually we will have a device that will want to use this code so leave it here.
    #subondinate_list_property = get_datatype(obj_type, 'subordinateList')
    #if subondinate_list_property is not None:
    #    _log.debug('Processing StructuredViewObject')
    #    process_device_object_reference(address, obj_type, index, 'subordinateList', max_range_report, config_writer)
    #    return
    #
    #subondinate_list_property = get_datatype(obj_type, 'zoneMembers')
    #if subondinate_list_property is not None:
    #    _log.debug('Processing LifeSafetyZoneObject')
    #    process_device_object_reference(address, obj_type, index, 'zoneMembers', max_range_report, config_writer)
    #    return
    
    present_value_type = get_datatype(obj_type, 'presentValue')
    if present_value_type is None:
        _log.debug('This object type has no presentValue. Skipping.')
        return
    
    if not issubclass(present_value_type, (Enumerated,
                                           Unsigned,
                                           Boolean,
                                           Integer,
                                           Real,
                                           Double)):
        _log.debug('presenValue is an unsupported type: ' + repr(present_value_type))
        return 
    
    try:
        object_name = read_prop(address, obj_type, index, "objectName")
        _log.debug('object name = ' + object_name)
    except (TypeError,RemoteError):
        object_name = "NO NAME! PLEASE NAME THIS."
        
#         _log.debug('  object type = ' + obj_type)
#         _log.debug('  object index = ' + str(index))
    
    try:
        object_notes = read_prop(address, obj_type, index, "description")
        
    except (TypeError,RemoteError):
        object_notes = ''
        
    object_units_details = ''
    
    if issubclass(present_value_type, Enumerated):
        object_units = 'Enum'
        values=present_value_type.enumerations.values()
        min_value = min(values)
        max_value = max(values)
        
        vendor_range = ''
        if hasattr(present_value_type, 'vendor_range'):
            vendor_min, vendor_max = present_value_type.vendor_range
            vendor_range = ' (vendor {min}-{max})'.format(min=vendor_min, max=vendor_max)
            
        object_units_details = '{min}-{max}{vendor}'.format(min=min_value, max=max_value, vendor=vendor_range)
        
        if not obj_type.endswith('Input'):
            try:
                default_value = read_prop(address, obj_type, index, "relinquishDefault")
                object_units_details += ' (default {default})'.format(default=present_value_type.enumerations[default_value])
                #writable = 'TRUE'
            except KeyError:
                pass
            except TypeError:
                pass
            except ValueError:
                pass
            except RemoteError:
                pass
    
        if not object_notes:
            enum_strings=[]
            for name in Enumerated.keylist(present_value_type(0)):
                value = present_value_type.enumerations[name]
                enum_strings.append(str(value)+'='+name)
                
            object_notes = present_value_type.__name__ + ': ' + ', '.join(enum_strings)
        
        
    elif issubclass(present_value_type, Boolean):
        object_units = 'Boolean'
        
    elif get_datatype(obj_type, 'units') is None:
        if obj_type.startswith('multiState'):
            object_units = 'State'
            try:
                state_count = read_prop(address, obj_type, index, "numberOfStates")
                object_units_details = 'State count: {}'.format(state_count)
            except TypeError:
                pass
            except RemoteError:
                pass
            
            try:
                enum_strings=[]
                state_list = read_prop(address, obj_type, index, "stateText")
                for name in state_list[1:]:
                    enum_strings.append(name)
                    
                object_notes = ', '.join('{}={}'.format(x,y) for x,y in enumerate(enum_strings, start=1))
                    
            except TypeError:
                pass
            except RemoteError:
                pass
            
            if obj_type != 'multiStateInput':
                try:
                    default_value = read_prop(address, obj_type, index, "relinquishDefault")
                    object_units_details += ' (default {default})'.format(default=default_value)
                    object_units_details = object_units_details.strip()
                    #writable = 'TRUE'
                except TypeError:
                    pass
                except ValueError:
                    pass
                except RemoteError:
                    pass
                
        elif obj_type == 'loop':
            object_units = 'Loop'
        else:
            object_units = 'UNKNOWN UNITS'        
    else:
        try:
            object_units = read_prop(address, obj_type, index, "units")
        except (TypeError, RemoteError):
            object_units = 'UNKNOWN UNITS'
            
        if isinstance(object_units, (int, long)):
            object_units = 'UNKNOWN UNIT ENUM VALUE: ' + str(object_units)
            
        if obj_type.startswith('analog') or obj_type in ('largeAnalogValue', 'integerValue', 'positiveIntegerValue'):
            # Value objects never have a resolution property in practice.
            if not object_notes and not obj_type.endswith('Value'):
                try:
                    res_value = read_prop(address, obj_type, index, "resolution")
                    object_notes = 'Resolution: {resolution:.6g}'.format(resolution=res_value)
                except TypeError:
                    pass
                except RemoteError:
                    pass
            
            if obj_type not in ('largeAnalogValue', 'integerValue', 'positiveIntegerValue'):    
                try:
                    min_value = read_prop(address, obj_type, index, "minPresValue")
                    max_value = read_prop(address, obj_type, index, "maxPresValue")

                    has_min = (min_value is not None) and (min_value > -max_range_report)
                    has_max = (max_value is not None) and (max_value < max_range_report)
                    
                    if has_min and has_max:
                        object_units_details = '{min:.2f} to {max:.2f}'.format(min=min_value, max=max_value)
                    elif has_min:
                        object_units_details = 'Min: {min:.2f}'.format(min=min_value)
                    elif has_max:
                        object_units_details = 'Max: {max:.2f}'.format(max=max_value)
                    else:
                        object_units_details = 'No limits.'
                    #object_units_details = '{min} to {max}'.format(min=min_value, max=max_value)            
                except TypeError:
                    pass
                except RemoteError:
                    pass
            
            if obj_type != 'analogInput':
                try:
                    default_value = read_prop(address, obj_type, index, "relinquishDefault")
                    object_units_details += ' (default {default})'.format(default=default_value)
                    object_units_details = object_units_details.strip()
                    #writable = 'TRUE'
                except TypeError:
                    pass
                except ValueError:
                    pass
                except RemoteError:
                    pass
   
    _log.debug('  object units = ' + str(object_units))
    _log.debug('  object units details = ' + str(object_units_details))
    _log.debug('  object notes = ' + object_notes)    
    
    results = {}     
    results['Reference Point Name'] = results['Volttron Point Name'] = object_name
    results['Units'] = object_units
    results['Unit Details'] = object_units_details
    results['BACnet Object Type'] = obj_type
    results['Property'] = 'presentValue'
    results['Writable'] = writable
    results['Index'] = index
    results['Notes'] = object_notes
    
    config_writer.writerow(results)
Ejemplo n.º 13
0
    def test_enumerated_statement(self):
        if _debug: TestExtendedTagStatements._debug("test_enumerated_statement")

        assert statement_to_tag("enumerated 5") == tag_encode(Enumerated(5))
        assert statement_to_tag("enumerated 5 context 10") == tag_encode(Enumerated(5), context=10)
Ejemplo n.º 14
0
def process_object(app, address, obj_type, index, max_range_report, config_writer):
    _log.debug('obj_type = ' + repr(obj_type))
    _log.debug('bacnet_index = ' + repr(index))
    
    writable = 'FALSE'
    
    # subondinate_list_property = get_datatype(obj_type, 'subordinateList')
    # if subondinate_list_property is not None:
    #     _log.debug('Processing StructuredViewObject')
    #     process_device_object_reference(app, address, obj_type, index, 'subordinateList', max_range_report, config_writer)
    #     return
    #
    # subondinate_list_property = get_datatype(obj_type, 'zoneMembers')
    # if subondinate_list_property is not None:
    #     _log.debug('Processing LifeSafetyZoneObject')
    #     process_device_object_reference(app, address, obj_type, index, 'zoneMembers', max_range_report, config_writer)
    #     return
    
    present_value_type = get_datatype(obj_type, 'presentValue')
    if present_value_type is None:
        _log.debug('This object type has no presentValue. Skipping.')
        return
    
    if not issubclass(present_value_type, (Enumerated,
                                           Unsigned,
                                           Boolean,
                                           Integer,
                                           Real,
                                           Double)):
        _log.debug('presenValue is an unsupported type: ' + repr(present_value_type))
        return

    object_name = "NO NAME! PLEASE NAME THIS."
    try:
        object_name = read_prop(app, address, obj_type, index, "objectName")
        _log.debug('object name = ' + object_name)
    except TypeError:
        pass
    except:
        _log.debug(traceback.format_exc())
        
#         _log.debug('  object type = ' + obj_type)
#         _log.debug('  object index = ' + str(index))

    object_notes = ''
    try:
        object_notes = read_prop(app, address, obj_type, index, "description")
    except TypeError:
        pass
    except:
        _log.debug(traceback.format_exc())
        
    object_units_details = ''
    
    if issubclass(present_value_type, Enumerated):
        object_units = 'Enum'
        values=present_value_type.enumerations.values()
        min_value = min(values)
        max_value = max(values)
        
        vendor_range = ''
        if hasattr(present_value_type, 'vendor_range'):
            vendor_min, vendor_max = present_value_type.vendor_range
            vendor_range = ' (vendor {min}-{max})'.format(min=vendor_min, max=vendor_max)
            
        object_units_details = '{min}-{max}{vendor}'.format(min=min_value, max=max_value, vendor=vendor_range)
        
        if not obj_type.endswith('Input'):
            try:
                default_value = read_prop(app, address, obj_type, index, "relinquishDefault")
                object_units_details += ' (default {default})'.format(default=present_value_type.enumerations[default_value])
                #writable = 'TRUE'
            except TypeError:
                pass
            except ValueError:
                pass
            except:
                _log.debug(traceback.format_exc())
    
        if not object_notes:
            enum_strings=[]
            for name in Enumerated.keylist(present_value_type(0)):
                value = present_value_type.enumerations[name]
                enum_strings.append(str(value)+'='+name)
                
            object_notes = present_value_type.__name__ + ': ' + ', '.join(enum_strings)
        
        
    elif issubclass(present_value_type, Boolean):
        object_units = 'Boolean'
        
    elif get_datatype(obj_type, 'units') is None:
        if obj_type.startswith('multiState'):
            object_units = 'State'
            try:
                state_count = read_prop(app, address, obj_type, index, "numberOfStates")
                object_units_details = 'State count: {}'.format(state_count)
            except TypeError:
                pass
            except:
                _log.debug(traceback.format_exc())
            
            try:
                enum_strings=[]
                state_list = read_prop(app, address, obj_type, index, "stateText")
                for name in state_list[1:]:
                    enum_strings.append(name)
                    
                object_notes = ', '.join('{}={}'.format(x,y) for x,y in enumerate(enum_strings, start=1))
                    
            except TypeError:
                pass
            
            if obj_type != 'multiStateInput':
                try:
                    default_value = read_prop(app, address, obj_type, index, "relinquishDefault")
                    object_units_details += ' (default {default})'.format(default=default_value)
                    object_units_details = object_units_details.strip()
                    #writable = 'TRUE'
                except TypeError:
                    pass
                except ValueError:
                    pass
                except:
                    _log.debug(traceback.format_exc())
                
        elif obj_type == 'loop':
            object_units = 'Loop'
        else:
            object_units = 'UNKNOWN UNITS'        
    else:
        object_units = 'UNKNOWN UNITS'
        try:
            object_units = read_prop(app, address, obj_type, index, "units")
        except TypeError:
            pass
        except:
            _log.debug(traceback.format_exc())
            
        if isinstance(object_units, (int, long)):
            object_units = 'UNKNOWN UNIT ENUM VALUE: ' + str(object_units)
            
        if obj_type.startswith('analog') or obj_type in ('largeAnalogValue', 'integerValue', 'positiveIntegerValue'):
            # Value objects never have a resolution property in practice.
            if not object_notes and not obj_type.endswith('Value'):
                try:
                    res_value = read_prop(app, address, obj_type, index, "resolution")
                    object_notes = 'Resolution: {resolution:.6g}'.format(resolution=res_value)
                except TypeError:
                    pass
            
            if obj_type not in ('largeAnalogValue', 'integerValue', 'positiveIntegerValue'):    
                try:
                    min_value = read_prop(app, address, obj_type, index, "minPresValue")
                    max_value = read_prop(app, address, obj_type, index, "maxPresValue")

                    has_min = (min_value is not None) and (min_value > -max_range_report)
                    has_max = (max_value is not None) and (max_value < max_range_report)
                    
                    if has_min and has_max:
                        object_units_details = '{min:.2f} to {max:.2f}'.format(min=min_value, max=max_value)
                    elif has_min:
                        object_units_details = 'Min: {min:.2f}'.format(min=min_value)
                    elif has_max:
                        object_units_details = 'Max: {max:.2f}'.format(max=max_value)
                    else:
                        object_units_details = 'No limits.'
                    #object_units_details = '{min} to {max}'.format(min=min_value, max=max_value)            
                except TypeError:
                    pass
                except:
                    _log.debug(traceback.format_exc())
            
            if obj_type != 'analogInput':
                try:
                    default_value = read_prop(app, address, obj_type, index, "relinquishDefault")
                    object_units_details += ' (default {default})'.format(default=default_value)
                    object_units_details = object_units_details.strip()
                    #writable = 'TRUE'
                except TypeError:
                    pass
                except ValueError:
                    pass
                except:
                    _log.debug(traceback.format_exc())
   
    _log.debug('  object units = ' + str(object_units))
    _log.debug('  object units details = ' + str(object_units_details))
    _log.debug('  object notes = ' + object_notes)    
    
    results = {}     
    results['Reference Point Name'] = results['Volttron Point Name'] = object_name
    results['Units'] = object_units
    results['Unit Details'] = object_units_details
    results['BACnet Object Type'] = obj_type
    results['Property'] = 'presentValue'
    results['Writable'] = writable
    results['Index'] = index
    results['Notes'] = object_notes
    
    config_writer.writerow(results)
Ejemplo n.º 15
0
    def test_enumerated_copy(self):
        if _debug: TestEnumerated._debug("test_enumerated_copy")

        obj1 = Enumerated(12)
        obj2 = Enumerated(obj1)
        assert obj2.value == 12
Ejemplo n.º 16
0
         vendor_min, vendor_max = present_value_type.vendor_range
         vendor_range = ' (vendor {min}-{max})'.format(min=vendor_min, max=vendor_max)
         
     object_units_details = '{min}-{max}{vendor}'.format(min=min_value, max=max_value, vendor=vendor_range)
     
     if not obj_type.endswith('Input'):
         try:
             default_value = read_prop(this_application, target_address, obj_type, index, "relinquishDefault")
             object_units_details += ' (default {default})'.format(default=present_value_type.enumerations[default_value])
             #writable = 'TRUE'
         except TypeError:
             pass
 
     if not object_notes:
         enum_strings=[]
         for name in Enumerated.keylist(present_value_type(0)):
             value = present_value_type.enumerations[name]
             enum_strings.append(str(value)+'='+name)
             
         object_notes = present_value_type.__name__ + ': ' + ', '.join(enum_strings)
     
     
 elif issubclass(present_value_type, Boolean):
     object_units = 'Boolean'
     
 elif get_datatype(obj_type, 'units') is None:
     if obj_type.startswith('multiState'):
         object_units = 'State'
         try:
             state_count = read_prop(this_application, target_address, obj_type, index, "numberOfStates")
             object_units_details = 'State count: {}'.format(state_count)
Ejemplo n.º 17
0
def enumerated_statement(value):
    if _debug: enumerated_statement._debug("enumerated_statement %r", value)

    return Enumerated(int(value))