├── .gitignore
├── README.txt
├── license.txt
├── pom.xml
├── src
├── com
│ └── serotonin
│ │ └── bacnet4j
│ │ ├── LocalDevice.java
│ │ ├── RemoteDevice.java
│ │ ├── RemoteObject.java
│ │ ├── apdu
│ │ ├── APDU.java
│ │ ├── Abort.java
│ │ ├── AckAPDU.java
│ │ ├── ComplexACK.java
│ │ ├── ConfirmedRequest.java
│ │ ├── Error.java
│ │ ├── Reject.java
│ │ ├── SegmentACK.java
│ │ ├── Segmentable.java
│ │ ├── SimpleACK.java
│ │ └── UnconfirmedRequest.java
│ │ ├── base
│ │ └── BACnetUtils.java
│ │ ├── enums
│ │ ├── DayOfWeek.java
│ │ ├── MaxApduLength.java
│ │ ├── MaxSegments.java
│ │ └── Month.java
│ │ ├── event
│ │ ├── DefaultExceptionListener.java
│ │ ├── DeviceEventAdapter.java
│ │ ├── DeviceEventAdapterAsync.java
│ │ ├── DeviceEventHandler.java
│ │ ├── DeviceEventListener.java
│ │ ├── ExceptionDispatch.java
│ │ └── ExceptionListener.java
│ │ ├── exception
│ │ ├── AbortAPDUException.java
│ │ ├── BACnetErrorException.java
│ │ ├── BACnetException.java
│ │ ├── BACnetRejectException.java
│ │ ├── BACnetRuntimeException.java
│ │ ├── BACnetServiceException.java
│ │ ├── BACnetTimeoutException.java
│ │ ├── ConfirmedRequestParseException.java
│ │ ├── ErrorAPDUException.java
│ │ ├── IllegalPduTypeException.java
│ │ ├── NotImplementedException.java
│ │ ├── PropertyValueException.java
│ │ ├── ReflectionException.java
│ │ ├── RejectAPDUException.java
│ │ └── SegmentedMessageAbortedException.java
│ │ ├── npdu
│ │ ├── IncomingRequestParser.java
│ │ ├── IncomingRequestProcessor.java
│ │ ├── MessageValidationAssertionException.java
│ │ ├── NPCI.java
│ │ ├── Network.java
│ │ ├── NetworkIdentifier.java
│ │ ├── ip
│ │ │ ├── InetAddrCache.java
│ │ │ ├── IpNetwork.java
│ │ │ ├── IpNetworkIdentifier.java
│ │ │ ├── SegmentWindow.java
│ │ │ └── WaitingRoom.java
│ │ └── mstp
│ │ │ ├── Constants.java
│ │ │ ├── DataCRC.java
│ │ │ ├── Frame.java
│ │ │ ├── FrameResponseListener.java
│ │ │ ├── FrameType.java
│ │ │ ├── HeaderCRC.java
│ │ │ ├── MasterNode.java
│ │ │ ├── MstpNetwork.java
│ │ │ ├── MstpNetworkIdentifier.java
│ │ │ ├── MstpNode.java
│ │ │ └── SlaveNode.java
│ │ ├── obj
│ │ ├── BACnetObject.java
│ │ ├── FileObject.java
│ │ ├── ObjectCovSubscription.java
│ │ ├── ObjectProperties.java
│ │ ├── ObjectPropertyIdentifier.java
│ │ └── PropertyTypeDefinition.java
│ │ ├── service
│ │ ├── Service.java
│ │ ├── VendorServiceKey.java
│ │ ├── acknowledgement
│ │ │ ├── AcknowledgementService.java
│ │ │ ├── AtomicReadFileAck.java
│ │ │ ├── AtomicWriteFileAck.java
│ │ │ ├── AuthenticateAck.java
│ │ │ ├── ConfirmedPrivateTransferAck.java
│ │ │ ├── CreateObjectAck.java
│ │ │ ├── GetAlarmSummaryAck.java
│ │ │ ├── GetEnrollmentSummaryAck.java
│ │ │ ├── GetEventInformationAck.java
│ │ │ ├── ReadPropertyAck.java
│ │ │ ├── ReadPropertyConditionalAck.java
│ │ │ ├── ReadPropertyMultipleAck.java
│ │ │ ├── ReadRangeAck.java
│ │ │ ├── VtDataAck.java
│ │ │ └── VtOpenAck.java
│ │ ├── confirmed
│ │ │ ├── AcknowledgeAlarmRequest.java
│ │ │ ├── AddListElementRequest.java
│ │ │ ├── AtomicReadFileRequest.java
│ │ │ ├── AtomicWriteFileRequest.java
│ │ │ ├── AuthenticateRequest.java
│ │ │ ├── ConfirmedCovNotificationRequest.java
│ │ │ ├── ConfirmedEventNotificationRequest.java
│ │ │ ├── ConfirmedPrivateTransferRequest.java
│ │ │ ├── ConfirmedRequestService.java
│ │ │ ├── ConfirmedTextMessageRequest.java
│ │ │ ├── CreateObjectRequest.java
│ │ │ ├── DeleteObjectRequest.java
│ │ │ ├── DeviceCommunicationControlRequest.java
│ │ │ ├── GetAlarmSummaryRequest.java
│ │ │ ├── GetEnrollmentSummaryRequest.java
│ │ │ ├── GetEventInformation.java
│ │ │ ├── LifeSafetyOperationRequest.java
│ │ │ ├── ReadPropertyConditionalRequest.java
│ │ │ ├── ReadPropertyMultipleRequest.java
│ │ │ ├── ReadPropertyRequest.java
│ │ │ ├── ReadRangeRequest.java
│ │ │ ├── ReinitializeDeviceRequest.java
│ │ │ ├── RemoveListElementRequest.java
│ │ │ ├── RequestKeyRequest.java
│ │ │ ├── SubscribeCOVPropertyRequest.java
│ │ │ ├── SubscribeCOVRequest.java
│ │ │ ├── VtCloseRequest.java
│ │ │ ├── VtDataRequest.java
│ │ │ ├── VtOpenRequest.java
│ │ │ ├── WritePropertyMultipleRequest.java
│ │ │ └── WritePropertyRequest.java
│ │ └── unconfirmed
│ │ │ ├── IAmRequest.java
│ │ │ ├── IHaveRequest.java
│ │ │ ├── TimeSynchronizationRequest.java
│ │ │ ├── UTCTimeSynchronizationRequest.java
│ │ │ ├── UnconfirmedCovNotificationRequest.java
│ │ │ ├── UnconfirmedEventNotificationRequest.java
│ │ │ ├── UnconfirmedPrivateTransferRequest.java
│ │ │ ├── UnconfirmedRequestService.java
│ │ │ ├── UnconfirmedTextMessageRequest.java
│ │ │ ├── WhoHasRequest.java
│ │ │ └── WhoIsRequest.java
│ │ ├── transport
│ │ ├── Transport.java
│ │ ├── WaitingRoom.java
│ │ └── WaitingRoomKey.java
│ │ ├── type
│ │ ├── AmbiguousValue.java
│ │ ├── Encodable.java
│ │ ├── SequenceDefinition.java
│ │ ├── TagData.java
│ │ ├── ThreadLocalObjectTypeStack.java
│ │ ├── constructed
│ │ │ ├── AccumulatorRecord.java
│ │ │ ├── ActionCommand.java
│ │ │ ├── ActionList.java
│ │ │ ├── Address.java
│ │ │ ├── AddressBinding.java
│ │ │ ├── BACnetError.java
│ │ │ ├── BaseType.java
│ │ │ ├── CalendarEntry.java
│ │ │ ├── Choice.java
│ │ │ ├── ClientCov.java
│ │ │ ├── CovSubscription.java
│ │ │ ├── DailySchedule.java
│ │ │ ├── DateRange.java
│ │ │ ├── DateTime.java
│ │ │ ├── DaysOfWeek.java
│ │ │ ├── Destination.java
│ │ │ ├── DeviceObjectPropertyReference.java
│ │ │ ├── DeviceObjectPropertyValue.java
│ │ │ ├── DeviceObjectReference.java
│ │ │ ├── EventLogRecord.java
│ │ │ ├── EventTransitionBits.java
│ │ │ ├── LimitEnable.java
│ │ │ ├── LogData.java
│ │ │ ├── LogMultipleRecord.java
│ │ │ ├── LogRecord.java
│ │ │ ├── LogStatus.java
│ │ │ ├── ObjectPropertyReference.java
│ │ │ ├── ObjectPropertyValue.java
│ │ │ ├── ObjectTypesSupported.java
│ │ │ ├── Prescale.java
│ │ │ ├── PriorityArray.java
│ │ │ ├── PriorityValue.java
│ │ │ ├── PropertyReference.java
│ │ │ ├── PropertyStates.java
│ │ │ ├── PropertyValue.java
│ │ │ ├── ReadAccessResult.java
│ │ │ ├── ReadAccessSpecification.java
│ │ │ ├── Recipient.java
│ │ │ ├── RecipientProcess.java
│ │ │ ├── ResultFlags.java
│ │ │ ├── Scale.java
│ │ │ ├── Sequence.java
│ │ │ ├── SequenceOf.java
│ │ │ ├── ServicesSupported.java
│ │ │ ├── SessionKey.java
│ │ │ ├── SetpointReference.java
│ │ │ ├── ShedLevel.java
│ │ │ ├── SpecialEvent.java
│ │ │ ├── StatusFlags.java
│ │ │ ├── TimeStamp.java
│ │ │ ├── TimeValue.java
│ │ │ ├── VtSession.java
│ │ │ ├── WeekNDay.java
│ │ │ └── WriteAccessSpecification.java
│ │ ├── enumerated
│ │ │ ├── AbortReason.java
│ │ │ ├── Action.java
│ │ │ ├── BackupState.java
│ │ │ ├── BinaryPV.java
│ │ │ ├── DeviceStatus.java
│ │ │ ├── DoorAlarmState.java
│ │ │ ├── DoorSecuredStatus.java
│ │ │ ├── DoorStatus.java
│ │ │ ├── DoorValue.java
│ │ │ ├── EngineeringUnits.java
│ │ │ ├── ErrorClass.java
│ │ │ ├── ErrorCode.java
│ │ │ ├── EventState.java
│ │ │ ├── EventType.java
│ │ │ ├── FileAccessMethod.java
│ │ │ ├── LifeSafetyMode.java
│ │ │ ├── LifeSafetyOperation.java
│ │ │ ├── LifeSafetyState.java
│ │ │ ├── LockStatus.java
│ │ │ ├── LoggingType.java
│ │ │ ├── Maintenance.java
│ │ │ ├── MessagePriority.java
│ │ │ ├── NodeType.java
│ │ │ ├── NotifyType.java
│ │ │ ├── ObjectType.java
│ │ │ ├── Polarity.java
│ │ │ ├── ProgramError.java
│ │ │ ├── ProgramRequest.java
│ │ │ ├── ProgramState.java
│ │ │ ├── PropertyIdentifier.java
│ │ │ ├── RejectReason.java
│ │ │ ├── Reliability.java
│ │ │ ├── RestartReason.java
│ │ │ ├── Segmentation.java
│ │ │ ├── ShedState.java
│ │ │ ├── SilencedState.java
│ │ │ └── VtClass.java
│ │ ├── error
│ │ │ ├── BaseError.java
│ │ │ ├── ChangeListError.java
│ │ │ ├── ConfirmedPrivateTransferError.java
│ │ │ ├── CreateObjectError.java
│ │ │ ├── VTCloseError.java
│ │ │ └── WritePropertyMultipleError.java
│ │ ├── eventParameter
│ │ │ ├── BufferReady.java
│ │ │ ├── ChangeOfBitString.java
│ │ │ ├── ChangeOfLifeSafety.java
│ │ │ ├── ChangeOfState.java
│ │ │ ├── ChangeOfValue.java
│ │ │ ├── CommandFailure.java
│ │ │ ├── EventParameter.java
│ │ │ ├── Extended.java
│ │ │ ├── FloatingLimit.java
│ │ │ ├── OutOfRange.java
│ │ │ └── UnsignedRange.java
│ │ ├── notificationParameters
│ │ │ ├── BufferReady.java
│ │ │ ├── ChangeOfBitString.java
│ │ │ ├── ChangeOfLifeSafety.java
│ │ │ ├── ChangeOfState.java
│ │ │ ├── ChangeOfValue.java
│ │ │ ├── CommandFailure.java
│ │ │ ├── ComplexEventType.java
│ │ │ ├── Extended.java
│ │ │ ├── FloatingLimit.java
│ │ │ ├── NotificationParameters.java
│ │ │ ├── OutOfRange.java
│ │ │ └── UnsignedRange.java
│ │ └── primitive
│ │ │ ├── BitString.java
│ │ │ ├── Boolean.java
│ │ │ ├── CharacterString.java
│ │ │ ├── Date.java
│ │ │ ├── Double.java
│ │ │ ├── Enumerated.java
│ │ │ ├── Null.java
│ │ │ ├── ObjectIdentifier.java
│ │ │ ├── OctetString.java
│ │ │ ├── Primitive.java
│ │ │ ├── Real.java
│ │ │ ├── SignedInteger.java
│ │ │ ├── Time.java
│ │ │ ├── Unsigned16.java
│ │ │ ├── Unsigned32.java
│ │ │ ├── Unsigned8.java
│ │ │ └── UnsignedInteger.java
│ │ └── util
│ │ ├── ClockTimeSource.java
│ │ ├── PropertyReferences.java
│ │ ├── PropertyValues.java
│ │ ├── RequestListener.java
│ │ ├── RequestListenerUpdater.java
│ │ ├── RequestUtils.java
│ │ └── TimeSource.java
└── org
│ └── free
│ └── bacnet4j
│ └── util
│ ├── ArrayUtils.java
│ ├── ByteQueue.java
│ ├── IpAddressUtils.java
│ ├── IpWhiteListException.java
│ ├── RXTXHack.java
│ ├── SerialParameters.java
│ ├── SerialPortException.java
│ ├── SerialUtils.java
│ └── StreamUtils.java
└── src_test
├── BacnetTest.java
└── com
└── serotonin
└── bacnet4j
├── discovery
├── MstpObjectList.java
└── WhoIs.java
├── rs485
├── EncodingTest.java
├── HubClient.java
├── HubServer.java
├── MstpTest.java
├── PortTest.java
├── ScriptTest.java
├── SerialTest.java
└── readme.txt
└── test
├── AnnexFEncodingTest.java
├── CommandPriorityTest.java
├── DecodingTest.java
├── DeserializationTest.java
├── DiscoveryTest.java
├── FileAccessTest.java
├── LargeSegmentTest.java
├── LoopDevice.java
├── MessageControl.java
├── ObjectCovSubscriptionTest.java
├── OverflowTest.java
├── QuickTest.java
├── ReadAllAvailableProperties.java
├── SegmentedDecodingTest.java
├── SerializationTests.java
├── ServiceDataDecoding.java
├── SimpleSubscriptionClient.java
├── SlaveDeviceTest.java
├── Test.java
├── Test2.java
├── Test3.java
├── ThresholdCalculatorTest.java
├── TrendLogTest.java
└── UdpDump.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Package Files #
4 | *.jar
5 | *.war
6 | *.ear
7 | bin/*
8 | *.zip
9 | #Eclipse
10 | .classpath
11 | .project
12 | .settings/
13 | #Maven
14 | log/
15 | target/
16 | /bin/
17 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | *Version 2.0.4 release notes*
2 | -Project now generates javadoc and source via maven in package phase.
3 | *Version 2.0.3 release notes*
4 | -Project is now test-build-deploy lifecycle now managed by maven(3) rather than ant. Dependent libraries removed from repo tracking.
5 |
6 | *Version 2.0.2 release notes*
7 | -Non-blocking incoming message processor added.
8 | -Local device creation params improved. Changed to BRT from Serotonin. WIP need to make truly general from Vendor ID list.
9 | -Many compiler warnings fixed (that in fairness, weren't warnings until v1.7 & new features.)
10 |
11 | *Version 2.0.1 release notes*
12 |
13 | -bacnet4J.jar dependency added.
14 |
15 | -seroUtils.jar (and its proprietary licensing) are no longer a dependency. Relevant functionality has been coded from scratch in org.free.bacnet4j.util package,
16 | and imported throughout project where needed. A discussion forum for this package can be found at http://mango.serotoninsoftware.com/forum/forums/show/12.page.
17 |
18 | -Building the jar with ant should be close to one-click right from start of cloning.
19 |
20 |
21 | *Version 2.0 release notes*
22 |
23 | The networking package of this product has been pretty much entirely rewritten to support MS/TP. These changes implied
24 | many changes to the LocalDevice public interface, so if you were using version 1.x you will need to port some code to
25 | upgrade.
26 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | com.serotonin
4 | bacnet4j
5 | 2.0.4
6 | BACnet4J
7 | Java Library implementing BACnet messaging
8 |
9 | src
10 | src_test
11 |
12 |
13 | src
14 |
15 | **/*.java
16 |
17 |
18 |
19 |
20 |
21 | src_test
22 |
23 | **/*.java
24 |
25 |
26 |
27 |
28 |
29 | maven-compiler-plugin
30 | 3.1
31 |
32 | 1.7
33 | 1.7
34 |
35 |
36 |
37 | org.apache.maven.plugins
38 | maven-source-plugin
39 | 2.3
40 |
41 |
42 | attach-sources
43 |
44 | jar
45 |
46 |
47 |
48 |
49 |
50 | org.apache.maven.plugins
51 | maven-javadoc-plugin
52 | 2.10
53 |
54 |
55 | attach-javadocs
56 |
57 | jar
58 |
59 |
60 | -Xdoclint:none
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.apache.commons
70 | commons-lang3
71 | 3.0
72 |
73 |
74 | log4j
75 | log4j
76 | 1.2.17
77 |
78 |
79 | org.rxtx
80 | rxtx
81 | 2.1.7
82 |
83 |
84 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/RemoteObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license the following extension to GPL is made.
22 | * A special exception to the GPL is included to allow you to distribute a
23 | * combined work that includes BAcnet4J without being obliged to provide
24 | * the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j;
27 |
28 | import java.io.Serializable;
29 |
30 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
31 |
32 | public class RemoteObject implements Serializable {
33 | private static final long serialVersionUID = 2962046198697775365L;
34 | private final ObjectIdentifier oid;
35 | private String objectName;
36 |
37 | public RemoteObject(ObjectIdentifier oid) {
38 | this.oid = oid;
39 | }
40 |
41 | public ObjectIdentifier getObjectIdentifier() {
42 | return oid;
43 | }
44 |
45 | public void setObjectName(String objectName) {
46 | this.objectName = objectName;
47 | }
48 |
49 | public String getObjectName() {
50 | return objectName;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return oid.toString();
56 | }
57 |
58 | @Override
59 | public int hashCode() {
60 | final int PRIME = 31;
61 | int result = 1;
62 | result = PRIME * result + ((oid == null) ? 0 : oid.hashCode());
63 | return result;
64 | }
65 |
66 | @Override
67 | public boolean equals(Object obj) {
68 | if (this == obj)
69 | return true;
70 | if (obj == null)
71 | return false;
72 | if (getClass() != obj.getClass())
73 | return false;
74 | final RemoteObject other = (RemoteObject) obj;
75 | if (oid == null) {
76 | if (other.oid != null)
77 | return false;
78 | }
79 | else if (!oid.equals(other.oid))
80 | return false;
81 | return true;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/apdu/APDU.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.apdu;
27 |
28 | import java.io.Serializable;
29 |
30 | import com.serotonin.bacnet4j.exception.BACnetException;
31 | import com.serotonin.bacnet4j.exception.IllegalPduTypeException;
32 | import com.serotonin.bacnet4j.type.constructed.ServicesSupported;
33 | import org.free.bacnet4j.util.ByteQueue;
34 |
35 | abstract public class APDU implements Serializable {
36 | private static final long serialVersionUID = -5844093063653180470L;
37 |
38 | public static APDU createAPDU(ServicesSupported services, ByteQueue queue) throws BACnetException {
39 | // Get the first byte. The 4 high-order bits will tell us the type of PDU this is.
40 | byte type = queue.peek(0);
41 | type = (byte) ((type & 0xff) >> 4);
42 |
43 | if (type == ConfirmedRequest.TYPE_ID)
44 | return new ConfirmedRequest(services, queue);
45 | if (type == UnconfirmedRequest.TYPE_ID)
46 | return new UnconfirmedRequest(services, queue);
47 | if (type == SimpleACK.TYPE_ID)
48 | return new SimpleACK(queue);
49 | if (type == ComplexACK.TYPE_ID)
50 | return new ComplexACK(queue);
51 | if (type == SegmentACK.TYPE_ID)
52 | return new SegmentACK(queue);
53 | if (type == Error.TYPE_ID)
54 | return new Error(queue);
55 | if (type == Reject.TYPE_ID)
56 | return new Reject(queue);
57 | if (type == Abort.TYPE_ID)
58 | return new Abort(queue);
59 | throw new IllegalPduTypeException(Byte.toString(type));
60 | }
61 |
62 | abstract public byte getPduType();
63 |
64 | abstract public void write(ByteQueue queue);
65 |
66 | protected int getShiftedTypeId(byte typeId) {
67 | return typeId << 4;
68 | }
69 |
70 | abstract public boolean expectsReply();
71 | }
72 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/apdu/AckAPDU.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.apdu;
27 |
28 | abstract public class AckAPDU extends APDU {
29 | private static final long serialVersionUID = -1568364467441619342L;
30 |
31 | /**
32 | * This parameter shall be the 'invokeID' contained in the confirmed service request being acknowledged. The same
33 | * 'originalinvokeID' shall be used for all segments of a segmented acknowledgment.
34 | */
35 | protected byte originalInvokeId;
36 |
37 | public byte getOriginalInvokeId() {
38 | return originalInvokeId;
39 | }
40 |
41 | public boolean isServer() {
42 | return true;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/apdu/Segmentable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.apdu;
27 |
28 | import com.serotonin.bacnet4j.exception.BACnetException;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public interface Segmentable {
32 |
33 | byte getInvokeId();
34 |
35 | boolean isSegmentedMessage();
36 |
37 | boolean isMoreFollows();
38 |
39 | int getSequenceNumber();
40 |
41 | int getProposedWindowSize();
42 |
43 | void appendServiceData(ByteQueue segmentable);
44 |
45 | void parseServiceData() throws BACnetException;
46 |
47 | ByteQueue getServiceData();
48 |
49 | APDU clone(boolean moreFollows, int sequenceNumber, int actualSegWindow, ByteQueue data);
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/enums/DayOfWeek.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.enums;
27 | /**
28 | * Per ASHRAE Standard 135-2012 p.713
29 | *
30 | *
31 | */
32 | public enum DayOfWeek {
33 | MONDAY (1),
34 | TUESDAY (2),
35 | WEDNESDAY (3),
36 | THURSDAY (4),
37 | FRIDAY (5),
38 | SATURDAY (6),
39 | SUNDAY (7),
40 | UNSPECIFIED(255);//i.e. X'FF' = any day of week
41 |
42 | private byte id;
43 |
44 | DayOfWeek(int id) {
45 | this.id = (byte) id;
46 | }
47 |
48 | public byte getId() {
49 | return id;
50 | }
51 |
52 | public static DayOfWeek valueOf(byte id) {
53 | if (id == MONDAY.id)
54 | return MONDAY;
55 | if (id == TUESDAY.id)
56 | return TUESDAY;
57 | if (id == WEDNESDAY.id)
58 | return WEDNESDAY;
59 | if (id == THURSDAY.id)
60 | return THURSDAY;
61 | if (id == FRIDAY.id)
62 | return FRIDAY;
63 | if (id == SATURDAY.id)
64 | return SATURDAY;
65 | if (id == SUNDAY.id)
66 | return SUNDAY;
67 | return UNSPECIFIED;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/enums/MaxApduLength.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.enums;
27 |
28 | public enum MaxApduLength {
29 | UP_TO_50(0, 50), // MinimumMessageSize
30 | UP_TO_128(1, 128), //
31 | UP_TO_206(2, 206), // Fits in a LonTalk frame
32 | UP_TO_480(3, 480), // Fits in an ARCNET frame
33 | UP_TO_1024(4, 1024), //
34 | UP_TO_1476(5, 1476); // Fits in an ISO 8802-3 frame
35 |
36 | private byte id;
37 | private int maxLength;
38 |
39 | MaxApduLength(int id, int maxLength) {
40 | this.id = (byte) id;
41 | this.maxLength = maxLength;
42 | }
43 |
44 | public byte getId() {
45 | return id;
46 | }
47 |
48 | public int getMaxLength() {
49 | return maxLength;
50 | }
51 |
52 | public static MaxApduLength valueOf(byte id) {
53 | if (id == UP_TO_50.id)
54 | return UP_TO_50;
55 | if (id == UP_TO_128.id)
56 | return UP_TO_128;
57 | if (id == UP_TO_206.id)
58 | return UP_TO_206;
59 | if (id == UP_TO_480.id)
60 | return UP_TO_480;
61 | if (id == UP_TO_1024.id)
62 | return UP_TO_1024;
63 | if (id == UP_TO_1476.id)
64 | return UP_TO_1476;
65 |
66 | throw new IllegalArgumentException("Unknown id: " + id);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/enums/MaxSegments.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.enums;
27 |
28 | public enum MaxSegments {
29 | UNSPECIFIED(0, Integer.MAX_VALUE), //
30 | UP_TO_2(1, 2), //
31 | UP_TO_4(2, 4), //
32 | UP_TO_8(3, 8), //
33 | UP_TO_16(4, 16), //
34 | UP_TO_32(5, 32), //
35 | UP_TO_64(6, 64), //
36 | MORE_THAN_64(7, Integer.MAX_VALUE), //
37 | ;
38 |
39 | private byte id;
40 | private int maxSegments;
41 |
42 | MaxSegments(int id, int maxSegments) {
43 | this.id = (byte) id;
44 | this.maxSegments = maxSegments;
45 | }
46 |
47 | public byte getId() {
48 | return id;
49 | }
50 |
51 | public int getMaxSegments() {
52 | return maxSegments;
53 | }
54 |
55 | public static MaxSegments valueOf(byte id) {
56 | if (id == UNSPECIFIED.id)
57 | return UNSPECIFIED;
58 | if (id == UP_TO_2.id)
59 | return UP_TO_2;
60 | if (id == UP_TO_4.id)
61 | return UP_TO_4;
62 | if (id == UP_TO_8.id)
63 | return UP_TO_8;
64 | if (id == UP_TO_16.id)
65 | return UP_TO_16;
66 | if (id == UP_TO_32.id)
67 | return UP_TO_32;
68 | if (id == UP_TO_64.id)
69 | return UP_TO_64;
70 | if (id == MORE_THAN_64.id)
71 | return MORE_THAN_64;
72 |
73 | throw new IllegalArgumentException("Unknown id: " + id);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/enums/Month.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.enums;
27 |
28 | /**
29 | * Per ASHRAE Standard 135-2012 p.713
30 | *
31 | */
32 | public enum Month {
33 | JANUARY (1),
34 | FEBRUARY (2),
35 | MARCH (3),
36 | APRIL (4),
37 | MAY (5),
38 | JUNE (6),
39 | JULY (7),
40 | AUGUST (8),
41 | SEPTEMBER (9),
42 | OCTOBER (10),
43 | NOVEMBER (11),
44 | DECEMBER (12),
45 | ODD_MONTHS (13),
46 | EVEN_MONTHS(14),
47 | UNSPECIFIED(255);//X'FF' = any month
48 |
49 | private byte id;
50 |
51 | Month(int id) {
52 | this.id = (byte) id;
53 | }
54 |
55 | public byte getId() {
56 | return id;
57 | }
58 |
59 | public static Month valueOf(byte id) {
60 | if (id == JANUARY.id)
61 | return JANUARY;
62 | if (id == FEBRUARY.id)
63 | return FEBRUARY;
64 | if (id == MARCH.id)
65 | return MARCH;
66 | if (id == APRIL.id)
67 | return APRIL;
68 | if (id == MAY.id)
69 | return MAY;
70 | if (id == JUNE.id)
71 | return JUNE;
72 | if (id == JULY.id)
73 | return JULY;
74 | if (id == AUGUST.id)
75 | return AUGUST;
76 | if (id == SEPTEMBER.id)
77 | return SEPTEMBER;
78 | if (id == OCTOBER.id)
79 | return OCTOBER;
80 | if (id == NOVEMBER.id)
81 | return NOVEMBER;
82 | if (id == DECEMBER.id)
83 | return DECEMBER;
84 | if (id == ODD_MONTHS.id)
85 | return ODD_MONTHS;
86 | if (id == EVEN_MONTHS.id)
87 | return EVEN_MONTHS;
88 | return UNSPECIFIED;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/event/DefaultExceptionListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.event;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class DefaultExceptionListener implements ExceptionListener {
32 | public void unimplementedVendorService(UnsignedInteger vendorId, UnsignedInteger serviceNumber, ByteQueue queue) {
33 | System.out.println("Received unimplemented vendor service: vendor id=" + vendorId + ", service number="
34 | + serviceNumber + ", bytes (with context id)=" + queue);
35 | }
36 |
37 | public void receivedException(Exception e) {
38 | e.printStackTrace();
39 | }
40 |
41 | public void receivedThrowable(Throwable t) {
42 | t.printStackTrace();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/event/ExceptionDispatch.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.event;
2 |
3 | import java.util.List;
4 | import java.util.concurrent.CopyOnWriteArrayList;
5 |
6 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
7 | import org.free.bacnet4j.util.ByteQueue;
8 |
9 | public class ExceptionDispatch {
10 | private static final List listeners = new CopyOnWriteArrayList();
11 | private static final ExceptionListener defaultExceptionListener = new DefaultExceptionListener();
12 |
13 | static {
14 | listeners.add(defaultExceptionListener);
15 | }
16 |
17 | public static void addListener(ExceptionListener l) {
18 | listeners.add(l);
19 | }
20 |
21 | public static void removeListener(ExceptionListener l) {
22 | listeners.remove(l);
23 | }
24 |
25 | public void removeDefaultExceptionListener() {
26 | listeners.remove(defaultExceptionListener);
27 | }
28 |
29 | public static void fireUnimplementedVendorService(UnsignedInteger vendorId, UnsignedInteger serviceNumber,
30 | ByteQueue queue) {
31 | for (ExceptionListener l : listeners)
32 | l.unimplementedVendorService(vendorId, serviceNumber, queue);
33 | }
34 |
35 | public static void fireReceivedException(Exception e) {
36 | for (ExceptionListener l : listeners)
37 | l.receivedException(e);
38 | }
39 |
40 | public static void fireReceivedThrowable(Throwable t) {
41 | for (ExceptionListener l : listeners)
42 | l.receivedThrowable(t);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/event/ExceptionListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.event;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public interface ExceptionListener {
32 | void unimplementedVendorService(UnsignedInteger vendorId, UnsignedInteger serviceNumber, ByteQueue queue);
33 |
34 | void receivedException(Exception e);
35 |
36 | void receivedThrowable(Throwable t);
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/AbortAPDUException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.apdu.Abort;
29 |
30 | public class AbortAPDUException extends BACnetException {
31 | private static final long serialVersionUID = -1;
32 |
33 | private final Abort apdu;
34 |
35 | public AbortAPDUException(Abort apdu) {
36 | super(apdu.toString());
37 | this.apdu = apdu;
38 | }
39 |
40 | public Abort getApdu() {
41 | return apdu;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/BACnetException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | public class BACnetException extends Exception {
29 | private static final long serialVersionUID = -1;
30 |
31 | public BACnetException() {
32 | super();
33 | }
34 |
35 | public BACnetException(String message, Throwable cause) {
36 | super(message, cause);
37 | }
38 |
39 | public BACnetException(String message) {
40 | super(message);
41 | }
42 |
43 | public BACnetException(Throwable cause) {
44 | super(cause);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/BACnetRejectException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.type.enumerated.RejectReason;
29 |
30 | public class BACnetRejectException extends BACnetException {
31 | private static final long serialVersionUID = -1;
32 |
33 | private final RejectReason rejectReason;
34 |
35 | public BACnetRejectException(RejectReason rejectReason) {
36 | this.rejectReason = rejectReason;
37 | }
38 |
39 | public RejectReason getRejectReason() {
40 | return rejectReason;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/BACnetRuntimeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | public class BACnetRuntimeException extends RuntimeException {
29 | private static final long serialVersionUID = -1;
30 |
31 | public BACnetRuntimeException() {
32 | super();
33 | }
34 |
35 | public BACnetRuntimeException(String message, Throwable cause) {
36 | super(message, cause);
37 | }
38 |
39 | public BACnetRuntimeException(String message) {
40 | super(message);
41 | }
42 |
43 | public BACnetRuntimeException(Throwable cause) {
44 | super(cause);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/BACnetServiceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.type.enumerated.ErrorClass;
29 | import com.serotonin.bacnet4j.type.enumerated.ErrorCode;
30 |
31 | public class BACnetServiceException extends Exception {
32 | private static final long serialVersionUID = -1;
33 |
34 | private final ErrorClass errorClass;
35 | private final ErrorCode errorCode;
36 |
37 | public BACnetServiceException(ErrorClass errorClass, ErrorCode errorCode) {
38 | this.errorClass = errorClass;
39 | this.errorCode = errorCode;
40 | }
41 |
42 | public BACnetServiceException(ErrorClass errorClass, ErrorCode errorCode, String message) {
43 | super(message);
44 | this.errorClass = errorClass;
45 | this.errorCode = errorCode;
46 | }
47 |
48 | public ErrorClass getErrorClass() {
49 | return errorClass;
50 | }
51 |
52 | public ErrorCode getErrorCode() {
53 | return errorCode;
54 | }
55 |
56 | public boolean equals(ErrorClass errorClass, ErrorCode errorCode) {
57 | return this.errorClass.equals(errorClass) && this.errorCode.equals(errorCode);
58 | }
59 |
60 | @Override
61 | public String getMessage() {
62 | String message = "class=" + errorClass + ", code=" + errorCode;
63 | String userDesc = super.getMessage();
64 | if (userDesc != null)
65 | message += ", message=" + userDesc;
66 | return message;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/BACnetTimeoutException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | public class BACnetTimeoutException extends BACnetException {
29 | private static final long serialVersionUID = -1;
30 |
31 | public BACnetTimeoutException() {
32 | super();
33 | }
34 |
35 | public BACnetTimeoutException(String message) {
36 | super(message);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/ConfirmedRequestParseException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | public class ConfirmedRequestParseException extends BACnetException {
29 | private static final long serialVersionUID = -1;
30 |
31 | private final int originalInvokeId;
32 |
33 | public ConfirmedRequestParseException(int originalInvokeId) {
34 | this.originalInvokeId = originalInvokeId;
35 | }
36 |
37 | public ConfirmedRequestParseException(int originalInvokeId, Throwable cause) {
38 | super(cause);
39 | this.originalInvokeId = originalInvokeId;
40 | }
41 |
42 | public int getOriginalInvokeId() {
43 | return originalInvokeId;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/ErrorAPDUException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.apdu.Error;
29 | import com.serotonin.bacnet4j.type.constructed.BACnetError;
30 |
31 | public class ErrorAPDUException extends BACnetException {
32 | private static final long serialVersionUID = -1;
33 |
34 | private final Error apdu;
35 |
36 | public ErrorAPDUException(Error apdu) {
37 | super(apdu.toString());
38 | this.apdu = apdu;
39 | }
40 |
41 | public Error getApdu() {
42 | return apdu;
43 | }
44 |
45 | public BACnetError getBACnetError() {
46 | return apdu.getError().getError();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/IllegalPduTypeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | public class IllegalPduTypeException extends BACnetRuntimeException {
29 | private static final long serialVersionUID = -1;
30 |
31 | public IllegalPduTypeException(String message) {
32 | super(message);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/NotImplementedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | public class NotImplementedException extends BACnetException {
29 | private static final long serialVersionUID = -1;
30 |
31 | public NotImplementedException() {
32 | super();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/PropertyValueException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.type.constructed.BACnetError;
29 |
30 | /**
31 | * @author Matthew Lohbihler
32 | */
33 | public class PropertyValueException extends Exception {
34 | private static final long serialVersionUID = 1L;
35 |
36 | private final BACnetError error;
37 |
38 | public PropertyValueException(BACnetError error) {
39 | this.error = error;
40 | }
41 |
42 | public BACnetError getError() {
43 | return error;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/ReflectionException.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.exception;
2 |
3 | public class ReflectionException extends BACnetException {
4 | private static final long serialVersionUID = 1L;
5 |
6 | public ReflectionException(Throwable cause) {
7 | super(cause);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/RejectAPDUException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.apdu.Reject;
29 |
30 | public class RejectAPDUException extends BACnetException {
31 | private static final long serialVersionUID = -1;
32 |
33 | private final Reject apdu;
34 |
35 | public RejectAPDUException(Reject apdu) {
36 | super(apdu.toString());
37 | this.apdu = apdu;
38 | }
39 |
40 | public Reject getApdu() {
41 | return apdu;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/exception/SegmentedMessageAbortedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.exception;
27 |
28 | import com.serotonin.bacnet4j.apdu.Abort;
29 |
30 | public class SegmentedMessageAbortedException extends BACnetException {
31 | private static final long serialVersionUID = -1;
32 |
33 | private final Abort abort;
34 |
35 | public SegmentedMessageAbortedException(Abort abort) {
36 | this.abort = abort;
37 | }
38 |
39 | public Abort getAbort() {
40 | return abort;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/IncomingRequestProcessor.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 |
6 | public class IncomingRequestProcessor {
7 | private static IncomingRequestProcessor ref = null;
8 | private final ExecutorService es;
9 | private IncomingRequestProcessor(){
10 | es = Executors.newCachedThreadPool();
11 | }
12 | public static IncomingRequestProcessor getIncomingRequestProcessor(){
13 | if(ref == null){
14 | ref = new IncomingRequestProcessor();
15 | }
16 | return ref;
17 | }
18 |
19 | public void submit(final IncomingRequestParser irp){
20 | es.submit(new Runnable(){
21 | @Override
22 | public void run() {
23 | irp.run();
24 | }});
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/MessageValidationAssertionException.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu;
2 |
3 | public class MessageValidationAssertionException extends Exception {
4 | private static final long serialVersionUID = -1;
5 |
6 | public MessageValidationAssertionException(String message) {
7 | super(message);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/NetworkIdentifier.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu;
2 |
3 | abstract public class NetworkIdentifier {
4 | // no op
5 | }
6 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/ip/InetAddrCache.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu.ip;
2 |
3 | import java.net.InetAddress;
4 | import java.net.InetSocketAddress;
5 | import java.net.UnknownHostException;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | public class InetAddrCache {
10 | private static final Map> socketCache = new HashMap>();
11 |
12 | public static InetSocketAddress get(String host, int port) {
13 | try {
14 | return get(InetAddress.getByName(host), port);
15 | }
16 | catch (UnknownHostException e) {
17 | throw new RuntimeException(e);
18 | }
19 | }
20 |
21 | /**
22 | * InetSocketAddress cache, because instantiation can take up to 10 seconds on Android.
23 | * ??? Should there be a means of purging this?
24 | *
25 | * @param addr
26 | * @param port
27 | * @return
28 | */
29 | public static InetSocketAddress get(InetAddress addr, int port) {
30 | Map ports = socketCache.get(addr);
31 | if (ports == null) {
32 | synchronized (socketCache) {
33 | ports = socketCache.get(addr);
34 | if (ports == null) {
35 | ports = new HashMap();
36 | socketCache.put(addr, ports);
37 | }
38 | }
39 | }
40 |
41 | InetSocketAddress socket = ports.get(port);
42 | if (socket == null) {
43 | synchronized (ports) {
44 | socket = ports.get(port);
45 | if (socket == null) {
46 | socket = new InetSocketAddress(addr, port);
47 | ports.put(port, socket);
48 | }
49 | }
50 | }
51 |
52 | return socket;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/ip/IpNetworkIdentifier.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu.ip;
2 |
3 | import com.serotonin.bacnet4j.npdu.NetworkIdentifier;
4 |
5 | public class IpNetworkIdentifier extends NetworkIdentifier {
6 | private final int port;
7 | private final String localBindAddress;
8 |
9 | public IpNetworkIdentifier(int port, String localBindAddress) {
10 | this.port = port;
11 | this.localBindAddress = localBindAddress;
12 | }
13 |
14 | public int getPort() {
15 | return port;
16 | }
17 |
18 | public String getLocalBindAddress() {
19 | return localBindAddress;
20 | }
21 |
22 | @Override
23 | public int hashCode() {
24 | final int prime = 31;
25 | int result = 1;
26 | result = prime * result + ((localBindAddress == null) ? 0 : localBindAddress.hashCode());
27 | result = prime * result + port;
28 | return result;
29 | }
30 |
31 | @Override
32 | public boolean equals(Object obj) {
33 | if (this == obj)
34 | return true;
35 | if (obj == null)
36 | return false;
37 | if (getClass() != obj.getClass())
38 | return false;
39 | IpNetworkIdentifier other = (IpNetworkIdentifier) obj;
40 | if (localBindAddress == null) {
41 | if (other.localBindAddress != null)
42 | return false;
43 | }
44 | else if (!localBindAddress.equals(other.localBindAddress))
45 | return false;
46 | if (port != other.port)
47 | return false;
48 | return true;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/ip/SegmentWindow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.npdu.ip;
27 |
28 | import com.serotonin.bacnet4j.apdu.Segmentable;
29 |
30 | public class SegmentWindow {
31 | private int firstSequenceId;
32 | private final Segmentable[] segments;
33 |
34 | public SegmentWindow(int windowSize, int firstSequenceId) {
35 | this.firstSequenceId = firstSequenceId;
36 | segments = new Segmentable[windowSize];
37 | }
38 |
39 | public Segmentable getSegment(int sequenceId) {
40 | return segments[sequenceId - firstSequenceId];
41 | }
42 |
43 | public void setSegment(Segmentable segment) {
44 | segments[segment.getSequenceNumber() - firstSequenceId] = segment;
45 | }
46 |
47 | public boolean fitsInWindow(Segmentable segment) {
48 | int index = segment.getSequenceNumber() - firstSequenceId;
49 | if (index < 0 || index >= segments.length)
50 | return false;
51 | return true;
52 | }
53 |
54 | public boolean isEmpty() {
55 | for (int i = 0; i < segments.length; i++) {
56 | if (segments[i] != null)
57 | return false;
58 | }
59 | return true;
60 | }
61 |
62 | public boolean isFull() {
63 | for (int i = 0; i < segments.length; i++) {
64 | if (segments[i] == null)
65 | return false;
66 | }
67 | return true;
68 | }
69 |
70 | public void clear(int firstSequenceId) {
71 | this.firstSequenceId = firstSequenceId;
72 | for (int i = 0; i < segments.length; i++)
73 | segments[i] = null;
74 | }
75 |
76 | public boolean isLastSegment(int sequenceId) {
77 | return sequenceId == segments.length + firstSequenceId - 1;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/mstp/DataCRC.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu.mstp;
2 |
3 | public class DataCRC {
4 | public static final int CHECK_VALUE = 0xF0B8;
5 | private int value = 0xffff;
6 |
7 | public void reset() {
8 | value = 0xffff;
9 | }
10 |
11 | public void accumulate(int data) {
12 | value = calcDataCRC(data, value);
13 | }
14 |
15 | public void accumulate(byte data) {
16 | accumulate(data & 0xFF);
17 | }
18 |
19 | public boolean isOk() {
20 | return value == CHECK_VALUE;
21 | }
22 |
23 | public int getCrc(Frame frame) {
24 | reset();
25 | for (byte b : frame.getData())
26 | accumulate(b);
27 | return onesComplement(value);
28 | }
29 |
30 | private static int calcDataCRC(int dataValue, int crcValue) {
31 | int crcLow = (crcValue & 0xff) ^ dataValue; /* XOR C7..C0 with D7..D0 */
32 | /* Exclusive OR the terms in the table (top down) */
33 | int crc = (crcValue >> 8) ^ (crcLow << 8) ^ (crcLow << 3) ^ (crcLow << 12) ^ (crcLow >> 4) ^ (crcLow & 0x0f)
34 | ^ ((crcLow & 0x0f) << 7);
35 | return crc & 0xffff;
36 | }
37 |
38 | private static int onesComplement(int i) {
39 | return (~i) & 0xffff;
40 | }
41 |
42 | public static void main(String[] args) {
43 | // DataCRC crc = new DataCRC();
44 | // crc.accumulate(0x01);
45 | // crc.accumulate(0x22);
46 | // crc.accumulate(0x33);
47 | // System.out.println(Integer.toString(crc.close(), 16));
48 |
49 | DataCRC crc = new DataCRC();
50 | System.out.println(Integer.toString(crc.getCrc(new Frame(FrameType.bacnetDataNotExpectingReply, (byte) 0xff,
51 | (byte) 8, new byte[] { 0x1, 0x20, (byte) 0xff, (byte) 0xfc, (byte) 0xfe, 0x20, (byte) 0xa0,
52 | (byte) 0xe7, (byte) 0x91, (byte) 0xf0, 0x3, 0x22, 0x1, 0x15, 0x2b, (byte) 0xf9, (byte) 0xff,
53 | 0x55, (byte) 0xff, 0x0, 0x4 })), 16));
54 | // crc.accumulate(0xb8);
55 | // crc.accumulate(0x96);
56 | System.out.println(Integer.toString(crc.value, 16));
57 |
58 | // crc.accumulate(0x8);
59 | // crc.accumulate(0x0);
60 | // System.out.println(Integer.toString(crc.getValue(), 16));
61 |
62 | //[55,ff,6,ff,8,0,15,da,1,20,ff,fc,fe,20,a0,e7,91,f0,3,22,1,15,2b,f9,ff,55,ff,0,4,8,0,0,14]
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/mstp/FrameResponseListener.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu.mstp;
2 |
3 | public interface FrameResponseListener {
4 | void response(Frame frame);
5 |
6 | void timeout();
7 | }
8 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/mstp/FrameType.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu.mstp;
2 |
3 | import org.apache.commons.lang3.ArrayUtils;
4 |
5 | /**
6 | * Using a different convention for instance naming here to see how it feels.
7 | */
8 | public enum FrameType {
9 | token(0), //
10 | pollForMaster(1), //
11 | replyToPollForMaster(2), //
12 | testRequest(3), //
13 | testResponse(4), //
14 | bacnetDataExpectingReply(5), //
15 | bacnetDataNotExpectingReply(6), //
16 | replyPostponed(7), //
17 | ;
18 |
19 | public final byte id;
20 |
21 | private FrameType(int id) {
22 | this.id = (byte) id;
23 | }
24 |
25 | public static FrameType forId(byte b) {
26 | for (FrameType e : values()) {
27 | if (e.id == b)
28 | return e;
29 | }
30 | return null;
31 | }
32 |
33 | public boolean oneOf(FrameType... types) {
34 | return ArrayUtils.contains(types, this);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/npdu/mstp/MstpNetworkIdentifier.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.npdu.mstp;
2 |
3 | import com.serotonin.bacnet4j.npdu.NetworkIdentifier;
4 |
5 | public class MstpNetworkIdentifier extends NetworkIdentifier {
6 | private final String commPortId;
7 |
8 | public MstpNetworkIdentifier(String commPortId) {
9 | this.commPortId = commPortId;
10 | }
11 |
12 | public String getCommPortId() {
13 | return commPortId;
14 | }
15 |
16 | @Override
17 | public int hashCode() {
18 | final int prime = 31;
19 | int result = 1;
20 | result = prime * result + ((commPortId == null) ? 0 : commPortId.hashCode());
21 | return result;
22 | }
23 |
24 | @Override
25 | public boolean equals(Object obj) {
26 | if (this == obj)
27 | return true;
28 | if (obj == null)
29 | return false;
30 | if (getClass() != obj.getClass())
31 | return false;
32 | MstpNetworkIdentifier other = (MstpNetworkIdentifier) obj;
33 | if (commPortId == null) {
34 | if (other.commPortId != null)
35 | return false;
36 | }
37 | else if (!commPortId.equals(other.commPortId))
38 | return false;
39 | return true;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/obj/ObjectPropertyIdentifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.obj;
27 |
28 | import com.serotonin.bacnet4j.type.enumerated.ObjectType;
29 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
30 |
31 | public class ObjectPropertyIdentifier {
32 | private final ObjectType objectType;
33 | private final PropertyIdentifier propertyIdentifier;
34 |
35 | public ObjectPropertyIdentifier(ObjectType objectType, PropertyIdentifier propertyIdentifier) {
36 | this.objectType = objectType;
37 | this.propertyIdentifier = propertyIdentifier;
38 | }
39 |
40 | @Override
41 | public int hashCode() {
42 | final int PRIME = 31;
43 | int result = 1;
44 | result = PRIME * result + ((objectType == null) ? 0 : objectType.hashCode());
45 | result = PRIME * result + ((propertyIdentifier == null) ? 0 : propertyIdentifier.hashCode());
46 | return result;
47 | }
48 |
49 | @Override
50 | public boolean equals(Object obj) {
51 | if (this == obj)
52 | return true;
53 | if (obj == null)
54 | return false;
55 | if (getClass() != obj.getClass())
56 | return false;
57 | final ObjectPropertyIdentifier other = (ObjectPropertyIdentifier) obj;
58 | if (objectType == null) {
59 | if (other.objectType != null)
60 | return false;
61 | }
62 | else if (!objectType.equals(other.objectType))
63 | return false;
64 | if (propertyIdentifier == null) {
65 | if (other.propertyIdentifier != null)
66 | return false;
67 | }
68 | else if (!propertyIdentifier.equals(other.propertyIdentifier))
69 | return false;
70 | return true;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/service/Service.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.service;
27 |
28 | import com.serotonin.bacnet4j.type.constructed.BaseType;
29 |
30 | abstract public class Service extends BaseType {
31 | private static final long serialVersionUID = 6310521953905282247L;
32 |
33 | abstract public byte getChoiceId();
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/service/VendorServiceKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.service;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
29 |
30 | public class VendorServiceKey {
31 | private final UnsignedInteger vendorId;
32 | private final UnsignedInteger serviceNumber;
33 |
34 | public VendorServiceKey(int vendorId, int serviceNumber) {
35 | this(new UnsignedInteger(vendorId), new UnsignedInteger(serviceNumber));
36 | }
37 |
38 | public VendorServiceKey(UnsignedInteger vendorId, UnsignedInteger serviceNumber) {
39 | this.vendorId = vendorId;
40 | this.serviceNumber = serviceNumber;
41 | }
42 |
43 | @Override
44 | public int hashCode() {
45 | final int PRIME = 31;
46 | int result = 1;
47 | result = PRIME * result + ((serviceNumber == null) ? 0 : serviceNumber.hashCode());
48 | result = PRIME * result + ((vendorId == null) ? 0 : vendorId.hashCode());
49 | return result;
50 | }
51 |
52 | @Override
53 | public boolean equals(Object obj) {
54 | if (this == obj)
55 | return true;
56 | if (obj == null)
57 | return false;
58 | if (getClass() != obj.getClass())
59 | return false;
60 | final VendorServiceKey other = (VendorServiceKey) obj;
61 | if (serviceNumber == null) {
62 | if (other.serviceNumber != null)
63 | return false;
64 | }
65 | else if (!serviceNumber.equals(other.serviceNumber))
66 | return false;
67 | if (vendorId == null) {
68 | if (other.vendorId != null)
69 | return false;
70 | }
71 | else if (!vendorId.equals(other.vendorId))
72 | return false;
73 | return true;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/service/confirmed/GetAlarmSummaryRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.service.confirmed;
27 |
28 | import com.serotonin.bacnet4j.LocalDevice;
29 | import com.serotonin.bacnet4j.exception.BACnetException;
30 | import com.serotonin.bacnet4j.exception.NotImplementedException;
31 | import com.serotonin.bacnet4j.service.acknowledgement.AcknowledgementService;
32 | import com.serotonin.bacnet4j.type.constructed.Address;
33 | import com.serotonin.bacnet4j.type.primitive.OctetString;
34 | import org.free.bacnet4j.util.ByteQueue;
35 |
36 | public class GetAlarmSummaryRequest extends ConfirmedRequestService {
37 | private static final long serialVersionUID = 7026623260581737268L;
38 | public static final byte TYPE_ID = 3;
39 |
40 | @Override
41 | public byte getChoiceId() {
42 | return TYPE_ID;
43 | }
44 |
45 | public GetAlarmSummaryRequest() {
46 | // no op
47 | }
48 |
49 | @Override
50 | public AcknowledgementService handle(LocalDevice localDevice, Address from, OctetString linkService)
51 | throws BACnetException {
52 | throw new NotImplementedException();
53 | }
54 |
55 | @Override
56 | public void write(ByteQueue queue) {
57 | // no op
58 | }
59 |
60 | GetAlarmSummaryRequest(ByteQueue queue) {
61 | // no op
62 | }
63 |
64 | @Override
65 | public boolean equals(Object obj) {
66 | if (this == obj)
67 | return true;
68 | if (obj == null)
69 | return false;
70 | if (getClass() != obj.getClass())
71 | return false;
72 | return true;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/transport/WaitingRoomKey.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.transport;
2 |
3 | import com.serotonin.bacnet4j.type.constructed.Address;
4 | import com.serotonin.bacnet4j.type.primitive.OctetString;
5 |
6 | /**
7 | * The waiting room key is the means by which an acknowledged request is matched with the acknowledgement.
8 | *
9 | * @author Matthew
10 | */
11 | public class WaitingRoomKey {
12 | private final Address address;
13 | private final OctetString linkService;
14 | private final byte invokeId;
15 | private final boolean fromServer;
16 |
17 | public WaitingRoomKey(Address address, OctetString linkService, byte invokeId, boolean fromServer) {
18 | this.address = address;
19 | this.linkService = linkService;
20 | this.invokeId = invokeId;
21 | this.fromServer = fromServer;
22 | }
23 |
24 | public Address getAddress() {
25 | return address;
26 | }
27 |
28 | public OctetString getLinkService() {
29 | return linkService;
30 | }
31 |
32 | public byte getInvokeId() {
33 | return invokeId;
34 | }
35 |
36 | public boolean isFromServer() {
37 | return fromServer;
38 | }
39 |
40 | @Override
41 | public String toString() {
42 | return "Key(address=" + address + ", linkService=" + linkService + ", invokeId=" + invokeId + ", fromServer="
43 | + fromServer + ")";
44 | }
45 |
46 | /*
47 | * (non-Javadoc)
48 | *
49 | * @see java.lang.Object#hashCode()
50 | */
51 | @Override
52 | public int hashCode() {
53 | final int prime = 31;
54 | int result = 1;
55 | result = prime * result + ((address == null) ? 0 : address.hashCode());
56 | result = prime * result + (fromServer ? 1231 : 1237);
57 | result = prime * result + invokeId;
58 | result = prime * result + ((linkService == null) ? 0 : linkService.hashCode());
59 | return result;
60 | }
61 |
62 | /*
63 | * (non-Javadoc)
64 | *
65 | * @see java.lang.Object#equals(java.lang.Object)
66 | */
67 | @Override
68 | public boolean equals(Object obj) {
69 | if (this == obj)
70 | return true;
71 | if (obj == null)
72 | return false;
73 | if (getClass() != obj.getClass())
74 | return false;
75 | WaitingRoomKey other = (WaitingRoomKey) obj;
76 | if (address == null) {
77 | if (other.address != null)
78 | return false;
79 | }
80 | else if (!address.equals(other.address))
81 | return false;
82 | if (fromServer != other.fromServer)
83 | return false;
84 | if (invokeId != other.invokeId)
85 | return false;
86 | if (linkService == null) {
87 | if (other.linkService != null)
88 | return false;
89 | }
90 | else if (!linkService.equals(other.linkService))
91 | return false;
92 | return true;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/TagData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type;
27 |
28 | public class TagData {
29 | public int tagNumber;
30 | public boolean contextSpecific;
31 | public long length;
32 | public int tagLength;
33 |
34 | public int getTotalLength() {
35 | return (int) (length + tagLength);
36 | }
37 |
38 | public boolean isStartTag() {
39 | return contextSpecific && ((length & 6) == 6);
40 | }
41 |
42 | public boolean isStartTag(int contextId) {
43 | return isStartTag() && tagNumber == contextId;
44 | }
45 |
46 | public boolean isEndTag() {
47 | return contextSpecific && ((length & 7) == 7);
48 | }
49 |
50 | public boolean isEndTag(int contextId) {
51 | return isEndTag() && tagNumber == contextId;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/ThreadLocalObjectTypeStack.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type;
27 |
28 | import java.util.ArrayList;
29 | import java.util.List;
30 |
31 | import com.serotonin.bacnet4j.type.enumerated.ObjectType;
32 |
33 | public class ThreadLocalObjectTypeStack {
34 | private static ThreadLocal> objType = new ThreadLocal>();
35 |
36 | public static void set(ObjectType objectType) {
37 | List stack = objType.get();
38 |
39 | if (stack == null) {
40 | stack = new ArrayList();
41 | objType.set(stack);
42 | }
43 |
44 | stack.add(objectType);
45 | }
46 |
47 | public static ObjectType get() {
48 | List stack = objType.get();
49 | if (stack == null)
50 | return null;
51 | return stack.get(stack.size() - 1);
52 | }
53 |
54 | public static void remove() {
55 | List stack = objType.get();
56 | if (stack == null)
57 | return;
58 |
59 | if (stack.size() <= 1)
60 | objType.remove();
61 | else
62 | stack.remove(stack.size() - 1);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/ActionList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.exception.BACnetException;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class ActionList extends BaseType {
32 | private static final long serialVersionUID = 2923869954790260717L;
33 | private final SequenceOf action;
34 |
35 | public ActionList(SequenceOf action) {
36 | this.action = action;
37 | }
38 |
39 | @Override
40 | public void write(ByteQueue queue) {
41 | write(queue, action, 0);
42 | }
43 |
44 | public ActionList(ByteQueue queue) throws BACnetException {
45 | action = readSequenceOf(queue, ActionCommand.class, 0);
46 | }
47 |
48 | public SequenceOf getAction() {
49 | return action;
50 | }
51 |
52 | @Override
53 | public int hashCode() {
54 | final int prime = 31;
55 | int result = 1;
56 | result = prime * result + ((action == null) ? 0 : action.hashCode());
57 | return result;
58 | }
59 |
60 | @Override
61 | public boolean equals(Object obj) {
62 | if (this == obj)
63 | return true;
64 | if (obj == null)
65 | return false;
66 | if (getClass() != obj.getClass())
67 | return false;
68 | final ActionList other = (ActionList) obj;
69 | if (action == null) {
70 | if (other.action != null)
71 | return false;
72 | }
73 | else if (!action.equals(other.action))
74 | return false;
75 | return true;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/BaseType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.type.Encodable;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | abstract public class BaseType extends Encodable {
32 | private static final long serialVersionUID = -2536344211247711774L;
33 |
34 | @Override
35 | public void write(ByteQueue queue, int contextId) {
36 | // Write a start tag
37 | writeContextTag(queue, contextId, true);
38 | write(queue);
39 | // Write an end tag
40 | writeContextTag(queue, contextId, false);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/DailySchedule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.exception.BACnetException;
29 | import org.free.bacnet4j.util.ByteQueue;
30 | /**
31 | * ASHRAE Standard 135-2012 Clause 21 p. 667
32 | * BACnetDailySchedule ::= SEQUENCE {
33 | * day-schedule [0] SEQUENCE OF BACnetTimeValue }
34 | */
35 | public class DailySchedule extends BaseType {
36 | private static final long serialVersionUID = -8539541069909649459L;
37 | private final SequenceOf daySchedule;
38 |
39 | public DailySchedule(SequenceOf daySchedule) {
40 | this.daySchedule = daySchedule;
41 | }
42 |
43 | public SequenceOf getDaySchedule() {
44 | return daySchedule;
45 | }
46 |
47 | @Override
48 | public void write(ByteQueue queue) {
49 | write(queue, daySchedule, 0);
50 | }
51 |
52 | public DailySchedule(ByteQueue queue) throws BACnetException {
53 | daySchedule = readSequenceOf(queue, TimeValue.class, 0);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/EventTransitionBits.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.type.enumerated.EventState;
29 | import com.serotonin.bacnet4j.type.primitive.BitString;
30 | import org.free.bacnet4j.util.ByteQueue;
31 |
32 | public class EventTransitionBits extends BitString {
33 | private static final long serialVersionUID = 7904969709288399573L;
34 |
35 | public EventTransitionBits(boolean toOffnormal, boolean toFault, boolean toNormal) {
36 | super(new boolean[] { toOffnormal, toFault, toNormal });
37 | }
38 |
39 | public EventTransitionBits(ByteQueue queue) {
40 | super(queue);
41 | }
42 |
43 | public boolean isToOffnormal() {
44 | return getValue()[0];
45 | }
46 |
47 | public boolean isToFault() {
48 | return getValue()[1];
49 | }
50 |
51 | public boolean isToNormal() {
52 | return getValue()[2];
53 | }
54 |
55 | public boolean contains(EventState toState) {
56 | if (toState.equals(EventState.normal) && isToNormal())
57 | return true;
58 |
59 | if (toState.equals(EventState.fault) && isToFault())
60 | return true;
61 |
62 | // All other event states are considered off-normal
63 | return isToOffnormal();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/LimitEnable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.BitString;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class LimitEnable extends BitString {
32 | private static final long serialVersionUID = -8754983228968085042L;
33 |
34 | public LimitEnable(boolean lowLimitEnable, boolean highLimitEnable) {
35 | super(new boolean[] { lowLimitEnable, highLimitEnable });
36 | }
37 |
38 | public LimitEnable(ByteQueue queue) {
39 | super(queue);
40 | }
41 |
42 | public boolean isLowLimitEnable() {
43 | return getValue()[0];
44 | }
45 |
46 | public boolean isHighLimitEnable() {
47 | return getValue()[1];
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/LogStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.BitString;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class LogStatus extends BitString {
32 | private static final long serialVersionUID = 2623926749486653669L;
33 |
34 | public LogStatus(boolean logDisabled, boolean bufferPurged) {
35 | super(new boolean[] { logDisabled, bufferPurged });
36 | }
37 |
38 | public LogStatus(ByteQueue queue) {
39 | super(queue);
40 | }
41 |
42 | public boolean isLogDisabled() {
43 | return getValue()[0];
44 | }
45 |
46 | public boolean isBufferPurged() {
47 | return getValue()[1];
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/ResultFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.BitString;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class ResultFlags extends BitString {
32 | private static final long serialVersionUID = 7657134249555371620L;
33 |
34 | public ResultFlags(boolean firstItem, boolean lastItem, boolean moreItems) {
35 | super(new boolean[] { firstItem, lastItem, moreItems });
36 | }
37 |
38 | public ResultFlags(ByteQueue queue) {
39 | super(queue);
40 | }
41 |
42 | public boolean isFirstItem() {
43 | return getValue()[0];
44 | }
45 |
46 | public boolean isLastItem() {
47 | return getValue()[1];
48 | }
49 |
50 | public boolean isMoreItems() {
51 | return getValue()[2];
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/constructed/StatusFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.constructed;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.BitString;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class StatusFlags extends BitString {
32 | private static final long serialVersionUID = 2553458399968003127L;
33 |
34 | public StatusFlags(boolean inAlarm, boolean fault, boolean overridden, boolean outOfService) {
35 | super(new boolean[] { inAlarm, fault, overridden, outOfService });
36 | }
37 |
38 | public StatusFlags(ByteQueue queue) {
39 | super(queue);
40 | }
41 |
42 | public boolean isInAlarm() {
43 | return getValue()[0];
44 | }
45 |
46 | public boolean isFault() {
47 | return getValue()[1];
48 | }
49 |
50 | public boolean isOverridden() {
51 | return getValue()[2];
52 | }
53 |
54 | public boolean isOutOfService() {
55 | return getValue()[3];
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/Action.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class Action extends Enumerated {
32 | private static final long serialVersionUID = -6669625812130523631L;
33 | public static final Action direct = new Action(0);
34 | public static final Action reverse = new Action(1);
35 |
36 | public static final Action[] ALL = { direct, reverse, };
37 |
38 | public Action(int value) {
39 | super(value);
40 | }
41 |
42 | public Action(ByteQueue queue) {
43 | super(queue);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/BackupState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class BackupState extends Enumerated {
32 | private static final long serialVersionUID = -4811672152182130623L;
33 | public static final BackupState idle = new BackupState(0);
34 | public static final BackupState preparingForBackup = new BackupState(1);
35 | public static final BackupState preparingForRestore = new BackupState(2);
36 | public static final BackupState performingABackup = new BackupState(3);
37 | public static final BackupState performingARestore = new BackupState(4);
38 | public static final BackupState backupFailure = new BackupState(5);
39 | public static final BackupState restoreFailure = new BackupState(6);
40 |
41 | public static final BackupState[] ALL = { idle, preparingForBackup, preparingForRestore, performingABackup,
42 | performingARestore, backupFailure, restoreFailure, };
43 |
44 | public BackupState(int value) {
45 | super(value);
46 | }
47 |
48 | public BackupState(ByteQueue queue) {
49 | super(queue);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/BinaryPV.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class BinaryPV extends Enumerated {
32 | private static final long serialVersionUID = -22603618114789798L;
33 | public static final BinaryPV inactive = new BinaryPV(0);
34 | public static final BinaryPV active = new BinaryPV(1);
35 |
36 | public static final BinaryPV[] ALL = { inactive, active, };
37 |
38 | public BinaryPV(int value) {
39 | super(value);
40 | }
41 |
42 | public BinaryPV(ByteQueue queue) {
43 | super(queue);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/DeviceStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class DeviceStatus extends Enumerated {
32 | private static final long serialVersionUID = -111489048861220863L;
33 | public static final DeviceStatus operational = new DeviceStatus(0);
34 | public static final DeviceStatus operationalReadOnly = new DeviceStatus(1);
35 | public static final DeviceStatus downloadRequired = new DeviceStatus(2);
36 | public static final DeviceStatus downloadInProgress = new DeviceStatus(3);
37 | public static final DeviceStatus nonOperational = new DeviceStatus(4);
38 | public static final DeviceStatus backupInProgress = new DeviceStatus(5);
39 |
40 | public static final DeviceStatus[] ALL = { operational, operationalReadOnly, downloadRequired, downloadInProgress,
41 | nonOperational, backupInProgress, };
42 |
43 | public DeviceStatus(int value) {
44 | super(value);
45 | }
46 |
47 | public DeviceStatus(ByteQueue queue) {
48 | super(queue);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/DoorAlarmState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class DoorAlarmState extends Enumerated {
35 | private static final long serialVersionUID = -4016268027739544828L;
36 | public static final DoorAlarmState normal = new DoorAlarmState(0);
37 | public static final DoorAlarmState alarm = new DoorAlarmState(1);
38 | public static final DoorAlarmState doorOpenTooLong = new DoorAlarmState(2);
39 | public static final DoorAlarmState forcedOpen = new DoorAlarmState(3);
40 | public static final DoorAlarmState tamper = new DoorAlarmState(4);
41 | public static final DoorAlarmState doorFault = new DoorAlarmState(5);
42 | public static final DoorAlarmState lockDown = new DoorAlarmState(6);
43 | public static final DoorAlarmState freeAccess = new DoorAlarmState(7);
44 | public static final DoorAlarmState egressOpen = new DoorAlarmState(8);
45 |
46 | public static final DoorAlarmState[] ALL = { normal, alarm, doorOpenTooLong, forcedOpen, tamper, doorFault,
47 | lockDown, freeAccess, egressOpen, };
48 |
49 | public DoorAlarmState(int value) {
50 | super(value);
51 | }
52 |
53 | public DoorAlarmState(ByteQueue queue) {
54 | super(queue);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/DoorSecuredStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class DoorSecuredStatus extends Enumerated {
35 | private static final long serialVersionUID = 7337105893343734773L;
36 | public static final DoorSecuredStatus secured = new DoorSecuredStatus(0);
37 | public static final DoorSecuredStatus unsecured = new DoorSecuredStatus(1);
38 | public static final DoorSecuredStatus unknown = new DoorSecuredStatus(2);
39 |
40 | public static final DoorSecuredStatus[] ALL = { secured, unsecured, unknown, };
41 |
42 | public DoorSecuredStatus(int value) {
43 | super(value);
44 | }
45 |
46 | public DoorSecuredStatus(ByteQueue queue) {
47 | super(queue);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/DoorStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class DoorStatus extends Enumerated {
35 | private static final long serialVersionUID = -2813060268315235754L;
36 | public static final DoorStatus closed = new DoorStatus(0);
37 | public static final DoorStatus open = new DoorStatus(1);
38 | public static final DoorStatus unknown = new DoorStatus(2);
39 |
40 | public static final DoorStatus[] ALL = { closed, open, unknown, };
41 |
42 | public DoorStatus(int value) {
43 | super(value);
44 | }
45 |
46 | public DoorStatus(ByteQueue queue) {
47 | super(queue);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/DoorValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class DoorValue extends Enumerated {
35 | private static final long serialVersionUID = -2200245400075159155L;
36 | public static final DoorValue lock = new DoorValue(0);
37 | public static final DoorValue unlock = new DoorValue(1);
38 | public static final DoorValue pulseUnlock = new DoorValue(2);
39 | public static final DoorValue extendedPulseUnlock = new DoorValue(3);
40 |
41 | public static final DoorValue[] ALL = { lock, unlock, pulseUnlock, extendedPulseUnlock, };
42 |
43 | public DoorValue(int value) {
44 | super(value);
45 | }
46 |
47 | public DoorValue(ByteQueue queue) {
48 | super(queue);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/EventState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class EventState extends Enumerated {
32 | private static final long serialVersionUID = -8567972022145562375L;
33 | public static final EventState normal = new EventState(0);
34 | public static final EventState fault = new EventState(1);
35 | public static final EventState offnormal = new EventState(2);
36 | public static final EventState highLimit = new EventState(3);
37 | public static final EventState lowLimit = new EventState(4);
38 | public static final EventState lifeSafetyAlarm = new EventState(5);
39 |
40 | public static final EventState[] ALL = { normal, fault, offnormal, highLimit, lowLimit, lifeSafetyAlarm, };
41 |
42 | public EventState(int value) {
43 | super(value);
44 | }
45 |
46 | public EventState(ByteQueue queue) {
47 | super(queue);
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | if (intValue() == 0)
53 | return "normal";
54 | if (intValue() == 1)
55 | return "fault";
56 | if (intValue() == 2)
57 | return "off normal";
58 | if (intValue() == 3)
59 | return "high limit";
60 | if (intValue() == 4)
61 | return "low limit";
62 | if (intValue() == 5)
63 | return "life safety alarm";
64 | return "Unknown";
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/FileAccessMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class FileAccessMethod extends Enumerated {
32 | private static final long serialVersionUID = -2447330212564862936L;
33 | public static final FileAccessMethod recordAccess = new FileAccessMethod(0);
34 | public static final FileAccessMethod streamAccess = new FileAccessMethod(1);
35 |
36 | public static final FileAccessMethod[] ALL = { recordAccess, streamAccess, };
37 |
38 | public FileAccessMethod(int value) {
39 | super(value);
40 | }
41 |
42 | public FileAccessMethod(ByteQueue queue) {
43 | super(queue);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/LifeSafetyOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class LifeSafetyOperation extends Enumerated {
32 | private static final long serialVersionUID = -8453182789389518551L;
33 | public static final LifeSafetyOperation none = new LifeSafetyOperation(0);
34 | public static final LifeSafetyOperation silence = new LifeSafetyOperation(1);
35 | public static final LifeSafetyOperation silenceAudible = new LifeSafetyOperation(2);
36 | public static final LifeSafetyOperation silenceVisual = new LifeSafetyOperation(3);
37 | public static final LifeSafetyOperation reset = new LifeSafetyOperation(4);
38 | public static final LifeSafetyOperation resetAlarm = new LifeSafetyOperation(5);
39 | public static final LifeSafetyOperation resetFault = new LifeSafetyOperation(6);
40 | public static final LifeSafetyOperation unsilence = new LifeSafetyOperation(7);
41 | public static final LifeSafetyOperation unsilenceAudible = new LifeSafetyOperation(8);
42 | public static final LifeSafetyOperation unsilenceVisual = new LifeSafetyOperation(9);
43 |
44 | public static final LifeSafetyOperation[] ALL = { none, silence, silenceAudible, silenceVisual, reset, resetAlarm,
45 | resetFault, unsilence, unsilenceAudible, unsilenceVisual, };
46 |
47 | public LifeSafetyOperation(int value) {
48 | super(value);
49 | }
50 |
51 | public LifeSafetyOperation(ByteQueue queue) {
52 | super(queue);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/LockStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class LockStatus extends Enumerated {
35 | private static final long serialVersionUID = -1433958074950622510L;
36 | public static final LockStatus locked = new LockStatus(0);
37 | public static final LockStatus unlocked = new LockStatus(1);
38 | public static final LockStatus fault = new LockStatus(2);
39 | public static final LockStatus unknown = new LockStatus(3);
40 |
41 | public static final LockStatus[] ALL = { locked, unlocked, fault, unknown, };
42 |
43 | public LockStatus(int value) {
44 | super(value);
45 | }
46 |
47 | public LockStatus(ByteQueue queue) {
48 | super(queue);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/LoggingType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class LoggingType extends Enumerated {
32 | private static final long serialVersionUID = 7142631539010266808L;
33 | public static final LoggingType polled = new LoggingType(0);
34 | public static final LoggingType cov = new LoggingType(1);
35 | public static final LoggingType triggered = new LoggingType(2);
36 |
37 | public static final LoggingType[] ALL = { polled, cov, triggered, };
38 |
39 | public LoggingType(int value) {
40 | super(value);
41 | }
42 |
43 | public LoggingType(ByteQueue queue) {
44 | super(queue);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/Maintenance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class Maintenance extends Enumerated {
32 | private static final long serialVersionUID = -8105102280345072070L;
33 | public static final Maintenance none = new Maintenance(0);
34 | public static final Maintenance periodicTest = new Maintenance(1);
35 | public static final Maintenance needServiceOperational = new Maintenance(2);
36 | public static final Maintenance needServiceInoperative = new Maintenance(3);
37 |
38 | public static final Maintenance[] ALL = { none, periodicTest, needServiceOperational, needServiceInoperative, };
39 |
40 | public Maintenance(int value) {
41 | super(value);
42 | }
43 |
44 | public Maintenance(ByteQueue queue) {
45 | super(queue);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/MessagePriority.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class MessagePriority extends Enumerated {
32 | private static final long serialVersionUID = 2123880793993301090L;
33 | public static final MessagePriority normal = new MessagePriority(0);
34 | public static final MessagePriority urgent = new MessagePriority(1);
35 |
36 | public static final MessagePriority[] ALL = { normal, urgent, };
37 |
38 | public MessagePriority(int value) {
39 | super(value);
40 | }
41 |
42 | public MessagePriority(ByteQueue queue) {
43 | super(queue);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/NodeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class NodeType extends Enumerated {
35 | private static final long serialVersionUID = -1462203629019212150L;
36 | public static final NodeType unknown = new NodeType(0);
37 | public static final NodeType system = new NodeType(1);
38 | public static final NodeType network = new NodeType(2);
39 | public static final NodeType device = new NodeType(3);
40 | public static final NodeType organizational = new NodeType(4);
41 | public static final NodeType area = new NodeType(5);
42 | public static final NodeType equipment = new NodeType(6);
43 | public static final NodeType point = new NodeType(7);
44 | public static final NodeType collection = new NodeType(8);
45 | public static final NodeType property = new NodeType(9);
46 | public static final NodeType functional = new NodeType(10);
47 | public static final NodeType other = new NodeType(11);
48 |
49 | public static final NodeType[] ALL = { unknown, system, network, device, organizational, area, equipment, point,
50 | collection, property, functional, other, };
51 |
52 | public NodeType(int value) {
53 | super(value);
54 | }
55 |
56 | public NodeType(ByteQueue queue) {
57 | super(queue);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/NotifyType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class NotifyType extends Enumerated {
32 | private static final long serialVersionUID = 3980483915280625804L;
33 | public static final NotifyType alarm = new NotifyType(0);
34 | public static final NotifyType event = new NotifyType(1);
35 | public static final NotifyType ackNotification = new NotifyType(2);
36 |
37 | public static final NotifyType[] ALL = { alarm, event, ackNotification, };
38 |
39 | public NotifyType(int value) {
40 | super(value);
41 | }
42 |
43 | public NotifyType(ByteQueue queue) {
44 | super(queue);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/Polarity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class Polarity extends Enumerated {
32 | private static final long serialVersionUID = -1843145729195555092L;
33 | public static final Polarity normal = new Polarity(0);
34 | public static final Polarity reverse = new Polarity(1);
35 |
36 | public static final Polarity[] ALL = { normal, reverse, };
37 |
38 | public Polarity(int value) {
39 | super(value);
40 | }
41 |
42 | public Polarity(ByteQueue queue) {
43 | super(queue);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/ProgramError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class ProgramError extends Enumerated {
32 | private static final long serialVersionUID = 4478176770591341682L;
33 | public static final ProgramError normal = new ProgramError(0);
34 | public static final ProgramError loadFailed = new ProgramError(1);
35 | public static final ProgramError internal = new ProgramError(2);
36 | public static final ProgramError program = new ProgramError(3);
37 | public static final ProgramError other = new ProgramError(4);
38 |
39 | public static final ProgramError[] ALL = { normal, loadFailed, internal, program, other, };
40 |
41 | public ProgramError(int value) {
42 | super(value);
43 | }
44 |
45 | public ProgramError(ByteQueue queue) {
46 | super(queue);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/ProgramRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class ProgramRequest extends Enumerated {
32 | private static final long serialVersionUID = 8388693192499087156L;
33 | public static final ProgramRequest ready = new ProgramRequest(0);
34 | public static final ProgramRequest load = new ProgramRequest(1);
35 | public static final ProgramRequest run = new ProgramRequest(2);
36 | public static final ProgramRequest halt = new ProgramRequest(3);
37 | public static final ProgramRequest restart = new ProgramRequest(4);
38 | public static final ProgramRequest unload = new ProgramRequest(5);
39 |
40 | public static final ProgramRequest[] ALL = { ready, load, run, halt, restart, unload, };
41 |
42 | public ProgramRequest(int value) {
43 | super(value);
44 | }
45 |
46 | public ProgramRequest(ByteQueue queue) {
47 | super(queue);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/ProgramState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class ProgramState extends Enumerated {
32 | private static final long serialVersionUID = 9182595225658615643L;
33 | public static final ProgramState idle = new ProgramState(0);
34 | public static final ProgramState loading = new ProgramState(1);
35 | public static final ProgramState running = new ProgramState(2);
36 | public static final ProgramState waiting = new ProgramState(3);
37 | public static final ProgramState halted = new ProgramState(4);
38 | public static final ProgramState unloading = new ProgramState(5);
39 |
40 | public static final ProgramState[] ALL = { idle, loading, running, waiting, halted, unloading, };
41 |
42 | public ProgramState(int value) {
43 | super(value);
44 | }
45 |
46 | public ProgramState(ByteQueue queue) {
47 | super(queue);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/RejectReason.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class RejectReason extends Enumerated {
32 | private static final long serialVersionUID = 3672606740809550085L;
33 | public static final RejectReason other = new RejectReason(0);
34 | public static final RejectReason bufferOverflow = new RejectReason(1);
35 | public static final RejectReason inconsistentParameters = new RejectReason(2);
36 | public static final RejectReason invalidParameterDataType = new RejectReason(3);
37 | public static final RejectReason invalidTag = new RejectReason(4);
38 | public static final RejectReason missingRequiredParameter = new RejectReason(5);
39 | public static final RejectReason parameterOutOfRange = new RejectReason(6);
40 | public static final RejectReason tooManyArguments = new RejectReason(7);
41 | public static final RejectReason undefinedEnumeration = new RejectReason(8);
42 | public static final RejectReason unrecognizedService = new RejectReason(9);
43 |
44 | public static final RejectReason[] ALL = { other, bufferOverflow, inconsistentParameters, invalidParameterDataType,
45 | invalidTag, missingRequiredParameter, parameterOutOfRange, tooManyArguments, undefinedEnumeration,
46 | unrecognizedService, };
47 |
48 | public RejectReason(int value) {
49 | super(value);
50 | }
51 |
52 | public RejectReason(ByteQueue queue) {
53 | super(queue);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/Reliability.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class Reliability extends Enumerated {
32 | private static final long serialVersionUID = 1105281466137206125L;
33 | public static final Reliability noFaultDetected = new Reliability(0);
34 | public static final Reliability noSensor = new Reliability(1);
35 | public static final Reliability overRange = new Reliability(2);
36 | public static final Reliability underRange = new Reliability(3);
37 | public static final Reliability openLoop = new Reliability(4);
38 | public static final Reliability shortedLoop = new Reliability(5);
39 | public static final Reliability noOutput = new Reliability(6);
40 | public static final Reliability unreliableOther = new Reliability(7);
41 | public static final Reliability processError = new Reliability(8);
42 | public static final Reliability multiStateFault = new Reliability(9);
43 | public static final Reliability configurationError = new Reliability(10);
44 | public static final Reliability communicationFailure = new Reliability(12);
45 |
46 | public static final Reliability[] ALL = { noFaultDetected, noSensor, overRange, underRange, openLoop, shortedLoop,
47 | noOutput, unreliableOther, processError, multiStateFault, configurationError, communicationFailure, };
48 |
49 | public Reliability(int value) {
50 | super(value);
51 | }
52 |
53 | public Reliability(ByteQueue queue) {
54 | super(queue);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/RestartReason.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class RestartReason extends Enumerated {
32 | private static final long serialVersionUID = -4199348259202899844L;
33 | public static final RestartReason unknown = new RestartReason(0);
34 | public static final RestartReason coldstart = new RestartReason(1);
35 | public static final RestartReason warmstart = new RestartReason(2);
36 | public static final RestartReason detectedPowerLost = new RestartReason(3);
37 | public static final RestartReason detectedPoweredOff = new RestartReason(4);
38 | public static final RestartReason hardwareWatchdog = new RestartReason(5);
39 | public static final RestartReason softwareWatchdog = new RestartReason(6);
40 | public static final RestartReason suspended = new RestartReason(7);
41 |
42 | public static final RestartReason[] ALL = { unknown, coldstart, warmstart, detectedPowerLost, detectedPoweredOff,
43 | hardwareWatchdog, softwareWatchdog, suspended, };
44 |
45 | public RestartReason(int value) {
46 | super(value);
47 | }
48 |
49 | public RestartReason(ByteQueue queue) {
50 | super(queue);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/Segmentation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class Segmentation extends Enumerated {
32 | private static final long serialVersionUID = -7301676227213297779L;
33 | public static final Segmentation segmentedBoth = new Segmentation(0);
34 | public static final Segmentation segmentedTransmit = new Segmentation(1);
35 | public static final Segmentation segmentedReceive = new Segmentation(2);
36 | public static final Segmentation noSegmentation = new Segmentation(3);
37 |
38 | public static final Segmentation[] ALL = { segmentedBoth, segmentedTransmit, segmentedReceive, noSegmentation, };
39 |
40 | public Segmentation(int value) {
41 | super(value);
42 | }
43 |
44 | public Segmentation(ByteQueue queue) {
45 | super(queue);
46 | }
47 |
48 | public boolean hasTransmitSegmentation() {
49 | return this.equals(segmentedBoth) || this.equals(segmentedTransmit);
50 | }
51 |
52 | public boolean hasReceiveSegmentation() {
53 | return this.equals(segmentedBoth) || this.equals(segmentedReceive);
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | int type = intValue();
59 | if (type == segmentedBoth.intValue())
60 | return "both";
61 | if (type == segmentedTransmit.intValue())
62 | return "transmit";
63 | if (type == segmentedReceive.intValue())
64 | return "receive";
65 | if (type == noSegmentation.intValue())
66 | return "none";
67 | return "Unknown: " + type;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/ShedState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | /**
32 | * @author Matthew Lohbihler
33 | */
34 | public class ShedState extends Enumerated {
35 | private static final long serialVersionUID = 1807549359103525990L;
36 | public static final ShedState shedInactive = new ShedState(0);
37 | public static final ShedState shedRequestPending = new ShedState(1);
38 | public static final ShedState shedCompliant = new ShedState(2);
39 | public static final ShedState shedNonCompliant = new ShedState(3);
40 |
41 | public static final ShedState[] ALL = { shedInactive, shedRequestPending, shedCompliant, shedNonCompliant, };
42 |
43 | public ShedState(int value) {
44 | super(value);
45 | }
46 |
47 | public ShedState(ByteQueue queue) {
48 | super(queue);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/SilencedState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class SilencedState extends Enumerated {
32 | private static final long serialVersionUID = -9140683573905523375L;
33 | public static final SilencedState unsilenced = new SilencedState(0);
34 | public static final SilencedState audibleSilenced = new SilencedState(1);
35 | public static final SilencedState visibleSilenced = new SilencedState(2);
36 | public static final SilencedState allSilenced = new SilencedState(3);
37 |
38 | public static final SilencedState[] ALL = { unsilenced, audibleSilenced, visibleSilenced, allSilenced, };
39 |
40 | public SilencedState(int value) {
41 | super(value);
42 | }
43 |
44 | public SilencedState(ByteQueue queue) {
45 | super(queue);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/enumerated/VtClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.enumerated;
27 |
28 | import com.serotonin.bacnet4j.type.primitive.Enumerated;
29 | import org.free.bacnet4j.util.ByteQueue;
30 |
31 | public class VtClass extends Enumerated {
32 | private static final long serialVersionUID = 8557805107090951917L;
33 | public static final VtClass defaultTerminal = new VtClass(0);
34 | public static final VtClass ansi_x3_64 = new VtClass(1);
35 | public static final VtClass dec_vt52 = new VtClass(2);
36 | public static final VtClass dec_vt100 = new VtClass(3);
37 | public static final VtClass dec_vt220 = new VtClass(4);
38 | public static final VtClass hp_700_94 = new VtClass(5);
39 | public static final VtClass ibm_3130 = new VtClass(6);
40 |
41 | public static final VtClass[] ALL = { defaultTerminal, ansi_x3_64, dec_vt52, dec_vt100, dec_vt220, hp_700_94,
42 | ibm_3130, };
43 |
44 | public VtClass(int value) {
45 | super(value);
46 | }
47 |
48 | public VtClass(ByteQueue queue) {
49 | super(queue);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/primitive/Enumerated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.primitive;
27 |
28 | import java.math.BigInteger;
29 |
30 | import org.free.bacnet4j.util.ByteQueue;
31 |
32 | public class Enumerated extends UnsignedInteger {
33 | private static final long serialVersionUID = 2462119559912570064L;
34 | public static final byte TYPE_ID = 9;
35 |
36 | public Enumerated(int value) {
37 | super(value);
38 | }
39 |
40 | public Enumerated(BigInteger value) {
41 | super(value);
42 | }
43 |
44 | public byte byteValue() {
45 | return (byte) intValue();
46 | }
47 |
48 | public boolean equals(Enumerated that) {
49 | return intValue() == that.intValue();
50 | }
51 |
52 | //
53 | // Reading and writing
54 | //
55 | public Enumerated(ByteQueue queue) {
56 | super(queue);
57 | }
58 |
59 | @Override
60 | protected byte getTypeId() {
61 | return TYPE_ID;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/primitive/Null.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.primitive;
27 |
28 | import org.free.bacnet4j.util.ByteQueue;
29 |
30 | public class Null extends Primitive {
31 | private static final long serialVersionUID = 4511984655190634429L;
32 | public static final byte TYPE_ID = 0;
33 |
34 | public Null() {
35 | // no op
36 | }
37 |
38 | public Null(ByteQueue queue) {
39 | readTag(queue);
40 | }
41 |
42 | @Override
43 | public void writeImpl(ByteQueue queue) {
44 | // no op
45 | }
46 |
47 | @Override
48 | protected long getLength() {
49 | return 0;
50 | }
51 |
52 | @Override
53 | protected byte getTypeId() {
54 | return TYPE_ID;
55 | }
56 |
57 | @Override
58 | public boolean equals(Object obj) {
59 | if (this == obj)
60 | return true;
61 | if (obj == null)
62 | return false;
63 | if (getClass() != obj.getClass())
64 | return false;
65 | return true;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return "Null";
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/primitive/Unsigned16.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.primitive;
27 |
28 | import org.free.bacnet4j.util.ByteQueue;
29 |
30 | public class Unsigned16 extends UnsignedInteger {
31 | private static final long serialVersionUID = -4615555609013008931L;
32 | private static final int MAX = 0xffff;
33 |
34 | public Unsigned16(int value) {
35 | super(value);
36 | if (value > MAX)
37 | throw new IllegalArgumentException("Value cannot be greater than " + MAX);
38 | }
39 |
40 | public Unsigned16(ByteQueue queue) {
41 | super(queue);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/primitive/Unsigned32.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.primitive;
27 |
28 | import java.math.BigInteger;
29 |
30 | import org.free.bacnet4j.util.ByteQueue;
31 |
32 | public class Unsigned32 extends UnsignedInteger {
33 | private static final long serialVersionUID = -933873380384300138L;
34 | private static final long MAX = 0xffffffffl - 1;
35 |
36 | public Unsigned32(int value) {
37 | super(value);
38 | }
39 |
40 | public Unsigned32(BigInteger value) {
41 | super(value);
42 | if (value.longValue() > MAX)
43 | throw new IllegalArgumentException("Value cannot be greater than " + MAX);
44 | }
45 |
46 | public Unsigned32(ByteQueue queue) {
47 | super(queue);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/type/primitive/Unsigned8.java:
--------------------------------------------------------------------------------
1 | /*
2 | * ============================================================================
3 | * GNU General Public License
4 | * ============================================================================
5 | *
6 | * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
7 | * @author Matthew Lohbihler
8 | *
9 | * This program is free software: you can redistribute it and/or modify
10 | * it under the terms of the GNU General Public License as published by
11 | * the Free Software Foundation, either version 3 of the License, or
12 | * (at your option) any later version.
13 | *
14 | * This program is distributed in the hope that it will be useful,
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | * GNU General Public License for more details.
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see .
20 | *
21 | * When signing a commercial license with Serotonin Software Technologies Inc.,
22 | * the following extension to GPL is made. A special exception to the GPL is
23 | * included to allow you to distribute a combined work that includes BAcnet4J
24 | * without being obliged to provide the source code for any proprietary components.
25 | */
26 | package com.serotonin.bacnet4j.type.primitive;
27 |
28 | import org.free.bacnet4j.util.ByteQueue;
29 |
30 | public class Unsigned8 extends UnsignedInteger {
31 | private static final long serialVersionUID = 3671427317129449189L;
32 | private static final int MAX = 0xff - 1;
33 |
34 | public Unsigned8(int value) {
35 | super(value);
36 | if (value > MAX)
37 | throw new IllegalArgumentException("Value cannot be greater than " + MAX);
38 | }
39 |
40 | public Unsigned8(ByteQueue queue) {
41 | super(queue);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/util/ClockTimeSource.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.util;
2 |
3 | public class ClockTimeSource implements TimeSource {
4 | @Override
5 | public long currentTimeMillis() {
6 | return System.currentTimeMillis();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/util/RequestListener.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.util;
2 |
3 | import com.serotonin.bacnet4j.type.Encodable;
4 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
5 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
6 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
7 |
8 | public interface RequestListener {
9 | /**
10 | * Provides the current progress from 0 (not started, never actually sent) to 1 (finished and will not called again)
11 | * as well as an opportunity for the client to cancel the request. Other parameters represent the property that was
12 | * just received.
13 | *
14 | * @param progress
15 | * the current progress amount
16 | * @param oid
17 | * the oid of the property that was received
18 | * @param pid
19 | * the property id of the property that was received
20 | * @param pin
21 | * the index of the property that was received
22 | * @param value
23 | * the value of the property that was received
24 | * @return true if the request should be cancelled.
25 | */
26 | boolean requestProgress(double progress, ObjectIdentifier oid, PropertyIdentifier pid, UnsignedInteger pin,
27 | Encodable value);
28 | }
29 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/util/RequestListenerUpdater.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.util;
2 |
3 | import com.serotonin.bacnet4j.type.Encodable;
4 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
5 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
6 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
7 |
8 | public class RequestListenerUpdater {
9 | private final RequestListener callback;
10 | private final PropertyValues propertyValues;
11 | private final int max;
12 | private int current;
13 | private boolean cancelled;
14 |
15 | public RequestListenerUpdater(final RequestListener callback,
16 | final PropertyValues propertyValues,
17 | final int max) {
18 | this.callback = callback;
19 | this.propertyValues = propertyValues;
20 | this.max = max;
21 | }
22 |
23 | public void increment(final ObjectIdentifier oid,
24 | final PropertyIdentifier pid,
25 | final UnsignedInteger propindex,
26 | final Encodable value) {
27 | current++;
28 | if (callback != null)
29 | cancelled = callback.requestProgress(((double) current) / max, oid, pid,
30 | propindex, value);
31 | propertyValues.add(oid, pid, propindex, value);
32 | }
33 |
34 | public boolean cancelled() {
35 | return cancelled;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/serotonin/bacnet4j/util/TimeSource.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.util;
2 |
3 | public interface TimeSource {
4 | long currentTimeMillis();
5 | }
6 |
--------------------------------------------------------------------------------
/src/org/free/bacnet4j/util/IpWhiteListException.java:
--------------------------------------------------------------------------------
1 | package org.free.bacnet4j.util;
2 |
3 | public class IpWhiteListException extends Exception
4 | {
5 |
6 | public IpWhiteListException(String message)
7 | {
8 | super(message);
9 | }
10 |
11 | private static final long serialVersionUID = -1L;
12 | }
13 |
--------------------------------------------------------------------------------
/src/org/free/bacnet4j/util/RXTXHack.java:
--------------------------------------------------------------------------------
1 | package org.free.bacnet4j.util;
2 |
3 | import gnu.io.RXTXPort;
4 |
5 | public class RXTXHack{
6 |
7 | private RXTXHack(){}
8 |
9 | public static void closeRxtxPort(RXTXPort port){
10 | try{
11 | //port.IOLocked = 0;
12 | }
13 | catch(IllegalAccessError e){
14 | System.out.println(e.getMessage());
15 | }
16 | port.close();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/org/free/bacnet4j/util/SerialPortException.java:
--------------------------------------------------------------------------------
1 | package org.free.bacnet4j.util;
2 |
3 | public class SerialPortException extends Exception{
4 |
5 | public SerialPortException(String message)
6 | {
7 | super(message);
8 | }
9 |
10 | public SerialPortException(Throwable cause)
11 | {
12 | super(cause);
13 | }
14 |
15 | private static final long serialVersionUID = -1L;
16 | }
17 |
--------------------------------------------------------------------------------
/src/org/free/bacnet4j/util/SerialUtils.java:
--------------------------------------------------------------------------------
1 | package org.free.bacnet4j.util;
2 |
3 | import gnu.io.*;
4 |
5 | public class SerialUtils{
6 |
7 | public SerialUtils(){}
8 |
9 | public static SerialPort openSerialPort(SerialParameters serialParameters)
10 | throws SerialPortException{
11 | SerialPort serialPort = null;
12 | try{
13 | CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(serialParameters.getCommPortId());
14 | if(cpi.getPortType() != 1)
15 | throw new SerialPortException((new StringBuilder()).append("Port with id ").append(serialParameters.getCommPortId()).append(" is not a serial port").toString());
16 | serialPort = (SerialPort)cpi.open(serialParameters.getPortOwnerName(), 1000);
17 | serialPort.setSerialPortParams(serialParameters.getBaudRate(), serialParameters.getDataBits(), serialParameters.getStopBits(), serialParameters.getParity());
18 | serialPort.setFlowControlMode(serialParameters.getFlowControlIn() | serialParameters.getFlowControlOut());
19 | }
20 | catch(SerialPortException e){
21 | close(serialPort);
22 | throw e;
23 | }
24 | catch(Exception e)
25 | {
26 | close(serialPort);
27 | throw new SerialPortException(e);
28 | }
29 | return serialPort;
30 | }
31 |
32 | public static void close(SerialPort serialPort){
33 | if(serialPort != null)
34 | if(serialPort instanceof RXTXPort)
35 | RXTXHack.closeRxtxPort((RXTXPort)serialPort);
36 | else
37 | serialPort.close();
38 | }
39 | }
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/discovery/WhoIs.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.discovery;
2 |
3 | import com.serotonin.bacnet4j.LocalDevice;
4 | import com.serotonin.bacnet4j.RemoteDevice;
5 | import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
6 | import com.serotonin.bacnet4j.transport.Transport;
7 | import com.serotonin.bacnet4j.type.constructed.Address;
8 | import com.serotonin.bacnet4j.type.primitive.OctetString;
9 |
10 | public class WhoIs {
11 | public static void main(String[] args) throws Exception {
12 | IpNetwork network = new IpNetwork();
13 | Transport transport = new Transport(network);
14 | LocalDevice localDevice = new LocalDevice(45677, transport);
15 |
16 | try {
17 | localDevice.initialize();
18 |
19 | // CBM
20 | // RemoteDevice r = localDevice.findRemoteDevice(new Address(36, (byte) 1), new OctetString("89.101.141.54"),
21 | // 121);
22 |
23 | // CBT
24 | RemoteDevice r = localDevice.findRemoteDevice(new Address(36, (byte) 2), new OctetString("89.101.141.54"),
25 | 122);
26 |
27 | // CBR
28 | // RemoteDevice r = localDevice.findRemoteDevice(new Address("89.101.141.54", IpNetwork.DEFAULT_PORT), null,
29 | // 123);
30 |
31 | System.out.println(r);
32 | }
33 | finally {
34 | localDevice.terminate();
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/rs485/EncodingTest.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.rs485;
2 |
3 | import com.serotonin.bacnet4j.npdu.NPCI;
4 | import org.free.bacnet4j.util.ByteQueue;
5 |
6 | public class EncodingTest {
7 | // public static void main(String[] args) {
8 | // Frame frame = new Frame(FrameType.bacnetDataNotExpectingReply, (byte) 0xff, (byte) 8, new byte[] { 0x1, 0x20,
9 | // (byte) 0xff, (byte) 0xff, 0x0, (byte) 0xff, 0x10, 0x0, (byte) 0xc4, 0x2, 0x4, 0x3a, 0x10, 0x22, 0x1,
10 | // (byte) 0xe0, (byte) 0x91, 0x3, 0x22, 0x1, 0x15 });
11 | //
12 | // ByteArrayOutputStream out = new ByteArrayOutputStream();
13 | // MasterNode master = new MasterNode(null, out, (byte) 8, 1);
14 | // master.testSendFrame(frame);
15 | //
16 | // System.out.println(StreamUtils.dumpArrayHex(out.toByteArray()));
17 | // }
18 |
19 | // public static void main(String[] args) throws Exception {
20 | // // byte[] b = new byte[] { 0x1, 0x20, (byte) 0xff, (byte) 0xff, 0x0, (byte) 0xff, 0x10, 0x0, (byte) 0xc4, 0x2,
21 | // // 0x4, 0x3a, 0x10, 0x22, 0x1, (byte) 0xe0, (byte) 0x91, 0x3, 0x22, 0x1, 0x15 };
22 | // // byte[] b = new byte[] { 0x1, 0x20, (byte) 0xff, (byte) 0xff, 0x0, (byte) 0xff };
23 | // byte[] b = new byte[] { 0x10, 0x0, (byte) 0xc4, 0x2, 0x4, 0x3a, 0x10, 0x22, 0x1, (byte) 0xe0, (byte) 0x91, 0x3,
24 | // 0x22, 0x1, 0x15 };
25 | //
26 | // ByteQueue queue = new ByteQueue(b);
27 | // ServicesSupported ss = new ServicesSupported();
28 | // ss.setAll(true);
29 | // System.out.println(APDU.createAPDU(ss, queue));
30 | // }
31 |
32 | public static void main(String[] args) throws Exception {
33 | byte[] b = new byte[] { 0x1, 0x20, (byte) 0xff, (byte) 0xff, 0x0, (byte) 0xff };
34 | ByteQueue queue = new ByteQueue(b);
35 | new NPCI(queue);
36 | }
37 |
38 | // public static void main(String[] args) {
39 | // ByteQueue queue = new ByteQueue();
40 | //
41 | // IAmRequest iam = new IAmRequest(new ObjectIdentifier(ObjectType.device, 277008), new UnsignedInteger(
42 | // MaxApduLength.UP_TO_50.getId()), Segmentation.segmentedBoth, new UnsignedInteger(277));
43 | // UnconfirmedRequest req = new UnconfirmedRequest(iam);
44 | // req.write(queue);
45 | // System.out.println(queue);
46 | // }
47 | }
48 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/rs485/HubClient.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.rs485;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.OutputStream;
6 | import java.net.Socket;
7 | import java.util.Random;
8 |
9 | public class HubClient {
10 | public static void main(String[] args) throws Exception {
11 | new HubClient();
12 | }
13 |
14 | Socket socket;
15 |
16 | HubClient() throws Exception {
17 | // Set up the socket
18 | socket = new Socket("localhost", 50505);
19 | new Thread(new MessageReader()).start();
20 | OutputStream out = socket.getOutputStream();
21 |
22 | // Write the occasional message.
23 | Random random = new Random();
24 |
25 | byte[] msg = new byte[random.nextInt(2000)];
26 | random.nextBytes(msg);
27 | System.out.println("Message length=" + msg.length);
28 |
29 | try {
30 | while (true) {
31 | Thread.sleep(random.nextInt(3000));
32 | out.write(msg);
33 | }
34 | }
35 | finally {
36 | socket.close();
37 | }
38 | }
39 |
40 | class MessageReader implements Runnable {
41 | private final InputStream in;
42 |
43 | public MessageReader() throws Exception {
44 | in = socket.getInputStream();
45 | }
46 |
47 | @Override
48 | public void run() {
49 | try {
50 | byte[] buffer = new byte[1024];
51 |
52 | while (true) {
53 | int readcount = in.read(buffer);
54 | System.out.println("Read " + readcount + " bytes");
55 | }
56 | }
57 | catch (IOException e) {
58 | try {
59 | socket.close();
60 | }
61 | catch (IOException e1) {
62 | System.out.println("Error closing socket");
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/rs485/MstpTest.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.rs485;
2 |
3 | import java.net.Socket;
4 |
5 | import com.serotonin.bacnet4j.npdu.mstp.MasterNode;
6 | import com.serotonin.bacnet4j.npdu.mstp.SlaveNode;
7 |
8 | public class MstpTest {
9 | public static void main(String[] args) throws Exception {
10 | new MstpTest();
11 | }
12 |
13 | MstpTest() throws Exception {
14 | new HubServer();
15 | master((byte) 0, 3);
16 | master((byte) 1, 3);
17 | master((byte) 2, 3);
18 | master((byte) 3, 3);
19 | master((byte) 4, 3);
20 | master((byte) 10, 3);
21 | master((byte) 15, 3);
22 | master((byte) 20, 3);
23 | master((byte) 25, 3);
24 | master((byte) 30, 3);
25 | master((byte) 35, 3);
26 | master((byte) 40, 3);
27 | master((byte) 45, 3);
28 | master((byte) 50, 3);
29 | master((byte) 55, 3);
30 | master((byte) 70, 3);
31 | master((byte) 80, 3);
32 | master((byte) 110, 3);
33 | slave((byte) 5);
34 | slave((byte) 6);
35 | slave((byte) 7);
36 | slave((byte) 8);
37 | slave((byte) 9);
38 | slave((byte) 71);
39 | slave((byte) 72);
40 | slave((byte) 73);
41 | }
42 |
43 | void master(byte station, int retryCount) throws Exception {
44 | // Set up the socket
45 | try(Socket socket = new Socket("localhost", 50505)){
46 | new MasterNode(socket.getInputStream(), socket.getOutputStream(), station, retryCount).initialize();
47 | Thread.sleep(1000);
48 | }
49 | }
50 |
51 | void slave(byte station) throws Exception {
52 | // Set up the socket
53 | try(Socket socket = new Socket("localhost", 50505)){
54 | new SlaveNode(socket.getInputStream(), socket.getOutputStream(), station).initialize();
55 | Thread.sleep(1000);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/rs485/PortTest.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.rs485;
2 |
3 | import gnu.io.SerialPort;
4 | import java.io.InputStream;
5 | import org.free.bacnet4j.util.SerialParameters;
6 | import org.free.bacnet4j.util.SerialUtils;
7 |
8 | public class PortTest {
9 | public static void main(String[] args) throws Exception {
10 | SerialParameters params = new SerialParameters();
11 | params.setCommPortId("COM4");
12 | params.setBaudRate(9600);
13 | params.setPortOwnerName("Testing");
14 |
15 | SerialPort serialPort = SerialUtils.openSerialPort(params);
16 | InputStream in = serialPort.getInputStream();
17 | //OutputStream out = serialPort.getOutputStream();
18 |
19 | while (true) {
20 | System.out.print(Integer.toString(in.read(), 16));
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/rs485/SerialTest.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.rs485;
2 |
3 | import java.util.logging.Level;
4 | import java.util.logging.Logger;
5 |
6 | import com.serotonin.bacnet4j.LocalDevice;
7 | import com.serotonin.bacnet4j.RemoteDevice;
8 | import com.serotonin.bacnet4j.event.DeviceEventAdapter;
9 | import com.serotonin.bacnet4j.exception.BACnetException;
10 | import com.serotonin.bacnet4j.npdu.mstp.MasterNode;
11 | import com.serotonin.bacnet4j.npdu.mstp.MstpNetwork;
12 | import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
13 | import com.serotonin.bacnet4j.transport.Transport;
14 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
15 | import com.serotonin.bacnet4j.util.RequestUtils;
16 | import org.free.bacnet4j.util.SerialParameters;
17 |
18 | /**
19 | * This class tests the MS/TP code using an RS-485 network accessed via COM4.
20 | *
21 | * @author Matthew
22 | *
23 | */
24 | public class SerialTest {
25 | static LocalDevice localDevice;
26 |
27 | public static void main(String[] args) throws Exception {
28 | Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.FINEST);
29 |
30 | SerialParameters params = new SerialParameters();
31 | params.setCommPortId("COM4");
32 | params.setBaudRate(9600);
33 | params.setPortOwnerName("Testing");
34 |
35 | MasterNode master = new MasterNode(params, (byte) 0x4, 2);
36 | MstpNetwork network = new MstpNetwork(master);
37 | Transport transport = new Transport(network);
38 | localDevice = new LocalDevice(1234, transport);
39 | localDevice.getEventHandler().addListener(new Listener());
40 |
41 | localDevice.initialize();
42 |
43 | localDevice.sendGlobalBroadcast(new WhoIsRequest());
44 |
45 | network.sendTestRequest((byte) 8);
46 | }
47 |
48 | static class Listener extends DeviceEventAdapter {
49 | @Override
50 | public void iAmReceived(RemoteDevice d) {
51 | System.out.println("Received IAm from " + d);
52 |
53 | try {
54 | System.out.println(RequestUtils.sendReadPropertyAllowNull(localDevice, d, d.getObjectIdentifier(),
55 | PropertyIdentifier.objectList));
56 | }
57 | catch (BACnetException e) {
58 | e.printStackTrace();
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/rs485/readme.txt:
--------------------------------------------------------------------------------
1 | This source provides a testing tool for simulating an RS-485 environment.
2 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/DeserializationTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2006-2009 Serotonin Software Technologies Inc.
3 | @author Matthew Lohbihler
4 | */
5 | package com.serotonin.bacnet4j.test;
6 |
7 | import com.serotonin.bacnet4j.service.unconfirmed.WhoHasRequest;
8 | import com.serotonin.bacnet4j.type.enumerated.ObjectType;
9 | import com.serotonin.bacnet4j.type.primitive.CharacterString;
10 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
11 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
12 | import org.free.bacnet4j.util.ByteQueue;
13 |
14 | /**
15 | * @author Matthew Lohbihler
16 | */
17 | public class DeserializationTest {
18 | // public static void main(String[] args) throws Exception {
19 | // byte[] bytes = {0xc, 0x0, (byte)0x80, 0x0, 0x1, 0x19, 0x55, 0x3e, 0x31, 0x5, 0x3f};
20 | // ComplexACK ack = new ComplexACK(false, false, (byte)0, 0, 0, (byte)12, new ByteQueue(bytes));
21 | // ack.parseServiceData();
22 | // }
23 |
24 | public static void main(String[] args) throws Exception {
25 | test2();
26 | test3();
27 | test5();
28 | test6();
29 | }
30 |
31 | static void test2() throws Exception {
32 | WhoHasRequest req = new WhoHasRequest(null, new CharacterString("ELEC"));
33 | ByteQueue queue = new ByteQueue();
34 | req.write(queue);
35 | System.out.println(queue);
36 | new WhoHasRequest(queue);
37 | }
38 |
39 | static void test3() throws Exception {
40 | WhoHasRequest req = new WhoHasRequest(null, new ObjectIdentifier(ObjectType.accessDoor, 5));
41 | ByteQueue queue = new ByteQueue();
42 | req.write(queue);
43 | System.out.println(queue);
44 | new WhoHasRequest(queue);
45 | }
46 |
47 | static void test5() throws Exception {
48 | WhoHasRequest req = new WhoHasRequest(
49 | new WhoHasRequest.Limits(new UnsignedInteger(0), new UnsignedInteger(4194303)),
50 | new CharacterString("ELEC"));
51 | ByteQueue queue = new ByteQueue();
52 | req.write(queue);
53 | System.out.println(queue);
54 | new WhoHasRequest(queue);
55 | }
56 |
57 | static void test6() throws Exception {
58 | WhoHasRequest req = new WhoHasRequest(
59 | new WhoHasRequest.Limits(new UnsignedInteger(0), new UnsignedInteger(4194303)),
60 | new ObjectIdentifier(ObjectType.accessDoor, 5));
61 | ByteQueue queue = new ByteQueue();
62 | req.write(queue);
63 | System.out.println(queue);
64 | new WhoHasRequest(queue);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/FileAccessTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2006-2009 Serotonin Software Technologies Inc.
3 | @author Matthew Lohbihler
4 | */
5 | package com.serotonin.bacnet4j.test;
6 |
7 | import java.util.List;
8 |
9 | import com.serotonin.bacnet4j.LocalDevice;
10 | import com.serotonin.bacnet4j.RemoteDevice;
11 | import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
12 | import com.serotonin.bacnet4j.service.acknowledgement.AtomicReadFileAck;
13 | import com.serotonin.bacnet4j.service.confirmed.AtomicReadFileRequest;
14 | import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
15 | import com.serotonin.bacnet4j.transport.Transport;
16 | import com.serotonin.bacnet4j.type.constructed.SequenceOf;
17 | import com.serotonin.bacnet4j.type.enumerated.ObjectType;
18 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
19 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
20 | import com.serotonin.bacnet4j.util.RequestUtils;
21 |
22 | /**
23 | * Use with SlaveDeviceTest
24 | *
25 | * @author Matthew Lohbihler
26 | */
27 | public class FileAccessTest {
28 | @SuppressWarnings("unchecked")
29 | public static void main(String[] args) throws Exception {
30 | IpNetwork network = new IpNetwork("192.168.0.255");
31 | LocalDevice localDevice = new LocalDevice(1234, new Transport(network));
32 | try {
33 | localDevice.initialize();
34 | localDevice.sendBroadcast(network.getBroadcastAddress(2068), null, new WhoIsRequest(null, null));
35 |
36 | Thread.sleep(1000);
37 |
38 | RemoteDevice fileDev = null;
39 | ObjectIdentifier file = null;
40 | for (RemoteDevice d : localDevice.getRemoteDevices()) {
41 | RequestUtils.getExtendedDeviceInformation(localDevice, d);
42 | List oids = ((SequenceOf) RequestUtils.sendReadPropertyAllowNull(
43 | localDevice, d, d.getObjectIdentifier(), PropertyIdentifier.objectList)).getValues();
44 |
45 | for (ObjectIdentifier oid : oids) {
46 | if (oid.getObjectType().equals(ObjectType.file)) {
47 | fileDev = d;
48 | file = oid;
49 | break;
50 | }
51 | }
52 | }
53 |
54 | AtomicReadFileRequest request = new AtomicReadFileRequest(file, false, 0, 716);
55 | AtomicReadFileAck response = (AtomicReadFileAck) localDevice.send(fileDev, request);
56 |
57 | System.out.println("eof: " + response.getEndOfFile());
58 | System.out.println("start: " + response.getFileStartPosition());
59 | System.out.println("data: " + new String(response.getFileData().getBytes()));
60 | System.out.println("length: " + response.getFileData().getBytes().length);
61 | }
62 | finally {
63 | localDevice.terminate();
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/ReadAllAvailableProperties.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/empeeoh/BACnet4J/d662c753cf6e4e600e72945f8bf1348e6d8b1724/src_test/com/serotonin/bacnet4j/test/ReadAllAvailableProperties.java
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/ServiceDataDecoding.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.test;
2 |
3 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
4 | import org.free.bacnet4j.util.ByteQueue;
5 |
6 | public class ServiceDataDecoding {
7 | public static void main(String[] args) throws Exception {
8 | ByteQueue queue = new ByteQueue();
9 | // queue.push((byte) 30);
10 | // queue.push((byte) 10);
11 | // queue.push((byte) 1);
12 | // queue.push((byte) 0);
13 | // new UnsignedInteger(queue);
14 |
15 | UnsignedInteger u = new UnsignedInteger(30);
16 | u.write(queue);
17 | System.out.println();
18 |
19 | }
20 |
21 | // public static void main(String[] args) throws Exception {
22 | // String s = "[c,7,80,30,0,1e,29,4b,4e,c4,7,80,30,0,4f,29,4d,4e,75,c,0,4f,54,45,53,20,44,4f,4f,52,20,31,4f,29,4f,4e,91,1e,4f,29,55,4e,91,0,4f,29,6f,4e,82,4,0,4f,29,24,4e,91,0,4f,29,67,4e,91,0,4f,29,51,4e,10,4f,29,57,4e,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4f,29,68,4e,91,0,4f,29,e7,4e,91,0,4f,29,e9,4e,91,0,4f,29,eb,4e,91,2,4f,29,e6,4e,1e,4f,29,e3,4e,64,4f,29,e5,4e,7,8,4f,29,1c,4e,75,c,0,4f,54,45,53,20,44,4f,4f,52,20,31,4f,29,e2,4e,91,0,4f,29,e4,4e,c4,1,0,20,0,4f,29,e8,4e,0,4f,29,ea,5e,91,2,91,20,5f,1f]";
23 | // ByteQueue queue = new ByteQueue(toBytes(s));
24 | //
25 | // AcknowledgementService.createAcknowledgementService(ReadPropertyMultipleAck.TYPE_ID, queue);
26 | // }
27 | //
28 | // public static byte[] toBytes(String s) {
29 | // if (s.startsWith("["))
30 | // s = s.substring(1);
31 | // if (s.endsWith("]"))
32 | // s = s.substring(0, s.length() - 1);
33 | // String[] parts = s.split(",");
34 | // if (parts.length == 1)
35 | // parts = s.split("\\|");
36 | // if (parts.length == 1)
37 | // parts = s.split(" ");
38 | // if (parts.length == 1) {
39 | // parts = new String[s.length() / 2];
40 | // for (int i = 0; i < parts.length; i++)
41 | // parts[i] = s.substring(i * 2, i * 2 + 2);
42 | // }
43 | //
44 | // byte[] bytes = new byte[parts.length];
45 | //
46 | // for (int i = 0; i < bytes.length; i++)
47 | // bytes[i] = (byte) Integer.parseInt(parts[i].trim(), 16);
48 | //
49 | // return bytes;
50 | // }
51 | }
52 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/SimpleSubscriptionClient.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.test;
2 |
3 | import com.serotonin.bacnet4j.LocalDevice;
4 | import com.serotonin.bacnet4j.RemoteDevice;
5 | import com.serotonin.bacnet4j.event.DeviceEventAdapter;
6 | import com.serotonin.bacnet4j.npdu.ip.InetAddrCache;
7 | import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
8 | import com.serotonin.bacnet4j.service.confirmed.SubscribeCOVRequest;
9 | import com.serotonin.bacnet4j.transport.Transport;
10 | import com.serotonin.bacnet4j.type.constructed.Address;
11 | import com.serotonin.bacnet4j.type.constructed.PropertyValue;
12 | import com.serotonin.bacnet4j.type.constructed.SequenceOf;
13 | import com.serotonin.bacnet4j.type.enumerated.ObjectType;
14 | import com.serotonin.bacnet4j.type.primitive.Boolean;
15 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
16 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
17 |
18 | public class SimpleSubscriptionClient {
19 | public static void main(String[] args) throws Exception {
20 | IpNetwork network = new IpNetwork();
21 | LocalDevice localDevice = new LocalDevice(1234, new Transport(network));
22 | RemoteDevice d = null;
23 | ObjectIdentifier oid = new ObjectIdentifier(ObjectType.binaryInput, 0);
24 | ObjectIdentifier aoid = new ObjectIdentifier(ObjectType.analogInput, 0);
25 | try {
26 | localDevice.initialize();
27 | localDevice.getEventHandler().addListener(new Listener());
28 | localDevice.sendBroadcast(new Address(InetAddrCache.get("255.255.255.255", 2068)), null,
29 | localDevice.getIAm());
30 | d = localDevice
31 | .findRemoteDevice(new Address(new byte[] { (byte) 192, (byte) 168, 0, 2 }, 2068), null, 1968);
32 |
33 | // Subscribe to binary 0
34 | SubscribeCOVRequest req = new SubscribeCOVRequest(new UnsignedInteger(0), oid, new Boolean(true),
35 | new UnsignedInteger(0));
36 | localDevice.send(d, req);
37 |
38 | // Also subscribe to analog 0
39 | req = new SubscribeCOVRequest(new UnsignedInteger(1), aoid, new Boolean(true), new UnsignedInteger(0));
40 | localDevice.send(d, req);
41 |
42 | Thread.sleep(22000);
43 | }
44 | finally {
45 | if (d != null)
46 | // Unsubscribe
47 | localDevice.send(d, new SubscribeCOVRequest(new UnsignedInteger(0), oid, null, null));
48 | localDevice.send(d, new SubscribeCOVRequest(new UnsignedInteger(1), aoid, null, null));
49 | localDevice.terminate();
50 | }
51 | }
52 |
53 | static class Listener extends DeviceEventAdapter {
54 | @Override
55 | public void covNotificationReceived(UnsignedInteger subscriberProcessIdentifier, RemoteDevice initiatingDevice,
56 | ObjectIdentifier monitoredObjectIdentifier, UnsignedInteger timeRemaining,
57 | SequenceOf listOfValues) {
58 | System.out.println("Received COV notification: " + listOfValues);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/Test3.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.test;
2 |
3 | import java.util.Map;
4 |
5 | import com.serotonin.bacnet4j.LocalDevice;
6 | import com.serotonin.bacnet4j.RemoteDevice;
7 | import com.serotonin.bacnet4j.npdu.ip.IpNetwork;
8 | import com.serotonin.bacnet4j.transport.Transport;
9 | import com.serotonin.bacnet4j.type.Encodable;
10 | import com.serotonin.bacnet4j.type.constructed.Address;
11 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
12 | import com.serotonin.bacnet4j.util.RequestUtils;
13 |
14 | public class Test3 {
15 | public static void main(String[] args) throws Exception {
16 | IpNetwork network = new IpNetwork();
17 | Transport transport = new Transport(network);
18 | LocalDevice ld = new LocalDevice(1, transport);
19 | ld.initialize();
20 |
21 | RemoteDevice rd = ld.findRemoteDevice(new Address("192.168.0.68", 0xbac0), null, 101);
22 |
23 | Map values = RequestUtils.getProperties(ld, rd, null,
24 | PropertyIdentifier.objectName, PropertyIdentifier.vendorName, PropertyIdentifier.modelName,
25 | PropertyIdentifier.description, PropertyIdentifier.location, PropertyIdentifier.objectList);
26 |
27 | System.out.println(values);
28 |
29 | ld.terminate();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src_test/com/serotonin/bacnet4j/test/TrendLogTest.java:
--------------------------------------------------------------------------------
1 | package com.serotonin.bacnet4j.test;
2 |
3 | import com.serotonin.bacnet4j.LocalDevice;
4 | import com.serotonin.bacnet4j.exception.BACnetServiceException;
5 | import com.serotonin.bacnet4j.obj.BACnetObject;
6 | import com.serotonin.bacnet4j.type.constructed.DateTime;
7 | import com.serotonin.bacnet4j.type.constructed.LogRecord;
8 | import com.serotonin.bacnet4j.type.constructed.SequenceOf;
9 | import com.serotonin.bacnet4j.type.constructed.StatusFlags;
10 | import com.serotonin.bacnet4j.type.enumerated.ObjectType;
11 | import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
12 | import com.serotonin.bacnet4j.type.primitive.Boolean;
13 | import com.serotonin.bacnet4j.type.primitive.CharacterString;
14 | import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
15 | import com.serotonin.bacnet4j.type.primitive.Real;
16 | import com.serotonin.bacnet4j.type.primitive.UnsignedInteger;
17 |
18 | public class TrendLogTest {
19 | public static void main(String[] args) throws BACnetServiceException {
20 | LocalDevice localDevice = null;
21 | BACnetObject obj = new BACnetObject(localDevice, new ObjectIdentifier(ObjectType.trendLog, 0));
22 | obj.setProperty(PropertyIdentifier.objectName, new CharacterString("My trend log"));
23 | obj.setProperty(PropertyIdentifier.enable, new Boolean(true));
24 | // Define other properties as necessary.
25 |
26 | SequenceOf buffer = new SequenceOf();
27 | obj.setProperty(PropertyIdentifier.logBuffer, buffer);
28 | obj.setProperty(PropertyIdentifier.recordCount, new UnsignedInteger(0));
29 |
30 | // Add records to the buffer.
31 | LogRecord record = new LogRecord(new DateTime(), new Real(123), new StatusFlags(false, false, false, false));
32 | buffer.add(record);
33 | obj.setProperty(PropertyIdentifier.recordCount,
34 | new UnsignedInteger(((UnsignedInteger) obj.getProperty(PropertyIdentifier.recordCount)).intValue() + 1));
35 | // Update totalRecordCount too, if required.
36 | }
37 | }
38 |
--------------------------------------------------------------------------------