hexagon logo

looking to catch machine errors with Visual Basic event from Pcdmis

hello all,

I need some help, I want to get the machine errors with a Visual Basic script from Pcdmis and i found the relevant event, but I can't get it to work.
The event is never triggered.

I'm trying to use this event:


Public Event ErrorMsg( _ ByVal Msg As String, _ ByVal ErrorType As Long _ ) handles ??

anyone tried to get this working before ?

thanks

Frank Degryse

Parents
  • I'm not a VB programmer, but I have used this event successfully in C#. To use any PCDMIS event you need to create the event handler method (VB subroutine). Then the name of the subroutine handler needs to be added to the object that generates the event.

    In this case the object that generates the ErrorMsg event is the PCDLRN.Machine object. The PCDLRN.Machine object is obtained from the PCDLRN.Machines object which is an array of machines which was obtained from the PCDLRN.Application object.


    In pseudo code it would look something like the following:
    Dim pcdApplication as PDLRN.Application
    Dim pcdMachines as PCDLRN.Machines
    DIM pcdMachine as PCDLRN.Machine

    // Initialize pcdApplication with a running version of PCDMIS
    pcdApplication = CreateInstance ("Pcdmis") (this is not how it's actually done)

    //With the pcdApplication variable initialized to a session of PCDMIS
    pcdMachines = pcdApplication.Machines

    // pcdMachines is a list of machines. the 'Count' property is the number of machines returned which in most cases is only 1.
    // we check that the list has more the zero machines, if so, then get the first machine in the list
    if (pcdMachines.Count > 0)
    pcdMachine = pcdMachine.Item[0]
    endif

    //We need to tell the ErrorMsg Event what method or subroutine to call when the event is triggered
    pcdMachine.ErrorMsg += HandleErrorMessage (this is how C# adds the HandleErrorMessage callback method to the event.
    AddHandler pcdMachine.ErrorMsg addressOf HandleErrorMessage (I think this is close to how it's done in VB


    //This subroutine is called by the ErrorMsg event when a error message is sent by the machine.
    Subroutine HandleErrorMessage(string msg, int msgNum)
    //put code here to do something with the error message and number
    EndSubroutine
Reply
  • I'm not a VB programmer, but I have used this event successfully in C#. To use any PCDMIS event you need to create the event handler method (VB subroutine). Then the name of the subroutine handler needs to be added to the object that generates the event.

    In this case the object that generates the ErrorMsg event is the PCDLRN.Machine object. The PCDLRN.Machine object is obtained from the PCDLRN.Machines object which is an array of machines which was obtained from the PCDLRN.Application object.


    In pseudo code it would look something like the following:
    Dim pcdApplication as PDLRN.Application
    Dim pcdMachines as PCDLRN.Machines
    DIM pcdMachine as PCDLRN.Machine

    // Initialize pcdApplication with a running version of PCDMIS
    pcdApplication = CreateInstance ("Pcdmis") (this is not how it's actually done)

    //With the pcdApplication variable initialized to a session of PCDMIS
    pcdMachines = pcdApplication.Machines

    // pcdMachines is a list of machines. the 'Count' property is the number of machines returned which in most cases is only 1.
    // we check that the list has more the zero machines, if so, then get the first machine in the list
    if (pcdMachines.Count > 0)
    pcdMachine = pcdMachine.Item[0]
    endif

    //We need to tell the ErrorMsg Event what method or subroutine to call when the event is triggered
    pcdMachine.ErrorMsg += HandleErrorMessage (this is how C# adds the HandleErrorMessage callback method to the event.
    AddHandler pcdMachine.ErrorMsg addressOf HandleErrorMessage (I think this is close to how it's done in VB


    //This subroutine is called by the ErrorMsg event when a error message is sent by the machine.
    Subroutine HandleErrorMessage(string msg, int msgNum)
    //put code here to do something with the error message and number
    EndSubroutine
Children
No Data