alielie
2026-06-15 f08871fe7d148d667f2f11f80f64de71a0d9504c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
using CommunityToolkit.Mvvm.ComponentModel;
using HslCommunication.Profinet.Siemens;
using PLCHelper;
using Plugin.CurrentSensorControl.Entity;
using System.Windows.Controls;
 
namespace Plugin.CurrentSensorControl
{
    /// <summary>
    /// BurnInOven.xaml 的交互逻辑
    /// </summary>
    [ObservableObject]
    public partial class BurnInCell : UserControl
    {
        private BaseConfig config;
 
        [ObservableProperty]
        private string header;
 
        [ObservableProperty]
        private string req;
 
        [ObservableProperty]
        private bool lightOK;
 
        [ObservableProperty]
        private bool lightNG;
 
        private bool powerStatus;
 
        public bool PowerStatus
        {
            get => powerStatus;
            set
            {
                try
                {
                    string name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Power";
                    if (S7Context.WriteData(api, name, value))
                    {
                        powerStatus = value;
                        OnPropertyChanged(nameof(PowerStatus));
                    }
                }
                catch (Exception ex)
                {
 
                }
            }
        }
 
        private bool activationStatus;
        public bool ActivationStatus
        {
            get => activationStatus;
            set
            {
 
                try
                {
                    string name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Activation";
                    if (S7Context.WriteData(api, name, value))
                    {
                        activationStatus = value;
                        OnPropertyChanged(nameof(ActivationStatus));
                    }
                }
                catch (Exception ex)
                {
 
                }
            }
        }
 
        private bool okLightOn;
        public bool OkLightOn
        {
            get => okLightOn;
            set
            {
 
                try
                {
                    string name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Light_OK";
                    if (S7Context.WriteData(api, name, value))
                    {
                        okLightOn = value;
                        OnPropertyChanged(nameof(OkLightOn));
                    }
                }
                catch (Exception ex)
                {
 
                }
            }
        }
 
        private bool ngLightOn;
        public bool NgLightOn
        {
            get => ngLightOn;
            set
            {
 
                try
                {
                    string name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Light_NG";
                    if (S7Context.WriteData(api, name, value))
                    {
                        ngLightOn = value;
                        OnPropertyChanged(nameof(NgLightOn));
                    }
                }
                catch (Exception ex)
                {
 
                }
            }
        }
 
        [ObservableProperty]
        private string current;
 
 
 
        [ObservableProperty]
        private bool? cellStatus;
 
        private int ovenIndex;
        private int cellIndex;
        private SiemensS7Net api;
 
        public BurnInCell(int ovenIndex, int cellIndex)
        {
            this.ovenIndex = ovenIndex;
            this.cellIndex = cellIndex;
            this.Header = $"Cell {cellIndex + 1}";
            DataContext = this;
            api = S7Context.Get($"1");
            config = BaseConfig.Instance;
            InitializeComponent();
        }
 
        public void Refresh()
        {
            try
            {
                string name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Power";
                object val; string errMsg;
                if (S7Context.GetData(api, name, out val))
                {
                    powerStatus = (bool)val;
                    OnPropertyChanged("PowerStatus");
                }
 
                name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Activation";
                if (S7Context.GetData(api, name, out val))
                {
                    activationStatus = (bool)val;
                    OnPropertyChanged("ActivationStatus");
                }
 
                name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Light_OK";
                if (S7Context.GetData(api, name, out val))
                {
                    okLightOn = (bool)val;
                    OnPropertyChanged("OkLightOn");
                }
 
                name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Light_NG";
                if (S7Context.GetData(api, name, out val))
                {
                    ngLightOn = (bool)val;
                    OnPropertyChanged("NgLightOn");
                }
 
                name = $"Oven{ovenIndex + 1}_Cell{cellIndex + 1}_Current";
                if (S7Context.GetData(api, name, out val))
                {
                    Current = val.ToString();
                }
            }
            catch (Exception ex)
            {
 
            }
        }
    }
}