Exemple #1
0
        public override List <int>[] DiagnosticLine(int distance, SensAR sens)
        {
            _lastPidTest    = new List <int> [2];
            _lastPidTest[0] = new List <int>();
            _lastPidTest[1] = new List <int>();

            _lockFrame[UdpFrameFunction.FinDeplacement] = new Semaphore(0, int.MaxValue);

            Frame frame = UdpFrameFactory.Deplacer(sens, distance, this);

            _asserConnection.SendMessage(frame);

            frame = UdpFrameFactory.DemandePositionsCodeurs(this);

            while (!_lockFrame[UdpFrameFunction.FinDeplacement].WaitOne(0))
            {
                _asserConnection.SendMessage(frame);
                Thread.Sleep(30);
            }

            List <int>[] output = new List <int> [2];
            output[0] = new List <int>(_lastPidTest[0]);
            output[1] = new List <int>(_lastPidTest[1]);

            return(output);
        }
Exemple #2
0
        public override void MoveBackward(int distance, bool wait = true)
        {
            base.MoveBackward(distance, wait);

            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement] = new Semaphore(0, int.MaxValue);
            }

            IsInLineMove = true;

            Frame frame;

            if (distance < 0)
            {
                frame = UdpFrameFactory.Deplacer(SensAR.Avant, -distance, this);
            }
            else
            {
                frame = UdpFrameFactory.Deplacer(SensAR.Arriere, distance, this);
            }

            _asserConnection.SendMessage(frame);

            Historique.AjouterAction(new ActionRecule(this, distance));

            if (wait)
            {
                //if (!SemaphoresTrame[FrameFunction.FinDeplacement].WaitOne((int)SpeedConfig.LineDuration(distance).TotalMilliseconds))
                //    Thread.Sleep(1000); // Tempo de secours, on a jamais reçu la fin de trajectoire après la fin du délai théorique
                _lockFrame[UdpFrameFunction.FinDeplacement].WaitOne();
            }
        }
Exemple #3
0
        public override List <double>[] DiagnosticCpuPwm(int pointsCount)
        {
            _lastRecMoveLoad = new List <double>();
            _lastPwmLeft     = new List <double>();
            _lastPwmRight    = new List <double>();

            Frame frame = UdpFrameFactory.DemandeCpuPwm(this);

            while (_lastRecMoveLoad.Count <= pointsCount)
            {
                _asserConnection.SendMessage(frame);
                Thread.Sleep(30);
            }

            // Supprime d'éventuelles valeurs supplémentaires
            while (_lastRecMoveLoad.Count > pointsCount)
            {
                _lastRecMoveLoad.RemoveAt(_lastRecMoveLoad.Count - 1);
            }

            while (_lastPwmLeft.Count > pointsCount)
            {
                _lastPwmLeft.RemoveAt(_lastPwmLeft.Count - 1);
            }

            while (_lastPwmRight.Count > pointsCount)
            {
                _lastPwmRight.RemoveAt(_lastPwmRight.Count - 1);
            }

            return(new List <double>[3] {
                _lastRecMoveLoad, _lastPwmLeft, _lastPwmRight
            });
        }
