Spel Class Events
EventReceived Event, Spel Class
Description
Occurs when Epson RC+ 8.0 sends a system event or when a program running in SPEL+ sends an event using a SPELCom_Event statement.
Syntax
EventReceived (ByVal sender As Object, ByVal e As RCAPINet.SpelEventArgs)
Parameters
- e.Event
A number indicating the specified user-defined event. - e.Message
A character string indicating the event message.
Remarks
There are several system events that Epson RC+ 8.0 issues. The following table describes them.
System Events
Some events are disabled by default. To use these events you must first enable them using the EnableEvent Method.
Event Number | Event Message | Constant | Description |
---|---|---|---|
1 | "PAUSE" | SpelEvents.Pause | Occurs when tasks are paused. Enabled by default. |
2 | "SAFE GUARD OPEN" | SpelEvents.SafeGuardOpen | Occurs when safe guard is open. Enabled by default. |
3 | "SAFE GUARD CLOSE" | SpelEvents.SafeGuardClose | Occurs when safe guard is closed. Enabled by default. |
4 | Project build status text | SpelEvents.ProjectBuildStatus | Each build status message is sent during the BuildProject method. CRLFs are added as needed. These messages are the same ones displayed on the Project Build Status window in Epson RC+ 8.0 GUI. This event must be enabled with the EnableEvent method. Disabled by default. |
5 | "Error xxx!: mmm in task at line yyy" | SpelEvents.Error | Occurs when a task is aborted due to an unhandled error or a system error is generated. Enabled by default. |
6 | Text from print statement | SpelEvents.Print | Occurs when a Print statement executes from a SPEL+ task. Disabled by default. |
7 | "ESTOP ON" | SpelEvents.EStopOn | Occurs when emergency stop condition changes to ON. Enabled by default. |
8 | "ESTOP OFF" | SpelEvents.EStopOff | Occurs when emergency stop condition changes to OFF. Enabled by default. |
9 | "CONT" | SpelEvents.Continue | Occurs after a Cont has been executed. Enabled by default. |
10 | <Robot #>,"MOTOR ON" | SpelEvents.MotorOn | Occurs when motors go ON for the robot indicated. Disabled by default. |
11 | <Robot #>,"MOTOR OFF" | SpelEvents.MotorOff | Occurs when motors go OFF for the robot indicated. Disabled by default. |
12 | <Robot #>,"POWER HIGH" | SpelEvents.PowerHigh | Occurs when power goes HIGH for the robot indicated. Disabled by default. |
13 | <Robot #>,"POWER LOW" | SpelEvents.PowerLow | Occurs when power goes LOW for the robot indicated. Disabled by default. |
14 | "TEACH MODE" | SpelEvents.TeachMode | Occurs when teach mode is activated. Enabled by default. |
15 | "AUTO MODE" | SpelEvents.AutoMode | Occurs when auto mode is activated. Enabled by default. |
16 | "<TaskID>,<Status>,<FuncName>" Status: "RUN", "HALT", "PAUSE", “FINISHED”, “ABORTED” | SpelEvents.TaskState | Occurs when task state changes. Disabled by default. |
17 | "SHUTDOWN" | SpelEvents.Shutdown | Occurs when RC+ is shutting down. Disabled by default. |
18 | "ALL TASKS STOPPED" | SpelEvents.AllTasksStopped | Occurs when all tasks have been stopped. Disabled by default. |
19 | "DISCONNECTED" | SpelEvents.Disconnected | Occurs when Controller communication has been disconnected from the PC. When enabled, RC+ does not display a message box indicating disconnection. Disabled by default. |
20 | “MOTION STARTED” | SpelEvents.MotionStarted | Occurs when the control command started If enabled, it will be displayed when the following Spel class methods are executed. Arc, Arc3, BGo, BMove, CVMove, Go, Home, JTran, Jump, Jump3, Jump3CP, MCal, Move, Pass, PTran, Pulse, TGo, TMove Disabled by default |
21 | “MOTION COMPLETE” | SpelEvents.MotionComplete | Occurs when the control command started If enabled, it will be displayed after the execution of the following Spel class methods are completed. Arc, Arc3, BGo, BMove, CVMove, Go, Home, JTran, Jump, Jump3, Jump3CP, MCal, Move, Pass, PTran, Pulse, TGo, TMove Disabled by default |
User Events
You can send events from your SPEL+ program to your Visual Basic application using the SPELCom_Event command.
Spelcom_Event 3000, cycNum, lotNum, cycTime
When this statement executes, the EventReceived routine will be called with the event number and message. See Epson RC+ 8.0 Online Help or 13. SPELCom_Event for details on SPELCom_Event.
Use Example
VB Example:
Sub m_spel_EventReceived ( _
ByVal sender As Object, _
ByVal e As RCAPINet.SpelEventArgs) _
Handles m_spel.EventReceived
Redim tokens(0) As String
Select Case e.Event
Case 3000
tokens = e.Message.Split(New [Char]() {" "c}, _
System.StringSplitOptions.RemoveEmptyEntries)
lblCycCount.Text = tokens(0)
lblLotNumber.Text = tokens(1)
lblCycTime.Text = tokens(2)
End Select
End Sub
C# Example:
public void m_spel_EventReceived(object sender, SpelEventArgs e)
{
string[] tokens = new string[3];
switch ((int) e.Event){
case 3000:
tokens = e.Message.Split(' ');
lblCycCount.Text = tokens(0);
lblLotNumber.Text = tokens(1);
lblCycTime.Text = tokens(2);
break;
default:
break;
}
}
Handling Events
When EventReceived is called from the Spel class instance, the Epson RC+ 8.0 process server will wait for the event handling routine to finish. Therefore, you should never try to execute any RC+ API commands or perform long running processing from within the EventReceived routine. If you want to execute commands based on an event that occurred, set a flag in EventReceived and handle the flag from the main loop of your application, outside of the event handling function.
For example, in your Visual Basic main form Load procedure, you can create an event loop that receives events from SPEL+. In the spel_EventReceived routine, set global flags to indicate which events were received. Then, you can execute an actual event handling from the event loop created in Load procedure.
To display event message
Add a TextBox control to a form. Each time the event is received, you can display the event message in the Text property of the TextBox control.
VB Example:
Private Sub m_spel_EventReceived(ByVal sender As Object, _
ByVal e As SpelEventArgs) Handles m_spel.EventReceived
txtEvents.AppendText(e.Event & ": " & e.Message & vbCrLf)
End Sub
C# Example:
private void m_spel_EventReceived(object sender, SpelEventArgs e)
{
txtEvents.AppendText(e.Event + ": " + e.Message);
}
See Also
EnableEvent (Spel Class)