|
@@ -138,17 +138,19 @@ namespace MV485.uc
|
|
|
private void InitConfigView()
|
|
|
{
|
|
|
cmbMeterType.SelectedItem = null;
|
|
|
- cmbFlowRate.Text = "";
|
|
|
+ //cmbFlowRate.Text = "";
|
|
|
+ cmbDnValue.SelectedItem = null;
|
|
|
cmbNumCount.Text = "";
|
|
|
cmbIndCount.Text = "";
|
|
|
- cmbBrightVal.Text = "";
|
|
|
+ //cmbBrightVal.Text = "";
|
|
|
cmbLastUnit.SelectedItem = null;
|
|
|
txtLastValue.Text = "";
|
|
|
dtpLastValueTime.Text = "";
|
|
|
txtMeterRegion.Text = "";
|
|
|
txtFeatureRegion.Text = "";
|
|
|
- //txtSampleInterval.Text = "";
|
|
|
- cmbSampleInterval.Text = "";
|
|
|
+
|
|
|
+ //cmbSampleInterval.Text = "";
|
|
|
+ cmbSampleInterval.SelectedItem = null;
|
|
|
//txtFirstHour.Text = "";
|
|
|
cmbFirstHour.SelectedItem = null;
|
|
|
}
|
|
@@ -156,11 +158,13 @@ namespace MV485.uc
|
|
|
private void LoadConfigItems()
|
|
|
{
|
|
|
cmbMeterType.ItemsSource = Tools.MeterTypeList;
|
|
|
- cmbFlowRate.ItemsSource = Tools.FlowRateList;
|
|
|
- cmbLastUnit.ItemsSource = Tools.LastUnitMap; //.UnitList;
|
|
|
+ //cmbFlowRate.ItemsSource = Tools.FlowRateList;
|
|
|
+ cmbDnValue.ItemsSource = Tools.DnValueList;
|
|
|
+
|
|
|
+ cmbLastUnit.ItemsSource = Tools.LastUnitMap; //.UnitList;
|
|
|
cmbNumCount.ItemsSource = Tools.NumList;
|
|
|
cmbIndCount.ItemsSource = Tools.NumList;
|
|
|
- cmbBrightVal.ItemsSource = Tools.BrightList;
|
|
|
+ //cmbBrightVal.ItemsSource = Tools.BrightList;
|
|
|
cmbSampleInterval.ItemsSource = Tools.SampleIntervalList;
|
|
|
cmbFirstHour.ItemsSource = Enumerable.Range(0, 24).ToList();
|
|
|
}
|
|
@@ -181,6 +185,7 @@ namespace MV485.uc
|
|
|
//初始化读数栏视图
|
|
|
InitWMDataView();
|
|
|
InitConfigView();
|
|
|
+ txtDeviceTime.Text = "";
|
|
|
}
|
|
|
|
|
|
|
|
@@ -710,7 +715,8 @@ namespace MV485.uc
|
|
|
}
|
|
|
if (runConfig.DnValueWRFlag)
|
|
|
{
|
|
|
- cmbFlowRate.Text = runConfig.DnValue.ToString();
|
|
|
+ //cmbFlowRate.Text = runConfig.DnValue.ToString();
|
|
|
+ cmbDnValue.SelectedValue = runConfig.DnValue;
|
|
|
}
|
|
|
|
|
|
if (runConfig.DigitCountWRFlag &&
|
|
@@ -727,10 +733,12 @@ namespace MV485.uc
|
|
|
grdIndCount.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
|
|
|
- if (runConfig.BrightValueWRFlag)
|
|
|
+ //此项已经不需要了
|
|
|
+ /*if (runConfig.BrightValueWRFlag)
|
|
|
{
|
|
|
cmbBrightVal.Text = runConfig.BrightValue.ToString();
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
if (runConfig.LastUnitLevelWRFlag)
|
|
|
{
|
|
|
cmbLastUnit.SelectedValue = runConfig.LastUnitLevel;
|
|
@@ -745,8 +753,8 @@ namespace MV485.uc
|
|
|
|
|
|
if (runConfig.SampleIntervalFlag)
|
|
|
{
|
|
|
- //txtSampleInterval.Text = runConfig.SampleInterval.ToString();
|
|
|
- cmbSampleInterval.Text = runConfig.SampleInterval.ToString();
|
|
|
+ //cmbSampleInterval.Text = runConfig.SampleInterval.ToString();
|
|
|
+ cmbSampleInterval.SelectedValue = runConfig.SampleInterval;
|
|
|
}
|
|
|
|
|
|
if (runConfig.FirstHourFlag)
|
|
@@ -825,7 +833,8 @@ namespace MV485.uc
|
|
|
runConfig.MeterTypeWRFlag = true;
|
|
|
runConfig.MeterType = (byte)cmbMeterType.SelectedValue;
|
|
|
|
|
|
- if(cmbFlowRate.SelectedItem != null)
|
|
|
+ //改变形式
|
|
|
+ /*if(cmbFlowRate.SelectedItem != null)
|
|
|
{
|
|
|
runConfig.DnValueWRFlag = true;
|
|
|
runConfig.DnValue = (ushort)cmbFlowRate.SelectedValue;
|
|
@@ -840,7 +849,15 @@ namespace MV485.uc
|
|
|
MessageBox.Show(Application.Current.MainWindow, "请输入水表口径对应的每小时最大水流", "提示",
|
|
|
MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
return;
|
|
|
+ }*/
|
|
|
+ if(cmbDnValue.SelectedItem == null)
|
|
|
+ {
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择水表口径", "提示",
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
+ return;
|
|
|
}
|
|
|
+ runConfig.DnValueWRFlag = true;
|
|
|
+ runConfig.DnValue = (ushort)cmbDnValue.SelectedValue;
|
|
|
|
|
|
if (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_NUM)
|
|
|
{
|
|
@@ -870,7 +887,8 @@ namespace MV485.uc
|
|
|
runConfig.IndCount = indCount;
|
|
|
}
|
|
|
|
|
|
- if (string.IsNullOrEmpty(cmbBrightVal.Text.Trim()) ||
|
|
|
+ //此项已经不需要了
|
|
|
+ /*if (string.IsNullOrEmpty(cmbBrightVal.Text.Trim()) ||
|
|
|
!float.TryParse(cmbBrightVal.Text.Trim(),out float brightValue) ||
|
|
|
!(brightValue >= 0.8 && brightValue <= 2.0))
|
|
|
{
|
|
@@ -879,7 +897,8 @@ namespace MV485.uc
|
|
|
return;
|
|
|
}
|
|
|
runConfig.BrightValueWRFlag = true;
|
|
|
- runConfig.BrightValue = brightValue;
|
|
|
+ runConfig.BrightValue = brightValue;*/
|
|
|
+
|
|
|
|
|
|
if(cmbLastUnit.SelectedItem == null)
|
|
|
{
|
|
@@ -899,16 +918,17 @@ namespace MV485.uc
|
|
|
}
|
|
|
runConfig.LatestValueWRFlag = true;
|
|
|
runConfig.LatestValue = latestValue * Constant.CUBE_VALUE;
|
|
|
-
|
|
|
- if(string.IsNullOrWhiteSpace(dtpLastValueTime.Text) ||
|
|
|
- !DateTime.TryParse(dtpLastValueTime.Text,out DateTime dtLatestTime))
|
|
|
+
|
|
|
+ //if(string.IsNullOrWhiteSpace(dtpLastValueTime.Text) ||
|
|
|
+ // !DateTime.TryParse(dtpLastValueTime.Value,out DateTime dtLatestTime))
|
|
|
+ if (dtpLastValueTime.Value == null)
|
|
|
{
|
|
|
MessageBox.Show(Application.Current.MainWindow, "请输入表底读数对应的时间", "提示",
|
|
|
MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
return;
|
|
|
}
|
|
|
runConfig.LatestTimeWRFlag = true;
|
|
|
- runConfig.LatestTime = dtLatestTime;
|
|
|
+ runConfig.LatestTime = dtpLastValueTime.Value.GetValueOrDefault();
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(txtMeterRegion.Text))
|
|
|
{
|
|
@@ -940,15 +960,21 @@ namespace MV485.uc
|
|
|
|
|
|
if (chkSampleInterval.IsChecked == true)
|
|
|
{
|
|
|
- if(string.IsNullOrWhiteSpace(cmbSampleInterval.Text) ||
|
|
|
- !ushort.TryParse(cmbSampleInterval.Text, out ushort sampleInterval))
|
|
|
+ //if(string.IsNullOrWhiteSpace(cmbSampleInterval.Text) ||
|
|
|
+ //!ushort.TryParse(cmbSampleInterval.Text, out ushort sampleInterval))
|
|
|
+ //{
|
|
|
+ // MessageBox.Show(Application.Current.MainWindow, "请输入正确的采样时间间隔(1~9898)", "提示",
|
|
|
+ // MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
+ // return;
|
|
|
+ //}
|
|
|
+ if(cmbSampleInterval.SelectedItem == null)
|
|
|
{
|
|
|
- MessageBox.Show(Application.Current.MainWindow, "请输入正确的采样时间间隔(1~9898)", "提示",
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择采样间隔", "提示",
|
|
|
MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
return;
|
|
|
}
|
|
|
runConfig.SampleIntervalFlag = true;
|
|
|
- runConfig.SampleInterval = sampleInterval;
|
|
|
+ runConfig.SampleInterval = (ushort)cmbSampleInterval.SelectedValue; //sampleInterval;
|
|
|
}
|
|
|
|
|
|
if (chkFirstHour.IsChecked == true)
|
|
@@ -1152,16 +1178,18 @@ namespace MV485.uc
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //暂时不需要这种形式
|
|
|
|
|
|
- private void CmbSampleInterval_DropDownClosed(object sender, EventArgs e)
|
|
|
+ /* private void CmbSampleInterval_DropDownClosed(object sender, EventArgs e)
|
|
|
{
|
|
|
if (cmbSampleInterval.SelectedItem is KeyValuePair<ushort, string> kv)
|
|
|
{
|
|
|
cmbSampleInterval.Text = kv.Key.ToString();
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- private void CmbFlowRate_DropDownClosed(object sender, EventArgs e)
|
|
|
+ //暂时不需要这种形式
|
|
|
+ /*private void CmbFlowRate_DropDownClosed(object sender, EventArgs e)
|
|
|
{
|
|
|
if (cmbFlowRate.SelectedItem is KeyValuePair<ushort, string> kv)
|
|
|
{
|
|
@@ -1175,15 +1203,16 @@ namespace MV485.uc
|
|
|
{
|
|
|
textBox.MaxLength = 4; // 限制最多输入 4 个字符
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- private void CmbSampleInterval_Loaded(object sender, RoutedEventArgs e)
|
|
|
+ //暂时不需要这种形式
|
|
|
+ /*private void CmbSampleInterval_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (cmbSampleInterval.Template.FindName("PART_EditableTextBox", cmbSampleInterval) is TextBox textBox)
|
|
|
{
|
|
|
textBox.MaxLength = 4; // 限制最多输入 4 个字符
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
private void ImgMeter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
@@ -1198,6 +1227,88 @@ namespace MV485.uc
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private async void BtnReadDeviceTime_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devId, out int baudrate))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ txtDeviceTime.Text = "";
|
|
|
+
|
|
|
+ //开始通过xModem协议读取照片
|
|
|
+ string titleInfo = "正在读取抄表器的当前时钟";
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
+ {
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
+ };
|
|
|
+ waitWindow.Show();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string deviceTime = await Task.Run(() =>
|
|
|
+ {
|
|
|
+ return _rwRunConfig.ReadDeviceTime(portName, baudrate, devId);
|
|
|
+ });
|
|
|
+ AppendLog($"读取抄表器当前时钟成功{(deviceTime != null ? "成功" : "失败")}");
|
|
|
+ if (deviceTime != null)
|
|
|
+ {
|
|
|
+ //LoadWMDataView(data);
|
|
|
+ txtDeviceTime.Text = deviceTime;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, _rwRunConfig.GetLastError(), "错误",
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ waitWindow.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private async void BtnWriteDeviceTime_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devId, out int baudrate))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ txtDeviceTime.Text = "";
|
|
|
+
|
|
|
+ //开始通过xModem协议读取照片
|
|
|
+ string titleInfo = "正在同步抄表器的时钟";
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
+ {
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
+ };
|
|
|
+ waitWindow.Show();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bool blWrite = await Task.Run(() =>
|
|
|
+ {
|
|
|
+ return _rwRunConfig.WriteDeviceTime(portName, baudrate, devId,DateTime.Now);
|
|
|
+ });
|
|
|
+ string msgInfo = $"同步抄表器的时钟{(blWrite ? "成功" : "失败")}";
|
|
|
+ AppendLog(msgInfo);
|
|
|
+ if (blWrite)
|
|
|
+ {
|
|
|
+ msgInfo += "\n抄表器会重启,请等待1-2分钟,再尝试读取参数进行核对。";
|
|
|
+ }
|
|
|
+
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, msgInfo, "提示",
|
|
|
+ MessageBoxButton.OK, blWrite ? MessageBoxImage.Information : MessageBoxImage.Warning);
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ waitWindow.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//------------------------------------------------------------------
|
|
|
}
|
|
|
}
|