Example #1
0
        public Encodable getProperty(PropertyIdentifier pid, UnsignedInteger propertyArrayIndex)
        {
            Encodable result = getProperty(pid);

            if (propertyArrayIndex == null)
            {
                return(result);
            }

            if (!(result is SequenceOf))
            {
                throw new BACnetServiceException(ErrorClass.Property, ErrorCode.PropertyIsNotAnArray);
            }

            SequenceOf array = (SequenceOf )result;
            uint       index = propertyArrayIndex.Value;

            if (index == 0)
            {
                return(new UnsignedInteger((uint)array.Count));
            }

            if (index > array.getCount())
            {
                throw new BACnetServiceException(ErrorClass.Property, ErrorCode.InvalidArrayIndex);
            }

            return(array.Get((int)index));
        }
Example #2
0
 public OutOfRange(UnsignedInteger timeDelay, Real lowLimit, Real highLimit, Real deadband)
 {
     TimeDelay = timeDelay;
     LowLimit  = lowLimit;
     HighLimit = highLimit;
     Deadband  = deadband;
 }
Example #3
0
//
//
// COV subscriptions
//

        public void addCovSubscription(Address from, OctetString linkService, UnsignedInteger subscriberProcessIdentifier,
                                       BBoolean issueConfirmedNotifications, UnsignedInteger lifetime)
        {
            //synchronized (covSubscriptions) {
            ObjectCovSubscription sub = findCovSubscription(from, subscriberProcessIdentifier);
            bool confirmed            = issueConfirmedNotifications.Value;

            if (sub == null)
            {
                // Ensure that this object is valid for COV notifications.
                if (!ObjectCovSubscription.SendCovNotification(Id.ObjectType, null, this.getCovIncrement()))
                {
                    throw new BACnetServiceException(ErrorClass.Services, ErrorCode.CovSubscriptionFailed,
                                                     "Object is invalid for COV notifications");
                }

                if (confirmed)
                {
                    // If the peer wants confirmed notifications, it must be in the remote device list.
                    RemoteDevice d = localDevice.getRemoteDevice(from);
                    if (d == null)
                    {
                        throw new BACnetServiceException(ErrorClass.Services, ErrorCode.CovSubscriptionFailed,
                                                         "From address not found in remote device list. Cannot send confirmed notifications");
                    }
                }

                sub = new ObjectCovSubscription(from, linkService, subscriberProcessIdentifier, this.getCovIncrement());
                covSubscriptions.Add(sub);
            }

            sub.SetIssueConfirmedNotifications(issueConfirmedNotifications.Value);
            sub.SetExpiryTime((int)lifetime.Value);
            // }
        }
 public ObjectPropertyReference(ObjectIdentifier objectIdentifier, PropertyIdentifier propertyIdentifier,
                                UnsignedInteger propertyArrayIndex)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
 }
Example #5
0
        private void sendCovNotification(ObjectCovSubscription sub, long now)
        {
            try
            {
                UnsignedInteger timeLeft = new UnsignedInteger(sub.GetTimeRemaining(now));
                SequenceOf      values   = new SequenceOf(ObjectCovSubscription.GetValues(this));

                if (sub.IsIssueConfirmedNotifications)
                {
                    // Confirmed
                    ConfirmedCovNotificationRequest req = new ConfirmedCovNotificationRequest(
                        sub.SubscriberProcessIdentifier, localDevice.Configuration.Id, Id, timeLeft,
                        values);
                    RemoteDevice d = localDevice.getRemoteDevice(sub.Address);
                    localDevice.send(d, req);
                }
                else
                {
                    // Unconfirmed
                    UnconfirmedCovNotificationRequest req = new UnconfirmedCovNotificationRequest(
                        sub.SubscriberProcessIdentifier, localDevice.Configuration.Id, Id, timeLeft,
                        values);
                    localDevice.sendUnconfirmed(sub.Address, sub.LinkService, req);
                }
            }
            catch (BACnetException e)
            {
                throw e;
                //ExceptionDispatch.fireReceivedException(e);
            }
        }
