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
c1064d45
Commit
c1064d45
authored
Sep 14, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(PassiveTimer): исправил ошибку в начальной инициализации t_start.
(Pulse): переделал рассчёт оставшегося времени по импульсам..
parent
347f7bc0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
9 deletions
+39
-9
libuniset2.spec
conf/libuniset2.spec
+5
-1
PassiveTimer.h
include/PassiveTimer.h
+1
-1
Pulse.h
include/Pulse.h
+15
-6
PassiveTimer.cc
src/Timers/PassiveTimer.cc
+1
-1
test_pulse.cc
tests/test_pulse.cc
+17
-0
No files found.
conf/libuniset2.spec
View file @
c1064d45
...
...
@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.1
Release: alt2
4
Release: alt2
5
Summary: UniSet - library for building distributed industrial control systems
...
...
@@ -456,6 +456,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Mon Sep 14 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt25
- (PassiveTimer): fixed bug in default init
- (Pulse): refactoring
* Thu Sep 10 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt24
- (LogServer): refactoring (more use shared_ptr)
...
...
include/PassiveTimer.h
View file @
c1064d45
...
...
@@ -113,7 +113,7 @@ class PassiveTimer:
virtual
void
terminate
();
/*!< прервать работу таймера */
protected
:
timeout_t
t_msec
;
/*!< интервал таймера, в милисекундах */
timeout_t
t_msec
=
{
0
}
;
/*!< интервал таймера, в милисекундах */
std
::
chrono
::
high_resolution_clock
::
time_point
t_start
;
/*!< время установки таймера (сброса) */
private
:
...
...
include/Pulse.h
View file @
c1064d45
...
...
@@ -3,6 +3,7 @@
#define Pulse_H_
// --------------------------------------------------------------------------
#include <iostream>
#include <algorithm>
#include "PassiveTimer.h"
// --------------------------------------------------------------------------
/*! Класс реализующий формирование импульсов заданной длительности(t1) и заданных пауз между ними(t0).
...
...
@@ -11,6 +12,8 @@
Формирование импульсов включается функцией run() либо функцией set(true).
Вызов reset() тоже включает формирование импульсов.
Выключается формирование вызовом set(false).
\warning Точность поддержания "импульсов" зависит от частоты вызова step() или out()
*/
class
Pulse
{
...
...
@@ -53,17 +56,13 @@ class Pulse
if
(
ostate
&&
t1
.
checkTime
()
)
{
ostate
=
false
;
// учитываем что step мог вызваться гораздо позже..
t0
.
setTiming
(
t0_msec
-
t1
.
getCurrent
()
%
t1
.
getInterval
()
);
t0
.
setTiming
(
t0_msec
);
}
if
(
!
ostate
&&
t0
.
checkTime
()
)
{
ostate
=
true
;
// учитываем что step мог вызваться гораздо позже..
t1
.
setTiming
(
t1_msec
-
t0
.
getCurrent
()
%
t0
.
getInterval
()
);
t1
.
setTiming
(
t1_msec
);
}
return
ostate
;
...
...
@@ -102,9 +101,19 @@ class Pulse
}
inline
long
getT1
()
{
return
t1_msec
;
}
inline
long
getT0
()
{
return
t0_msec
;
}
protected
:
PassiveTimer
t1
;
// таймер "1"
PassiveTimer
t0
;
// таймер "0"
PassiveTimer
tCorr
;
// корректирующий таймер
bool
ostate
;
bool
isOn
;
long
t1_msec
;
...
...
src/Timers/PassiveTimer.cc
View file @
c1064d45
...
...
@@ -29,7 +29,7 @@
PassiveTimer
::
PassiveTimer
(
)
:
PassiveTimer
(
WaitUpTime
)
{
reset
();
}
//------------------------------------------------------------------------------
...
...
tests/test_pulse.cc
View file @
c1064d45
...
...
@@ -10,6 +10,10 @@ TEST_CASE("Pulse", "[Test for class 'Pulse' - impulse generator]" )
{
// Работа без задержки..(нулевые задержки)
Pulse
p
;
REQUIRE
(
p
.
getT1
()
==
0
);
REQUIRE
(
p
.
getT0
()
==
0
);
CHECK_FALSE
(
p
.
out
()
);
p
.
step
();
...
...
@@ -51,5 +55,18 @@ TEST_CASE("Pulse", "[Test for class 'Pulse' - impulse generator]" )
CHECK
(
p
.
step
()
);
msleep
(
110
);
CHECK_FALSE
(
p
.
step
()
);
// проверка того, что при познем вызове step
// тоже всё будет хорошо..
p
.
reset
();
CHECK
(
p
.
step
()
);
msleep
(
110
);
CHECK_FALSE
(
p
.
step
()
);
msleep
(
2050
);
CHECK
(
p
.
step
()
);
msleep
(
110
);
CHECK_FALSE
(
p
.
step
()
);
msleep
(
70
);
CHECK
(
p
.
step
()
);
}
}
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