HI can any one please help me on this ....
package com.lnt.TestApp;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.serotonin.bacnet4j.LocalDevice;
import com.serotonin.bacnet4j.RemoteDevice;
import com.serotonin.bacnet4j.enums.MaxApduLength;
import com.serotonin.bacnet4j.exception.BACnetException;
import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
import com.serotonin.bacnet4j.service.acknowledgement.AcknowledgementService;
import com.serotonin.bacnet4j.service.acknowledgement.ReadPropertyAck;
import com.serotonin.bacnet4j.service.acknowledgement.ReadRangeAck;
import com.serotonin.bacnet4j.service.confirmed.ConfirmedRequestService;
import com.serotonin.bacnet4j.service.confirmed.ReadPropertyRequest;
import com.serotonin.bacnet4j.service.confirmed.ReadRangeRequest;
import com.serotonin.bacnet4j.service.confirmed.ReadRangeRequest.BySequenceNumber;
import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
import com.serotonin.bacnet4j.transport.Transport;
import com.serotonin.bacnet4j.type.Encodable;
import com.serotonin.bacnet4j.type.constructed.Address;
import com.serotonin.bacnet4j.type.constructed.LogRecord;
import com.serotonin.bacnet4j.type.constructed.SequenceOf;
import com.serotonin.bacnet4j.type.enumerated.ObjectType;
import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
import com.serotonin.bacnet4j.type.enumerated.Segmentation;
import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
import com.serotonin.bacnet4j.type.primitive.OctetString;
import com.serotonin.bacnet4j.type.primitive.SignedInteger;
import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
import com.serotonin.bacnet4j.util.PropertyReferences;
import com.serotonin.bacnet4j.util.PropertyValues;
import com.serotonin.bacnet4j.util.RequestUtils;
public class Test {
static LocalDevice lDevice;
static Address addr = new Address(0, "172.28.14.100");
public Test() {
}
public static void main(String args[]) {
initializeDevice();
}
public static void initializeDevice() {
try {
System.out.println("Initializing...");
IpNetwork ipNetwork = new IpNetwork("172.28.14.255", 47808,
"172.28.14.63");
Transport transport = new Transport(ipNetwork);
lDevice = new LocalDevice(9899, transport);
lDevice.initialize();
lDevice.getEventHandler().addListener(new Listener());
lDevice.sendGlobalBroadcast(new WhoIsRequest());
Thread.sleep(500);
getObjectList(lDevice, "172.28.14.100", 47808, 0);
} catch (Exception e) {
System.out.println("Error : " + e.getMessage());
} finally {
closeDevice();
}
}
public static AcknowledgementService send(LocalDevice d,
ConfirmedRequestService s) throws Exception {
// Address a = new Address(InetAddrCache.get("localhost", 0xbac1));
return d.send(addr, null, MaxApduLength.UP_TO_1476,
Segmentation.segmentedBoth, s);
}
public static void closeDevice() {
try {
lDevice.terminate();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
private static void getObjectList(LocalDevice localDevice, String ip,
int port, int deviceId) {
RemoteDevice fileDev = null;
ObjectIdentifier file = null;
ReadPropertyRequest readPropertyRequest;
ReadPropertyAck reaPropertyAck;
UnsignedInteger referenceIndex = null;
SignedInteger signedInteger = null;
Address address[] = lDevice.getAllLocalAddresses();
OctetString octetString = new OctetString("172.28.14.63", 47808);
RemoteDevice dev3400 = null;
//try {
//dev3400 = lDevice.findRemoteDevice(address[0], octetString, 0);
dev3400 = lDevice.getRemoteDevice(address[0]);
//} catch (BACnetException e1) {
// TODO Auto-generated catch block
// e1.printStackTrace();
//}
for (RemoteDevice d : localDevice.getRemoteDevices()) {
// ObjectIdentifier oid = d.getObjectIdentifier();
RemoteDevice rd = new RemoteDevice(123, localDevice.getAllLocalAddresses()[0], octetString);
@SuppressWarnings("unchecked")
List<ObjectIdentifier> oids;
try {
oids = ((SequenceOf<ObjectIdentifier>) RequestUtils .sendReadPropertyAllowNull(localDevice, d, d.getObjectIdentifier(),
PropertyIdentifier.objectList)).getValues();
for (ObjectIdentifier oid : oids) {
readPropertyRequest = new ReadPropertyRequest(oid, PropertyIdentifier.objectName);
reaPropertyAck = (ReadPropertyAck) localDevice.send(d,readPropertyRequest);
System.out.println("Value: " + reaPropertyAck.getValue());
if (oid.getObjectType().equals(ObjectType.trendLog)) {
readPropertyRequest = new ReadPropertyRequest(oid, PropertyIdentifier.objectName);
reaPropertyAck = (ReadPropertyAck) localDevice.send(d, readPropertyRequest);
System.out.println("ObjectName: "+ reaPropertyAck.getValue());
readPropertyRequest = new ReadPropertyRequest(oid,PropertyIdentifier.bufferSize);
reaPropertyAck = (ReadPropertyAck) localDevice.send(d,readPropertyRequest);
System.out.println("BufferSize: "+ reaPropertyAck.getValue());
readPropertyRequest = new ReadPropertyRequest(oid, PropertyIdentifier.totalRecordCount);
reaPropertyAck = (ReadPropertyAck) localDevice.send(d, readPropertyRequest);
System.out.println("totalRecordCount: " + reaPropertyAck.getValue());
// Encodable totalRecordCount = // reaPropertyAck.getValue();
readPropertyRequest = new ReadPropertyRequest(oid, PropertyIdentifier.recordCount);
reaPropertyAck = (ReadPropertyAck) localDevice.send(d, readPropertyRequest);
System.out.println("RecordCount: "+ reaPropertyAck.getValue());
// Encodable recordCount = reaPropertyAck.getValue();
readPropertyRequest = new ReadPropertyRequest(oid, PropertyIdentifier.eventState);
reaPropertyAck = (ReadPropertyAck) localDevice.send(d, readPropertyRequest);
System.out.println("eventState: " + reaPropertyAck.getValue());
readPropertyRequest = new ReadPropertyRequest(oid,PropertyIdentifier.totalRecordCount);
reaPropertyAck = (ReadPropertyAck) lDevice.send(d,readPropertyRequest);
System.out.println("TotalRecordCount: "+ reaPropertyAck.getValue());
UnsignedInteger totalRecordCount = (UnsignedInteger) reaPropertyAck.getValue();
readPropertyRequest = new ReadPropertyRequest(oid, PropertyIdentifier.recordCount);
reaPropertyAck = (ReadPropertyAck) lDevice.send(d, readPropertyRequest);
System.out.println("RecordCount: "+ reaPropertyAck.getValue());
UnsignedInteger recordCount = (UnsignedInteger) reaPropertyAck.getValue();
signedInteger = new SignedInteger(recordCount.bigIntegerValue());
referenceIndex = new UnsignedInteger(totalRecordCount.longValue() - signedInteger.longValue() - 1);
ReadRangeRequest rrr = new ReadRangeRequest(new ObjectIdentifier(ObjectType.trendLogMultiple, 11),
PropertyIdentifier.logBuffer, null, new BySequenceNumber(referenceIndex,signedInteger));
//lDevice.send(d, rrr);
ReadRangeAck rra = (ReadRangeAck)lDevice.send(d, rrr);
System.out.println(rra.getItemCount());
System.out.println(rra.getFirstSequenceNumber());
System.out.println(rra.getItemData());
Iterator<?> it = (Iterator<?>)rra.getItemData().iterator();
while (it.hasNext())
{
Encodable e = (Encodable)it.next();
if (e instanceof LogRecord)
{
LogRecord lr = (LogRecord)e;
//System.out.println(lr.getBaseType());
System.out.println(lr.getChoiceType());
}
}
}
}
} catch (BACnetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
I am able to read bacnet objets, but i want to read trendlog contentes in my code when the flo comes ReadRangeRequest and ReadRangeAc am getting bacnet timeout exception can u please see the code and guid me on this...