示例#1
0
 protected void ConnectDevices(object sender, EventArgs e)
 {
     NIRSrecorder.ConnectDevices connectDevices = new ConnectDevices();
     connectDevices.Run();
 }
示例#2
0
 protected override void OnStart()
 {
     BlobCache.ApplicationName = "SmartGames";
     ConnectDevices connect = new ConnectDevices();
 }
        private async void TimerCommandExecute()
        {
            if (String.IsNullOrEmpty(StudentCode))
            {
                await Application.Current.MainPage.DisplayAlert("Atención", "Debe rellenar el código de alumno", "Aceptar");

                return;
            }

            if (!isAllConnectedDevices(lDevices))
            {
                Loading = true;
                var answer = await Application.Current.MainPage.DisplayAlert("Atención", "No se ha podido establecer conexión con todos los dispositivos. ¿Desea intentarlo de nuevo?", "Reintentar", "Cancelar");

                if (answer)
                {
                    await CrossBluetoothLE.Current.Adapter.StartScanningForDevicesAsync();

                    if (isAllConnectedDevices(lDevices))
                    {
                        ColorFrame = "Green";
                        Loading    = false;
                    }
                    else
                    {
                        ColorFrame = "Red";
                    }

                    return;
                }
                else
                {
                    Loading = false;
                }
            }

            sessionInit             = new SessionInit();
            sessionInit.SessionId   = session.ID;
            sessionInit.StudentCode = StudentCode;
            sessionInit.Date        = DateTime.Now;


            StudentCode = StudentCode;
            if (StartStop.Equals(INICIAR) || StartStop.Equals(REANUDAR))
            {
                StudentCodeEntry = false;
                StartStop        = DETENER;
            }
            else
            {
                StudentCodeEntry = true;
                StartStop        = INICIAR;
            }
            WriteDevices("1");

            Device.StartTimer(TimeSpan.FromMilliseconds(10), () =>
            {
                if (StartStop.Equals(INICIAR) || StartStop.Equals(REANUDAR))
                {
                    WriteDevices("0");
                    return(false);
                }
                else
                {
                    intMilliseconds = intMilliseconds + 10;

                    if (intMilliseconds == 1000)
                    {
                        intMilliseconds = 0;
                        intSeconds++;
                    }

                    if (intSeconds == 60)
                    {
                        intSeconds = 0;
                        intMinutes++;
                    }

                    if (intMinutes / 10 == 0)
                    {
                        Minutes = "0" + intMinutes.ToString();
                    }
                    else
                    {
                        Minutes = intMinutes.ToString();
                    }

                    if (intSeconds / 10 == 0)
                    {
                        Seconds = "0" + intSeconds.ToString();
                    }
                    else
                    {
                        Seconds = intSeconds.ToString();
                    }

                    if (intMilliseconds / 100 == 0)
                    {
                        Milliseconds = "0" + (intMilliseconds / 10).ToString();
                    }
                    else
                    {
                        Milliseconds = (intMilliseconds / 10).ToString();
                    }

                    return(true);
                }
            });

            if (StartStop.Equals(INICIAR))
            {
                StartStop = REANUDAR;
                var action = await Application.Current.MainPage.DisplayActionSheet("¿Que desea hacer?", PAUSAR, FINALIZAR);

                if (action.Equals(FINALIZAR))
                {
                    sessionInit.Time = Minutes + ":" + Seconds + ":" + Milliseconds;
                    ResetChronometer();
                    ConnectDevices.saveData(sessionInit);
                }
            }
        }