• A
    Andreas Vogt

    Hello @terrypacker, thank you for answering! :)

    I am using:

    <dependency>
    	<groupId>com.infiniteautomation</groupId>
    	<artifactId>bacnet4j</artifactId>
    	<version>5.0.2</version>
    </dependency>
    

    As I followd the stacktrace I found in the "DefaultTransport" that at the line 769 "Segmentation" is needed. So the "Segmentation" is the object which is null in the "extended" class.
    If I try:

    static class Listener extends DeviceEventAdapter {
      @Override
      public void iAmReceived(RemoteDevice d) {
    
      //Not null
      d.getSegmentationSupported();
      Device device = new Device(localDevice,d.getInstanceNumber(),d.getAddress());
    
      //Here happens a null pointer
      device.getSegmentationSupported();
      }
    }
    

    Therefore I was thinking of override this property and tried this:

    public class DeviceTest {
        static LocalDevice localDevice;
    
        public static void main(String[] args) throws Exception {
            int localDevice_ID = 10001;
            IpNetworkBuilder ipNetworkBuilder = new IpNetworkBuilder();
            ipNetworkBuilder.withLocalBindAddress(IpNetwork.DEFAULT_BIND_IP);
            ipNetworkBuilder.withBroadcast("255.255.255.255", IpNetwork.BVLC_TYPE);
            ipNetworkBuilder.withPort(47808);
            DefaultTransport transport = new DefaultTransport(ipNetworkBuilder.build());
            localDevice = new LocalDevice(localDevice_ID, transport);
            localDevice.getEventHandler().addListener(new Listener());
            localDevice.initialize();
            localDevice.startRemoteDeviceDiscovery();
        }
    
        static class Listener extends DeviceEventAdapter {
            @Override
            public void iAmReceived(RemoteDevice d) {
                Device device = new Device(localDevice, d.getInstanceNumber(), d.getAddress(), d.getSegmentationSupported());
                try {
                    Map<PropertyIdentifier, Encodable> values = RequestUtils.getProperties(
                            localDevice, device, device.getObjectIdentifier(),null,
                            PropertyIdentifier.objectList);
                    System.out.println(values);
                } catch (BACnetException e) {
                    e.printStackTrace();
                }
            }
        }
    
        static class Device extends RemoteDevice{
            Segmentation segmentation;
    
            public Device(LocalDevice localDevice, int instanceNumber, Address address, Segmentation segmentation) {
                super(localDevice, instanceNumber, address);
                this.segmentation = segmentation;
            }
    
            @Override
            public Segmentation getSegmentationSupported() {
                return this.segmentation;
            }
        }
    }
    

    But I am running in a new exception:

    10:32:31.350 [BACnet4J transport for device 10001] ERROR com.serotonin.bacnet4j.transport.DefaultTransport - Error during send: OutgoingConfirmed [maxAPDULengthAccepted=-1, segmentationSupported=segmented-both, service=ReadPropertyRequest [objectIdentifier=device 2098177, propertyIdentifier=object-list, propertyArrayIndex=null], consumer=com.serotonin.bacnet4j.transport.ServiceFutureImpl@36f5e9d5, address=Address [networkNumber=0, macAddress=[c0,a8,1,b1,ba,c0]], linkService=null]
    java.lang.NegativeArraySizeException: -7
    	at com.serotonin.bacnet4j.transport.DefaultTransport$OutgoingConfirmed.sendImpl(DefaultTransport.java:392)
    	at com.serotonin.bacnet4j.transport.DefaultTransport$Outgoing.send(DefaultTransport.java:336)
    	at com.serotonin.bacnet4j.transport.DefaultTransport.run(DefaultTransport.java:486)
    	at java.base/java.lang.Thread.run(Thread.java:830)
    10:32:31.350 [BACnet4J transport for device 10001] ERROR com.serotonin.bacnet4j.transport.DefaultTransport - Original send stack
    java.lang.Exception: null
    	at com.serotonin.bacnet4j.transport.DefaultTransport.send(DefaultTransport.java:292)
    	at com.serotonin.bacnet4j.transport.DefaultTransport.send(DefaultTransport.java:283)
    	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:989)
    	at com.serotonin.bacnet4j.util.RequestUtils.sendOneAtATime(RequestUtils.java:425)
    	at com.serotonin.bacnet4j.util.RequestUtils.readProperties(RequestUtils.java:396)
    	at com.serotonin.bacnet4j.util.RequestUtils.readProperties(RequestUtils.java:257)
    	at com.serotonin.bacnet4j.util.RequestUtils.getProperties(RequestUtils.java:141)
    	at com.serotonin.bacnet4j.util.RequestUtils.getProperties(RequestUtils.java:136)
    	at com.bacnetbrowser.schoko.DeviceTest$Listener.iAmReceived(DeviceTest.java:41)
    	at com.serotonin.bacnet4j.event.DeviceEventHandler.fireIAmReceived(DeviceEventHandler.java:97)
    	at com.serotonin.bacnet4j.service.unconfirmed.IAmRequest.lambda$handle$0(IAmRequest.java:118)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:830)
    

    This time there sems a problem with the getMaxAPDULengthAccepted() of the Remote Device so I overrided this property as well:

    public class DeviceTest {
        static LocalDevice localDevice;
    
        public static void main(String[] args) throws Exception {
            int localDevice_ID = 10001;
            IpNetworkBuilder ipNetworkBuilder = new IpNetworkBuilder();
            ipNetworkBuilder.withLocalBindAddress(IpNetwork.DEFAULT_BIND_IP);
            ipNetworkBuilder.withBroadcast("255.255.255.255", IpNetwork.BVLC_TYPE);
            ipNetworkBuilder.withPort(47808);
            DefaultTransport transport = new DefaultTransport(ipNetworkBuilder.build());
            localDevice = new LocalDevice(localDevice_ID, transport);
            localDevice.getEventHandler().addListener(new Listener());
            localDevice.initialize();
            localDevice.startRemoteDeviceDiscovery();
        }
    
        static class Listener extends DeviceEventAdapter {
            @Override
            public void iAmReceived(RemoteDevice d) {
                Device device = new Device(localDevice, d.getInstanceNumber(), d.getAddress(), d.getSegmentationSupported());
                try {
                    Map<PropertyIdentifier, Encodable> values = RequestUtils.getProperties(
                            localDevice, device, device.getObjectIdentifier(),null,
                            PropertyIdentifier.objectList);
                    System.out.println(values);
                } catch (BACnetException e) {
                    e.printStackTrace();
                }
            }
        }
    
        static class Device extends RemoteDevice{
            Segmentation segmentation;
            int maxAPDULengthAccepted = 1476;
    
            public Device(LocalDevice localDevice, int instanceNumber, Address address, Segmentation segmentation) {
                super(localDevice, instanceNumber, address);
                this.segmentation = segmentation;
            }
    
            @Override
            public Segmentation getSegmentationSupported() {
                return this.segmentation;
            }
    
            @Override
            public int getMaxAPDULengthAccepted() {
                return maxAPDULengthAccepted;
            }
        }
    }
    

    This is working but I do not know if I am on the right way.

    BR
    Andreas

    posted in BACnet4J general discussion read more
  • A
    Andreas Vogt

    Hi guys,
    If I "extend" from the class "RemoteDevice" and then create a object of that, I can't use it to send regular BACnet requests. I always run in a NullPointerException.

    /17:02:40.933 [BACnet4J transport for device 10001] ERROR com.serotonin.bacnet4j.transport.DefaultTransport - Error during send: OutgoingConfirmed [maxAPDULengthAccepted=-1, segmentationSupported=null, service=ReadPropertyRequest [objectIdentifier=device 2098177, propertyIdentifier=object-list, propertyArrayIndex=null], consumer=com.serotonin.bacnet4j.transport.ServiceFutureImpl@10a4064, address=Address [networkNumber=0, macAddress=[c0,a8,1,b1,ba,c0]], linkService=null]
    java.lang.NullPointerException: null
    	at com.serotonin.bacnet4j.transport.DefaultTransport$OutgoingConfirmed.sendImpl(DefaultTransport.java:380)
    	at com.serotonin.bacnet4j.transport.DefaultTransport$Outgoing.send(DefaultTransport.java:336)
    	at com.serotonin.bacnet4j.transport.DefaultTransport.run(DefaultTransport.java:486)
    	at java.base/java.lang.Thread.run(Thread.java:830)
    17:02:40.933 [BACnet4J transport for device 10001] ERROR com.serotonin.bacnet4j.transport.DefaultTransport - Original send stack
    java.lang.Exception: null
    	at com.serotonin.bacnet4j.transport.DefaultTransport.send(DefaultTransport.java:292)
    	at com.serotonin.bacnet4j.transport.DefaultTransport.send(DefaultTransport.java:283)
    	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:989)
    	at com.serotonin.bacnet4j.util.RequestUtils.sendOneAtATime(RequestUtils.java:425)
    	at com.serotonin.bacnet4j.util.RequestUtils.readProperties(RequestUtils.java:396)
    	at com.serotonin.bacnet4j.util.RequestUtils.readProperties(RequestUtils.java:257)
    	at com.serotonin.bacnet4j.util.RequestUtils.getProperties(RequestUtils.java:141)
    	at com.serotonin.bacnet4j.util.RequestUtils.getProperties(RequestUtils.java:136)
    	at com.bacnetbrowser.schoko.DeviceTest$Listener.iAmReceived(DeviceTest.java:40)
    	at com.serotonin.bacnet4j.event.DeviceEventHandler.fireIAmReceived(DeviceEventHandler.java:97)
    	at com.serotonin.bacnet4j.service.unconfirmed.IAmRequest.lambda$handle$0(IAmRequest.java:118)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:830)
    

    The code I used for testing:

    public class DeviceTest {
        static LocalDevice localDevice;
    
        public static void main(String[] args) throws Exception {
            int localDevice_ID = 10001;
            IpNetworkBuilder ipNetworkBuilder = new IpNetworkBuilder();
            ipNetworkBuilder.withLocalBindAddress(IpNetwork.DEFAULT_BIND_IP);
            ipNetworkBuilder.withBroadcast("255.255.255.255", IpNetwork.BVLC_TYPE);
            ipNetworkBuilder.withPort(47808);
            DefaultTransport transport = new DefaultTransport(ipNetworkBuilder.build());
            localDevice = new LocalDevice(localDevice_ID, transport);
            localDevice.getEventHandler().addListener(new Listener());
            localDevice.initialize();
            localDevice.startRemoteDeviceDiscovery();
        }
    
        static class Listener extends DeviceEventAdapter {
            @Override
            public void iAmReceived(RemoteDevice d) {
                System.out.println("I am received" + d);
                Device device = new Device(localDevice, d.getInstanceNumber(), d.getAddress());
                try {
                    Map<PropertyIdentifier, Encodable> values = RequestUtils.getProperties(
                            localDevice, device, device.getObjectIdentifier(),null,
                            PropertyIdentifier.objectList);
                    System.out.println(values);
                } catch (BACnetException e) {
                    e.printStackTrace();
                }
            }
        }
    
        static class Device extends RemoteDevice{
            public Device(LocalDevice localDevice, int instanceNumber, Address address) {
                super(localDevice, instanceNumber, address);
            }
        }
    
    }
    

    I would be glad if somone could have a look and give me a feedback ;-)

    BR
    Andreas

    posted in BACnet4J general discussion read more
  • A
    Andreas Vogt

    I have figured out by myself. You have to send a new WritePropertyRequest on present value but insted of the pv value you have to send a "PriorityValue" with "Null".

    0_1575487504859_79706a4c-1e1f-425b-8d62-da4cf2ebaf62-image.png

    posted in BACnet4J general discussion read more
  • A
    Andreas Vogt

    Hello Guys

    If I use the WritePropertyRequest to write a present value, I do this with the priority 8 (Manual Operation).
    As shown in the example:
    0_1575135310967_c475bcd1-8261-4f3b-af4d-75c6dd67a94b-image.png

    This works fine but if I want to release the manual operation again, what do I have to do?
    Do I have to send a new WritePropertyRequest which sets the PriorityValue back to null?

    Many thanks for your support!

    Regards
    Andreas

    posted in BACnet4J general discussion read more
  • A
    Andreas Vogt

    Hi phil

    Meanwhile I found the "Destination" type in the type package. I could registered the LocalDevcie on my RemoteDevices at the notifications class objects.
    Now I am goning to try the intrinsic reporting as you said.

    Many thanks for your hepl!

    posted in BACnet4J general discussion read more
  • A
    Andreas Vogt

    Hello Guys
    I guess I have the same problem as revanreddy. The DeviceEventListener works fine for COV in datapoints like present value. But how do I get the Events/Alarms in the eventNotificationReceived
    method?

    I think, I have to set the localDevice as a receifer in the notifications class on the the remote device. Could you guys help me out with an example or test class?
    Thanks in advance!

    posted in BACnet4J general discussion read more