<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ArrayIndexOutOfBoundsException in CommandPriorityTest]]></title><description><![CDATA[<p dir="auto">Hi everyone,<br />
i could run almost all examples, but i really need run this one 'CommandPriorityTest.java', i want to set the present value of my object.</p>
<p dir="auto">So i try to run, and gives me this error:</p>
<pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
        at java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:343)
        at com.bacnet.webservice.CommandPriorityTest.main(CommandPriorityTest.java:46)
</code></pre>
<p dir="auto">Here's my code:</p>
<pre><code>/*
    Copyright (C) 2006-2009 Serotonin Software Technologies Inc.
 	@author Matthew Lohbihler
 */
package com.bacnet.webservice;

import com.serotonin.bacnet4j.LocalDevice;
import com.serotonin.bacnet4j.RemoteDevice;
import com.serotonin.bacnet4j.RemoteObject;
import com.serotonin.bacnet4j.service.acknowledgement.ReadPropertyAck;
import com.serotonin.bacnet4j.service.confirmed.ReadPropertyRequest;
import com.serotonin.bacnet4j.service.confirmed.WritePropertyRequest;
import com.serotonin.bacnet4j.service.unconfirmed.WhoHasRequest;
import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
import com.serotonin.bacnet4j.type.Encodable;
import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
import com.serotonin.bacnet4j.type.primitive.CharacterString;
import com.serotonin.bacnet4j.type.primitive.Null;
import com.serotonin.bacnet4j.type.primitive.Real;
import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;

/**
 * @author Matthew Lohbihler
 */
public class CommandPriorityTest {
    private static LocalDevice localDevice;
    private static RemoteDevice remoteDevice;
    private static RemoteObject remoteObject;
    
    public static void main(String[] args) throws Exception {
        String objectName = "Command Priority Test";
        localDevice = new LocalDevice(101, "255.255.255.255"); // the only thing i change is the device id
        localDevice.initialize();
        
        // Who is
        localDevice.sendBroadcast(2068, null, new WhoIsRequest());
        Thread.sleep(1000);
        
        // Who has
        localDevice.sendBroadcast(2068, null, new WhoHasRequest(null, new CharacterString(objectName)));
        
        // Wait a bit for responses to come in.
        Thread.sleep(1000);
        
        // Find the device
        remoteDevice = localDevice.getRemoteDevices().get(0);
//        localDevice.getExtendedDeviceInformation(remoteDevice);
//        List&lt;ObjectIdentifier&gt; oids = ((SequenceOf&lt;ObjectIdentifier&gt;)localDevice.sendReadPropertyAllowNull(
//                remoteDevice, remoteDevice.getObjectIdentifier(), PropertyIdentifier.objectList)).getValues();
//        for ()
//        remoteDevice.setObject(new RemoteObject())
        
        
        // Find the object.
        for (RemoteObject o : remoteDevice.getObjects()) {
            if (o.getObjectName().equals(objectName)) {
                remoteObject = o;
                break;
            }
        }
            
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Real(16), 16);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Real(15), 15);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Null(), 16);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Real(16), 16);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Real(10), 10);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Null(), 10);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Null(), 15);
        getPresentValue();
        getPriorityArray();
        
        setPresentValue(new Null(), 16);
        getPresentValue();
        getPriorityArray();
        
        
        localDevice.terminate();
    }
    
    private static void getPresentValue() throws Exception {
        ReadPropertyRequest rpr = new ReadPropertyRequest(remoteObject.getObjectIdentifier(),
                PropertyIdentifier.presentValue);
        ReadPropertyAck ack = (ReadPropertyAck)localDevice.send(remoteDevice, rpr);
        System.out.println("Present value: "+ ack.getValue());
    }
    
    private static void getPriorityArray() throws Exception {
        ReadPropertyRequest rpr = new ReadPropertyRequest(remoteObject.getObjectIdentifier(),
                PropertyIdentifier.priorityArray);
        ReadPropertyAck ack = (ReadPropertyAck)localDevice.send(remoteDevice, rpr);
        System.out.println("Priority array: "+ ack.getValue());
    }
    
    private static void setPresentValue(Encodable value, int priority) throws Exception {
        WritePropertyRequest wpr = new WritePropertyRequest(remoteObject.getObjectIdentifier(),
                PropertyIdentifier.presentValue, null, value, new UnsignedInteger(priority));
        localDevice.send(remoteDevice, wpr);
    }
}
</code></pre>
<p dir="auto">Any idea ?</p>
<p dir="auto">Best regards,<br />
Valter Henrique.</p>
]]></description><link>https://forum.mango-os.com/topic/820/arrayindexoutofboundsexception-in-commandprioritytest</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Nov 2026 12:40:55 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/820.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Apr 2011 19:35:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ArrayIndexOutOfBoundsException in CommandPriorityTest on Wed, 04 May 2011 16:50:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mlohbihler" aria-label="Profile: mlohbihler">@<bdi>mlohbihler</bdi></a>, i follow your suggestion and happens what you say, no remote devices responds.<br />
I think in my case is just local devices .<br />
Well, this is my code if could help anyone:</p>
<pre><code>
/*
Copyright (C) 2006-2009 Serotonin Software Technologies Inc.
@author Matthew Lohbihler
 */
package com.bacnet.ready;

