tx
2025-04-10 2538101febc78f525945da72c7cdcb2589f9e6ea
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
using System.Collections.Generic;
using System.Linq;
using TProduct.Model;
 
namespace TProduct.WinFrmUI.TestBench
{
    public partial class SetWorkBenchInstrument701Ctrl : DevExpress.XtraEditors.XtraUserControl
    {
        public SetWorkBenchInstrument701Ctrl()
        {
            InitializeComponent();
            InitialComPortList();
        }
        private void InitialComPortList()
        {
            var list = System.IO.Ports.SerialPort.GetPortNames();
            if (list != null && list.Count() > 1)
            {
                this.plC701ParasControl1.InitialComPortList(list);
 
            }
            else
            {
                var names = new List<string>();
                for (int i = 1; i <= 12; i++)
                {
                    names.Add(string.Format("COM{0}", i));
                }
                this.plC701ParasControl1.InitialComPortList(names);
 
            }
        }
        private List<Model.WorkBenchInstrumentKedi> _instruments = null;
        private Model.WorkBenchBase _workBench = null;
        public void SetBindingData(Model.WorkBenchBase workBench)
        {
            if (workBench == null)
                return;
            _workBench = workBench;
            _instruments = new List<WorkBenchInstrumentKedi>();
            //torqueParasControl1.SetBindingData(workBench.LinkTag, null);
        }
 
        public void SetBindingData(Model.WorkBenchBase workBench, List<Model.WorkBenchInstrumentKedi> instruments)
        {
            if (workBench == null)
                return;
            _workBench = workBench;
 
            if (instruments != null)
            {
                foreach (var instrument in instruments)
                {
                    if (instrument.InstrumentType ==
                       (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.PLC)
                    {
                        this.plC701ParasControl1.SetBindingData(workBench.LinkTag, instrument);
                    }
 
                }
 
                _instruments = instruments;
            }
            else
            {
                SetBindingData(workBench);
            }
        }
 
        public List<WorkBenchInstrumentKedi> GetData()
        {
            if (_workBench == null)
                return null;
            if (_instruments == null)
                _instruments = new List<WorkBenchInstrumentKedi>();
 
 
 
 
 
 
            var model = _instruments.Find(x => x.InstrumentType ==
                    (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.PLC);
            if (model == null)
            {
                model = new WorkBenchInstrumentKedi();
                model.ID = 0; model.BenchID = this._workBench.ID; 
            }
            model.InstrumentType =
                (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.PLC;
 
            model.Reset4UI(this.plC701ParasControl1.GetData());
 
            if (model.ID == 0)
            {
                model.ID = new BLL.WorkBenchInstrumentKedi().Insert(model);
                _instruments.Add(model);
            }
 
 
 
 
 
            return _instruments;
        }
 
 
 
 
    }
}