public static TempMaster CreateItem() { TempMaster result = new TempMaster() { CarNo = $"辽A{new Random().Next(10000, 99999)}", UDP = DateTime.Now }; return(result); }
void UpdateRTD(TempMaster item) { item.Detect1 = true; var props = typeof(TempMaster).GetProperties(); var detectList = props.Where(x => x.Name.Contains("Detect")).ToList(); foreach (var det in detectList) { var temp = det.GetValue(item); if (temp == null) { det.SetValue(item, true); break; } } }
public MasterControlViewModel() { Data.Add(TempMaster.CreateItem()); Stations.Add(new StationModel() { StationNo = "一工位", DetectName = "尾气检测" }); Stations.Add(new StationModel() { StationNo = "二工位", DetectName = "测重检测" }); Stations.Add(new StationModel() { StationNo = "三工位", DetectName = "外廓检测" }); Stations.Add(new StationModel() { StationNo = "四工位", DetectName = "灯光检测" }); StartUpdate(); }
private void Timer_Tick(object sender, EventArgs e) { Data.BeginUpdate(); foreach (var item in Data) { if (item.Detect6 == null) { UpdateRTD(item); } } if (Data.First().Detect6 != null) { Data.Insert(0, (TempMaster.CreateItem())); } Data.EndUpdate(); Stations.BeginUpdate(); if (CarIndex == 0) { Stations.First().CarNo = Data.First().CarNo; } else if (CarIndex == 4) { Stations[3].CarNo = string.Empty; CarIndex = 0; Stations.First().CarNo = Data.First().CarNo; } if (CarIndex != 0) { Stations[CarIndex].CarNo = Stations[CarIndex - 1].CarNo; Stations[CarIndex - 1].CarNo = string.Empty; } //if (CarIndex == 3) // CarIndex = 0; //else CarIndex++; Stations.EndUpdate(); }