IOManager.cs
1.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TcpKPIO;
namespace DeviceLibrary.manager
{
public class IOManager
{
static int diCount = 2;
public static void Start(int port=6000)
{
bool rtn = KPIOServer.StartServer(port);
IOLogUtil.info($"开启IO模块:{rtn}");
}
public static bool GetDI(string ip,int idx)
{
return KPIOServer.GetDI(ip, idx)==0?false:true;
}
public static void Stop()
{
KPIOServer.StopServer();
}
public static void WriteDO(string ip,int idx,int value)
{
KPIOServer.WriteDO(ip, idx, value);
}
public static string GetDI(string ip)
{
try
{
return string.Format("DI0={0},DI1={1}",KPIOServer.GetDI(ip,0), KPIOServer.GetDI(ip, 1));
}
catch
{
return "";
}
}
}
}