Пример #1
0
        /// <summary>Set acquisition configuration according to connected ECU</summary>
        /// <param name="protocol">Reference to protocol to connected ECU</param>
        public void SetConfiguration(ref ProtocolBase protocol)
        {
            mNumberOfBlocks = protocol.AcquisitionSectors;

            // Save mask
            byte NumOfCols = 0;

            mSaveMin = new bool[10];
            mSaveAvg = new bool[10];
            mSaveMax = new bool[10];
            UInt32 Mask = 1;

            for (int i = 0; i < 10; i++)
            {
                if ((protocol.AcquisitionSaveMask & Mask) == 0)
                {
                    mSaveMin[i] = false;
                }
                else
                {
                    mSaveMin[i] = true;
                    NumOfCols++;
                }
                Mask = (UInt32)(Mask * 2);
                if ((protocol.AcquisitionSaveMask & Mask) == 0)
                {
                    mSaveAvg[i] = false;
                }
                else
                {
                    mSaveAvg[i] = true;
                    NumOfCols++;
                }
                Mask = (UInt32)(Mask * 2);
                if ((protocol.AcquisitionSaveMask & Mask) == 0)
                {
                    mSaveMax[i] = false;
                }
                else
                {
                    mSaveMax[i] = true;
                    NumOfCols++;
                }
                Mask = (UInt32)(Mask * 2);
            }

            mSourceValues = new byte[10];
            for (byte i = 0; i < 10; i++)
            {
                mSourceValues[i] = protocol.AcquisitionSource(i);
            }

            // row
            mHead          = new string[NumOfCols + 1];
            mHead[0]       = "DateTime";
            mValuePosition = new byte[NumOfCols + 1];
            mRowLength     = 1;
            for (int i = 0; i < 10; i++)
            {
                byte   ValuePosition = protocol.GetValuePosition(mSourceValues[i]);
                string ValueName     = protocol.GetValueName(ValuePosition);
                string ValueUnit     = protocol.GetValueUnit(ValuePosition);
                if (ValueName != null)
                {
                    if (mSaveMin[i] == true)
                    {
                        mHead[mRowLength] = String.Format("{0}_MIN_in_{1}", ValueName, ValueUnit);
                        mValuePosition[mRowLength - 1] = ValuePosition;
                        // Replace prohibited xml characters
                        mHead[mRowLength] = mHead[mRowLength].Replace(@" ", @"_");
                        mHead[mRowLength] = mHead[mRowLength].Replace(@"@", @"at");
                        mHead[mRowLength] = mHead[mRowLength].Replace(@"%", @"_Pozent");
                        mRowLength++;
                    }
                    if (mSaveAvg[i] == true)
                    {
                        mHead[mRowLength] = String.Format("{0}_AVG_in_{1}", ValueName, ValueUnit);
                        mValuePosition[mRowLength - 1] = ValuePosition;
                        // Replace prohibited xml characters
                        mHead[mRowLength] = mHead[mRowLength].Replace(@" ", @"_");
                        mHead[mRowLength] = mHead[mRowLength].Replace(@"@", @"at");
                        mHead[mRowLength] = mHead[mRowLength].Replace(@"%", @"_Pozent");
                        mRowLength++;
                    }
                    if (mSaveMax[i] == true)
                    {
                        mHead[mRowLength] = String.Format("{0}_MAX_in_{1}", ValueName, ValueUnit);
                        mValuePosition[mRowLength - 1] = ValuePosition;
                        // Replace prohibited xml characters
                        mHead[mRowLength] = mHead[mRowLength].Replace(@" ", @"_");
                        mHead[mRowLength] = mHead[mRowLength].Replace(@"@", @"at");
                        mHead[mRowLength] = mHead[mRowLength].Replace(@"%", @"_Pozent");
                        mRowLength++;
                    }
                }
            }
            mItem = new AcquisitionItem[0];
            // calculate row length from amount of values to amount of bytes
            // all values are 2-byte-values
            mRowLength = (UInt16)(mRowLength * 2);
            // except date has 3 bytes
            mRowLength++;
        }