Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ACSingleStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2470f161
由
LN
编写于
2020-05-07 09:12:59 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
ac6deef9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
44 行增加
和
63 行删除
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
查看文件 @
2470f16
...
...
@@ -9,19 +9,17 @@ using OnlineStore.Common;
using
OnlineStore.LoadCSVLibrary
;
using
System.Threading.Tasks
;
using
Asa.IOModule
;
using
System.Collections.Concurrent
;
namespace
OnlineStore.DeviceLibrary
{
public
class
AIOBOXManager
:
IOManager
{
//public static uint DefaultDICount = 16;
//public static uint DefaultDOCount = 16;
{
public
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
Dictionary
<
string
,
AIOBOX
>
AIOMap
=
new
Dictionary
<
string
,
AIOBOX
>();
public
Dictionary
<
string
,
List
<
Box_Sta
>>
DIValueMap
=
new
Dictionary
<
string
,
List
<
Box_Sta
>>();
public
Dictionary
<
string
,
List
<
Box_Sta
>>
DOValueMap
=
new
Dictionary
<
string
,
List
<
Box_Sta
>>();
public
ConcurrentDictionary
<
string
,
List
<
Box_Sta
>>
DIValueMap
=
new
Concurrent
Dictionary
<
string
,
List
<
Box_Sta
>>();
public
ConcurrentDictionary
<
string
,
List
<
Box_Sta
>>
DOValueMap
=
new
Concurrent
Dictionary
<
string
,
List
<
Box_Sta
>>();
private
object
DIMapLock
=
""
;
private
object
DOMapLock
=
""
;
...
...
@@ -87,13 +85,14 @@ namespace OnlineStore.DeviceLibrary
}
AIOMap
.
Remove
(
ioIp
);
}
List
<
Box_Sta
>
list
=
new
List
<
Box_Sta
>();
if
(
DIValueMap
.
ContainsKey
(
ioIp
))
{
DIValueMap
.
Remove
(
ioIp
);
DIValueMap
.
TryRemove
(
ioIp
,
out
list
);
}
if
(
DOValueMap
.
ContainsKey
(
ioIp
))
{
DOValueMap
.
Remove
(
ioIp
);
DOValueMap
.
TryRemove
(
ioIp
,
out
list
);
}
int
DIMS
=
ConfigAppSettings
.
GetIntValue
(
"DIMS"
);
if
(
DIMS
<
20
)
...
...
@@ -220,15 +219,7 @@ namespace OnlineStore.DeviceLibrary
needUpdate
=
true
;
}
else
{
//foreach(Box_Sta s in sta)
//{
// updateDi += s.ToString() + ",";
//}
//if (ip.Equals("192.168.201.61"))
//{
// LogUtil.info(updateDi);
//}
{
for
(
int
i
=
0
;
i
<
newList
.
Count
;
i
++)
{
if
(!(
oldList
[
i
].
Equals
(
newList
[
i
])))
...
...
@@ -240,13 +231,15 @@ namespace OnlineStore.DeviceLibrary
}
if
(
needUpdate
)
{
lock
(
DILock
)
//
lock (DILock)
{
if
(
DIValueMap
.
ContainsKey
(
ip
))
{
DIValueMap
.
Remove
(
ip
);
List
<
Box_Sta
>
s
=
new
List
<
Box_Sta
>();
DIValueMap
.
TryRemove
(
ip
,
out
s
);
}
DIValueMap
.
Add
(
ip
,
newList
);
DIValueMap
.
TryAdd
(
ip
,
newList
);
}
}
}
...
...
@@ -261,12 +254,7 @@ namespace OnlineStore.DeviceLibrary
newList
.
AddRange
(
sta
);
List
<
Box_Sta
>
oldList
=
null
;
DOValueMap
.
TryGetValue
(
ip
,
out
oldList
);
//string result = "UpdateAllDO ip[" + ip + "], sta :";
//for (int i = 0; i < newList.Count; i++)
//{
// result += newList[i] + ",";
//}
//LogUtil.info(result);
if
(
oldList
==
null
||
oldList
.
Count
.
Equals
(
newList
.
Count
).
Equals
(
false
))
{
needUpdate
=
true
;
...
...
@@ -284,27 +272,17 @@ namespace OnlineStore.DeviceLibrary
}
if
(
needUpdate
)
{
lock
(
DOLock
)
//
lock (DOLock)
{
if
(
DOValueMap
.
ContainsKey
(
ip
))
{
DOValueMap
.
Remove
(
ip
);
List
<
Box_Sta
>
list
=
new
List
<
Box_Sta
>();
DOValueMap
.
TryRemove
(
ip
,
out
list
);
}
DOValueMap
.
Add
(
ip
,
newList
);
DOValueMap
.
Try
Add
(
ip
,
newList
);
}
}
}
//else
//{
// if (sta == null)
// {
// LogUtil.error("UpdateAllDO ip[" + ip + "], sta=null");
// }
// else
// {
// LogUtil.error(" UpdateAllDO ip[" + ip + "], sta.Length=" + sta.Length);
// }
//}
}
...
...
@@ -422,7 +400,7 @@ namespace OnlineStore.DeviceLibrary
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"ReadAllDI
出错:"
+
ioIp
);
LogUtil
.
error
(
"ReadAllDI
["
+
ioIp
+
"] 出错:"
+
ex
.
ToString
()
);
}
}
public
override
void
ReadAllDO
(
string
ioIp
,
byte
slaveId
)
...
...
@@ -439,7 +417,7 @@ namespace OnlineStore.DeviceLibrary
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"ReadAllDO
出错:"
+
ioIp
);
LogUtil
.
error
(
"ReadAllDO
["
+
ioIp
+
"] 出错:"
+
ex
.
ToString
()
);
}
}
public
override
IO_VALUE
GetDOValue
(
string
ioIP
,
byte
slaveId
,
ushort
StartAddress
)
...
...
@@ -468,7 +446,7 @@ namespace OnlineStore.DeviceLibrary
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"GetDOValue 出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"GetDOValue
["
+
ioIP
+
"] ["
+
StartAddress
+
"]
出错:"
+
ex
.
ToString
());
}
return
value
;
}
...
...
@@ -476,31 +454,34 @@ namespace OnlineStore.DeviceLibrary
public
override
IO_VALUE
GetDIValue
(
string
ioIP
,
byte
slaveId
,
ushort
StartAddress
)
{
IO_VALUE
value
=
IO_VALUE
.
LOW
;
try
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
AIOBOX
aioBox
=
getAIO
(
ioIP
);
if
(
aioBox
!=
null
)
try
{
Box_Sta
sta
=
Box_Sta
.
Off
;
// Box_Addr addr = GetAddr(StartAddress);
int
index
=
StartAddress
;
if
(
DIValueMap
.
ContainsKey
(
ioIP
)
&&
DIValueMap
[
ioIP
].
Count
>
index
)
AIOBOX
aioBox
=
getAIO
(
ioIP
);
if
(
aioBox
!=
null
)
{
sta
=
DIValueMap
[
ioIP
][
index
];
}
else
{
sta
=
aioBox
.
ReadDI
(
StartAddress
);
}
if
(
sta
.
Equals
(
Box_Sta
.
On
))
{
value
=
IO_VALUE
.
HIGH
;
Box_Sta
sta
=
Box_Sta
.
Off
;
// Box_Addr addr = GetAddr(StartAddress);
int
index
=
StartAddress
;
if
(
DIValueMap
.
ContainsKey
(
ioIP
)
&&
DIValueMap
[
ioIP
].
Count
>
index
)
{
sta
=
DIValueMap
[
ioIP
][
index
];
}
else
{
sta
=
aioBox
.
ReadDI
(
StartAddress
);
}
if
(
sta
.
Equals
(
Box_Sta
.
On
))
{
value
=
IO_VALUE
.
HIGH
;
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"GetDIValue 出错:"
+
ex
.
ToString
());
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"GetDIValue ["
+
ioIP
+
"] ["
+
StartAddress
+
"] ["
+
i
+
"] 出错:"
+
ex
.
ToString
());
}
}
return
value
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论