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.CenterViews.DataLogs.ProcessHistory; 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 ValueTestList { get; set; } private string _strValueTestList; [Subscription("MfcTest.ValueTestList")] public string StrValueTestList { get { return _strValueTestList; } set { if (_strValueTestList != value && value != null) ValueTestList = JsonConvert.DeserializeObject>(value); _strValueTestList = value; } } public List PCTestList { get; set; } private string _strPCTestList; [Subscription("MfcTest.PCTestList")] public string StrPCTestList { get { return _strPCTestList; } set { if (_strPCTestList != value && value != null) PCTestList = JsonConvert.DeserializeObject>(value); _strPCTestList = value; } } private string useMfcName; /// /// Combobox下拉框选择项 /// public MfcTestData SelectedMfc { get; set; } private List mfcTestList; public List 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>(value);//整个界面MFC的测试结果 _strMfcTestList = value; } } protected override void OnViewLoaded(object _view) { base.OnViewLoaded(_view); } protected override void OnDeactivate(bool close) { ActiveUpdateData = true; base.OnDeactivate(close); } 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"); } } /// /// 输入数值检测 /// 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; } } }