Example #6
0
 internal IAmRequest(ByteStream queue)
 {
     iAmDeviceIdentifier   = new ObjectIdentifier(queue);
     maxAPDULengthAccepted = new UnsignedInteger(queue);
     segmentationSupported = new Segmentation(queue);
     vendorId = new UnsignedInteger(queue);
 }
Example #7
0
 public UnconfirmedPrivateTransferRequest(UnsignedInteger vendorId, UnsignedInteger serviceNumber,
                                          Encodable serviceParameters)
 {
     this.vendorId          = vendorId;
     this.serviceNumber     = serviceNumber;
     this.serviceParameters = serviceParameters;
 }
Example #8
0
 public BufferReady(DeviceObjectPropertyReference bufferProperty, UnsignedInteger previousNotification,
                    UnsignedInteger currentNotification)
 {
     BufferProperty       = bufferProperty;
     PreviousNotification = previousNotification;
     CurrentNotification  = currentNotification;
 }
Example #9
0
 public ConfirmedPrivateTransferError(byte choice, BACnetError error, UnsignedInteger vendorId,
                                      UnsignedInteger serviceNumber, BaseType errorParameters) : base(choice, error)
 {
     this.vendorId        = vendorId;
     this.serviceNumber   = serviceNumber;
     this.errorParameters = errorParameters;
 }
Example #10
0
 public AccumulatorRecord(DateTime timestamp, UnsignedInteger presentValue, UnsignedInteger accumulatedValue,
                          AccumulatorStatus accumulatorStatus)
 {
     Timestamp              = timestamp;
     PresentValue           = presentValue;
     AccumulatedValue       = accumulatedValue;
     AccumulatorStatusValue = accumulatorStatus;
 }
Example #11
0
 public IAmRequest(ObjectIdentifier iamDeviceIdentifier, UnsignedInteger maxAPDULengthAccepted,
                   Segmentation segmentationSupported, UnsignedInteger vendorId)
 {
     iAmDeviceIdentifier        = iamDeviceIdentifier;
     this.maxAPDULengthAccepted = maxAPDULengthAccepted;
     this.segmentationSupported = segmentationSupported;
     this.vendorId = vendorId;
 }
Example #12
0
 public PropertyValue(PropertyIdentifier propertyIdentifier, UnsignedInteger propertyArrayIndex, Encodable value,
                      UnsignedInteger priority)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Value    = value;
     this.Priority = priority;
 }
 public ChangeOfLifeSafety(UnsignedInteger timeDelay, SequenceOf listOfLifeSafetyAlarmValues,
                           SequenceOf listOfAlarmValues, DeviceObjectPropertyReference modePropertyReference)
 {
     TimeDelay = timeDelay;
     ListOfLifeSafetyAlarmValues = listOfLifeSafetyAlarmValues;
     ListOfAlarmValues           = listOfAlarmValues;
     ModePropertyReference       = modePropertyReference;
 }
Example #14
0
 public ReadPropertyAck(ObjectIdentifier eventObjectIdentifier, PropertyIdentifier propertyIdentifier,
                        UnsignedInteger propertyArrayIndex, Encodable value)
 {
     EventObjectIdentifier = eventObjectIdentifier;
     PropertyIdentifier    = propertyIdentifier;
     PropertyArrayIndex    = propertyArrayIndex;
     Value = value;
 }
Example #15
0
 public DeviceObjectPropertyReference(ObjectIdentifier objectIdentifier, PropertyIdentifier propertyIdentifier,
                                      UnsignedInteger propertyArrayIndex, ObjectIdentifier deviceIdentifier)
 {
     ObjectIdentifier   = objectIdentifier;
     PropertyIdentifier = propertyIdentifier;
     PropertyArrayIndex = propertyArrayIndex;
     DeviceIdentifier   = deviceIdentifier;
 }
