Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 internal AtomicReadFileAck(ByteStream queue)
 {
     EndOfFile = (BBoolean)read(queue, typeof(BBoolean));
     if (popStart(queue) == 0)
     {
         FileStartPosition   = (SignedInteger)read(queue, typeof(SignedInteger));
         FileData            = (OctetString)read(queue, typeof(OctetString));
         ReturnedRecordCount = null;
         FileRecordData      = null;
         popEnd(queue, 0);
     }
     else
     {
         FileStartPosition   = (SignedInteger)read(queue, typeof(SignedInteger));
         ReturnedRecordCount = (UnsignedInteger)read(queue, typeof(UnsignedInteger));
         FileData            = null;
         IList records = new ArrayList();
         for (int i = 0; i < ReturnedRecordCount.Value; i++)
         {
             records.Add(read(queue, typeof(OctetString)));
         }
         FileRecordData = new SequenceOf(records);
         popEnd(queue, 1);
     }
 }
        // SELECT SMS_CARD.ULAZNA_PORUKA_ARHIVA_SEQ.NEXTVAL FROM dual;
        public static int GetNextSequenceValue(SequenceOf sequenceType /*, IHacEncDataContext context*/)
        {
            //try
            //{
            //    IList<decimal> sequence;
            //    switch (sequenceType)
            //    {
            //        case SequenceOf.SMS_ULAZNA_PORUKA_ARHIVA:
            //            sequence =
            //                context.GetDatabase().SqlQuery<decimal>("SELECT " +
            //                                                        "SMS_CARD." +
            //                                                        "ULAZNA_PORUKA_ARHIVA_SEQ.NEXTVAL FROM DUAL")
            //                    .ToList();
            //            return Convert.ToInt32(sequence[0]);
            //        case SequenceOf.SMS_ULAZNA_PORUKA:
            //            sequence =
            //                context.GetDatabase().SqlQuery<decimal>("SELECT " +
            //                                                        "SMS_CARD." +
            //                                                        "ULAZNA_PORUKA_SEQ.NEXTVAL FROM DUAL").ToList();
            //            return Convert.ToInt32(sequence[0]);

            //        default:
            //            throw new ArgumentException("Unknown sequence type: " + sequenceType);
            //    }
            //}
            //catch (Exception seqEx)
            //{
            //    LogFactory.GetLogger().LogFatal(new object(), "Null sequence", seqEx);
            //    throw new Exception("Null sequence");
            //}

            return(1);
        }
Ejemplo n.º 5
0
        public static ListBuilder <ContractSchedule, ContractScheduleBuilder> CreateDefaultList(int size = 3, bool isNew = true)
        {
            var builder = ContractScheduleBuilder.CreateListOfSize(size)
                          .All()
                          .Set(x => x.Id, SequenceOf.Keys(size, isNew).Next);

            return(builder.ListBuilder);
        }
Ejemplo n.º 6
0
 public ChangeOfLifeSafety(UnsignedInteger timeDelay, SequenceOf listOfLifeSafetyAlarmValues,
                           SequenceOf listOfAlarmValues, DeviceObjectPropertyReference modePropertyReference)
 {
     TimeDelay = timeDelay;
     ListOfLifeSafetyAlarmValues = listOfLifeSafetyAlarmValues;
     ListOfAlarmValues           = listOfAlarmValues;
     ModePropertyReference       = modePropertyReference;
 }
Ejemplo n.º 7
0
        protected static SequenceOf readSequenceOf(ByteStream source, Type type, int contextId)
        {
            popStart(source, contextId);
            SequenceOf result = new SequenceOf(source, type, contextId);

            popEnd(source, contextId);
            return(result);
        }
Ejemplo n.º 8
0
        public static ListBuilder <MasterTradingAgreement, MasterTradingAgreementBuilder> CreateDefaultList(int size = 3, bool isNew = true, bool persistRelatives = false)
        {
            var builder = CreateListOfSize(size)
                          .All()
                          .Set(x => x.Id, SequenceOf.Keys(size, isNew).Next)
                          .Set(x => x.ContractSchedules, ContractScheduleBuilder.CreateDefaultList(size, isNew).BuildList().ToList());

            return(builder.ListBuilder);
        }
