Once you have created device drivers for your measurement instruments, you are ready to build HTML data acquisition applications. Typical purpose of such application is to synchronize several devices with different response time, perform data averaging, control signal commutation and sweep (or scanning).
When you run Measurement System Wizard discussed in the last part of this article, you implicitly select one of four types of universal measurement control cycles. To better understand DHTML code produced by this wizard, look at four simplified diagrams shown below:
On this diagram, TriggerDevices procedure is called when user clicks Run or Point button to start measurements. It calls Trigger method for all device drivers. After all devices have invoked OnData event, ProcessOnData procedure calls ProcessReadout which, in turn, performs data averaging (data averaging cycles are divided by AverageDelay timeouts) and, finally, calls AddPoint procedure that calculates values of columns to be inserted into DM2003 data window by averaged device channel values. After MainDelay timeout, the cycle loops. Notice that some elements at the diagram (ones that have yellow background) involve time delays - that is, appropriate procedures are called using window.SetTimeout() that defers actual code execution for given timeout value.
Unlike general device synchronization cycle from previous diagram, in this case AddPoint calls ScanStep procedure. The latter checks whether scanning is active, sends appropriate command to the scanner device and calls TriggerDevices after ScanDelay timeout. Synchronous sweep implemented by this type of cycles allows to provide stable measurement conditions since the moments of taking signal readout always divided from scanning steps by equal time intervals.
Signal commutation is essential requirement for many data acquisition applications, that's why abstract commutation was implemented in this measurement control cycle (see Fig. 3). After averaging data, ProcessReadout calls ChangeState procedure which is responsible for commutation control. Every state change is followed by relaxation timeout (StateDelay). At the last state of commutation sequence, this procedure invokes AddPoint as in the previous types of cycles.
The diagram shown above is the most versatile type of control cycles. In fact, this is a combination of two previous cycles. After commutator device has switched all states and AddPoint procedure has calculated current data point, next cycle is started from ScanStep procedure.
Each type of control cycles discussed above is based on special code template used by Measurement System Wizard, default templates are installed along with other sample files. You can use them to create your own templates so that DAQ applications generated by this wizard can be easily customized. For example, you can add your own UI controls and algorithms that may be utilized in all applications created from this template.
Template technology uses special tags formatted as follows: <#tagname>, where tagname - any unique identifier. When wizard processes template, it replaces those tags by actual values entered by the user. Full set of tag names listed in the table below: