Пример #1
0
        public void SetBoardID(CanBoard board)
        {
            _boardID = board;

            if (_servo1 != null)
            {
                _servo1.TorqueAlert -= PanelBoardCanServos_TorqueAlert1;
                _servo2.TorqueAlert -= PanelBoardCanServos_TorqueAlert2;
                _servo3.TorqueAlert -= PanelBoardCanServos_TorqueAlert3;
                _servo4.TorqueAlert -= PanelBoardCanServos_TorqueAlert4;
            }

            _servo1 = AllDevices.CanServos[(ServomoteurID)(((int)_boardID - 1) * 4 + 0)];
            _servo2 = AllDevices.CanServos[(ServomoteurID)(((int)_boardID - 1) * 4 + 1)];
            _servo3 = AllDevices.CanServos[(ServomoteurID)(((int)_boardID - 1) * 4 + 2)];
            _servo4 = AllDevices.CanServos[(ServomoteurID)(((int)_boardID - 1) * 4 + 3)];

            lblTitle.Text  = _boardID.ToString();
            lblServo1.Text = Parse(_servo1.ID);
            lblServo2.Text = Parse(_servo2.ID);
            lblServo3.Text = Parse(_servo3.ID);
            lblServo4.Text = Parse(_servo4.ID);

            if (!Execution.DesignMode)
            {
                _servo1.TorqueAlert += PanelBoardCanServos_TorqueAlert1;
                _servo2.TorqueAlert += PanelBoardCanServos_TorqueAlert2;
                _servo3.TorqueAlert += PanelBoardCanServos_TorqueAlert3;
                _servo4.TorqueAlert += PanelBoardCanServos_TorqueAlert4;
            }
        }
Пример #2
0
        public CanSubConnection(CanConnection baseConnection, CanBoard board)
        {
            _baseConnection   = baseConnection;
            _board            = board;
            ConnectionChecker = new ConnectionChecker(this, 500);
            ConnectionChecker.SendConnectionTest += ConnectionChecker_SendConnectionTest;
            _baseConnection.FrameReceived        += _baseConnection_FrameReceived;

            _name = board.ToString();
        }
Пример #3
0
 private void ShowFramesSender(CanBoard board, bool show)
 {
     lstSender.Items.Remove(board.ToString());
     lstSender.Items.Add(board.ToString(), show);
     Config.CurrentConfig.LogsCanSenders[board] = show;
 }
Пример #4
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";
                }

                CanBoard board    = CanFrameFactory.ExtractBoard(tFrame.Frame);
                CanBoard sender   = CanFrameFactory.ExtractSender(tFrame.Frame, tFrame.IsInputFrame);
                CanBoard receiver = CanFrameFactory.ExtractReceiver(tFrame.Frame, tFrame.IsInputFrame);

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

                bool receiverVisible = Config.CurrentConfig.LogsCanReceivers[receiver];
                bool senderVisible   = Config.CurrentConfig.LogsCanSenders[sender];
                bool functionVisible = Config.CurrentConfig.LogsCanFunctions[CanFrameFactory.ExtractFunction(tFrame.Frame)];

                if (senderVisible && receiverVisible && functionVisible)
                {
                    dgvLog.Rows.Add(_counter, time, sender.ToString(), receiver.ToString(), CanFrameDecoder.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 e)
            {
                dgvLog.Rows.Add(_counter, time, "?", "?", "Inconnu !", tFrame.Frame.ToString());
                dgvLog.Rows[dgvLog.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Red;
            }

            _counter++;
            _previousTime = tFrame.Date;
        }