Ejemplo n.º 9
0
        //
        //
        // Get property
        //
        public Encodable getProperty(PropertyIdentifier pid)
        {
            if (pid.Value == PropertyIdentifier.ObjectIdentifier.Value)
            {
                return(Id);
            }
            if (pid.Value == PropertyIdentifier.ObjectType.Value)
            {
                return(Id.ObjectType);
            }

            // Check that the requested property is valid for the object. This will throw an exception if the
            // property doesn't belong.
            ObjectProperties.getPropertyTypeDefinitionRequired(Id.ObjectType, pid);

            // Do some property-specific checking here.
            if (pid.Value == PropertyIdentifier.LocalTime.Value)
            {
                return(new Time());
            }
            if (pid.Value == PropertyIdentifier.LocalDate.Value)
            {
                return(new Date());
            }

            // AdK - COV subscriptions
            if (pid.Value == PropertyIdentifier.ActiveCovSubscriptions.Value)
            {
                IList      objs = localDevice.LocalObjects;
                SequenceOf covS = new SequenceOf(); // CovSubscriptions

                foreach (BACnetObject obj in objs)
                {
                    foreach (ObjectCovSubscription s in obj.covSubscriptions)
                    {
                        RemoteDevice d = localDevice.getRemoteDevice(s.Address);
                        Recipient    r = null;
                        if (d != null)
                        {
                            r = new Recipient(d.ObjectIdentifier);
                        }
                        else
                        {
                            r = new Recipient(s.Address);
                        }
                        covS.add(new CovSubscription(new RecipientProcess(r, s.SubscriberProcessIdentifier),
                                                     new ObjectPropertyReference(obj.Id, PropertyIdentifier.PresentValue),
                                                     new BBoolean(s.IsIssueConfirmedNotifications),
                                                     new UnsignedInteger(s.GetTimeRemaining(System.DateTime.Now.Ticks)), obj.getCovIncrement()
                                                     ));
                    }
                }
                return(covS);
            }

            return((Encodable)properties[pid]);
        }
Ejemplo n.º 10
0
 public AtomicReadFileAck(BBoolean endOfFile, SignedInteger fileStartPosition,
                          UnsignedInteger returnedRecordCount,
                          SequenceOf fileRecordData) : base()
 {
     EndOfFile           = endOfFile;
     FileStartPosition   = fileStartPosition;
     FileData            = null;
     ReturnedRecordCount = returnedRecordCount;
     FileRecordData      = fileRecordData;
 }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
0
        public void setProperty(PropertyIdentifier pid, uint indexBase1, Encodable value)
        {
            ObjectProperties.validateSequenceValue(Id.ObjectType, pid, value);
            SequenceOf list = (SequenceOf)properties[pid];

            if (list == null)
            {
                list = new SequenceOf();
                setPropertyImpl(pid, list);
            }
            list.set((int)indexBase1, value);
        }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
0
        // SequenceOf<Choice>
        protected static SequenceOf readSequenceOfChoice(ByteStream source, IList types, int contextId)
        {
            popStart(source, contextId);
            SequenceOf result = new SequenceOf(typeof(Choice));

            while (readEnd(source) != contextId)
            {
                result.add(new Choice(source, types));
            }
            popEnd(source, contextId);
            return(result);
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
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();
     }
 }
Ejemplo n.º 17
0
 internal VTCloseError(byte choice, ByteStream queue) : base(choice, queue, 0)
 {
     listOfVTSessionIdentifiers = readOptionalSequenceOf(queue, typeof(UnsignedInteger), 1);
 }
Ejemplo n.º 18
0
 public ChangeOfBitString(UnsignedInteger timeDelay, BitString bitMask, SequenceOf listOfBitstringValues)
 {
     TimeDelay             = timeDelay;
     BitMask               = bitMask;
     ListOfBitstringValues = listOfBitstringValues;
 }
Ejemplo n.º 19
0
 public ComplexEventType(SequenceOf values)
 {
     Values = values;
 }
 public ReadPropertyConditionalAck(SequenceOf listOfReadAccessResults)
 {
     ListOfReadAccessResults = listOfReadAccessResults;
 }
Ejemplo n.º 21
0
 public GetEventInformationAck(SequenceOf listOfEventSummaries, BBoolean moreEvents)
 {
     ListOfEventSummaries = listOfEventSummaries;
     MoreEvents           = moreEvents;
 }
Ejemplo n.º 22
0
 public GetAlarmSummaryAck(SequenceOf values)
 {
     Values = values;
 }
Ejemplo n.º 23
0
 public ReadPropertyMultipleAck(SequenceOf listOfReadAccessResults)
 {
     ListOfReadAccessResults = listOfReadAccessResults;
 }
Ejemplo n.º 24
0
 public ChangeOfState(UnsignedInteger timeDelay, SequenceOf listOfValues)
 {
     TimeDelay    = timeDelay;
     ListOfValues = listOfValues;
 }
Ejemplo n.º 25
0
 public Extended(UnsignedInteger vendorId, UnsignedInteger extendedEventType, SequenceOf parameters)
 {
     VendorId          = vendorId;
     ExtendedEventType = extendedEventType;
     Parameters        = parameters;
 }
Ejemplo n.º 26
0
 public GetEnrollmentSummaryAck(SequenceOf values)
 {
     Values = values;
 }
Ejemplo n.º 27
0
        private readonly SequenceOf listOfVTSessionIdentifiers; // UnsignedInteger

        public VTCloseError(byte choice, BACnetError error, SequenceOf listOfVTSessionIdentifiers) : base(choice, error)
        {
            this.listOfVTSessionIdentifiers = listOfVTSessionIdentifiers;
        }