wangxinhui
2024-11-06 8f392cc88b0768b74efca3b68785cf5aa1c38e70
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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();
            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调度");
 
            Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        WriteLog.GetLog().Write($"开始时间:{DateTime.Now} --------------", $"AGV心跳");
                        if (agvplc != null)
                        {
                            OperateResult W_AGV_XTZZ = agvplc.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true); ;
                        }
                        if (agvplcZ != null)
                        {
                            OperateResult W_AGV_XTZ = agvplcZ.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true);
                        }
                        if (agvplcF != null)
                        {
                            OperateResult W_AGV_XTF = agvplcF.SiemensPLCClient.SiemensS7NetClient.Write("DB1000.306.0", true);
                        }
                        Thread.Sleep(300);
                        WriteLog.GetLog().Write($"结束时间:{DateTime.Now} --------------", $"AGV心跳");
                    }
                    catch (Exception ex)
                    {
                        //throw new Exception(ex.Message);
                    }
                }
            });
 
 
            //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;
            //    }
 
            //});
 
 
        }
    }
}