hexagon logo

visual studio

I am struggling with two problems. Hopefully someone can help.
The following code will open pcdmis 2014.1, 32 bit, execute a program and close pcdmis.

1) How can I make pcdmis visible? Seems like "PCDApp.visible = True" doesn't do anything.
2) How can I make the application moveable when pcdmis is running? The application can be moved around the screen before and after pcdmis runs, but not during.

Dim PCDApp, PCDPartPrograms, PCDPartProgram
        PCDApp = CreateObject("PCDLRN.Application")
        PCDApp.visible = True
        PCDPartPrograms = PCDApp.PartPrograms
        PCDPartPrograms.Open("c:\test.PRG", "CMM1")
        PCDPartProgram = PCDApp.ActivePartProgram
        PCDPartProgram.Execute()
        PCDPartProgram.Close()
        PCDApp.Quit()
  • I don't have an answer to your 1st question. But, I always leave PCDMIS open. Using the same code you have, minus the quit command.

    When you say "application", do you mean the .net application? If so, you can use another thread to launch PCDMIS. That should still give you access to the form. Only problem is, if you plan to update the form via the new thread, you have to deal with marshaling.
  • I don't have an answer to your 1st question. But, I always leave PCDMIS open. Using the same code you have, minus the quit command.

    When you say "application", do you mean the .net application? If so, you can use another thread to launch PCDMIS. That should still give you access to the form. Only problem is, if you plan to update the form via the new thread, you have to deal with marshaling.



    There's a handy feature called a background worker, which makes this much easier!
  • 1. Maybe you have to do a .Restore or .Maximize on the PC-DMIS Window? Just guessing, I've never seen that problem.

    2. Use .AsyncExecute instead of .Execute. To know when the part program has ended execution, you have to catch the .PCD_ApplicationEventsEndExecution and/or .PCD_PartProgEventsEndExecution or whatever those events are actually called in your development environment.

    I use (2) in a cell system, where my control program also lights up a red/yellow/green flasher, depending on the result of the part program run. There's also a 'watchdog timer' getting reset on every PC-DMIS event, so the red flash can be turned on if PC-DMIS stops generating events (usually means that PC-DMIS has crashed...).
  • 1) I must be missing something really obvious to some of you, but PCDApp .visible, .restore of .maximize does nothing. In fact, the only selections that pop up when I type PCDApp. are Equals, GetHashCode, GetType, ReferenceEquals, or ToString.

    2) Looks like background worker is the way to go. Thanks!

    AndersI, any chance of posting some of the 'watchdog timer' code?
  • 1) I must be missing something really obvious to some of you, but PCDApp .visible, .restore of .maximize does nothing. In fact, the only selections that pop up when I type PCDApp. are Equals, GetHashCode, GetType, ReferenceEquals, or ToString.

    2) Looks like background worker is the way to go. Thanks!

    AndersI, any chance of posting some of the 'watchdog timer' code?


    It's because you've not defined what type of objects you're dealing with so vis studio intelisense can't let you knwo what properties and methods are available.

    Dim PCDApp, PCDPartPrograms, PCDPartProgram

    Try

    Add a reference to the pcdmis object library (Project > Add Ref > Com Tab select your version of pc-dmis)

    then

    dim PCDApp as pcdrln.application
    dim PCDPartPrograms as pcdlrn.partprograms
    dim PCDPartProgram as pcdlrn.partprogram

    Now you will have the methods & properties visible in the development environment
  • well that makes things a little easier. thanks !
  • 2) Looks like background worker is the way to go. Thanks!


    I would still recommend .AsyncExecute. It's already there, built into PC-DMIS.

    AndersI, any chance of posting some of the 'watchdog timer' code?


    It's just a timer set to X seconds, activated on part program start, and reset each time any PC-DMIS event arrives. If PC-DMIS stays silent (event-wise) for more than X seconds, the timer event will be triggered, and the red flash is turned on (via RS232 communication to a PLC). End of PP execution deactivates the timer.
  • The .AsyncExecute is working. Simple solution. However, .close and .quit are Not working now. They Do work if I use .execute

    PCDPartProgram.Close()
    PCDApp.Quit()
  • Are you sure you're not doing them too soon? The VB code after .AsyncExecute will be executed immediately - you have to move .Close and .Quit so they are not executed until after the EndExecution Events have transpired. Also note that the .Close and .Quit can not be put in the EndExecution event handler, it's usually impossible to call back to the server inside a server event handler.