def test_make_iocb(self): """inputs ------- read_args : (iterable) of ('', 'read', <address>, <object_identifier>) address : (str) BACnet IP address of device we are trying to communicate with. Example 192.168.1.100 object_identifier : (str) BACnet Object Identifier of the device defined in 'address'. This is of the form <ObjectType>:<Instance>. Typical values for ObjectType can be found where? """ read_args = ('192.168.1.100', 'analogValue:1') addr, obj_id = read_args[:2] obj_id = ObjectIdentifier(obj_id).value # Enforce a specific object type if not get_object_class( obj_id[0]): # bacpypes.object.AnalogInputObject raise ValueError("unknown object type") # implement a default property, the bain of committee meetings if len(read_args) == 3: prop_id = read_args[2] else: prop_id = "presentValue" # look for its datatype, an easy way to see if the property is # appropriate for the object datatype = get_datatype(obj_id[0], prop_id) if not datatype: raise ValueError("invalid property for object type") # build a request request = ReadPropertyRequest(objectIdentifier=obj_id, propertyIdentifier=prop_id) request.pduDestination = Address(addr) # look for an optional array index if len(read_args) == 5: request.propertyArrayIndex = int(read_args[4]) # make an IOCB iocb = IOCB(request) # Information related to destination and network control (context information and processing instructions) apci_contents = request.apci_contents() self.assertEqual(apci_contents['destination'], read_args[0]) # Read property requests always require a confirmation PDU self.assertEqual(apci_contents['apduType'], 'ConfirmedRequestPDU') # This test only applies to ReadPropertyRequests self.assertEqual(apci_contents['apduService'], 'ReadPropertyRequest') # Information related to DATA apdu_contents = request.apdu_contents() self.assertEqual(apdu_contents['function'], 'ReadPropertyRequest') self.assertEqual(apdu_contents['objectIdentifier'], ('analogValue', 1)) self.assertEqual(apdu_contents['propertyIdentifier'], 'presentValue') # Testing of IOCB - not much to test self.assertIsInstance(iocb.args[0], ReadPropertyRequest) return None