Skip to content

Commit

Permalink
Fixes for V1.0.3.0, see CHANGES.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
gerritv committed Jan 6, 2015
1 parent ae64d4a commit 4f7e5e5
Show file tree
Hide file tree
Showing 12 changed files with 783 additions and 415 deletions.
6 changes: 6 additions & 0 deletions Grbl-Panel/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
<setting name="DefaultFileExt" serializeAs="String">
<value />
</setting>
<setting name="IPAddress" serializeAs="String">
<value />
</setting>
<setting name="ConnectionType" serializeAs="String">
<value>0</value>
</setting>
</GrblPanel.My.MySettings>
</userSettings>
</configuration>
6 changes: 6 additions & 0 deletions Grbl-Panel/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
This file documents changes made:
V1.0.3.0 - 2014 Dec 30
- Release file handle immediately after loading, Issue #19
- Ensure we always treat '.' as decimal, force Locale, Issue #17
- Ignore "%" in gcode file, Issue #20
- Fix layout errors when screen is set to 125%, Issue #18 and others
- Add IP address as a connection, thanks Tyler for designing and implementing this feature.
V1.0.2.0 - 2014 Dec 5
- Prevent keyboard jogging if running a gcode file or in MDI, Issue #15
- Add Reload for gcode file, reloads same file from scratch, Issue #11-5, 15
Expand Down
1 change: 1 addition & 0 deletions Grbl-Panel/CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ This tool would not have been possible without:
- Tortoise SVN for providing a simple to use code version control system
- Sonny Jeon's support by maintaining Grbl and providing useful input to design of GrblPanel as well as testing
- Legendaire for testing beta versions
- Tyler for adding IP connectivity
- Peter Smid, for his amazing books on CNC and Gcode
13 changes: 11 additions & 2 deletions Grbl-Panel/GrblGcode.vb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Partial Class GrblGui
End Sub

Public Function loadGCodeFile(ByVal file As String) As Boolean
Dim data As String

' Start from clean slate
resetGcode(True)
Expand All @@ -45,11 +46,19 @@ Partial Class GrblGui
' count the lines while loading up
_inputcount = 0
Do While Not _inputfh.EndOfStream
_gui.gcodeview.Insert(_inputfh.ReadLine(), _inputcount)
_inputcount += 1
data = _inputfh.ReadLine() ' Issue #20, ignore '%'
If data <> "%" Then
_gui.gcodeview.Insert(data, _inputcount)
_inputcount += 1
End If
Loop

lineCount = _inputcount

If Not IsNothing(_inputfh) Then
_inputfh.Close()
End If ' Issue #19

Return True

End Function
Expand Down
98 changes: 72 additions & 26 deletions Grbl-Panel/GrblGui.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Imports System.Threading.Thread
Imports System.Globalization
Imports System.Threading
Imports System.Threading.Thread


Public Class GrblGui

Expand All @@ -13,7 +16,7 @@ Public Class GrblGui
Public settings As GrblSettings ' To handle Settings related ops

Public Sub myhandler(ByVal sender As Object, args As UnhandledExceptionEventArgs)
' Show exception in useable manner
' Show exception in usable manner
Dim e As Exception = DirectCast(args.ExceptionObject, Exception)
MessageBox.Show("Exception: " + e.Message + vbLf + e.InnerException.Message + vbLf + e.StackTrace)
End Sub
Expand All @@ -23,6 +26,9 @@ Public Class GrblGui
' Use handler below to trap wierd problems at Form creation, e.g. when going from .Net 4 to 3.5
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf myhandler

' Ensure that we always interpret things such as '.' as decimal (instead of ',' in EU)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-CA")

' Set user preferences/defaults
Application.EnableVisualStyles()

Expand Down Expand Up @@ -52,9 +58,11 @@ Public Class GrblGui
End If

cbBaud.SelectedText = My.Settings.Baud

grblPort.baudrate = Convert.ToInt32(My.Settings.Baud)

tcConnection.SelectedIndex = My.Settings.ConnectionType
tbIPAddress.Text = My.Settings.IPAddress

If cbSettingsConnectOnLoad.Checked Then
' auto connect
btnConnDisconnect_Click(btnConnect, Nothing)
Expand Down Expand Up @@ -92,29 +100,36 @@ Public Class GrblGui
End Sub

Private Sub SwitchSides(ByVal side As Boolean)
' We switch GUI sides, this needs to be fixed EVERYTIME that the layout changes!
' We switch GUI sides

Dim ctl As Control

' Get existing locations for X ' Issue #17,18 and others fix
Dim left_X As Integer
Dim right_X As Integer
left_X = gbJogging.Width + 3
right_X = gbPosition.Width + 3

If side Then ' we are going left handed
For Each ctl In {gbGrbl, gbJogging, gbGcode}
ctl.Location = New Point(3, ctl.Location.Y)
Next
gbMDI.Location = New Point(3 + 184, gbMDI.Location.Y)
gbMDI.Location = New Point(3 + gbGrbl.Width + 3, gbMDI.Location.Y)

