Example #1
0
        public SpeedTestLogic(ICommunication communication, PanTiltControlType panTiltControlType, AxisType axisType)
        {
            this._axisType = axisType;
            if (panTiltControlType == PanTiltControlType.Eneo)
            {
                this._panTiltControl = new EneoPanTiltControl(communication);
            }
            else
            {
                this._panTiltControl = new AlturosPanTiltControl(communication);
            }
            this._panTiltControl.PositionChanged += OnPositionChanged;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.Start();
        }
        public SpeedDetectionLogicPan(ICommunication communication, PanTiltControlType panTiltControlType)
        {
            this._communication = communication;
            if (panTiltControlType == PanTiltControlType.Eneo)
            {
                this._panTiltControl = new EneoPanTiltControl(this._communication);
            }
            else
            {
                this._panTiltControl = new AlturosPanTiltControl(this._communication);
            }

            this._panTiltControl.PositionChanged += OnPositionChanged;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.Start();
        }
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            var connectionType     = (CommunicationType)this.comboBoxCommunicationType.SelectedItem;
            var panTiltControlType = (PanTiltControlType)this.comboBoxPanTiltControl.SelectedItem;

            this.PanTiltControlType = panTiltControlType;

            try
            {
                switch (connectionType)
                {
                case CommunicationType.SerialPort:
                    this.Communication = new SerialPortCommunication(this.textBoxValue.Text);
                    break;

                case CommunicationType.NetworkTcp:
                    this.Communication = new TcpNetworkCommunication(new IPEndPoint(IPAddress.Parse(this.textBoxValue.Text), 4003));
                    break;

                case CommunicationType.NetworkUdp:
                    var port = 4003;
                    if (panTiltControlType == PanTiltControlType.Alturos)
                    {
                        port = 5555;
                    }

                    this.Communication = new UdpNetworkCommunication(IPAddress.Parse(this.textBoxValue.Text), port, port);
                    break;

                default:
                    break;
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Cannot connect {exception}", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        public Main()
        {
            this.InitializeComponent();
            this._bindingSource.DataSource   = this._speedReports;
            this.dataGridViewAxis.DataSource = this._bindingSource;

            this.comboBoxAxisType.DataSource    = Enum.GetValues(typeof(AxisType));
            this.comboBoxAxisType.SelectedIndex = 0;
            this.buttonAbortQuickCheck.Enabled  = false;

            var dialog = new CommunicationDialog
            {
                StartPosition = FormStartPosition.CenterScreen
            };
            var dialogResult = dialog.ShowDialog(this);

            if (dialogResult == DialogResult.OK)
            {
                this._communication      = dialog.Communication;
                this._panTiltControlType = dialog.PanTiltControlType;
            }
        }