Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e8bad718
由
LN
编写于
2021-06-28 14:07:28 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
IOdll更新为佳世达四楼用的版本。
1 个父辈
ba23a99d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
16 行增加
和
109 行删除
dll/Asa.IOModule.AIOBOX.dll
dll/Asa.IOModule.AIOBOX.xml
source/DeviceLibrary/IO/AIOBOX/AIOAIManager.cs
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
dll/Asa.IOModule.AIOBOX.dll
查看文件 @
e8bad71
此文件类型无法预览
dll/Asa.IOModule.AIOBOX.xml
查看文件 @
e8bad71
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/IO/AIOBOX/AIOAIManager.cs
查看文件 @
e8bad71
...
...
@@ -11,99 +11,40 @@ namespace OnlineStore.DeviceLibrary
{
public
class
AIOAIManager
:
AIManager
{
private
object
AILock
=
""
;
private
List
<
int
>
AIValList
=
null
;
private
object
AILock
=
""
;
private
int
AILength
=
4
;
private
Asa
.
IOModule
.
AIOBOX
AIBox
=
null
;
private
System
.
Timers
.
Timer
conTimer
=
null
;
private
List
<
string
>
needConIp
=
new
List
<
string
>();
private
Asa
.
IOModule
.
AIOBOX
AiBox
=
null
;
public
override
void
StartConnect
(
params
string
[]
ipList
)
{
if
(
conTimer
==
null
)
{
conTimer
=
new
System
.
Timers
.
Timer
();
conTimer
.
AutoReset
=
true
;
conTimer
.
Interval
=
60000
;
conTimer
.
Elapsed
+=
ConTimer_Elapsed
;
}
conTimer
.
Enabled
=
false
;
needConIp
=
new
List
<
string
>(
ipList
);
{
foreach
(
string
ip
in
ipList
)
{
bool
result
=
ConnectionIP
(
ip
);
}
if
(
needConIp
.
Count
>
0
)
{
//启动定时器,1一分钟重连一次
conTimer
.
Start
();
}
}
}
private
bool
ConnectionIP
(
string
ioIp
)
private
bool
ConnectionIP
(
string
ioIp
)
{
int
autoMS
=
150
;
try
{
AIValList
=
new
List
<
int
>();
AIBox
=
new
Asa
.
IOModule
.
AIOBOX
();
AIBox
.
IP
=
ioIp
;
// bool rtn = AIBox.AutoIP(ioIp);
AIBox
.
SetInput
(
Asa
.
IOModule
.
Box_Type
.
AI
,
AILength
);
AIBox
.
SetOutput
(
Asa
.
IOModule
.
Box_Type
.
DO
,
0
);
AIBox
.
AutoReadInput
(
true
,
autoMS
);
AIBox
.
AI_Changed_Event
+=
Box_AI_Changed_Event
;
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
+
"],尝试重连三次"
);
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
bool
result
=
AIBox
.
Connect
();
if
(
result
)
{
if
(
needConIp
.
Contains
(
ioIp
))
{
needConIp
.
Remove
(
ioIp
);
}
LogUtil
.
info
(
"第【"
+
i
+
"】次连接IO模块["
+
ioIp
+
"]["
+
autoMS
+
"]成功:"
+
AIBox
.
ErrInfo
);
return
true
;
}
else
{
LogUtil
.
error
(
"第【"
+
i
+
"】次连接IO模块["
+
ioIp
+
"]["
+
autoMS
+
"]失败:"
+
AIBox
.
ErrInfo
+
""
);
}
Thread
.
Sleep
(
10
);
}
bool
result
=
AiBox
.
Connect
();
}
catch
(
Exception
error
)
{
LogUtil
.
error
(
"连接IO模块["
+
ioIp
+
"]["
+
autoMS
+
"]出错:"
+
error
.
ToString
());
}
return
false
;
}
private
void
ConTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
try
{
List
<
string
>
list
=
new
List
<
string
>(
needConIp
);
if
(
list
.
Count
>
0
)
{
foreach
(
string
ip
in
list
)
{
LogUtil
.
info
(
"重连AOI AI 模块 :"
+
ip
);
ConnectionIP
(
ip
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"AOI AI ConTimer_Elapsed 出错: "
+
ex
.
ToString
());
}
}
}
public
override
void
CloseConnect
()
{
try
{
if
(
A
I
Box
!=
null
)
if
(
A
i
Box
!=
null
)
{
A
I
Box
.
Close
();
A
i
Box
.
Close
();
}
}
catch
(
Exception
ex
)
...
...
@@ -112,49 +53,15 @@ namespace OnlineStore.DeviceLibrary
}
}
private
void
Box_AI_Changed_Event
(
AIOBOX
box
,
int
[]
val
)
{
try
{
if
(
val
!=
null
&&
val
.
Length
>=
AILength
)
{
lock
(
AILock
)
{
AIValList
=
new
List
<
int
>();
AIValList
.
AddRange
(
val
);
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"Box_AI_Changed_Event出错:"
+
ex
.
ToString
());
}
}
public
override
double
GetAIValue
(
string
ioiP
,
int
index
)
{
for
(
int
i
=
1
;
i
<=
3
;
i
++
)
if
(
AiBox
!=
null
)
{
try
{
if
(
AIValList
!=
null
&&
index
>=
0
&&
AIValList
.
Count
>
index
)
{
return
AIValList
[
index
];
}
}
catch
(
Exception
ex
)
{
if
(
i
>
1
)
{
LogUtil
.
error
(
"GetAIValue第【"
+
i
+
"】次获取 "
+
ioiP
+
"_"
+
index
+
"出错:"
+
ex
.
ToString
());
}
}
Thread
.
Sleep
(
1
);
return
AiBox
.
ReadAI
(
index
);
}
return
0
;
return
-
1
;
}
}
}
}
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
查看文件 @
e8bad71
此文件的差异被折叠,
点击展开。
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论