For Each ctl In {gbPosition, gbStatus, gbControl}

ctl.Location = New Point(3 + 3 + 520, ctl.Location.Y)
ctl.Location = New Point(3 + left_X, ctl.Location.Y)
Next
Else
For Each ctl In {gbGrbl, gbJogging, gbGcode}
ctl.Location = New Point(3 + 403, ctl.Location.Y)
ctl.Location = New Point(3 + right_X, ctl.Location.Y)
Next
gbMDI.Location = New Point(3 + 400 + 187, gbMDI.Location.Y)
gbMDI.Location = New Point(3 + right_X + gbGrbl.Width + 3, gbMDI.Location.Y)

For Each ctl In {gbPosition, gbStatus, gbControl}

ctl.Location = New Point(3, ctl.Location.Y)
Next
End If

End Sub

Private Sub cbSettingsLeftHanded_CheckedChanged(sender As Object, e As EventArgs) Handles cbSettingsLeftHanded.CheckedChanged
Expand All @@ -126,7 +141,7 @@ Public Class GrblGui
' set desired com port
' always remember as new default
' allow re-connect to new port
grblPort.port = cbPorts.SelectedItem
grblPort.comport = cbPorts.SelectedItem
' Set as new default
My.Settings.Port = cbPorts.SelectedItem
btnConnect.Enabled = True
Expand All @@ -142,22 +157,53 @@ Public Class GrblGui

End Sub

Private Sub btnConnDisconnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
Private Sub btnConnDisconnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click, btnIPConnect.Click
' Open connection to Grbl
Dim btn As Button = sender
' This routine is used for both Com and IP connections. Buttons are differentiated by using Tag property.

If grblPort.port = "" Then
MessageBox.Show("Please select a Com port" + vbCr + "or connect the cable", "Connect Error", MessageBoxButtons.OK)
grblPort.rescan()
Return
End If
Dim btn As Button = sender
Dim connected As Boolean

Select Case btn.Text
Case "Connect"
If grblPort.Connect() = True Then
' disable Connect button to prevent reconnects
btnConnect.Text = "Disconnect"

Select Case btn.Tag
Case "COM"
connected = grblPort.Connect(GrblIF.ConnectionType.Serial)
If connected = True Then
' disable other Connect button to prevent reconnects
btn.Text = "Disconnect"
btnIPConnect.Enabled = False
Else
MessageBox.Show("Please select a Com port" + vbCr + "or connect the cable", "Connect Error", MessageBoxButtons.OK)
grblPort.rescan()
Return
End If
Case "IP"
If tbIPAddress.TextLength <= 0 Then
MessageBox.Show("Please enter an IP Address" + vbCr + "and a port number in the format" + vbCr + """<ip address>:<port number>""", "Connect Error", MessageBoxButtons.OK)
Return
End If

Dim address As String() = tbIPAddress.Text.Split({":"}, StringSplitOptions.RemoveEmptyEntries)
grblPort.ipaddress = System.Net.IPAddress.Parse(address(0))
grblPort.portnum = Integer.Parse(address(1))

If grblPort.portnum = 0 Then
MessageBox.Show("Please enter an IP Address" + vbCr + "and a port number in the format" + vbCr + """<ip address>:<port number>""", "Connect Error", MessageBoxButtons.OK)
Return
End If
' finally we try to connect
connected = grblPort.Connect(GrblIF.ConnectionType.IP)
If connected = True Then
' disable other Connect button to prevent reconnects
btn.Text = "Disconnect"
btnConnect.Enabled = False
Else
MessageBox.Show("Please enter an IP Address" + vbCr + "and a port number in the format" + vbCr + """<ip address>:<port number>""", "Connect Error", MessageBoxButtons.OK)
Return
End If
End Select
If connected = True Then
' Wake up the subsystems
' TODO Replace these calls with Event Connected handling in each object
status.enableStatus(True)
Expand All @@ -172,15 +218,14 @@ Public Class GrblGui
Sleep(tbSettingsStartupDelay.Text * 1000) ' Give Grbl time to wake up from Reset

RaiseEvent Connected("Connected") ' tell everyone of the happy event
Else
MessageBox.Show("Please select a Com port" + vbCr + "or connect the cable", "Connect Error", MessageBoxButtons.OK)
grblPort.rescan()
Return
End If
Case "Disconnect"
' it must be a disconnect
grblPort.Disconnect()
btnConnect.Text = "Connect"
btnIPConnect.Text = "Connect"
btnConnect.Enabled = True
btnIPConnect.Enabled = True

' Stop the status poller
' TODO Replace these calls with Event Disconnected handling in each object
Expand Down Expand Up @@ -286,4 +331,5 @@ Public Class GrblGui
' Raised when we succesfully connected to Grbl
Public Event Connected(ByVal msg As String)


End Class
Loading

0 comments on commit 4f7e5e5

Please sign in to comment.