Skip to content

Commit

Permalink
Increase timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocipriani01 committed Dec 9, 2021
1 parent e33b9a0 commit 77bc894
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 29 deletions.
21 changes: 12 additions & 9 deletions Driver.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
' This definition is used to select code that's only applicable for one device type
#Const Device = "ObservingConditions"

Option Infer On
Option Strict On

Imports System.Globalization
Imports System.Threading
Imports ASCOM.DeviceInterface
Expand All @@ -39,6 +36,9 @@ Public Class ObservingConditions
Friend Shared comPortProfileName As String = "COM Port"
Friend Shared comPort As String

Friend Shared debugProfileName As String = "Debug"
Friend Shared debug As Boolean

Friend WithEvents serial As IO.Ports.SerialPort = New IO.Ports.SerialPort()
Private WithEvents updateTimer As Threading.Timer = New Threading.Timer(AddressOf updateTimer_Tick, Nothing, Timeout.Infinite, Timeout.Infinite)

Expand All @@ -54,7 +54,7 @@ Public Class ObservingConditions
Public Sub New()
ReadProfile()
TL = New TraceLogger("", "SimpleSQM") With {
.Enabled = False
.Enabled = debug
}
Application.EnableVisualStyles()
connectedState = False
Expand All @@ -78,6 +78,7 @@ Public Class ObservingConditions
Using dialog As SimpleSQM = New SimpleSQM()
Dim result As DialogResult = dialog.ShowDialog()
If result = DialogResult.OK Then
TL.Enabled = debug
WriteProfile()
End If
End Using
Expand Down Expand Up @@ -132,18 +133,18 @@ Public Class ObservingConditions
serial.NewLine = vbCr
'serial.DtrEnable = True
'serial.RtsEnable = True
serial.ReadTimeout = 1500
serial.ReadTimeout = 8000
serial.BaudRate = 115200
serial.Open()
Thread.Sleep(300)
Thread.Sleep(200)
serial.WriteLine(">")
Thread.Sleep(500)
Thread.Sleep(800)
Dim msg As String
Try
msg = serial.ReadLine().Replace(vbCr, "").Trim()
Catch tex1 As TimeoutException
serial.WriteLine(">")
Thread.Sleep(500)
Thread.Sleep(2000)
Try
msg = serial.ReadLine().Replace(vbCr, "").Trim()
Catch tex2 As TimeoutException
Expand All @@ -157,7 +158,7 @@ Public Class ObservingConditions
sqmValue = Double.Parse(msg.Substring(1), CultureInfo.InvariantCulture)
TL.LogMessage("SQM", sqmValue.ToString())
sqmUpdateTime = Date.Now
updateTimer.Change(10000, 10000)
updateTimer.Change(15000, 15000)
connectedState = True
Else
serial.Close()
Expand Down Expand Up @@ -426,6 +427,7 @@ Public Class ObservingConditions
Using driverProfile As New Profile()
driverProfile.DeviceType = "ObservingConditions"
comPort = driverProfile.GetValue(driverID, comPortProfileName, String.Empty, "")
debug = Convert.ToBoolean(driverProfile.GetValue(driverID, debugProfileName, String.Empty, False))
End Using
End Sub

Expand All @@ -436,6 +438,7 @@ Public Class ObservingConditions
Using driverProfile As New Profile()
driverProfile.DeviceType = "ObservingConditions"
driverProfile.WriteValue(driverID, comPortProfileName, comPort.ToString())
driverProfile.WriteValue(driverID, debugProfileName, debug.ToString())
End Using

