コード例 #1
0
        public static void Do_TwincatNotification(bool burn)
        {
            var cts = new CancellationTokenSource();

            AdsClient client = new AdsClient();

            client.Connect(AmsPort.R0_RTS + 1);

            client.AdsNotification += (s, e) => DoTick();
            var notiSets = new NotificationSettings(AdsTransMode.OnChange, 1, 0);
            var h_tick   = client.AddDeviceNotification("MAIN.tick", 1, notiSets, null);

            if (burn)
            {
                CpuBurner.Fire(cts.Token);
            }

            Wait_PressEnterToStop();

            cts.Cancel();
            client.DeleteDeviceNotification(h_tick);
            client.Disconnect();
        }