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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using WIDESEA_Services.IRepositories;
using WIDESEA_Services.Repositories;
using WIDESEA_Services.Services;
using WIDESEA_WCS.WCSClient;
namespace WIDESEA_WCS
{
    public partial class StackerExecutor
    {
        private static int _readRWSignalso = 0;//_readZTBUPSignalso
        /// <summary>
        /// 信号灯控制
        /// </summary>
        /// <param name="client"></param>
        public static void HCJ_XHD(PLCClient client)
        {
            if (Interlocked.Exchange(ref _readRWSignalso, 1) == 0)
            {
                try
                {
                    VOLContext Context = new VOLContext();
                    WebResponseContent responseContent = new WebResponseContent();
                    Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
                    Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
                    List<dt_agvtask> dt_Agvtasks = agvRepository.Find(d => true);
                    WebResponseContent wificontent = new WebResponseContent();
                    if (dt_Agvtasks.Count != 0)
                    {
                        foreach (var item in dt_Agvtasks)
                        {
                            base_ware_location ware_Locations1 = locRepository.FindFirst(d => d.upper_code == item.agv_fromaddress);
                            base_ware_location ware_Locations2 = locRepository.FindFirst(d => d.upper_code == item.agv_toaddress);
                            if (ware_Locations1 != null && ware_Locations2 != null)
                            {
                                Dictionary<string, string> loctionnum = new Dictionary<string, string>();
                                loctionnum.Add("up_Location", ware_Locations1.upper_code.ToString());
                                loctionnum.Add("dw_Location", ware_Locations2.upper_code.ToString());
                                string wificont = WIFIAPIInvoke.Start_XHD1(loctionnum);
                                wificontent = JsonConvert.DeserializeObject<WebResponseContent>(wificont);
                            }
                            else if (ware_Locations1 != null)
                            {
                                Dictionary<string, string> loctionnum = new Dictionary<string, string>();
                                loctionnum.Add("up_Location", ware_Locations1.upper_code.ToString());
                                string wificont = WIFIAPIInvoke.Start_XHD2(loctionnum);
                                wificontent = JsonConvert.DeserializeObject<WebResponseContent>(wificont);
                            }
                            else if (ware_Locations2 != null)
                            {
                                Dictionary<string, string> loctionnum = new Dictionary<string, string>();
                                loctionnum.Add("up_Location", ware_Locations2.upper_code.ToString());
                                string wificont = WIFIAPIInvoke.Start_XHD2(loctionnum);
                                wificontent = JsonConvert.DeserializeObject<WebResponseContent>(wificont);
                            }
 
                        }
                    }
                    List<base_ware_location> base_Ware_Locations = locRepository.Find(d => d.location_state == "LocationState_Stored");
                    if (base_Ware_Locations != null)
                    {
                        foreach (var item in base_Ware_Locations)
                        {
                            if (item.logic_col == 1)
                            {
                                if (item.light_color != "green")
                                {
                                    Dictionary<string, string> loctionnum = new Dictionary<string, string>();
                                    loctionnum.Add("up_Location", item.upper_code.ToString());
                                    string wificont = WIFIAPIInvoke.Start_XHD_LV(loctionnum);
                                    wificontent = JsonConvert.DeserializeObject<WebResponseContent>(wificont);
                                }
                            }
                            else if (item.logic_col == 0)
                            {
                                if (item.light_color != "yellow")
                                {
                                    Dictionary<string, string> loctionnum = new Dictionary<string, string>();
                                    loctionnum.Add("up_Location", item.upper_code.ToString());
                                    string wificont = WIFIAPIInvoke.Start_XHD_Yellow(loctionnum);
                                    wificontent = JsonConvert.DeserializeObject<WebResponseContent>(wificont);
                                }
 
                            }
                        }
                    }
                }
                catch (Exception)
                {
 
                    throw;
                }
                finally
                {
                    Interlocked.Exchange(ref _readRWSignalso, 0);
                }
            }
        }
 
    }
}