Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
顾剑亮
/
AIOBOX
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 1040b75b
由
顾剑亮
编写于
2020-05-23 17:10:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
Handle WriteDO Not SendDO
1 个父辈
cc200872
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
80 行增加
和
53 行删除
.vs/AIOBOX/v16/.suo
AIOBOX/AIOBOX.cs
AIOBOX/Properties/AssemblyInfo.cs
AIOBOX/bin/Debug/Asa.IOModule.AIOBOX.dll
AIOBOX/bin/Debug/Asa.IOModule.AIOBOX.pdb
AIOBOX/obj/Debug/Asa.IOModule.AIOBOX.dll
AIOBOX/obj/Debug/Asa.IOModule.AIOBOX.pdb
WindowsFormsApp1/bin/Debug/Asa.IOModule.AIOBOX.dll
WindowsFormsApp1/bin/Debug/Asa.IOModule.AIOBOX.pdb
WindowsFormsApp1/obj/Debug/DesignTimeResolveAssemblyReferences.cache
WindowsFormsApp1/obj/Debug/WindowsFormsApp1.csprojAssemblyReference.cache
.vs/AIOBOX/v16/.suo
查看文件 @
1040b75
此文件类型无法预览
AIOBOX/AIOBOX.cs
查看文件 @
1040b75
...
@@ -41,7 +41,7 @@ namespace Asa.IOModule
...
@@ -41,7 +41,7 @@ namespace Asa.IOModule
private
readonly
Box_Type
_typeOutput
;
//输出类型
private
readonly
Box_Type
_typeOutput
;
//输出类型
private
readonly
byte
[]
_addressInput
;
//输入地址
private
readonly
byte
[]
_addressInput
;
//输入地址
private
readonly
byte
[]
_addressOutput
;
//输出地址
private
readonly
byte
[]
_addressOutput
;
//输出地址
private
const
int
SEND_SLEEP
=
50
;
//每条命令发送的间隔
,不能小于15,会出现IO接收不到的情况,小于30时,会出现接收数据连包的情况
private
const
int
SEND_SLEEP
=
50
;
//每条命令发送的间隔
private
const
int
PORT
=
502
;
//端口
private
const
int
PORT
=
502
;
//端口
private
const
int
UPLOAD_TIME
=
8000
;
//8秒
private
const
int
UPLOAD_TIME
=
8000
;
//8秒
...
@@ -339,58 +339,77 @@ namespace Asa.IOModule
...
@@ -339,58 +339,77 @@ namespace Asa.IOModule
}
}
else
else
{
{
if
(
writeTimer
>=
3
)
//连续发送WriteDO3次,强制发送DO
if
(
_writeDO
.
TryDequeue
(
out
buff
))
{
{
buff
=
GetReadDO_Command
();
writeTimer
=
0
;
}
}
else
else
{
{
if
(
_writeDO
.
TryDequeue
(
out
buff
))
continue
;
{
writeTimer
++;
}
else
{
buff
=
GetReadDO_Command
();
writeTimer
=
0
;
}
}
}
//2020年5月23日
// if (writeTimer >= 3) //连续发送WriteDO3次,强制发送DO
// {
// buff = GetReadDO_Command();
// writeTimer = 0;
// }
// else
// {
// if (_writeDO.TryDequeue(out buff))
// {
// writeTimer++;
// }
// else
// {
// buff = GetReadDO_Command();
// writeTimer = 0;
// }
// }
}
}
time
+=
SEND_SLEEP
;
time
+=
SEND_SLEEP
;
}
}
else
else
{
{
if
(
writeTimer
>=
3
)
//连续发送WriteDO3次,强制发送DI和DO
if
(
_writeDO
.
TryDequeue
(
out
buff
))
{
{
if
(
shift
)
buff
=
GetReadDI_Command
();
else
buff
=
GetReadDO_Command
();
shift
=
!
shift
;
if
(
writeStop
)
writeTimer
=
0
;
else
writeStop
=
true
;
}
}
else
else
{
{
if
(
_writeDO
.
TryDequeue
(
out
buff
))
buff
=
GetReadDI_Command
();
{
writeTimer
++;
writeStop
=
false
;
}
else
{
if
(
shift
)
buff
=
GetReadDI_Command
();
else
buff
=
GetReadDO_Command
();
shift
=
!
shift
;
writeTimer
=
0
;
}
}
}
//2020年5月23日
//if (writeTimer >= 3) //连续发送WriteDO3次,强制发送DI和DO
//{
// if (shift)
// buff = GetReadDI_Command();
// else
// buff = GetReadDO_Command();
// shift = !shift;
// if (writeStop)
// writeTimer = 0;
// else
// writeStop = true;
//}
//else
//{
// if (_writeDO.TryDequeue(out buff))
// {
// writeTimer++;
// writeStop = false;
// }
// else
// {
// if (shift)
// buff = GetReadDI_Command();
// else
// buff = GetReadDO_Command();
// shift = !shift;
// writeTimer = 0;
// }
//}
}
}
...
@@ -465,19 +484,16 @@ namespace Asa.IOModule
...
@@ -465,19 +484,16 @@ namespace Asa.IOModule
byte
[]
temp
=
new
byte
[
count
];
byte
[]
temp
=
new
byte
[
count
];
Array
.
Copy
(
buff
,
0
,
temp
,
0
,
count
);
Array
.
Copy
(
buff
,
0
,
temp
,
0
,
count
);
lock
(
_receive
)
_receive
.
AddRange
(
temp
);
while
(
_receive
.
Count
>
6
)
//分解连包
{
{
_receive
.
AddRange
(
temp
);
int
len
=
_receive
[
5
]
+
6
;
while
(
_receive
.
Count
>
6
)
//分解连包
if
(
len
>
_receive
.
Count
)
break
;
{
byte
[]
cmd
=
new
byte
[
len
];
int
len
=
_receive
[
5
]
+
6
;
_receive
.
CopyTo
(
0
,
cmd
,
0
,
len
);
if
(
len
>
_receive
.
Count
)
break
;
_receive
.
RemoveRange
(
0
,
len
);
byte
[]
cmd
=
new
byte
[
len
];
log
.
Debug
(
"Receive: "
+
HexBuff
(
cmd
));
_receive
.
CopyTo
(
0
,
cmd
,
0
,
len
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
CommandProcess
(
cmd
));
_receive
.
RemoveRange
(
0
,
len
);
log
.
Debug
(
"Receive: "
+
HexBuff
(
cmd
));
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
CommandProcess
(
cmd
));
}
}
}
}
}
}
}
...
@@ -557,6 +573,17 @@ namespace Asa.IOModule
...
@@ -557,6 +573,17 @@ namespace Asa.IOModule
}
}
else
if
(
cmd
[
7
]
==
5
)
else
if
(
cmd
[
7
]
==
5
)
{
{
idx
=
Array
.
FindIndex
(
_addressOutput
,
s
=>
s
==
cmd
[
9
]);
if
(
idx
!=
-
1
)
{
Box_Sta
[]
staDO
=
new
Box_Sta
[
_stateDO
.
Length
];
lock
(
_stateDO
)
{
_stateDO
[
idx
]
=
cmd
[
10
]
==
0xFF
?
Box_Sta
.
On
:
Box_Sta
.
Off
;
Array
.
Copy
(
_stateDO
,
staDO
,
staDO
.
Length
);
}
DO_Changed_Event
?.
Invoke
(
this
,
staDO
);
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
...
AIOBOX/Properties/AssemblyInfo.cs
查看文件 @
1040b75
...
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
...
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.0.
0
")]
[assembly: AssemblyVersion("2.4.0.
2
")]
[assembly: AssemblyFileVersion("2.4.0.
0
")]
[assembly: AssemblyFileVersion("2.4.0.
2
")]
AIOBOX/bin/Debug/Asa.IOModule.AIOBOX.dll
查看文件 @
1040b75
此文件类型无法预览
AIOBOX/bin/Debug/Asa.IOModule.AIOBOX.pdb
查看文件 @
1040b75
此文件类型无法预览
AIOBOX/obj/Debug/Asa.IOModule.AIOBOX.dll
查看文件 @
1040b75
此文件类型无法预览
AIOBOX/obj/Debug/Asa.IOModule.AIOBOX.pdb
查看文件 @
1040b75
此文件类型无法预览
WindowsFormsApp1/bin/Debug/Asa.IOModule.AIOBOX.dll
查看文件 @
1040b75
此文件类型无法预览
WindowsFormsApp1/bin/Debug/Asa.IOModule.AIOBOX.pdb
查看文件 @
1040b75
此文件类型无法预览
WindowsFormsApp1/obj/Debug/DesignTimeResolveAssemblyReferences.cache
查看文件 @
1040b75
此文件类型无法预览
WindowsFormsApp1/obj/Debug/WindowsFormsApp1.csprojAssemblyReference.cache
查看文件 @
1040b75
此文件类型无法预览
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论