How to know the type of the object ?
-
Hi everyone,
i was thinking how to know if the object is 'analog output' or 'analog input' ? the same to binary type.in Test2.java you can :
private static void getObjectList(LocalDevice localDevice, String ip, int port, int deviceId) throws Exception { InetSocketAddress addr = new InetSocketAddress(InetAddress.getByName(ip), port); ReadPropertyRequest read = new ReadPropertyRequest(new ObjectIdentifier(ObjectType.device, deviceId), PropertyIdentifier.objectList); ReadPropertyAck ack = (ReadPropertyAck) localDevice.send(addr, null, 1476, Segmentation.segmentedBoth, read); System.out.println("IP: " + ip); SequenceOf<ObjectIdentifier> oids = (SequenceOf<ObjectIdentifier>) ack.getValue(); for (ObjectIdentifier oid : oids) System.out.println(" " + oid); }
But if i try get only the analogOutput like this:
private static void getAnalogOutputList(LocalDevice localDevice, String ip, int port, int deviceId) throws Exception { InetSocketAddress addr = new InetSocketAddress(InetAddress.getByName(ip), port); ReadPropertyRequest read = new ReadPropertyRequest(new ObjectIdentifier(ObjectType.analogOutput, deviceId), PropertyIdentifier.presentValue); ReadPropertyAck ack = (ReadPropertyAck) localDevice.send(addr, null, 1476, Segmentation.segmentedBoth, read); System.out.println("IP: " + ip); SequenceOf<ObjectIdentifier> oids = (SequenceOf<ObjectIdentifier>) ack.getValue(); for (ObjectIdentifier oid : oids) { System.out.println(" " + oid); } }
Launch a exception:
ErrorAPDU(choice=12, errorClass=Object, errorCode=Unknown object)
Could anyone help me with this ?
-
you still need to ask for complete objectList
then only show analogOutputprivate static void getObjectList(LocalDevice localDevice, String ip, int port, int deviceId) throws Exception { InetSocketAddress addr = new InetSocketAddress(InetAddress.getByName(ip), port); ReadPropertyRequest read = new ReadPropertyRequest(new ObjectIdentifier(ObjectType.device, deviceId), PropertyIdentifier.objectList); ReadPropertyAck ack = (ReadPropertyAck) localDevice.send(addr, null, 1476, Segmentation.segmentedBoth, read); System.out.println("IP: " + ip); SequenceOf<ObjectIdentifier> oids = (SequenceOf<ObjectIdentifier>) ack.getValue(); for (ObjectIdentifier oid : oids) { if(oid.getObjectType().intValue() == ObjectType.analogOutput.intValue()) { System.out.println(" " + oid); } } }
-
sorry taking so long to reply friend. (I was involved in another project, but now returning to bacnet4j )
I try what you suggest but it just told me the value of the binary and the analog, which is :
Object type || value
Device : 8
Analog Value : 2
Binary Value : 5What I need is a little more specific, how to know the int value of a binary input for example ?