Automatic Notification to User Application

This example (demoPrograms\engine\VC#\notify or demoPrograms\engine\VB\notify) demonstrates how to get WiT Engine to notify your .Net application whenever data change, and how to set parameters in a WIC.


Notification of Change and Setting Operator Parameters

The declarations and Form Unload sections are standard.

In the Form1_Load method, the SetOutputCallback method is used to instruct WiT Engine to call the myOutCallback event procedure when data in the window named ‘data’ changes. Similarly, SetStateCallback is used to tell WiT Engine to call the myStateCallback event procedure whenever the WIC execution state changes (e.g. from idle to running to stopped).

[C#]
myOutCallback = new WiT.engine.outputCB(dataChanged);
WiT.engine.SetOutputCallback("data", myOutCallback, 
    (int)WiT.DataFormat.WIT_DATA_FORMAT_NONE);

[Visual Basic]
myOutCallback = New WiT.engine.outputCB(AddressOf dataChanged)
WiT.engine.SetOutputCallback("data", myOutCallback, _
    CType(WiT.DataFormat.WIT_DATA_FORMAT_NONE, Integer))

The application loads the WIC from demoPrograms\engine\wic\notify.wic on startup. If the WiT code file is successfully loaded, the Run button is enabled. The Run button procedure demonstrates how parameters in a WIC can be changed. The parameter values are read from the Image, Loop, and Smooth controls:

[C#]

WiT.engine.SetOpParam(exehandle, "filename", imNameWgt.Text);
WiT.engine.SetOpParam(exehandle, "count", loopWgt.Text);
WiT.engine.SetOpParam(exehandle, "width", smoothWgt.Text)
WiT.engine.SetOpParam(exehandle, "height", smoothWgt.Text)
WiT.engine.ControlExec(execID, (short)WiT.ExeCmds.WIT_EXE_FLASH, 0)

[Visual Basic]
WiT.engine.SetOpParam(exehandle, "filename", imgText.Text)
WiT.engine.SetOpParam(exehandle, "count", loopText.Text)
WiT.engine.SetOpParam(exehandle, "width", _
                      smoothCmb.SelectedItem.ToString())
WiT.engine.SetOpParam(exehandle, "height", _
                      smoothCmb.SelectedItem.ToString())
WiT.engine.ControlExec(exehandle, _
                       CType(WiT.ExeCmds.WIT_EXE_FLASH, Short), 0)

While the WIC is running, the Pause and Stop buttons are enabled, and the Run button is disabled. If you press Pause, the Run button is enabled. When the WIC terminates by itself or after your press Stop, the application goes back to its initial state: Run is enabled, Pause and Stop are disabled. These buttons use ControlExec with different arguments to control the execution.

Previous 

Up 

Next