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
using HMI.Core.Setting;
using PLCHelper;
using Plugin.CurrentSensorControl.Entity;
using System.Windows.Controls;
 
namespace Plugin.CurrentSensorControl
{
    /// <summary>
    /// BurnInOvenCollection.xaml 的交互逻辑
    /// </summary>
    public partial class BurnInOvenCollection : UserControl
    {
        private int rowCount;
        private int colCount;
        private int cellCount;
        private BurnInOven[] ovens;
        private BaseConfig config;
 
        public BurnInOvenCollection()
        {
            config = BaseConfig.Instance;
            InitializeComponent();
            InitMainGrid();
        }
 
        public void InitMainGrid()
        {
            S7Context.Init(SystemSetting.Instance.PlcIp, SystemSetting.Instance.PlcPort);
            this.rowCount = config.Row;
            this.colCount = config.Column;
            ovens = new BurnInOven[this.rowCount * this.colCount];
            if (config.CellCount < 0)
            {
                this.cellCount = rowCount * colCount;
            }
            else
            {
                this.cellCount = config.CellCount;
            }
            for (int r = 0; r < rowCount; r++)
            {
                RowDefinition row = new RowDefinition();
                mainGrid.RowDefinitions.Add(row);
            }
 
            for (int c = 0; c < colCount; c++)
            {
                ColumnDefinition col = new ColumnDefinition();
                mainGrid.ColumnDefinitions.Add(col);
            }
            string[] names = config.NameStr.Split(',');
            for (int n = 0; n < cellCount; n++)
            {
                string name = n < names.Length ? names[n] : "";
                BurnInOven child = new BurnInOven(n);
                child.Header = name;
                mainGrid.Children.Add(child);
                ovens[n] = child;
                int row = n / colCount;
                int col = n % colCount;
                Grid.SetRow(child, row);
                Grid.SetColumn(child, col);
            }
        }
 
        public void Refresh()
        {
            try
            {
                for (int i = 0; i < ovens.Length; i++)
                {
                    var oven = ovens[i];
                    oven.Refresh();
                }
                //Task[] allTask = new Task[ovens.Length];
                //for (int i = 0; i < ovens.Length; i++)
                //{
                //    var oven = ovens[i];
                //    var task = Task.Factory.StartNew(() =>
                //    {
                //        oven.Refresh();
                //    });
                //    allTask[i] = task;
                //}
                //Task.WaitAll(allTask);
            }
            catch (Exception ex)
            {
 
            }
        }
    }
}