AIOAIManager.cs
1.8 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
using Asa.IOModule;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class AIOAIManager:AIManager
{
private object AILock = "";
private int AILength = 4;
private Asa.IOModule.AIOBOX AiBox = null;
public override void StartConnect(params string[] ipList)
{
foreach (string ip in ipList)
{
bool result = ConnectionIP(ip);
}
}
private bool ConnectionIP(string ioIp)
{
int autoMS = 150;
try
{
AiBox = new Asa.IOModule.AIOBOX();
AiBox.IP = ioIp;
AiBox.SetType(Asa.IOModule.Box_Type.AI, AILength, Box_Type.AO, 0);
LogUtil.debug("开始连接AI模块[" + ioIp + "][" + autoMS + "],尝试重连三次");
bool result = AiBox.Connect();
}
catch (Exception error)
{
LogUtil.error("连接IO模块[" + ioIp + "][" + autoMS + "]出错:" + error.ToString());
}
return false;
}
public override void CloseConnect()
{
try
{
if (AiBox != null)
{
AiBox.Close();
}
}
catch (Exception ex)
{
LogUtil.error("断开AI连接出错:" + ex.ToString());
}
}
public override double GetAIValue(string ioiP, int index)
{
if (AiBox != null)
{
return AiBox.ReadAI(index);
}
return -1;
}
}
}