示例#1
0
        public UnconfirmedEventNotification(byte[] apdu)
        {
            int len = 2;

            BacNetTag tag = new BacNetTag(apdu, len, ref len);

            ProccessId = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag    = new BacNetTag(apdu, len, ref len);
            Device = new BacNetObject(apdu, len, ref len);

            tag    = new BacNetTag(apdu, len, ref len);
            Object = new BacNetObject(apdu, len, ref len);

            tag = new BacNetTag(apdu, len, ref len);
            if (tag.Length == 6 && tag.Number == 3)
            {
                tag = new BacNetTag(apdu, len, ref len);
                if (tag.Length == 6 && tag.Number == 2)
                {
                    TimeStamp = new BacNetTimeStamp(apdu, len, ref len);
                }
                tag = new BacNetTag(apdu, len, ref len);
                tag = new BacNetTag(apdu, len, ref len);
                if (tag.Length != 7 && tag.Number != 3)
                {
                    throw new Exception("Invalid TimeStamp");
                }
            }

            tag = new BacNetTag(apdu, len, ref len);
            NotificationClass = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag      = new BacNetTag(apdu, len, ref len);
            Priority = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag       = new BacNetTag(apdu, len, ref len);
            EventType = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag     = new BacNetTag(apdu, len, ref len);
            Message = new BacNetString(apdu, len, tag.Length, ref len);

            tag        = new BacNetTag(apdu, len, ref len);
            NotifyType = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag         = new BacNetTag(apdu, len, ref len);
            AckRequired = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag       = new BacNetTag(apdu, len, ref len);
            FromState = new BacNetUInt(apdu, len, tag.Length, ref len);

            tag     = new BacNetTag(apdu, len, ref len);
            ToState = new BacNetUInt(apdu, len, tag.Length, ref len);
        }
示例#2
0
        public static object GetAppTagValue(byte[] apdu, int startIndex, BacNetTag metaTag, ref int len)
        {
            object res = null;

            switch (metaTag.Number)
            {
            case 1:     //UNSIGNED_INT
                var boolValue = new BacNetBool(metaTag);
                res = boolValue;
                break;

            case 2:     //UNSIGNED_INT
                var uIntValue = new BacNetUInt(apdu, len, metaTag.Length, ref len);
                res = uIntValue;
                break;

            case 3:     //SIGNED_INT
                var intValue = new BacNetInt(apdu, len, metaTag.Length, ref len);
                res = intValue;
                break;

            case 4:     //REAL
                var realValue = new BacNetReal(apdu, len, metaTag.Length, ref len);
                res = realValue;
                break;

            case 5:     //DOUBLE
                var doubleValue = new BacNetDouble(apdu, len, metaTag.Length, ref len);
                res = doubleValue;
                break;

            case 7:     //CHARACTER STRING
                var str = new BacNetString(apdu, len, metaTag.Length, ref len);
                res = str;
                break;

            case 9:     //ENUMERATION
                var enumValue = new BacNetEnumeration(apdu, len, metaTag.Length, ref len);
                res = enumValue;
                break;

            case 11:     //TIME
                var time = new BacNetTime(apdu, len, ref len);
                res = time;
                break;

            case 12:     //OBJECT IDENTIFIER
                var obj = new BacNetObject(apdu, len, ref len);
                res = obj;
                break;
            }
            return(res);
        }