wangxinhui
2024-09-23 a3eb67538c4716aef9967f1e6301720cce095e3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using HslCommunication;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using WIDESEA_Common.Tools;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Services.IRepositories;
using WIDESEA_Services.Repositories;
using WIDESEA_WCS.WCSClient;
 
namespace WIDESEA_WCS.SchedulerExecute.AGV
{
    public partial class AGVSchedulerExecute
    {
        /// <summary>
        /// 传递AGV与负极SB动作流对接信号
        /// </summary>
        public static void AgvAndEquiWorkFJ()
        {
           // Console.WriteLine($"心跳调度JOP:开始时间:{DateTime.Now}");
            VOLContext Context = new VOLContext();
            Idt_plcinfodetailRepository plcdetailRep = new dt_plcinfodetailRepository(Context);
            Idt_plcinfoheadRepository plcheadRep = new dt_plcinfoheadRepository(Context);
            PLCClient agvplcZ = WCSService.Clients.Find(v => v.PLCName == "正极AGV调度");
            PLCClient agvplcF = WCSService.Clients.Find(v => v.PLCName == "负极AGV调度");
            PLCClient agvplc = WCSService.Clients.Find(v => v.PLCName == "组装AGV调度");
            List<Task> taskList = new List<Task>();
            var tokenSource = new CancellationTokenSource();
            //var token = tokenSource.Token;
            Task.Run(() =>
            {
                try
                {
                    if (WCSService.Clients == null || agvplc == null)
                    {
                        return;
                    }
                    OperateResult W_AGV_XTZZ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true);
                   // Console.WriteLine($"组装AGV调度:[{W_AGV_XTZZ.IsSuccess}],时间:{DateTime.Now}");
                    if (!W_AGV_XTZZ.IsSuccess)
                    {
                        return;
                    }
 
                }
                catch (Exception)
                {
 
                    throw;
                }
            });
            Task.Run(() =>
            {
                try
                {
                    if (WCSService.Clients == null || agvplcZ == null)
                    {
                        return;
                    }
                    OperateResult W_AGV_XTZ = agvplcZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true);
                  //  Console.WriteLine($"正极AGV调度:[{W_AGV_XTZ.IsSuccess}],时间:{DateTime.Now}");
                    if (!W_AGV_XTZ.IsSuccess)
                    {
                        return;
                    }
                }
                catch (Exception)
                {
 
                    throw;
                }
            });
            Task.Run(() =>
            {
                try
                {
                    if (WCSService.Clients == null || agvplcF == null)
                    {
                        return;
                    }
                    OperateResult W_AGV_XTF = agvplcF.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true);
                    //Console.WriteLine($"负极AGV调度:[{W_AGV_XTF.IsSuccess}],时间:{DateTime.Now}");
                    if (!W_AGV_XTF.IsSuccess)
                    {
                        return;
                    }
                }
                catch (Exception)
                {
 
                    throw;
                }
 
            });
 
 
        }
    }
}