示例#1
0
        static async Task TestEvents(IUArm uArm)
        {
            //Console.WriteLine("Disable default function of the base buttons");
            //await uArm.SetEnableDefaultFunctionOfBaseButtonsAsync(false);

            Console.WriteLine("Enable event handler loggers");
            uArm.LimitedSwitchStateChanged += OnLimitedSwitchStateChanged;
            uArm.PowerConnectionChanged    += OnPowerConnectionChanged;
            uArm.ReceivedButtonAction      += OnReceivedButtonAction;
            uArm.ReceivedPositionFeedback  += OnReceivedPositionFeedback;

            while (true)
            {
                Console.WriteLine("Input 'F' to start 1.0sec freq feedback, 'D' to disable, or end by other pattern");
                string line = Console.ReadLine();
                if (string.Compare("F", line, true) == 0)
                {
                    Console.WriteLine("start feedback");
                    await uArm.StartFeedbackCycleAsync(1.0f);

                    Console.WriteLine("wait 5sec, and see the feedback example");
                    await Task.Delay(5000);
                }
                else if (string.Compare("D", line, true) == 0)
                {
                    Console.WriteLine("stop feedback");
                    await uArm.StartFeedbackCycleAsync(0.0f);
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine("Disable event handler loggers");
            uArm.LimitedSwitchStateChanged -= OnLimitedSwitchStateChanged;
            uArm.PowerConnectionChanged    -= OnPowerConnectionChanged;
            uArm.ReceivedButtonAction      -= OnReceivedButtonAction;
            uArm.ReceivedPositionFeedback  -= OnReceivedPositionFeedback;

            //Console.WriteLine("Enable default function of the base buttons");
            //await uArm.SetEnableDefaultFunctionOfBaseButtonsAsync(true);
        }