Exemple #4
0
 private void SpeedConfig_ParamChange(bool lineAccelChange, bool lineDecelChange, bool lineSpeedChange, bool pivotAccelChange, bool pivotDecelChange, bool pivotSpeedChange)
 {
     if (lineSpeedChange)
     {
         Frame frame = UdpFrameFactory.VitesseLigne(SpeedConfig.LineSpeed, this);
         _asserConnection.SendMessage(frame);
         Historique.AjouterAction(new ActionVitesseLigne(this, SpeedConfig.LineSpeed));
     }
     if (lineAccelChange || lineDecelChange)
     {
         Frame frame = UdpFrameFactory.AccelLigne(SpeedConfig.LineAcceleration, SpeedConfig.LineDeceleration, this);
         _asserConnection.SendMessage(frame);
         Historique.AjouterAction(new ActionAccelerationLigne(this, SpeedConfig.LineAcceleration, SpeedConfig.LineDeceleration));
     }
     if (pivotSpeedChange)
     {
         Frame frame = UdpFrameFactory.VitessePivot(SpeedConfig.PivotSpeed, this);
         _asserConnection.SendMessage(frame);
         Historique.AjouterAction(new ActionVitessePivot(this, SpeedConfig.PivotSpeed));
     }
     if (pivotAccelChange || pivotDecelChange)
     {
         Frame frame = UdpFrameFactory.AccelPivot(SpeedConfig.PivotAcceleration, this);
         _asserConnection.SendMessage(frame);
         Historique.AjouterAction(new ActionAccelerationPivot(this, SpeedConfig.PivotAcceleration, SpeedConfig.PivotDeceleration));
     }
 }
Exemple #5
0
        public override void SetMotorReset(MotorID motor)
        {
            base.SetMotorReset(motor);

            Frame trame = UdpFrameFactory.MoteurResetPosition(_boardMotor[motor], motor);

            Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame);
        }
Exemple #6
0
        public override void SetMotorSpeed(MotorID motor, SensGD sens, int speed)
        {
            base.SetMotorSpeed(motor, sens, speed);

            Frame trame = UdpFrameFactory.MoteurVitesse(_boardMotor[motor], motor, sens, speed);

            Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame);
        }
Exemple #7
0
        public override void SetMotorStop(MotorID motor, StopMode mode)
        {
            base.SetMotorStop(motor, mode);

            Frame trame = UdpFrameFactory.MoteurStop(_boardMotor[motor], motor, mode);

            Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame);
        }
Exemple #8
0
        public override void SetMotorAcceleration(MotorID motor, int acceleration)
        {
            base.SetMotorAcceleration(motor, acceleration);

            Frame trame = UdpFrameFactory.MoteurAcceleration(_boardMotor[motor], motor, acceleration);

            Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(trame);
        }
Exemple #9
0
        public override void SetActuatorOnOffValue(ActuatorOnOffID actuator, bool on)
        {
            ActuatorOnOffState[actuator] = on;

            Frame frame = UdpFrameFactory.ActionneurOnOff(_boardActuatorOnOff[actuator], actuator, on);

            Connections.UDPBoardConnection[_boardActuatorOnOff[actuator]].SendMessage(frame);

            Historique.AjouterAction(new ActionOnOff(this, actuator, on));
        }
Exemple #10
0
        public override void SetAsservOffset(Position newPosition)
        {
            Position.Copy(newPosition);
            newPosition.Angle = -newPosition.Angle; // Repère angulaire du robot inversé

            Frame frame = UdpFrameFactory.OffsetPos(newPosition, this);

            _asserConnection.SendMessage(frame);

            OnPositionChanged(Position);
        }
Exemple #11
0
        public Position ReadPosition()
        {
            _lockFrame[UdpFrameFunction.AsserRetourPositionCodeurs] = new Semaphore(0, int.MaxValue);

            Frame frame = UdpFrameFactory.DemandePosition(this);

            _asserConnection.SendMessage(frame);

            _lockFrame[UdpFrameFunction.AsserRetourPositionXYTeta].WaitOne(100);

            return(Position);
        }
Exemple #12
0
        public override void Stop(StopMode mode = StopMode.Smooth)
        {
            AsserEnable = (mode != StopMode.Freely);

            IsInLineMove = false;

            Frame frame = UdpFrameFactory.Stop(mode, this);

            _asserConnection.SendMessage(frame);

            Historique.AjouterAction(new ActionStop(this, mode));
        }
