分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-01-31 50fd5cc9cfad08714c4daa6d481c5293ff2ae6b1
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/Jobs/equipment/PipelineJob.cs
@@ -4,7 +4,15 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Comm;
using WIDESEA_Core.BaseProvider;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.FreeDB;
using WIDESEA_WCS.IRepositories;
using WIDESEA_WCS.Jobs;
using WIDESEA_WCS.Repositories;
using WIDESEA_WCS.WCSClient;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WCS
{
@@ -12,7 +20,7 @@
    /// é“¾æ¡æœº
    /// </summary>
    [DisallowConcurrentExecution]
    public class PipelineJob : IJob
    public class PipelineJob : JobBase, IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
@@ -31,15 +39,83 @@
                    return Task.CompletedTask;
                }
                DoAction(client);
                //DoAction(client);
                ExecuteJob(context, DoAction);
            }
            catch { }
            return Task.CompletedTask;
        }
        private void DoAction(PLCClient client)
        private void DoAction(IJobExecutionContext context)
        {
            throw new NotImplementedException();
            var client = context.JobDetail.JobDataMap.Get("JobParams") as PLCClient;
            //自动重连
            if (!client.IsConnected)
            {
                client.Connect();
                return;
            }
            Loadinglevel(client);
        }
        /// <summary>
        /// ä¸Šæ–™åŒº
        /// </summary>
        /// <param name="client"></param>
        private void Loadinglevel(PLCClient client, string number = "上料区")
        {
            VOLContext Context = new VOLContext();
            Idt_plcinfoheadRepository repository = new dt_plcinfoheadRepository(Context);
            Idt_plcinfodetailRepository plcRepository = new dt_plcinfodetailRepository(Context);
            Idt_geometry_dataRepository dataRepository = new dt_geometry_dataRepository(Context);
            Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context);
            var plc = repository.FindFirst(x => x.plcinfo_name == client.PLCName);
            var Gantry_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "桁架");
            if (!Gantry_client.IsConnected) return;
            var Gantryplc = repository.FindFirst(x => x.plcinfo_name == Gantry_client.PLCName);
            List<string> names = new List<string>() { "S01001001", "S01001002" };
            foreach (string name in names)
            {
                var station = stationinfoRepository.FindFirst(x => x.stationCode == name && x.enable && x.location_state == LocationStateEnum.Stroge.ToString());
                if (station == null)
                {
                    Gantry_client.WriteByOrder("W_RequestUnload", false, number);//信号为false桁架停止进入
                    continue;
                }
                var details = plcRepository.Find(x => x.plcdetail_iotype == plc.plcinfo_iotyep && x.plcdetail_number == name).ToList();
                var PalletSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_PalletSignal").First(), client);//读取托盘信号:1:有,2无
                var MaterialSignal = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "R_MaterialSignal").First(), client);//读取货物信号:1:有,2无
                if (PalletSignal == 1 && MaterialSignal == 1)
                {
                    Gantry_client.WriteByOrder("W_AreaNr", (Int16)1, number);//区域货位号
                    Gantry_client.WriteByOrder("W_IndexNr", (Int16)1, number);//托盘上的第几个车轮
                    Gantry_client.WriteByOrder("W_Storage_Type", (Int16)1, number); //托盘类型1-横放;2-竖放
                    Gantry_client.WriteByOrder("W_Wheel_Type", (Int16)1, number);//车轮类型
                    Gantry_client.WriteByOrder("W_Wheel_id", "", number);//车轮SN号
                    Gantry_client.WriteByOrder("W_RequestUnload", true, number);
                }
                else
                {
                    Gantry_client.WriteByOrder("W_RequestUnload", false, number);
                }
                var Gantrydetails = plcRepository.Find(x => x.plcdetail_iotype == Gantryplc.plcinfo_iotyep && x.plcdetail_number == number).ToList();
                var Gantry_Out_of_Area = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Gantry_Out_of_Area").First(), Gantry_client);//桁架是否在区域内
                var QueryDate = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_QueryDate").First(), Gantry_client);//信息查询
                if (QueryDate)
                {
                    var Date_Vaild = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Date_Vaild").First(), Gantry_client);//信息确认
                    if (!Date_Vaild)//信息有误,记录日志
                    {
                    }
                }
                var finished = (bool)DBExtension.Read(Gantrydetails.Where(x => x.plcdetail_name == "R_Unlod_finished").First(), Gantry_client);//夹取完成
                if (finished)
                {
                    Gantry_client.WriteByOrder("W_Storage_update", true, number);//货位状态更新
                }
            }
        }
    }
}