+1-866-946-2263 / +1-530-776-0843 Mon–Fri
0 Items

Tutorial: Interfacing to C++ in Visual Studio 2013

Posted by John Goedert on 8/31/2016 to General
Tutorial: Interfacing to C++ in Visual Studio 2013

It is our pleasure to announce a new Visual C++ tutorial for interfacing DataRay Camera and Slit Scan Profilers using the DataRay OCX. The DataRay OCX is an ActiveX component that can be accessed from a variety of Windows based environments. It includes ActiveX controls that allow users to build an interface that is capable of sending and receiving data from the DataRay software. The OCX is automatically generated and registered with the Windows operating system upon installation of the standard DataRay software. Complete documentation of the DataRay OCX is available for reference. Before writing an interface using the DataRay OCX, we recommend that you learn to use your beam profiler in the standard DataRay software.

In this tutorial, we will show you step by step how an example custom interface was created in Visual C++ as a Microsoft Foundation Class (MFC) application. This example can be used with any of DataRay’s WinCamD beam profiling cameras. The MFC library offers a large set of classes, data types, and functions to simplify the creation of applications for the Microsoft Windows family of operating systems. The MFC library is utilized in this tutorial to create an application dialog box, which hosts DataRay OCX controls. The first portion of the tutorial demonstrates how to include the OCX elements of your choosing by utilizing the Resource View Toolbox, which is populated with DataRay controls. Next, the properties of the controls are modified to assign the controls a diverse range of functions, including modifiable settings and visual representations of real-time measurement results.

After demonstrating how to build and run a simplified custom interface, the tutorial explains how the OCX can be utilized to develop and implement event handling features in your custom software. If you would like to include code in your project that will be executed only when a specified event occurs, consider utilizing event handling. In this tutorial, we work with an event that is triggered every time a new frame is available for processing. Our example code contains a function that is called every time this event is fired. You can insert whatever code you want into this function and it will be executed once per new image. This is an effective method for recording data on a per frame basis.

There are many techniques and calculations provided by the standard DataRay software, but in some situations it may be useful to manipulate data provided directly by the OCX. In the third and final part of the tutorial, we will demonstrate how to programmatically extract data from the OCX using three methods: creating control classes or variables, querying directly for parameters, and sending data by means of variants. Sending data by means of variants is the preferred method for reading large amounts of data from the OCX. In this tutorial, we illustrate one method for reading and retrieving 2D image data via a variant, and we store the information as an array of pixel data in a .csv file.

There are additional tutorials and examples available in the interfacing section of our site that are helpful for developing interfaces not only in Visual C++, but also in Python, LabView, MATLAB, and Visual Basic. If you have any questions regarding interfacing DataRay beam profilers, please do not hesitate to contact us. We would love to speak with you about setting up your custom interface.