Пример #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;
        }
Пример #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;
        }
Пример #3
0
        public BinaryObjectViewModel(BinaryObjectBase binaryObject)
        {
            BinaryObject = binaryObject;
            Description = binaryObject.BinaryBase.GetBinaryDescription();
            switch (binaryObject.ObjectType)
            {
                case ObjectType.Device:
                    ImageSource = binaryObject.Device.Driver.ImageSource;
                    break;

                case ObjectType.Zone:
                case ObjectType.Direction:
                    ImageSource = XManager.DriversConfiguration.Drivers.FirstOrDefault(x => x.DriverType == XDriverType.System).ImageSource;
                    break;
            }

            Formula = BinaryObject.Formula.GetStringFomula();
        }