|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using FryPot_DosingSystem.Attributes;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- 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:ObservableObject
- {
- 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++;
- }
- }
- }
- }
- }
|