IOManager.cs
4.0 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
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
127
128
using DeviceLibrary;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary.IO;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace DeviceLibrary
{
using StoreManager = RobotManage;
public class IOManager
{
static I_IOManager instance = null;
static IOManager()
{
instance = new HCIOManager();
}
public static void IOMove(string ioType, IO_VALUE ioValue)
{
if (StoreManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DOList[ioType];
instance.WriteSingleDO(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
//Thread.Sleep(60);
}
else
{
LogUtil.error("没有DO=" + ioType);
}
}
public static IO_VALUE IOValue(string ioType, object o = null)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (StoreManager.Config.DIList.ContainsKey(ioType))
{
if (IO_Type.SafetyLightCurtains.Equals(ioType))
{
if (Setting_Init.Disable_SafetyLightCurtains)
{
return IO_VALUE.HIGH;
}
}
ConfigIO configIo = StoreManager.Config.DIList[ioType];
ioValue = instance.GetDIValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
//UpdateDoValue(ioType, ioValue);
}
else if (StoreManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DOList[ioType];
ioValue = instance.GetDOValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("没有DO=" + ioType);
}
return ioValue;
}
public static IO_VALUE DOValue(string ioType)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (StoreManager.Config.DOList.ContainsKey(ioType))
{
ConfigIO configIo = StoreManager.Config.DOList[ioType];
ioValue = instance.GetDOValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error("没有DO=" + ioType);
}
return ioValue;
}
public static bool ConnectionIOList(List<string> dIODeviceNameList)
{
return instance.ConnectionIOList(dIODeviceNameList);
}
static void ReadAllDI(string deviceName, byte slaveId)
{
instance.ReadAllDI(deviceName, slaveId);
}
static void ReadAllDO(string deviceName, byte slaveId)
{
instance.ReadAllDO(deviceName, slaveId);
}
public static void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value, int time)
{
instance.WriteSingleDO(deviceName, slaveId, index, value, time);
}
public static void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value)
{
instance.WriteSingleDO(deviceName, slaveId, index, value);
}
public static IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v)
{
return instance.GetDIValue(deviceName, slaveID, v);
}
public static IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v)
{
return instance.GetDOValue(deviceName, slaveID, v);
}
public static IO_VALUE GetIOValue(ConfigIO configIO)
{
return instance.GetIOValue(configIO);
}
public static void CloseAllDO()
{
instance.CloseAllDO();
}
public static void CloseAllConnection()
{
instance.CloseAllConnection();
}
}
}