Ejemplo n.º 1
0
        private void plotExperience(int _mode, int indexOfSelection)
        {
            ExperienceUnit          unit = user.Experiences[user.Index[indexOfSelection]];
            List <SimulatedVehicle> list = unit.Vehicles;

            speed.addRealTimePoint(-1, new Point(0, unit.Top.Speed));
            offset.addRealTimePoint(-1, new Point(0, unit.Top.Offset));
            accelerate.addRealTimePoint(-1, new Point(0, unit.Top.Acceleration));
            brake.addRealTimePoint(-1, new Point(0, unit.Top.BrakePedal));
            follow.addRealTimePoint(-1, new Point(0, unit.Top.DistanceToNext));

            speed.addRealTimePoint(-1, new Point(0, unit.Bottom.Speed));
            offset.addRealTimePoint(-1, new Point(0, unit.Bottom.Offset));
            accelerate.addRealTimePoint(-1, new Point(0, unit.Bottom.Acceleration));
            brake.addRealTimePoint(-1, new Point(0, unit.Bottom.BrakePedal));
            follow.addRealTimePoint(-1, new Point(0, unit.Bottom.DistanceToNext));

            speed.addRealTimePoint(-1, new Point(unit.Right.SimulationTime, 0));
            offset.addRealTimePoint(-1, new Point(unit.Right.SimulationTime, 0));
            accelerate.addRealTimePoint(-1, new Point(unit.Right.SimulationTime, 0));
            brake.addRealTimePoint(-1, new Point(unit.Right.SimulationTime, 0));
            follow.addRealTimePoint(-1, new Point(unit.Right.SimulationTime, 0));

            foreach (SimulatedVehicle vehicle in list)
            {
                speed.addRealTimePoint(_mode, new Point(vehicle.SimulationTime, vehicle.Speed));
                offset.addRealTimePoint(_mode, new Point(vehicle.SimulationTime, vehicle.Offset));
                accelerate.addRealTimePoint(_mode, new Point(vehicle.SimulationTime, vehicle.Acceleration));
                brake.addRealTimePoint(_mode, new Point(vehicle.SimulationTime, vehicle.BrakePedal));
                follow.addRealTimePoint(_mode, new Point(vehicle.SimulationTime, vehicle.DistanceToNext));
            }
        }
Ejemplo n.º 2
0
        public void endRefreshDataSource(bool state)
        {
            refreshing = false;
            udp.close();
            udp = null;

            if (vissim != null && PageList.Main.Selection.SceneSelect != UserSelections.SceneLaneChange)
            {
                vissim.Stop();
            }

            if (state)
            {
                ExperienceUnit unit = new ExperienceUnit();
                unit.SceneID  = PageList.Main.Selection.SceneSelect;
                unit.Mode     = PageList.Main.Selection.ModeSelect;
                unit.Vehicles = PageList.Main.Player.Vehicles;
                unit.BrakeAct = this.brakeActivity;
                unit.ReactAct = this.reactActivity;
                unit.Accident = accident;
                Evaluation evaluation = new Evaluation(unit);
                unit.Evaluation = evaluation;

                PageList.Main.User.NewExperience = unit;
            }
        }
Ejemplo n.º 3
0
        private void plotExperienceLine(int scene, int mode, LinePlotter plotter, string variable, int xAxis)
        {
            int index = UserSelections.getIndex(scene, mode);

            if (user.Index[index] == -1)
            {
                return;
            }

            Dispatcher              dispatcher = PageList.Main.Dispatcher;
            ExperienceUnit          unit       = user.Experiences[user.Index[index]];
            List <SimulatedVehicle> list       = unit.Vehicles;

            plotter.Init.AppendAsync(dispatcher,
                                     new Point(0, (float)unit.Top.GetType().GetProperty(variable).GetValue(unit.Top)));
            plotter.Init.AppendAsync(dispatcher,
                                     new Point(0, (float)unit.Bottom.GetType().GetProperty(variable).GetValue(unit.Bottom)));

            switch (xAxis)
            {
            case 0:
                plotter.Init.AppendAsync(dispatcher, new Point(unit.Right.SimulationTime, 0));
                break;

            case 1:
                plotter.Init.AppendAsync(dispatcher, new Point(unit.Right.TotalDistance, 0));
                break;

            default:
                return;
            }


            foreach (SimulatedVehicle vehicle in list)
            {
                float x;

                switch (xAxis)
                {
                case 0:
                    x = vehicle.SimulationTime;
                    break;

                case 1:
                    x = vehicle.TotalDistance;
                    break;

                default:
                    return;
                }

                plotter.addRealTimePoint(mode,
                                         new Point(x, (float)vehicle.GetType().GetProperty(variable).GetValue(vehicle)));
            }
        }