Example #16
0
 public EnrollmentSummary(ObjectIdentifier objectIdentifier, EventType eventType, EventState eventState,
                          UnsignedInteger priority, UnsignedInteger notificationClass)
 {
     this.ObjectIdentifier  = objectIdentifier;
     this.EventType         = eventType;
     this.EventState        = eventState;
     this.Priority          = priority;
     this.NotificationClass = notificationClass;
 }
Example #17
0
 public Limits(UnsignedInteger deviceInstanceRangeLowLimit, UnsignedInteger deviceInstanceRangeHighLimit)
 {
     if (deviceInstanceRangeLowLimit == null || deviceInstanceRangeHighLimit == null)
     {
         throw new System.Exception("Both the low and high limits must be set");
     }
     this.DeviceInstanceRangeLowLimit  = deviceInstanceRangeLowLimit;
     this.DeviceInstanceRangeHighLimit = deviceInstanceRangeHighLimit;
 }
Example #18
0
 public CovSubscription(RecipientProcess recipient, ObjectPropertyReference monitoredPropertyReference,
                        BBoolean issueConfirmedNotifications, UnsignedInteger timeRemaining, Real covIncrement)
 {
     this.Recipient = recipient;
     this.MonitoredPropertyReference  = monitoredPropertyReference;
     this.IssueConfirmedNotifications = issueConfirmedNotifications;
     this.TimeRemaining = timeRemaining;
     this.CovIncrement  = covIncrement;
 }
Example #19
0
 public ObjectCovSubscription(Address address, OctetString linkService,
                              UnsignedInteger subscriberProcessIdentifier,
                              Real covIncrement)
 {
     this.Address     = address;
     this.LinkService = linkService;
     this.SubscriberProcessIdentifier = subscriberProcessIdentifier;
     this.covIncrement = covIncrement;
 }
Example #20
0
 public AtomicReadFileAck(BBoolean endOfFile, SignedInteger fileStartPosition,
                          UnsignedInteger returnedRecordCount,
                          SequenceOf fileRecordData) : base()
 {
     EndOfFile           = endOfFile;
     FileStartPosition   = fileStartPosition;
     FileData            = null;
     ReturnedRecordCount = returnedRecordCount;
     FileRecordData      = fileRecordData;
 }
Example #21
0
        public Encodable getPropertyRequired(PropertyIdentifier pid, UnsignedInteger propertyArrayIndex)
        {
            Encodable p = getProperty(pid, propertyArrayIndex);

            if (p == null)
            {
                throw new BACnetServiceException(ErrorClass.Property, ErrorCode.UnknownProperty);
            }
            return(p);
        }
Example #22
0
 public FloatingLimit(UnsignedInteger timeDelay, DeviceObjectPropertyReference setpointReference,
                      Real lowDiffLimit,
                      Real highDiffLimit, Real deadband)
 {
     TimeDelay         = timeDelay;
     SetpointReference = setpointReference;
     LowDiffLimit      = lowDiffLimit;
     HighDiffLimit     = highDiffLimit;
     Deadband          = deadband;
 }
Example #23
0
        private readonly SequenceOf listOfValues; //<PropertyValue>

        public UnconfirmedCovNotificationRequest(UnsignedInteger subscriberProcessIdentifier,
                                                 ObjectIdentifier initiatingDeviceIdentifier, ObjectIdentifier monitoredObjectIdentifier,
                                                 UnsignedInteger timeRemaining, SequenceOf listOfValues)
        {
            this.subscriberProcessIdentifier = subscriberProcessIdentifier;
            this.initiatingDeviceIdentifier  = initiatingDeviceIdentifier;
            this.monitoredObjectIdentifier   = monitoredObjectIdentifier;
            this.timeRemaining = timeRemaining;
            this.listOfValues  = listOfValues;
        }
