public SpeedTestLogic(ICommunication communication, AxisType axisType)
        {
            this._axisType       = axisType;
            this._panTiltControl = new EneoPanTiltControl(communication);
            this._panTiltControl.PositionChanged += OnPositionChanged;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.Start();
        }
        public SpeedDetectionLogicPan(ICommunication communication)
        {
            this._communication  = communication;
            this._panTiltControl = new EneoPanTiltControl(this._communication);
            this._panTiltControl.PositionChanged += OnPositionChanged;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.Start();
        }
        public void SetPanTiltControl(IPanTiltControl panTiltControl)
        {
            this._panTiltControl  = panTiltControl;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.PositionChanged += PanTiltPositionChanged;
            this._panTiltControl.LimitChanged    += PanTiltLimitChanged;

            this.CheckPtLimitAsync().GetAwaiter().GetResult();
        }
        public void SetPanTiltControl(IPanTiltControl panTiltControl)
        {
            this._panTiltControl  = panTiltControl;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.PositionChanged += PanTiltPositionChanged;
            this._panTiltControl.LimitChanged    += PanTiltLimitChanged;

            this.CheckPtLimit();
        }
Beispiel #5
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();
        }
Beispiel #7
0
 public void SetPanTiltControl(IPanTiltControl panTiltControl)
 {
     this._panTiltControl = panTiltControl;
 }
Beispiel #8
0
        private async Task StartPanTiltCommunication()
        {
            if (string.IsNullOrEmpty(this._deviceConfiguration.PanTiltIpAddress))
            {
                return;
            }

            try
            {
                switch (this._deviceConfiguration.CommunicationType)
                {
                case CommunicationType.NetworkTcp:
                    this._communication = new TcpNetworkCommunication(new IPEndPoint(IPAddress.Parse(this._deviceConfiguration.PanTiltIpAddress), 4003));
                    break;

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

                    this._communication = new UdpNetworkCommunication(IPAddress.Parse(this._deviceConfiguration.PanTiltIpAddress), port, port);
                    break;

                case CommunicationType.SerialPort:
                    this._communication = new SerialPortCommunication(this._deviceConfiguration.ComPort);
                    break;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Cannot initialize communication, error:{exception.ToString()}", "Communication error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this._communication.SendData    += this.CommunicationSendData;
            this._communication.ReceiveData += this.CommunicationReceiveData;

            using (var firmwareReader = new FirmwareReader(this._communication))
            {
                this.labelFirmware.Invoke(o => o.Text = $"Firmware: {firmwareReader.Firmware}");
                await Task.Delay(100).ConfigureAwait(false);
            }

            switch (this._deviceConfiguration.PanTiltControlType)
            {
            case PanTiltControlType.Alturos:
                this._panTiltControl = new AlturosPanTiltControl(this._communication);
                break;

            case PanTiltControlType.Eneo:
                this._panTiltControl = new EneoPanTiltControl(this._communication);
                break;
            }
            this._panTiltControl.PositionChanged += OnPositionChanged;
            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.Start();
            this.SetSmoothing(100, 50);

            Thread.Sleep(500);
            this.GetLimitInfos();
        }
Beispiel #9
0
        private async Task StartPanTiltCommunication()
        {
            if (string.IsNullOrEmpty(this._deviceConfiguration.PanTiltIpAddress))
            {
                return;
            }

            try
            {
                switch (this._deviceConfiguration.CommunicationType)
                {
                case CommunicationType.NetworkTcp:
                    this._communication = new TcpNetworkCommunication(new IPEndPoint(IPAddress.Parse(this._deviceConfiguration.PanTiltIpAddress), 4003));
                    break;

                case CommunicationType.NetworkUdp:
                    if (this._deviceConfiguration.PanTiltControlType == PanTiltControlType.Alturos)
                    {
                        this._communication = new UdpNetworkCommunication(IPAddress.Parse(this._deviceConfiguration.PanTiltIpAddress), 5555);
                    }
                    else
                    {
                        this._communication = new UdpNetworkCommunication(IPAddress.Parse(this._deviceConfiguration.PanTiltIpAddress), 4003, 4003);
                    }

                    break;

                case CommunicationType.SerialPort:
                    this._communication = new SerialPortCommunication(this._deviceConfiguration.ComPort);
                    break;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Cannot initialize communication, error:{exception.ToString()}", "Communication error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this._communication.SendData    += this.CommunicationSendData;
            this._communication.ReceiveData += this.CommunicationReceiveData;

            switch (this._deviceConfiguration.PanTiltControlType)
            {
            case PanTiltControlType.Alturos:
                this.mainTabControl.TabPages.Remove(this.tabPageEneo);
                this._panTiltControl = new AlturosPanTiltControl(this._communication);
                this.communicationHistoryControl1.SetTranslator(new AlturosFeedbackTranslator());
                break;

            case PanTiltControlType.Eneo:
                this.mainTabControl.TabPages.Remove(this.tabPageAlturos);
                this._panTiltControl = new EneoPanTiltControl(this._communication);
                this.communicationHistoryControl1.SetTranslator(new EneoFeedbackTranslator());
                break;
            }

            if (this._panTiltControl is IFirmwareReader firmwareReader)
            {
                var firmware = await firmwareReader.GetFirmwareAsync();

                this.labelFirmware.Invoke(o => o.Text = $"Firmware: {firmware}");
            }
            else
            {
                this.labelFirmware.Invoke(o => o.Text = $"Cannot get firmware info");
            }

            this._panTiltControl.PositionChanged            += OnPositionChanged;
            this._panTiltControl.LimitChanged               += OnLimitChanged;
            this._panTiltControl.NoPositionFeedbackReceived += NoPositionFeedbackReceived;

            this._positionChecker = new PositionChecker(this._panTiltControl);

            this._panTiltControl.Start();

            Thread.Sleep(500);
            this.GetLimitInfos();
        }
Beispiel #10
0
 public PositionChecker(IPanTiltControl panTiltControl, bool debug = false)
 {
     this._panTiltControl = panTiltControl;
     this._debug          = false;
 }
Beispiel #11
0
 public void SetPanTiltControl(IPanTiltControl panTiltControl)
 {
     this._panTiltControl = panTiltControl;
     this._panTiltControl.PositionChanged += PositionChanged;
     this._positionChecker = new PositionChecker(this._panTiltControl);
 }