|
- using FryPot_DosingSystem.Attributes;
- using BPA.Helper;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace FryPot_DosingSystem.Model
- {
- internal class FryPotInfoManage:NotifyBase
- {
- public static FryPotInfoManage GetInstance => _instance ?? (_instance = new FryPotInfoManage());
- private static FryPotInfoManage _instance;
- public int id { get; set; }
- public ObservableCollection<VariableMonitorModel> variableInfos { get; set; } = new ObservableCollection<VariableMonitorModel>();
- public FryPotInfoManage()
- {
- if (variableInfos.Count > 0)
- {
- variableInfos.Clear();
- }
- PropertyInfo[] pros = FryPotMonitorManage.GetInstance.fryOne.GetType().GetProperties();
- foreach (var item in pros)
- {
- var monitor = item.GetCustomAttribute<VariableAttribute>();
- if (monitor != null)
- {
- variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
- id++;
- }
- }
- PropertyInfo[] pros2 = FryPotMonitorManage.GetInstance.fryTwo.GetType().GetProperties();
- foreach (var item in pros2)
- {
- var monitor = item.GetCustomAttribute<VariableAttribute>();
- if (monitor != null)
- {
- variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
- id++;
- }
- }
- PropertyInfo[] pros3 = FryPotMonitorManage.GetInstance.fryThree.GetType().GetProperties();
- foreach (var item in pros3)
- {
- var monitor = item.GetCustomAttribute<VariableAttribute>();
- if (monitor != null)
- {
- variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
- id++;
- }
- }
- PropertyInfo[] pros4 = FryPotMonitorManage.GetInstance.fryFour.GetType().GetProperties();
- foreach (var item in pros4)
- {
- var monitor = item.GetCustomAttribute<VariableAttribute>();
- if (monitor != null)
- {
- variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
- id++;
- }
- }
- PropertyInfo[] pros5 = FryPotMonitorManage.GetInstance.fryFive.GetType().GetProperties();
- foreach (var item in pros5)
- {
- var monitor = item.GetCustomAttribute<VariableAttribute>();
- if (monitor != null)
- {
- variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
- id++;
- }
- }
- }
- }
- }
|