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 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; } } public MfcTestData SelectedMfc { get; set; } private List mfcTestList; public List MfcTestList { get { return mfcTestList; } set { value.ForEach(t => { if (SelectedMfc is not null && SelectedMfc.MfcName == t.MfcName) SelectedMfc = t; }); 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) { //整个界面MFC的测试结果 MfcTestList = JsonConvert.DeserializeObject>(value); } _strMfcTestList = value; } } //protected override void OnActivate() //{ // base.OnActivate(); //} //protected override void OnInitialize() //{ // base.OnInitialize(); //} //protected override void InvokeAfterUpdateProperty(Dictionary data) //{ // base.InvokeAfterUpdateProperty(data); //} public void MfcStart() { 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.Red); else return new SolidColorBrush(Colors.Gray); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; } } }