Getting Started
This chapter contains information for getting started with GUI Builder 8.0.
Before continuing, ensure that the GUI Builder option is enabled.
See the following chapter for details.
To install GUI Builder
If you have never used Epson RC+ before, you should read the Epson RC+ 8.0 User's Guide to get familiar with creating projects and programs.
The following section presents a tutorial illustrating some simple concepts.
GUI Builder Tutorial
In this section we will create a simple GUI application that runs a robot cycle. We will walk through the following tasks. For details of terms and descriptions of GUI Builder, refer to section 4.2 onward.
- Create a new Epson RC+ project with a function to run the robot cycle.
- Create a form with Start and Stop buttons to run the robot cycle. This shows how to create a form and add buttons with events to start and stop a SPEL+ task.
- Add Pause and Continue buttons to the form. This shows the use of the EventTaskType property.
- Add a setup form. This form will use the Label and TextBox controls to allow the user to change robot speeds.
- Add a button on the main form to display the setup form. This shows the use of the GShowDialog statement and the DialogResult property.
Follow these steps:
- Create a new Epson RC+ 8.0 project called GUITest.
- Using the Robot Manager, teach two robot points P0 and P1 in two different positions.
- Add code to function main in Main.prg as shown below:
Function main Robot 1
Motor On
Do Go P0 Wait 0.5
Go P1 Wait 0.5
LoopFend
Select Tools | GUI Builder to open the GUI Builder window.
Click the New Form button on the GUI Builder window toolbar to create a form and name it frmMain. Click the OK button.
Click the New Button button on the GUI Builder window toolbar click the mouse on the form. A new button will be created.
In the Property Grid, scroll down to the Name property,
then change the name to btnStart and press ENTER.
In the Property Grid, scroll down to the Text property, then change the text from Button1 to Start and press ENTER.
Double click on the Start button on your form. A new program window named frmMain.prg will be opened with a new function for the button click event handler.
Change the frmMain_btnStart_Click function to start the main task as shown below.
This will cause the main function to start when the user clicks the Start button.
Function frmMain_btnStart_Click(Sender$ As String)
Xqt main
Fend
Click the New Button button on the GUI Builder window toolbar, then click on the form under the Start button to create another button.
For the new button, change the Name property to btnStop, and change the Text property to Stop.
At this point, your form should look as shown below:
Double click the Stop button to create the button click event handler.
Then change the code as shown below:
Function frmMain_btnStop_Click(Sender$ As String)
Quit main
Fend
Press F5 to build the project and display the Run Window.
If any build errors occur, correct your code and press F5 again.Select the Form radio button on the Run Window.
Click the Start button on the Run Window.
frmMain will be displayed. Click the Start button on frmMain.
The robot should now be moving between P0 and P1.Click the Stop button on your form.
The robot task will stop.Now click the X button in the upper right of your form.
The form will close.
We will now add Pause and Continue buttons to our GUI.Click the New Button button on the GUI Builder window toolbar and click the form to the right of the Start button to create a new button.
For the new button, change the Name property to btnPause, and change the Text property to Pause.
Change the EventTaskType for the Pause button to 1 – NoPause.
This allows the button click event handler to execute the Pause statement without pausing the task itself.Double click the Pause button to create an event handler function.
Then change the code by adding the Pause statement as shown below:
Function frmMain_btnPause_Click(Sender$ As String)
Pause
Fend
Click the New Button button on the GUI Builder window toolbar and click the form to the right of the Stop button to create a new button.
For the new button, change the Name property to "btnCont", and change the Text property to "Continue".
Change the EventTaskType for the Continue button to 1 – NoPause.
This allows the button click event handler to execute the Cont statement when normal tasks are paused.Double click the Continue button to create an event handler function.
Then change the code by adding the Cont statement as shown below:
Function frmMain_btnCont_Click(Sender$ As String)
Cont
Fend
Press F5 to build the project and display the Run Window.
If any build errors occur, correct your code and press F5 again.Click the Start button on the Run Window. Your form will be displayed.
Click the Start button on your form.
The robot cycle will execute.Click the Pause button on your form.
The robot cycle will pause.Click the Continue button on your form.
The robot cycle will continue.Click the Stop button on your form, then close the form by clicking the X button in the upper right corner.
We will now add a setup form to our GUI.
Click the New Form button the GUI Builder window toolbar and name the new form frmSetup, then click OK. A new tab page will be opened showing the new form.
Click the New Label button and click on frmSetup to create a label.
In the Property Grid, change the name of the new label to "lblSpeed".
Change the Text property to "Speed:".
Click the New TextBox button and click on frmSetup to the right of the Speed label.
Change the Name property to "txtSpeed" and change the Text property to "10".
Double click on frmSetup to create the Load event handler function for the form and change the code as shown below:
Function frmSetup_Load(Sender$ As String)
GSet frmSetup.txtSpeed.Text, Str$(Speed(1))
Fend
Click the New Button button on the GUI Builder window toolbar and click the form to add the button.
Name this button "btnOK" and set the Text property to "OK".Click the New Button button on the GUI Builder window toolbar and click the form to add the button.
Name this button "btnCancel" and set the Text property to "Cancel". At this point, you setup form should look similar to the one shown below:
Double click the OK button to create an event handler function. Then change the code to set the form's DialogResult property and call GClose as shown below:
Function frmSetup_btnOK_Click(Sender$ As String)
GSet frmSetup.DialogResult, DIALOGRESULT_OK
GClose frmSetup
Fend
- Double click the Cancel button to create an event handler function. Then change the code to set the form's DialogResult property and call GClose as shown below:
Function frmSetup_btnCancel_Click(Sender$ As String)
GSet frmSetup.DialogResult, DIALOGRESULT_CANCEL
GClose frmSetup
Fend
Click the frmMain tab on the GUI Builder window to work with frmMain again.
Click the New Button button on the GUI Builder window toolbar and click the form to add the button.
Name this button "btnSetup" and set the Text property to "Setup".Double click the Setup button to create an event handler function. Then change the code to show the setup dialog and set the new robot speed as shown below:
Function frmMain_btnSetup_Click(Sender$ As String)
Integer result
String value$
result = GShowDialog(frmSetup)
If result = DIALOGRESULT_OK Then
GGet frmSetup.txtSpeed.Text, value$
Speed Val(value$)
EndIf
Fend
Press F5 to build the project and open the Run Window.
Click the Start button on the Run Window. The main form will be displayed.
Click the Start button on the main form.
The robot cycle will execute.Click the Setup button on the main form. The setup dialog will be displayed with the current robot speed in the textbox.
Enter a new speed and click OK.
The robot cycle is run at the new speed.
If the Stop button is clicked and the robot stops, the motion speed will be reset to the default.
This completes the tutorial.