Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
SO815-AutoInOutStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 7b083fb1
由
gujlg
编写于
2019-05-16 15:08:11 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改IO
1 个父辈
d469e222
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
60 行增加
和
19 行删除
source/DeviceLibrary/DeviceLibrary/IO/AIOBOX/BLL.cs
source/DeviceLibrary/DeviceLibrary/IO/AIOBOX/BLL.cs
查看文件 @
7b083fb
...
...
@@ -34,7 +34,8 @@ namespace Asa.IOModule
private
int
_readDOSleep
;
//自动读取DO间隔
private
List
<
string
>
_log
;
//日志
private
List
<
string
>
_logRxTx
;
//日志
private
List
<
byte
[
]>
_send
;
//发送的命令
//private List<byte[]> _send; //发送的命令
private
System
.
Collections
.
Concurrent
.
ConcurrentQueue
<
byte
[
]>
_send
;
private
List
<
byte
[
]>
_receive
;
//接收的数据
private
Thread
tSend
;
//发送命令处理
...
...
@@ -117,7 +118,8 @@ namespace Asa.IOModule
_sta
=
new
Box_Sta
[
32
];
_log
=
new
List
<
string
>();
_logRxTx
=
new
List
<
string
>();
_send
=
new
List
<
byte
[
]>
();
//_send = new List<byte[]>();
_send
=
new
System
.
Collections
.
Concurrent
.
ConcurrentQueue
<
byte
[
]>
();
_receive
=
new
List
<
byte
[
]>
();
Type
=
Box_Type
.
DIO_32
;
...
...
@@ -288,7 +290,10 @@ namespace Asa.IOModule
_unrevd
=
0
;
_unrevdRemote
=
0
;
_flag
=
0
;
_send
.
Clear
();
//_send.Clear();
while
(
_send
.
TryDequeue
(
out
byte
[]
aa
))
{
}
_receive
.
Clear
();
_log
.
Clear
();
_logRxTx
.
Clear
();
...
...
@@ -482,7 +487,9 @@ namespace Asa.IOModule
_log
.
Add
(
s
);
}
_send
.
Add
(
buff
);
//_send.Add(buff);
_send
.
Enqueue
(
buff
);
if
(
_unrevdRemote
==
0
)
ErrInfo
=
"OK"
;
return
true
;
}
...
...
@@ -524,24 +531,51 @@ namespace Asa.IOModule
while
(
true
)
{
if
(
_send
.
Count
>
0
)
{
if
(
_send
[
0
]
!=
null
)
//if (_send.Count > 0)
//{
// if (_send[0] != null)
// {
// try
// {
// _client.Send(_send[0]);
// if (LogOut)
// {
// byte[] bb = new byte[2];
// bb[0] = _send[0][1];
// bb[1] = _send[0][0];
// flag = BitConverter.ToUInt16(bb, 0);
// s = string.Format("{0:HH:mm:ss:fff} Send {1}", DateTime.Now, flag);
// _log.Add(s);
// _logRxTx.Add(flag + "," + _send[0][7]);
// }
// _send.RemoveAt(0);
// }
// catch (Exception ex)
// {
// ErrInfo = ex.Message;
// LogUtil.error(ex.ToString());
// _unrevdRemote = 1;
// break;
// }
// }
//}
bool
rtn
=
_send
.
TryDequeue
(
out
byte
[]
result
);
if
(
rtn
)
{
try
{
_client
.
Send
(
_send
[
0
]
);
_client
.
Send
(
result
);
if
(
LogOut
)
{
byte
[]
bb
=
new
byte
[
2
];
bb
[
0
]
=
_send
[
0
]
[
1
];
bb
[
1
]
=
_send
[
0
]
[
0
];
bb
[
0
]
=
result
[
1
];
bb
[
1
]
=
result
[
0
];
flag
=
BitConverter
.
ToUInt16
(
bb
,
0
);
s
=
string
.
Format
(
"{0:HH:mm:ss:fff} Send {1}"
,
DateTime
.
Now
,
flag
);
_log
.
Add
(
s
);
_logRxTx
.
Add
(
flag
+
","
+
_send
[
0
]
[
7
]);
_logRxTx
.
Add
(
flag
+
","
+
result
[
7
]);
}
_send
.
RemoveAt
(
0
);
}
catch
(
Exception
ex
)
{
...
...
@@ -551,7 +585,6 @@ namespace Asa.IOModule
break
;
}
}
}
Thread
.
Sleep
(
SEND_SLEEP
);
}
...
...
@@ -861,7 +894,8 @@ namespace Asa.IOModule
buff
[
11
]
=
8
;
//个数
else
if
(
_type
==
Box_Type
.
DIO_32
)
buff
[
11
]
=
16
;
//个数
_send
.
Add
(
buff
);
//_send.Add(buff);
_send
.
Enqueue
(
buff
);
}
Thread
.
Sleep
(
_readDISleep
);
}
...
...
@@ -887,7 +921,8 @@ namespace Asa.IOModule
buff
[
11
]
=
16
;
//个数
else
if
(
_type
==
Box_Type
.
DO_16
)
buff
[
11
]
=
16
;
//个数
_send
.
Add
(
buff
);
//_send.Add(buff);
_send
.
Enqueue
(
buff
);
}
Thread
.
Sleep
(
_readDOSleep
);
}
...
...
@@ -950,14 +985,20 @@ namespace Asa.IOModule
//临时
Dictionary
<
string
,
string
>
dic
=
new
Dictionary
<
string
,
string
>();
dic
.
Add
(
"send.Count = "
,
_send
.
Count
.
ToString
());
foreach
(
System
.
Reflection
.
PropertyInfo
info
in
_client
.
GetType
().
GetProperties
())
try
{
{
try
{
dic
.
Add
(
info
.
Name
,
info
.
GetValue
(
_client
)
==
null
?
"null"
:
info
.
GetValue
(
_client
).
ToString
());
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
dic
.
Add
(
"错误"
+
info
.
Name
,
ex
.
Message
);
dic
.
Add
(
"错误"
+
info
.
Name
,
ex
.
Message
);
}
}
CloseConn
();
Thread
.
Sleep
(
100
);
...
...
@@ -999,7 +1040,7 @@ namespace Asa.IOModule
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"Reconn出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"Reconn出错:"
+
ex
.
ToString
());
}
Thread
.
Sleep
(
1000
);
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论