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
ed9473bf
Commit
ed9473bf
authored
Feb 04, 2019
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'mtype' for TextMessage.
parent
8f3305c5
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
68 additions
and
28 deletions
+68
-28
UniSetObject_i.idl
IDL/UniSetTypes/UniSetObject_i.idl
+1
-0
admin.cc
Utilities/Admin/admin.cc
+24
-6
DBServer_MySQL.cc
extensions/DBServer-MySQL/DBServer_MySQL.cc
+2
-1
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+2
-1
DBServer_SQLite.cc
extensions/DBServer-SQLite/DBServer_SQLite.cc
+2
-1
TestObject.cc
extensions/SharedMemory/tests/TestObject.cc
+6
-0
TestObject.h
extensions/SharedMemory/tests/TestObject.h
+2
-0
test_sm.cc
extensions/SharedMemory/tests/test_sm.cc
+2
-1
MessageType.h
include/MessageType.h
+2
-0
UInterface.h
include/UInterface.h
+1
-1
UniSetObject.h
include/UniSetObject.h
+1
-0
MessageType.cc
src/Core/MessageType.cc
+6
-3
UInterface.cc
src/Core/UInterface.cc
+3
-3
UniSetObject.cc
src/Core/UniSetObject.cc
+3
-2
test_messagetype.cc
tests/test_messagetype.cc
+9
-7
test_ui.cc
tests/test_ui.cc
+2
-2
No files found.
IDL/UniSetTypes/UniSetObject_i.idl
View file @
ed9473bf
...
...
@@ -55,6 +55,7 @@
/*
!
Функция
посылки
текстового
сообщения
объекту
*/
void
pushMessage
(
in
string
msg
,
in
long
mtype
,
in
uniset
::
Timespec
tm
,
in
uniset
::
ProducerInfo
pi
,
in
long
priority
...
...
Utilities/Admin/admin.cc
View file @
ed9473bf
...
...
@@ -78,7 +78,7 @@ int getState( const string& args, UInterface& ui );
int
getCalibrate
(
const
string
&
args
,
UInterface
&
ui
);
int
oinfo
(
const
string
&
args
,
UInterface
&
ui
,
const
string
&
userparam
);
int
apiRequest
(
const
string
&
args
,
UInterface
&
ui
,
const
string
&
query
);
void
sendText
(
const
string
&
args
,
UInterface
&
ui
,
const
string
&
txt
);
void
sendText
(
const
string
&
args
,
UInterface
&
ui
,
const
string
&
txt
,
int
mtype
);
// --------------------------------------------------------------------------
static
void
print_help
(
int
width
,
const
string
&
cmd
,
const
string
&
help
,
const
string
&
tab
=
" "
)
{
...
...
@@ -125,7 +125,7 @@ static void usage()
print_help
(
36
,
"-v|--verbose"
,
"Подробный вывод логов.
\n
"
);
print_help
(
36
,
"-q|--quiet"
,
"Выводит только результат.
\n
"
);
print_help
(
36
,
"-z|--csv"
,
"Вывести результат (getValue) в виде val1,val2,val3...
\n
"
);
print_help
(
36
,
"-m|--sendText id1@node1,id2@node2,id3,..
text"
,
"Послать объектам текстовое сообщение text
\n
"
);
print_help
(
36
,
"-m|--sendText id1@node1,id2@node2,id3,..
mtype text"
,
"Послать объектам текстовое сообщение text типа mtype
\n
"
);
cout
<<
endl
;
}
...
...
@@ -377,17 +377,35 @@ int main(int argc, char** argv)
if
(
checkArg
(
optind
,
argc
,
argv
)
==
0
)
{
if
(
!
quiet
)
cerr
<<
"admin(sendText): Unknown '
text'. Use: id,name,name2@nodeX
text"
<<
endl
;
cerr
<<
"admin(sendText): Unknown '
mtype'. Use: id,name,name2@nodeX mtype
text"
<<
endl
;
return
1
;
}
ostringstream
txt
;
if
(
checkArg
(
optind
+
1
,
argc
,
argv
)
==
0
)
{
if
(
!
quiet
)
cerr
<<
"admin(sendText): Unknown 'text'. Use: id,name,name2@nodeX mtype text"
<<
endl
;
return
1
;
}
for
(
int
i
=
optind
+
1
;
i
<
argc
;
i
++
)
{
if
(
checkArg
(
i
,
argc
,
argv
)
==
0
)
break
;
txt
<<
" "
<<
argv
[
optind
+
1
];
}
auto
conf
=
uniset_init
(
argc
,
argv
,
conffile
);
UInterface
ui
(
conf
);
ui
.
initBackId
(
uniset
::
AdminID
);
std
::
string
txt
=
string
(
argv
[
optind
]);
int
mtype
=
uni_atoi
(
argv
[
optind
]);
sendText
(
optarg
,
ui
,
txt
);
sendText
(
optarg
,
ui
,
txt
.
str
(),
mtype
);
return
0
;
}
break
;
...
...
@@ -1111,7 +1129,7 @@ int apiRequest( const string& args, UInterface& ui, const string& query )
}
// --------------------------------------------------------------------------------------
void
sendText
(
const
string
&
args
,
UInterface
&
ui
,
const
string
&
txt
)
void
sendText
(
const
string
&
args
,
UInterface
&
ui
,
const
string
&
txt
,
int
mtype
)
{
auto
conf
=
uniset_conf
();
auto
sl
=
uniset
::
getObjectsList
(
args
,
conf
);
...
...
extensions/DBServer-MySQL/DBServer_MySQL.cc
View file @
ed9473bf
...
...
@@ -138,11 +138,12 @@ void DBServer_MySQL::onTextMessage( const TextMessage* msg )
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
msg
->
type
)
<<
"(date, time, time_usec, text, node) VALUES( '"
<<
"(date, time, time_usec, text,
mtype,
node) VALUES( '"
<<
dateToString
(
msg
->
tm
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
msg
->
tm
.
tv_sec
,
":"
)
<<
"','"
// time
<<
msg
->
tm
.
tv_nsec
<<
"','"
// time_usec
<<
msg
->
txt
<<
"','"
// text
<<
msg
->
mtype
<<
"','"
// mtype
<<
msg
->
node
<<
"')"
;
// node
dbinfo
<<
myname
<<
"(insert_main_messages): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
View file @
ed9473bf
...
...
@@ -128,11 +128,12 @@ void DBServer_PostgreSQL::onTextMessage( const TextMessage* msg )
{
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
msg
->
type
)
<<
"(date, time, time_usec, text, node) VALUES( '"
<<
"(date, time, time_usec, text,
mtype,
node) VALUES( '"
<<
dateToString
(
msg
->
tm
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
msg
->
tm
.
tv_sec
,
":"
)
<<
"','"
// time
<<
msg
->
tm
.
tv_nsec
<<
"','"
// time_usec
<<
msg
->
txt
<<
"','"
// text
<<
msg
->
mtype
<<
"','"
// mtype
<<
msg
->
node
<<
"')"
;
// node
dbinfo
<<
myname
<<
"(insert_main_messages): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/DBServer-SQLite/DBServer_SQLite.cc
View file @
ed9473bf
...
...
@@ -125,11 +125,12 @@ void DBServer_SQLite::onTextMessage( const TextMessage* msg )
{
ostringstream
data
;
data
<<
"INSERT INTO "
<<
tblName
(
msg
->
type
)
<<
"(date, time, time_usec, text, node) VALUES( '"
<<
"(date, time, time_usec, text,
mtype,
node) VALUES( '"
<<
dateToString
(
msg
->
tm
.
tv_sec
,
"-"
)
<<
"','"
// date
<<
timeToString
(
msg
->
tm
.
tv_sec
,
":"
)
<<
"','"
// time
<<
msg
->
tm
.
tv_nsec
<<
"','"
// time_usec
<<
msg
->
txt
<<
"','"
// text
<<
msg
->
mtype
<<
"','"
// mtype
<<
msg
->
node
<<
"')"
;
// node
dbinfo
<<
myname
<<
"(insert_main_messages): "
<<
data
.
str
()
<<
endl
;
...
...
extensions/SharedMemory/tests/TestObject.cc
View file @
ed9473bf
...
...
@@ -59,6 +59,7 @@ void TestObject::sensorInfo( const SensorMessage* sm )
void
TestObject
::
onTextMessage
(
const
TextMessage
*
msg
)
{
lastText
=
msg
->
txt
;
lastTextType
=
msg
->
mtype
;
}
// -----------------------------------------------------------------------------
void
TestObject
::
stopHeartbeat
()
...
...
@@ -112,4 +113,9 @@ string TestObject::getLastTextMessage() const
{
return
lastText
;
}
int
TestObject
::
getLastTextMessageType
()
const
{
return
lastTextType
;
}
// -----------------------------------------------------------------------------
extensions/SharedMemory/tests/TestObject.h
View file @
ed9473bf
...
...
@@ -37,6 +37,7 @@ class TestObject:
bool
isFullQueue
();
std
::
string
getLastTextMessage
()
const
;
int
getLastTextMessageType
()
const
;
protected
:
TestObject
();
...
...
@@ -52,6 +53,7 @@ class TestObject:
long
lostMessages
=
{
false
};
long
lastValue
=
{
0
};
std
::
string
lastText
=
{
""
};
int
lastTextType
=
{
0
};
};
// -----------------------------------------------------------------------------
#endif // _TestObject_H_
...
...
extensions/SharedMemory/tests/test_sm.cc
View file @
ed9473bf
...
...
@@ -317,8 +317,9 @@ TEST_CASE("[SM]: sendText", "[sm][sendText]")
std
::
string
txt
=
"Hello world"
;
ui
->
sendText
(
obj
->
getId
(),
txt
);
ui
->
sendText
(
obj
->
getId
(),
txt
,
3
);
msleep
(
300
);
REQUIRE
(
obj
->
getLastTextMessage
()
==
txt
);
REQUIRE
(
obj
->
getLastTextMessageType
()
==
3
);
}
include/MessageType.h
View file @
ed9473bf
...
...
@@ -287,6 +287,7 @@ namespace uniset
TextMessage
()
noexcept
;
TextMessage
(
const
VoidMessage
*
msg
)
noexcept
;
TextMessage
(
const
char
*
msg
,
int
mtype
,
const
::
uniset
::
Timespec
&
tm
,
const
::
uniset
::
ProducerInfo
&
pi
,
Priority
prior
=
Message
::
Medium
,
...
...
@@ -295,6 +296,7 @@ namespace uniset
std
::
shared_ptr
<
VoidMessage
>
toLocalVoidMessage
()
const
;
std
::
string
txt
;
int
mtype
;
};
}
...
...
include/UInterface.h
View file @
ed9473bf
...
...
@@ -233,7 +233,7 @@ namespace uniset
/*! посылка сообщения msg объекту name на узел node */
void
send
(
const
uniset
::
ObjectId
name
,
const
uniset
::
TransportMessage
&
msg
,
uniset
::
ObjectId
node
);
void
send
(
const
uniset
::
ObjectId
name
,
const
uniset
::
TransportMessage
&
msg
);
void
sendText
(
const
uniset
::
ObjectId
name
,
const
std
::
string
&
text
,
const
uniset
::
ObjectId
node
=
uniset
::
DefaultObjectId
);
void
sendText
(
const
uniset
::
ObjectId
name
,
const
std
::
string
&
text
,
int
mtype
,
const
uniset
::
ObjectId
node
=
uniset
::
DefaultObjectId
);
void
sendText
(
const
uniset
::
ObjectId
name
,
const
uniset
::
TextMessage
&
msg
,
const
uniset
::
ObjectId
node
=
uniset
::
DefaultObjectId
);
// ---------------------------------------------------------------
...
...
include/UniSetObject.h
View file @
ed9473bf
...
...
@@ -109,6 +109,7 @@ namespace uniset
//! поместить текстовое сообщение в очередь
virtual
void
pushMessage
(
const
char
*
msg
,
::
CORBA
::
Long
mtype
,
const
::
uniset
::
Timespec
&
tm
,
const
::
uniset
::
ProducerInfo
&
pi
,
::
CORBA
::
Long
priority
,
...
...
src/Core/MessageType.cc
View file @
ed9473bf
...
...
@@ -241,6 +241,7 @@ namespace uniset
tm
=
m
->
tm
;
consumer
=
m
->
consumer
;
supplier
=
m
->
supplier
;
mtype
=
m
->
mtype
;
txt
=
m
->
txt
;
}
}
...
...
@@ -250,7 +251,8 @@ namespace uniset
type
=
Message
::
TextMessage
;
}
TextMessage
::
TextMessage
(
const
char
*
msg
,
TextMessage
::
TextMessage
(
const
char
*
msg
,
int
_mtype
,
const
uniset
::
Timespec
&
tm
,
const
::
uniset
::
ProducerInfo
&
pi
,
Priority
prior
,
...
...
@@ -263,7 +265,8 @@ namespace uniset
this
->
consumer
=
cons
;
this
->
tm
.
tv_sec
=
tm
.
sec
;
this
->
tm
.
tv_nsec
=
tm
.
nsec
;
txt
=
std
::
string
(
msg
);
this
->
txt
=
std
::
string
(
msg
);
this
->
mtype
=
_mtype
;
}
//--------------------------------------------------------------------------------------------
std
::
shared_ptr
<
VoidMessage
>
TextMessage
::
toLocalVoidMessage
()
const
...
...
@@ -276,7 +279,7 @@ namespace uniset
ts
.
sec
=
tm
.
tv_sec
;
ts
.
nsec
=
tm
.
tv_nsec
;
auto
tmsg
=
std
::
make_shared
<
TextMessage
>
(
txt
.
c_str
(),
ts
,
pi
,
priority
,
consumer
);
auto
tmsg
=
std
::
make_shared
<
TextMessage
>
(
txt
.
c_str
(),
mtype
,
ts
,
pi
,
priority
,
consumer
);
return
std
::
static_pointer_cast
<
VoidMessage
>
(
tmsg
);
}
//--------------------------------------------------------------------------------------------
...
...
src/Core/UInterface.cc
View file @
ed9473bf
...
...
@@ -1020,7 +1020,7 @@ namespace uniset
send
(
name
,
msg
,
uconf
->
getLocalNode
());
}
// ------------------------------------------------------------------------------------------------------------
void
UInterface
::
sendText
(
const
ObjectId
name
,
const
std
::
string
&
txt
,
const
ObjectId
node
)
void
UInterface
::
sendText
(
const
ObjectId
name
,
const
std
::
string
&
txt
,
int
mtype
,
const
ObjectId
node
)
{
if
(
name
==
uniset
::
DefaultObjectId
)
throw
uniset
::
ORepFailed
(
"UI(sendText): ERROR: id=uniset::DefaultObjectId"
);
...
...
@@ -1051,7 +1051,7 @@ namespace uniset
oref
=
resolve
(
name
,
onode
);
UniSetObject_i_var
obj
=
UniSetObject_i
::
_narrow
(
oref
);
obj
->
pushMessage
(
txt
.
c_str
(),
ts
,
pi
,
Message
::
Medium
,
uniset
::
DefaultObjectId
);
obj
->
pushMessage
(
txt
.
c_str
(),
mtype
,
ts
,
pi
,
Message
::
Medium
,
uniset
::
DefaultObjectId
);
return
;
}
catch
(
const
CORBA
::
TRANSIENT
&
)
{}
...
...
@@ -1125,7 +1125,7 @@ namespace uniset
oref
=
resolve
(
name
,
onode
);
UniSetObject_i_var
obj
=
UniSetObject_i
::
_narrow
(
oref
);
obj
->
pushMessage
(
msg
.
txt
.
c_str
(),
ts
,
pi
,
msg
.
priority
,
msg
.
consumer
);
obj
->
pushMessage
(
msg
.
txt
.
c_str
(),
msg
.
mtype
,
ts
,
pi
,
msg
.
priority
,
msg
.
consumer
);
return
;
}
catch
(
const
CORBA
::
TRANSIENT
&
)
{}
...
...
src/Core/UniSetObject.cc
View file @
ed9473bf
...
...
@@ -400,13 +400,14 @@ namespace uniset
termWaiting
();
}
// ------------------------------------------------------------------------------------------
void
UniSetObject
::
pushMessage
(
const
char
*
msg
,
void
UniSetObject
::
pushMessage
(
const
char
*
msg
,
::
CORBA
::
Long
mtype
,
const
::
uniset
::
Timespec
&
tm
,
const
::
uniset
::
ProducerInfo
&
pi
,
::
CORBA
::
Long
priority
,
::
CORBA
::
Long
consumer
)
{
uniset
::
TextMessage
tmsg
(
msg
,
tm
,
pi
,
(
uniset
::
Message
::
Priority
)
priority
,
consumer
);
uniset
::
TextMessage
tmsg
(
msg
,
mtype
,
tm
,
pi
,
(
uniset
::
Message
::
Priority
)
priority
,
consumer
);
auto
vm
=
tmsg
.
toLocalVoidMessage
();
if
(
vm
->
priority
==
Message
::
Medium
)
...
...
tests/test_messagetype.cc
View file @
ed9473bf
...
...
@@ -260,25 +260,27 @@ TEST_CASE("TextMessage", "[basic][message types][TextMessage]" )
ObjectId
consumer
=
40
;
TextMessage
tm
(
txt
.
c_str
(),
tspec
,
pi
,
uniset
::
Message
::
High
,
consumer
);
TextMessage
tm
(
txt
.
c_str
(),
3
,
tspec
,
pi
,
uniset
::
Message
::
High
,
consumer
);
REQUIRE
(
tm
.
consumer
==
consumer
);
REQUIRE
(
tm
.
node
==
pi
.
node
);
REQUIRE
(
tm
.
supplier
==
pi
.
id
);
REQUIRE
(
tm
.
txt
==
txt
);
REQUIRE
(
tm
.
tm
.
tv_sec
==
tspec
.
sec
);
REQUIRE
(
tm
.
tm
.
tv_nsec
==
tspec
.
nsec
);
REQUIRE
(
tm
.
mtype
==
3
);
auto
vm
=
tm
.
toLocalVoidMessage
();
REQUIRE
(
vm
->
type
==
Message
::
TextMessage
);
TextMessage
tm2
(
vm
.
get
());
REQUIRE
(
tm
.
consumer
==
consumer
);
REQUIRE
(
tm
.
node
==
pi
.
node
);
REQUIRE
(
tm
.
supplier
==
pi
.
id
);
REQUIRE
(
tm
.
txt
==
txt
);
REQUIRE
(
tm
.
tm
.
tv_sec
==
tspec
.
sec
);
REQUIRE
(
tm
.
tm
.
tv_nsec
==
tspec
.
nsec
);
REQUIRE
(
tm2
.
consumer
==
consumer
);
REQUIRE
(
tm2
.
node
==
pi
.
node
);
REQUIRE
(
tm2
.
supplier
==
pi
.
id
);
REQUIRE
(
tm2
.
txt
==
txt
);
REQUIRE
(
tm2
.
tm
.
tv_sec
==
tspec
.
sec
);
REQUIRE
(
tm2
.
tm
.
tv_nsec
==
tspec
.
nsec
);
REQUIRE
(
tm2
.
mtype
==
3
);
}
}
// ---------------------------------------------------------------
tests/test_ui.cc
View file @
ed9473bf
...
...
@@ -44,8 +44,8 @@ TEST_CASE("UInterface", "[UInterface]")
REQUIRE_THROWS_AS
(
ui
.
getTimeChange
(
sid
,
-
20
),
uniset
::
Exception
);
REQUIRE_THROWS_AS
(
ui
.
getTimeChange
(
sid
,
DefaultObjectId
),
uniset
::
Exception
);
REQUIRE_THROWS_AS
(
ui
.
getTimeChange
(
sid
,
conf
->
getLocalNode
()),
uniset
::
Exception
);
REQUIRE_THROWS_AS
(
ui
.
sendText
(
testOID
,
"hello"
),
uniset
::
Exception
);
REQUIRE_THROWS_AS
(
ui
.
sendText
(
testOID
,
"hello"
,
-
20
),
uniset
::
Exception
);
REQUIRE_THROWS_AS
(
ui
.
sendText
(
testOID
,
"hello"
,
1
),
uniset
::
Exception
);
REQUIRE_THROWS_AS
(
ui
.
sendText
(
testOID
,
"hello"
,
1
,
-
20
),
uniset
::
Exception
);
CHECK_FALSE
(
ui
.
isExist
(
sid
)
);
CHECK_FALSE
(
ui
.
isExist
(
sid
,
DefaultObjectId
)
);
...
...
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