hexagon logo

Example of handling PC-Dmis events in VB

In this version, I respond to a PM asking for more info on handling events from PC-Dmis. Starting with version 1 of the Clock Start application, I've added another Listbox to the user window. This listbox will be used to show the pass/fail of Dimension measurements as they happen during execution of the measurement program.

The source code has a lot of comment lines so I'm not going into the details of the code itself. But will answer any questions posted here about the code in this posting.

There are a couple of things I should explain. In the Pcdmis-VB_Library, I added two new classes, DimensionData and DimensionFactory. The purpose of these two classes is to translate the PC-Dmis Dimension statement and measurement results into a neutral data structure. The DimensionFactory does the translating and the result is a DimensionData object containing all the data from the PC-Dmis Dimension statement. It is this DimensionData object that is passed back to the user application. Remember, only the classes in the Pcdmis-VB_Library have access to PC-Dmis API. The user application does not.

Secondly, this version handles the PC-Dmis event "OnObjectExecuted". The handler, when triggered, checks to see if the "Object" executed is a Dimension Statement. If so, it processes it as described above, then raises a PcdmisWrapper event "DimensionAvailable". If the user application has assigned a handler to this event (in this application there is) then that handler is triggered and it receives the DimensionData Object from the PcdmisWrapper. In this user application the DimensionData is saved in a collection dictionary of DimensionData objects as well as the ListBox UI component. If the user clicks on a dimension in the Listbox, a popup will appear listing the contents of the dimension data.

There are two Version 2.0-0 zip files in the google drive. One is the compile application the other is the VB project files.

https://drive.google.com/drive/folders/1F1SnmqbyUKa35XhVJ1eV_v-0D91SXLmH?usp=sharing