Пример #1
0
        public byte[] GetBytes()
        {
            ArrayList res = new ArrayList();

            res.Add((byte)BacNetEnums.BACNET_PDU_TYPE.PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST);
            res.Add((byte)BacNetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_I_AM);

            //Object ID
            BacNetTag deviceTag = new BacNetTag {
                Class = false, Length = 4, Number = (byte)BacNetEnums.BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_OBJECT_ID
            };

            res.AddRange(deviceTag.GetBytes());
            BacNetObject device = new BacNetObject {
                ObjectType = BacNetEnums.BACNET_OBJECT_TYPE.OBJECT_DEVICE, ObjectId = deviceObject.ObjectId
            };

            res.AddRange(device.GetObjectBytes());

            //Max APDU
            BacNetTag maxApduTag = new BacNetTag {
                Class = false, Length = (byte)MaxApduLength.GetLength(), Number = (int)BacNetEnums.BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_UNSIGNED_INT
            };

            res.AddRange(maxApduTag.GetBytes());
            res.AddRange(MaxApduLength.GetBytes());

            //Segmentation
            BacNetTag segmentationTag = new BacNetTag {
                Class = false, Length = 1, Number = (int)BacNetEnums.BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_ENUMERATED
            };

            res.AddRange(segmentationTag.GetBytes());
            res.Add((byte)SegmentationSupported);

            //Vendor Id
            BacNetTag vendorIdTag = new BacNetTag {
                Class = false, Length = (byte)VendorId.GetLength(), Number = (int)BacNetEnums.BACNET_APPLICATION_TAG.BACNET_APPLICATION_TAG_UNSIGNED_INT
            };

            res.AddRange(vendorIdTag.GetBytes());
            res.AddRange(VendorId.GetBytes());

            return((byte[])res.ToArray(typeof(byte)));
        }