alielie
2026-04-23 ef52fd6fd07508883dce4eb002acda59f0169e59
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
using HMI.Util;
using Plugin.TestResult_WPF.Constant;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Controls;
 
namespace Plugin.TestResult_WPF
{
    /// <summary>
    /// InfoTable.xaml 的交互逻辑
    /// </summary>
    public partial class InfoTable : UserControl, INotifyPropertyChanged
    {
 
        #region ...
        public event PropertyChangedEventHandler PropertyChanged;
 
        public virtual void RaisePropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
 
        public void RaiseAndSetIfchanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
        {
            old = @new;
            if (propertyName != null) RaisePropertyChanged(propertyName);
        }
        #endregion
 
        private double _temperature;
        public double temperature
        {
            get => _temperature;
            set
            {
                RaiseAndSetIfchanged(ref _temperature, value);
                RaisePropertyChanged("temperatureStr");
            }
        }
 
        public string temperatureStr
        {
            get => $"{_temperature.ToString("f2")}℃";
        }
 
        private string _status;
        public string status
        {
            get => _status;
            set
            {
                RaiseAndSetIfchanged(ref _status, value);
                RaisePropertyChanged("statusStr");
            }
        }
 
        public string statusStr
        {
            get => status != null && CommonStatus.STATUS_MAP.ContainsKey(status) ? CommonStatus.STATUS_MAP[status] : "";
        }
 
        private int _okCount;
        public int okCount
        {
            get => _okCount;
            set
            {
                RaiseAndSetIfchanged(ref _okCount, value);
            }
        }
 
        private int _ngCount;
 
        public int ngCount
        {
            get => _ngCount;
            set
            {
                RaiseAndSetIfchanged(ref _ngCount, value);
            }
        }
 
        private int _allCount;
 
        public int allCount
        {
            get => _allCount;
            set
            {
                RaiseAndSetIfchanged(ref _allCount, value);
            }
        }
 
        public string countStr
        {
            get => $"OK:{okCount},NG:{ngCount},ALL:{allCount}";
        }
 
        private string _startTimeStr;
        public string startTimeStr
        {
            get => _startTimeStr;
            set
            {
                RaiseAndSetIfchanged(ref _startTimeStr, value);
            }
        }
 
        private double _consumeTime;
        public double consumeTime
        {
            get => _consumeTime;
            set
            {
                RaiseAndSetIfchanged(ref _consumeTime, value);
            }
        }
 
        private double? _leftTime;
        public double? leftTime
        {
            get => _leftTime;
            set
            {
                RaiseAndSetIfchanged(ref _leftTime, value);
            }
        }
 
        public string consumeTimeStr
        {
            get
            {
                var str1 = ConvertDurtion(consumeTime);
                if (leftTime != null)
                {
                    str1 += $"/{ConvertDurtion(leftTime.Value)}";
                }
                return str1;
            }
        }
 
        private string ConvertDurtion(double seconds)
        {
            if (seconds <= 0)
            {
                return "0s";
            }
            if (seconds <= 60)
            {
                return $"{seconds.ToString("f2")}s";
            }
            else if (seconds <= 3600)
            {
                var min = Math.Floor(seconds / 60);
                seconds = seconds % 60;
                if (seconds > 0)
                {
                    return $"{min}m{seconds.ToString("f2")}s";
                }
                return $"{min}m";
            }
            else
            {
                var hour = Math.Floor(seconds / 3600);
                var min = Math.Floor((seconds % 3600) / 60);
                seconds = seconds % 60;
                if (seconds > 0)
                {
                    return $"{hour}h{min}m{seconds.ToString("f2")}s";
                }
                return $"{hour}h{min}m";
            }
        }
 
        private string _endTimeStr;
 
        public string endTimeStr
        {
            get => _endTimeStr;
            set => RaiseAndSetIfchanged(ref _endTimeStr, value);
        }
 
        public void UpdateNumber(int ok, int ng)
        {
            this._okCount = ok;
            this._ngCount = ng;
            this._allCount = this._okCount + this._ngCount;
            RaisePropertyChanged("countStr");
        }
 
        public void UpdateConsumeTime(double consumeTime, double? leftTime)
        {
            this.consumeTime = consumeTime;
            this.leftTime = leftTime;
            RaisePropertyChanged("consumeTimeStr");
        }
 
        public InfoTable()
        {
            this.DataContext = this;
            InitializeComponent();
        }
    }
}