diff --git a/Aucma.Core.OldBoxFoam/ViewModels/RealRoadPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/RealRoadPageViewModel.cs
index 0c9c502d..4403a754 100644
--- a/Aucma.Core.OldBoxFoam/ViewModels/RealRoadPageViewModel.cs
+++ b/Aucma.Core.OldBoxFoam/ViewModels/RealRoadPageViewModel.cs
@@ -24,6 +24,9 @@ using System.Windows.Documents;
using static Npgsql.Replication.PgOutput.Messages.RelationMessage;
using System.Windows.Media;
using log4net;
+using System.Windows.Forms;
+using Aucma.Core.HwPLc;
+using Aucma.Core.PLc;
namespace Aucma.Core.OldBoxFoam.ViewModels
{
@@ -267,6 +270,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
ListItems.Add(new OldBoxFoamTypeModel()
{
+ ObjId = spaceInfoLeft[i].ObjId,
SpaceName = $"{i + 1}#货道",
Local = spaceInfo.Local,
Status = spaceInfoLeft[i].StoreAmount == 3 ? "1" : "0",
@@ -293,6 +297,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
ListItems.Add(new OldBoxFoamTypeModel()
{
+ ObjId = spaceInfoRight[i].ObjId,
SpaceName = $"{i + 1}#货道",
Local = spaceInfo.Local,
Status = spaceInfoRight[i].StoreAmount == 3 ? "1" : "0",
@@ -437,5 +442,92 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
}
}
+
+ private OldBoxFoamTypeModel selectedDataItem;
+ public OldBoxFoamTypeModel SelectedDataItem
+ {
+ get => selectedDataItem;
+ set => SetProperty(ref selectedDataItem, value);
+ }
+
+ ///
+ /// 设置夹具箱型
+ ///
+ ///
+ public void MouseClick(object obj)
+ {
+ var info = SelectedDataItem as OldBoxFoamTypeModel;
+ if (info != null)
+ {
+ SetBoxTypeView setBoxTypeView = new SetBoxTypeView(info.Boxtype);
+ setBoxTypeView.ShowDialog();
+
+ if(setBoxTypeView.boxTypeResult != info.Boxtype)
+ {
+ if (!string.IsNullOrEmpty(setBoxTypeView.boxTypeResult))
+ {
+ HwPLc.PlcModel plc = null;
+ //下发给PLC
+ var address = GetSpaceBoxTypeAddress(Convert.ToInt32(info.ObjId));
+ if (info.ObjId <= 4)
+ {
+ plc = HwPLc.PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
+ }
+ else
+ {
+ plc = HwPLc.PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc3"));
+ }
+ if(plc != null)
+ {
+ bool isFlag = plc.plc.WriteInt16(address, setBoxTypeView.boxTypeResult);
+
+ if (isFlag)
+ {
+ System.Windows.MessageBox.Show("货道型号设置成功");
+ }
+ else
+ {
+ System.Windows.MessageBox.Show("货道型号设置失败");
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ private string GetSpaceBoxTypeAddress(int spaceCode)
+ {
+ string address = string.Empty;
+ switch(spaceCode)
+ {
+ case 1:
+ address = "D2010";
+ break;
+ case 2:
+ address = "D2020";
+ break;
+ case 3:
+ address = "D2030";
+ break;
+ case 4:
+ address = "D2040";
+ break;
+ case 5:
+ address = "D2010";
+ break;
+ case 6:
+ address = "D2020";
+ break;
+ case 7:
+ address = "D2030";
+ break;
+ case 8:
+ address = "D2040";
+ break;
+ }
+
+ return address;
+ }
}
}
diff --git a/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml b/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml
index e80db730..d60371af 100644
--- a/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml
+++ b/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml
@@ -226,8 +226,9 @@
RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
- Foreground="White">
+ Foreground="White" SelectedItem="{Binding SelectedDataItem}" MouseLeftButtonDown="dgvMH_MouseLeftButtonDown_1">
+
diff --git a/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml.cs b/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml.cs
index 5e685fbb..7059e61c 100644
--- a/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml.cs
+++ b/Aucma.Core.OldBoxFoam/Views/RealRoadPageView.xaml.cs
@@ -22,10 +22,17 @@ namespace Aucma.Core.OldBoxFoam.Views
///
public partial class RealRoadPageView : UserControl
{
+ private RealRoadPageViewModel realRoadPageView = null;
public RealRoadPageView()
{
InitializeComponent();
- this.DataContext = new RealRoadPageViewModel();
+ realRoadPageView = new RealRoadPageViewModel();
+ this.DataContext = realRoadPageView;
+ }
+
+ private void dgvMH_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
+ {
+ realRoadPageView.MouseClick(sender);
}
}
}
diff --git a/Aucma.Core.OldBoxFoam/Views/SetBoxTypeView.xaml b/Aucma.Core.OldBoxFoam/Views/SetBoxTypeView.xaml
new file mode 100644
index 00000000..3f8876a2
--- /dev/null
+++ b/Aucma.Core.OldBoxFoam/Views/SetBoxTypeView.xaml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Aucma.Core.OldBoxFoam/Views/SetBoxTypeView.xaml.cs b/Aucma.Core.OldBoxFoam/Views/SetBoxTypeView.xaml.cs
new file mode 100644
index 00000000..a3ad2548
--- /dev/null
+++ b/Aucma.Core.OldBoxFoam/Views/SetBoxTypeView.xaml.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Aucma.Core.OldBoxFoam.Views
+{
+ ///
+ /// SetBoxTypeView.xaml 的交互逻辑
+ ///
+ public partial class SetBoxTypeView : Window
+ {
+ public string boxTypeResult = string.Empty;
+ public SetBoxTypeView(string boxType)
+ {
+ boxTypeResult = boxType ;
+ InitializeComponent();
+
+ this.BoxType.Text = boxType;
+
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ this.boxTypeResult = this.BoxType.Text;
+ this.Close();
+ }
+
+ private void Button_Click_1(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+ }
+}