Exemplo n.º 1
0
        static List<List<byte>> CreateDescriptors(BinaryObjectBase binaryObject)
        {
            var objectNo = (ushort)(binaryObject.GetNo());
            if (objectNo == 236)
            {
                ;
            }

            var packs = new List<List<byte>>();
            for (int packNo = 0; packNo <= binaryObject.AllBytes.Count / 256; packNo++)
            {
                int packLenght = Math.Min(256, binaryObject.AllBytes.Count - packNo * 256);
                var packBytes = binaryObject.AllBytes.Skip(packNo * 256).Take(packLenght).ToList();

                if (packBytes.Count > 0)
                {
                    var resultBytes = new List<byte>();
                    ushort binaryObjectNo = (ushort)(binaryObject.GetNo());
                    resultBytes.AddRange(BytesHelper.ShortToBytes(binaryObjectNo));
                    resultBytes.Add((byte)(packNo + 1));
                    resultBytes.AddRange(packBytes);
                    packs.Add(resultBytes);
                }
            }
            return packs;
        }
Exemplo n.º 2
0
        public static List<byte> CreateDescriptor(BinaryObjectBase binaryObject)
        {
            var resultBytes = new List<byte>();
            var bytes = binaryObject.AllBytes;

            resultBytes.AddRange(BytesHelper.ShortToBytes((ushort)(binaryObject.GetNo())));
            resultBytes.Add(1);
            resultBytes.AddRange(BytesHelper.ShortToBytes((ushort)bytes.Count));
            resultBytes.AddRange(BytesHelper.StringDescriptionToBytes(binaryObject.BinaryBase.GetBinaryDescription(), 33));
            resultBytes.AddRange(bytes);
            var resultButesCount = resultBytes.Count;
            for (int i = 0; i < 256 - resultButesCount; i++)
            {
                resultBytes.Add(0);
            }
            return resultBytes;
        }