Monday, April 26, 2010

PVSS C++ Extensions, Part 2

  It is best to also set up the PVSS side of the project so that you may test things quickly. You will need to create a PVSS project, or simply use an existing one. This could be a different tutorial in its own article, but there's no need for such a thing. The PVSS online help should help you go easily through all steps. Just search for "Create project" and you will quickly find what you need.


I will use an existing project for this example. Just add a new manager to the existing project, select it to be a "Control Manager" in order to run a PVSS control script, set it to manual start and give it a name (e.g. "example.ctl").

  Create a new file in the project's scripts folder and name it as in the control manager:
  Now, it's about time to start coding. Back to the C++ project.
Create an "ExampleExt.cpp" file in  the "src" sub-folder and an "ExampleExt.h" in the "include" sub-folder. Copy and paste the following code in the header file : ExampleExt.h. Copy and paste the following code in the source file: ExampleExt.cpp.
Build the project (F7). The project should build with some warnings, but no errors. Copy the output file ("ExampleExt.dll") in the "bin" folder of the PVSS project.

  An optimization step would be to automate the copy operation. Let's say that the pvss project is stored in "C:\work\pvss\projects\workstation". The bin folder would be "C:\work\pvss\projects\workstation\bin". In Visual Studio, go to the project properties, then under "Configuration Properties" -> "Build Events" -> "Post-Build Event" set the "Command Line" to "copy .\build\ExampleExt.dll C:\work\pvss\projects\workstation\bin\ExampleExt.dll". Now, you're free of manual copy operations.

  Back in the PVSS area, use a modern text editor (Notepad++, PsPad, UltraEdit, etc... for this example, Notepad will also suffice), open the file "example.ctl" you created at the beginning of this article and copy and paste the following code into it: Example.ctl.
  In the PVSS console for your project, try starting the Control Manager that contains example.ctl. Make sure that the log viewer is opened for the project. You should see something similar to the following picture in the log:

No comments:

Post a Comment