|
@@ -1,10 +1,13 @@
|
|
|
-using SCADA.CommonCtrl.WpfControl;
|
|
|
+using DBModel;
|
|
|
+using SCADA.CommonCtrl.WpfControl;
|
|
|
+using SCADA.CommonLib;
|
|
|
using SCADA.CommonLib.Helper;
|
|
|
using SCADA.Drive;
|
|
|
using SCADA_DAQ.Customer.Machines;
|
|
|
using SCADA_DAQ.Customer.Models;
|
|
|
using SCADA_DAQ.Customer.Views.Uct;
|
|
|
using SCADA_DAQ.Plugin.Machine;
|
|
|
+using SCADA_DAQ.Plugin.Robot.Stacking;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -30,6 +33,10 @@ namespace SCADA_DAQ.Customer
|
|
|
{
|
|
|
public SampleMachine plc { get; set; }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ public StackParameter stackParameter { get; set; } = new StackParameter();
|
|
|
/// <summary>
|
|
|
/// 码垛方案
|
|
|
/// </summary>
|
|
@@ -41,98 +48,72 @@ namespace SCADA_DAQ.Customer
|
|
|
ToolBar.Visibility = Visibility.Collapsed;
|
|
|
plc = MachineServer.GetInstance().GetMachine<SampleMachine>("Device1");
|
|
|
AxisGroup.SetMacBinding(plc);
|
|
|
- Stacksln.Text = "码垛方案:";
|
|
|
- BoardWidth.Value = "0.0";
|
|
|
- BoardWidth.TitleValue = "栈板宽度:";
|
|
|
- BoardLength.TitleValue = "栈板长度:";
|
|
|
- BoardLength.Value = "0.0";
|
|
|
- StackHeight.TitleValue = "最高高度:";
|
|
|
- StackHeight.Value = "0.0";
|
|
|
- BoxWidth.TitleValue = "纸箱宽度:";
|
|
|
- BoxHeight.TitleValue = "纸箱高度:";
|
|
|
- BoxLength.TitleValue = "纸箱长度:";
|
|
|
- BoxWidth.Value = "0.0";
|
|
|
- BoxHeight.Value = "0.0";
|
|
|
- BoxLength.Value = "0.0";
|
|
|
- CaptureIndex.Value = "0";
|
|
|
- CaptureIndex.TitleValue = "码垛序号:";
|
|
|
- LayerNo.Value = "0";
|
|
|
- LayerNo.TitleValue = "层号:";
|
|
|
- LayerIndex.Value = "0";
|
|
|
- LayerIndex.TitleValue = "层内序号:";
|
|
|
+ //Stacksln.Text = "码垛方案:";
|
|
|
+ //BoardWidth.Value = "0.0";
|
|
|
+ //BoardWidth.TitleValue = "栈板宽度:";
|
|
|
+ //BoardLength.TitleValue = "栈板长度:";
|
|
|
+ //BoardLength.Value = "0.0";
|
|
|
+ //StackHeight.TitleValue = "最高高度:";
|
|
|
+ //StackHeight.Value = "0.0";
|
|
|
+ //BoxWidth.TitleValue = "纸箱宽度:";
|
|
|
+ //BoxHeight.TitleValue = "纸箱高度:";
|
|
|
+ //BoxLength.TitleValue = "纸箱长度:";
|
|
|
+ //BoxWidth.Value = "0.0";
|
|
|
+ //BoxHeight.Value = "0.0";
|
|
|
+ //BoxLength.Value = "0.0";
|
|
|
|
|
|
|
|
|
- var stackSlnList = Env.DAL.App_Stack_Sln.GetData().DtToList<StackSlnModel>();
|
|
|
- var fileStr = "(";
|
|
|
- for (int i = 0; i < stackSlnList.Count; i++)
|
|
|
- {
|
|
|
- if (i == stackSlnList.Count - 1)
|
|
|
- {
|
|
|
- fileStr += $"{stackSlnList[i].ID})";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fileStr += $"{stackSlnList[i].ID},";
|
|
|
- }
|
|
|
+ StackSelection.Content = new AutoView(stackParameter, new List<string>() {
|
|
|
+ nameof(stackParameter.SlnName)
|
|
|
+ }, 1, Orientation.Vertical,
|
|
|
+ Orientation.Vertical)
|
|
|
+ { ContentWidth = 120 };
|
|
|
|
|
|
- }
|
|
|
- var stackCaputerList = Env.DAL.App_Stack_Capture.GetData($"SlnId_Int in {fileStr}").DtToList<StackCaptureModel>().ToLookup(i => i.SlnId_Int);
|
|
|
- foreach (var stackCaputer in stackCaputerList)
|
|
|
- {
|
|
|
- var stackSlnID = stackSlnList.Where(i => i.ID == stackCaputer.Key).FirstOrDefault();
|
|
|
- if (stackSlnID != null)
|
|
|
- {
|
|
|
- foreach (var item in stackCaputer)
|
|
|
- {
|
|
|
- stackSlnID.StackCaptureList.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- StackSlnList = stackSlnList;
|
|
|
- ChooseStackSln.ItemsSource = stackSlnList.Select(i => i.SlnName_Str).ToList();
|
|
|
- ChooseStackSln.DropDownClosed += ChooseStackSln_DropDownClosed;
|
|
|
- plc.BaseDevice.RegReadValueChanged += BaseDevice_RegReadValueChanged;
|
|
|
- }
|
|
|
+ StackInfo.Content = new AutoView(
|
|
|
+ stackParameter, new List<string>() {
|
|
|
+ nameof(stackParameter.BoardWidth),
|
|
|
+ nameof(stackParameter.BoardLength),
|
|
|
+ nameof(stackParameter.StackHeight),
|
|
|
|
|
|
- private void BaseDevice_RegReadValueChanged(object sender, SCADA.Drive.RegReadValueChangedEventArgs e)
|
|
|
- {
|
|
|
- var reg = (RegInfo)sender;
|
|
|
- if (reg.Comment.Variable == "开始作业" && reg.Value == 1)
|
|
|
- {
|
|
|
- Dispatcher.Invoke(() =>
|
|
|
- {
|
|
|
- CaptureIndex.Value = CustomerEnv.StackCapture.CaptureIndex_Int.ToString();
|
|
|
- LayerIndex.Value = CustomerEnv.StackCapture.LayerIndex_Int.ToString();
|
|
|
- LayerNo.Value = CustomerEnv.StackCapture.LayerNo_Int.ToString();
|
|
|
- });
|
|
|
- }
|
|
|
+ nameof(stackParameter.BoxWidth),
|
|
|
+ nameof(stackParameter.BoxHeight),
|
|
|
+ nameof(stackParameter.BoxWidth),
|
|
|
+ }, 3, Orientation.Horizontal,
|
|
|
+ Orientation.Horizontal, AutoViewElementKind.TextBlock)
|
|
|
+ { ContentWidth = 60 };
|
|
|
+
|
|
|
+ CurrentBoxInfo.Content = new AutoView(plc.StackCapture,
|
|
|
+ new List<string>() {
|
|
|
+ nameof(CaptureModel.CaptureIndex),
|
|
|
+ null,
|
|
|
+ nameof(CaptureModel.LayearIndex),
|
|
|
+ nameof(CaptureModel.LayearNo)
|
|
|
+
|
|
|
+ }, 2, Orientation.Horizontal, Orientation.Horizontal, AutoViewElementKind.TextBlock)
|
|
|
+ { ContentWidth = 50 };
|
|
|
+
|
|
|
+ DG_StackLayout.SetBinding(SmartGrid.ItemsSourceProperty, new Binding("StackCaptureList"));
|
|
|
+ DG_StackLayout.DataContext = plc.StackSln;
|
|
|
+
|
|
|
+ stackParameter.SlnNameSrc = Env.DAL.App_Stack_Sln.GetData().DtToList<App_Stack_Sln>().Select(t => t.SlnName_Str).ToList();
|
|
|
+ stackParameter.PropertyChanged += StackParameter_PropertyChanged;
|
|
|
}
|
|
|
|
|
|
- private void ChooseStackSln_DropDownClosed(object sender, EventArgs e)
|
|
|
+ private void StackParameter_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
{
|
|
|
- try
|
|
|
+ if (e.PropertyName == nameof(stackParameter.SlnName))
|
|
|
{
|
|
|
- Dispatcher.Invoke(() =>
|
|
|
+ var sln = Env.DAL.App_Stack_Sln.GetData<StackParameter>(t => t.SlnName == stackParameter.SlnName).FirstOrDefault();
|
|
|
+ if (sln != null)
|
|
|
{
|
|
|
- BoardWidth.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.BoardWidth_Dec + "mm").FirstOrDefault()?.ToString();
|
|
|
- BoardLength.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.BoardLength_Dec + "mm").FirstOrDefault()?.ToString();
|
|
|
- StackHeight.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.StackHeight_Dec + "mm").FirstOrDefault()?.ToString();
|
|
|
- BoxHeight.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.BoxHeight_Dec + "mm").FirstOrDefault()?.ToString();
|
|
|
- BoxWidth.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.BoxWidth_Dec + "mm").FirstOrDefault()?.ToString();
|
|
|
- BoxLength.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.BoxLength_Dec + "mm").FirstOrDefault()?.ToString();
|
|
|
- CaptureIndex.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.StackCaptureList.FirstOrDefault()?.CaptureIndex_Int).FirstOrDefault()?.ToString();
|
|
|
- LayerNo.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.StackCaptureList.FirstOrDefault()?.LayerNo_Int).FirstOrDefault()?.ToString();
|
|
|
- LayerIndex.Value = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text)?.Select(i => i.StackCaptureList.FirstOrDefault()?.LayerIndex_Int).FirstOrDefault()?.ToString();
|
|
|
- });
|
|
|
- CustomerEnv.StackSln = StackSlnList.Where(i => i.SlnName_Str == ChooseStackSln.Text).FirstOrDefault();
|
|
|
- CustomerEnv.StackCapture = CustomerEnv.StackSln?.StackCaptureList?.FirstOrDefault();
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
+ stackParameter.Update(sln);
|
|
|
+ plc.SetSln(sln);
|
|
|
|
|
|
+ var stack = new StackManage();
|
|
|
+ var layer1 = stack.CreateLayout(null, stackParameter, 32, sln.LayoutId);
|
|
|
+ board1.Init(stackParameter, layer1);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|