import com.serotonin.bacnet4j.LocalDevice;
import com.serotonin.bacnet4j.RemoteDevice;
import com.serotonin.bacnet4j.RemoteObject;
import com.serotonin.bacnet4j.service.acknowledgement.ReadPropertyAck;
import com.serotonin.bacnet4j.service.confirmed.ReadPropertyRequest;
import com.serotonin.bacnet4j.service.confirmed.WritePropertyRequest;
import com.serotonin.bacnet4j.service.unconfirmed.WhoHasRequest;
import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
import com.serotonin.bacnet4j.type.Encodable;
import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
import com.serotonin.bacnet4j.type.primitive.CharacterString;
import com.serotonin.bacnet4j.type.primitive.Null;
import com.serotonin.bacnet4j.type.primitive.Real;
import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;

/**
 * @author Matthew Lohbihler
 */
public class CommandPriorityTest {

    private static LocalDevice localDevice;
    private static RemoteDevice remoteDevice;
    private static RemoteObject remoteObject;

    public static void main(String[] args) throws Exception {
        String objectName = "Command Priority Test";
        localDevice = new LocalDevice(101, "192.168.1.255");
        localDevice.initialize();

        // Who is
        localDevice.sendBroadcast(47808, null, new WhoIsRequest());
        Thread.sleep(1000);

        // Who has
        localDevice.sendBroadcast(47808, null, new WhoHasRequest(null, new CharacterString(objectName)));

        // Wait a bit for responses to come in.
        Thread.sleep(1000);

        // Find the device
        if (localDevice.getRemoteDevices().isEmpty()) {
            System.out.println("No devices responded");
        } else {
            remoteDevice = localDevice.getRemoteDevices().get(0);
//        localDevice.getExtendedDeviceInformation(remoteDevice);
//        List&lt;ObjectIdentifier&gt; oids = ((SequenceOf&lt;ObjectIdentifier&gt;)localDevice.sendReadPropertyAllowNull(
//                remoteDevice, remoteDevice.getObjectIdentifier(), PropertyIdentifier.objectList)).getValues();
//        for ()
//        remoteDevice.setObject(new RemoteObject())


            // Find the object.
            for (RemoteObject o : remoteDevice.getObjects()) {
                if (o.getObjectName().equals(objectName)) {
                    remoteObject = o;
                    break;
                }
            }

            getPresentValue();
            getPriorityArray();

            setPresentValue(new Real(16), 16);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Real(15), 15);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Null(), 16);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Real(16), 16);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Real(10), 10);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Null(), 10);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Null(), 15);
            getPresentValue();
            getPriorityArray();

            setPresentValue(new Null(), 16);
            getPresentValue();
            getPriorityArray();


        }
            localDevice.terminate();
    }

    private static void getPresentValue() throws Exception {
        ReadPropertyRequest rpr = new ReadPropertyRequest(remoteObject.getObjectIdentifier(),
                PropertyIdentifier.presentValue);
        ReadPropertyAck ack = (ReadPropertyAck) localDevice.send(remoteDevice, rpr);
        System.out.println("Present value: " + ack.getValue());
    }

    private static void getPriorityArray() throws Exception {
        ReadPropertyRequest rpr = new ReadPropertyRequest(remoteObject.getObjectIdentifier(),
                PropertyIdentifier.priorityArray);
        ReadPropertyAck ack = (ReadPropertyAck) localDevice.send(remoteDevice, rpr);
        System.out.println("Priority array: " + ack.getValue());
    }

    private static void setPresentValue(Encodable value, int priority) throws Exception {
        WritePropertyRequest wpr = new WritePropertyRequest(remoteObject.getObjectIdentifier(),
                PropertyIdentifier.presentValue, null, value, new UnsignedInteger(priority));
        localDevice.send(remoteDevice, wpr);
    }
}

</code></pre>
]]></description><link>https://forum.mango-os.com/post/5730</link><guid isPermaLink="true">https://forum.mango-os.com/post/5730</guid><dc:creator><![CDATA[Valter Henrique]]></dc:creator><pubDate>Wed, 04 May 2011 16:50:56 GMT</pubDate></item><item><title><![CDATA[Reply to ArrayIndexOutOfBoundsException in CommandPriorityTest on Thu, 28 Apr 2011 06:57:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mlohbihler" aria-label="Profile: mlohbihler">@<bdi>mlohbihler</bdi></a>, i have a supervisory that is composed by a FX 20 and a FX 06 both from Johnson Controls, i connected my FX 20 in my router, so i can connect with it acessing 192.168.1.149 inside my LAN.<br />
So i wonder how i can change the value from my device ?<br />
I can read those values, but i don't know how to change them.</p>
<p dir="auto">If you can help me, i appreciate.</p>
<p dir="auto">I could run some example and paste it here to help us.</p>
<p dir="auto">Best regards,<br />
Valter Henrique.</p>
]]></description><link>https://forum.mango-os.com/post/5709</link><guid isPermaLink="true">https://forum.mango-os.com/post/5709</guid><dc:creator><![CDATA[Valter Henrique]]></dc:creator><pubDate>Thu, 28 Apr 2011 06:57:05 GMT</pubDate></item><item><title><![CDATA[Reply to ArrayIndexOutOfBoundsException in CommandPriorityTest on Thu, 21 Apr 2011 18:50:54 GMT]]></title><description><![CDATA[<p dir="auto">This test class works under the expectation that the device you want to communicate with will respond to a WhoIs request (or at least be the first to respond) within one second. Below, at lines 36 and 40 WhoIs and WhoHas requests are sent respectively. Responses to these cause the responder to be automatically registered in the list of known remote devices. If nothing has responded, you will the the error that you have gotten.</p>
<p dir="auto">If you want a cleaner message, you can check if the list in question is empty, print out a messages like "no devices responded", and return.</p>
]]></description><link>https://forum.mango-os.com/post/5701</link><guid isPermaLink="true">https://forum.mango-os.com/post/5701</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Thu, 21 Apr 2011 18:50:54 GMT</pubDate></item></channel></rss>