コード例 #1
0
ファイル: ImportData.cs プロジェクト: saverydj/RDEImport
        private void SetTestProcedureData(ref TestProcedure newTestProcedure, string name, string traceName)
        {
            TestProcedure templateTestProcedure = ExtendedEntityManager.DeserializeEntity <TestProcedure>(Properties.Resources.TestProcedure);

            newTestProcedure.Blocks = templateTestProcedure.Blocks;
            (newTestProcedure.Blocks[0] as DriveUnitBlock).TraceNames = new string[] { traceName };
            newTestProcedure.Name = name;
        }
コード例 #2
0
ファイル: ImportData.cs プロジェクト: saverydj/RDEImport
        private void SetShiftTableData(ref ShiftTable newShiftTable, List <TraceColumn> columnData, FileContents fileContents, string name, string traceName)
        {
            ShiftTable templateShiftTableAutomatic = ExtendedEntityManager.DeserializeEntity <ShiftTable>(Properties.Resources.ShiftTableA);
            ShiftTable templateShiftTableManual    = ExtendedEntityManager.DeserializeEntity <ShiftTable>(Properties.Resources.ShiftTableM);

            int  gearIndex   = -1;
            bool isAutomatic = true;

            for (int i = 0; i < fileContents.NamesSplit.Length; i++)
            {
                if (fileContents.NamesSplit[i].Contains("gear"))
                {
                    gearIndex = i;
                }
            }

            if (gearIndex >= 0)
            {
                for (int i = fileContents.DataIndex; i < fileContents.DataLength + fileContents.DataIndex; i++)
                {
                    string thisGear = fileContents.Lines[i].Split(fileContents.Delimiter)[gearIndex];
                    if (CaseInsensitiveContains(thisGear, "MANUAL"))
                    {
                        isAutomatic = false;
                        break;
                    }
                    if (CaseInsensitiveContains(thisGear, "AUTOMATIC"))
                    {
                        isAutomatic = true;
                        break;
                    }
                }
            }

            double[] timeData = columnData.FirstOrDefault(x => x.Name == "Time").Data;
            if (isAutomatic)
            {
                double[] speedData = columnData.FirstOrDefault(x => x.Name == "Speed").Data;

                int start = -1;
                int end   = speedData.Length - 1;
                for (int i = 0; i < speedData.Length; i++)
                {
                    if (speedData[i] != 0 && start < 0)
                    {
                        start = i - 1;
                    }
                    if (speedData[i] != 0)
                    {
                        end = i + 1;
                    }
                }
                if (start >= 5)
                {
                    start = start - 5;
                }
                else if (start < 0)
                {
                    start = 0;
                }
                if (end > speedData.Length - 1)
                {
                    end = speedData.Length - 1;
                }

                newShiftTable.MaximumGear      = templateShiftTableAutomatic.MaximumGear;
                newShiftTable.TransmissionType = templateShiftTableAutomatic.TransmissionType;
                newShiftTable.Vectors          = templateShiftTableAutomatic.Vectors;
                newShiftTable.Vectors[0].Data  = (new double[] { start, end }).Cast <object>().ToArray();
            }
            else
            {
                List <double> time     = new List <double>();
                List <string> gear     = new List <string>();
                List <bool>   declutch = new List <bool>();
                List <string> message  = new List <string>();
                for (int i = fileContents.DataIndex; i < fileContents.DataLength + fileContents.DataIndex; i++)
                {
                    string thisGear = fileContents.Lines[i].Split(fileContents.Delimiter)[gearIndex];
                    if (thisGear != String.Empty)
                    {
                        thisGear = thisGear.Split('-').Last();
                        if (TypeCast.IsInt(thisGear))
                        {
                            time.Add(timeData[i - fileContents.DataIndex]);
                            gear.Add(thisGear);
                            declutch.Add(false);
                            message.Add(String.Empty);
                        }
                    }
                }
                newShiftTable.MaximumGear      = TypeCast.ToInt(gear.Max());
                newShiftTable.TransmissionType = templateShiftTableManual.TransmissionType;
                newShiftTable.Vectors          = templateShiftTableManual.Vectors;
                newShiftTable.Vectors[0].Data  = time.Cast <object>().ToArray();
                newShiftTable.Vectors[1].Data  = gear.Cast <object>().ToArray();
                newShiftTable.Vectors[2].Data  = declutch.Cast <object>().ToArray();
                newShiftTable.Vectors[3].Data  = message.Cast <object>().ToArray();
            }

            newShiftTable.TraceName = traceName;
            newShiftTable.Name      = name;
        }