© Copyri ght 200 7 - 2009 ABB . All ri ghts res erved.
5.4 Launching other views
5.4.1. Using launch service
OverviewThe FlexPendant SDK provides a launch service, which enables a RAB application to start a standard ABB application, such as the program editor or the jogging view.
It is also possible to start another custom application by specifying proxy assembly name and the application view class.
For information about how to add and launch another view of your own application, see
Adding a view to a custom application on page 99.
NOTE!
To launch a view in order to edit a specified rapid data instance, another mechanism is available. See Using standard dialogs to modify data on page 131 for details.
ITpsViewSetup Install
It is only classes that inherit the ITpsViewSetup interface that can launch other applications. TheInstall method, which is called when your custom application is launched, has a sender argument. Your application needs to save this object to be able to use the
ITpsViewLaunchServices interface. It is used by the launch service to call LaunchView
and CloseView.
VB:
//declaration
Private iTpsSite As ITpsViewLaunchServices ...
//Install method of the TpsView class
Function Install(ByVal sender As System.Object, ByVal data As System.Object) As Boolean Implements ITpsViewSetup.Install If TypeOf sender Is ITpsViewLaunchServices Then
// Save the sender object for later use
Me.iTpsSite = DirectCast(sender, ITpsViewLaunchServices) Return True
End If Return False End Function
5.4.1. Using launch service © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved. C#: //declaration
private ITpsViewLaunchServices iTpsSite; ...
//Install method of the TpsView class
bool ITpsViewSetup.Install(object sender,object data) {
if (sender is ITpsViewLaunchServices) { // Save the sender object for later use
this.iTpsSite = sender as ITpsViewLaunchServices; return true;
}
return false; }
Launching standard views
Using the FpStandardView enumerator, the following standard views can be started using the launch services:
• Program editor • Program data • Jogging • Logoff • Backup/Restore TIP!
Launching the Program data view is the best way to let end-users create new RAPID data.
NOTE!
To launch the program editor an initialization object of RapidEditorInitData type can be used as argument. It specifies the task, module and row that the Program editor should display when it opens. For the other standard views no InitData can be used.
LaunchView / CloseView example
In the example below, the program editor is launched at a specified routine. First initData
is created. Then the reference to the sender object, retrieved by the Install method in the previous example, is used to call LaunchView.
The cookie out argument is later used to specify the view to be closed by the CloseView
method. VB:
Dim initData As RapidEditorInitData = New RapidEditorInitData (ATask, AModule, ARoutine.TextRange.Begin.Row)
If Not (Me.iTpsSite.LaunchView(FpStandardView.RapidEditor, initData, True, Me.cookieRapidEd) = True) Then
GTPUMessageBox.Show(Me, Nothing, "Could not start RapidEditor application")
Return
Continued
5.4.1. Using launch service © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved. End If ... Me.iTpsSite.CloseView(Me.cookieRapidEd) C#:
RapidEditorInitData initData = new RapidEditorInitData(task, module,routine.TextRange.Begin.Row;
if(this.iTpsSite.LaunchView(FpStandardView.RapidEditor,initData, true,out this.cookieRapidEd)!= true) {
GTPUMessageBox.Show(this, null,"Could not start RapidEditor application");
return; }
...
this.iTpsSite.CloseView(this.cookieRapidEd);
What happens if the specified view is already open when the call is made? The third argument specifies application behavior in this case. If true, another instance of the view is launched. If false, the already opened view gets focus. Notice, however, that creating a new instance is not possible for all standard views. The Jogging view, for example, is not allowed multiple instances.
Launching custom applications
The launch service can also be used to launch another RAB application. The name of the proxy assembly along with the fully qualified class name should be used as arguments. VB:
If Not (Me.iTpsSite.LaunchView("TpsViewCustomApp.gtpu.dll", "ABB.Robotics.SDK.Views.TpsViewCustomApp", Nothing, True, Me.cookieUser) = True) Then
GTPUMessageBox.Show(Me, Nothing, "Could not start User application")
Return End If
C#:
if (this.iTpsSite.LaunchView("TpsViewCustomApp.gtpu.dll", "ABB.Robotics.SDK.Views.TpsViewCustomApp", null, true, out this.cookieUser)!= true) {
GTPUMessageBox.Show(this, null,"Could not start User application");
return; }
NOTE!
It is the namespace of the proxy assembly, ABB.Robotics.SDK.Views,which should be used to specify the TpsView class.
NOTE!
By using the argument cookieUser your application can close the launched custom
application in the same way as in the Launching standard views on page 129 example above. Continued
5.4.2. Using standard dialogs to modify data © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved.
5.4.2. Using standard dialogs to modify data
OverviewThe FpRapidData, FpToolCalibration and FpWorkObjectCalibration dialogs take
a RapidData reference as argument. When the dialog is opened it allows the user to directly operate on the referenced RapidData object, for example modifying a RAPID data variable or calibrate a work object. These dialogs are the ones used by the standard ABB applications. They are ready-made and cannot be modified, except for the title.
Creating the dialog
As with all secondary dialogs, the reference to the dialog should be declared as a class variable. This is to make sure that the reference is available for Dispose. The RapidData
reference can be declared locally if it is disposed immediately after use, or else as a class variable. When the dialog has been created the title can be set using the Text property. A
Closed event handler should be added to dispose the dialog. All three dialogs are created in the same way:
VB:
Private ARapidData As RapidData Friend WithEvents FpRD As FpRapidData ...
Me.ARapidData = Me.AController.Rapid.GetRapidData(ATaskName, AModuleName, AVariableName)
Me.FpRD = New FpRapidData(Me.ARapidData) Me.FpRD.Text = Me.ARapidData.Name
AddHandler Me.FpRD.Closed, AddressOf Me.FpRD_Closed Me.FpRD.ShowMe(Me)
C#:
private FpRapidData fpRD; private RapidData aRapidData; ...
this.aRapidData = this.aController.Rapid.GetRapidData(taskName, moduleName, variableName);
this.fpRD = new FpRapidData(this.aRapidData); this.fpRD.Text = this.aRapidData.Name;
this.fpRD.Closed += new EventHandler( fpRD_Closed); this.fpRD.ShowMe(this);
5.4.2. Using standard dialogs to modify data © Copyri ght 200 7 - 2009 ABB . All ri ghts res erved. NOTE!
Verify that the RapidData is of correct RapidDataType for the dialog before using it, i.e.
tooldata for the FpToolCalibration dialog and wobjdata for the FpWorkObjectCalibration dialog. See Type checking on page 132 below.
NOTE!
The FpRapidData dialog is created with a RapidData as in argument. If the RapidData is an array, an index argument is used to specify which element should be displayed (the first element is 1).
Type checking
When calling the FpToolCalibration or FpWorkObjectCalibration constructor the
RapidData value should be type checked before use: VB:
If TypeOf Me.ARapidData.Value Is ToolData Then Me.FpTC = New FpToolCalibration(Me.ARapidData) ...
End If
C#:
if (this.aRapidData.Value is ToolData) {
this.fpTC = new FpToolCalibration(this.aRapidData); ....
}