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
13b33b33
Commit
13b33b33
authored
Dec 03, 2012
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Переименовал xxx_template.h --> xxx.tcc
parent
62f54d37
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
5 additions
and
575 deletions
+5
-575
libuniset.spec
conf/libuniset.spec
+2
-1
CallBackTimer.tcc
include/CallBackTimer.tcc
+3
-3
CallBackTimer_template.h
include/CallBackTimer_template.h
+0
-183
TriggerAND.tcc
include/TriggerAND.tcc
+0
-0
TriggerAND_template.h
include/TriggerAND_template.h
+0
-129
TriggerOR.tcc
include/TriggerOR.tcc
+0
-0
TriggerOR_template.h
include/TriggerOR_template.h
+0
-130
TriggerOutput.tcc
include/TriggerOutput.tcc
+0
-0
TriggerOutput_template.h
include/TriggerOutput_template.h
+0
-129
No files found.
conf/libuniset.spec
View file @
13b33b33
...
...
@@ -15,7 +15,7 @@ Source: /var/ftp/pvt/Etersoft/Ourside/unstable/sources/tarball/%name-%version.ta
# manually removed: glibc-devel-static
# Automatically added by buildreq on Fri Nov 26 2010
BuildRequires:
glibc-devel-static
libcomedi-devel libcommoncpp2-devel libomniORB-devel libsigc++2.0-devel python-modules xsltproc
BuildRequires: libcomedi-devel libcommoncpp2-devel libomniORB-devel libsigc++2.0-devel python-modules xsltproc
# Using old package name instead of libmysqlclient-devel it absent in branch 5.0 for yauza
BuildRequires: libMySQL-devel
...
...
@@ -138,6 +138,7 @@ rm -f %buildroot%_libdir/*.la
%dir %_includedir/%oname/
%_includedir/%oname/*.h
%_includedir/%oname/*.hh
%_includedir/%oname/*.tcc
%_includedir/%oname/IOs/
%_includedir/%oname/modbus/
%_includedir/%oname/mysql/
...
...
include/CallBackTimer.tcc
View file @
13b33b33
...
...
@@ -21,8 +21,8 @@
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
# ifndef CallBackTimer_T
CC
_H_
# define CallBackTimer_T
CC
_H_
# ifndef CallBackTimer_T
EMPLATE
_H_
# define CallBackTimer_T
EMPLATE
_H_
// --------------------------------------------------------------------------
#include <unistd.h>
#include <sstream>
...
...
@@ -180,4 +180,4 @@ int CallBackTimer<Caller>::getCurrent( int id )
}
// ------------------------------------------------------------------------------------------
# endif //CallBackTimer_
TCC_
H_
# endif //CallBackTimer_H_
include/CallBackTimer_template.h
deleted
100644 → 0
View file @
62f54d37
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Pavel Vainerman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
# ifndef CallBackTimer_TEMPLATE_H_
# define CallBackTimer_TEMPLATE_H_
// --------------------------------------------------------------------------
#include <unistd.h>
#include <sstream>
#include "CallBackTimer.h"
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
class
CallBackTimer
;
// ------------------------------------------------------------------------------------------
/*! Создание таймера
\param r - указатель на заказчика
*/
template
<
class
Caller
>
CallBackTimer
<
Caller
>::
CallBackTimer
(
Caller
*
r
,
Action
a
)
:
cal
(
r
),
act
(
a
),
terminated
(
false
)
{
thr
=
new
ThreadCreator
<
CallBackTimer
>
(
this
,
&
CallBackTimer
<
Caller
>::
work
);
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
CallBackTimer
<
Caller
>::
CallBackTimer
()
:
cal
(
null
),
terminated
(
false
)
{
thr
=
new
ThreadCreator
<
CallBackTimer
>
(
this
,
&
CallBackTimer
<
Caller
>::
work
);
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
CallBackTimer
<
Caller
>::~
CallBackTimer
()
{
terminate
();
clearTimers
();
delete
thr
;
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
work
()
{
terminated
=
false
;
while
(
!
terminated
)
{
usleep
(
UniSetTimer
::
MIN_QUANTITY_TIME_MKS
);
for
(
typename
TimersList
::
iterator
li
=
lst
.
begin
();
li
!=
lst
.
end
();
++
li
)
{
if
(
li
->
pt
.
checkTime
()
)
{
(
cal
->*
act
)(
li
->
id
);
li
->
pt
.
reset
();
}
}
}
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
run
()
{
if
(
!
terminated
)
terminate
();
startTimers
();
// PosixThread::start(static_cast<PosixThread*>(this));
thr
->
start
();
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
terminate
()
{
// timeAct = 0;
terminated
=
true
;
usleep
(
1000
);
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
add
(
int
id
,
int
timeMS
)
throw
(
UniSetTypes
::
LimitTimers
)
{
if
(
lst
.
size
()
>=
MAXCallBackTimer
)
{
ostringstream
err
;
err
<<
"CallBackTimers: превышено максимальное количество таймеров"
<<
MAXCallBackTimer
;
throw
UniSetTypes
::
LimitTimers
(
err
.
str
());
}
PassiveTimer
pt
(
timeMS
);
TimerInfo
ti
(
id
,
pt
);
lst
.
push_back
(
ti
);
// lst[id] = ti;
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
remove
(
int
id
)
{
// STL - способ поиска
typename
TimersList
::
iterator
li
=
find_if
(
lst
.
begin
(),
lst
.
end
(),
FindId_eq
(
id
));
if
(
li
!=
lst
.
end
()
)
lst
.
erase
(
li
);
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
startTimers
()
{
for
(
typename
TimersList
::
iterator
li
=
lst
.
begin
();
li
!=
lst
.
end
();
++
li
)
{
li
->
pt
.
reset
();
}
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
clearTimers
()
{
lst
.
clear
();
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
reset
(
int
id
)
{
typename
TimersList
::
iterator
li
=
find_if
(
lst
.
begin
(),
lst
.
end
(),
FindId_eq
(
id
));
if
(
li
!=
lst
.
end
()
)
li
->
pt
.
reset
();
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
void
CallBackTimer
<
Caller
>::
setTiming
(
int
id
,
int
timeMS
)
{
typename
TimersList
::
iterator
li
=
find_if
(
lst
.
begin
(),
lst
.
end
(),
FindId_eq
(
id
));
if
(
li
!=
lst
.
end
()
)
li
->
pt
.
setTimer
(
timeMS
);
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
int
CallBackTimer
<
Caller
>::
getInterval
(
int
id
)
{
typename
TimersList
::
iterator
li
=
find_if
(
lst
.
begin
(),
lst
.
end
(),
FindId_eq
(
id
));
if
(
li
!=
lst
.
end
()
)
return
li
->
pt
.
getInterval
();
return
-
1
;
}
// ------------------------------------------------------------------------------------------
template
<
class
Caller
>
int
CallBackTimer
<
Caller
>::
getCurrent
(
int
id
)
{
typename
TimersList
::
iterator
li
=
find_if
(
lst
.
begin
(),
lst
.
end
(),
FindId_eq
(
id
));
if
(
li
!=
lst
.
end
()
)
return
li
->
pt
.
getCurrent
();
return
-
1
;
}
// ------------------------------------------------------------------------------------------
# endif //CallBackTimer_H_
include/TriggerAND.tcc
View file @
13b33b33
include/TriggerAND_template.h
deleted
100644 → 0
View file @
62f54d37
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Pavel Vainerman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
#include "TriggerAND.h"
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
TriggerAND
<
Caller
,
InputType
>::
TriggerAND
(
Caller
*
c
,
Action
a
)
:
cal
(
c
),
act
(
a
)
{
}
template
<
class
Caller
,
typename
InputType
>
TriggerAND
<
Caller
,
InputType
>::~
TriggerAND
()
{
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
bool
TriggerAND
<
Caller
,
InputType
>::
commit
(
InputType
num
,
bool
state
)
{
typename
InputMap
::
iterator
it
=
inputs
.
find
(
num
);
if
(
it
!=
inputs
.
end
()
)
{
inputs
[
num
]
=
state
;
check
();
return
true
;
}
return
false
;
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerAND
<
Caller
,
InputType
>::
add
(
InputType
num
,
bool
state
)
{
inputs
[
num
]
=
state
;
check
();
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerAND
<
Caller
,
InputType
>::
remove
(
InputType
num
)
{
typename
InputMap
::
iterator
it
=
inputs
.
find
(
num
);
if
(
it
!=
inputs
.
end
()
)
inputs
.
erase
(
it
);
check
();
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
bool
TriggerAND
<
Caller
,
InputType
>::
getState
(
InputType
num
)
{
typename
InputMap
::
iterator
it
=
inputs
.
find
(
num
);
if
(
it
!=
inputs
.
end
()
)
return
it
->
second
;
return
false
;
// throw NotFound
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerAND
<
Caller
,
InputType
>::
check
()
{
bool
old
=
out
;
for
(
typename
InputMap
::
iterator
it
=
inputs
.
begin
();
it
!=
inputs
.
end
();
++
it
)
{
if
(
!
it
->
second
)
{
// если хоть один вход "0" на выходе "0"
// и прекращаем дальнейший поиск
out
=
false
;
if
(
old
!=
out
)
{
// try
// {
(
cal
->*
act
)(
out
);
// }
// catch(...){}
}
return
;
}
}
out
=
true
;
if
(
old
!=
out
)
{
// try
// {
(
cal
->*
act
)(
out
);
// }
// catch(...){}
}
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerAND
<
Caller
,
InputType
>::
update
()
{
(
cal
->*
act
)(
out
);
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerAND
<
Caller
,
InputType
>::
reset
()
{
out
=
false
;
(
cal
->*
act
)(
out
);
}
//---------------------------------------------------------------------------
include/TriggerOR.tcc
View file @
13b33b33
include/TriggerOR_template.h
deleted
100644 → 0
View file @
62f54d37
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Pavel Vainerman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
#include "TriggerOR.h"
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
TriggerOR
<
Caller
,
InputType
>::
TriggerOR
(
Caller
*
c
,
Action
a
)
:
cal
(
c
),
act
(
a
)
{
}
template
<
class
Caller
,
typename
InputType
>
TriggerOR
<
Caller
,
InputType
>::~
TriggerOR
()
{
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
bool
TriggerOR
<
Caller
,
InputType
>::
commit
(
InputType
num
,
bool
state
)
{
typename
InputMap
::
iterator
it
=
inputs
.
find
(
num
);
if
(
it
!=
inputs
.
end
()
)
{
inputs
[
num
]
=
state
;
check
();
return
true
;
}
return
false
;
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerOR
<
Caller
,
InputType
>::
add
(
InputType
num
,
bool
state
)
{
inputs
[
num
]
=
state
;
check
();
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerOR
<
Caller
,
InputType
>::
remove
(
InputType
num
)
{
typename
InputMap
::
iterator
it
=
inputs
.
find
(
num
);
if
(
it
!=
inputs
.
end
()
)
inputs
.
erase
(
it
);
check
();
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
bool
TriggerOR
<
Caller
,
InputType
>::
getState
(
InputType
num
)
{
typename
InputMap
::
iterator
it
=
inputs
.
find
(
num
);
if
(
it
!=
inputs
.
end
()
)
return
it
->
second
;
return
false
;
// throw NotFound
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerOR
<
Caller
,
InputType
>::
check
()
{
bool
old
=
out
;
for
(
typename
InputMap
::
iterator
it
=
inputs
.
begin
();
it
!=
inputs
.
end
();
++
it
)
{
if
(
it
->
second
)
{
// если хоть один вход "1" на выходе "1"
// и прекращаем дальнейший поиск
out
=
true
;
if
(
old
!=
out
)
{
// try
// {
(
cal
->*
act
)(
out
);
// }
// catch(...){}
}
return
;
}
}
out
=
false
;
if
(
old
!=
out
)
{
// try
// {
(
cal
->*
act
)(
out
);
// }
// catch(...){}
}
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerOR
<
Caller
,
InputType
>::
update
()
{
(
cal
->*
act
)(
out
);
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
InputType
>
void
TriggerOR
<
Caller
,
InputType
>::
reset
()
{
out
=
false
;
(
cal
->*
act
)(
out
);
}
//---------------------------------------------------------------------------
include/TriggerOutput.tcc
View file @
13b33b33
include/TriggerOutput_template.h
deleted
100644 → 0
View file @
62f54d37
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Pavel Vainerman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "TriggerOutput.h"
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
TriggerOutput
(
Caller
*
r
,
Action
a
)
:
cal
(
r
),
act
(
a
)
{
}
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::~
TriggerOutput
()
{
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
void
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
add
(
OutIdType
num
,
ValueType
val
)
{
outs
[
num
]
=
val
;
set
(
num
,
val
);
try
{
(
cal
->*
act
)(
num
,
val
);
}
catch
(...){}
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
void
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
remove
(
OutIdType
num
)
{
typename
OutList
::
iterator
it
=
outs
.
find
(
num
);
if
(
it
!=
outs
.
end
()
)
outs
.
erase
(
it
);
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
bool
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
getState
(
OutIdType
out
)
{
typename
OutList
::
iterator
it
=
outs
.
find
(
out
);
if
(
it
!=
outs
.
end
()
)
return
it
->
second
;
return
false
;
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
void
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
set
(
OutIdType
out
,
ValueType
val
)
{
typename
OutList
::
iterator
it
=
outs
.
find
(
out
);
if
(
it
==
outs
.
end
()
)
return
;
// потом val
ValueType
prev
(
it
->
second
);
it
->
second
=
val
;
if
(
prev
!=
val
)
{
check
(
out
);
// выставляем сперва все нули
try
{
(
cal
->*
act
)(
it
->
first
,
it
->
second
);
}
catch
(...){}
}
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
void
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
check
(
OutIdType
newout
)
{
for
(
typename
OutList
::
iterator
it
=
outs
.
begin
();
it
!=
outs
.
end
();
++
it
)
{
if
(
it
->
first
!=
newout
&&
it
->
second
)
{
it
->
second
=
0
;
// try
// {
(
cal
->*
act
)(
it
->
first
,
it
->
second
);
// }
// catch(...){}
}
}
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
void
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
update
()
{
for
(
typename
OutList
::
iterator
it
=
outs
.
begin
();
it
!=
outs
.
end
();
++
it
)
(
cal
->*
act
)(
it
->
first
,
it
->
second
);
}
//---------------------------------------------------------------------------
template
<
class
Caller
,
typename
OutIdType
,
typename
ValueType
>
void
TriggerOutput
<
Caller
,
OutIdType
,
ValueType
>::
reset
()
{
for
(
typename
OutList
::
iterator
it
=
outs
.
begin
();
it
!=
outs
.
end
();
++
it
)
{
it
->
second
=
0
;
(
cal
->*
act
)(
it
->
first
,
it
->
second
);
}
}
//---------------------------------------------------------------------------
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