|
@@ -168,14 +168,59 @@ namespace MV485.uc
|
|
//dtpLastValueTime.v
|
|
//dtpLastValueTime.v
|
|
txtMeterRegion.Text = "";
|
|
txtMeterRegion.Text = "";
|
|
txtFeatureRegion.Text = "";
|
|
txtFeatureRegion.Text = "";
|
|
-
|
|
|
|
-
|
|
|
|
//cmbSampleInterval.Text = "";
|
|
//cmbSampleInterval.Text = "";
|
|
cmbSampleInterval.SelectedItem = null;
|
|
cmbSampleInterval.SelectedItem = null;
|
|
//txtFirstHour.Text = "";
|
|
//txtFirstHour.Text = "";
|
|
cmbFirstHour.SelectedItem = null;
|
|
cmbFirstHour.SelectedItem = null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void InitAIConfigView()
|
|
|
|
+ {
|
|
|
|
+ cmbMeterType.SelectedItem = null;
|
|
|
|
+ //cmbFlowRate.Text = "";
|
|
|
|
+ cmbDnValue.SelectedItem = null;
|
|
|
|
+ //cmbNumCount.Text = "";
|
|
|
|
+ cmbNumCount.SelectedItem = null;
|
|
|
|
+ //cmbIndCount.Text = "";
|
|
|
|
+ cmbIndCount.SelectedItem = null;
|
|
|
|
+ //cmbBrightVal.Text = "";
|
|
|
|
+ cmbLastUnit.SelectedItem = null;
|
|
|
|
+ cmbUploadRedind.SelectedItem = null;
|
|
|
|
+
|
|
|
|
+ txtLastValue.Text = "";
|
|
|
|
+ //dtpLastValueTime.Text = "";
|
|
|
|
+ //dtpLastValueTime.Value = null;
|
|
|
|
+ //dtpLastValueTime.ClearValue(dtpLastValueTime.ValueProperty);
|
|
|
|
+ //dtpLastValueTime.SelectedDate = null;
|
|
|
|
+ //dtpLastValueTime.Value = null; // 第一步:清空 Value 依赖属性
|
|
|
|
+ //dtpLastValueTime.SelectedDate = null; // 清空基础类 DatePicker 的值
|
|
|
|
+
|
|
|
|
+ dtpLastValueTime.Value = null;
|
|
|
|
+
|
|
|
|
+ dtpLastValueTime.ApplyTemplate();
|
|
|
|
+ var tb = dtpLastValueTime.Template.FindName("PART_TextBox_New", dtpLastValueTime) as DatePickerTextBox;
|
|
|
|
+ var cal = dtpLastValueTime.Template.FindName("PART_Calendar", dtpLastValueTime) as Calendar;
|
|
|
|
+ if (tb != null) tb.Text = "";
|
|
|
|
+ if (cal != null) cal.SelectedDate = null;
|
|
|
|
+
|
|
|
|
+ //txtMeterRegion.Text = "";
|
|
|
|
+ //txtFeatureRegion.Text = "";
|
|
|
|
+ //cmbSampleInterval.SelectedItem = null;
|
|
|
|
+ //cmbFirstHour.SelectedItem = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void InitRegionConfigView()
|
|
|
|
+ {
|
|
|
|
+ txtMeterRegion.Text = "";
|
|
|
|
+ txtFeatureRegion.Text = "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void InitSampleConfigView()
|
|
|
|
+ {
|
|
|
|
+ cmbSampleInterval.SelectedItem = null;
|
|
|
|
+ cmbFirstHour.SelectedItem = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void LoadConfigItems()
|
|
private void LoadConfigItems()
|
|
{
|
|
{
|
|
cmbMeterType.ItemsSource = Tools.MeterTypeList;
|
|
cmbMeterType.ItemsSource = Tools.MeterTypeList;
|
|
@@ -614,14 +659,23 @@ namespace MV485.uc
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if(cmbMeterType.SelectedItem == null)
|
|
|
|
|
|
+ RunConfig readRunConfig = btnSetImgConfig.Tag as RunConfig;
|
|
|
|
+ if(readRunConfig == null)
|
|
{
|
|
{
|
|
- MessageBox.Show(Application.Current.MainWindow, "请先指定水表类型", "提示",
|
|
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请先读取AI基本参数", "提示",
|
|
MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- byte meterType = (byte)cmbMeterType.SelectedValue;
|
|
|
|
|
|
+
|
|
|
|
+ //if(cmbMeterType.SelectedItem == null)
|
|
|
|
+ //{
|
|
|
|
+ // MessageBox.Show(Application.Current.MainWindow, "请先指定水表类型", "提示",
|
|
|
|
+ // MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ // return;
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ byte meterType = readRunConfig.MeterType; //(byte)cmbMeterType.SelectedValue;
|
|
DlgMark dlgMark = new DlgMark(meterType, ImageFilePath)
|
|
DlgMark dlgMark = new DlgMark(meterType, ImageFilePath)
|
|
{
|
|
{
|
|
Owner = Application.Current.MainWindow,
|
|
Owner = Application.Current.MainWindow,
|
|
@@ -705,7 +759,7 @@ namespace MV485.uc
|
|
{
|
|
{
|
|
RunConfig runConfig = await Task.Run(() =>
|
|
RunConfig runConfig = await Task.Run(() =>
|
|
{
|
|
{
|
|
- return _rwRunConfig.ReadRunConfig(portName,baudrate,devid);
|
|
|
|
|
|
+ return _rwRunConfig.ReadRunConfig(portName,baudrate,devid,0);
|
|
});
|
|
});
|
|
if(runConfig != null)
|
|
if(runConfig != null)
|
|
{
|
|
{
|
|
@@ -821,7 +875,108 @@ namespace MV485.uc
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //设置配置按钮
|
|
|
|
|
|
+ private void LoadAIConfigView(RunConfig runConfig)
|
|
|
|
+ {
|
|
|
|
+ grdIndCount.Visibility = Visibility.Collapsed;
|
|
|
|
+ grdNumCount.Visibility = Visibility.Collapsed;
|
|
|
|
+
|
|
|
|
+ if (runConfig.MeterTypeWRFlag)
|
|
|
|
+ {
|
|
|
|
+ cmbMeterType.SelectedValue = runConfig.MeterType;
|
|
|
|
+ }
|
|
|
|
+ if (runConfig.DnValueWRFlag)
|
|
|
|
+ {
|
|
|
|
+ //cmbFlowRate.Text = runConfig.DnValue.ToString();
|
|
|
|
+ cmbDnValue.SelectedValue = runConfig.DnValue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.DigitCountWRFlag &&
|
|
|
|
+ (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_NUM))
|
|
|
|
+ {
|
|
|
|
+ //cmbNumCount.Text = runConfig.DigitCount.ToString();
|
|
|
|
+ cmbNumCount.SelectedItem = runConfig.DigitCount;
|
|
|
|
+ grdNumCount.Visibility = Visibility.Visible;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.IndCountWRFlag &&
|
|
|
|
+ (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_IND))
|
|
|
|
+ {
|
|
|
|
+ //cmbIndCount.Text = runConfig.IndCount.ToString();
|
|
|
|
+ cmbIndCount.SelectedItem = runConfig.IndCount;
|
|
|
|
+ grdIndCount.Visibility = Visibility.Visible;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //此项已经不需要了
|
|
|
|
+ /*if (runConfig.BrightValueWRFlag)
|
|
|
|
+ {
|
|
|
|
+ cmbBrightVal.Text = runConfig.BrightValue.ToString();
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ if (runConfig.LastUnitLevelWRFlag)
|
|
|
|
+ {
|
|
|
|
+ cmbLastUnit.SelectedValue = runConfig.LastUnitLevel;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.UploadRedindWRFlag)
|
|
|
|
+ {
|
|
|
|
+ cmbUploadRedind.SelectedValue = runConfig.UploadRedind;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.LatestValueWRFlag && runConfig.LatestTimeWRFlag && runConfig.LatestTime != null)
|
|
|
|
+ {
|
|
|
|
+ txtLastValue.Text = ((int)(runConfig.LatestValue / Constant.CUBE_VALUE)).ToString();
|
|
|
|
+ //dtpLastValueTime.Text = runConfig.LatestTime.ToString("yyyy-MM-dd HH:mm");
|
|
|
|
+ dtpLastValueTime.Value = runConfig.LatestTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.MeterTypeWRFlag &&
|
|
|
|
+ (runConfig.MeterType == Constant.METER_TYPE_NUM_IND ||
|
|
|
|
+ runConfig.MeterType == Constant.METER_TYPE_NUM))
|
|
|
|
+ {
|
|
|
|
+ txtFeatureRegionTitle.Text = "数字区域\n坐标";
|
|
|
|
+ }
|
|
|
|
+ else if (runConfig.MeterTypeWRFlag && (runConfig.MeterType == Constant.METER_TYPE_IND))
|
|
|
|
+ {
|
|
|
|
+ txtFeatureRegionTitle.Text = "首位指针\n同刻度坐标";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void LoadRegionConfigView(RunConfig runConfig)
|
|
|
|
+ {
|
|
|
|
+ if (runConfig.MeterRegion != null)
|
|
|
|
+ {
|
|
|
|
+ txtMeterRegion.Text = runConfig.MeterRegion;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.DigitRegionWRFlag &&
|
|
|
|
+ (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_NUM))
|
|
|
|
+ {
|
|
|
|
+ txtFeatureRegionTitle.Text = "数字区域\n坐标";
|
|
|
|
+ txtFeatureRegion.Text = runConfig.DigitRegion;
|
|
|
|
+ }
|
|
|
|
+ else if (runConfig.FTIndRegionWRFlag && (runConfig.MeterType == Constant.METER_TYPE_IND))
|
|
|
|
+ {
|
|
|
|
+ txtFeatureRegionTitle.Text = "首位指针\n同刻度坐标";
|
|
|
|
+ txtFeatureRegion.Text = runConfig.FTIndRegion;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void LoadSampleConfigView(RunConfig runConfig)
|
|
|
|
+ {
|
|
|
|
+ if (runConfig.SampleIntervalFlag)
|
|
|
|
+ {
|
|
|
|
+ //cmbSampleInterval.Text = runConfig.SampleInterval.ToString();
|
|
|
|
+ cmbSampleInterval.SelectedValue = runConfig.SampleInterval;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.FirstHourFlag)
|
|
|
|
+ {
|
|
|
|
+ //txtFirstHour.Text = runConfig.FirstHour.ToString();
|
|
|
|
+ cmbFirstHour.SelectedItem = (int)runConfig.FirstHour;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //设置配置按钮
|
|
private async void BtnSetConfig_Click(object sender, RoutedEventArgs e)
|
|
private async void BtnSetConfig_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
if (!LicenseMana.mIsLicensed)
|
|
if (!LicenseMana.mIsLicensed)
|
|
@@ -993,7 +1148,7 @@ namespace MV485.uc
|
|
runConfig.LatestTime = dtpLastValueTime.Value.GetValueOrDefault();
|
|
runConfig.LatestTime = dtpLastValueTime.Value.GetValueOrDefault();
|
|
|
|
|
|
|
|
|
|
- if (chkMeterRegion.IsChecked == true)
|
|
|
|
|
|
+ //if (chkMeterRegion.IsChecked == true)
|
|
{
|
|
{
|
|
if (string.IsNullOrWhiteSpace(txtMeterRegion.Text))
|
|
if (string.IsNullOrWhiteSpace(txtMeterRegion.Text))
|
|
{
|
|
{
|
|
@@ -1005,7 +1160,7 @@ namespace MV485.uc
|
|
runConfig.MeterRegion = txtMeterRegion.Text;
|
|
runConfig.MeterRegion = txtMeterRegion.Text;
|
|
}
|
|
}
|
|
|
|
|
|
- if (chkFeatureRegion.IsChecked == true)
|
|
|
|
|
|
+ //if (chkFeatureRegion.IsChecked == true)
|
|
{
|
|
{
|
|
string featureTitle = (runConfig.MeterType == Constant.METER_TYPE_IND) ?
|
|
string featureTitle = (runConfig.MeterType == Constant.METER_TYPE_IND) ?
|
|
"首尾指针同刻度坐标" : "数字区域范围坐标";
|
|
"首尾指针同刻度坐标" : "数字区域范围坐标";
|
|
@@ -1029,7 +1184,7 @@ namespace MV485.uc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (chkSampleInterval.IsChecked == true)
|
|
|
|
|
|
+ //if (chkSampleInterval.IsChecked == true)
|
|
{
|
|
{
|
|
//if(string.IsNullOrWhiteSpace(cmbSampleInterval.Text) ||
|
|
//if(string.IsNullOrWhiteSpace(cmbSampleInterval.Text) ||
|
|
//!ushort.TryParse(cmbSampleInterval.Text, out ushort sampleInterval))
|
|
//!ushort.TryParse(cmbSampleInterval.Text, out ushort sampleInterval))
|
|
@@ -1048,7 +1203,7 @@ namespace MV485.uc
|
|
runConfig.SampleInterval = (ushort)cmbSampleInterval.SelectedValue; //sampleInterval;
|
|
runConfig.SampleInterval = (ushort)cmbSampleInterval.SelectedValue; //sampleInterval;
|
|
}
|
|
}
|
|
|
|
|
|
- if (chkFirstHour.IsChecked == true)
|
|
|
|
|
|
+ //if (chkFirstHour.IsChecked == true)
|
|
{
|
|
{
|
|
if (cmbFirstHour.SelectedItem==null)
|
|
if (cmbFirstHour.SelectedItem==null)
|
|
{
|
|
{
|
|
@@ -1380,6 +1535,431 @@ namespace MV485.uc
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private async void BtnReadBasicConfig_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devid, out int baudrate))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //显示等待串口
|
|
|
|
+ string titleInfo = "正在读取设备的运行参数";
|
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
|
+ {
|
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
|
+ };
|
|
|
|
+ waitWindow.Show();
|
|
|
|
+ //InitConfigView();
|
|
|
|
+ InitAIConfigView();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ RunConfig runConfig = await Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ return _rwRunConfig.ReadRunConfig(portName, baudrate, devid,1);
|
|
|
|
+ });
|
|
|
|
+ if (runConfig != null)
|
|
|
|
+ {
|
|
|
|
+ //加载数据到页面视图
|
|
|
|
+ //LoadRunConfigView(runConfig);
|
|
|
|
+ LoadAIConfigView(runConfig);
|
|
|
|
+ btnSetImgConfig.Tag = runConfig;
|
|
|
|
+ AppendLog("已成功读取设备运行参数");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ AppendLog("读取设备运行参数失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ waitWindow.Close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private async void BtnSetBasicConfig_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (!LicenseMana.mIsLicensed)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "软件未注册,不能使用此功能。", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devid, out int baudrate))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RunConfig runConfig = new RunConfig();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //判断输入项的正确性
|
|
|
|
+ if (cmbMeterType.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择表类型", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.MeterTypeWRFlag = true;
|
|
|
|
+ runConfig.MeterType = (byte)cmbMeterType.SelectedValue;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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)
|
|
|
|
+ {
|
|
|
|
+ if (cmbNumCount.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择数字个数", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ }
|
|
|
|
+ runConfig.DigitCountWRFlag = true;
|
|
|
|
+ runConfig.DigitCount = (byte)cmbNumCount.SelectedItem; //digitCount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (runConfig.MeterType == Constant.METER_TYPE_NUM_IND || runConfig.MeterType == Constant.METER_TYPE_IND)
|
|
|
|
+ {
|
|
|
|
+ if (cmbIndCount.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择指针个数", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ }
|
|
|
|
+ runConfig.IndCountWRFlag = true;
|
|
|
|
+ runConfig.IndCount = (byte)cmbIndCount.SelectedItem; //indCount;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (cmbLastUnit.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择正确的尾数单位", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.LastUnitLevelWRFlag = true;
|
|
|
|
+ runConfig.LastUnitLevel = (byte)cmbLastUnit.SelectedValue;
|
|
|
|
+
|
|
|
|
+ if (cmbUploadRedind.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择是否上传红色指针的读数", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.UploadRedindWRFlag = true;
|
|
|
|
+ runConfig.UploadRedind = (byte)cmbUploadRedind.SelectedValue;
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrWhiteSpace(txtLastValue.Text) ||
|
|
|
|
+ !ulong.TryParse(txtLastValue.Text, out ulong latestValue))
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请输入正确的表底读数", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.LatestValueWRFlag = true;
|
|
|
|
+ runConfig.LatestValue = latestValue * Constant.CUBE_VALUE;
|
|
|
|
+
|
|
|
|
+ //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 = dtpLastValueTime.Value.GetValueOrDefault();
|
|
|
|
+
|
|
|
|
+ //显示等待串口
|
|
|
|
+ string titleInfo = "正在设置AI基本参数";
|
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
|
+ {
|
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
|
+ };
|
|
|
|
+ waitWindow.Show();
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ bool blResult = await Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ return _rwRunConfig.WriteRunConfig(portName, baudrate, devid, runConfig);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ string msgInfo = $"设置AI基本参数{(blResult ? "成功" : "失败")}";
|
|
|
|
+ if (blResult)
|
|
|
|
+ {
|
|
|
|
+ msgInfo += "\n抄表器会重启,请等待1-2分钟,再尝试读取参数进行核对。";
|
|
|
|
+ btnSetImgConfig.Tag = runConfig;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, msgInfo, "提示",
|
|
|
|
+ MessageBoxButton.OK, blResult ? MessageBoxImage.Information : MessageBoxImage.Warning);
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ waitWindow.Close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private async void BtnReadImgConfig_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devid, out int baudrate))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //显示等待串口
|
|
|
|
+ string titleInfo = "正在读取图像区域参数";
|
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
|
+ {
|
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
|
+ };
|
|
|
|
+ waitWindow.Show();
|
|
|
|
+ //InitConfigView();
|
|
|
|
+ InitRegionConfigView();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ RunConfig runConfig = await Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ return _rwRunConfig.ReadRunConfig(portName, baudrate, devid, 2);
|
|
|
|
+ });
|
|
|
|
+ if (runConfig != null)
|
|
|
|
+ {
|
|
|
|
+ //加载数据到页面视图
|
|
|
|
+ //LoadRunConfigView(runConfig);
|
|
|
|
+ //LoadAIConfigView(runConfig);
|
|
|
|
+ LoadRegionConfigView(runConfig);
|
|
|
|
+ AppendLog("已成功读取设备运行参数");
|
|
|
|
+ btnSetImgConfig.Tag = runConfig;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ AppendLog("读取设备运行参数失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ waitWindow.Close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private async void BtnSetImgConfig_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (!LicenseMana.mIsLicensed)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "软件未注册,不能使用此功能。", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devid, out int baudrate))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RunConfig readRunConfig = btnSetImgConfig.Tag as RunConfig;
|
|
|
|
+ if(readRunConfig == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请先读取图像区域参数", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取水表的类型
|
|
|
|
+ RunConfig runConfig = new RunConfig();
|
|
|
|
+ runConfig.MeterType = readRunConfig.MeterType;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrWhiteSpace(txtMeterRegion.Text))
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请输入表盘范围坐标", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.MeterRegionWRFlag = true;
|
|
|
|
+ runConfig.MeterRegion = txtMeterRegion.Text;
|
|
|
|
+
|
|
|
|
+ string featureTitle = (runConfig.MeterType == Constant.METER_TYPE_IND) ?
|
|
|
|
+ "首尾指针同刻度坐标" : "数字区域范围坐标";
|
|
|
|
+ if (string.IsNullOrEmpty(txtFeatureRegion.Text))
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, $"请输入{featureTitle}", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (runConfig.MeterType == Constant.METER_TYPE_IND)
|
|
|
|
+ {
|
|
|
|
+ runConfig.FTIndRegionWRFlag = true;
|
|
|
|
+ runConfig.FTIndRegion = txtFeatureRegion.Text.Trim();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ runConfig.DigitRegionWRFlag = true;
|
|
|
|
+ runConfig.DigitRegion = txtFeatureRegion.Text.Trim();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //显示等待串口
|
|
|
|
+ string titleInfo = "正在设置图像区域参数";
|
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
|
+ {
|
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
|
+ };
|
|
|
|
+ waitWindow.Show();
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ bool blResult = await Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ return _rwRunConfig.WriteRunConfig(portName, baudrate, devid, runConfig);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ string msgInfo = $"设置图像区域参数{(blResult ? "成功" : "失败")}";
|
|
|
|
+ if (blResult)
|
|
|
|
+ {
|
|
|
|
+ msgInfo += "\n抄表器会重启,请等待1-2分钟,再尝试读取参数进行核对。";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, msgInfo, "提示",
|
|
|
|
+ MessageBoxButton.OK, blResult ? MessageBoxImage.Information : MessageBoxImage.Warning);
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ waitWindow.Close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private async void BtnReadSampleConfig_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devid, out int baudrate))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //显示等待串口
|
|
|
|
+ string titleInfo = "正在读取采样间隔参数";
|
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
|
+ {
|
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
|
+ };
|
|
|
|
+ waitWindow.Show();
|
|
|
|
+
|
|
|
|
+ InitSampleConfigView();
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ RunConfig runConfig = await Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ return _rwRunConfig.ReadRunConfig(portName, baudrate, devid, 3);
|
|
|
|
+ });
|
|
|
|
+ if (runConfig != null)
|
|
|
|
+ {
|
|
|
|
+ //加载数据到页面视图
|
|
|
|
+ LoadSampleConfigView(runConfig);
|
|
|
|
+ AppendLog("已成功读取设备运行参数");
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ AppendLog("读取设备运行参数失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ waitWindow.Close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private async void BtnSetSampleConfig_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (!LicenseMana.mIsLicensed)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "软件未注册,不能使用此功能。", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!GetSerialParameter(out string portName, out byte devid, out int baudrate))
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RunConfig runConfig = new RunConfig();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //if (chkSampleInterval.IsChecked == true)
|
|
|
|
+ //{
|
|
|
|
+ if (cmbSampleInterval.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请选择采样间隔", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.SampleIntervalFlag = true;
|
|
|
|
+ runConfig.SampleInterval = (ushort)cmbSampleInterval.SelectedValue; //sampleInterval;
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ //if (chkFirstHour.IsChecked == true)
|
|
|
|
+ //{
|
|
|
|
+ if (cmbFirstHour.SelectedItem == null)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, "请输入正确首次采样整点时(0~23)", "提示",
|
|
|
|
+ MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ runConfig.FirstHourFlag = true;
|
|
|
|
+ runConfig.FirstHour = (byte)(int)cmbFirstHour.SelectedItem;
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //显示等待串口
|
|
|
|
+ string titleInfo = "正在设置采样间隔参数";
|
|
|
|
+ WaitWindow waitWindow = new WaitWindow(titleInfo)
|
|
|
|
+ {
|
|
|
|
+ Owner = Application.Current.MainWindow,
|
|
|
|
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
|
|
+ };
|
|
|
|
+ waitWindow.Show();
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ bool blResult = await Task.Run(() =>
|
|
|
|
+ {
|
|
|
|
+ return _rwRunConfig.WriteRunConfig(portName, baudrate, devid, runConfig);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ string msgInfo = $"设置采样间隔参数{(blResult ? "成功" : "失败")}";
|
|
|
|
+ if (blResult)
|
|
|
|
+ {
|
|
|
|
+ msgInfo += "\n抄表器会重启,请等待1-2分钟,再尝试读取参数进行核对。";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MessageBox.Show(Application.Current.MainWindow, msgInfo, "提示",
|
|
|
|
+ MessageBoxButton.OK, blResult ? MessageBoxImage.Information : MessageBoxImage.Warning);
|
|
|
|
+ }
|
|
|
|
+ catch { }
|
|
|
|
+ finally
|
|
|
|
+ {
|
|
|
|
+ waitWindow.Close();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
//------------------------------------------------------------------
|