Exemple #13
0
        public override String ReadLidarMeasure(LidarID lidar, int timeout, out Position refPosition)
        {
            _lastLidarMeasure = "";

            _lockFrame[UdpFrameFunction.ReponseLidar] = new Semaphore(0, int.MaxValue);
            Connections.ConnectionMove.SendMessage(UdpFrameFactory.DemandeMesureLidar(lidar));
            _lockFrame[UdpFrameFunction.ReponseLidar].WaitOne(timeout);

            refPosition = _lastLidarPosition;

            return(_lastLidarMeasure);
        }
Exemple #14
0
        private void mnuHideSameTypeFrames_Click(object sender, EventArgs e)
        {
            if (dgvLog.SelectedRows.Count >= 1)
            {
                foreach (DataGridViewRow line in dgvLog.SelectedRows)
                {
                    TimedFrame tFrame = GetFrameFromLine(line);
                    ShowFrameFunction(UdpFrameFactory.ExtractBoard(tFrame.Frame), UdpFrameFactory.ExtractFunction(tFrame.Frame), false);
                }

                DisplayLog();
            }
        }
Exemple #15
0
        private void mnuHideSameReceiverFrames_Click(object sender, EventArgs e)
        {
            if (dgvLog.SelectedRows.Count >= 1)
            {
                foreach (DataGridViewRow line in dgvLog.SelectedRows)
                {
                    TimedFrame tFrame = GetFrameFromLine(line);
                    ShowFramesReceiver(UdpFrameFactory.ExtractReceiver(tFrame.Frame, tFrame.IsInputFrame), false);
                }

                DisplayLog();
            }
        }
Exemple #16
0
 void timerTestConnexion_Tick(object sender, EventArgs e)
 {
     if (boxMove.Checked)
     {
         Frame trame = UdpFrameFactory.TestConnexion(Board.RecMove);
         Connections.ConnectionMove.SendMessage(trame);
     }
     if (boxIO.Checked)
     {
         Frame trame = UdpFrameFactory.TestConnexion(Board.RecIO);
         Connections.ConnectionIO.SendMessage(trame);
     }
 }
Exemple #17
0
        private void mnuHideSameBoardFrames_Click(object sender, EventArgs e)
        {
            if (dgvLog.SelectedRows.Count >= 1)
            {
                foreach (DataGridViewRow line in dgvLog.SelectedRows)
                {
                    Board board = UdpFrameFactory.ExtractBoard(GetFrameFromLine(line).Frame);
                    ShowFramesReceiver(board, false);
                    ShowFramesSender(board, false);
                }

                DisplayLog();
            }
        }
Exemple #18
0
        private void btnDebug_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    val = Convert.ToInt16(btn.Tag);

            if (boxMove.Checked)
            {
                Frame trame = UdpFrameFactory.Debug(Board.RecMove, val);
                Connections.ConnectionMove.SendMessage(trame);
            }
            if (boxIO.Checked)
            {
                Frame trame = UdpFrameFactory.Debug(Board.RecIO, val);
                Connections.ConnectionIO.SendMessage(trame);
            }
        }
Exemple #19
0
        public override void PolarTrajectory(SensAR sens, List <RealPoint> points, bool wait = true)
        {
            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement] = new Semaphore(0, int.MaxValue);
            }

            Frame frame = UdpFrameFactory.TrajectoirePolaire(sens, points, this);

            _asserConnection.SendMessage(frame);

            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement].WaitOne();
            }
        }
Exemple #20
0
        public override void ReadNumericPins(Board board, bool wait = true)
        {
            if (wait)
            {
                _lockFrame[UdpFrameFunction.RetourValeursNumeriques] = new Semaphore(0, int.MaxValue);
            }

            Frame frame = UdpFrameFactory.DemandeValeursNumeriques(board);

            Connections.UDPBoardConnection[board].SendMessage(frame);

            if (wait)
            {
                _lockFrame[UdpFrameFunction.RetourValeursNumeriques].WaitOne(100);
            }
        }