End Sub
Expand Down
4 changes: 2 additions & 2 deletions My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices
' 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.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: AssemblyVersion("1.0.1.0")>
<Assembly: AssemblyFileVersion("1.0.1.0")>
<Assembly: NeutralResourcesLanguage("en")>
21 changes: 21 additions & 0 deletions SetupDialogForm.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 63 additions & 9 deletions SetupDialogForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<value>1</value>
</data>
<data name="TableLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>120, 104</value>
<value>118, 142</value>
</data>
<data name="TableLayoutPanel1.RowCount" type="System.Int32, mscorlib">
<value>1</value>
Expand All @@ -199,13 +199,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;TableLayoutPanel1.ZOrder" xml:space="preserve">
<value>4</value>
<value>6</value>
</data>
<data name="TableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="OK_Button" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="Cancel_Button" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,50,Percent,50" /&gt;&lt;Rows Styles="Percent,50,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="OK_Button" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="Cancel_Button" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,50,Percent,50" /&gt;&lt;Rows Styles="Percent,50,Absolute,37" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="PictureBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>23, 146</value>
<value>23, 185</value>
</data>
<data name="PictureBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>48, 56</value>
Expand All @@ -226,7 +226,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;PictureBox1.ZOrder" xml:space="preserve">
<value>3</value>
<value>5</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
Expand All @@ -253,7 +253,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>2</value>
<value>4</value>
</data>
<data name="ComboBoxComPort.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 9pt</value>
Expand All @@ -277,13 +277,13 @@
<value>$this</value>
</data>
<data name="&gt;&gt;ComboBoxComPort.ZOrder" xml:space="preserve">
<value>1</value>
<value>3</value>
</data>
<data name="linkLabel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="linkLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>83, 180</value>
<value>83, 219</value>
</data>
<data name="linkLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>289, 23</value>
Expand All @@ -304,6 +304,60 @@
<value>$this</value>
</data>
<data name="&gt;&gt;linkLabel.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="debugToggle.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="debugToggle.Location" type="System.Drawing.Point, System.Drawing">
<value>169, 106</value>
</data>
<data name="debugToggle.Size" type="System.Drawing.Size, System.Drawing">
<value>80, 17</value>
</data>
<data name="debugToggle.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="debugToggle.Text" xml:space="preserve">
<value>Off</value>
</data>
<data name="&gt;&gt;debugToggle.Name" xml:space="preserve">
<value>debugToggle</value>
</data>
<data name="&gt;&gt;debugToggle.Type" xml:space="preserve">
<value>MetroFramework.Controls.MetroToggle, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="&gt;&gt;debugToggle.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;debugToggle.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="MetroLabel1.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="MetroLabel1.Location" type="System.Drawing.Point, System.Drawing">
<value>23, 104</value>
</data>
<data name="MetroLabel1.Size" type="System.Drawing.Size, System.Drawing">
<value>51, 19</value>
</data>
<data name="MetroLabel1.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="MetroLabel1.Text" xml:space="preserve">
<value>Debug:</value>
</data>
<data name="&gt;&gt;MetroLabel1.Name" xml:space="preserve">
<value>MetroLabel1</value>
</data>
<data name="&gt;&gt;MetroLabel1.Type" xml:space="preserve">
<value>MetroFramework.Controls.MetroLabel, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="&gt;&gt;MetroLabel1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;MetroLabel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand All @@ -313,7 +367,7 @@
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>395, 224</value>
<value>395, 257</value>
</data>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
10 changes: 4 additions & 6 deletions SetupDialogForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ Public Class SimpleSQM

Private Sub OK_Button_Click(sender As Object, e As EventArgs) Handles OK_Button.Click
ObservingConditions.comPort = ComboBoxComPort.SelectedItem.ToString()
ObservingConditions.debug = debugToggle.Checked
DialogResult = DialogResult.OK
Close()
End Sub

Private Sub Cancel_Button_Click(sender As Object, ByVal e As EventArgs) Handles Cancel_Button.Click
Me.DialogResult = DialogResult.Cancel
Me.Close()
DialogResult = DialogResult.Cancel
Close()
End Sub

Private Sub ShowAscomWebPage(sender As Object, e As EventArgs) Handles PictureBox1.DoubleClick, PictureBox1.Click
Expand All @@ -33,14 +34,11 @@ Public Class SimpleSQM
End Sub

Private Sub SetupDialogForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
InitUI()
End Sub

Private Sub InitUI()
ComboBoxComPort.Items.Clear()
ComboBoxComPort.Items.AddRange(IO.Ports.SerialPort.GetPortNames())
If ComboBoxComPort.Items.Contains(ObservingConditions.comPort) Then
ComboBoxComPort.SelectedItem = ObservingConditions.comPort
End If
debugToggle.Checked = ObservingConditions.debug
End Sub
End Class
Binary file modified SimpleSQM Setup.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions SimpleSQM Setup.iss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Setup]
AppID={{85c45996-e7eb-4ff2-bd4a-4e7385acca5b}
AppName=SimpleSQM ASCOM ObservingConditions driver
AppVerName=SimpleSQM ASCOM ObservingConditions driver 1.0.0
AppVersion=1.0.0
AppVerName=SimpleSQM ASCOM ObservingConditions driver 1.0.1
AppVersion=1.0.1
AppPublisher=Marco Cipriani <marco.cipriani.01@gmail.com>
AppPublisherURL=mailto:marco.cipriani.01@gmail.com
AppSupportURL=https://marcocipriani01.github.io/
AppUpdatesURL=https://marcocipriani01.github.io/
VersionInfoVersion=1.0.0
VersionInfoVersion=1.0.1
MinVersion=6.1sp1
DefaultDirName="{commoncf}\ASCOM\ObservingConditions"
DisableDirPage=yes
Expand Down

0 comments on commit 77bc894

Please sign in to comment.