Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
4404d4a2
Commit
4404d4a2
authored
Aug 22, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UNet): added "undefined_value" property
parent
e6210567
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
5 deletions
+68
-5
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+1
-1
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+24
-3
UNetSender.h
extensions/UNetUDP/UNetSender.h
+4
-0
test_unetudp.cc
extensions/UNetUDP/tests/test_unetudp.cc
+38
-0
unetudp-test-configure.xml
extensions/UNetUDP/tests/unetudp-test-configure.xml
+1
-1
No files found.
extensions/UNetUDP/UNetExchange.cc
View file @
4404d4a2
...
...
@@ -103,7 +103,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
nodes
=
conf
->
findNode
(
xml
->
getFirstNode
(),
nconfname
);
}
unetinfo
<<
myname
<<
"(init):
init from <"
<<
nconfname
<<
">"
<<
endl
;
unetinfo
<<
myname
<<
"(init): init from <"
<<
nconfname
<<
">"
<<
endl
;
if
(
!
nodes
)
throw
uniset
::
SystemError
(
"(UNetExchange): Not found confnode <"
+
nconfname
+
">"
);
...
...
extensions/UNetUDP/UNetSender.cc
View file @
4404d4a2
...
...
@@ -152,8 +152,27 @@ namespace uniset
for
(
auto
&&
it
:
items
)
{
UItem
&
i
=
it
.
second
;
long
value
=
shm
->
localGetValue
(
i
.
ioit
,
i
.
id
);
updateItem
(
i
,
value
);
try
{
long
value
=
shm
->
localGetValue
(
i
.
ioit
,
i
.
id
);
updateItem
(
i
,
value
);
}
catch
(
IOController_i
::
Undefined
&
ex
)
{
unetwarn
<<
myname
<<
"(updateFromSM): sid="
<<
i
.
id
<<
" undefined state..."
<<
endl
;
if
(
i
.
undefined_value
!=
not_specified_value
)
updateItem
(
i
,
i
.
undefined_value
);
}
catch
(
std
::
exception
&
ex
)
{
unetwarn
<<
myname
<<
"(updateFromSM): "
<<
ex
.
what
()
<<
endl
;
if
(
i
.
undefined_value
!=
not_specified_value
)
updateItem
(
i
,
i
.
undefined_value
);
}
}
}
// -----------------------------------------------------------------------------
...
...
@@ -293,7 +312,6 @@ namespace uniset
if
(
packetnum
==
0
)
packetnum
=
1
;
if
(
!
udp
||
!
udp
->
poll
(
UniSetTimer
::
millisecToPoco
(
writeTimeout
),
Poco
::
Net
::
Socket
::
SELECT_WRITE
)
)
return
;
...
...
@@ -399,6 +417,9 @@ namespace uniset
p
.
iotype
=
uniset
::
getIOType
(
it
.
getProp
(
"iotype"
));
p
.
pack_sendfactor
=
priority
;
if
(
!
it
.
getProp
(
"undefined_value"
).
empty
()
)
p
.
undefined_value
=
it
.
getIntProp
(
"undefined_value"
);
if
(
p
.
iotype
==
UniversalIO
::
UnknownIOType
)
{
unetcrit
<<
myname
<<
"(readItem): Unknown iotype for sid="
<<
sid
<<
endl
;
...
...
extensions/UNetUDP/UNetSender.h
View file @
4404d4a2
...
...
@@ -20,6 +20,7 @@
#include <ostream>
#include <string>
#include <vector>
#include <limits>
#include <unordered_map>
#include "UniSetObject.h"
#include "Trigger.h"
...
...
@@ -76,6 +77,8 @@ namespace uniset
typedef
size_t
sendfactor_t
;
static
const
long
not_specified_value
=
{
std
::
numeric_limits
<
long
>::
max
()
};
struct
UItem
{
UItem
()
:
...
...
@@ -91,6 +94,7 @@ namespace uniset
size_t
pack_num
;
size_t
pack_ind
;
sendfactor_t
pack_sendfactor
=
{
0
};
long
undefined_value
=
{
not_specified_value
};
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
UItem
&
p
);
};
...
...
extensions/UNetUDP/tests/test_unetudp.cc
View file @
4404d4a2
...
...
@@ -468,3 +468,41 @@ TEST_CASE("[UNetUDP]: switching channels", "[unetudp][chswitch]")
REQUIRE
(
ui
->
getValue
(
node1_numchannel_as
)
==
1
);
}
// -----------------------------------------------------------------------------
TEST_CASE
(
"[UNetUDP]: check undefined value"
,
"[unetudp][sender]"
)
{
InitTest
();
UniSetUDP
::
UDPMessage
pack
=
receive
();
ui
->
setValue
(
2
,
110
);
REQUIRE
(
ui
->
getValue
(
2
)
==
110
);
msleep
(
600
);
pack
=
receive
();
REQUIRE
(
pack
.
num
!=
0
);
REQUIRE
(
pack
.
asize
()
==
4
);
REQUIRE
(
pack
.
dsize
()
==
2
);
REQUIRE
(
pack
.
a_dat
[
0
].
val
==
110
);
IOController_i
::
SensorInfo
si
;
si
.
id
=
2
;
si
.
node
=
uniset_conf
()
->
getLocalNode
();
ui
->
setUndefinedState
(
si
,
true
,
6000
/* TestProc */
);
msleep
(
600
);
pack
=
receive
();
REQUIRE
(
pack
.
num
!=
0
);
REQUIRE
(
pack
.
asize
()
==
4
);
REQUIRE
(
pack
.
dsize
()
==
2
);
REQUIRE
(
pack
.
a_dat
[
0
].
val
==
65635
);
ui
->
setUndefinedState
(
si
,
false
,
6000
/* TestProc */
);
msleep
(
600
);
pack
=
receive
();
REQUIRE
(
pack
.
num
!=
0
);
REQUIRE
(
pack
.
asize
()
==
4
);
REQUIRE
(
pack
.
dsize
()
==
2
);
REQUIRE
(
pack
.
a_dat
[
0
].
val
==
110
);
}
// -----------------------------------------------------------------------------
extensions/UNetUDP/tests/unetudp-test-configure.xml
View file @
4404d4a2
...
...
@@ -43,7 +43,7 @@
<item
id=
"100"
iotype=
"DI"
name=
"TestMode_S"
textname=
"Test sensor"
/>
<item
id=
"1"
iotype=
"DI"
name=
"Node1_Not_Respond_S"
textname=
"Node1 not respond"
/>
<item
id=
"2"
iotype=
"AI"
name=
"AI1_S"
textname=
"AI sensor 1"
unet=
"1"
default=
"1"
/>
<item
id=
"2"
iotype=
"AI"
name=
"AI1_S"
textname=
"AI sensor 1"
unet=
"1"
default=
"1"
undefined_value=
"65635"
/>
<item
id=
"3"
iotype=
"AI"
name=
"AI2_S"
textname=
"AI sensor 2"
unet=
"1"
default=
"2"
/>
<item
id=
"4"
iotype=
"AI"
name=
"AI3_S"
textname=
"AI sensor 3"
unet=
"1"
default=
"3"
/>
<item
id=
"5"
iotype=
"AI"
name=
"AI4_S"
textname=
"AI sensor 4"
unet=
"1"
default=
"4"
/>
...
...
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