Beispiel #1
0
        public TestRTDViewModel()
        {
            Data = new ObservableCollectionCore <RTDItem>();
            Data.Add(RTDItem.CreateItem());
            Stations = new ObservableCollectionCore <RTDStation>();
            Stations.Add(new RTDStation()
            {
                StationNo = "一工位", StationName = "尾气检测"
            });
            Stations.Add(new RTDStation()
            {
                StationNo = "二工位", StationName = "测重检测"
            });
            Stations.Add(new RTDStation()
            {
                StationNo = "三工位", StationName = "外廓检测"
            });
            Stations.Add(new RTDStation()
            {
                StationNo = "四工位", StationName = "灯光检测"
            });

            UpdataCP(CP);
            CPS.Add(CP);
            CP2 = new ControlParameter();

            DI.Param1 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DI.Param2 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
            DI.Param3 = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100).ToString();
        }
Beispiel #2
0
        public static RTDItem CreateItem()
        {
            RTDItem result = new RTDItem()
            {
                CarNo = $"辽A{new Random().Next(10000, 99999)}",
                UDP   = DateTime.Now
            };

            return(result);
        }
Beispiel #3
0
        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, (RTDItem.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();
            //DispatcherService.BeginInvoke(() =>
            //{
            //   // UpdataCP(CPS.First());
            //   // UpdataCP(CP);
            //});
            //CP.Param2 = 123m;
            lala = new Random(Guid.NewGuid().GetHashCode()).Next(0, 100);
        }
Beispiel #4
0
        void UpdateRTD(RTDItem item)
        {
            item.Detect1 = true;
            var props      = typeof(RTDItem).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;
                }
            }
        }