Ejemplo n.º 4
0
        private static void setAllValues(ExcelManger manger, ExperienceUnit unit)
        {
            manger.setCellValue(1, 1, getSheetTitle(unit));

            manger.setCellValue(4, 3, unit.Evaluation.AverageDelay.ToString("0.00"));
            manger.setCellValue(4, 5, unit.Evaluation.AverageQueueLength.ToString("0.00"));
            manger.setCellValue(4, 7, unit.Evaluation.AverageSpeed.ToString("0.00"));

            manger.setCellValue(6, 4, unit.Evaluation.MeanSpeed.ToString("0.00"));
            manger.setCellValue(7, 4, unit.Evaluation.VarianceSpeed.ToString("0.00"));
            manger.setCellValue(6, 7, unit.Evaluation.MeanAcc.ToString("0.00"));
            manger.setCellValue(7, 7, unit.Evaluation.VarianceAcc.ToString("0.00"));
            manger.setCellValue(6, 10, unit.Evaluation.MeanSteeringWheel.ToString("0.00"));
            manger.setCellValue(7, 10, unit.Evaluation.VarianceSteeringWheel.ToString("0.00"));
            manger.setCellValue(8, 4, unit.Evaluation.MeanOffset.ToString("0.00"));
            manger.setCellValue(9, 4, unit.Evaluation.VarianceOffset.ToString("0.00"));
            manger.setCellValue(8, 7, unit.Evaluation.MeanDistanceToNext.ToString("0.00"));
            manger.setCellValue(9, 7, unit.Evaluation.VarianceDistanceToNext.ToString("0.00"));

            manger.setCellValue(10, 4, unit.Evaluation.MeanSpeedEx.ToString("0.00"));
            manger.setCellValue(11, 4, unit.Evaluation.VarianceSpeedEx.ToString("0.00"));
            manger.setCellValue(10, 7, unit.Evaluation.MeanAccEx.ToString("0.00"));
            manger.setCellValue(11, 7, unit.Evaluation.VarianceAccEx.ToString("0.00"));
            manger.setCellValue(10, 10, unit.Evaluation.MeanSteeringWheelEx.ToString("0.00"));
            manger.setCellValue(11, 10, unit.Evaluation.VarianceSteeringWheelEx.ToString("0.00"));
            manger.setCellValue(12, 4, unit.Evaluation.MeanOffsetEx.ToString("0.00"));
            manger.setCellValue(13, 4, unit.Evaluation.VarianceOffsetEx.ToString("0.00"));
            manger.setCellValue(12, 7, unit.Evaluation.MeanDistanceToNextEx.ToString("0.00"));
            manger.setCellValue(13, 7, unit.Evaluation.VarianceDistanceToNextEx.ToString("0.00"));

            manger.setCellValue(15, 3, unit.Evaluation.ReactTime.ToString("0.00"));
            manger.setCellValue(15, 5, unit.Evaluation.BrakeDistance.ToString("0.00"));

            int insertRow = 18;

            foreach (SimulatedVehicle vehicle in unit.Vehicles)
            {
                manger.setCellValue(insertRow, 1, vehicle.SimulationTime.ToString("0.00"));
                manger.setCellValue(insertRow, 2, vehicle.PositionX.ToString("0.00"));
                manger.setCellValue(insertRow, 3, vehicle.PositionY.ToString("0.00"));
                manger.setCellValue(insertRow, 4, vehicle.Speed.ToString("0.00"));
                manger.setCellValue(insertRow, 5, vehicle.Acceleration.ToString("0.00"));
                manger.setCellValue(insertRow, 6, vehicle.SteeringWheel.ToString("0.00"));
                manger.setCellValue(insertRow, 7, vehicle.Offset.ToString("0.00"));
                manger.setCellValue(insertRow, 8, vehicle.BrakePedal.ToString("0.00"));
                manger.setCellValue(insertRow, 9, vehicle.TotalDistance.ToString("0.00"));
                manger.setCellValue(insertRow, 10, vehicle.DistanceToNext.ToString("0.00"));
                manger.setCellValue(insertRow, 11, vehicle.Braking.ToString("0.00"));
                manger.setCellValue(insertRow, 12, vehicle.Reacting.ToString("0.00"));
                manger.setCellValue(insertRow, 13, vehicle.Area.ToString("0.00"));
                manger.setCellValue(insertRow, 14, vehicle.Lane.ToString("0.00"));
                manger.setCellValue(insertRow, 15, vehicle.TrafficLight.ToString("0.00"));
                insertRow++;
            }
        }
Ejemplo n.º 5
0
        private static string getSheetName(ExperienceUnit unit)
        {
            string sheetName = "";

            switch (unit.SceneID)
            {
            case UserSelections.ScenePractice:
                sheetName += "#0";
                return(sheetName);

            case UserSelections.SceneBrake:
                sheetName += "#1";
                break;

            case UserSelections.SceneLaneChange:
                sheetName += "#2";
                break;

            case UserSelections.SceneIntersection:
                sheetName += "#3";
                break;
            }

            switch (unit.Mode)
            {
            case UserSelections.NormalMode:
                sheetName += " - mode = 0";
                break;

            case UserSelections.DistractAMode:
                sheetName += " - mode = 1";
                break;

            case UserSelections.DistractBMode:
                sheetName += " - mode = 2";
                break;

            case UserSelections.DistractCMode:
                sheetName += " - mode = 3";
                break;

            case UserSelections.DistractDMode:
                sheetName += " - mode = 4";
                break;
            }

            return(sheetName);
        }
Ejemplo n.º 6
0
        private static string getSheetTitle(ExperienceUnit unit)
        {
            string sheetTitle = PageList.Main.User.LoginName;

            switch (unit.SceneID)
            {
            case UserSelections.ScenePractice:
                sheetTitle += " - 练习场景";
                return(sheetTitle);

            case UserSelections.SceneBrake:
                sheetTitle += " - 跟驰刹车";
                break;

            case UserSelections.SceneLaneChange:
                sheetTitle += " - 前车并线";
                break;

            case UserSelections.SceneIntersection:
                sheetTitle += " - 路口等灯";
                break;
            }

            switch (unit.Mode)
            {
            case UserSelections.NormalMode:
                sheetTitle += " - 正常模式";
                break;

            case UserSelections.DistractAMode:
                sheetTitle += " - 微信语音";
                break;

            case UserSelections.DistractBMode:
                sheetTitle += " - 微信短信";
                break;

            case UserSelections.DistractCMode:
                sheetTitle += " - 调节收音机";
                break;

            case UserSelections.DistractDMode:
                sheetTitle += " - 行车导航";
                break;
            }

            return(sheetTitle);
        }
Ejemplo n.º 7
0
        private float getBarChartValue(int scene, int mode, string dataName)
        {
            int   index = UserSelections.getIndex(scene, mode);
            float result;

            if (index != -1 && user.Index[index] != -1)
            {
                ExperienceUnit unit = user.Experiences[user.Index[index]];
                result = (float)unit.Evaluation.GetType().GetProperty(dataName).GetValue(unit.Evaluation);
            }
            else
            {
                result = 0;
            }

            return(result);
        }
Ejemplo n.º 8
0
        public static void exportExcel()
        {
            ExcelManger manger = new ExcelManger(PageList.Main.User.LoginName + ".xlsx");

            manger.openTemplate();
            int[] index = PageList.Main.User.Index;
            int   count = 0;

            exportUserInfo(manger);
            for (int i = 0; i < index.Length; i++)
            {
                if (index[i] != -1)
                {
                    showTip(++count);
                    ExperienceUnit unit = PageList.Main.User.Experiences[index[i]];
                    exportAExperienceUnit(manger, unit);
                }
            }

            manger.saveFileAndExit();
        }
Ejemplo n.º 9
0
        // distance oriented
        private void plotMarks()
        {
            if (currentScene == UserSelections.ScenePractice)
            {
                return;
            }

            SimulatedVehicle top    = new SimulatedVehicle();
            SimulatedVehicle bottom = new SimulatedVehicle();

            int            count = 0;
            int            index;
            ExperienceUnit unit = null;

            foreach (int mode in UserSelections.ModeList)
            {
                index = user.Index[UserSelections.getIndex(currentScene, mode)];
                if (index != -1)
                {
                    unit = user.Experiences[index];
                    foreach (PropertyInfo p in top.GetType().GetProperties())
                    {
                        if ((float)p.GetValue(unit.Top) > (float)p.GetValue(top))
                        {
                            p.SetValue(top, (float)p.GetValue(unit.Top));
                        }

                        if ((float)p.GetValue(unit.Bottom) < (float)p.GetValue(bottom))
                        {
                            p.SetValue(bottom, (float)p.GetValue(unit.Bottom));
                        }
                    }
                    ++count;
                }
            }


            if (count != 0)
            {
                foreach (DistractMark mark in unit.Marks)
                {
                    float start = mark.Start.TotalDistance;
                    float end   = mark.End.TotalDistance;

                    SpeedChart.AddAMarker(new List <Point>()
                    {
                        new Point(start, top.Speed),
                        new Point(start, bottom.Speed), new Point(end, bottom.Speed), new Point(end, top.Speed), new Point(start, top.Speed)
                    });
                    OffsetChart.AddAMarker(new List <Point>()
                    {
                        new Point(start, top.Offset),
                        new Point(start, bottom.Offset), new Point(end, bottom.Offset), new Point(end, top.Offset), new Point(start, top.Offset)
                    });
                    AccelerationChart.AddAMarker(new List <Point>()
                    {
                        new Point(start, top.Acceleration),
                        new Point(start, bottom.Acceleration), new Point(end, bottom.Acceleration), new Point(end, top.Acceleration), new Point(start, top.Acceleration)
                    });
                    BrakeChart.AddAMarker(new List <Point>()
                    {
                        new Point(start, top.BrakePedal),
                        new Point(start, bottom.BrakePedal), new Point(end, bottom.BrakePedal), new Point(end, top.BrakePedal), new Point(start, top.BrakePedal)
                    });
                    FollowChart.AddAMarker(new List <Point>()
                    {
                        new Point(start, top.DistanceToNext),
                        new Point(start, bottom.DistanceToNext), new Point(end, bottom.DistanceToNext), new Point(end, top.DistanceToNext), new Point(start, top.DistanceToNext)
                    });
                }
            }

            if (showMark && axis == 1)
            {
                showMarkers();
            }
            else
            {
                hideMarkers();
            }
        }
