Explorar el Código

开料分拣更换放板旋转方向,增加获取开料机的状态显示

陈子杰 hace 3 meses
padre
commit
2c5736146e

+ 15 - 9
SCADA_DAQ/Customer/Machines/SortMachine.cs

@@ -36,7 +36,7 @@ namespace SCADA_DAQ.Customer.Machines
     {
         private SampleBarcodeReader _barcodeReader;
 
-        private SyntecRemoteCNC CuttingMac { get; set; } = null;
+        public SyntecRemoteCNC CuttingMac { get; set; } = null;
         /// <summary>
         /// 
         /// </summary>
@@ -240,9 +240,10 @@ namespace SCADA_DAQ.Customer.Machines
                     {
                         if (CuttingMac.isConnected())
                         {
-                            var ncName = new int[40];
+                            var ncName = new int[41];
                             CuttingMac.READ_plc_register(7200, 7240, out ncName);
                             var path = CycFilePath(ncName);
+                            CuttingMac.WRITE_plc_register(7200, 7240, new int[41]);
                             if (path != null)
                             {
                                 _Lbls = GetLabes(path);
@@ -340,7 +341,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 {
                                     var cup1NewCenter = new Point(Cup1Center.X, Cup1Center.Y);  //旋转后的坐标
                                     BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup1NewCenter.X, BoardInfo.CupCenter.Y - cup1NewCenter.Y);
-                                    BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
+                                    BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 30;
                                     CupNewCenter = cup1NewCenter;
                                     //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 170;
                                 }
@@ -384,7 +385,7 @@ namespace SCADA_DAQ.Customer.Machines
                                 var cup3NewCenter = new Point(Cup3Center.X, (double)Cup3Center.Y);  //旋转后的坐标
                                 BoardInfo.CupCenter = new Point(BoardInfo.CupCenter.X - cup3NewCenter.X, BoardInfo.CupCenter.Y - cup3NewCenter.Y);
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 + 500;
-                                BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 30;
+                                BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 180;
                                 CupNewCenter = cup3NewCenter;
 
                                 //BoardInfo.ReleaseY = CurrentLabel.ActualWidth / 2 - 20;
@@ -490,13 +491,18 @@ namespace SCADA_DAQ.Customer.Machines
                         Log.Info($"开始处理,{CurrentLabel.ID}");
                         
                         var rotation = BoardInfo.Rotation;
-                        var releaseRotation = rotation == -90 ? -90 : 90;
+                        var releaseRotation = rotation  == 0 ? -90  : rotation;
+                        
                         var releaseXOffset = 0f;
                         if (BoardInfo.CupIndex != 2)
                         {
                             releaseXOffset = releaseRotation == 90 ? -155f : 155f;
 
                         }
+                        //else
+                        //{
+                        //    releaseRotation = -90;
+                        //}
                         BoardInfo.ReleaseY = Math.Max(10, BoardInfo.ReleaseY);
                         rotation += _lbl.R;
 
@@ -530,10 +536,10 @@ namespace SCADA_DAQ.Customer.Machines
                             {
                                 GetListenReg(Tag_AAutoSpeed).WriteReg(CustomerEnv.SortingMacConfigValue.AxisAAutoLowSpeed);
                             }
-                            if (Math.Max(CurrentLabel.ActualLength, CurrentLabel.ActualWidth) >= 2400)
-                            {
-                                releaseXOffset -= 200;
-                            }
+                            //if (Math.Max(CurrentLabel.ActualLength, CurrentLabel.ActualWidth) >= 2300)
+                            //{
+                            //    releaseXOffset -= 200;
+                            //}
                             GetListenReg(Tag_CaptureX).WriteObject(null,
                             moveX + (float)xOffset,  //D1512
                             moveY + (float)yOffset,  //D1514

+ 140 - 0
SCADA_DAQ/Customer/Models/SortingModel/CuttingMacInfo.cs

@@ -0,0 +1,140 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models.SortingModel
+{
+    public class CuttingMacInfo :ObservableObject
+    {
+
+        /// <summary>
+        /// 主程式档案
+        /// </summary>
+        public string MainProg
+        {
+            get { return _MainProg; }
+            set
+            {
+                if (value != _MainProg)
+                {
+                    _MainProg = value;
+                    OnPropertyChanged(nameof(MainProg));
+                }
+            }
+        }
+        private string _MainProg;
+
+
+        /// <summary>
+        /// 目前执行档案
+        /// </summary>
+        public string CurProg
+        {
+            get { return _CurProg; }
+            set
+            {
+                if (value != _CurProg)
+                {
+                    _CurProg = value;
+                    OnPropertyChanged(nameof(CurProg));
+                }
+            }
+        }
+        private string _CurProg;
+
+
+        /// <summary>
+        /// 当成程序行数
+        /// </summary>
+        public int CurSeq
+        {
+            get { return _CurSeq; }
+            set
+            {
+                if (value != _CurSeq)
+                {
+                    _CurSeq = value;
+                    OnPropertyChanged(nameof(CurSeq));
+                }
+            }
+        }
+        private int _CurSeq;
+
+
+
+        /// <summary>
+        /// 模式
+        /// </summary>
+        public string Mode
+        {
+            get { return _Mode; }
+            set
+            {
+                if (value != _Mode)
+                {
+                    _Mode = value;
+                    OnPropertyChanged(nameof(Mode));
+                }
+            }
+        }
+        private string _Mode;
+
+
+        /// <summary>
+        /// 状态
+        /// </summary>
+        public string Status
+        {
+            get { return _Status; }
+            set
+            {
+                if (value != _Status)
+                {
+                    _Status = value;
+                    OnPropertyChanged(nameof(Status));
+                }
+            }
+        }
+        private string _Status;
+
+
+        /// <summary>
+        /// 警告
+        /// </summary>
+        public string Alarm
+        {
+            get { return _Alarm; }
+            set
+            {
+                if (value != _Alarm)
+                {
+                    _Alarm = value;
+                    OnPropertyChanged(nameof(Alarm));
+                }
+            }
+        }
+        private string _Alarm;
+
+
+        /// <summary>
+        /// 紧急停止
+        /// </summary>
+        public string EmergencyStop
+        {
+            get { return _EmergencyStop; }
+            set
+            {
+                if (value != _EmergencyStop)
+                {
+                    _EmergencyStop = value;
+                    OnPropertyChanged(nameof(EmergencyStop));
+                }
+            }
+        }
+        private string _EmergencyStop;
+
+    }
+}

+ 2 - 2
SCADA_DAQ/Customer/Service/ScannerService.cs

@@ -109,8 +109,8 @@ namespace SCADA_DAQ.Customer.Service
             var barcode = e.Barcode;
             Plc1.GetListenReg(SortingDeliveryMachine.Tag_CodeMatch).WriteReg(0);
 
-            //var barcodeTask = BoardTasks.Where(t => t.BoardID == barcode).FirstOrDefault();
-            var barcodeTask = Env.DAL.App_Hold_BoardInfo.GetData<BoardTaskModel>(t=>t.BoardID == barcode).FirstOrDefault();
+            var barcodeTask = BoardTasks.Where(t => t.BoardID == barcode).FirstOrDefault();
+            //var barcodeTask = Env.DAL.App_Hold_BoardInfo.GetData<BoardTaskModel>(t=>t.BoardID == barcode).FirstOrDefault();
             var api = new WebApiHelper(_ScannerServiceConfig.Url);
             if (barcode != "NoRead" && barcodeTask != null)
             {

+ 194 - 0
SCADA_DAQ/Customer/Service/SortingService.cs

@@ -0,0 +1,194 @@
+using SCADA.CommonLib;
+using SCADA.CommonLib.Service;
+using SCADA_DAQ.Customer.Machines;
+using SCADA_DAQ.Customer.Models;
+using SCADA_DAQ.Customer.Models.SortingModel;
+using SCADA_DAQ.Plugin.Machine;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+
+namespace SCADA_DAQ.Customer.Service
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    [DisplayName("开料分拣服务")]
+    public class SortingService : BaseService
+    {
+        private static SortingService _instance;
+        private SortingServiceConfig _SortingServiceConfig;
+        /// <summary>
+        /// 
+        /// </summary>
+        public override ObservableObject ServiceConfig
+        {
+            get => _SortingServiceConfig;
+            set { _SortingServiceConfig = (SortingServiceConfig)value; }
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public static SortingService Instance { get => _instance ?? (_instance = new SortingService()); }
+
+        private SortMachine plc = MachineServer.GetInstance().GetMachine<SortMachine>("分拣机");
+        
+        /// <summary>
+        /// 开料机信息
+        /// </summary>
+        public CuttingMacInfo CuttingMacState
+        {
+            get { return _CuttingMacState; }
+            set
+            {
+                if (value != _CuttingMacState)
+                {
+                    _CuttingMacState = value;
+                    OnPropertyChanged(nameof(CuttingMacState));
+                }
+            }
+        }
+        private CuttingMacInfo _CuttingMacState = new CuttingMacInfo();
+
+
+
+        /// <summary>
+        /// 开料机运行状态
+        /// </summary>
+        public State CuttingMacRunState
+        {
+            get { return _CuttingMacRunState; }
+            set
+            {
+                if (value != _CuttingMacRunState)
+                {
+                    _CuttingMacRunState = value;
+                    OnPropertyChanged(nameof(CuttingMacRunState));
+                }
+            }
+        }
+        private State _CuttingMacRunState;
+
+
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public override Type ConfigType => typeof(SortingServiceConfig);
+
+
+        private SortingService()
+        {
+            if (_instance == null)
+            {
+                _instance = this;
+            }
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <returns></returns>
+        public override bool Start()
+        {
+            if (IsRunning) { return false; }
+            RpcService.GetInstance().Regiseter(this);   //将服务中方法注册到RPC服务器,可以给WebApi调用
+            Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
+            return base.Start();
+        }
+
+        private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
+        {
+            if (e.ChangeType.HasFlag(DateTimeChangeType.SecondChanged))
+            {
+                string mainProg;
+                string curProg;
+                int curSeq;
+                string mode;
+                string status;
+                string alarm;
+                string emg;
+                if (plc.CuttingMac.isConnected())
+                {
+                    plc.CuttingMac.READ_status(
+                        out mainProg, out curProg, out curSeq, out mode, out status, out alarm, out emg);
+                    CuttingMacState.MainProg = mainProg;
+                    CuttingMacState.CurProg = curProg;
+                    CuttingMacState.CurSeq = curSeq;
+                    CuttingMacState.Mode = mode;
+                    CuttingMacState.Status = status;
+                    CuttingMacState.Alarm = alarm;
+                    CuttingMacState.EmergencyStop = emg;
+                    if (alarm == "ALARM")
+                    {
+                        CuttingMacRunState = State.Alarm;
+                    }
+                    else if (status == "START")
+                    {
+                        CuttingMacRunState = State.Stop;
+
+                    }
+                    else
+                    {
+                        CuttingMacRunState = State.Stop;
+                    }
+                }
+            }
+        }
+
+
+
+        /// <summary>
+        /// PDA扫码获取产品信息
+        /// </summary>
+        /// <param name="barcode"></param>
+        /// <returns></returns>
+        public object GetData(string barcode)
+        {
+            return new object();
+        }
+
+        /// <summary>
+        /// PDA提交产品信息
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public bool SubmitData(object model)
+        {
+            return true;
+        }
+
+        /// <summary>
+        /// PDA查询历史提交记录
+        /// </summary>
+        /// <param name="count">要获取的数量</param>
+        /// <param name="skip">跳过的数量</param>
+        /// <param name="filter">过滤条件</param>
+        /// <returns></returns>
+        public object GetHistoryData(int count, int skip, string filter)
+        {
+            return null;
+        }
+
+        public override bool Stop()
+        {
+            Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged;
+            return base.Stop();
+        }
+
+    }
+
+    public enum State
+    {
+        [EnumDisplay("运行")]
+        Run,
+        [EnumDisplay("停止")]
+        Stop,
+        [EnumDisplay("报警")]
+        Alarm
+    }
+}

+ 17 - 0
SCADA_DAQ/Customer/Service/SortingServiceConfig.cs

@@ -0,0 +1,17 @@
+using SCADA.CommonLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Service
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class SortingServiceConfig : ObservableObject
+    {
+
+    }
+}

+ 11 - 3
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml

@@ -10,9 +10,11 @@
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid>
         <Grid.RowDefinitions>
+            
             <RowDefinition Height="1*"/>
             <RowDefinition Height="400"/>
             <RowDefinition Height="auto"/>
+            <RowDefinition Height="auto"/>
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="1200"/>
@@ -33,8 +35,12 @@
                 <RowDefinition Height="1.2*"/>
                 <RowDefinition/>
             </Grid.RowDefinitions>
-            <ucrsorting:UctCurrentPosition x:Name="CurrentPos"/>
-            <GroupBox Header="自动参数设置" Grid.Row="1" Grid.Column="1" Margin="5" >
+            <!--<Grid.ColumnDefinitions>
+                <ColumnDefinition Width="1.8*"/>
+                <ColumnDefinition/>
+            </Grid.ColumnDefinitions>-->
+            <ucrsorting:UctCurrentPosition x:Name="CurrentPos" />
+            <GroupBox Header="自动参数设置" Grid.Row="1"  Margin="5" Grid.ColumnSpan="2">
                 <WrapPanel x:Name="AutoSettingPanel" HorizontalAlignment="Center"/>
             </GroupBox>
         </Grid>
@@ -204,7 +210,9 @@
               
             </GroupBox>
         </Grid>
-        <uct:UctAlarmBar Grid.Row="2" x:Name="AlarmRoller" Grid.ColumnSpan="2"/>
+        <ucrsorting:UctCuttingMacState Grid.Row="2" Grid.ColumnSpan="2"/>
+
+        <uct:UctAlarmBar Grid.Row="3" x:Name="AlarmRoller" Grid.ColumnSpan="2"/>
 
     </Grid>
 </wpfcontrol:BaseUctFrm>

+ 1 - 0
SCADA_DAQ/Customer/Views/Menu/UctFrmSorting/UctFrmSortingMain.xaml.cs

@@ -69,6 +69,7 @@ namespace SCADA_DAQ.Customer.Views.Menu.UctFrmSorting
                 SortMachine.Tag_YAutoSpeed,
                 SortMachine.Tag_ZAutoSpeed,
                 SortMachine.Tag_Y1AutoSpeed,
+                SortMachine.Tag_Thickness,
                 //SortMachine.Tag_AAutoSpeed,
             };
             for (int i = 0; i < autoSetting.Length; i++)

+ 26 - 0
SCADA_DAQ/Customer/Views/Uct/UcrSorting/UctCuttingMacState.xaml

@@ -0,0 +1,26 @@
+<wpfcontrol:BaseUserControl  xmlns:wpfcontrol="clr-namespace:SCADA.CommonCtrl.WpfControl;assembly=SCADA.CommonCtrl"
+                             x:Class="SCADA_DAQ.Customer.Views.Uct.UcrSorting.UctCuttingMacState"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:SCADA_DAQ.Customer.Views.Uct.UcrSorting"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
+        <StackPanel.Resources>
+            <Style TargetType="TextBlock">
+                <Setter Property="FontWeight" Value="Bold"/>
+                <Setter Property="Margin" Value="10,0,0,0"/>
+            </Style>
+        </StackPanel.Resources>
+        <TextBlock Text="{Binding MainProg,StringFormat=MainProg:{0}}"/>
+        <TextBlock Text="{Binding CurProg,StringFormat=CurProg:{0}}"/>
+        <TextBlock Text="{Binding CurSeq,StringFormat=CurSeq:{0}}"/>
+        <TextBlock Text="{Binding Mode,StringFormat=Mode:{0}}"/>
+        <TextBlock Text="{Binding Status,StringFormat=Status:{0}}"/>
+        <TextBlock Text="{Binding Alarm,StringFormat=Alarm:{0}}"/>
+        <TextBlock Text="{Binding EmergencyStop,StringFormat=Emg:{0}}"/>
+
+    </StackPanel>
+</wpfcontrol:BaseUserControl>

+ 31 - 0
SCADA_DAQ/Customer/Views/Uct/UcrSorting/UctCuttingMacState.xaml.cs

@@ -0,0 +1,31 @@
+using SCADA.CommonCtrl.WpfControl;
+using SCADA_DAQ.Customer.Service;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace SCADA_DAQ.Customer.Views.Uct.UcrSorting
+{
+    /// <summary>
+    /// UctCuttingMacState.xaml 的交互逻辑
+    /// </summary>
+    public partial class UctCuttingMacState : BaseUserControl
+    {
+        public UctCuttingMacState()
+        {
+            InitializeComponent();
+            DataContext = SortingService.Instance.CuttingMacState;
+        }
+    }
+}

+ 6 - 0
SCADA_DAQ/SCADA_DAQ.csproj.user

@@ -50,6 +50,9 @@
     <Compile Update="Customer\Views\Uct\UcrSorting\UctCurrentPosition.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Update="Customer\Views\Uct\UcrSorting\UctCuttingMacState.xaml.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Update="Customer\Views\Uct\UcrSorting\UctShowItem.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -133,6 +136,9 @@
     <Page Update="Customer\Views\Uct\UcrSorting\UctCurrentPosition.xaml">
       <SubType>Designer</SubType>
     </Page>
+    <Page Update="Customer\Views\Uct\UcrSorting\UctCuttingMacState.xaml">
+      <SubType>Designer</SubType>
+    </Page>
     <Page Update="Customer\Views\Uct\UcrSorting\UctShowItem.xaml">
       <SubType>Designer</SubType>
     </Page>