using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Windows.Forms;
|
using TProduct.Model;
|
|
namespace TProduct.WinFrmUI.TPump
|
{
|
/// <summary>
|
/// 性能测试
|
/// </summary>
|
public partial class FeatTestIngMainPage : TestIngBaseMainPage
|
{
|
private TestRecordOperateBaseCtrl _recordOperateCtrl;
|
//初始化实时测点数据表
|
private void InitialMonitorGrid(
|
List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
|
{
|
if (_monitorGridCtrl == null)
|
{
|
_monitorGridCtrl = new GridFeatMonitorRecordCtrl();
|
_monitorGridCtrl.Name = "GridFeatTestCtrl";
|
_monitorGridCtrl.Dock = DockStyle.Fill;
|
_monitorGridCtrl.OnDeleteRecord += (record) =>
|
{
|
if (record != null)
|
DeleteFeatTestRecord(record);
|
};
|
_monitorGridCtrl.OnEditRecord += (record) =>
|
{
|
if (record != null)
|
EditFeatTestRecord(record);
|
};
|
_monitorGridCtrl.OnEmptyAllRecord += () =>
|
{
|
EmptyAllRecord();
|
};
|
|
tabPageGrid.Controls.Add(_monitorGridCtrl);
|
}
|
_monitorGridCtrl.SetBindingData(allMonitorList);
|
_monitorGridCtrl.RefreshData(this._allRecords);
|
if (_correctPtGridCtrl != null)
|
_correctPtGridCtrl.RefreshData(this._allRecords);
|
}
|
|
//初始化自动测试数据表
|
private void InitialAutoTestGrid(
|
List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
|
{
|
if (_testItem.AutoTestInfo == null || !_testItem.AutoTestInfo.IsHave)
|
{
|
tabPageAutoTest.PageVisible = false;
|
return;
|
}
|
|
if (_autoTestInfoCtrl == null)
|
{
|
_autoTestInfoCtrl = new FeatTestAutoParasCtrl();
|
_autoTestInfoCtrl.Name = "FeatTestAutoParasCtrl";
|
_autoTestInfoCtrl.Dock = DockStyle.Fill;
|
tabPageAutoTest.Controls.Add(_autoTestInfoCtrl);
|
|
if (!_autoTestInfoCtrl.IntialTestInfo(this._testItem))
|
{
|
tabControlRight.SelectedTabPageIndex = 1;
|
}
|
}
|
}
|
|
private FeatTestRealTimeChart _realTimeChart;
|
private GridFeatCorrectPtCtrl _correctPtGridCtrl = null;
|
private void InitialCorrentPtGrid()
|
{
|
if (TProduct.UserSetting.Setting.PumpTest.IsDispCorrectPtGrid)
|
{
|
if (_correctPtGridCtrl == null)
|
{
|
_correctPtGridCtrl = new GridFeatCorrectPtCtrl();
|
_correctPtGridCtrl.Name = "GridFeatCorrectPtCtrl";
|
_correctPtGridCtrl.Dock = DockStyle.Fill;
|
tabPageFeatCorrectPt.Controls.Add(_correctPtGridCtrl);
|
}
|
|
_correctPtGridCtrl.RefreshData(this._allRecords);
|
}
|
else
|
{
|
_correctPtGridCtrl = null;
|
tabPageFeatCorrectPt.PageVisible = false;
|
}
|
|
|
if ( _monitorValveIngRecordHelper != null &&
|
TProduct.UserSetting.Setting.PumpTest.IsDispRealTimeChart)
|
{
|
if (TProduct.UserSetting.Setting.PumpTest.RealTimeChartPosi==0)
|
{
|
_realTimeChart = new FeatTestRealTimeChart();
|
_realTimeChart.Dock = DockStyle.Fill;
|
_realTimeChart.Name = "ReatTimeDataCtrl";
|
if(_realTimeChart.SetBindingData(
|
this._allMonitorPointList, _monitorValveIngRecordHelper))
|
{
|
tabPageRealTimeRight.PageVisible = false;
|
tabPageRealTimeLeft.PageVisible = true;
|
tabPageRealTimeLeft.Controls.Add(_realTimeChart);
|
}
|
else
|
{
|
_realTimeChart = null;
|
tabPageRealTimeRight.PageVisible = false;
|
tabPageRealTimeLeft.PageVisible = false;
|
}
|
}
|
else
|
{
|
_realTimeChart = new FeatTestRealTimeChart();
|
_realTimeChart.Dock = DockStyle.Fill;
|
_realTimeChart.Name = "ReatTimeDataCtrl";
|
if (_realTimeChart.SetBindingData(
|
this._allMonitorPointList, _monitorValveIngRecordHelper))
|
{
|
tabPageRealTimeRight.Controls.Add(_realTimeChart);
|
tabPageRealTimeRight.PageVisible = true;
|
tabPageRealTimeLeft.PageVisible = false;
|
}
|
else
|
{
|
_realTimeChart = null;
|
tabPageRealTimeRight.PageVisible = false;
|
tabPageRealTimeLeft.PageVisible = false;
|
}
|
}
|
}
|
else
|
{
|
_realTimeChart = null;
|
tabPageRealTimeRight.PageVisible = false;
|
tabPageRealTimeLeft.PageVisible = false;
|
}
|
}
|
|
|
private bool InitialRecordOperateCtrl()
|
{
|
if (TProduct.CorpConfig.Instance.CorpFlag == eCorpFlag.LIFU)
|
{
|
var autoOperateCtrl = new TestRecordOperate4LifuCtrl();
|
autoOperateCtrl.Name = "OperateValveDegreeCtrl";
|
autoOperateCtrl.Dock = DockStyle.Fill;
|
autoOperateCtrl.SetBindingData(_workBenchInfo, _testItem);
|
autoOperateCtrl.SetLinkHelper(this._linkHelper);
|
panelValve.Controls.Add(autoOperateCtrl);
|
tableLayoutRight.RowStyles[1].Height = 0;
|
this._recordOperateCtrl = autoOperateCtrl;
|
|
autoOperateCtrl.OnChangePanelStatus += (isExpand) =>
|
{
|
if (isExpand)
|
{
|
if (_correctPtGridCtrl == null && _realTimeChart == null && _autoTestInfoCtrl == null)
|
tableLayoutRight.RowStyles[1].Height = tableLayoutRight.Height - 65;
|
else
|
tableLayoutRight.RowStyles[1].Height = 300;
|
}
|
else
|
{
|
tableLayoutRight.RowStyles[1].Height = 0;
|
}
|
};
|
}
|
else
|
{
|
var autoOperateCtrl = new TestRecordOperate4Wh701Ctrl();
|
autoOperateCtrl.Name = "OperateValveDegreeCtrl";
|
autoOperateCtrl.Dock = DockStyle.Fill;
|
autoOperateCtrl.SetBindingData(_workBenchInfo, _testItem);
|
autoOperateCtrl.SetLinkHelper(this._linkHelper);
|
panelValve.Controls.Add(autoOperateCtrl);
|
tableLayoutRight.RowStyles[1].Height = 0;
|
this._recordOperateCtrl = autoOperateCtrl;
|
|
autoOperateCtrl.OnChangePanelStatus += (isExpand) =>
|
{
|
if (isExpand)
|
{
|
if (_correctPtGridCtrl == null && _realTimeChart == null && _autoTestInfoCtrl == null)
|
tableLayoutRight.RowStyles[1].Height = tableLayoutRight.Height - 65;
|
else
|
tableLayoutRight.RowStyles[1].Height = 165;
|
}
|
else
|
{
|
tableLayoutRight.RowStyles[1].Height = 0;
|
}
|
};
|
}
|
//_recordOperateCtrl.OnChangeValveDegree += (prop, degree) =>
|
//{
|
// this.theCalcDataDlg.SetValveDegree(prop, degree);
|
// if (_featTestHelper != null)
|
// {
|
// _featTestHelper.SetValveDegree(prop, degree);
|
// }
|
//};
|
|
_recordOperateCtrl.OnGetRecord += (para, type) =>
|
{//获取数据
|
NewFeatTestRecord(para, type);
|
};
|
_recordOperateCtrl.OnStartAutoTest += () =>
|
{//开始自动测试
|
TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm, "提示", "自动测试已开始...");
|
StartAutoTest();
|
};
|
_recordOperateCtrl.OnStopAutoTest += () =>
|
{//停止自动测试
|
StopAutoTest();
|
};
|
_recordOperateCtrl.OnFinishAutoTest += () =>
|
{//结束自动测试
|
TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm, "提示", "自动测试已结束...");
|
StopAutoTest();
|
JudgeTestResult();//判断一下合格性
|
};
|
_recordOperateCtrl.OnChangePanelSize += (height) =>
|
{
|
tableLayoutRight.RowStyles[1].Height = height;
|
};
|
if (_monitorValveIngRecordHelper != null)
|
{
|
_monitorValveIngRecordHelper.OnInitialValveDegree += (tag, degree) =>
|
{
|
if (tag == TProduct.Model.MonitorTypeProperty.出口)
|
{
|
if(degree > 1)
|
{
|
this.Invoke(new Action(() =>
|
{
|
_recordOperateCtrl.SetValveDegree出口(degree);
|
}));
|
}
|
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
|
};
|
}
|
return true;
|
}
|
|
private void InitialFeatTestHelper()
|
{
|
if (_featTestHelper == null)
|
{
|
_featTestHelper = new FeatTestHelper();
|
_featTestHelper.SetPumpInfo(
|
this._currentPumpSeries,
|
this._currentPump );
|
if (_currentMotor != null && !string.IsNullOrEmpty(_currentMotor.RatedParas))
|
{
|
var rated_motor = TProduct.Model.RatedParas4Motor.ToModel(_currentMotor.RatedParas);
|
_featTestHelper.SetMotorInfo(rated_motor.E_Self, _currentMotor.EtaCurve);
|
}
|
_featTestHelper.SetParallelInfo(this._parallelInfo);
|
_featTestHelper.SetTestInfo(
|
this._workBenchInfo,
|
this._testItem,
|
this._allMonitorPointList);
|
}
|
}
|
/// <summary>
|
/// 是否操控过测试记录
|
/// </summary>
|
private bool _isModifyTestRecord = false;
|
public bool IsModifyTestRecord
|
{
|
get { return _isModifyTestRecord; }
|
}
|
#region 自动测试
|
//开始自动测试
|
FeatTestHelper _featTestHelper = null;
|
private void StartAutoTest()
|
{
|
InitialFeatTestHelper();
|
//不让关闭COM口
|
tableLayoutRight.RowStyles[2].Height = 0;
|
|
|
bsiOperateInfo.Caption = "自动测试开始";
|
}
|
private void StopAutoTest()
|
{
|
tableLayoutRight.RowStyles[2].Height = 50;
|
|
bsiOperateInfo.Caption = "自动测试停止";
|
}
|
#endregion
|
|
|
#region 添加记录
|
/// <summary>
|
/// 获取有效点(添加记录):
|
/// </summary>
|
/// <param name="paras">操作参数 , 手动时,没用, 自动时, 输入开度</param>
|
/// <param name="type">type 0 自动 1 手动</param>
|
private void NewFeatTestRecord(string paras,
|
TProduct.WinFrmUI.TPump.TestRecordOperateBaseCtrl.eGetRecordType type)
|
{
|
_isModifyTestRecord = true;
|
if (type == TestRecordOperateBaseCtrl.eGetRecordType.手动)
|
{// 1 手动
|
#region 手动,对话框
|
//防止重复点击,否则会报错
|
if (theCalcDataDlg.Visible)
|
return;
|
|
//获取仪表的测量值
|
List<TProduct.Model.MonitorPointValuePure> valueList = this._monitorValveIngRecordHelper.GetAverageValueList();
|
|
theCalcDataDlg.NewTestRecord(valueList, true);
|
if (this._recordOperateCtrl != null)
|
{
|
theCalcDataDlg.SetValveDegree("进口", this._recordOperateCtrl.GetValveDegree进口());
|
theCalcDataDlg.SetValveDegree("出口", this._recordOperateCtrl.GetValveDegree出口());
|
}
|
|
theCalcDataDlg.Show(this);
|
#endregion
|
}
|
else if (type == TestRecordOperateBaseCtrl.eGetRecordType.自动)
|
{//自动
|
List<TProduct.Model.MonitorPointValuePure> valueList =
|
this._monitorValveIngRecordHelper.GetAverageValueList();
|
if (string.IsNullOrEmpty(paras))
|
return;
|
|
if (_featTestHelper == null)
|
{
|
InitialFeatTestHelper();
|
}
|
var degree = Convert.ToDouble(paras);
|
string error_info = "";
|
var record = _featTestHelper.NewTestRecord(valueList, degree,
|
out error_info);
|
if (this._recordOperateCtrl != null)
|
{
|
_featTestHelper.SetValveDegree("进口", this._recordOperateCtrl.GetValveDegree进口());
|
_featTestHelper.SetValveDegree("出口", this._recordOperateCtrl.GetValveDegree出口());
|
}
|
|
if (record == null)
|
{
|
_autoTestInfoCtrl.SetErrorRecord(degree, error_info);
|
|
var info = string.Format("获取{0}度的数据时, 出错了,请检查,具体原因是:{1}", degree,
|
error_info);
|
bsiOperateInfo.Caption = info;
|
TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm,
|
"错误提示", info);
|
}
|
else
|
{
|
_autoTestInfoCtrl.SetNormalRecord(degree, record);
|
|
//保存
|
SaveTestRecord(record, 1);
|
|
//
|
string info = string.Format("自动获取特征点({0}度),Q:{1},H:{2}", degree, record.CorrectPtQ, record.CorrectPtH);
|
bsiOperateInfo.Caption = info;
|
|
TProduct.WinFrmUI.AlertTool.ShowInfo(TProduct.WinFrmUI.GlobeParas.MainForm, "提示", info);
|
}
|
|
}
|
}
|
|
#endregion
|
|
|
#region 编辑记录
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="record"></param>
|
private void EditFeatTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
|
{
|
_isModifyTestRecord = true;
|
//防止重复点击,否则会报错
|
if (theCalcDataDlg.Visible)
|
return;
|
|
theCalcDataDlg.EditTestRecord(record);
|
|
theCalcDataDlg.Show(this);
|
}
|
#endregion
|
|
|
#region 删除记录
|
/// <summary>
|
/// 单条删除
|
/// </summary>
|
/// <param name="record"></param>
|
private void DeleteFeatTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record)
|
{
|
if (this._allRecords == null)
|
return;
|
var f = this._allRecords.Find(x => x.ID == record.ID);
|
if (f == null)
|
return;
|
|
_isModifyTestRecord = true;
|
|
new BLL.PumpFeatTestRecord().Delete(this._testItem, f.ID);
|
this._allRecords.Remove(f);
|
|
|
_monitorGridCtrl.RefreshData(this._allRecords);
|
_chartMainCtrl.SetRecordPoint(this._allRecords);
|
if (_correctPtGridCtrl != null)
|
_correctPtGridCtrl.RefreshData(this._allRecords);
|
|
RefreshItemPointNumber();
|
}
|
|
/// <summary>
|
/// 全部删除
|
/// </summary>
|
private void EmptyAllRecord()
|
{
|
if (this._allRecords == null || this._allRecords.Count() == 0)
|
return;
|
DialogResult result1 = MessageBox.Show("请问是否清空测试数据", "询问",
|
System.Windows.Forms.MessageBoxButtons.YesNo,
|
System.Windows.Forms.MessageBoxIcon.Warning);
|
if (result1 != DialogResult.Yes)
|
{
|
return;
|
}
|
|
DialogResult result2 = MessageBox.Show("请问是否清空测试数据,删除后, 数据无法恢复,请再次确认", "询问",
|
System.Windows.Forms.MessageBoxButtons.YesNo,
|
System.Windows.Forms.MessageBoxIcon.Warning);
|
if (result2 != DialogResult.Yes)
|
{
|
return;
|
}
|
_isModifyTestRecord = true;
|
|
new TProduct.BLL.PumpFeatTestRecord().ClearAllRecord(this._testItem);
|
this._allRecords.Clear();
|
this._monitorGridCtrl.ClearData();
|
this._chartMainCtrl.EmptyRecordPoint();
|
if (_correctPtGridCtrl != null)
|
this._correctPtGridCtrl.ClearData();
|
}
|
|
#endregion
|
|
|
#region 保存记录
|
/// <summary>
|
/// 保存记录 operateType表示操作类型 1 表示添加 2 表示更新 3表示删除
|
/// </summary>
|
/// <param name="record"></param>
|
private void SaveTestRecord(TProduct.Model.PumpFeatTestRecordViewModel record,
|
int operateType)
|
{
|
if (operateType == 1)
|
{
|
if (this._allRecords == null)
|
this._allRecords = new List<TProduct.Model.PumpFeatTestRecordViewModel>();
|
|
this._allRecords.Add(record);
|
}
|
if (this._allRecords == null || this._allRecords.Count == 0)
|
{
|
RefreshItemPointNumber();
|
return;
|
}
|
RefreshItemPointNumber();
|
|
_isModifyTestRecord = true;
|
|
_monitorGridCtrl.RefreshData(this._allRecords);
|
_chartMainCtrl.SetRecordPoint(this._allRecords);
|
if (_correctPtGridCtrl != null)
|
_correctPtGridCtrl.RefreshData(this._allRecords);
|
}
|
/// <summary>
|
/// 保存记录点数
|
/// </summary>
|
private void RefreshItemPointNumber()
|
{
|
this._testItem.TestEndTime = DateTime.Now;
|
if (this._allRecords == null || this._allRecords.Count == 0)
|
{
|
if (this._testItem.PointNumber != 0)
|
{
|
this._testItem.PointNumber = 0;
|
new BLL.TestProjectItem().UpdatePointNumberAndTime(this._testItem.ItemID,
|
this._testItem.PointNumber);
|
|
if (OnChangeTestInfo != null)
|
{
|
OnChangeTestInfo(this._testItem);
|
}
|
}
|
return;
|
}
|
else
|
{
|
if (this._testItem.PointNumber != this._allRecords.Count)
|
{
|
this._testItem.PointNumber = this._allRecords.Count;
|
new BLL.TestProjectItem().UpdatePointNumberAndTime(this._testItem.ItemID,
|
this._testItem.PointNumber);
|
|
if (OnChangeTestInfo != null)
|
{
|
OnChangeTestInfo(this._testItem);
|
}
|
}
|
}
|
}
|
|
#endregion
|
|
|
#region 对话框操作
|
private CalcFeatTestBaseDlg theCalcDataDlg = null;
|
//初始化计算对话框
|
private bool InitialCalcDialog(
|
TProduct.Model.ProductSeries pump_series,
|
TProduct.Model.ProductMainExPump pump,
|
TProduct.Model.ProductMainExMotor motor,
|
TProduct.Model.WorkBenchBase workBenchParas,
|
TProduct.Model.TestProjectItemView item,
|
List<TProduct.Model.WorkBenchMonitorPoint> allMonitorList)
|
{
|
if (this._allMonitorPointList == null || this._allMonitorPointList.Count < 1)
|
return false;
|
|
if (pump != null && pump.Ratedn == null)
|
{
|
MessageBox.Show("泵参数还未设置额定转速");
|
return false;
|
}
|
|
CalcFeatTestData1Dlg theCalc1Dlg = new CalcFeatTestData1Dlg();
|
theCalc1Dlg.SetPumpInfo(pump_series,pump);
|
theCalc1Dlg.SetMotorInfo(motor);
|
theCalc1Dlg.SetTestInfo(workBenchParas, item);
|
theCalc1Dlg.InitialMonitorInfo(allMonitorList);
|
theCalc1Dlg.Name = "CalcFeatTestDataDlg";
|
theCalc1Dlg.OnSaveRecord += (record, operateType) =>
|
{//operateType表示操作类型 1 表示添加 2 表示更新 3表示删除
|
SaveTestRecord(record, operateType);
|
};
|
|
theCalcDataDlg = theCalc1Dlg;
|
|
return true;
|
}
|
|
#endregion
|
|
|
#region 初始化通讯设备
|
private bool InitialLink()
|
{
|
if (this._workBenchInfo.LinkType == Model.eLinkType.ShunZhou)
|
{
|
#region 顺舟
|
var shunlinkHelper = new Link.Shun.LinkHelper();
|
this._linkHelper = shunlinkHelper;
|
|
//使用事件接收
|
shunlinkHelper.OnReceiveMonitorValue += (s, e) =>
|
{
|
this.Invoke(new MethodInvoker(delegate
|
{
|
//测点信息
|
ReceiveIntrumentMonitorValue(e.MonitorValues );
|
//附加信息
|
RefreshAdditionInfo(e.AdditionInfos);
|
}));
|
};
|
TProduct.Model.WorkBenchInstrumentShunBundle bundles_shun =
|
new BLL.WorkBenchInstrumentShun().GetShunBundle(this._workBenchInfo);
|
if (bundles_shun == null || bundles_shun.MonitorPointList == null || bundles_shun.MonitorPointList.Count == 0)
|
{
|
MessageBox.Show("初始化测试台bundles失败");
|
return false;
|
}
|
// 初始化监控点(会根据当前设置修改 监控点 的信息)
|
this._allMonitorPointList =
|
ResetMonitorPoint(bundles_shun.MonitorPointList);
|
|
string error_info;
|
if (!shunlinkHelper.InitialData(
|
this._currentPump,
|
this._currentMotor,
|
this._testItem,
|
bundles_shun, out error_info))
|
{
|
MessageBox.Show(error_info);
|
return false;
|
}
|
//初始化步骤控件
|
var com_names = (from x in bundles_shun.Sz02List where x.UseStatus == TProduct.Model.eUseStatus.Enable select x.ComPortName).Distinct();
|
if (!InitialCommConnectCtrl(com_names.ToList()))
|
{
|
MessageBox.Show("初始化步骤控件失败,请确认Comm口");
|
return false;
|
}
|
#endregion
|
}
|
else if (this._workBenchInfo.LinkType == Model.eLinkType.KeDi)
|
{
|
#region 科迪 KD
|
var allPressMeter = new TProduct.BLL.PressureMeter().GetAll();
|
var allFlowMeter = new TProduct.BLL.FlowMeter().GetAll();
|
var kdlinkHelper = new TProduct.Link.Kedi.LinkHelper();
|
kdlinkHelper.SetMeterInfo(allPressMeter, allFlowMeter);
|
|
this._linkHelper = kdlinkHelper;
|
//使用事件接收 _linkHelper.OnReceiveMsg += OnReceiveMessage;
|
kdlinkHelper.OnReceiveMonitorValue += (s, e) =>
|
{//子线程会操作界面, 需用委托
|
this.Invoke(new MethodInvoker(delegate
|
{
|
//测点信息
|
ReceiveIntrumentMonitorValue(e.MonitorValues );
|
//附加信息
|
RefreshAdditionInfo(e.AdditionInfos);
|
}));
|
};
|
List<Model.WorkBenchInstrumentKedi> listInstructs =
|
new BLL.WorkBenchInstrumentKedi().GetByBenchID(this._workBenchInfo.ID);
|
if (listInstructs == null || listInstructs.Count() == 0)
|
{
|
MessageBox.Show("初始化测试台bundles失败");
|
return false;
|
}
|
// 在软件里面 是否可以操控泵的开启挺
|
ribbonPageGroup开停机.Visible = TProduct.CorpSetting.PumpTest. IsOperatePumpAble;
|
|
// 初始化监控点(会根据当前设置修改 监控点 的信息)
|
this._allMonitorPointList = ResetMonitorPoint(new BLL.WorkBenchMonitorPoint().GetByBenchID(this._workBenchInfo.ID));
|
if (this._allMonitorPointList == null || this._allMonitorPointList.Count() == 0)
|
{
|
MessageBox.Show("初始化测试台失败,未配备测点");
|
return false;
|
}
|
|
|
//初始化数据(此时可能时间会比较长,需要设置CT和PT)
|
string error_info;
|
if (!kdlinkHelper.InitialData(
|
this._currentPump,
|
this._currentMotor,
|
this._workBenchInfo, this._testItem,
|
listInstructs,
|
this._allMonitorPointList, out error_info))
|
{
|
MessageBox.Show(error_info);
|
return false;
|
}
|
|
//初始化步骤控件
|
var com_names = (from x in listInstructs select x.ComPortName).Distinct().ToList();
|
if (!InitialCommConnectCtrl(com_names))
|
{
|
MessageBox.Show("初始化步骤控件失败,请确认Comm口");
|
return false;
|
}
|
#endregion
|
}
|
else if (this._workBenchInfo.LinkType == Model.eLinkType.RandomValue)
|
{
|
#region 随机数
|
var kdlinkHelper = new TProduct.Link.RandomLinkHelper();
|
|
this._linkHelper = kdlinkHelper;
|
//使用事件接收 _linkHelper.OnReceiveMsg += OnReceiveMessage;
|
kdlinkHelper.OnReceiveMonitorValue += (s, e) =>
|
{//子线程会操作界面, 需用委托
|
this.Invoke(new MethodInvoker(delegate
|
{
|
//测点信息
|
ReceiveIntrumentMonitorValue(e.MonitorValues);
|
//附加信息
|
RefreshAdditionInfo(e.AdditionInfos);
|
}));
|
};
|
List<Model.WorkBenchInstrumentKedi> listInstructs =
|
new BLL.WorkBenchInstrumentKedi().GetByBenchID(this._workBenchInfo.ID);
|
if (listInstructs == null || listInstructs.Count() == 0)
|
{
|
MessageBox.Show("初始化测试台bundles失败");
|
return false;
|
}
|
|
|
this._allMonitorPointList = ResetMonitorPoint(new BLL.WorkBenchMonitorPoint().GetByBenchID(this._workBenchInfo.ID));
|
if (this._allMonitorPointList == null || this._allMonitorPointList.Count() == 0)
|
{
|
MessageBox.Show("初始化测试台失败,未配备测点");
|
return false;
|
}
|
string error_info;
|
if (!kdlinkHelper.InitialData(
|
this._currentPump,
|
this._currentMotor,
|
this._workBenchInfo, this._testItem,
|
listInstructs,
|
this._allMonitorPointList, out error_info))
|
{
|
MessageBox.Show(error_info);
|
return false;
|
}
|
//初始化步骤控件
|
var com_names = new List<string>() { "ComX" };
|
if (!InitialCommConnectCtrl(com_names))
|
{
|
MessageBox.Show("初始化步骤控件失败,请确认Comm口");
|
return false;
|
}
|
#endregion
|
}
|
|
else
|
{
|
MessageBox.Show("暂时不支持此类型的链接");
|
return false;
|
}
|
|
return true;
|
}
|
|
#endregion
|
|
|
#region 通讯日志
|
|
TProduct.WinFrmUI.TBase.LinkLogListCtrl _linkLogCtrl = null;
|
/// <summary>
|
/// 通讯日志
|
/// </summary>
|
private void InitialLinkLogCtrl()
|
{
|
if (this._testItem == null)
|
return;
|
if (!TProduct.UserSetting.Setting.Disp.IsShowLog)
|
{
|
this.tabPageLinkLog.PageVisible = false;
|
return;
|
}
|
|
|
if (_linkLogCtrl == null)
|
{
|
_linkLogCtrl = new TBase.LinkLogListCtrl();
|
_linkLogCtrl.Name = "TestItemLogContentCtrl";
|
_linkLogCtrl.Dock = DockStyle.Fill;
|
|
this.tabPageLinkLog.Controls.Add(_linkLogCtrl);
|
|
this._linkHelper.OnShowMsg += (arg) =>
|
{//子线程会操作界面, 需用委托
|
this.Invoke(new MethodInvoker(delegate
|
{
|
_linkLogCtrl.AddMsg(arg);
|
}));
|
};
|
|
|
}
|
}
|
|
|
|
#endregion
|
|
}
|
}
|