147 lines
4.5 KiB
C#
147 lines
4.5 KiB
C#
using Aitex.Core.Common.DeviceData;
|
||
using Aitex.Core.Util;
|
||
using MECF.Framework.Common.Aitex.Core.Common.DeviceData.IoDevice;
|
||
using MECF.Framework.Common.DataCenter;
|
||
using MECF.Framework.Common.OperationCenter;
|
||
using MECF.Framework.UI.Client.ClientBase;
|
||
using Newtonsoft.Json;
|
||
using OpenSEMI.ClientBase;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Collections.ObjectModel;
|
||
using System.Globalization;
|
||
using System.IO.Ports;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Data;
|
||
using System.Windows.Media;
|
||
|
||
namespace SicUI.Models.PMs
|
||
{
|
||
public class PMMfcTestViewModel : SicModuleUIViewModelBase, ISupportMultipleSystem
|
||
{
|
||
|
||
public List<ControlNameData> ValueTestList { get; set; }
|
||
|
||
private string _strValueTestList;
|
||
[Subscription("MfcTest.ValueTestList")]
|
||
public string StrValueTestList
|
||
{
|
||
get { return _strValueTestList; }
|
||
set
|
||
{
|
||
if (_strValueTestList != value && value != null)
|
||
ValueTestList = JsonConvert.DeserializeObject<List<ControlNameData>>(value);
|
||
|
||
_strValueTestList = value;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
public List<ControlNameData> PCTestList { get; set; }
|
||
|
||
private string _strPCTestList;
|
||
[Subscription("MfcTest.PCTestList")]
|
||
public string StrPCTestList
|
||
{
|
||
get { return _strPCTestList; }
|
||
set
|
||
{
|
||
if (_strPCTestList != value && value != null)
|
||
PCTestList = JsonConvert.DeserializeObject<List<ControlNameData>>(value);
|
||
|
||
_strPCTestList = value;
|
||
}
|
||
}
|
||
|
||
private string useMfcName;
|
||
|
||
/// <summary>
|
||
/// Combobox下拉框选择项
|
||
/// </summary>
|
||
public MfcTestData SelectedMfc { get; set; }
|
||
|
||
|
||
private List<MfcTestData> mfcTestList;
|
||
public List<MfcTestData> MfcTestList
|
||
{
|
||
get
|
||
{
|
||
if (useMfcName is not null && mfcTestList is not null && SelectedMfc is null)//整个列表刷新后,SelectedMfc会为Null,这里需要重新赋值
|
||
{
|
||
mfcTestList.ForEach(t =>
|
||
{
|
||
if (useMfcName is not null && useMfcName == t.MfcName)
|
||
SelectedMfc = t;
|
||
});
|
||
}
|
||
return mfcTestList;
|
||
|
||
}
|
||
set
|
||
{
|
||
if (value is not null && SelectedMfc is null)//第一次打开时,给选择列表初始值
|
||
SelectedMfc = value[0];
|
||
|
||
mfcTestList = value;
|
||
}
|
||
}
|
||
|
||
|
||
private string _strMfcTestList;
|
||
|
||
[Subscription("MfcTest.MfcTestList")]
|
||
public string StrMfcTestList
|
||
{
|
||
get { return _strMfcTestList; }
|
||
set
|
||
{
|
||
if (_strMfcTestList != value && value != null)
|
||
MfcTestList = JsonConvert.DeserializeObject<List<MfcTestData>>(value);//整个界面MFC的测试结果
|
||
_strMfcTestList = value;
|
||
}
|
||
}
|
||
|
||
public void MfcStart()
|
||
{
|
||
useMfcName = SelectedMfc.MfcName;
|
||
InvokeClient.Instance.Service.DoOperation($"{SystemName}.MfcValueTest", SelectedMfc.MfcName);
|
||
}
|
||
|
||
public void DeleteMfcTest()
|
||
{
|
||
var selection = DialogBox.ShowDialog(DialogButton.Yes | DialogButton.Cancel, DialogType.CONFIRM,
|
||
"Are you sure delect all test data");
|
||
if (selection == DialogButton.Yes)
|
||
InvokeClient.Instance.Service.DoOperation($"{SystemName}.MfcTest.DeleteMfcTest");
|
||
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 输入数值检测
|
||
/// </summary>
|
||
class ColorConverter_IsTestOK : IValueConverter
|
||
{
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||
{
|
||
if (value == null || value.ToString().Length == 0)
|
||
return new SolidColorBrush(Colors.Gray);
|
||
if (value.ToString() == "OK")
|
||
return new SolidColorBrush(Colors.Green);
|
||
else if (value.ToString() == "NG")
|
||
return new SolidColorBrush(Colors.MediumVioletRed);
|
||
else
|
||
return new SolidColorBrush(Colors.Gray);
|
||
}
|
||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
}
|