The following methods of queuing in the CLX arrays and unloading via use of the xCoupler trigger handshaking has been used by many customers in the past few years to guarantee no miss data transitions even when the round-trip times to the database/MQ have temporary slowdowns in their response time.
NOTE: This example is provided as just that an example of the concept of the data queuing for our customer.
The xc_queue program is an example of how the xCoupler can record the values of many different UDTs while only actually monitoring a few tags, which also allows the xCoupler to run much faster and more efficiently.
The basic concept is that the controller copies all the data into arrayed variables, and then copies elements from the array one at a time into a few tags which the xCoupler then takes and sends to the database.
In this example program, the program has 100 virtual “meter” structures. The Load routine will copy the data from each of these meters into a 100 element structure array.
After this completes a bit is set, which causes the Unload routine to run.
The Unload routine uses a FOR loop to run through the structure array.
1.
Each element is first copied to the tags monitored by the xCoupler.
2.
The routine waits a second (Note: trigger priority=1s), to ensure the correct values are read by the xCoupler,
3.
Then, the xC_Ready tag is incremented, to cause the trigger in the xCoupler to fire.
4.
The routine waits until the xCoupler returns a value to the xC_Complete tag, signaling that the trigger has completed,
5.
Then, the loop executes again, for the next element of the array. This happens for every element of the array, which each contains data from one of the meter structures.
In the main routine a timer is used so that data is only collected from the meter structures every 5 minutes (300,000 milliseconds). This is a predefined time which can be configured by editing the qTimer tag’s Preset value.