Ejemplo n.º 10
0
        private void plotExperienceLine(int _mode, int indexOfSelection)
        {
            Dispatcher              dispatcher = PageList.Main.Dispatcher;
            ExperienceUnit          unit       = user.Experiences[user.Index[indexOfSelection]];
            List <SimulatedVehicle> list       = unit.Vehicles;

            SpeedChart.Init.AppendAsync(dispatcher, new Point(0, unit.Top.Speed));
            OffsetChart.Init.AppendAsync(dispatcher, new Point(0, unit.Top.Offset));
            AccelerationChart.Init.AppendAsync(dispatcher, new Point(0, unit.Top.Acceleration));
            BrakeChart.Init.AppendAsync(dispatcher, new Point(0, unit.Top.BrakePedal));
            FollowChart.Init.AppendAsync(dispatcher, new Point(0, unit.Top.DistanceToNext));

            SpeedChart.Init.AppendAsync(dispatcher, new Point(0, unit.Bottom.Speed));
            OffsetChart.Init.AppendAsync(dispatcher, new Point(0, unit.Bottom.Offset));
            AccelerationChart.Init.AppendAsync(dispatcher, new Point(0, unit.Bottom.Acceleration));
            BrakeChart.Init.AppendAsync(dispatcher, new Point(0, unit.Bottom.BrakePedal));
            FollowChart.Init.AppendAsync(dispatcher, new Point(0, unit.Bottom.DistanceToNext));

            switch (axis)
            {
            case 0:
                SpeedChart.Init.AppendAsync(dispatcher, new Point(unit.Right.SimulationTime, 0));
                OffsetChart.Init.AppendAsync(dispatcher, new Point(unit.Right.SimulationTime, 0));
                AccelerationChart.Init.AppendAsync(dispatcher, new Point(unit.Right.SimulationTime, 0));
                BrakeChart.Init.AppendAsync(dispatcher, new Point(unit.Right.SimulationTime, 0));
                FollowChart.Init.AppendAsync(dispatcher, new Point(unit.Right.SimulationTime, 0));
                break;

            case 1:
                SpeedChart.Init.AppendAsync(dispatcher, new Point(unit.Right.TotalDistance, 0));
                OffsetChart.Init.AppendAsync(dispatcher, new Point(unit.Right.TotalDistance, 0));
                AccelerationChart.Init.AppendAsync(dispatcher, new Point(unit.Right.TotalDistance, 0));
                BrakeChart.Init.AppendAsync(dispatcher, new Point(unit.Right.TotalDistance, 0));
                FollowChart.Init.AppendAsync(dispatcher, new Point(unit.Right.TotalDistance, 0));
                break;

            default:
                return;
            }


            foreach (SimulatedVehicle vehicle in list)
            {
                float x;

                switch (axis)
                {
                case 0:
                    x = vehicle.SimulationTime;
                    break;

                case 1:
                    x = vehicle.TotalDistance;
                    break;

                default:
                    return;
                }

                SpeedChart.addRealTimePoint(_mode, new Point(x, vehicle.Speed));
                OffsetChart.addRealTimePoint(_mode, new Point(x, vehicle.Offset));
                AccelerationChart.addRealTimePoint(_mode, new Point(x, vehicle.Acceleration));
                BrakeChart.addRealTimePoint(_mode, new Point(x, vehicle.BrakePedal));
                FollowChart.addRealTimePoint(_mode, new Point(x, vehicle.DistanceToNext));
            }
        }
Ejemplo n.º 11
0
 private static void exportAExperienceUnit(ExcelManger manger, ExperienceUnit unit)
 {
     manger.createNewSheet(getSheetName(unit));
     setAllValues(manger, unit);
 }