Exemple #21
0
        public override void Turn(SensAR sensAr, SensGD sensGd, int radius, AngleDelta angle, bool wait = true)
        {
            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement] = new Semaphore(0, int.MaxValue);
            }

            Frame frame = UdpFrameFactory.Virage(sensAr, sensGd, radius, angle, this);

            _asserConnection.SendMessage(frame);

            Historique.AjouterAction(new ActionVirage(this, radius, angle, sensAr, sensGd));

            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement].WaitOne();
            }
        }
Exemple #22
0
        public override bool ReadSensorOnOff(SensorOnOffID sensor, bool wait = true)
        {
            if (wait)
            {
                _lockSensorOnOff[sensor] = new Semaphore(0, int.MaxValue);
            }

            Frame t = UdpFrameFactory.DemandeCapteurOnOff(_boardSensorOnOff[sensor], sensor);

            Connections.UDPBoardConnection[_boardSensorOnOff[sensor]].SendMessage(t);

            if (wait)
            {
                _lockSensorOnOff[sensor].WaitOne(100);
            }

            return(SensorsOnOffValue[sensor]);
        }
Exemple #23
0
        public override void SetMotorAtOrigin(MotorID motor, bool wait)
        {
            base.SetMotorAtOrigin(motor);

            if (wait)
            {
                _lockMotor[motor] = new Semaphore(0, int.MaxValue);
            }

            Frame frame = UdpFrameFactory.MoteurOrigin(_boardMotor[motor], motor);

            Connections.UDPBoardConnection[_boardMotor[motor]].SendMessage(frame);

            if (wait)
            {
                _lockMotor[motor].WaitOne(30000);
            }
        }
Exemple #24
0
        public override void Init()
        {
            Historique = new Historique(IDRobot);

            Connections.ConnectionCan.FrameReceived += ReceptionCanMessage;

            _asserConnection.FrameReceived += ReceptionUdpMessage;

            if (this == Robots.MainRobot)
            {
                Connections.ConnectionIO.FrameReceived += ReceptionUdpMessage;
            }

            //Connections.ConnectionsCan[CanBoard.CanAlim].FrameReceived += ReceptionCanMessage;

            if (this == Robots.MainRobot)
            {
                if (GameBoard.MyColor == GameBoard.ColorLeftBlue)
                {
                    Position = new Position(0, new RealPoint(240, 1000));
                }
                else
                {
                    Position = new Position(180, new RealPoint(3000 - 240, 1000));
                }
            }
            else
            {
                if (GameBoard.MyColor == GameBoard.ColorLeftBlue)
                {
                    Position = new Position(0, new RealPoint(480, 1000));
                }
                else
                {
                    Position = new Position(180, new RealPoint(3000 - 480, 1000));
                }
            }

            PositionTarget = null; //TODO2018 Init commun à la simu

            PositionsHistorical = new List <Position>();
            _asserConnection.SendMessage(UdpFrameFactory.DemandePositionContinue(50, this));
        }
Exemple #25
0
        public override void Recalibration(SensAR sens, bool wait = true, bool sendOffset = false)
        {
            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement] = new Semaphore(0, int.MaxValue);
            }

            Frame frame = UdpFrameFactory.Recallage(sens, this);

            _asserConnection.SendMessage(frame);

            Historique.AjouterAction(new ActionRecallage(this, sens));

            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement].WaitOne();
            }

            base.Recalibration(sens, wait, sendOffset);
        }
Exemple #26
0
        public override void PivotRight(AngleDelta angle, bool wait = true)
        {
            base.PivotRight(angle, wait);

            if (wait)
            {
                _lockFrame[UdpFrameFunction.FinDeplacement] = new Semaphore(0, int.MaxValue);
            }

            Frame frame = UdpFrameFactory.Pivot(SensGD.Droite, angle, this);

            _asserConnection.SendMessage(frame);

            Historique.AjouterAction(new ActionPivot(this, angle, SensGD.Droite));

            if (wait)
            {
                //if (!SemaphoresTrame[FrameFunction.FinDeplacement].WaitOne((int)SpeedConfig.PivotDuration(angle, Entraxe).TotalMilliseconds))
                //    Thread.Sleep(1000); // Tempo de secours, on a jamais reçu la fin de trajectoire après la fin du délai théorique
                _lockFrame[UdpFrameFunction.FinDeplacement].WaitOne();
            }
        }
