Beispiel #1
0
        private TransmissionState DoWriteParameterIntern(int pkParameter, int converterType, ref uint value)
        {
            byte[] array = new byte[13];
            int    num   = GlobalData.PKParameter2ConverterParameter(pkParameter, converterType);

            byte[]            array2;
            TransmissionState result;

            try
            {
                array2 = ProtocolFrame.CreateBuffer((ushort)_serialNumber, 0, (ushort)num, true, false, false, value);
                this.WriteData(array2, 0, array2.Length);
            }
            catch (TimeoutException)
            {
                result = TransmissionState.WriteTimeout;
                return(result);
            }
            catch (Exception ex)
            {
                result = TransmissionState.Error;
                return(result);
            }
            try
            {
                TransmissionState transmissionState = this.ReadFrame(13, array2, array);
                if (transmissionState == TransmissionState.Ok)
                {
                    uint num2 = (uint)(((int)array[7] << 24) + ((int)array[8] << 16) + ((int)array[9] << 8) + (int)array[10]);
                    if (value == num2)
                    {
                        result = TransmissionState.Ok;
                    }
                    else
                    {
                        value  = num2;
                        result = TransmissionState.Error;
                    }
                }
                else
                {
                    result = transmissionState;
                }
            }
            catch (TimeoutException)
            {
                result = TransmissionState.ReadTimeout;
            }
            catch (Exception ex2)
            {
                result = TransmissionState.Error;
            }
            return(result);
        }
Beispiel #2
0
        private TransmissionState ReadFileBlockIntern(byte[] values, int converterType)
        {
            byte[] array = new byte[137];
            int    num   = GlobalData.PKParameter2ConverterParameter(270, converterType);

            byte[]            array2;
            TransmissionState result;

            try
            {
                array2 = ProtocolFrame.CreateBuffer((ushort)_serialNumber, 0, (ushort)num, false, true, false, 0u);
                this.WriteData(array2);
            }
            catch (TimeoutException)
            {
                result = TransmissionState.WriteTimeout;
                return(result);
            }
            catch (Exception ex)
            {
                result = TransmissionState.Error;
                return(result);
            }
            try
            {
                TransmissionState transmissionState = this.ReadFrame(137, array2, array);
                if (transmissionState == TransmissionState.Ok)
                {
                    Array.Copy(array, 7, values, 0, 128);
                    result = TransmissionState.Ok;
                }
                else
                {
                    result = transmissionState;
                }
            }
            catch (TimeoutException)
            {
                result = TransmissionState.ReadTimeout;
            }
            catch (Exception ex2)
            {
                result = TransmissionState.Error;
            }
            return(result);
        }
Beispiel #3
0
 public ProtocolFrame(ushort receiver, ushort sender, ushort parameter, bool write, bool read, bool master, bool error, bool file, bool vdew, byte[] value)
 {
     this.Time          = DateTime.Now;
     this.buffer        = ProtocolFrame.CreateBuffer(receiver, sender, parameter, write, read, master, error, file, vdew, value);
     this.DataLength    = value.Length;
     this.Checksum      = this.buffer[7 + this.DataLength];
     this.RatedChecksum = this.Checksum;
     this.Receiver      = receiver;
     this.Sender        = sender;
     this.Parameter     = parameter;
     this.Write         = write;
     this.Read          = read;
     this.Master        = master;
     this.Error         = error;
     this.File          = file;
     this.Vdew          = vdew;
     this.State         = TransmissionState.Ok;
 }
Beispiel #4
0
 public ProtocolFrame(ushort receiver, ushort sender, ushort parameter, bool write, bool read, bool master, uint value)
 {
     this = new ProtocolFrame(receiver, sender, parameter, write, read, master, false, false, false, ProtocolFrame.ToByte(value));
 }
Beispiel #5
0
 public static byte[] CreateBuffer(ushort receiver, ushort sender, ushort parameter, bool write, bool read, bool master, uint value)
 {
     return(ProtocolFrame.CreateBuffer(receiver, sender, parameter, write, read, master, false, false, false, ProtocolFrame.ToByte(value)));
 }