public ControlPageViewModel( [NotNull] INavigationService navigationService, [NotNull] IMountInfo mountInfo) : base(navigationService) { this._mountInfo = mountInfo; Title = "Control Page"; }
public void SetMountInfo([NotNull] IMountInfo mountInfo) { if (mountInfo is null) { throw new ArgumentNullException(nameof(mountInfo), "Value cannot be null"); } this._mountInfo = mountInfo; }
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; }
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)); }
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); }
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); }
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; }
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; }
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); }
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])); }
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); }
public MountMotion([NotNull] IMountControl mountControl, [NotNull] IMountInfo mountInfo) { this._mountControl = mountControl; this._mountInfo = mountInfo; }
private Task ResetRxBuffer(IMountInfo mountInfo) { byte[] rxBuffer = this._commandBuilder.BuildResetRxBufferCommand(); return(this.SendCommand(mountInfo.WifiMount, rxBuffer)); }
private async Task FinaliseInitialisation(IMountInfo mountInfo, MountAxis axis) { byte[] command = this._commandBuilder.BuildFinaliseInitialisationCommand(axis); await this.SendCommand(mountInfo.WifiMount, command).ConfigureAwait(false); }