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
016c01b5
Commit
016c01b5
authored
Nov 21, 2012
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Новый формат ConfirmMessage (основанный на том, что сообщение это тоже датчик).
(eterbug #8842)
parent
f2fe49dc
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
77 deletions
+91
-77
libuniset.spec
conf/libuniset.spec
+4
-1
configure.ac
configure.ac
+2
-2
MessageType.h
include/MessageType.h
+16
-13
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+49
-15
InfoServer.cc
src/Services/InfoServer.cc
+2
-2
MessageType.cc
src/Various/MessageType.cc
+18
-44
No files found.
conf/libuniset.spec
View file @
016c01b5
...
...
@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.5
Release: alt
1
Release: alt
2
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
...
...
@@ -211,6 +211,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Wed Nov 21 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt2
- new ConfirmMessage format (eterbug #8842)
* Tue Nov 06 2012 Pavel Vainerman <pv@altlinux.ru> 1.5-alt1
- add depends for IOBase
...
...
configure.ac
View file @
016c01b5
...
...
@@ -3,7 +3,7 @@
# See doc: http://www.gnu.org/software/hello/manual/autoconf/Generic-Programs.html
# AC_PREREQ(2.59)
AC_INIT([uniset], [1.5.
0
], pv@etersoft.ru)
AC_INIT([uniset], [1.5.
1
], pv@etersoft.ru)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION)
# AC_CONFIG_MACRO_DIR([m4])
...
...
@@ -30,7 +30,7 @@ AC_ENABLE_SHARED(yes)
AC_ENABLE_STATIC(no)
AM_PROG_LIBTOOL
LIBVER=1:5:
0
LIBVER=1:5:
1
AC_SUBST(LIBVER)
# Checks for libraries.
...
...
include/MessageType.h
View file @
016c01b5
...
...
@@ -337,24 +337,27 @@ namespace UniSetTypes
{
public
:
ConfirmMessage
(
const
InfoMessage
&
msg
,
Priority
prior
=
Message
::
High
,
ObjectId
cons
=
UniSetTypes
::
DefaultObjectId
);
ConfirmMessage
(
const
AlarmMessage
&
msg
,
Priority
prior
=
Message
::
High
,
ObjectId
cons
=
UniSetTypes
::
DefaultObjectId
);
ConfirmMessage
(
const
VoidMessage
*
msg
);
inline
TransportMessage
transport_msg
()
const
{
return
transport
(
*
this
);
}
MessageCode
code
;
/*!< id подтвержденного события */
MessageCode
orig_cause
;
/*!< причина */
timeval
orig_tm
;
/*!< время сообщения */
int
orig_type
;
/*!< тип подтвержденного сообщения */
ObjectId
orig_node
;
/*!< узел */
ObjectId
orig_id
;
/*!< от кого оно было */
ConfirmMessage
(
const
VoidMessage
*
msg
);
ConfirmMessage
(
long
in_sensor_id
,
double
in_value
,
time_t
in_time
,
time_t
in_time_usec
,
time_t
in_confirm
,
Priority
in_priority
=
Message
::
Medium
);
long
sensor_id
;
/* ID датчика */
double
value
;
/* значение датчика */
time_t
time
;
/* время, когда датчик получил сигнал */
time_t
time_usec
;
/* время в микросекундах */
time_t
confirm
;
/* время, когда произошло квитирование */
bool
broadcast
;
/*!
...
...
src/ObjectRepository/UniSetObject.cc
View file @
016c01b5
...
...
@@ -270,16 +270,6 @@ struct MsgInfo
node
(
am
.
node
)
{}
MsgInfo
(
ConfirmMessage
&
am
)
:
type
(
am
.
orig_type
),
id
(
am
.
orig_id
),
acode
(
am
.
code
),
ccode
(
am
.
orig_cause
),
ch
(
0
),
tm
(
am
.
orig_tm
),
node
(
am
.
orig_node
)
{}
int
type
;
ObjectId
id
;
// от кого
MessageCode
acode
;
// код сообщения
...
...
@@ -313,6 +303,49 @@ struct MsgInfo
};
// структура определяющая минимальное количество полей
// по которым можно судить о схожести сообщений
// используется локально и только в функции очистки очереди сообщений
struct
CInfo
{
CInfo
()
:
sensor_id
(
DefaultObjectId
),
value
(
0
),
time
(
0
),
time_usec
(
0
),
confirm
(
0
)
{
}
CInfo
(
ConfirmMessage
&
cm
)
:
sensor_id
(
cm
.
sensor_id
),
value
(
cm
.
value
),
time
(
cm
.
time
),
time_usec
(
cm
.
time_usec
),
confirm
(
cm
.
confirm
)
{}
long
sensor_id
;
/* ID датчика */
double
value
;
/* значение датчика */
time_t
time
;
/* время, когда датчик получил сигнал */
time_t
time_usec
;
/* время в микросекундах */
time_t
confirm
;
/* время, когда произошло квитирование */
inline
bool
operator
<
(
const
CInfo
&
mi
)
const
{
if
(
sensor_id
!=
mi
.
sensor_id
)
return
sensor_id
<
mi
.
sensor_id
;
if
(
value
!=
mi
.
value
)
return
value
<
mi
.
value
;
if
(
time
!=
time
)
return
time
<
mi
.
time
;
return
time_usec
<
mi
.
time_usec
;
}
};
// ------------------------------------------------------------------------------------------
bool
UniSetObject
::
waitMessage
(
VoidMessage
&
vm
,
timeout_t
timeMS
)
{
...
...
@@ -497,7 +530,7 @@ struct tmpConsumerInfo
map
<
int
,
VoidMessage
>
sysmap
;
map
<
MsgInfo
,
VoidMessage
>
amap
;
map
<
MsgInfo
,
VoidMessage
>
imap
;
map
<
Msg
Info
,
VoidMessage
>
cmap
;
map
<
C
Info
,
VoidMessage
>
cmap
;
list
<
VoidMessage
>
lstOther
;
};
...
...
@@ -571,13 +604,14 @@ void UniSetObject::cleanMsgQueue( MessagesQueue& q )
}
break
;
case
Message
:
:
Confirm
:
{
ConfirmMessage
cm
(
&
m
);
MsgInfo
m
i
(
cm
);
CInfo
c
i
(
cm
);
// т.к. из очереди сообщений сперва вынимаются самые старые, потом свежее и т.п.
// то достаточно просто сохранять последнее сообщение для одинаковых MsgInfo
consumermap
[
cm
.
consumer
].
cmap
[
m
i
]
=
m
;
consumermap
[
cm
.
consumer
].
cmap
[
c
i
]
=
m
;
}
break
;
...
...
@@ -586,7 +620,7 @@ void UniSetObject::cleanMsgQueue( MessagesQueue& q )
break
;
default
:
// сразу п
изаем
// сразу п
омещаем в очередь
consumermap
[
m
.
consumer
].
lstOther
.
push_front
(
m
);
break
;
...
...
@@ -642,7 +676,7 @@ void UniSetObject::cleanMsgQueue( MessagesQueue& q )
q
.
push
(
it4
->
second
);
}
map
<
Msg
Info
,
VoidMessage
>::
iterator
it5
=
it0
->
second
.
cmap
.
begin
();
map
<
C
Info
,
VoidMessage
>::
iterator
it5
=
it0
->
second
.
cmap
.
begin
();
for
(
;
it5
!=
it0
->
second
.
cmap
.
end
();
++
it5
)
{
q
.
push
(
it5
->
second
);
...
...
src/Services/InfoServer.cc
View file @
016c01b5
...
...
@@ -334,7 +334,7 @@ void InfoServer::processingMessage( UniSetTypes::VoidMessage *msg )
{
UniSetTypes
::
ConfirmMessage
cm
(
msg
);
unideb
[
Debug
::
INFO
]
<<
myname
<<
" ConfirmMessage на сообщение
code= "
<<
cm
.
code
<<
endl
;
unideb
[
Debug
::
INFO
]
<<
myname
<<
" ConfirmMessage на сообщение
sensor_id= "
<<
cm
.
sensor_id
<<
endl
;
try
{
// если это не пересланное сообщение
...
...
@@ -356,7 +356,7 @@ void InfoServer::processingMessage( UniSetTypes::VoidMessage *msg )
// посылаем всем зазкачикам уведомление
event
(
cm
.
code
,
cm
,
true
);
event
(
cm
.
sensor_id
,
cm
,
true
);
try
{
...
...
src/Various/MessageType.cc
View file @
016c01b5
...
...
@@ -311,7 +311,6 @@ TimerMessage::TimerMessage(UniSetTypes::TimerId id, Priority prior, ObjectId con
id
(
id
)
{
type
=
Message
::
Timer
;
this
->
priority
=
prior
;
this
->
consumer
=
cons
;
}
...
...
@@ -321,53 +320,28 @@ TimerMessage::TimerMessage(const VoidMessage *msg)
assert
(
this
->
type
==
Message
::
Timer
);
}
//--------------------------------------------------------------------------------------------
ConfirmMessage
::
ConfirmMessage
()
:
code
(
UniSetTypes
::
DefaultMessageCode
),
orig_cause
(
DefaultMessageCode
),
orig_type
(
Message
::
Info
),
orig_node
(
DefaultObjectId
),
orig_id
(
UniSetTypes
::
DefaultMessageCode
),
broadcast
(
false
),
route
(
false
)
{
}
ConfirmMessage
::
ConfirmMessage
(
const
InfoMessage
&
msg
,
Priority
prior
,
ObjectId
cons
)
:
code
(
msg
.
infocode
),
orig_cause
(
DefaultMessageCode
),
orig_tm
(
msg
.
tm
),
orig_type
(
msg
.
type
),
orig_node
(
msg
.
node
),
orig_id
(
msg
.
id
),
broadcast
(
msg
.
broadcast
),
route
(
false
)
ConfirmMessage
::
ConfirmMessage
(
const
VoidMessage
*
msg
)
{
type
=
Message
::
Confirm
;
this
->
priority
=
prior
;
this
->
consumer
=
cons
;
// struct timeb tm;
memcpy
(
this
,
msg
,
sizeof
(
*
this
));
assert
(
this
->
type
==
Message
::
Confirm
);
}
ConfirmMessage
::
ConfirmMessage
(
const
AlarmMessage
&
msg
,
Priority
prior
,
ObjectId
cons
)
:
code
(
msg
.
alarmcode
),
orig_cause
(
msg
.
causecode
),
orig_tm
(
msg
.
tm
),
orig_type
(
msg
.
type
),
orig_node
(
msg
.
node
),
orig_id
(
msg
.
id
),
broadcast
(
msg
.
broadcast
),
route
(
false
)
//--------------------------------------------------------------------------------------------
ConfirmMessage
::
ConfirmMessage
(
long
in_sensor_id
,
double
in_value
,
time_t
in_time
,
time_t
in_time_usec
,
time_t
in_confirm
,
Priority
in_priority
)
:
sensor_id
(
in_sensor_id
),
value
(
in_value
),
time
(
in_time
),
time_usec
(
in_time_usec
),
confirm
(
in_confirm
),
broadcast
(
false
),
route
(
false
)
{
type
=
Message
::
Confirm
;
this
->
priority
=
prior
;
this
->
consumer
=
cons
;
}
ConfirmMessage
::
ConfirmMessage
(
const
VoidMessage
*
msg
)
{
memcpy
(
this
,
msg
,
sizeof
(
*
this
));
assert
(
this
->
type
==
Message
::
Confirm
);
priority
=
in_priority
;
}
//--------------------------------------------------------------------------------------------
...
...
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