Ejemplo n.º 1
0
        public void TestSequence_Thread(SrbThread.dIsThreadStoping IsStoping)
        {
            pd = new PerformanceDetector(10);
            bgd.setPd(pd);
            int lose_times = 0;

            if (pg_last != null)
            {
                chart.remove(pg_last.Plots[0]);
                chart.remove(pg_last.Plots[1]);
            }
            if (pg != null)
            {
                pg_last = pg;
                pg_last.Plots[0].Color = System.Drawing.Color.FromArgb(64, pg_last.Plots[0].Color);
                pg_last.Plots[1].Color = System.Drawing.Color.FromArgb(64, pg_last.Plots[1].Color);
            }
            pg = new PlotGroup(3);
            pg.Plots[0].Color   = System.Drawing.Color.ForestGreen;
            pg.Plots[1].Color   = System.Drawing.Color.Violet;
            chart.Forcu_on_plot = pg.Plots[0];
            chart.add(pg.Plots[0]);
            chart.add(pg.Plots[1]);


            if (target_speed_table == null)
            {
                target_speed_table = initSpeedArray();
            }
            Stopwatch sw = new Stopwatch();

            float time = 0f;

            sw.Restart();
            object motion = null;

            double[] temp = new double[3];
            while (time < target_speed_table.Max_time)
            {
                pd.beginCheck();

                bgd.target_speed = target_speed_table.speed(time, ref motion);

                pd.checkPoint(1);
                bgd.addDataAccess_pd(1, true);
                pd.checkPoint(5);
                temp[0] = bgd.target_speed;
                temp[1] = bgd.sensor_speed;
                temp[2] = bgd.odometer;
                pg.append(time, temp);
                pd.checkPoint(6);
                bool check(long[] ticks)
                {
                    return(((ticks[6] - ticks[0]).tickToMs()) > 2);
                }

                pd.endCheckPoint(check);

                if (IsStoping())
                {
                    break;
                }
                while (sw.getElapsedMs() - time < period_in_ms)
                {
                    ;
                }
                time = sw.getElapsedMs();
            }
            string lose_sync_report = "";

            pd.initPage();
            do
            {
                lose_sync_report += $"T={(pd[6] - pd[0]).tickToMs():f2}, Send = {pd[3] - pd[2]}, recv = {pd[4] - pd[3]},";
                lose_sync_report += $"a1={pd[2] - pd[1]}, a2 = {pd[5] - pd[4]} ";
                lose_sync_report += $"access-(send+recv)={pd[5] - pd[1]-(pd[4] - pd[2])}\n\n";
            }while (pd.nextPage());



            this.lose_sync_report = lose_sync_report;
            if (eGetMotorStatus != null)
            {
                eGetMotorStatus.Invoke(pg);
            }
        }
Ejemplo n.º 2
0
        public TimeMappingSpeed initSpeedArray()
        {
            int max_speed = (bgd.pid_clu.k0 * 1024 / (bgd.pid_clu.k1 + 1024)) - 10;

            return(TimeMappingSpeed.createTest_1(max_speed));
        }