-
Notifications
You must be signed in to change notification settings - Fork 0
/
UCCNCplugin.vb
211 lines (180 loc) · 7.61 KB
/
UCCNCplugin.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
Imports MouseMPG
Public Class UCCNCplugin
Friend UC As Plugininterface.Entry
Friend WithEvents Settings As Settings
Friend LoopStop As Boolean
Friend LoopWorking As Boolean
Dim FirstRun As Boolean = True
Dim MyForm As PluginForm
' Called when the plugin is initialised.
' The parameter is the Plugin interface object which contains all functions prototypes for calls and callbacks.
Public Sub Init_event(UC As Plugininterface.Entry)
Me.UC = UC
Me.Settings = New Settings(UC)
MyForm = New PluginForm(Me)
End Sub
' Called when the plugin is loaded, the author of the plugin should set the details of the plugin here.
Public Function Getproperties_event(ByVal Properties As Plugininterface.Entry.Pluginproperties) As Plugininterface.Entry.Pluginproperties
Properties.author = "Eldar Gerfanov"
Properties.pluginname = "MouseWheel MPG"
Properties.pluginversion = "1.1.1"
Properties.pluginversion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString ' Get version from Assembly info
Return Properties
End Function
' Called from UCCNC when the user presses the Configuration button in the Plugin configuration menu.
' Typically the plugin configuration window is shown to the user.
Public Sub Configure_event()
Dim CForm As New ConfigForm(Me)
CForm.ShowDialog()
End Sub
' Called from UCCNC when the plugin is loaded and started.
Public Sub Startup_event()
If MyForm.IsDisposed Then
MyForm = New PluginForm(Me)
End If
MyForm.Show()
End Sub
' Called when the Pluginshowup(string Pluginfilename); function is executed in the UCCNC.
Public Sub Showup_event()
If MyForm.IsDisposed Then
MyForm = New PluginForm(Me)
End If
MyForm.Show()
MyForm.BringToFront()
End Sub
' Called when the UCCNC software is closing.
Public Sub Shutdown_event()
Try
MyForm.Close()
Catch ex As Exception
End Try
End Sub
' Called in a loop with a 25Hz interval.
Public Sub Loop_event()
If LoopStop Then
Return
End If
LoopWorking = True
If MyForm Is Nothing Or MyForm.IsDisposed Then
Return
End If
If FirstRun Then
FirstRun = False
' Write code here which has to be run on first cycle only...
End If
Try
'MyForm.Label1.Text = "X: " + UC.Getfield(True, 226)
' MyForm.label2.Text = "Y: " + UC.Getfield(True, 227)
' MyForm.label3.Text = "Z: " + UC.Getfield(True, 228)
' MyForm.label4.Text = "A: " + UC.Getfield(True, 229)
' MyForm.label5.Text = "Set feed: " + UC.Getfield(True, 867)
' MyForm.label6.Text = "Act feed: " + UC.Getfield(True, 868)
Catch ex As Exception
End Try
LoopWorking = False
' Console.WriteLine("" + Convert.ToInt32("A"))
End Sub
' This is a direct function call addressed to this plugin dll
' The function can be called by macros or by another plugin
' The passed parameter is an object and the return value is also an object
Public Function Informplugin_event(Message As Object) As Object
'If Not (MyForm Is Nothing Or MyForm.IsDisposed) Then
' If TypeOf Message Is String Then
' Dim receivedstr As String = Message
' MsgBox("Informplugin message received by Plugintest! Message was: " + receivedstr)
' End If
'End If
'Dim returnstr As String = "Return string by Plugintest"
'Return returnstr
End Function
' This is a function call made to all plugin dll files
' The function can be called by macros or by another plugin
' The passed parameter is an object and there is no return value
Public Sub Informplugins_event(Message As Object)
'If Not (MyForm Is Nothing Or MyForm.IsDisposed) Then
' If TypeOf Message Is String Then
' Dim receivedstr As String = Message
' MsgBox("Informplugins message received by Plugintest! Message was: " + receivedstr)
' End If
'End If
End Sub
' Called when the user presses a button on the UCCNC GUI or if a Callbutton function is executed.
' The int buttonnumber parameter is the ID of the caller button.
' The bool onscreen parameter is true if the button was pressed on the GUI and is false if the Callbutton function was called.
Public Sub Buttonpress_event(ByVal ButtonNumber As Integer, ByVal OnScreen As Boolean)
'If OnScreen Then
' If ButtonNumber = 128 Then
' ' Code...
' End If
'End If
End Sub
' Called when the user clicks and enters a Textfield on the screen
' The labelnumber parameter is the ID of the accessed Textfield
' The bool Ismainscreen parameter is true is the Textfield is on the main screen and false if it is on the jog screen
Public Sub Textfieldclick_event(labelnumber As Integer, Ismainscreen As Boolean)
'If Ismainscreen Then
' If labelnumber = 1000 Then
' ' Your code here...
' End If
'End If
End Sub
' Called when the user enters text into the Textfield and it gets validated
' The labelnumber parameter is the ID of the accessed Textfield
' The bool Ismainscreen parameter is true is the Textfield is on the main screen and false if it is on the jog screen.
' The text parameter is the text entered and validated by the user
Public Sub Textfieldtexttyped_event(labelnumber As Integer, Ismainscreen As Boolean, text As String)
'If Ismainscreen Then
' If labelnumber = 1000 Then
' ' Your code here...
' End If
'End If
End Sub
' Called when the user presses the Cycle start button and before the Cycle starts
' This event may be used to show messages or do actions on Cycle start
' For example to cancel the Cycle if a condition met before the Cycle starts with calling the Button code 130 Cycle stop
Public Sub Cyclethreadstart_event()
' MsgBox("Cycle is starting...")
End Sub
Public Sub Cyclethreadstop_event()
' MsgBox("Cycle is stopping...")
End Sub
Public Sub Toolpathclick_event(X As Double, Y As Double, Istopview As Boolean)
' Toolpath clicked
End Sub
' Public Function Get_event(pluginfilename As String, exec As Executer) As Boolean ---->>>> ?
End Class
Public Class Settings
Property imperial As Boolean = True
Property feedrate As Double = 50
Property UC As Plugininterface.Entry
Public Event SettingsChanged()
Public Sub New(UC As Plugininterface.Entry)
Me.UC = UC
Try
'#If Not DEBUG Then
Dim v As String = ""
v = UC.Readkey("MouseWheelMPG", "imperial", "0")
If v = "0" Then
imperial = False
End If
v = UC.Readkey("MouseWheelMPG", "feedrate", "")
If Not Double.TryParse(v, feedrate) Then
feedrate = 50
End If
'#End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Friend Sub Save()
Try
'#If Not DEBUG Then
UC.Writekey("MouseWheelMPG", "imperial", If(imperial, "1", "0"))
UC.Writekey("MouseWheelMPG", "feedrate", feedrate.ToString)
RaiseEvent SettingsChanged()
'#End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
End Class