Download OPC Toolbox User`s Guide
Transcript
Use the Default Callback Function grp.RecordsToAcquire = 20; grp.UpdateRate = 0.5; Step 3: Configure the Callback Properties Set the values of three callback properties. The example uses the default callback function opccallback. grp.StartFcn = @opccallback; grp.StopFcn = @opccallback; grp.RecordsAcquiredFcn = @opccallback; For this example, specify how often to generate a records acquired event. grp.RecordsAcquiredFcnCount = 5; Step 4: Start the Logging Task Start the dagroup object. The object logs 20 records at 0.5-second intervals, and then stops. With the three callback functions enabled, the object outputs information about each event as it occurs. The records acquired event occurs four times for this example. start(grp) OPC Start event occurred at local time 18:52:38 Group 'CallbackTest': 0 records acquired. OPC RecordsAcquired event occurred at local time Group 'CallbackTest': 5 records acquired. OPC RecordsAcquired event occurred at local time Group 'CallbackTest': 10 records acquired. OPC RecordsAcquired event occurred at local time Group 'CallbackTest': 15 records acquired. OPC RecordsAcquired event occurred at local time Group 'CallbackTest': 20 records acquired. OPC Stop event occurred at local time 18:52:49 Group 'CallbackTest': 20 records acquired. 18:52:41 18:52:44 18:52:47 18:52:49 Step 5: Clean Up Always remove toolbox objects from memory, and the variables that reference them, when you no longer need them. disconnect(da) 9-3