Beispiel #1
0
        internal override void InterpretResult(bool reverseByteOrder, IEECmdConverters cmdConv, IEECommandParameter cmdParams)
        {
            base.InterpretResult(reverseByteOrder, cmdConv, cmdParams);

            // Create command specific result from data
            if (Code == EECmdResultCode.Success)
            {
                if (Data.Length < 20)
                {
                    Code = EECmdResultCode.InvalidResult;
                    return;
                }

                // ACK received, response data valid
                int dataIdx = 2;
                RelaisConfig  = Data[dataIdx++];
                MVCode        = cmdConv.MVIndexToMVCode(Data[dataIdx++]);
                MVRangeMin    = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                dataIdx      += 4;
                MVRangeMax    = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                dataIdx      += 4;
                PulseWidthSec = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                dataIdx      += 4;
                PulseWeight   = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                dataIdx      += 4;

                // OPTIONAL: Variant Index (Byte)
                Variant = OptionalVariant(Data, ref dataIdx);
                // OPTIONAL: Error Indication
                ErrorIndicationEnabled = OptionalErrorIndication(ref dataIdx, reverseByteOrder, out double?value);
                ErrorIndicationValue   = value;
            }
        }
        internal override void InterpretResult(bool reverseByteOrder, IEECmdConverters cmdConv, IEECommandParameter cmdParams)
        {
            // Create command specific result from data
            if (Data.Length < 18)
            {
                Code = EECmdResultCode.InvalidResult;
                return;
            }

            Out1_MVCode = cmdConv.MVIndexToMVCode(Data[0]);
            Out2_MVCode = cmdConv.MVIndexToMVCode(Data[1]);

            Out1_MVRangeMin = DataTypeConverter.ByteConverter.ToFloat(Data, 2, reverseByteOrder);
            Out1_MVRangeMax = DataTypeConverter.ByteConverter.ToFloat(Data, 6, reverseByteOrder);

            Out2_MVRangeMin = DataTypeConverter.ByteConverter.ToFloat(Data, 10, reverseByteOrder);
            Out2_MVRangeMax = DataTypeConverter.ByteConverter.ToFloat(Data, 14, reverseByteOrder);
        }
        internal override void InterpretResult(bool reverseByteOrder, IEECmdConverters cmdConv, IEECommandParameter cmdParams)
        {
            base.InterpretResult(reverseByteOrder, cmdConv, cmdParams);

            // Create command specific result from data
            if (Code == EECmdResultCode.Success)
            {
                // ACK received, response data valid
                int dataIdx = 2;
                RelaisConfig = Data[dataIdx++];
                if (OutputMode != OutputMode.Relais_ErrorIndication)
                {
                    if (Data.Length < 20)
                    {
                        Code = EECmdResultCode.InvalidResult;
                        return;
                    }

                    // Following data is not received in case of error indication
                    MVCode = cmdConv.MVIndexToMVCode(Data[dataIdx]);
                    dataIdx++;
                    MVRangeMin   = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                    dataIdx     += 4;
                    MVRangeMax   = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                    dataIdx     += 4;
                    SwitchPoint1 = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                    dataIdx     += 4;
                    Hysteresis1  = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                    dataIdx     += 4;
                    if (OutputMode == OutputMode.Relais_Window)
                    {
                        // 2nd point in window mode
                        SwitchPoint2 = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                        dataIdx     += 4;
                        Hysteresis2  = DataTypeConverter.ByteConverter.ToFloat(Data, dataIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                        dataIdx     += 4;
                    }

                    // OPTIONAL: Variant Index (Byte)
                    Variant = OptionalVariant(Data, ref dataIdx);
                }
                else if (Data.Length < 4)
                {
                    Code = EECmdResultCode.InvalidResult;
                    return;
                }

                // OPTIONAL: Error Indication
                ErrorIndicationEnabled = OptionalErrorIndication(ref dataIdx, reverseByteOrder, out double?value);
                ErrorIndicationValue   = value;
            }
        }
Beispiel #4
0
        internal override void InterpretResult(bool reverseByteOrder, IEECmdConverters cmdConv, IEECommandParameter cmdParams)
        {
            // Create command specific result from data
            if (Data.Length < cmdParams.CmdData.Length + 1)
            {
                Code = EECmdResultCode.InvalidResult;
            }
            else
            {
                // First response byte is 0, data begins at 1
                int resultIdx = 1;

                // Get number of requested values from sent command data
                int nrValues = cmdParams.CmdData.Length / 2;

                for (int i = 0; i < nrValues; i++)
                {
                    // Get MVCode from sent command data
                    MVCode code = cmdConv.MVIndexToMVCode(cmdParams.CmdData[i * 2]);

                    // Get data type (try to get from MVCode if invalid)
                    MVDataType dataType = (MVDataType)Data[resultIdx++];

                    // Get value for data type
                    double value = double.NaN;
                    switch (dataType)
                    {
                    case MVDataType.Float:
                        if ((resultIdx + 4) <= Data.Length)
                        {
                            value = DataTypeConverter.ByteConverter.ToFloat(Data, resultIdx, reverseByteOrder).ToDoubleWithFloatResolution();
                        }
                        resultIdx += 4;
                        break;

                    case MVDataType.Double:
                        if ((resultIdx + 8) <= Data.Length)
                        {
                            value = DataTypeConverter.ByteConverter.ToDouble(Data, resultIdx, reverseByteOrder);
                        }
                        resultIdx += 8;
                        break;
                    }

                    MeasValues.Add(new KeyValuePair <MVCode, double>(code, value));
                }
            }
        }
        internal override void InterpretResult(bool reverseByteOrder, IEECmdConverters cmdConv, IEECommandParameter cmdParams)
        {
            // ACK received...
            if (Data.Length < 2)
            {
                Code = EECmdResultCode.InvalidResult;
                return;
            }

            byte dispMode = Data[0];

            // Bit 7 = 0: measurands numbering is from EE31 indices list.
            // Bit 7 = 1: measurands numbering as in Gen.Cfg
            MVCodesNumberTranslationNeeded = (0x80 != (dispMode & 0x80));
            // Bit 6 = 0: automatic measuring range switch (on overflow) off
            // Bit 6 = 1: automatic measuring range switch (on overflow) on
            // settings.xxx = (0x40 == (dispMode & 0x40));
            // Bit 5 = 0: backlight off
            // Bit 5 = 1: backlight on
            BacklightActive = (0x20 == (dispMode & 0x20));
            // Bit 4 = 0: Startup logo off
            // Bit 4 = 1: Startup logo on
            // settings.xxx = (0x10 == (dispMode & 0x10));
            // Bit 3 = 0: Startup lamptest off
            // Bit 3 = 1: Startup lamptest on
            // settings.xxx = (0x08 == (dispMode & 0x08));
            // Bits 0..2: Display mode
            switch ((dispMode & 0x07))
            {
            case 0:
                // Display off
                DisplayMode = Protocol.DisplayMode.Off;
                break;

            case 1:
                // One line
                DisplayMode = Protocol.DisplayMode.OneLine;
                break;

            case 2:
                // One line alternating
                DisplayMode = Protocol.DisplayMode.OneLineAlternating;
                break;

            case 3:
                // Two lines
                DisplayMode = Protocol.DisplayMode.TwoLines;
                break;

            case 4:
                // Three lines
                DisplayMode = Protocol.DisplayMode.ThreeLines;
                break;

            case 5:
                // Four lines
                // unused
                break;

            case 6:
                // unused
                break;

            case 7:
                // unused
                break;
            }

            // Fetch following measurand codes
            var listAssignedMeasurands = new List <MVCode>();

            for (int idx = 1; idx < Data.Length; idx++)
            {
                MVCode mvc;
                if (MVCodesNumberTranslationNeeded)
                {
                    mvc = cmdConv.MVIndexToMVCode(Data[idx]);
                }
                else
                {
                    if (0xFF == Data[idx])
                    {
                        mvc = MVCode.INVALID;
                    }
                    else
                    {
                        mvc = (MVCode)Data[idx];
                    }
                }
                listAssignedMeasurands.Add(mvc);
            }

            AssignedMeasurands = listAssignedMeasurands;
        }