using System.Collections.Generic;
using System.Linq;
namespace TProduct.Link.Kedi
{
public partial class LinkHelper
{
///
/// 构建设备
///
///
///
///
///
///
public bool InitialData犇流(
TProduct.Model.ProductMainExPump pump,
TProduct.Model.ProductMainExMotor motor,
TProduct.Model.WorkBenchBase workBench,
TProduct.Model.TestProjectItemView tesItem,
List instrumentParas,
List allMonitors,
out string error_info)
{
_singleCommList = new List();
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;
}
}
}