CylinderManger.cs
2.7 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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class CylinderManger : ISafetyDevice
{
string High;
string Low;
string Name;
IO_VALUE currentIOvalue = IO_VALUE.None;
public CylinderManger(string name,string high,string low) {
High = high;
Low = low;
Name = name;
SafetyDevice.AddDevice(this);
}
public bool IsHigh() {
return IOManager.IOValue(High).Equals(IO_VALUE.HIGH);
}
public bool IsLow()
{
return IOManager.IOValue(Low).Equals(IO_VALUE.HIGH);
}
public void ToHigh(MoveInfo moveInfo) {
currentIOvalue = IO_VALUE.HIGH;
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.HIGH));
}
Resume();
LogUtil.info($"{Name},设置{High}=High");
}
public void ToLow(MoveInfo moveInfo)
{
currentIOvalue = IO_VALUE.LOW;
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.LOW));
}
Resume();
LogUtil.info($"{Name},设置{High}=Low");
}
public void Pause()
{
LogUtil.info($"{Name},停止运行");
if (currentIOvalue == IO_VALUE.None) {
LogUtil.info($"{Name},没有在运行");
return;
}
else if (currentIOvalue == IO_VALUE.HIGH && IOManager.IOValue(High).Equals(IO_VALUE.HIGH))
{
LogUtil.info($"{Name},currentIOvalue:{currentIOvalue},暂停是IO已到位");
return;
}else if (currentIOvalue == IO_VALUE.LOW && IOManager.IOValue(Low).Equals(IO_VALUE.HIGH))
{
LogUtil.info($"{Name},currentIOvalue:{currentIOvalue},暂停是IO已到位");
return;
}
IOManager.IOMove(Low, IO_VALUE.LOW);
IOManager.IOMove(High, IO_VALUE.LOW);
}
public void Resume()
{
if (currentIOvalue == IO_VALUE.None)
return;
IOManager.IOMove(Low, currentIOvalue == IO_VALUE.LOW ? IO_VALUE.HIGH : IO_VALUE.LOW);
IOManager.IOMove(High, currentIOvalue == IO_VALUE.HIGH ? IO_VALUE.HIGH : IO_VALUE.LOW);
LogUtil.info($"{Name},恢复运行");
}
}
}