IOManage.cs
1.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public class IOManage : IO_Interface
{
IO_Interface iom;
public IOManage(string ip,string iomodule="") {
if (string.IsNullOrWhiteSpace(iomodule))
iom = new KND_IO(ip);
else
iom = new NiRenIO(ip);
iom.DI_Changed_Event += Iom_DI_Changed_Event;
}
private void Iom_DI_Changed_Event(Status[] sta)
{
DI_Changed_Event?.Invoke(sta);
}
/// <summary>
/// 自动读取DI委托
/// </summary>
/// <param name="sta">状态</param>
public delegate void DI_Changed(Status[] sta);
public string IP { get=>iom.IP; set=>iom.IP=value; }
public bool IsConn { get => iom.IsConn;}
public int Port { get => iom.Port; set => iom.Port = value; }
public event DI_Changed DI_Changed_Event;
public void Close()
{
iom.Close();
}
public bool Connect()
{
return iom.Connect();
}
public bool ReadDI(Addr add, out Status sta)
{
return iom.ReadDI(add, out sta);
}
public bool ReadDO(Addr add, out Status sta)
{
return iom.ReadDO(add, out sta);
}
public bool WriteDO(int add, Status sta)
{
return iom.WriteDO(add, sta);
}
}
}