ServerCommunication_AgvProcess.cs
3.5 KB
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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class ServerCommunication
{
Dictionary<string, string> AgvStatus() {
Dictionary<string, string> status = new Dictionary<string, string>();
status["X16"] = IOManager.GetDIValue("", 0, 16).Equals(IO_VALUE.HIGH) ? "1" : "0";
status["X27"] = IOManager.GetDIValue("", 0, 27).Equals(IO_VALUE.HIGH) ? "1" : "0";
status["X09"] = IOManager.GetDIValue("", 0, 09).Equals(IO_VALUE.HIGH) ? "1" : "0";
status["X10"] = IOManager.GetDIValue("", 0, 10).Equals(IO_VALUE.HIGH) ? "1" : "0";
status["X11"] = IOManager.GetDIValue("", 0, 11).Equals(IO_VALUE.HIGH) ? "1" : "0";
status["X12"] = IOManager.GetDIValue("", 0, 12).Equals(IO_VALUE.HIGH) ? "1" : "0";
status["Y02"] = IOManager.GetDOValue("", 0, 2).Equals(IO_VALUE.HIGH) ? "1" : "0";
return status;
}
private void AgvProcess(Dictionary<string, string> dataMap)
{
bool v;
//紧急料口 1开门 0关门
if (YDataCheck(dataMap, "Y10", out v)|| YDataCheck(dataMap, "Y11", out v))
{
if (v)
RobotManage.mainMachine.SingleDoor.ToHigh(null);
else
RobotManage.mainMachine.SingleDoor.ToLow(null);
}
//折叠门 1开门 0关门
if (YDataCheck(dataMap, "Y15", out v)|| YDataCheck(dataMap, "Y14", out v))
{
if (v)
RobotManage.mainMachine.StringDoorOpen(null);
else
RobotManage.mainMachine.StringDoorClose(null);
}
//滚筒正传
if (YDataCheck(dataMap, "Y08", out v))
{
if (v)
RobotManage.mainMachine.Line.LineRun("remote", false, 999);
else
RobotManage.mainMachine.Line.LineStop("remote");
}
//滚筒反转
if (YDataCheck(dataMap, "Y09", out v))
{
if (v)
RobotManage.mainMachine.Line.LineRun("remote", true, 999);
else
RobotManage.mainMachine.Line.LineStop("remote");
}
}
Dictionary<string, int> LastSingnalSeq = new Dictionary<string, int>();
bool YDataCheck(Dictionary<string, string> dataMap, string key, out bool value) {
value = false;
if (!dataMap.TryGetValue(key, out string v))
return false;
//var vs = v.Split('|');
//if (vs.Length != 2)
// return false;
//if (!int.TryParse(vs[1], out int result))
// return false;
//if (!LastSingnalSeq.ContainsKey(key))
// LastSingnalSeq.Add(key, -1);
//if (LastSingnalSeq[key] == result)
// return false;
//LastSingnalSeq[key] = result;
v = v.Trim().ToLower();
LogUtil.info($"YDataCheck:{key},value:{v}");
if (v == "open")
{
value = true;
return true;
}
else if (v == "close")
{
value = false;
return true;
}
return false;
}
}
}