Exemplo n.º 1
0
        public async Task <string> ResetMode()
        {
            await Task.Run(() =>
            {
                int devCount = CwUSB.FCWOpenCleware(cwObj);

                if (devCount >= 1)
                {
                    CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_0, 0);
                    CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_1, 0);
                    CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_2, 0);
                }
            });

            return("reset done");
        }
Exemplo n.º 2
0
        public async Task <string> InitiateDuelMode(CancellationToken ct)
        {
            if (ct.IsCancellationRequested) // Is cancellation request already true
            {
                ct.ThrowIfCancellationRequested();
            }
            CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_1, 1); //turning the orange light on
            await Task.Delay(PREPARATION_TIME, ct);

            CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_1, 0); // and off

            //loop of 5 because of 5 rounds

            for (int i = 0; i < 5; i++)
            {
                CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_0, 1); //turning the red light on
                await Task.Delay(AVERTED_TIME, ct);

                CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_0, 0); // and off

                CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_2, 1); //turning the green light on
                await Task.Delay(FACED_TIME, ct);

                CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_2, 0); // and off
            }

            //show red light after the last green phase
            CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_0, 1); //turning the red light on
            await Task.Delay(AVERTED_TIME, ct);

            CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_0, 0); // and off

            // orange light on for 5 secs to signal ending
            CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_1, 1); //turning the orange light on
            await Task.Delay(AFTERMATH_TIME, ct);

            CwUSB.FCWSetSwitch(cwObj, 0, (int)CwUSB.SWITCH_IDs.SWITCH_1, 0); // and off

            return("done");
        }