Example: CWBinding Features
Demonstrates a wide variety of CWBinding features.
Description
The user interface controls in this example use integrated DataSocket connectivity to connect a property from the control to a data item. Integrated DataSocket connectivity works through CWBinding objects. The actual connection between the external data item and the control property is called a binding.
CWGraph1 uses two CWBinding objects to connect two separate plots to two separate data items on the National Instruments OPC Demo server: a square wave generator and a sine wave generator. Both bindings are connected in Read mode with an update interval of 100 ms. The initial data is read and charted as soon as the connection is made and then updated every 100 ms. This type of binding is useful if you want to chart y data with respect to actual time, rather than charting new data when ever it is available (the x-axis values becomes arbitrary). Check the Bindings property page to see how to specify interval updates. If you want to set intervals programmatically, use the CWBinding.TimerInterval property.
CWSlide1 creates a binding in the property page that configures a CWBinding object to write data to an item on the National Instruments OPC Demo server. CWGraph2 programmatically creates a CWBinding and connection to the same item in read mode so that the data from the slide is visualized in a plot on the graph. Try moving the value of the slide and see how the plot on the graph responds.
The binding on CWKnob1, which also is configured in the Bindings property page, connects to a sine generator on the National Instruments OPC Demo server and automatically reads new data. As each new data point is received, CWKnob1 generates the CWBindingDataUpdated event. This event procedure checks the range of each data point. If a data point exceeds 9, then the knob turns red. If the data point falls below 1, then the knob turns yellow. You can use the CWBindingDataUpdated event to manipulate, process, or save data from the data source. CWKnob1 uses the CWBindingStatusUpdated event to check the status of the binding connection and display it on the user interface.
Controls, Properties, Methods, and Events
This example demonstrates the following controls, properties, methods, and events:
AccessMode, URL, BindProperty, SetBindObject, ConnectTo, Disconnect, Connect
Example Location
Samples\UI\Common\CWBinding