Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
e6c70111
Commit
e6c70111
authored
Aug 05, 2023
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 TimeOutEvent 事件
parent
d67c4e95
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
19 deletions
+29
-19
Dev7E.cs
GeneralGommunication/Dev7E.cs
+21
-14
IDev7E.cs
GeneralGommunication/IDev7E.cs
+1
-1
IModbusAsciiAsync.cs
GeneralGommunication/IModbusAsciiAsync.cs
+1
-1
ModbusAsciiAsync.cs
GeneralGommunication/ModbusAsciiAsync.cs
+1
-1
ModbusRTUAsync.cs
GeneralGommunication/ModbusRTUAsync.cs
+1
-1
Modbus_Transaction.cs
GeneralGommunication/Modbus_Transaction.cs
+4
-1
No files found.
GeneralGommunication/Dev7E.cs
View file @
e6c70111
...
...
@@ -43,9 +43,9 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
public
event
SendDataEventHander
SendMsgEvent
;
public
event
SendDataEventHandler
SendMsgEvent
;
public
event
TimeOutEventHandler
TimeOutEvent
;
...
...
@@ -125,6 +125,8 @@ namespace GeneralGommunication
{
//已经重试了3次,放弃
ResetMsg
();
//连接断开
TimeOutEvent
?.
Invoke
(
this
);
return
;
}
else
...
...
@@ -140,6 +142,9 @@ namespace GeneralGommunication
//IsConnected = true;
csm
.
IncRec
(
recBuf
.
Count
());
List
<
byte
[
]>
packs
=
new
List
<
byte
[
]>
();
lock
(
currPack
)
{
for
(
int
i
=
0
;
i
<
recBuf
.
Count
();
i
++)
{
if
(
recBuf
[
i
]
==
0x7e
)
...
...
@@ -149,16 +154,18 @@ namespace GeneralGommunication
if
(
currPack
.
Count
>
0
)
{
var
pack
=
currPack
.
ToArray
();
ParsePack
(
pack
);
packs
.
Add
(
pack
);
currPack
.
Clear
();
csm
.
IncPack
(
1
);
}
}
currPack
.
Add
(
recBuf
[
i
]);
}
}
//OnPoll_TimeOut();
for
(
int
i
=
0
;
i
<
packs
.
Count
();
i
++)
{
ParsePack
(
packs
[
i
]);
}
}
...
...
GeneralGommunication/IDev7E.cs
View file @
e6c70111
...
...
@@ -28,7 +28,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
event
SendDataEventHander
SendMsgEvent
;
event
SendDataEventHand
l
er
SendMsgEvent
;
#
region
模块运行接口
...
...
GeneralGommunication/IModbusAsciiAsync.cs
View file @
e6c70111
...
...
@@ -21,7 +21,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
event
SendDataEventHander
SendMsgEvent
;
event
SendDataEventHand
l
er
SendMsgEvent
;
/// <summary>
/// 设备连接状态改变
...
...
GeneralGommunication/ModbusAsciiAsync.cs
View file @
e6c70111
...
...
@@ -37,7 +37,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
public
event
SendDataEventHander
SendMsgEvent
;
public
event
SendDataEventHand
l
er
SendMsgEvent
;
public
event
DeviceConnectEventHander
DeviceConnectEvent
;
...
...
GeneralGommunication/ModbusRTUAsync.cs
View file @
e6c70111
...
...
@@ -36,7 +36,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
public
event
SendDataEventHander
SendMsgEvent
;
public
event
SendDataEventHand
l
er
SendMsgEvent
;
/// <summary>
/// 对于全部 有返回的函数调用,都使用Dispatcher,使线程同步
...
...
GeneralGommunication/Modbus_Transaction.cs
View file @
e6c70111
...
...
@@ -101,5 +101,8 @@ namespace GeneralGommunication
public
string
errMsg
;
}
public
delegate
void
SendDataEventHander
(
object
sender
,
byte
[]
data
);
public
delegate
void
SendDataEventHandler
(
object
sender
,
byte
[]
data
);
public
delegate
void
TimeOutEventHandler
(
object
sender
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment