public void Write(CalibrationExerciseResultPitaco result, CalibrationExercisePitaco exercise, float value) { switch (exercise) { case CalibrationExercisePitaco.ExpiratoryPeak: case CalibrationExercisePitaco.InspiratoryPeak: FlowDataDevice.FlowData.Add(new FlowData { Date = DateTime.Now, Value = PitacoFlowMath.ToLitresPerMinute(value) }); break; case CalibrationExercisePitaco.RespiratoryFrequency: FlowDataDevice.FlowData.Add(new FlowData { Date = DateTime.Now, Value = value * 60f }); break; default: FlowDataDevice.FlowData.Add(new FlowData { Date = DateTime.Now, Value = value / 1000f }); break; } }
//Stores the score of the round and change the stars sprites public void ReceivedStars(int roundScore, int roundNumber, float pikeValue) { totalScores[roundNumber] = roundScore; // Se o Pitaco estiver conectado if (scp.IsConnected) { FinalScore.pikeString[roundNumber].text += $"{PitacoFlowMath.ToLitresPerMinute(pikeValue)} L/min ({pikeValue} pa)"; } else { // Se o Mano estiver conectado if (scm.IsConnected) { FinalScore.pikeString[roundNumber].text += $"{ManoFlowMath.ToCentimetersofWater(pikeValue)} CmH2O ({pikeValue} pa)"; } else { // Se a Cinta de Pressão estiver conectada if (scc.IsConnected) { FinalScore.pikeString[roundNumber].text += $"{CintaFlowMath.ToLitresPerMinute(pikeValue)} L/min ({pikeValue} pa)"; } } } //////////////////////////////////////// WaterBehaviour(roundScore); for (int i = 0; i < roundScore; i++) { starsUI[i].sprite = starFilled; } }
public void ShowPlayerInfo() { //%%%%%%%%%% Tradução da condição respiratória para português %%%%%%%%%% var obstructiveTranslation = "Obstrutivo"; var restrictiveTranslation = "Restritivo"; var healthyTranslation = "Saudável"; var disfunction = Pacient.Loaded.Condition == ConditionType.Healthy ? healthyTranslation : (Pacient.Loaded.Condition == ConditionType.Obstructive ? obstructiveTranslation : restrictiveTranslation); ////////////////////////////////////////////////////////////////////////////// GameObject.Find("Canvas").transform.Find("Informations Menu").gameObject.SetActive(true); var TextPacient = GameObject.FindWithTag("txPacient").gameObject.GetComponent <Text>(); var TextPitacoInfos = GameObject.FindWithTag("txPitacoInfos").gameObject.GetComponent <Text>(); var TextManoInfos = GameObject.FindWithTag("txManoInfos").gameObject.GetComponent <Text>(); var TextCintaInfos = GameObject.FindWithTag("txCintaInfos").gameObject.GetComponent <Text>(); TextPacient.text = $"Jogador: {Pacient.Loaded.Name}\n" + $"Condição Respiratória: {disfunction}\n" + $"Partidas Jogadas: {Pacient.Loaded.PlaySessionsDone}\n"; TextPitacoInfos.text = $"Pico Exp.: {PitacoFlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesPitaco.RawExpPeakFlow):F2} L/min ({Pacient.Loaded.CapacitiesPitaco.RawExpPeakFlow:F2} Pa)\n" + $"Pico Ins.: {PitacoFlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesPitaco.RawInsPeakFlow):F2} L/min ({Pacient.Loaded.CapacitiesPitaco.RawInsPeakFlow:F2} Pa)\n" + $"Tempo Ins.: {Pacient.Loaded.CapacitiesPitaco.RawInsFlowDuration / 1000f:F1} s\n" + $"Tempo Exp.: {Pacient.Loaded.CapacitiesPitaco.RawExpFlowDuration / 1000f:F1} s\n" + $"Tins/Texp: {((Pacient.Loaded.CapacitiesPitaco.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesPitaco.RawExpFlowDuration / 1000f)):F1}\n" + $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesPitaco.RawRespRate * 60f:F1} rpm\n"; TextManoInfos.text = $"Pico Exp.: {ManoFlowMath.ToCentimetersofWater(Pacient.Loaded.CapacitiesMano.RawExpPeakFlow):F2} cmH2O ({Pacient.Loaded.CapacitiesMano.RawExpPeakFlow:F2} Pa)\n" + $"Pico Ins.: {ManoFlowMath.ToCentimetersofWater(Pacient.Loaded.CapacitiesMano.RawInsPeakFlow):F2} cmH2O ({Pacient.Loaded.CapacitiesMano.RawInsPeakFlow:F2} Pa)\n" + $"Tempo Ins.: {Pacient.Loaded.CapacitiesMano.RawInsFlowDuration / 1000f:F1} s\n" + $"Tempo Exp.: {Pacient.Loaded.CapacitiesMano.RawExpFlowDuration / 1000f:F1} s\n" + $"Tins/Texp: {((Pacient.Loaded.CapacitiesMano.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesMano.RawExpFlowDuration / 1000f)):F1}\n"; TextCintaInfos.text = $"Pico Exp.: {Pacient.Loaded.CapacitiesCinta.RawExpPeakFlow:F2} Pa\n" + $"Pico Ins.: {Pacient.Loaded.CapacitiesCinta.RawInsPeakFlow:F2} Pa\n" + $"Tempo Ins.: {Pacient.Loaded.CapacitiesCinta.RawInsFlowDuration / 1000f:F1} s\n" + $"Tempo Exp.: {Pacient.Loaded.CapacitiesCinta.RawExpFlowDuration / 1000f:F1} s\n" + $"Tins/Texp: {((Pacient.Loaded.CapacitiesCinta.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesCinta.RawExpFlowDuration / 1000f)):F1}\n" + $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesCinta.RawRespRate * 60f:F1} rpm"; }
public void DisplayFinalScore(int score1, int score2, int score3) { scp = FindObjectOfType <SerialControllerPitaco>(); scm = FindObjectOfType <SerialControllerMano>(); scc = FindObjectOfType <SerialControllerCinta>(); finalScore[0].FillStarsFinal(score1); finalScore[1].FillStarsFinal(score2); finalScore[2].FillStarsFinal(score3); // Se o Pitaco estiver conectado if (scp.IsConnected) { peakText[0].text = " Pico: " + PitacoFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[0])) + " L/min"; peakText[1].text = " Pico: " + PitacoFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[1])) + " L/min"; peakText[2].text = " Pico: " + PitacoFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[2])) + " L/min"; } else { // Se o Mano estiver conectado if (scm.IsConnected) { peakText[0].text = " Pico: " + ManoFlowMath.ToCentimetersofWater(Parsers.Float(pikeString[0])) + " CmH2O"; peakText[1].text = " Pico: " + ManoFlowMath.ToCentimetersofWater(Parsers.Float(pikeString[1])) + " CmH2O"; peakText[2].text = " Pico: " + ManoFlowMath.ToCentimetersofWater(Parsers.Float(pikeString[2])) + " CmH2O"; } else { // Se a Cinta Extensora estiver conectada if (scc.IsConnected) { peakText[0].text = " Pico: " + CintaFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[0])) + " L/min"; peakText[1].text = " Pico: " + CintaFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[1])) + " L/min"; peakText[2].text = " Pico: " + CintaFlowMath.ToLitresPerMinute(Parsers.Float(pikeString[2])) + " L/min"; } } } //////////////////////////////////////// }
private IEnumerator Flow(int round) { scp = FindObjectOfType <SerialControllerPitaco>(); scm = FindObjectOfType <SerialControllerMano>(); scc = FindObjectOfType <SerialControllerCinta>(); if (scp.IsConnected) // Se PITACO conectado { //While player does not blow. while (sensorValuePitaco >= -Pacient.Loaded.PitacoThreshold * 2f) { //Debug.Log($"Wait: {sensorValue}"); yield return(null); } //Player is blowing, take the highest value. while (sensorValuePitaco < -Pacient.Loaded.PitacoThreshold) { //Debug.Log($"Blow: {sensorValue}"); if (sensorValuePitaco < maximumPeak) { maximumPeak = sensorValuePitaco; //Debug.Log("Novo pico máximo: " + maximumPeak); } //calculate the percentage of the pike. yield return(null); } } else { if (scm.IsConnected) // Se Mano conectado { //While player does not blow. while (sensorValueMano >= -Pacient.Loaded.ManoThreshold * 2f) { //Debug.Log($"Wait: {sensorValue}"); yield return(null); } //Player is blowing, take the highest value. while (sensorValueMano < -Pacient.Loaded.ManoThreshold) { //Debug.Log($"Blow: {sensorValue}"); if (sensorValueMano < maximumPeak) { maximumPeak = sensorValueMano; //Debug.Log("Novo pico máximo: " + maximumPeak); } //calculate the percentage of the pike. yield return(null); } } else { if (scc.IsConnected) // Se CINTA conectada { //While player does not blow. while (sensorValueCinta >= -Pacient.Loaded.CintaThreshold * 2f) { //Debug.Log($"Wait: {sensorValue}"); yield return(null); } //Player is blowing, take the highest value. while (sensorValueCinta < -Pacient.Loaded.CintaThreshold) { //Debug.Log($"Blow: {sensorValue}"); if (sensorValueCinta < maximumPeak) { maximumPeak = sensorValueCinta; //Debug.Log("Novo pico máximo: " + maximumPeak); } //calculate the percentage of the pike. yield return(null); } } } } SoundManager.Instance.PlaySound("Success"); var roundScore = CalculateFlowPike(maximumPeak); WriteMinigameLog(round, roundScore, PitacoFlowMath.ToLitresPerMinute(maximumPeak)); waitSignal = false; maximumPeak = 0f; OnAuthorize(); }
public void ShowPlayerInfo() { //////////// Tradução da condição respiratória para português //////////////// var obstructiveTranslation = "Obstrutivo"; var restrictiveTranslation = "Restritivo"; var healthyTranslation = "Saudável"; var disfunction = Pacient.Loaded.Condition == ConditionType.Healthy ? healthyTranslation : (Pacient.Loaded.Condition == ConditionType.Obstructive ? obstructiveTranslation : restrictiveTranslation); ////////////////////////////////////////////////////////////////////////////// SysMessage.Info($"Jogador: {Pacient.Loaded.Name}\n" + $"Condição: {disfunction}\n" + $"Partidas Jogadas: {Pacient.Loaded.PlaySessionsDone}\n" + $"\n-------------- Pitaco --------------\n" + $"Pico Exp.: {PitacoFlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesPitaco.RawExpPeakFlow)} L/min ({Pacient.Loaded.CapacitiesPitaco.RawExpPeakFlow} Pa)\n" + $"Pico Ins.: {PitacoFlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesPitaco.RawInsPeakFlow)} L/min ({Pacient.Loaded.CapacitiesPitaco.RawInsPeakFlow} Pa)\n" + $"Tempo Ins.: {Pacient.Loaded.CapacitiesPitaco.RawInsFlowDuration / 1000f:F1} s\n" + $"Tempo Exp.: {Pacient.Loaded.CapacitiesPitaco.RawExpFlowDuration / 1000f:F1} s\n" + $"Tins/Texp: {((Pacient.Loaded.CapacitiesPitaco.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesPitaco.RawExpFlowDuration / 1000f)):F1}\n" + $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesPitaco.RawRespRate * 60f:F1} rpm\n" + $"\n-------------- Mano --------------\n" + $"Pico Exp.: {ManoFlowMath.ToCentimetersofWater(Pacient.Loaded.CapacitiesMano.RawExpPeakFlow)} cmH2O ({Pacient.Loaded.CapacitiesMano.RawExpPeakFlow} Pa)\n" + $"Pico Ins.: {ManoFlowMath.ToCentimetersofWater(Pacient.Loaded.CapacitiesMano.RawInsPeakFlow)} cmH2O ({Pacient.Loaded.CapacitiesMano.RawInsPeakFlow} Pa)\n" + $"Tempo Ins.: {Pacient.Loaded.CapacitiesMano.RawInsFlowDuration / 1000f:F1} s\n" + $"Tempo Exp.: {Pacient.Loaded.CapacitiesMano.RawExpFlowDuration / 1000f:F1} s\n" + $"Tins/Texp: {((Pacient.Loaded.CapacitiesMano.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesMano.RawExpFlowDuration / 1000f)):F1}\n" + // $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesMano.RawRespRate * 60f:F1} rpm\n" + $"\n-------- Cinta Extensora --------\n" + $"Pico Exp.: {CintaFlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesCinta.RawExpPeakFlow)} L/min ({Pacient.Loaded.CapacitiesCinta.RawExpPeakFlow} Pa)\n" + $"Pico Ins.: {CintaFlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesCinta.RawInsPeakFlow)} L/min ({Pacient.Loaded.CapacitiesCinta.RawInsPeakFlow} Pa)\n" + $"Tempo Ins.: {Pacient.Loaded.CapacitiesCinta.RawInsFlowDuration / 1000f:F1} s\n" + $"Tempo Exp.: {Pacient.Loaded.CapacitiesCinta.RawExpFlowDuration / 1000f:F1} s\n" + $"Tins/Texp: {((Pacient.Loaded.CapacitiesCinta.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesCinta.RawExpFlowDuration / 1000f)):F1}\n" + $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesCinta.RawRespRate * 60f:F1} rpm"); // SysMessage.Info ($"Jogador: {Pacient.Loaded.Name}\n" + // $"Condição: {Pacient.Loaded.Condition}\n" + // $"Partidas Jogadas: {Pacient.Loaded.PlaySessionsDone}\n" + // $"\nPitaco\n" + // $"-----------------------------\n" + // $"Pico Exp.: {FlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesPitaco.RawExpPeakFlow)} L/min ({Pacient.Loaded.CapacitiesPitaco.RawExpPeakFlow} Pa)\n" + // $"Pico Ins.: {FlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesPitaco.RawInsPeakFlow)} L/min ({Pacient.Loaded.CapacitiesPitaco.RawInsPeakFlow} Pa)\n" + // $"Tempo Ins.: {Pacient.Loaded.CapacitiesPitaco.RawInsFlowDuration / 1000f:F1} s\n" + // $"Tempo Exp.: {Pacient.Loaded.CapacitiesPitaco.RawExpFlowDuration / 1000f:F1} s\n" + // $"Tins/Texp: {((Pacient.Loaded.CapacitiesPitaco.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesPitaco.RawExpFlowDuration / 1000f)):F1}\n" + // $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesPitaco.RawRespRate * 60f:F1} rpm\n" + // $"\nManovacuômetro\n" + // $"-----------------------------\n" + // $"Pico Exp.: {FlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesMano.RawExpPeakFlow)} L/min ({Pacient.Loaded.CapacitiesMano.RawExpPeakFlow} Pa)\n" + // $"Pico Ins.: {FlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesMano.RawInsPeakFlow)} L/min ({Pacient.Loaded.CapacitiesMano.RawInsPeakFlow} Pa)\n" + // $"Tempo Ins.: {Pacient.Loaded.CapacitiesMano.RawInsFlowDuration / 1000f:F1} s\n" + // $"Tempo Exp.: {Pacient.Loaded.CapacitiesMano.RawExpFlowDuration / 1000f:F1} s\n" + // $"Tins/Texp: {((Pacient.Loaded.CapacitiesMano.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesMano.RawExpFlowDuration / 1000f)):F1}\n" + // // $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesMano.RawRespRate * 60f:F1} rpm\n" + // $"\nCinta Extensora\n" + // $"-----------------------------\n" + // $"Pico Exp.: {FlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesCinta.RawExpPeakFlow)} L/min ({Pacient.Loaded.CapacitiesCinta.RawExpPeakFlow} Pa)\n" + // $"Pico Ins.: {FlowMath.ToLitresPerMinute(Pacient.Loaded.CapacitiesCinta.RawInsPeakFlow)} L/min ({Pacient.Loaded.CapacitiesCinta.RawInsPeakFlow} Pa)\n" + // $"Tempo Ins.: {Pacient.Loaded.CapacitiesCinta.RawInsFlowDuration / 1000f:F1} s\n" + // $"Tempo Exp.: {Pacient.Loaded.CapacitiesCinta.RawExpFlowDuration / 1000f:F1} s\n" + // $"Tins/Texp: {((Pacient.Loaded.CapacitiesCinta.RawInsFlowDuration / 1000f) / (Pacient.Loaded.CapacitiesCinta.RawExpFlowDuration / 1000f)):F1}\n" + // $"Freq. Resp. Média: {Pacient.Loaded.CapacitiesCinta.RawRespRate * 60f:F1} rpm"); }
private IEnumerator Start() { _runStep = true; while (!_calibrationDone) { if (_runStep) { // Clear screen _enterButton.SetActive(false); DudeClearMessage(); // Wait to show next step yield return(new WaitForSeconds(0.7f)); switch (_currentExercise) { case CalibrationExercisePitaco.RespiratoryFrequency: switch (_currentStep) { case 1: DudeTalk("Você deve respirar somente pela boca. Não precisa morder o PITACO. Mantenha o PITACO sempre para baixo. Pressione (Enter) para continuar."); SetupNextStep(); break; case 2: DudeTalk($"Neste exercício, você deve RESPIRAR NORMALMENTE por {TimerRespFreq} segundos. Ao apertar (Enter), o relógio ficará verde para você começar o exercício."); SetupNextStep(); break; case 3: if (!_serialController.IsConnected) { SerialDisconnectedWarning(); continue; } _capturedSamples.Clear(); _serialController.StartSampling(); yield return(new WaitForSeconds(1f)); _dialogText.text = "(relaxe e RESPIRE NORMALMENTE)"; AirFlowEnable(); StartCoroutine(DisplayCountdown(TimerRespFreq)); while (_flowWatch.ElapsedMilliseconds < TimerRespFreq * 1000) { yield return(null); } AirFlowDisable(); _flowMeter = PitacoFlowMath.RespiratoryRate(_capturedSamples, TimerRespFreq); if (_flowMeter > RespiratoryFrequencyThreshold) { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Success, _currentExercise, _flowMeter); _tmpCapacities.RespiratoryRate = _flowMeter; SetupNextStep(true); continue; } else { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Failure, _currentExercise, _flowMeter); DudeWarnUnknownFlow(); SetupStep(_currentStep); break; } case 4: SoundManager.Instance.PlaySound("Success"); DudeTalk($"Sua média de frequência respiratória é de {(_tmpCapacities.RawRespRate * 60f):F} resp/min." + " Pressione (Enter) para continuar com os outros exercícios."); SetupNextStep(); break; case 5: _calibrationOverviewSendDto.CalibrationValue = _tmpCapacities.RawRespRate; _calibrationOverviewSendDto.Exercise = RespiratoryExercise.RespiratoryFrequency.GetDescription(); Pacient.Loaded.CapacitiesPitaco.RespiratoryRate = _tmpCapacities.RawRespRate; SaveAndQuit(); break; default: FindObjectOfType <SceneLoader>().LoadScene(0); break; } break; case CalibrationExercisePitaco.InspiratoryPeak: switch (_currentStep) { case 1: DudeTalk("Neste exercício, você deve PUXAR O AR COM FORÇA. Serão 3 tentativas. Ao apertar (Enter), o relógio ficará verde para você começar o exercício."); SetupNextStep(); break; case 2: if (!_serialController.IsConnected) { SerialDisconnectedWarning(); continue; } _serialController.StartSampling(); _exerciseCountText.text = $"Exercício: {_currentExerciseCount + 1}/3"; yield return(new WaitForSeconds(1f)); AirFlowEnable(); StartCoroutine(DisplayCountdown(TimerPeakExercise)); _dialogText.text = "(PUXE O AR COM FORÇA 1 vez! E aguarde o próximo passo...)"; yield return(new WaitForSeconds(TimerPeakExercise)); AirFlowDisable(); var insCheck = _flowMeter; ResetFlowMeter(); if (insCheck < -Pacient.Loaded.PitacoThreshold) { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Success, _currentExercise, insCheck); _currentExerciseCount++; SetupNextStep(true); continue; } else { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Failure, _currentExercise, insCheck); DudeWarnUnknownFlow(); SetupStep(_currentStep); break; } case 3: DudeCongratulate(); SetupStep(_currentExerciseCount == 3 ? _currentStep + 1 : _currentStep - 1); break; case 4: SoundManager.Instance.PlaySound("Success"); DudeTalk($"Seu pico inspiratório é de {PitacoFlowMath.ToLitresPerMinute(_tmpCapacities.RawInsPeakFlow):F} L/min." + " Pressione (Enter) para continuar com os outros exercícios."); SetupNextStep(); break; case 5: _calibrationOverviewSendDto.CalibrationValue = _tmpCapacities.RawInsPeakFlow; _calibrationOverviewSendDto.Exercise = RespiratoryExercise.InspiratoryPeak.GetDescription(); Pacient.Loaded.CapacitiesPitaco.InsPeakFlow = _tmpCapacities.RawInsPeakFlow; SaveAndQuit(); break; default: FindObjectOfType <SceneLoader>().LoadScene(0); break; } break; case CalibrationExercisePitaco.InspiratoryDuration: switch (_currentStep) { case 1: DudeTalk("Neste exercício, MANTENHA o ponteiro GIRANDO, PUXANDO O AR! Serão 3 tentativas. Ao apertar (Enter), o relógio ficará verde para você começar o exercício."); SetupNextStep(); break; case 2: if (!_serialController.IsConnected) { SerialDisconnectedWarning(); continue; } _serialController.StartSampling(); _exerciseCountText.text = $"Exercício: {_currentExerciseCount + 1}/3"; yield return(new WaitForSeconds(1)); AirFlowEnable(false); _dialogText.text = "(MANTENHA o ponteiro GIRANDO, PUXANDO O AR!)"; var tmpThreshold = Pacient.Loaded.PitacoThreshold; Pacient.Loaded.PitacoThreshold = tmpThreshold * 0.25f; while (_flowMeter >= -Pacient.Loaded.PitacoThreshold) { yield return(null); } _flowWatch.Restart(); while (_flowMeter < -Pacient.Loaded.PitacoThreshold) { yield return(null); } AirFlowDisable(); ResetFlowMeter(); Pacient.Loaded.PitacoThreshold = tmpThreshold; // Validate for player input if (_flowWatch.ElapsedMilliseconds > FlowTimeThreshold) { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Success, _currentExercise, _flowWatch.ElapsedMilliseconds); if (_flowWatch.ElapsedMilliseconds > _tmpCapacities.InsFlowDuration) { _tmpCapacities.InsFlowDuration = _flowWatch.ElapsedMilliseconds; } _currentExerciseCount++; SetupNextStep(true); continue; } else { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Failure, _currentExercise, _flowWatch.ElapsedMilliseconds); DudeWarnUnknownFlow(); SetupStep(_currentStep); break; } case 3: DudeCongratulate(); SetupStep(_currentExerciseCount == 3 ? _currentStep + 1 : _currentStep - 1); break; case 4: SoundManager.Instance.PlaySound("Success"); DudeTalk($"Seu tempo de inspiração máximo é de {(_tmpCapacities.RawInsFlowDuration / 1000f):F} segundos." + " Pressione (Enter) para continuar com os outros exercícios."); SetupNextStep(); break; case 5: _calibrationOverviewSendDto.CalibrationValue = _tmpCapacities.RawInsFlowDuration; _calibrationOverviewSendDto.Exercise = RespiratoryExercise.InspiratoryDuration.GetDescription(); Pacient.Loaded.CapacitiesPitaco.InsFlowDuration = _tmpCapacities.RawInsFlowDuration; SaveAndQuit(); break; default: FindObjectOfType <SceneLoader>().LoadScene(0); break; } break; case CalibrationExercisePitaco.ExpiratoryPeak: switch (_currentStep) { case 1: DudeTalk("Neste exercício, você deve ASSOPRAR FORTE. Serão 3 tentativas. Ao apertar (Enter), o relógio ficará verde para você começar o exercício."); SetupNextStep(); break; case 2: if (!_serialController.IsConnected) { SerialDisconnectedWarning(); continue; } _serialController.StartSampling(); _exerciseCountText.text = $"Exercício: {_currentExerciseCount + 1}/3"; yield return(new WaitForSeconds(1)); AirFlowEnable(); StartCoroutine(DisplayCountdown(TimerPeakExercise)); _dialogText.text = "(ASSOPRE FORTE 1 vez! E aguarde o próximo passo...)"; // Wait for player input yield return(new WaitForSeconds(TimerPeakExercise)); AirFlowDisable(); var expCheck = _flowMeter; ResetFlowMeter(); if (expCheck > Pacient.Loaded.PitacoThreshold) { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Success, _currentExercise, expCheck); _currentExerciseCount++; SetupNextStep(true); continue; } else { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Failure, _currentExercise, expCheck); DudeWarnUnknownFlow(); SetupStep(_currentStep); break; } case 3: DudeCongratulate(); SetupStep(_currentExerciseCount == 3 ? _currentStep + 1 : _currentStep - 1); break; case 4: SoundManager.Instance.PlaySound("Success"); DudeTalk($"Seu pico expiratório é de {PitacoFlowMath.ToLitresPerMinute(_tmpCapacities.RawExpPeakFlow):F} L/min." + " Pressione (Enter) para continuar com os outros exercícios."); SetupNextStep(); break; case 5: _calibrationOverviewSendDto.CalibrationValue = _tmpCapacities.RawExpPeakFlow; _calibrationOverviewSendDto.Exercise = RespiratoryExercise.ExpiratoryPeak.GetDescription(); Pacient.Loaded.CapacitiesPitaco.ExpPeakFlow = _tmpCapacities.RawExpPeakFlow; SaveAndQuit(); break; default: FindObjectOfType <SceneLoader>().LoadScene(0); break; } break; case CalibrationExercisePitaco.ExpiratoryDuration: switch (_currentStep) { case 1: DudeTalk("Neste exercício, MANTENHA o ponteiro GIRANDO, ASSOPRANDO! Serão 3 tentativas. Ao apertar (Enter), o relógio ficará verde para você começar o exercício."); SetupNextStep(); break; case 2: if (!_serialController.IsConnected) { SerialDisconnectedWarning(); continue; } _serialController.StartSampling(); _exerciseCountText.text = $"Exercício: {_currentExerciseCount + 1}/3"; yield return(new WaitForSeconds(1)); AirFlowEnable(false); _dialogText.text = "(MANTENHA o ponteiro GIRANDO, ASSOPRANDO!)"; var tmpThreshold = Pacient.Loaded.PitacoThreshold; Pacient.Loaded.PitacoThreshold = tmpThreshold * 0.25f; //this helps the player expel all his air // Wait for player input to be greather than threshold while (_flowMeter <= Pacient.Loaded.PitacoThreshold) { yield return(null); } _flowWatch.Restart(); while (_flowMeter > Pacient.Loaded.PitacoThreshold) { yield return(null); } AirFlowDisable(); ResetFlowMeter(); Pacient.Loaded.PitacoThreshold = tmpThreshold; // Validate for player input if (_flowWatch.ElapsedMilliseconds > FlowTimeThreshold) { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Success, _currentExercise, _flowWatch.ElapsedMilliseconds); if (_flowWatch.ElapsedMilliseconds > _tmpCapacities.ExpFlowDuration) { _tmpCapacities.ExpFlowDuration = _flowWatch.ElapsedMilliseconds; } _currentExerciseCount++; SetupNextStep(true); continue; } else { _calibrationLogger.Write(CalibrationExerciseResultPitaco.Failure, _currentExercise, _flowWatch.ElapsedMilliseconds); DudeWarnUnknownFlow(); SetupStep(_currentStep); break; } case 3: DudeCongratulate(); SetupStep(_currentExerciseCount == 3 ? _currentStep + 1 : _currentStep - 1); break; case 4: SoundManager.Instance.PlaySound("Success"); DudeTalk($"Seu tempo de fluxo expiratório máximo é de {(_tmpCapacities.RawExpFlowDuration / 1000f):F} segundos." + " Pressione (Enter) para continuar com os outros exercícios."); SetupNextStep(); break; case 5: _calibrationOverviewSendDto.CalibrationValue = _tmpCapacities.RawExpFlowDuration; _calibrationOverviewSendDto.Exercise = RespiratoryExercise.ExpiratoryDuration.GetDescription(); Pacient.Loaded.CapacitiesPitaco.ExpFlowDuration = _tmpCapacities.RawExpFlowDuration; SaveAndQuit(); break; default: ReturnToMainMenu(); break; } break; } _enterButton.SetActive(true); _runStep = false; } yield return(null); } }
public void TestEquationsPitaco() { var diffpress = 1100f; Debug.Log("Volumetric Flow Rate: " + PitacoFlowMath.ToLitresPerMinute(diffpress) + " L/min"); }