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
6141adc3
Commit
6141adc3
authored
Sep 05, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(unet-udp-tester): добавил возможность задавать конкретный список посылаемых
данных в виде id=val,id2=val2,...
parent
6434f4d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
13 deletions
+45
-13
Makefile.am
extensions/UNetUDP/Makefile.am
+1
-1
unet-udp-tester.cc
extensions/UNetUDP/unet-udp-tester.cc
+41
-6
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+3
-6
No files found.
extensions/UNetUDP/Makefile.am
View file @
6141adc3
...
@@ -21,7 +21,7 @@ libUniSet2UNetUDP_la_SOURCES = UDPPacket.cc UNetReceiver.cc UNetSender.cc UNetE
...
@@ -21,7 +21,7 @@ libUniSet2UNetUDP_la_SOURCES = UDPPacket.cc UNetReceiver.cc UNetSender.cc UNetE
@PACKAGE@
_unet_udp_tester_SOURCES
=
UDPPacket.cc unet-udp-tester.cc
@PACKAGE@
_unet_udp_tester_SOURCES
=
UDPPacket.cc unet-udp-tester.cc
@PACKAGE@
_unet_udp_tester_LDADD
=
$(POCO_LIBS)
@PACKAGE@
_unet_udp_tester_LDADD
=
$(
top_builddir)
/lib/libUniSet2.la
$(
POCO_LIBS)
@PACKAGE@
_unet_udp_tester_CXXFLAGS
=
$(POCO_CFLAGS)
@PACKAGE@
_unet_udp_tester_CXXFLAGS
=
$(POCO_CFLAGS)
# install
# install
...
...
extensions/UNetUDP/unet-udp-tester.cc
View file @
6141adc3
...
@@ -27,6 +27,8 @@ static struct option longopts[] =
...
@@ -27,6 +27,8 @@ static struct option longopts[] =
{
"verbode"
,
required_argument
,
0
,
'v'
},
{
"verbode"
,
required_argument
,
0
,
'v'
},
{
"num-cycles"
,
required_argument
,
0
,
'z'
},
{
"num-cycles"
,
required_argument
,
0
,
'z'
},
{
"prof"
,
required_argument
,
0
,
'y'
},
{
"prof"
,
required_argument
,
0
,
'y'
},
{
"a-data"
,
required_argument
,
0
,
'a'
},
{
"d-data"
,
required_argument
,
0
,
'i'
},
{
NULL
,
0
,
0
,
0
}
{
NULL
,
0
,
0
,
0
}
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -74,10 +76,12 @@ int main(int argc, char* argv[])
...
@@ -74,10 +76,12 @@ int main(int argc, char* argv[])
bool
show
=
false
;
bool
show
=
false
;
size_t
ncycles
=
0
;
size_t
ncycles
=
0
;
unsigned
int
nprof
=
0
;
unsigned
int
nprof
=
0
;
std
::
string
d_data
=
""
;
std
::
string
a_data
=
""
;
while
(
1
)
while
(
1
)
{
{
opt
=
getopt_long
(
argc
,
argv
,
"hs:c:r:p:n:t:x:blvdz:y:"
,
longopts
,
&
optindex
);
opt
=
getopt_long
(
argc
,
argv
,
"hs:c:r:p:n:t:x:blvdz:y:
a:i:
"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
if
(
opt
==
-
1
)
break
;
break
;
...
@@ -99,6 +103,8 @@ int main(int argc, char* argv[])
...
@@ -99,6 +103,8 @@ int main(int argc, char* argv[])
cout
<<
"[-d|--show-data] - show receive data."
<<
endl
;
cout
<<
"[-d|--show-data] - show receive data."
<<
endl
;
cout
<<
"[-z|--num-cycles] num - Number of cycles of exchange. Default: -1 - infinitely."
<<
endl
;
cout
<<
"[-z|--num-cycles] num - Number of cycles of exchange. Default: -1 - infinitely."
<<
endl
;
cout
<<
"[-y|--prof] num - Print receive statistics every NUM packets (for -r only)"
<<
endl
;
cout
<<
"[-y|--prof] num - Print receive statistics every NUM packets (for -r only)"
<<
endl
;
cout
<<
"[-a|--a-data] id1=val1,id2=val2,... - Analog data. Send: id1=id1,id2=id2,.. for analog sensors"
<<
endl
;
cout
<<
"[-i|--d-data] id1=val1,id2=val2,... - Digital data. Send: id1=id1,id2=id2,.. for digital sensors"
<<
endl
;
cout
<<
endl
;
cout
<<
endl
;
return
0
;
return
0
;
...
@@ -112,6 +118,14 @@ int main(int argc, char* argv[])
...
@@ -112,6 +118,14 @@ int main(int argc, char* argv[])
cmd
=
cmdSend
;
cmd
=
cmdSend
;
break
;
break
;
case
'a'
:
a_data
=
string
(
optarg
);
break
;
case
'i'
:
d_data
=
string
(
optarg
);
break
;
case
't'
:
case
't'
:
tout
=
atoi
(
optarg
);
tout
=
atoi
(
optarg
);
break
;
break
;
...
@@ -296,14 +310,35 @@ int main(int argc, char* argv[])
...
@@ -296,14 +310,35 @@ int main(int argc, char* argv[])
mypack
.
nodeID
=
nodeID
;
mypack
.
nodeID
=
nodeID
;
mypack
.
procID
=
procID
;
mypack
.
procID
=
procID
;
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
if
(
!
a_data
.
empty
()
)
{
auto
vlist
=
UniSetTypes
::
getSInfoList
(
a_data
,
nullptr
);
for
(
const
auto
&
v
:
vlist
)
{
UDPAData
d
(
v
.
si
.
id
,
v
.
val
);
mypack
.
addAData
(
d
);
}
}
else
{
{
UDPAData
d
(
i
,
i
);
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
mypack
.
addAData
(
d
);
{
UDPAData
d
(
i
,
i
);
mypack
.
addAData
(
d
);
}
}
}
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
if
(
!
d_data
.
empty
()
)
mypack
.
addDData
(
i
,
i
);
{
auto
vlist
=
UniSetTypes
::
getSInfoList
(
d_data
,
nullptr
);
for
(
const
auto
&
v
:
vlist
)
mypack
.
addDData
(
v
.
si
.
id
,
v
.
val
);
}
else
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
mypack
.
addDData
(
i
,
i
);
}
Poco
::
Net
::
SocketAddress
sa
(
s_host
,
port
);
Poco
::
Net
::
SocketAddress
sa
(
s_host
,
port
);
udp
->
connect
(
sa
);
udp
->
connect
(
sa
);
...
...
src/ObjectRepository/UniSetTypes.cc
View file @
6141adc3
...
@@ -280,9 +280,6 @@ bool UniSetTypes::is_digit( const std::string& s )
...
@@ -280,9 +280,6 @@ bool UniSetTypes::is_digit( const std::string& s )
// --------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------
std
::
list
<
UniSetTypes
::
ParamSInfo
>
UniSetTypes
::
getSInfoList
(
const
string
&
str
,
std
::
shared_ptr
<
Configuration
>
conf
)
std
::
list
<
UniSetTypes
::
ParamSInfo
>
UniSetTypes
::
getSInfoList
(
const
string
&
str
,
std
::
shared_ptr
<
Configuration
>
conf
)
{
{
if
(
conf
==
nullptr
)
conf
=
uniset_conf
();
std
::
list
<
UniSetTypes
::
ParamSInfo
>
res
;
std
::
list
<
UniSetTypes
::
ParamSInfo
>
res
;
auto
lst
=
UniSetTypes
::
explode_str
(
str
,
','
);
auto
lst
=
UniSetTypes
::
explode_str
(
str
,
','
);
...
@@ -317,7 +314,7 @@ std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str,
...
@@ -317,7 +314,7 @@ std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str,
{
{
std
::
string
s_id
=
*
(
t
.
begin
());
std
::
string
s_id
=
*
(
t
.
begin
());
if
(
is_digit
(
s_id
)
)
if
(
is_digit
(
s_id
)
||
!
conf
)
item
.
si
.
id
=
uni_atoi
(
s_id
);
item
.
si
.
id
=
uni_atoi
(
s_id
);
else
else
item
.
si
.
id
=
conf
->
getSensorID
(
s_id
);
item
.
si
.
id
=
conf
->
getSensorID
(
s_id
);
...
@@ -329,12 +326,12 @@ std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str,
...
@@ -329,12 +326,12 @@ std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str,
std
::
string
s_id
=
*
(
t
.
begin
());
std
::
string
s_id
=
*
(
t
.
begin
());
std
::
string
s_node
=
*
(
++
t
.
begin
());
std
::
string
s_node
=
*
(
++
t
.
begin
());
if
(
is_digit
(
s_id
)
)
if
(
is_digit
(
s_id
)
||
!
conf
)
item
.
si
.
id
=
uni_atoi
(
s_id
);
item
.
si
.
id
=
uni_atoi
(
s_id
);
else
else
item
.
si
.
id
=
conf
->
getSensorID
(
s_id
);
item
.
si
.
id
=
conf
->
getSensorID
(
s_id
);
if
(
is_digit
(
s_node
)
)
if
(
is_digit
(
s_node
)
||
!
conf
)
item
.
si
.
node
=
uni_atoi
(
s_node
);
item
.
si
.
node
=
uni_atoi
(
s_node
);
else
else
item
.
si
.
node
=
conf
->
getNodeID
(
s_node
);
item
.
si
.
node
=
conf
->
getNodeID
(
s_node
);
...
...
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