using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Windows.Forms;
|
using TProduct.Model;
|
|
namespace TProduct.WinFrmUI.TValve
|
{
|
/// <summary>
|
/// 性能测试
|
/// </summary>
|
public partial class FeatTestIngMainPage : TestIngBaseMainPage
|
{
|
//通讯辅助类
|
private TProduct.Link.LinkBaseHelper _linkHelper = null;
|
//是否正在测试
|
protected bool _isIngTestStatus = false;
|
//仪表盘控件
|
private Dictionary<long, TProduct.WinFrmUI.TBase.UserGaugeControl> _allMonitorGaugeDict = null;
|
//列表控件
|
private GridFeatMonitorRecordCtrl _monitorGridCtrl = null;
|
//图表控件
|
private ChartValveFeatCurveCtrl _chartMainCtrl = null;
|
//步骤操作控件
|
private TProduct.WinFrmUI.TBase.CommConBaseCtrl _commCtrl = null;
|
//自动测试表
|
private FeatTestAutoParasCtrl _autoTestInfoCtrl = null;
|
//日志控件
|
private TBase.TestItemLogContentCtrl _testLogCtrl = null;
|
//产品信息
|
private PartInfoCtrl _partInfoCtrl = null;
|
//所有记录
|
private List<TProduct.Model.ValveFeatTestRecordViewModel> _allRecords = null;
|
public int GetTestRecordCount()
|
{
|
if (_allRecords == null)
|
return 0;
|
return _allRecords.Count();
|
}
|
//数据记录辅助类
|
private MonitorValveIngRecordHelper _monitorValveIngRecordHelper = null;
|
//
|
private TProduct.Model.TestStandard _testStandard = null;
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public FeatTestIngMainPage()
|
{
|
InitializeComponent();
|
|
this.PageTitle.Caption = "性能测试";
|
this.tabPageLinkLog.PageVisible =
|
TProduct.UserSetting.Setting.Disp.IsShowLog;
|
}
|
|
public override void Close()
|
{
|
if (_realTimeChart != null)
|
_realTimeChart.Stop();
|
|
base.Close();
|
|
DisconectCommPort();
|
}
|
|
//能否关闭对话框
|
public virtual bool IsCloseFrmAble()
|
{
|
if (_durabilityTestTimeHelper != null)
|
{
|
if (_durabilityTestTimeHelper.IsTesting())
|
{
|
MessageBox.Show("请先停止耐力试验,再关闭对话框");
|
|
return false;
|
}
|
}
|
if (_isIngTestStatus)
|
{
|
DialogResult result = MessageBox.Show("请问是否关闭", "询问",
|
System.Windows.Forms.MessageBoxButtons.YesNo,
|
System.Windows.Forms.MessageBoxIcon.Warning);
|
if (result != DialogResult.Yes)
|
{
|
return false;
|
}
|
|
DisconectCommPort();
|
}
|
if (_realTimeChart != null)
|
_realTimeChart.Stop();
|
|
return true;
|
}
|
|
#region 收到信息/发送消息
|
//收到信息
|
private void ReceiveIntrumentMonitorValue(List<TProduct.Model.MonitorPointValue> receiveMessagesInfos)
|
{
|
if (receiveMessagesInfos == null)
|
return;
|
//放到辅助类进行修正
|
List<TProduct.Model.MonitorPointValuePure> items =
|
this._monitorValveIngRecordHelper.SetMonitorValue(receiveMessagesInfos);
|
|
//仪表控件
|
foreach (var measValue in items)
|
{
|
if (_allMonitorGaugeDict.ContainsKey(measValue.ID))
|
_allMonitorGaugeDict[measValue.ID].RefreshRecordValue(measValue.Value);
|
}
|
|
//三维控件
|
//if (this._model3dCtrl != null)
|
//{
|
// this._model3dCtrl.RefreshMonitorValue(items);
|
//}
|
}
|
|
//附加信息
|
private void RefreshAdditionInfo(
|
Dictionary<string, string> additionInfos)
|
{
|
if (_isRefreshAdditionInfo == false)
|
return;
|
if (additionInfos == null)
|
return;
|
|
if (TProduct.CorpConfig.Instance.CorpFlag == eCorpFlag.WH701)
|
{
|
RefreshAdditionInfo武汉701(additionInfos);
|
}
|
_isRefreshAdditionInfo = false;
|
}
|
|
#endregion
|
|
#region 修改Comm链接状态
|
private bool ChangeCommConnectStatus(bool isConnect)
|
{
|
if (isConnect)
|
{
|
return ConectCommPort();
|
}
|
else
|
{
|
return DisconectCommPort();
|
}
|
}
|
/// <summary>
|
/// 是否链接过COM口
|
/// </summary>
|
private bool _isConnetctCommPort = false;
|
public bool IsConnetctCommPort
|
{
|
get { return _isConnetctCommPort; }
|
}
|
/// <summary>
|
/// 链接COM口
|
/// </summary>
|
private bool ConectCommPort()
|
{
|
if (_linkHelper == null)
|
{
|
XtraMessageBox.Show("设备初始化失败!Error:79");
|
return false;
|
}
|
|
|
_isConnetctCommPort = true;
|
|
//开始
|
string error_info = null;
|
if (!_linkHelper.Start(out error_info))
|
{
|
XtraMessageBox.Show(error_info);
|
return false;
|
}
|
if (this._monitorValveIngRecordHelper != null)
|
{
|
_monitorValveIngRecordHelper.Start();
|
}
|
//通知操作组件
|
if (_recordOperateCtrl != null)
|
{
|
_recordOperateCtrl.SetCommConnectStatus(true);
|
}
|
|
//实时图表
|
if (_realTimeChart != null)
|
_realTimeChart.Start();
|
|
//设置最后一次测试信息
|
RefreshLastTestInfo();
|
|
bsiOperateInfo.Caption = "已链接COM口";
|
|
|
this._isIngTestStatus = true;
|
|
return true;
|
}
|
public void RefreshLastTestInfo()
|
{
|
var user = TProduct.WinFrmUI.GlobeParas.CurrentLoginUser;
|
if (user == null)
|
return;
|
if (_currentPart != null)
|
{
|
new BLL.PartBase().UpdateLastTestUserID(_currentPart.ID, user.ID);
|
}
|
if (_workBenchInfo != null)
|
{
|
new BLL.WorkBenchBase().UpdateLastTestUserID(_workBenchInfo.ID, user.ID);
|
}
|
if (this._testItem.TestStartTime == null)
|
{
|
this._testItem.TestStartTime = DateTime.Now;
|
new BLL.TestProjectItem().RefreshTestStartTime(this._testItem.ItemID);
|
}
|
}
|
|
/// <summary>
|
/// 结束测试,断开链接
|
/// </summary>
|
public bool DisconectCommPort()
|
{
|
if (_recordOperateCtrl != null)
|
{//在Stop之前, 因为还要调用COM口
|
_recordOperateCtrl.SetCommConnectStatus(false);
|
}
|
|
string error_info = null;
|
if (!_linkHelper.Stop(out error_info))
|
{
|
MessageBox.Show(error_info);
|
}
|
|
|
this._isIngTestStatus = false;
|
|
//if (_durabilityTestTimeHelper != null)
|
//{
|
// _durabilityTestTimeHelper.SetStop();
|
//}
|
if (this._monitorValveIngRecordHelper != null)
|
{
|
this._monitorValveIngRecordHelper.Stop();
|
}
|
if (_realTimeChart != null)
|
_realTimeChart.Stop();
|
|
|
this._testItem.TestEndTime = DateTime.Now;
|
new BLL.TestProjectItem().RefreshTestEndTime(this._testItem.ItemID);
|
|
|
bsiOperateInfo.Caption = "已断开COM口";
|
|
return true;
|
}
|
public void CheckTestEndTime()
|
{
|
if (this._testItem.TestStartTime == null)
|
return;
|
if (this._isIngTestStatus)
|
{
|
if (this._testItem.TestEndTime == null)
|
{
|
this._testItem.TestEndTime = DateTime.Now;
|
new BLL.TestProjectItem().RefreshTestEndTime(this._testItem.ItemID);
|
}
|
else if (this._testItem.TestEndTime.Value <= this._testItem.TestStartTime.Value)
|
{
|
this._testItem.TestEndTime = DateTime.Now;
|
new BLL.TestProjectItem().RefreshTestEndTime(this._testItem.ItemID);
|
}
|
}
|
}
|
|
#endregion
|
|
|
|
|
public Action OnCloseAndView = null;
|
private void bbi关闭并查看_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
if (OnCloseAndView != null)
|
OnCloseAndView.Invoke();
|
}
|
|
private bool _isRefreshAdditionInfo = false;
|
private void bbi刷新状态信息_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
_isRefreshAdditionInfo = true;
|
}
|
}
|
}
|