Exemple #27
0
        public override List <int>[] DiagnosticPID(int steps, SensAR sens, int pointsCount)
        {
            _lastPidTest    = new List <int> [2];
            _lastPidTest[0] = new List <int>();
            _lastPidTest[1] = new List <int>();

            Frame frame = UdpFrameFactory.EnvoiConsigneBrute(steps, sens, this);

            _asserConnection.SendMessage(frame);

            frame = UdpFrameFactory.DemandePositionsCodeurs(this);
            while (_lastPidTest[0].Count < pointsCount)
            {
                _asserConnection.SendMessage(frame);
                Thread.Sleep(30);
            }

            List <int>[] output = new List <int> [2];
            output[0] = _lastPidTest[0].GetRange(0, pointsCount);
            output[1] = _lastPidTest[1].GetRange(0, pointsCount);

            return(output);
        }
Exemple #28
0
        public void DisplayFrame(TimedFrame tFrame)
        {
            String time = "";

            try
            {
                if (rdoTimeAbsolute.Checked)
                {
                    time = tFrame.Date.ToString("hh:mm:ss:fff");
                }
                if (rdoTimeFromStart.Checked)
                {
                    time = (tFrame.Date - _startTime).ToString(@"hh\:mm\:ss\:fff");
                }
                if (rdoTimeFromPrev.Checked)
                {
                    time = ((int)(tFrame.Date - _previousTime).TotalMilliseconds).ToString() + " ms";
                }
                if (rdoTimeFromPrevDisplay.Checked)
                {
                    time = ((int)(tFrame.Date - _previousDisplayTime).TotalMilliseconds).ToString() + " ms";
                }

                Board            board    = UdpFrameFactory.ExtractBoard(tFrame.Frame);
                Board            sender   = UdpFrameFactory.ExtractSender(tFrame.Frame, tFrame.IsInputFrame);
                Board            receiver = UdpFrameFactory.ExtractReceiver(tFrame.Frame, tFrame.IsInputFrame);
                UdpFrameFunction func     = UdpFrameFactory.ExtractFunction(tFrame.Frame);

                if (board == Board.PC)
                {
                    throw new Exception();
                }

                bool receiverVisible = Config.CurrentConfig.LogsDestinataires[receiver];
                bool senderVisible   = Config.CurrentConfig.LogsExpediteurs[sender];
                bool functionVisible = (_configFunctions[_lstFunctions[board]][func]);

                if (senderVisible && receiverVisible && functionVisible)
                {
                    dgvLog.Rows.Add(_counter, time, sender.ToString(), receiver.ToString(), UdpFrameDecoder.Decode(tFrame.Frame), tFrame.Frame.ToString());
                    _previousDisplayTime = tFrame.Date;

                    if (rdoColorByBoard.Checked)
                    {
                        dgvLog.Rows[dgvLog.Rows.Count - 1].DefaultCellStyle.BackColor = _boardColor[board];
                    }
                    else if (rdoColorByReceiver.Checked)
                    {
                        dgvLog.Rows[dgvLog.Rows.Count - 1].DefaultCellStyle.BackColor = _boardColor[receiver];
                    }
                    else if (rdoColorBySender.Checked)
                    {
                        dgvLog.Rows[dgvLog.Rows.Count - 1].DefaultCellStyle.BackColor = _boardColor[sender];
                    }
                }
            }
            catch (Exception)
            {
                dgvLog.Rows.Add(_counter, time, "?", "?", "Inconnu !", tFrame.Frame.ToString());
                dgvLog.Rows[dgvLog.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Red;
            }

            _counter++;
            _previousTime = tFrame.Date;
        }
Exemple #29
0
        /// <summary>
        /// Anti scintillement
        /// </summary>
        //protected override CreateParams CreateParams
        //{
        //    get
        //    {
        //        CreateParams cp = base.CreateParams;
        //        cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
        //        return cp;
        //    }
        //}

        public FenGoBot(string[] args)
        {
            InitializeComponent();
            timerSauvegarde          = new Timer();
            timerSauvegarde.Interval = 10000;
            timerSauvegarde.Tick    += timerSauvegarde_Tick;
            timerSauvegarde.Start();

            if (!Execution.DesignMode)
            {
                panelGrosRobot.Init();

                if (Screen.PrimaryScreen.Bounds.Width <= 1024)
                {
                    WindowState              = FormWindowState.Maximized;
                    FormBorderStyle          = FormBorderStyle.None;
                    tabControl.SelectedTab   = tabPandaNew;
                    tabControl.Location      = new Point(-14, -50);
                    tabControl.Width        += 100;
                    tabControl.Height       += 100;
                    panelConnexions.Visible  = false;
                    lblSimulation.Visible    = false;
                    switchBoutonSimu.Visible = false;
                    btnFenetre.Visible       = false;
                }
                else
                {
                    WindowState     = FormWindowState.Normal;
                    FormBorderStyle = FormBorderStyle.FixedSingle;
                }

                switchBoutonSimu.Value = Robots.Simulation;

                tabPrecedent = new Dictionary <TabPage, TabPage>();
                tabPrecedent.Add(tabControl.TabPages[0], null);
                for (int i = 1; i < tabControl.Controls.Count; i++)
                {
                    tabPrecedent.Add(tabControl.TabPages[i], (tabControl.TabPages[i - 1]));
                }

                List <String> fichiersElog = new List <string>();
                List <String> fichiersTlog = new List <string>();

                foreach (String chaine in args)
                {
                    if (Path.GetExtension(chaine) == ".elog")
                    {
                        fichiersElog.Add(chaine);
                    }
                    if (Path.GetExtension(chaine) == FramesLog.FileExtension)
                    {
                        fichiersTlog.Add(chaine);
                    }
                }

                if (fichiersElog.Count > 0)
                {
                    foreach (String fichier in fichiersElog)
                    {
                        panelLogsEvents.ChargerLog(fichier);
                    }
                    panelLogsEvents.Afficher();

                    if (fichiersTlog.Count == 0)
                    {
                        tabControl.SelectedTab     = tabLogs;
                        tabControlLogs.SelectedTab = tabLogEvent;
                    }
                }

                if (fichiersTlog.Count > 0)
                {
                    foreach (String fichier in fichiersTlog)
                    {
                        pnlLogFrames.LoadLog(fichier);
                    }
                    pnlLogFrames.DisplayLog();

                    tabControl.SelectedTab     = tabLogs;
                    tabControlLogs.SelectedTab = tabLogUDP;
                }

                Instance = this;

                GameBoard.MyColor = GameBoard.ColorLeftBlue;

                Connections.ConnectionMove.SendMessage(UdpFrameFactory.DemandeCouleurEquipe());
            }

            Connections.StartConnections();

            SplashScreen.CloseSplash(-1);

            pnlPower.StartGraph();

            pnlNumericIO.SetBoard(Board.RecIO);
            pnlNumericMove.SetBoard(Board.RecMove);

            panelTable.StartDisplay();

            _pagesInWindow = new List <TabPage>();

            this.Text = "GoBot 2020 - Beta";
        }
Exemple #30
0
 /// <summary>
 /// Envoie un teste de connexion UDP à une connexion UDP
 /// </summary>
 /// <param name="sender">Connexion à laquelle envoyer le test</param>
 private static void ConnexionCheck_SendConnectionTestUDP(Connection sender)
 {
     sender.SendMessage(UdpFrameFactory.TestConnexion(GetUDPBoardByConnection(sender)));
 }