using DataEntity.Device;
|
using DataEntity.Share;
|
using DataRWDAL;
|
using DataRWDAL.Device;
|
using HandyControl.Data;
|
using HxEnum;
|
using HxSocketImplement.Sockets;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.IO;
|
using System.Linq;
|
using System.Windows;
|
using System.Windows.Input;
|
using System.Xml;
|
using XCommon;
|
using XCommon.Log;
|
using XCommon.Tip;
|
using XHandler.Class.DataEx;
|
using XHandler.Controls.Run.Com;
|
using XHandler.View.MethodProperty;
|
using XImagingXhandler.XDAL;
|
using static HxEnum.StateEnum;
|
|
namespace XHandler.View
|
{
|
/// <summary>
|
/// 设备编辑 页面
|
/// </summary>
|
public partial class RunAgoTips : System.Windows.Window
|
{
|
#region 参数
|
private RunWnd m_lauchView = null;
|
private ObservableCollection<DeviceStatusData> m_deviceStatusList = new ObservableCollection<DeviceStatusData>();
|
#endregion
|
|
#region 构造函数
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public RunAgoTips(RunWnd lauchView)
|
{
|
InitializeComponent();
|
m_lauchView = lauchView;
|
this.Owner = (Window)Shared.Main;
|
}
|
#endregion
|
|
#region 初始化
|
/// <summary>
|
/// 初始化,枪头盒不支持叠放
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
#region 枪头类型
|
var platformNodeList = m_lauchView.xmlDocument.SelectSingleNode("root/env").SelectNodes("platform");
|
|
// 从台面获取所有枪头
|
List<Labware> labwares = new List<Labware>();
|
foreach (XmlNode platformNodeItem in platformNodeList)
|
{
|
var a = platformNodeItem.SelectNodes("labware");
|
if (platformNodeItem.SelectNodes("labware")==null|| platformNodeItem.SelectNodes("labware").Count==0)
|
{
|
continue;
|
}
|
string labwareId = platformNodeItem.SelectNodes("labware")[0].SelectSingleNode("labware_id").InnerText;
|
if(labwareId==null||labwareId.Equals(string.Empty))
|
{
|
continue;
|
}
|
Labware labWare = LabwareDB.GetLabware(labwareId);
|
|
if (labWare.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.TipsBox).ToString()) // 吸头盒
|
{
|
labwares.Add(labWare);
|
}
|
}
|
|
labwares = labwares.Distinct().ToList();
|
labwares = labwares.GroupBy(item => item.labware_id).Select(group => group.First()).ToList();
|
|
comboboxLabwareType.ItemsSource = labwares;
|
if (labwares.Count > 0)
|
{
|
comboboxLabwareType.SelectedIndex = 0;
|
}
|
#endregion
|
|
#region 设备状态
|
var deviceConfigResult = DeviceConfigDB.GetDeviceConfigListByProjectId(Shared.SoftwareInformation.software_information_id);
|
|
foreach (var item in deviceConfigResult)
|
{
|
DeviceStatusData deviceStatus = new DeviceStatusData();
|
deviceStatus.DeviceName = item.Name;
|
deviceStatus.DeviceId = item.EquipmentId;
|
deviceStatus.VirtualConnectionState = item.VirtualConnectionState == EnumManagement.GetEnumValue(VirtualConnectionStateEnum.Virtually) ? "是" : "否";
|
|
if (item.CommunicateType == EnumManagement.GetEnumValue(CommunicateTypeEnum.Socket)) //Socket
|
{
|
var checkConnectedResult = HxSocketParameterService.CheckConnected(item.Type, item.Ip, Convert.ToInt32(item.Port), item.EquipmentId);
|
if (checkConnectedResult != null && checkConnectedResult.status == StateEnum_Equipment.Completed)
|
{
|
deviceStatus.DeviceStatus = true;
|
}
|
else
|
{
|
deviceStatus.DeviceStatus = false;
|
}
|
}
|
|
m_deviceStatusList.Add(deviceStatus);
|
}
|
|
dgDeviceData.ItemsSource = m_deviceStatusList;
|
#endregion
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
#endregion
|
|
#region 清除缓存数据
|
/// <summary>
|
/// 清除缓存数据
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
|
private void btnClearData_Click(object sender, RoutedEventArgs e)
|
{
|
if (m_lauchView != null)
|
{
|
// 清除Tip缓存数据
|
ControlCom.ClearTipData(m_lauchView);
|
}
|
|
string directoryBase = System.AppDomain.CurrentDomain.BaseDirectory;
|
string xmlFilePath = directoryBase + "Config\\" + "CurrentUsedTips.xml";
|
if (File.Exists(xmlFilePath))
|
{
|
File.Delete(xmlFilePath);
|
}
|
}
|
#endregion
|
|
#region 确定
|
/// <summary>
|
/// 确定
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
{
|
this.DialogResult = true;
|
this.Close();
|
}
|
#endregion
|
|
#region 拖动窗体
|
/// <summary>
|
/// 拖动窗体
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
|
{
|
if (e.ChangedButton == MouseButton.Left)
|
{
|
this.DragMove();
|
}
|
}
|
#endregion
|
|
#region 关闭页面
|
/// <summary>
|
/// 关闭页面
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnClose_Click(object sender, RoutedEventArgs e)
|
{
|
this.DialogResult = false;
|
this.Close();
|
}
|
#endregion
|
|
#region ESC关闭画面
|
/// <summary>
|
/// ESC关闭画面
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
{
|
if (e.Key == Key.Escape)
|
{
|
this.DialogResult = false;
|
this.Close();
|
}
|
}
|
#endregion
|
|
#region 枪头类型选择变更
|
private void comboboxLabwareType_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
{
|
if (comboboxLabwareType.SelectedIndex < 0)
|
{
|
return;
|
}
|
|
// 根据选择的类型加载枪头数量
|
if (m_lauchView.xmlDocument != null)
|
{
|
Labware labwareT = (Labware)(comboboxLabwareType.SelectedItem as Labware);
|
XmlNode latticeXn = m_lauchView.xmlDocument.SelectSingleNode("root/env");
|
|
//XmlNodeList labwareNode = latticeXn.SelectNodes("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false) + "]/labware");
|
//int countOfLabware = labwareNode.Count;
|
//var latticeDes = latticeXn.SelectSingleNode("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false) + "]/labware[@id=" + (countOfLabware - gripTransportData.transportCount + 1).ToString() + "][labware_id='" + labwareT.labware_id + "']");
|
|
XmlNodeList platFormXmlNodeList = latticeXn.SelectNodes("platform");// [labware_id='" + labwareT.labware_id + "']");
|
int totalCountTip = ((int)labwareT.number_row * (int)labwareT.number_column);
|
|
int usedAllTotalTips = 0;
|
foreach (XmlNode p in platFormXmlNodeList)
|
{
|
XmlNodeList labwareNodeList = p.SelectNodes("labware");
|
int countOfLabware = labwareNodeList.Count;
|
XmlNode xn= p.SelectSingleNode("labware[@id=" + (countOfLabware).ToString() + "][labware_id='" + labwareT.labware_id + "']");
|
|
if (xn != null)
|
{
|
List<string> lstResidueValidWells = ComUtility.GetValidWells(xn.SelectSingleNode("residueValidWells").InnerText);
|
usedAllTotalTips = usedAllTotalTips + (totalCountTip - lstResidueValidWells.Count());
|
}
|
}
|
tbkUsedCount.Text = usedAllTotalTips.ToString();
|
}
|
}
|
#endregion
|
|
#region 当前类型重置
|
/// <summary>
|
/// 当前类型重置
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnResetCurrentTipType_Click(object sender, RoutedEventArgs e)
|
{
|
if(comboboxLabwareType.SelectedIndex<0)
|
{
|
ShowTip.ShowNotice("请选择枪头类型", InfoType.Warning);
|
return;
|
}
|
|
Labware labwareTip = (Labware)(comboboxLabwareType.SelectedItem as Labware);
|
|
if (m_lauchView != null)
|
{
|
// 清除Tip缓存数据
|
ControlCom.ClearTipData(m_lauchView, labwareTip);
|
}
|
|
string directoryBase = System.AppDomain.CurrentDomain.BaseDirectory;
|
string xmlFilePath = directoryBase + "Config\\" + "CurrentUsedTips.xml";
|
if (File.Exists(xmlFilePath))
|
{
|
File.Delete(xmlFilePath);
|
}
|
|
tbkUsedCount.Text = "0";
|
ShowTip.ShowNotice("重置成功", InfoType.Success);
|
}
|
#endregion
|
|
/// <summary>
|
/// 全部重置
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnResetAllTipType_Click(object sender, RoutedEventArgs e)
|
{
|
if (m_lauchView != null)
|
{
|
// 清除Tip缓存数据
|
ControlCom.ClearTipData(m_lauchView);
|
}
|
|
string directoryBase = System.AppDomain.CurrentDomain.BaseDirectory;
|
string xmlFilePath = directoryBase + "Config\\" + "CurrentUsedTips.xml";
|
if (File.Exists(xmlFilePath))
|
{
|
File.Delete(xmlFilePath);
|
}
|
|
tbkUsedCount.Text = "0";
|
ShowTip.ShowNotice("重置成功", InfoType.Success);
|
}
|
}
|
}
|