RobotStudio event

Launchview

Hey everybody,

i'm really a Rookie in RAB and i've got a question, hope you guys can help me out....

I want to edit a special "pos" in the "Program Data"

I try to do this about a Button! If i click the Button the programm should launch to the "Program Data/pos/pos1" surface, so that i can edit the pos.

How can i do that in VB (not C#) ?

 

By now i try it with this command, but it didn't works:


Private
Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.ARapidData = Me.AController.Rapid.GetRapidData("T_ROB1", "MainModule", "pos1")
Me.FpRD = New FpRapidData(Me.ARapidData)
Me.FpRD.Text = Me.ARapidData.Name
AddHandler Me.Button4_Click, AddressOf Button4_Click
Me.FpRD.ShowMe(Me)

 

Hope someone can help me out with a right syntax example !

 

Thanks "7"

 

Comments

  • Try this:


    Dim
    ctrl As Controller
    Dim
    f As FpRapidData
    Dim
    rd As RapidDomain.RapidData
    Private
    Sub btnLaunch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLaunch.Click
    Try
      rd = ctrl.Rapid.GetRapidData(
    "T_ROB1", "user", "pos1")
      If Not rd Is Nothing Then
        f =
    New FpRapidData(rd)
        AddHandler f.Closed, AddressOf FpRapidDataClosed
        f.ShowMe(
    Me)
      Else
        GTPUMessageBox.Show(
    Me, _
        Nothing, _
        "Couldn't get RapidData", _
        "RapidData Access Problem", _
        Windows.Forms.MessageBoxIcon.Hand, _
        Windows.Forms.MessageBoxButtons.OK)
      End If
    Catch ex As Exception
      GTPUMessageBox.Show(
    Me, _
      Nothing, _
      ex.ToString, _
      "Exception", _
      Windows.Forms.MessageBoxIcon.Hand, _
      Windows.Forms.MessageBoxButtons.OK)
    Finally
      If Not rd Is Nothing Then
        rd.Dispose()
        rd =
    Nothing
      End If
    End Try
    End
    Sub
    Private
    Sub FpRapidDataClosed(ByVal sender As Object, ByVal e As EventArgs)
      RemoveHandler f.Closed, AddressOf FpRapidDataClosed
      If Not f Is Nothing Then
        f.Dispose()
        f =
    Nothing
      End If
    End
    Sub
    Russell Drown
  • Thanks for your answer image

    Mmmh, but it didn't work by now.

    When i click the button there is an Error Message:

    System.NullReference Exception:

    "The Objectreffering is not set on an objectinstance"

    I've read in the users guide.pdf : Using the
    FpStandardView enumerator, the following standard views can be started using
    the launch services: Program Data...

    Is there maybe a way to Launch direct to the Programm Data Window with the Variable that i want to Edit? For example, a End-User must edit a pos variable, so i want to launch by a button click direct to this window where the end user can edit the variable.

    Grettings "7"

  • It works for me, exactly as you described above, i.e the Data Viewer is launched, seeded with the RAPID variable pos1.What version of RAB and RW are you using?

    This wasn't an entire application, it is only the click event handler for a button that launches tha data viewer. You must make sure that you adjust the object names and the RAPID variable names to work with your app, otherwise it should work.

    If you continue to have problems, please attach the stack trace so that we can see where the null reference is coming from.

    Russell Drown

  • Hey Russ, once again thanks for your help so far, but i still have the problem. Here's my complete Programm, i'm nearly sure i've done everything right, but i still have the error message. The funny thing is that i can jump to a specify row in a Module with the RapidEditor initdata function, but the GetRapidData thing won't work....
    By the way i'm using RAB 5.10 & Robotstudio 5.10.
     
    Here's my complete programm, maybe you see what's wrong, i'll keep on trying image
    ' ABB namespaces

    Imports
    ABB.Robotics.Tps.Taf
    Imports
    ABB.Robotics.Controllers
    Imports
    ABB.Robotics.Tps.Windows.Forms
    Imports
    ABB.Robotics.Controllers.RapidDomain.RapidData
    ' Compliance Tool Info

    <Assembly: ABB.Robotics.Tps.Taf.TpsView(
    "test7", "tpu-Operator32.gif", "tpu-Operator16.gif", "TpsViewtest7.dll", _
    "TpsViewtest7.TpsViewtest7", StartPanelLocation.Left, TpsViewType.Dynamic, TpsViewStartupTypes.Manual)>
    Public
    Class TpsViewtest7
    Inherits TpsForm
    Implements ITpsViewSetup, ITpsViewActivation
    Dim ctrl As Controller
    Dim f As FpRapidData
    Dim rd As RapidDomain.RapidData
    Private iTpsSite As ITpsViewLaunchServices
     
     
    Friend WithEvents Button1 As ABB.Robotics.Tps.Windows.Forms.Button
    #
    Region " Windows Form Designer generated code "
    Public Sub New()
    MyBase.New()
    'This call is required by the Windows Form Designer.
    InitializeComponent()
    'Add any initialization after the InitializeComponent() call
    End Sub
    'NOTE: This is where you clean up any remaining resources used by your application before
    'the application itself is disposed of by TAF (TeachPendant Application Framework).
    'The method is called by TAF when the application is closed down.
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    If Not IsDisposed Then
    Try
    If disposing Then
    'ToDo: Call the Dispose method of all FP SDK instances that may otherwise cause memory leak
    End If
    Finally
    MyBase.Dispose(disposing)
    End Try
    End If
    End Sub
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()>
    Private Sub InitializeComponent()
    Me.Button1 = New ABB.Robotics.Tps.Windows.Forms.Button
    Me.SuspendLayout()
    '
    'Button1
    '
    Me.Button1.BackgroundImage = Nothing
    Me.Button1.FontName = New ABB.Robotics.Tps.Windows.Forms.DesignerFont("Font12b")
    Me.Button1.Location = New System.Drawing.Point(101, 118)
    Me.Button1.Size = New System.Drawing.Size(264, 145)
    Me.Button1.TabIndex = 2
    Me.Button1.Text = "Button1"
    Me.Button1.TextAlign = ABB.Robotics.Tps.Windows.Forms.ContentAlignmentABB.MiddleCen ter
    '
    'TpsViewtest7
    '
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit
    Me.BackColor = System.Drawing.Color.LightGray
    Me.Controls.Add(Me.Button1)
    Me.Size = New System.Drawing.Size(640, 390)
    Me.Controls.SetChildIndex(Me.Button1, 0)
    Me.ResumeLayout(False)
    End Sub
    #
    End Region
    #
    Region " ITpsViewSetup Members "
    'NOTE: This method is called by TAF when the control is closed down (before Dispose is called).
    Sub Uninstall() Implements ITpsViewSetup.Uninstall
    'TODO: Add TpsViewtest7.Uninstall implementation
    End Sub
    'NOTE: This method is called by TAF when the control is installed in the framework (after the constructor is called).
    Function Install(ByVal sender As System.Object, ByVal data As System.Object) As Boolean Implements ITpsViewSetup.Install
    'TODO: Add TpsViewtest7.Install implementation
    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
    #
    End Region
    #
    Region " ITpsViewActivation Members "
    'NOTE: This method is called by TAF when the control goes from the active state to the passive state,
    'and is no longer visible in the client view. This happens when the user presses another application button
    'on the task bar, or closes the application. Normally, any subscriptions to controller events are removed here.
    Sub Deactivate() Implements ITpsViewActivation.Deactivate
    'TODO: TODO: Add TpsViewtest7.Deactivate implementation
    End Sub
    'NOTE: This method is called by TAF when the control goes from the passive state to the active state,
    'i.e. becomes visible in the client view. Normally, this is where subscriptions to controller events are set up.
    Sub Activate() Implements ITpsViewActivation.Activate
    'TODO: Add TpsViewtest7.Activate implementation
    End Sub
    #
    End Region
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try
    rd = ctrl.Rapid.GetRapidData(
    "T_ROB1", "user", "pos1")
    If Not rd Is Nothing Then
    f =
    New FpRapidData(rd)
    AddHandler f.Closed, AddressOf FpRapidDataClosed
    f.ShowMe(
    Me)
    Else
    GTPUMessageBox.Show(
    Me, Nothing, "Couldn't get RapidData", "RapidData Access Problem", Windows.Forms.MessageBoxIcon.Hand, Windows.Forms.MessageBoxButtons.OK)
    End If
    Catch ex As Exception
    GTPUMessageBox.Show(
    Me, Nothing, ex.ToString, "Exception", Windows.Forms.MessageBoxIcon.Hand, Windows.Forms.MessageBoxButtons.OK)
    Finally
    If Not rd Is Nothing Then
    rd.Dispose()
    rd =
    Nothing
    End If
    End Try
    End Sub
    Private Sub FpRapidDataClosed(ByVal sender As Object, ByVal e As EventArgs)
    RemoveHandler f.Closed, AddressOf FpRapidDataClosed
    If Not f Is Nothing Then
    f.Dispose()
    f =
    Nothing
    End If
    End Sub
    End
    Class
     
    Grettings "7"
  • Ok, I see your problem. You need to instantiate the controller object somewhere in your code. Usually this is done in the install method.

    ctrl = New controller

    you can also do it in the declaration:

    Dim ctrl as new controller

    It is not necessary to add the ITpsViewLaunchServices stuff unless you want your application to be launched by another application.

    You should also see the section on disposal to make sure that you clean up all of these references when closing your app.

    Russell Drown
  • Ohh, how embarrassed is that for me image

    I only instantiate the controller like this:

    "Dim ctrl as controller" and forgot NEW! The compiler said that's Ok, but didn't work without the "new" in front of the controller ...

    Yeah, now it works!

    Muchas gracias Russ image