Esempio n. 1
0
    // =================================================================================================
    // Accelerometer_ReadingChanged
    //
    // The accelerometer posts about 30 readings per timer-event.  
    //    This function is entered about 30 times per ONE CPR Compress.
    // One of the 30+ accelerator events happen to be at the same
    //    moment the timer event happen.
    //
    // The first 5 readings are discarded; noise.
    //
    // The accelerator axis are:
    //     X / Y parallel to surface ( think north, east)
    //     Z perpendicular to surface ( think down to earth center, up into space)
    //
    // If Accelerator Z direction (away from ground) is: 
    // (+, positive), it points down, and we have a CPR Compress. CONTINUE 
    // (-, negative), it points up, and we have a CPR Recoil, STOP.
    // =================================================================================================
    private void Accelerometer_ReadingChanged(object sender, AccelerometerChangedEventArgs e)
    {
      //
      noise_Readings++;
      if (noise_Readings <= noiseRead_Level) return;// Skip very first (5) reads; Noise
      if (inPrinting) return;                       // in printing, and NO ACTIVITIES!!
      // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      read_XYZ(e.Reading);                          // Get the X, Y, Z, total Z, readings.
                                                    //
      if (newTimerEvent)                            // Display at each timer event (100/min, every approx 30th acceleration read)
      {
        if (aTotalZ_cnt > 0)                        // after at least one accelerator read
        {
                                                    // Phone must be flat for a valid accelerometer reading
          if (isPhoneLayingFlat(tilt_40, aX, aY))   // iS tilted IF X/Y > 0.4 (40).
          {
            aclAvgZ = aTotalZ / aTotalZ_cnt;          // Get average Z
            thirtyCountProc();                      // process CPR count (30, and Sets)
            Gen_Utility_1.BeepOnce();                     // beep if beep is allowed
                                                    // Only process "Downward" events
                                                    //if (aclAvgZ < 98)                       // 98 = rest on a desk
            displayCPR_Actions(aclAvgZ);            // show " Correct CPR ", " Too Shallow ", " Too Deep "
            showTESTdata(aclAvgZ);
            //
            newTimerEvent = false;                  // turned on inside timer event
            aTotalZ = 0;                            //
            aTotalZ_cnt = 0;                        //
          }
        }
      }

    }
Esempio n. 2
0
        // ====================================================================================================================================
        // Item selected from List
        //
        // ====================================================================================================================================
        async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var temp1 = e.SelectedItem as itemsDBTable;

            if (e.SelectedItem != null)
            {
                //App.toManageRules = temp1.SilenceRangeDB;
                //await Navigation.PushAsync(new ManageRules
                //{
                BindingContext = e.SelectedItem as itemsDBTable;
                //});
            }

            // announce, and let user decide if yes/no
            string strMM = AppResources.CPRResultData1 + "  " + temp1.datetimeCPR
                           + AppResources.CPRResultGoodData + "  " + temp1.goodCPR
                           + AppResources.CPRResultShallowData + "  " + temp1.shallowCPR
                           + AppResources.CPRResultShallowData + "  " + temp1.deepCPR + "\n\n";
            await Gen_Utility_1.DisplaySfPopupAlert(AppResources.CPRResultDeleteData, strMM, AppResources.CPRResultYesDelete, AppResources.CPRResultDeleteCancel);

            if (Alles.PopupAccepted)
            {
                BindingContext = e.SelectedItem as itemsDBTable;
                var sqlitem = (itemsDBTable)BindingContext;
                await App.Database.DeleteItemAsync(sqlitem).ConfigureAwait(true);

                listView.ItemsSource = await App.Database.GetItemsAsync(); //await App.Database.GetNotesAsync();

                //await Navigation.PopAsync();
            }
        }
Esempio n. 3
0
    // =======================================================================
    // pop up for popup-notification
    //
    // ======================================================================
    private async Task popup001()
    {
      //
      // announce, and let user decide if yes/no
      string strMM = AppResources.CPRSimulPopupmsg;
      await Gen_Utility_1.DisplaySfPopupAlert("CPR Simulation", strMM, AppResources.CPRSimulGotit, "");
      if (Alles.PopupAccepted)
      {
      }

    }
Esempio n. 4
0
    // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // Save. Save will display "no input" alert.
    //
    // Input via:
    // Id          =  ID (auto increment while adding the record) 
    // Run Date    =  DateTime.Now.ToString("MM/dd/yyyy hh:mm tt");
    // goodCPR     =  goodCPR;
    // schallowCPR =  flatCPR;
    // deepCPR     =  deepCPR;
    // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    private async void btResults_Clicked(object sender, EventArgs e)
    {
      string strLL;
      string strMM;
      string errMSGHeader = AppResources.CPRSimulResultMsg1; // "CPR Simulated Training Result";
      inPrinting = true;

      try
      {
        // noActions is on (true), we have NO RESULT(S), don't save
        //
        if (noActions)
        {
          //
          strLL = AppResources.CPRSimulResultMsg2; // "\nNo CPR Simulation Result available.\n"
                  //+ "___________________________________\n\n"
            //+ "  Please run a set of simulated CPR's\n"
            //+ "    and try again.\n";
          await Gen_Utility_1.DisplaySfPopupAlert(errMSGHeader, strLL, AppResources.CPRSimulGotit, "");
          if (Alles.PopupAccepted)
          {
          }
          inPrinting = false;
        }
        else
        {
          BindingContext = new itemsDBTable();
          var sqlitem = (itemsDBTable)BindingContext;
          sqlitem.datetimeCPR = DateTime.Now.ToString("MM/dd/yyyy hh:mm tt");
          sqlitem.goodCPR = totalCorrectCPR.ToString();
          sqlitem.shallowCPR = totalFlatCPR.ToString();
          sqlitem.deepCPR = totalTooDeepCPR.ToString();

          // announce, and let user decide if yes/no
          //////strMM = "\n  Adding CPR Simulation Results:\n"
          //////        + "  ______________________________\n\n"
          //////+ " Good Compressions .. .. .. .. .".PadRight(40) + sqlitem.goodCPR + "\n"
          //////+ " Compressions too Shallow..".PadRight(37) + sqlitem.shallowCPR + "\n"
          //////+ " Compressions to Deep .. .. ..".PadRight(40) + sqlitem.deepCPR + "\n\n";

          String data11 = String.Format("{0,-40} {1,-10}", AppResources.CPRSimulResultdata11, sqlitem.goodCPR);
          String data22 = String.Format("{0,-36} {1,-10}", AppResources.CPRSimulResultdata22, sqlitem.shallowCPR);
          String data33 = String.Format("{0,-38} {1,-10}", AppResources.CPRSimulResultdata33, sqlitem.deepCPR);

          strMM = AppResources.CPRSimulResultstm // "\n  Adding CPR Simulation Results:\n"
                  //+ "  ______________________________\n\n"
          + data11 + "\n"
          + data22 + "\n"
          + data33 + "\n\n";


          await Gen_Utility_1.DisplaySfPopupAlert(errMSGHeader, strMM, AppResources.CPRSimulResultYes, AppResources.CPRSimulCancel);
          if (Alles.PopupAccepted)
          {
            await App.Database.SaveItemAsync(sqlitem);
            readyBeep.IsOn = false;     // the first hit (false) is needed to set the 'stage'
            zeroOut();
            this.getAccelerometer();
            if (Alles.popupmsg_001) _ = popup001();
            await this.Navigation.PushAsync(new Results());
          }
          else
          {
            inPrinting = false;
          }
        }
      }
      catch (Exception sqle1)
      {
        _ = (sqle1.Message.ToString());
      }


    }