Esempio n. 1
0
 public ControlPageViewModel(
     [NotNull] INavigationService navigationService,
     [NotNull] IMountInfo mountInfo)
     : base(navigationService)
 {
     this._mountInfo = mountInfo;
     Title           = "Control Page";
 }
Esempio n. 2
0
        public void SetMountInfo([NotNull] IMountInfo mountInfo)
        {
            if (mountInfo is null)
            {
                throw new ArgumentNullException(nameof(mountInfo), "Value cannot be null");
            }

            this._mountInfo = mountInfo;
        }
Esempio n. 3
0
        public MountControl([NotNull] UdpClient udpClient,
                            [NotNull] IMountControlCommandBuilder commandBuilder,
                            [NotNull] IMountControlCommandParser commandParser,
                            [NotNull] IMountCommonCommandBuilder commonCommandBuilder,
                            [NotNull] IMountCommonCommandParser commonCommandParser,
                            [NotNull] IMountInfo mountInfo) : base(udpClient, commonCommandBuilder, commonCommandParser)
        {
            this._commandBuilder = commandBuilder;

            this._commandParser = commandParser;

            this._mountInfo = mountInfo;
        }
Esempio n. 4
0
        public async Task Handshake(IMountInfo mountInfo)
        {
            mountInfo.MountState = new MountState();

            await this.QueryExtendedStatus(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);


            await this.ResetRxBuffer(mountInfo).ConfigureAwait(false);


            await this.GetMotorBoardVersion(mountInfo).ConfigureAwait(false);


            await this.QueryCountsPerRevolution(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);

            await this.QueryCountsPerRevolution(mountInfo, MountAxis.UpDown).ConfigureAwait(false);


            await this.QueryTimerInteruptFrequency(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);

            await this.QueryTimerInteruptFrequency(mountInfo, MountAxis.UpDown).ConfigureAwait(false);


            await this.QueryHighSpeedRatio(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);

            await this.QueryHighSpeedRatio(mountInfo, MountAxis.UpDown).ConfigureAwait(false);


            await this.QueryAxisPosition(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);

            await this.QueryAxisPosition(mountInfo, MountAxis.UpDown).ConfigureAwait(false);


            await this.FinaliseInitialisation(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);

            await this.FinaliseInitialisation(mountInfo, MountAxis.UpDown).ConfigureAwait(false);


            await this.QueryStatus(mountInfo, MountAxis.LeftRight).ConfigureAwait(false);

            await this.QueryStatus(mountInfo, MountAxis.UpDown).ConfigureAwait(false);

            // Default break steps
            mountInfo.MountState.BreakSteps[(int)MountAxis.LeftRight] = 3500;

            mountInfo.MountState.BreakSteps[(int)MountAxis.UpDown] = 3500;

            Device.BeginInvokeOnMainThread(() => this.ConnectedMounts.Add(mountInfo));
        }
Esempio n. 5
0
        private async Task GetMotorBoardVersion(IMountInfo mountInfo)
        {
            byte[] mcVersionCommand = this._commandBuilder.BuildGetMotorBoardVersionCommand(MountAxis.LeftRight);

            byte[] mcVersionResponse = await this.SendRecieveCommand(mountInfo.WifiMount, mcVersionCommand).ConfigureAwait(false);

            if (!base.ValidateResponse(mcVersionResponse))
            {
                await this.GetMotorBoardVersion(mountInfo).ConfigureAwait(false);

                return;
            }

            mountInfo.MountState.MountControllerVersion = this._commandParser.ParseMotorBoardResponse(mcVersionResponse);
        }
Esempio n. 6
0
        private async Task QueryCountsPerRevolution(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commandBuilder.BuildGetCountsPerRevolutionCommand(axis);

            byte[] response = await this.SendRecieveCommand(mountInfo.WifiMount, command).ConfigureAwait(false);

            if (!base.ValidateResponse(response))
            {
                return;
            }

            double gearRatio = this._commandParser.ParseCountsPerRevolutionRepsonse(response, mountInfo.MountState.MountControllerVersion);

            mountInfo.MountState.StepCoefficients[(int)axis] = new StepCoefficients(gearRatio);
        }
Esempio n. 7
0
        private async Task QueryHighSpeedRatio(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commandBuilder.BuildGetHighSpeedRatioCommand(axis);

            byte[] response = await this.SendRecieveCommand(mountInfo.WifiMount, command).ConfigureAwait(false);

            if (!base.ValidateResponse(response))
            {
                return;
            }

            double ratio = this._commandParser.ParseHighSpeedRatioResponse(response);

            mountInfo.MountState.HighSpeedRatio[(int)axis] = ratio;
        }
