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
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犇流(
            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;
 
                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.电参数仪)
                    {
                        var msg_item = new TProduct.Link.Kedi.MsgItem_QZ_8902F2();
                        msg_item.InitialData(
                            workBench,
                            tesItem.ElectricInfo,
                            instrument,
                            allMonitors, out error_info);
                        msg_item.Name = "电参数仪";
                        single_com_helper.AddMsgItem(msg_item);
                    }
 
                    else if (instrument.InstrumentType ==
                         (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.无纸数据记录仪)
                    {
                        var msg_item = new MsgItem_犇流_Dr();
                        msg_item.SetMeterInfo(_allPressMeter, _allFlowMeter);
                        msg_item.Name = "无纸数据记录仪";
                        msg_item.InitialData(workBench, instrument, allMonitors);
                        single_com_helper.AddMsgItem(msg_item);
                    }
 
 
                    else if (instrument.InstrumentType ==
                         (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.转速二次仪表)
                    {
                        var msg_item = new TProduct.Link.Kedi.MsgItem_犇流_转速();
                        msg_item.InitialData(
                            workBench,
                            instrument,
                            allMonitors, out error_info);
                        msg_item.Name = "转速仪";
                        single_com_helper.AddMsgItem(msg_item);
                    }
 
                    else if (instrument.InstrumentType ==
                               (int)TProduct.Model.WorkBenchInstrumentKedi.eKediInstrumentType.阀门)
                    {
                        var msg_item = new TProduct.Link.Kedi.MsgItem_犇流_阀门();
                        msg_item.InitialData(workBench, instrument);
                        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);
                    //}
                  
                    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;
        }
 
 
 
    }
}