tx
8 天以前 e0b138b3e057de6f57021e6c8963868f5c5acc5a
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
206
207
208
209
using System.Collections.Generic;
using System.Linq;
 
namespace TProduct.Link.Kedi
{
    public partial class LinkHelper
    {
        /// <summary>
        /// 构建设备
        /// </summary>
        /// <param name="workBench"></param>
        /// <param name="instrumentParas"></param>
        /// <param name="allMonitors"></param>
        /// <param name="error_info"></param>
        /// <returns></returns>
        public bool InitialData武汉701(
            TProduct.Model.ProductMainExPump pump,
            TProduct.Model.ProductMainExMotor motor,
            TProduct.Model.WorkBenchBase workBench,
            TProduct.Model.TestProjectItemView tesItem,
            List<Model.WorkBenchInstrumentKedi> instrumentParas,
            List<TProduct.Model.WorkBenchMonitorPoint> allMonitors,
            out string error_info)
        {
 
            _singleCommList = new List<SingleComBaseHelper>();
           
            var com_names = (from x in instrumentParas select x.ComPortName).Distinct();
            foreach (var com_name in com_names)
            {
                if (string.IsNullOrEmpty(com_name))
                    continue;
                bool isPlc = false;//PLC com口有点不一样
 
                var single_com_helper = new SingleComBaseHelper();
 
                _iSc = 180;
 
                var f_instrumentParas = from x in instrumentParas where x.ComPortName == com_name select x;
 
                foreach (var instrument in f_instrumentParas)
                {
                    if (instrument.UseStatus != Model.eUseStatus.Enable)
                        continue;
 
                    if (instrument.InstrumentType ==
                        (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.PLC)
                    {
                        var msg_item = new MsgItem_武汉701_PLC_泵();
                        msg_item.InitialData(
                            workBench,
                            tesItem.ElectricInfo,
                            instrument,
                            allMonitors, out error_info);
                        msg_item.Name = "PLC";
                        isPlc = true;
                        single_com_helper.AddMsgItem(msg_item);
                    }
 
                    if (instrument.InstrumentType ==
                         (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.电参数仪)
                    {
                        var setting = new Model.WorkBenchSetting4Pump(workBench.TestSetting);
                        if(setting.SupplyCurrentType == Model.eSupplyCurrentType.直流)
                        {
 
                        }
                        else
                        {
                            var msg_item = new TProduct.Link.Kedi.MsgItem_QZ_8930_三相();
                            msg_item.InitialData(
                                workBench,
                                tesItem.ElectricInfo,
                                instrument,
                                allMonitors, out error_info);
                            msg_item.Name = "电参数仪";
                            single_com_helper.AddMsgItem(msg_item);
                        } 
                    }
 
                    if (instrument.InstrumentType ==
                         (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.转速二次仪表)
                    {
                        var msg_item = new TProduct.Link.Kedi.MsgItem_武汉701_转速();
                        msg_item.InitialData(
                            workBench, 
                            instrument,
                            allMonitors, out error_info);
                        msg_item.Name = "转速仪";
                        single_com_helper.AddMsgItem(msg_item);
                    }
                }
 
 
 
 
 
                if (single_com_helper.TotalMsgItemCount > 0)
                {
                    if (isPlc)
                    {//PLC不一样, 定死的
                        single_com_helper.InitialComPort(workBench, com_name,9600, 7, System.IO.Ports.Parity.Even);
                    }
                    else
                    {
                        single_com_helper.InitialComPort(workBench, com_name);
                    } 
 
                    single_com_helper.OnReceivePollValue += (values, additionInfo, info, bytes) =>
                    {
                        this.InvokeReceiveMonitorValue(values, additionInfo, info, bytes);
                    };
                    single_com_helper.OnShowMsg += (content) =>
                    {
                        if (OnShowMsg != null)
                        {
                            OnShowMsg(content);
                        }
                    };
 
                    _singleCommList.Add(single_com_helper);
                }
                  
            }
 
 
            error_info = null;
 
            return true;
        }
 
        /// <summary>
        /// 构建设备
        /// </summary>
        /// <param name="workBench"></param>
        /// <param name="instrumentParas"></param>
        /// <param name="allMonitors"></param>
        /// <param name="error_info"></param>
        /// <returns></returns>
        public bool InitialData武汉701(
            TProduct.Model.ProductMainExValve valve,
            TProduct.Model.WorkBenchBase workBench,
            TProduct.Model.TestProjectItemView tesItem,
            List<Model.WorkBenchInstrumentKedi> instrumentParas,
            List<TProduct.Model.WorkBenchMonitorPoint> allMonitors,
            out string error_info)
        {
            _singleCommList = new List<SingleComBaseHelper>();
 
            var com_names = (from x in instrumentParas select x.ComPortName).Distinct();
            foreach (var com_name in com_names)
            {
                if (string.IsNullOrEmpty(com_name))
                    continue;
 
                var single_com_helper = new SingleComBaseHelper();
 
                var f_instrumentParas = from x in instrumentParas where x.ComPortName == com_name select x;
 
                foreach (var instrument in f_instrumentParas)
                {
                    if (instrument.UseStatus != Model.eUseStatus.Enable)
                        continue;
 
                    if (instrument.InstrumentType ==
                        (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.PLC)
                    {
                        var msg_item = new MsgItem_武汉701_PLC_阀();
                        msg_item.InitialData(
                            workBench, 
                            instrument,
                            allMonitors, out error_info);
                        msg_item.Name = "PLC";
                        single_com_helper.AddMsgItem(msg_item);
                    } 
                }
 
                if (single_com_helper.TotalMsgItemCount > 0)
                { 
                    single_com_helper.InitialComPort(workBench, com_name, 9600, 7, System.IO.Ports.Parity.Even);
 
                    single_com_helper.OnReceivePollValue += (values, additionInfo, info, bytes) =>
                    {
                        this.InvokeReceiveMonitorValue(values, additionInfo, info, bytes);
                    };
                    single_com_helper.OnShowMsg += (content) =>
                    {
                        if (OnShowMsg != null)
                        {
                            OnShowMsg(content);
                        }
                    };
 
                    _singleCommList.Add(single_com_helper);
                }
           
 
 
                break;//只有一个PLC
            }
 
 
            error_info = null;
 
            return true;
        }
 
    }
}