Example #24
0
        public void removeCovSubscription(Address from, UnsignedInteger subscriberProcessIdentifier)
        {
            //synchronized(covSubscriptions) {
            ObjectCovSubscription sub = findCovSubscription(from, subscriberProcessIdentifier);

            if (sub != null)
            {
                covSubscriptions.Remove(sub);
            }
            //}
        }
Example #25
0
 public ReadRangeAck(ObjectIdentifier objectIdentifier, PropertyIdentifier propertyIdentifier,
                     UnsignedInteger propertyArrayIndex, ResultFlags resultFlags, UnsignedInteger itemCount,
                     SequenceOf itemData, UnsignedInteger firstSequenceNumber)
 {
     ObjectIdentifier    = objectIdentifier;
     PropertyIdentifier  = propertyIdentifier;
     PropertyArrayIndex  = propertyArrayIndex;
     ResultFlags         = resultFlags;
     ItemCount           = itemCount;
     ItemData            = itemData;
     FirstSequenceNumber = firstSequenceNumber;
 }
Example #26
0
 private ObjectCovSubscription findCovSubscription(Address from, UnsignedInteger subscriberProcessIdentifier)
 {
     foreach (ObjectCovSubscription sub in covSubscriptions)
     {
         if (sub.Address.Equals(from) &&
             sub.SubscriberProcessIdentifier.Equals(subscriberProcessIdentifier))
         {
             return(sub);
         }
     }
     return(null);
 }
Example #27
0
 public ActionCommand(ObjectIdentifier deviceIdentifier, ObjectIdentifier objectIdentifier,
                      PropertyIdentifier propertyIdentifier, UnsignedInteger propertyArrayIndex, Encodable propertyValue,
                      UnsignedInteger priority, UnsignedInteger postDelay, BBoolean quitOnFailure, BBoolean writeSuccessful)
 {
     DeviceIdentifier   = deviceIdentifier;
     ObjectIdentifier   = objectIdentifier;
     PropertyIdentifier = propertyIdentifier;
     PropertyArrayIndex = propertyArrayIndex;
     PropertyValue      = propertyValue;
     Priority           = priority;
     PostDelay          = postDelay;
     QuitOnFailure      = quitOnFailure;
     WriteSuccessful    = writeSuccessful;
 }
Example #28
0
        public void setCommandable(Encodable value, UnsignedInteger priority)
        {
            uint pri = 16;

            if (priority != null)
            {
                pri = priority.Value;
            }

            PriorityArray priorityArray = (PriorityArray)getProperty(PropertyIdentifier.PriorityArray);

            priorityArray.set((int)pri, createCommandValue(value));
            setCommandableImpl(priorityArray);
        }
Example #29
0
        public void removeProperty(PropertyIdentifier pid, UnsignedInteger propertyArrayIndex)
        {
            PropertyTypeDefinition def = ObjectProperties.getPropertyTypeDefinitionRequired(Id.ObjectType, pid);

            if (!def.IsSequence)
            {
                throw new BACnetServiceException(ErrorClass.Property, ErrorCode.InvalidArrayIndex);
            }
            SequenceOf sequence = (SequenceOf)properties[pid];

            if (sequence != null)
            {
                sequence.remove((int)propertyArrayIndex.Value);
            }
        }
Example #30
0
 internal UnconfirmedCovNotificationRequest(ByteStream queue)
 {
     subscriberProcessIdentifier = (UnsignedInteger)read(queue, typeof(UnsignedInteger), 0);
     initiatingDeviceIdentifier  = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier), 1);
     monitoredObjectIdentifier   = (ObjectIdentifier)read(queue, typeof(ObjectIdentifier), 2);
     timeRemaining = (UnsignedInteger)read(queue, typeof(UnsignedInteger), 3);
     try
     {
         ThreadLocalObjectTypeStack.set(monitoredObjectIdentifier.ObjectType);
         listOfValues = readSequenceOf(queue, typeof(PropertyValue), 4);
     }
     finally
     {
         ThreadLocalObjectTypeStack.remove();
     }
 }