Samples Silverlight adserr = AdsGetVarHandleEx(port, addr, ".deviceUp", &hDeviceUp); if(adserr == 0) adserr = AdsGetVarHandleEx(port, addr, ".deviceDown", &hDeviceDown); if(adserr == 0) adserr = AdsGetVarHandleEx(port, addr, ".steps", &hSteps); if(adserr == 0) adserr = AdsGetVarHandleEx(port, addr, ".count", &hCount); if(adserr == 0) adserr = AdsGetVarHandleEx(port, addr, ".switch", &hSwitch); // Ьberwachung der SPS-Variablen initialisierenif(adserr == 0) { attr.cbLength = 1; adserr = AdsSyncAddDeviceNotificationReqEx(port, addr, ADSIGRP_SYM_VALBYHND, hEngine, &attr, Callback, engine, &hEngineNotification); } if(adserr == 0) { attr.cbLength = 1; adserr = AdsSyncAddDeviceNotificationReqEx(port, addr, ADSIGRP_SYM_VALBYHND, hDeviceUp, &attr, Callback, deviceUp, &hDeviceUpNotification); } if(adserr == 0) { attr.cbLength = 1; adserr = AdsSyncAddDeviceNotificationReqEx(port, addr, ADSIGRP_SYM_VALBYHND, hDeviceDown, &attr, Callback, deviceDown, &hDeviceDownNotification); } if(adserr == 0) { attr.cbLength = 1 adserr = AdsSyncAddDeviceNotificationReqEx(port, addr, ADSIGRP_SYM_VALBYHND, hSteps, &attr, Callback, steps, &hStepsNotification); } if(adserr == 0) { attr.cbLength = 2; adserr = AdsSyncAddDeviceNotificationReqEx(port, addr, ADSIGRP_SYM_VALBYHND, hCount, &attr, Callback, count, &hCountNotification); } if(adserr == 0) { attr.cbLength = 1; adserr = AdsSyncAddDeviceNotificationReqEx(port, addr, ADSIGRP_SYM_VALBYHND, hSwitch, &attr, Callback, switchSpeed, &hSwitchNotification); } return adserr; } When disconnecting the Ads connection, the handles of the PLC variables must be released and the port closed.
long disconnect(long port, AmsAddr* addr) { // Handles der SPS-Variablen freigeben AdsFreeVarHandleEx(port, addr, hEngine); AdsFreeVarHandleEx(port, addr, hDeviceUp); AdsFreeVarHandleEx(port, addr, hDeviceDown); AdsFreeVarHandleEx(port, addr, hSteps); AdsFreeVarHandleEx(port, addr, hCount); AdsFreeVarHandleEx(port, addr, hSwitch); // Notifications lцschen AdsSyncDelDeviceNotificationReqEx(port, addr, hEngineNotification); AdsSyncDelDeviceNotificationReqEx(port, addr, hDeviceUpNotification); AdsSyncDelDeviceNotificationReqEx(port, addr, hDeviceDownNotification); AdsSyncDelDeviceNotificationReqEx(port, addr, hStepsNotification); AdsSyncDelDeviceNotificationReqEx(port, addr, hCountNotification); AdsSyncDelDeviceNotificationReqEx(port, addr, hSwitchNotification); // Kommunikationsport schlieЯen TX1000 16 Version:
1.2