Skip to content

Commit

Permalink
Merge pull request #11 from OpenAstroTech/tcp-fixes
Browse files Browse the repository at this point in the history
V0.9.9.27 Updates
  • Loading branch information
ClutchplateDude authored Feb 27, 2021
2 parents bfc2433 + fa6d6bc commit a435499
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 6 deletions.
17 changes: 14 additions & 3 deletions OATCommunications/CommunicationHandlers/TcpCommunicationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace OATCommunications.CommunicationHandlers
{
{
public class TcpCommunicationHandler : CommunicationHandler
{
private IPAddress _ip;
Expand Down Expand Up @@ -50,7 +51,7 @@ public TcpCommunicationHandler(IPAddress ip, int port)
}

protected override void RunJob(Job job)
{
{
if (_client == null)
{
Log.WriteLine($"TCP: Configuration error, IP [{_ip}] or port [{_port}] is invalid.");
Expand Down Expand Up @@ -147,11 +148,21 @@ public override bool Connected

public override void Disconnect()
{
if (_client != null && _client.Connected)
if (_client != null)
{
Log.WriteLine("TCP: Stopping Jobs processor.");
StopJobsProcessor();

Log.WriteLine("TCP: Port is open, sending shutdown command [:Qq#]");
ManualResetEvent waitQuit = new ManualResetEvent(false);
var quitJob = new Job(":Qq#", ResponseType.NoResponse, (s) => { waitQuit.Set(); });
RunJob(quitJob);
waitQuit.WaitOne();

Log.WriteLine("TCP: Closing port.");
_client.Close();
_client = null;
Log.WriteLine("TCP: Disconnected...");
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions OATControl/DlgChooseOat.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,19 @@ private async void ProcessStateMachine(object sender, EventArgs e)
{
ShowManualLocation = true;
CurrentStep = Steps.ConfirmLocation;
// Let's get teh coordinate stored on the OAT
var locDoneEvent = new AutoResetEvent(false);
bool gotLoc = false;
float lat = 0, lng = 0;
_sendCommand(":Gt#,#", (a) => { gotLoc = a.Success && TryParseLatLong(a.Data, ref lat); });
_sendCommand(":Gg#,#", (a) => { gotLoc = gotLoc && a.Success && TryParseLatLong(a.Data, ref lng); locDoneEvent.Set(); });
locDoneEvent.WaitOne();
if (gotLoc)
{
Latitude = lat;
Longitude = 180.0f - lng;
}
break;
}
}
break;
Expand Down
3 changes: 1 addition & 2 deletions OATControl/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@
<Button Grid.Row="4" Grid.Column="2" Content="Settings" Margin="0,2" HorizontalAlignment="Right" Padding="15,0" IsEnabled="{Binding MountConnected}" Style="{StaticResource AccentedSquareButtonStyle}" Command="{Binding ShowSettingsCommand}"/>
<Button Grid.Row="5" Grid.Column="2" Content="Log Files" Margin="0,2" HorizontalAlignment="Right" Padding="15,0" Style="{StaticResource AccentedSquareButtonStyle}" Command="{Binding ShowLogFolderCommand}" />


<Grid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="3" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
Expand All @@ -554,7 +553,7 @@
<TextBlock Grid.Row="0" Grid.Column="1" Text="Mount" Style="{StaticResource TextBlockHeading}" Margin="0,10,0,0" HorizontalAlignment="Right"/>
<Button Grid.Column="2" Margin="10,12,0,0" Style="{StaticResource AccentedSquareButtonStyle}" Command="{Binding ConnectScopeCommand}" Content="{Binding ConnectCommandString}"/>
</Grid>
<TextBlock Grid.Row="7" Grid.Column="2" Text="{Binding ScopeName}" Style="{StaticResource TextBlockLabel}" Margin="0,2,0,0" HorizontalAlignment="Right" />
<TextBlock Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding ScopeName}" Style="{StaticResource TextBlockLabel}" Margin="0,2,0,0" HorizontalAlignment="Right" />
</Grid>

</Grid>
Expand Down
2 changes: 1 addition & 1 deletion OATControl/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.9.26")]
[assembly: AssemblyVersion("0.9.9.27")]
[assembly: AssemblyFileVersion("1.0.0.0")]
10 changes: 10 additions & 0 deletions OATControl/SettingsDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public SettingsDialog(MountVM mount)
dispatchTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(333), DispatcherPriority.Normal, OnTimer, Dispatcher.CurrentDispatcher);
_mount = mount;
this.DataContext = _mount;
if ((_mount.RAStepsPerDegree < 10) || (_mount.DECStepsPerDegree < 10))
{
MessageBox.Show(
"It seems that the steps for RA and DEC have been incorrectly configured. It is strongly suggested to do a Factory Reset on the next screen.",
"Invalid EEPROM Data",
MessageBoxButton.OK,
MessageBoxImage.Exclamation
);
}

_mount.RAStepsPerDegreeEdit = _mount.RAStepsPerDegree;
_mount.DECStepsPerDegreeEdit = _mount.DECStepsPerDegree;
InitializeComponent();
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ To install any of these, click on the latest release under Releases to the right

Change Log:
===========
**V0.9.9.27 - Updates**
- TCP connections did not correctly shutdown the communications thread on disconnect. This could leave zombie OATcontrol processes on the machine.
- With no GPS, the lat long was not retrieved from OAT as the default for manual entry. It is now.
- Detected the incorrect RA/DEC steps in the Settings and pop up a message box suggesting factory reset.
- Fixed label width at bottom of main UI.

**V0.9.9.26 - Updates**
- Added label to slew rate boxes.
- Added log folder link to main UI.
- Added log file flushing in case of crash.

**V0.9.9.25 - Updates**
- Added Slewrate controls to Mini controller, bound to 1, 2, 3, and 4 keys.

Expand Down

0 comments on commit a435499

Please sign in to comment.