Esempio n. 8
0
        private async Task QueryExtendedStatus(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commonCommandBuilder.BuildGetStatusExCommand(axis, "010000");

            byte[] response = await this.SendRecieveCommand(mountInfo.WifiMount, command).ConfigureAwait(false);

            if (!base.ValidateResponse(response))
            {
                return;
            }

            AxisStatusEx statusEx = this._commonCommandParser.ParseExtendedStatusResponse(response);

            mountInfo.MountState.AxesStatusExtended[(int)axis] = statusEx;
        }
Esempio n. 9
0
        private async Task QueryTimerInteruptFrequency(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commandBuilder.BuildGetTimerInterruptFreqCommand(axis);

            byte[] response = await this.SendRecieveCommand(mountInfo.WifiMount, command).ConfigureAwait(false);

            if (!base.ValidateResponse(response))
            {
                return;
            }

            double timerFreq = this._commandParser.ParseTimerInterruptFreqResponse(response);

            mountInfo.MountState.TimerInterruptFrequencies[(int)axis] = timerFreq;

            mountInfo.MountState.MotorInterval[(int)axis] = Conversion.CalculateMotorInterval(mountInfo.MountState.StepCoefficients[(int)axis].FactorRadToStep, timerFreq);
        }
Esempio n. 10
0
        private async Task QueryAxisPosition(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commonCommandBuilder.BuildGetAxisPositionCommand(axis);

            byte[] response = await this.SendRecieveCommand(mountInfo.WifiMount, command).ConfigureAwait(false);

            if (!base.ValidateResponse(response))
            {
                return;
            }

            double steps = this._commonCommandParser.ParseAxisPositionResponse(response);

            mountInfo.MountState.AxisPositions[(int)axis] = Conversion.StepToAngle(mountInfo.MountState.StepCoefficients[(int)axis].FactorStepToRad, steps);

            mountInfo.MountState.AxisSexagesimalAngles[(int)axis] = SexagesimalAngle.FromDouble(Maths.RadToDeg(mountInfo.MountState.AxisPositions[(int)axis]));
        }
Esempio n. 11
0
        private async Task QueryStatus(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commonCommandBuilder.BuildGetStatusCommand(axis);

            byte[] response = await this.SendRecieveCommand(mountInfo.WifiMount, command).ConfigureAwait(false);

            if (!base.ValidateResponse(response))
            {
                return;
            }

            if (response.Length != 5)
            {
                Debug.WriteLine($"Got malformed response to status query {response.Length} bytes");
                return;
            }

            AxisStatus status = this._commonCommandParser.ParseStatusResponse(response);

            mountInfo.MountState.AxesStatus[(int)axis] = status;
        }
        public MainPageViewModel(
            [NotNull] INavigationService navigationService,
            [NotNull] IMountDiscovery mountDiscovery,
            [NotNull] IMountOptions mountOptions,
            [NotNull] IMountInfo mountInfo)
            : base(navigationService)
        {
            Title = "Main Page";


            this.MountDiscovery = mountDiscovery;

            this._mountOptions = mountOptions;

            this._currentAppMountInfo = mountInfo;

            FindMountsAsync = new AsyncCommand(ExecuteFindMountsAsync);

            RestartDiscoveryAsync = new AsyncCommand(ExecuteRestartDiscoveryAsync);

            SelectionChangedCommand = new DelegateCommand(this.OnSelectionChangedCommandExecuted);
        }
Esempio n. 13
0
        public MountMotion([NotNull] IMountControl mountControl, [NotNull] IMountInfo mountInfo)
        {
            this._mountControl = mountControl;

            this._mountInfo = mountInfo;
        }
Esempio n. 14
0
        private Task ResetRxBuffer(IMountInfo mountInfo)
        {
            byte[] rxBuffer = this._commandBuilder.BuildResetRxBufferCommand();

            return(this.SendCommand(mountInfo.WifiMount, rxBuffer));
        }
Esempio n. 15
0
        private async Task FinaliseInitialisation(IMountInfo mountInfo, MountAxis axis)
        {
            byte[] command = this._commandBuilder.BuildFinaliseInitialisationCommand(axis);

            await this.SendCommand(mountInfo.WifiMount, command).ConfigureAwait(false);
        }