public override void Read(MCDataProcessor source)
        {
            this.NetworkNumber = source.ReadByte();
            this.PLCNumber     = source.ReadByte();
            this.IONumber      = source.ReadUShort();
            this.StationNumber = source.ReadByte();

            this.CommandCode    = source.ReadUShort();
            this.SubCommandCode = source.ReadUShort();
        }
Beispiel #2
0
        public static DeviceCode Read(MCDataProcessor source)
        {
            if (source.DataCode == CommunicationDataCode.BINARY)
            {
                var code = (DeviceCode)source.ReadByte();
                return(code);
            }
            else if (source.DataCode == CommunicationDataCode.ASCII)
            {
                bool prev = source.IgnoreConvert;

                try
                {
                    source.IgnoreConvert = true;
                    var bytes    = source.ReadBytes(2);
                    var toString = Encoding.Default.GetString(bytes);

                    return(Enum.TryParse(toString.Replace("*", ""), out DeviceCode code) ? code : DeviceCode.None);
                }
                finally
                {
                    source.IgnoreConvert = prev;
                }
            }

            return(DeviceCode.None);
        }
        public override void Read(MCDataProcessor source)
        {
            if (source.DataCode == CommunicationDataCode.BINARY)
            {
                this.Offset = source.ReadUShort();
                source.ReadByte();
                this.DeviceCode = DeviceCodeSerializer.Read(source);
            }
            else if (source.DataCode == CommunicationDataCode.ASCII)
            {
                this.DeviceCode = DeviceCodeSerializer.Read(source);
                source.ReadByte();
                this.Offset = source.ReadUShort();
            }

            this.Count = source.ReadUShort();
        }
        public override void Read(MCDataProcessor source)
        {
            if (source.DataCode == CommunicationDataCode.BINARY)
            {
                this.Offset = source.ReadUShort();
                source.ReadByte();
                this.DeviceCode = DeviceCodeSerializer.Read(source);
            }
            else if (source.DataCode == CommunicationDataCode.ASCII)
            {
                this.DeviceCode = DeviceCodeSerializer.Read(source);
                this.Offset     = source.ReadUShort();
                source.ReadByte();
            }

            int count = source.ReadUShort();
            var data  = this.Data = new ushort[count];

            for (int i = 0; i < count; i++)
            {
                data[i] = source.ReadUShort();
            }
        }