private async void ReadMeasuredDatas() { try { ActualMeasuredIndicatorIsVisible = true; if (measuredTimer && !EchoAndTrendIndicatorIsVisible) { var resultHartCmd = await bluetoothConnect.BluetoothProcess.GetHart_HART_CMD_RDDEVVAR_EXTCommandResponse(bluetoothConnect.EmbeddedBluetoothDevices[bluetoothConnect.SelectedDeviceIndex].Device, bluetoothConnect.DeviceDetails.DeviceId, bluetoothConnect.DeviceDetails.DeviceIdInByte); if (resultHartCmd != null && resultHartCmd.Count != 0) { dataCyclingValue++; if (ErrorSignalList.Count != 0) { ErrorSignalList.Clear(); } if (StatusAndErrorSignalState) { var errorBits = DataConverter.HexToBinary(resultHartCmd[0].ErrorBytes); var errorText = DataConverter.LoadErrorText(errorBits); if (errorText.Count != 0) { foreach (var error in errorText) { ErrorSignalList.Add(new ErrorSignal { ErrorSignalText = $"Error [{error.Key}]-{error.Value}" }); } } var statusBits = DataConverter.HexToBinary(resultHartCmd[0].StatusBytes); var statusText = DataConverter.LoadStatusText(statusBits); if (statusText.Count != 0) { foreach (var status in statusText) { ErrorSignalList.Add(new ErrorSignal { ErrorSignalText = $"Status [{status.Key}]-{status.Value}" }); } } var warningBits = DataConverter.HexToBinary(resultHartCmd[0].WarningBytes); var warningText = DataConverter.LoadWarningText(warningBits); if (warningText.Count != 0) { foreach (var warning in warningText) { ErrorSignalList.Add(new ErrorSignal { ErrorSignalText = $"Warning [{warning.Key}]-{warning.Value}" }); } } } PV_Text = DataConverter.Get_PV_SV_TV_QV_ModeText(Convert.ToInt32(resultHartCmd[0].Measure_PV_SV_Mode.ToString().Substring(2, 2)), "(PV)"); pV_DataUnit = CodeTables.BaseCode(resultHartCmd[0].MeasureUnit_PV, resultHartCmd[0].P02_C_Value); PV_DataValue = $"{resultHartCmd[0].MeasureValue_PV.ToString("0.000")} {pV_DataUnit}"; PV_ListAction(resultHartCmd); if (PV_DataSwitchState) { if (PV_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(PV_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(PV_EntryChartList.Min(m => m.Value)) }); } ChartPV_LineColor = Colors.ChartPV_LineColor; PV_Stroke = 2; } else { ChartPV_LineColor = Color.Transparent; PV_Stroke = -1; } SV_Text = DataConverter.Get_PV_SV_TV_QV_ModeText(Convert.ToInt32(resultHartCmd[0].Measure_PV_SV_Mode.ToString().Substring(0, 2)), "(SV)"); sV_DataUnit = CodeTables.BaseCode(resultHartCmd[0].MeasureUnit_SV, resultHartCmd[0].P02_C_Value); SV_DataValue = $"{resultHartCmd[0].MeasureValue_SV.ToString("0.000")} {sV_DataUnit}"; SV_ListAction(resultHartCmd); if (SV_DataSwitchState) { if (SV_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(SV_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(SV_EntryChartList.Min(m => m.Value)) }); } ChartSV_LineColor = Colors.ChartSV_LineColor; } else { ChartSV_LineColor = Color.Transparent; } TV_Text = DataConverter.Get_PV_SV_TV_QV_ModeText(Convert.ToInt32(resultHartCmd[0].Measure_TV_QV_Mode.ToString().Substring(2, 2)), "(TV)"); tV_DataUnit = CodeTables.BaseCode(resultHartCmd[0].MeasureUnit_TV, resultHartCmd[0].P02_C_Value); TV_DataValue = $"{resultHartCmd[0].MeasureValue_TV.ToString("0.00")} {tV_DataUnit}"; TV_ListAction(resultHartCmd); if (TV_DataSwitchState) { if (TV_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(TV_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(TV_EntryChartList.Min(m => m.Value)) }); } ChartTV_LineColor = Colors.ChartTV_LineColor; } else { ChartTV_LineColor = Color.Transparent; } QV_Text = DataConverter.Get_PV_SV_TV_QV_ModeText(Convert.ToInt32(resultHartCmd[0].Measure_TV_QV_Mode.ToString().Substring(0, 2)), "(QV)"); qV_DataUnit = CodeTables.BaseCode(resultHartCmd[0].MeasureUnit_QV, resultHartCmd[0].P02_C_Value); QV_DataValue = $"{resultHartCmd[0].MeasureValue_QV.ToString("0.00")} {qV_DataUnit}"; QV_ListAction(resultHartCmd); if (QV_DataSwitchState) { if (QV_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(QV_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(QV_EntryChartList.Min(m => m.Value)) }); } ChartQV_LineColor = Colors.ChartQV_LineColor; } else { ChartQV_LineColor = Color.Transparent; } OutputCurrentText = App.Translate("CurrentValueText"); outputCurrentDataUnit = "mA"; OutputCurrentDataValue = $"{resultHartCmd[0].OutputCurrentValue.ToString("0.00")} {outputCurrentDataUnit}"; Current_ListAction(resultHartCmd); if (OutputCurrentDataSwitchState) { if (CurrentEntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(CurrentEntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(CurrentEntryChartList.Min(m => m.Value)) }); } ChartCurrent_LineColor = Colors.ChartCurrent_LineColor; } else { ChartCurrent_LineColor = Color.Transparent; } if (IsFlowVisible) { Tot_1_Text = App.Translate("Tot_1_Text"); totDataUnit = CodeTables.BaseCode(resultHartCmd[0].Tot_Unit, resultHartCmd[0].P02_C_Value); Tot_1_DataValue = $"{DataConverter.TotConverterFromUnit(resultHartCmd[0].Tot_1_Value, resultHartCmd[0].Tot_Unit).ToString("0.00")} {totDataUnit}"; Tot_1_ListAction(resultHartCmd); if (Tot_1_DataSwitchState) { if (Tot_1_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(Tot_1_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(Tot_1_EntryChartList.Min(m => m.Value)) }); } ChartTot_1_LineColor = Colors.ChartTot_1_LineColor; } else { ChartTot_1_LineColor = Color.Transparent; } Tot_2_Text = App.Translate("Tot_2_Text"); Tot_2_DataValue = $"{DataConverter.TotConverterFromUnit(resultHartCmd[0].Tot_2_Value, resultHartCmd[0].Tot_Unit).ToString("0.00")} {totDataUnit}"; Tot_2_ListAction(resultHartCmd); if (Tot_2_DataSwitchState) { if (Tot_2_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(Tot_2_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(Tot_2_EntryChartList.Min(m => m.Value)) }); } ChartTot_2_LineColor = Colors.ChartTot_2_LineColor; } else { ChartTot_2_LineColor = Color.Transparent; } H_LevelText = $"h {App.Translate("LevelText")}"; H_LevelDataValue = $"{resultHartCmd[0].H_Value.ToString("0.000")}"; H_ListAction(resultHartCmd); if (H_LevelDataSwitchState) { if (H_EntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(H_EntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(H_EntryChartList.Min(m => m.Value)) }); } Chart_H_LineColor = Colors.Chart_H_LineColor; } else { Chart_H_LineColor = Color.Transparent; } } EchoAmplitudeText = App.Translate("EchoAmplitudeText"); echoAmplitudeDataUnit = "dB"; EchoAmplitudeDataValue = $"{resultHartCmd[0].EchoAmplitude.ToString("0.00")} {echoAmplitudeDataUnit}"; Echo_ListAction(resultHartCmd); if (EchoAmplitudeDataSwitchState) { if (EchoAmplitudeEntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(EchoAmplitudeEntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(EchoAmplitudeEntryChartList.Min(m => m.Value)) }); } ChartEchoAmplitude_LineColor = Colors.ChartEchoAmplitude_LineColor; } else { ChartEchoAmplitude_LineColor = Color.Transparent; } LevelChangeSpeedText = App.Translate("LevelChangeSpeedText"); levelChangeSpeedDataUnit = CodeTables.BaseCode(resultHartCmd[0].LevelChangeSpeedUnit, resultHartCmd[0].P02_C_Value); LevelChangeSpeedDataValue = $"{resultHartCmd[0].LevelChangeSpeedValue.ToString("0.00")} {levelChangeSpeedDataUnit}"; LevelChangeSpeed_ListAction(resultHartCmd); if (LevelChangeSpeedSwitchState) { if (LevelChangeSpeedEntryChartList.Count != 0) { TrendListAll.Add(new TrendListItems { Maximum = (double)Math.Ceiling(LevelChangeSpeedEntryChartList.Max(m => m.Value)), Minimum = (double)Math.Floor(LevelChangeSpeedEntryChartList.Min(m => m.Value)) }); } ChartLevelChange_LineColor = Colors.ChartLevelChange_LineColor; } else { ChartLevelChange_LineColor = Color.Transparent; } //Trend enged lyez se if (TrendsIsVisible) { if (TrendListAll.Count != 0) { if ((double)Math.Ceiling(TrendListAll.Max(m => m.Maximum)) == 0) { YAxisMinimum = -1; YAxisMaximum = 1; } else { if ((double)Math.Ceiling(TrendListAll.Max(m => m.Maximum)) < YAxisMinimum) { YAxisMinimum = (double)Math.Floor(TrendListAll.Min(m => m.Minimum)) - ((double)Math.Abs(Math.Floor(TrendListAll.Min(m => m.Minimum))) / 15); YAxisMaximum = (double)Math.Ceiling(TrendListAll.Max(m => m.Maximum)) + ((double)Math.Ceiling(TrendListAll.Max(m => m.Maximum)) / 15); } else { YAxisMaximum = (double)Math.Ceiling(TrendListAll.Max(m => m.Maximum)) + ((double)Math.Ceiling(TrendListAll.Max(m => m.Maximum)) / 15); YAxisMinimum = (double)Math.Floor(TrendListAll.Min(m => m.Minimum)) - ((double)Math.Abs(Math.Floor(TrendListAll.Min(m => m.Minimum))) / 15); } } TrendListAll.Clear(); } if (dataCyclingValue != 0) { TrendStepingNumber = Calculate.TrendStepingNumberCalculate(dataCyclingValue); } if (PV_DataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == PV_Text).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = PV_Text, LegendColor = Colors.ChartPV_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == PV_Text).FirstOrDefault()); } if (SV_DataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == SV_Text).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = SV_Text, LegendColor = Colors.ChartSV_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == SV_Text).FirstOrDefault()); } if (TV_DataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == TV_Text).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = TV_Text, LegendColor = Colors.ChartTV_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == TV_Text).FirstOrDefault()); } if (QV_DataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == QV_Text).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = QV_Text, LegendColor = Colors.ChartQV_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == QV_Text).FirstOrDefault()); } if (OutputCurrentDataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == OutputCurrentText).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = OutputCurrentText, LegendColor = Colors.ChartCurrent_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == OutputCurrentText).FirstOrDefault()); } if (Tot_1_DataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == Tot_1_Text).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = Tot_1_Text, LegendColor = Colors.ChartTot_1_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == Tot_1_Text).FirstOrDefault()); } if (Tot_2_DataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == Tot_2_Text).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = Tot_2_Text, LegendColor = Colors.ChartTot_2_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == Tot_2_Text).FirstOrDefault()); } if (H_LevelDataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == H_LevelText).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = H_LevelText, LegendColor = Colors.Chart_H_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == H_LevelText).FirstOrDefault()); } if (EchoAmplitudeDataSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == EchoAmplitudeText).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = EchoAmplitudeText, LegendColor = Colors.ChartEchoAmplitude_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == EchoAmplitudeText).FirstOrDefault()); } if (LevelChangeSpeedSwitchState) { selectedTrendToggledIndex += 1; if (!TerendLegendList.Contains(TerendLegendList.Where(w => w.Name == LevelChangeSpeedText).FirstOrDefault())) { TerendLegendList.Add(new TrendLegend { Name = LevelChangeSpeedText, LegendColor = Colors.ChartLevelChange_LineColor }); } } else { TerendLegendList.Remove(TerendLegendList.Where(w => w.Name == LevelChangeSpeedText).FirstOrDefault()); } if (selectedTrendToggledIndex > 3) { myPopup = new MyPopupPage(App.Translate("TrendSelectedErrorText")); await PopupNavigation.Instance.PushAsync(myPopup, false); } } selectedTrendToggledIndex = 0; await Task.Run(() => ReadEchoData()); } ActualMeasuredIndicatorIsVisible = false; } if (EchoAndTrendIndicatorIsVisible) { await Task.Run(() => ReadEchoMapDatas()); } if (currentValueIsEnabled) { await Task.Run(() => SetManualCurrent()); } PageBusy = false; await Task.CompletedTask; } catch (Exception) { ActualMeasuredIndicatorIsVisible = false; PageBusy = false; } }