瀏覽代碼

首页增加3D图

肖奇伟 3 天之前
父節點
當前提交
8cf65ebdf7

二進制
Lib/SCADA_DAQ.Plugin.Robot.dll


二進制
Lib/SCADA_DAQ.Plugin.RobotUI.dll


+ 55 - 2
SCADA_DAQ/Customer/Machines/SampleMachine.cs

@@ -49,6 +49,18 @@ namespace SCADA_DAQ.Customer.Machines
         /// </summary>
         public int CurrentCaputerIndex { get; set; } = 1;
 
+        /// <summary>
+        /// 
+        /// </summary>
+        public event EventHandler<CaputerFinishEventArgs> CaptureFinished;
+
+        /// <summary>
+        /// 开始了新的一盘堆码
+        /// </summary>
+        public event EventHandler<StackStartEventArgs> StackStarted;
+
+        public event EventHandler<StackFinishEventArgs> StackFinished;
+
         ///// <summary>
         ///// X轴取料点
         ///// </summary>
@@ -125,7 +137,10 @@ namespace SCADA_DAQ.Customer.Machines
                 }
                 var currentBox = StackSln.StackCaptureList[CurrentCaputerIndex - 1];  //查找当前需要的Box
                 StackCapture.Update(currentBox);     //用当前的box数据刷新 抓取数据
-
+                if (CurrentCaputerIndex == 1)
+                {
+                    StackStarted?.Invoke(this, new StackStartEventArgs());
+                }
                 var BoxLength = (int)StackSln.BoxLength_Dec;
                 var BoxWidth = (int)StackSln.BoxWidth_Dec;
                 var BoxHeight = (int)StackSln.BoxHeight_Dec;
@@ -171,7 +186,21 @@ namespace SCADA_DAQ.Customer.Machines
             {
                 if (CurrentCaputerIndex == StackCapture.CaptureIndex)   // 判断当前序号是否和执行的序号一致,防止误触发
                 {
-                    CurrentCaputerIndex++;   //抓取完毕,序号自增
+                    CaptureFinished?.Invoke(this, new CaputerFinishEventArgs()
+                    {
+                        CurrentCapture = StackCapture
+                    });
+                    if (CurrentCaputerIndex == StackSln.StackCaptureList.Count)
+                    {
+                        CurrentCaputerIndex = 1;  //堆码完成
+                        StackFinished?.Invoke(this, new StackFinishEventArgs());
+                    }
+                    else
+                    {
+                        CurrentCaputerIndex++;   //抓取完毕,序号自增
+                    }
+
+
                 }
                 else
                 {
@@ -236,4 +265,28 @@ namespace SCADA_DAQ.Customer.Machines
             }));
         }
     }
+
+    /// <summary>
+    /// 抓取完成
+    /// </summary>
+    public class CaputerFinishEventArgs : EventArgs
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public CaptureModel CurrentCapture { get; set; }
+    }
+
+    /// <summary>
+    /// 完成全部纸箱的堆码
+    /// </summary>
+    public class StackFinishEventArgs : EventArgs
+    {
+
+    }
+
+    public class StackStartEventArgs : EventArgs
+    {
+
+    }
 }

+ 2 - 2
SCADA_DAQ/Customer/UctFrmPalletizingManual.xaml

@@ -39,7 +39,7 @@
                     </wpfcontrol:Card>
                 </Grid>
             </Grid>
-            <Grid Grid.Row="1">
+            <Grid Grid.Row="1" MaxHeight="400">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="2*"/>
                     <ColumnDefinition Width="Auto"/>
@@ -62,7 +62,7 @@
                 <uct:UctAxisGroup x:Name="AxisGroup"/>
             </Grid>
             <Grid>
-                <stacking:UctStack3D/>
+                <stacking:UctStack3D x:Name="D3_Stack"/>
             </Grid>
             
             <Grid Grid.Column="1">

+ 53 - 1
SCADA_DAQ/Customer/UctFrmPalletizingManual.xaml.cs

@@ -42,12 +42,19 @@ namespace SCADA_DAQ.Customer
         /// </summary>
         public List<StackSlnModel> StackSlnList { get; set; }
 
+        /// <summary>
+        /// 
+        /// </summary>
         public UctFrmPalletizingManual()
         {
             InitializeComponent();
             ToolBar.Visibility = Visibility.Collapsed;
             plc = MachineServer.GetInstance().GetMachine<SampleMachine>("Device1");
             AxisGroup.SetMacBinding(plc);
+
+            plc.CaptureFinished += Plc_CaptureFinished;
+            plc.StackStarted += Plc_StackStarted; ;
+            plc.StackFinished += Plc_StackFinished; ;
             //Stacksln.Text = "码垛方案:";
             //BoardWidth.Value = "0.0";
             //BoardWidth.TitleValue = "栈板宽度:";
@@ -99,6 +106,45 @@ namespace SCADA_DAQ.Customer
             stackParameter.PropertyChanged += StackParameter_PropertyChanged;
         }
 
+        private void Plc_StackFinished(object sender, StackFinishEventArgs e)
+        {
+
+        }
+
+        private void Plc_StackStarted(object sender, StackStartEventArgs e)
+        {
+            Dispatcher.Invoke(() =>
+            {
+                D3_Stack.Clear();
+            });
+        }
+
+        private void Plc_CaptureFinished(object sender, CaputerFinishEventArgs e)
+        {
+            Dispatcher.Invoke(() =>
+            {
+                D3_Stack.Add3DBox(new StackBoxModel()
+                {
+                    BoxHeight = stackParameter.BoxHeight,
+                    BoxLabel = "三倍",
+                    BoxLength = stackParameter.BoxLength,
+                    BoxWidth = stackParameter.BoxWidth,
+                    LabelLocation = stackParameter.LableLocation,
+                    CaptureInfo = e.CurrentCapture
+                    //Width=stackParameter.BoardWidth,
+                    //Height=stackParameter.BoardLength,
+                });
+            });
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        protected override void CloseThis()
+        {
+            base.CloseThis();
+            plc.CaptureFinished -= Plc_CaptureFinished;
+        }
         private void StackParameter_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
         {
             if (e.PropertyName == nameof(stackParameter.SlnName))
@@ -110,7 +156,13 @@ namespace SCADA_DAQ.Customer
                     plc.SetSln(sln);
 
                     var stack = new StackManage();
-                    var layer1 = stack.CreateLayout(null, stackParameter, 32, sln.LayoutId);
+                    var boxSource = new List<StackBoxModel>();
+                    for (int i = 0; i < 32; i++)
+                    {
+                        boxSource.Add(new StackBoxModel());
+                    }
+                    var layer1 = stack.CreateLayout(boxSource, stackParameter, 32, sln.LayoutId);
+                    layer1 = stack.GetBestLayerBoxs(layer1, stackParameter);
                     board1.Init(stackParameter, layer1);
                 }
             }

二進制
SCADA_DAQ/Data/Platform.zip