Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
dt_ctrl
Commits
99329e9e
Commit
99329e9e
authored
Dec 31, 2014
by
Jeroen Vreeken
Browse files
Small improvements
Move some more time related stuff to controller_time Add code to handle skipped samples.
parent
9d9e8e0e
Changes
10
Hide whitespace changes
Inline
Side-by-side
controller/block/build.mk
View file @
99329e9e
...
...
@@ -77,7 +77,7 @@ CTRL_BLOCKS += $(BLOCKS) $(BLOCKS_IL)
CTRL_BLOCK_LIBS
+=
libblock.la
TARGETS
+=
$(BLOCK_TARGETS)
CLEAN
+=
$(BLOCK_TARGETS)
$(BLOCK_OBJS)
CLEAN
+=
$(BLOCK_TARGETS)
$(BLOCK_OBJS)
$(BLOCK_OBJS:.lo=.o)
SRCS
+=
$(BLOCK_SRCS)
CTRL_TESTS
+=
\
...
...
controller/block/il2c/il2c.c
View file @
99329e9e
...
...
@@ -61,6 +61,7 @@ void il2c_program(char *program)
fprintf
(
il2c_cout
,
"#include <string.h>
\n
"
);
fprintf
(
il2c_cout
,
"#include <math.h>
\n
"
);
fprintf
(
il2c_cout
,
"#include <controller/controller_block.h>
\n
"
);
fprintf
(
il2c_cout
,
"#include <controller/controller_time.h>
\n
"
);
fprintf
(
il2c_cout
,
"
\n
"
);
}
...
...
controller/block/il2c/test/build.mk
View file @
99329e9e
...
...
@@ -16,5 +16,5 @@ $(DIR)/blocks: $(BLOCKS_OBJS)
TARGETS
+=
$(TEST_TARGETS)
CLEAN
+=
$(
TEST_TARGETS
)
$(BLOCKS_OBJS)
CLEAN
+=
$(
BLOCKS_OBJSC:.il=.il2c.c
)
$(BLOCKS_OBJS)
SRCS
+=
$(BLOCKS_SRCS)
controller/controller/controller_block.c
View file @
99329e9e
...
...
@@ -490,11 +490,6 @@ int controller_block_link(void)
uint64_t
controller_time_nseconds
=
0
;
uint32_t
controller_time_seconds
=
0
;
uint32_t
controller_time_samplenr
=
0
;
uint32_t
controller_samplenr
=
0
;
void
controller_block_calculate
(
void
)
{
struct
calculate_func
*
calculate
;
...
...
@@ -510,6 +505,12 @@ void controller_block_calculate(void)
calculates_sub_cur
%=
calculates_sub
;
}
void
controller_block_skip
(
int64_t
nr
)
{
nr
+=
calculates_sub_cur
;
nr
%=
calculates_sub
;
calculates_sub_cur
=
nr
;
}
...
...
controller/controller/controller_block.h
View file @
99329e9e
...
...
@@ -178,13 +178,6 @@ struct controller_block_link {
char
*
type
;
};
/* 64bit continuous counter */
extern
uint64_t
controller_time_nseconds
;
extern
uint32_t
controller_time_seconds
;
extern
uint32_t
controller_time_samplenr
;
extern
uint32_t
controller_samplenr
;
int
controller_block_create
(
char
*
type
,
char
*
name
,
va_list
ap
);
void
controller_block_add
(
struct
controller_block
*
newblock
);
struct
controller_block
*
controller_block_find
(
char
*
name
);
...
...
@@ -208,6 +201,8 @@ int controller_block_link_nr(void);
int
controller_block_sample_init
(
void
);
void
controller_block_calculate
(
void
);
void
controller_block_skip
(
int64_t
nr
);
char
*
controller_block_context_get
(
void
);
void
controller_block_context_set
(
char
*
new_context
);
...
...
controller/controller/controller_block_trace.c
View file @
99329e9e
...
...
@@ -26,6 +26,7 @@
#include
<string.h>
#include
<controller/controller_block.h>
#include
<controller/controller_time.h>
#include
<log/log.h>
static
int
nr_traces
=
0
;
...
...
controller/controller/controller_sample.c
View file @
99329e9e
...
...
@@ -272,6 +272,7 @@ static void wait_next_default(struct timespec *t)
uint64_t
tnow
=
timestamp
();
if
(
sample_timing_sane
(
controller_time_nseconds
,
tnow
))
{
controller_block_skip
((
int64_t
)(
tnow
-
controller_time_nseconds
)
/
nsec_interval
);
clock_gettime
(
sample_clock
,
t
);
t
->
tv_nsec
-=
(
t
->
tv_nsec
%
nsec_interval
);
log_send
(
LOG_T_WARNING
,
...
...
@@ -299,6 +300,7 @@ static void wait_next_prestart(struct timespec *t)
uint64_t
tnow
=
timestamp
();
if
(
sample_timing_sane
(
controller_time_nseconds
,
tnow
))
{
controller_block_skip
((
int64_t
)(
tnow
-
controller_time_nseconds
)
/
nsec_interval
);
clock_gettime
(
sample_clock
,
t
);
t
->
tv_nsec
-=
(
t
->
tv_nsec
%
nsec_interval
);
log_send
(
LOG_T_WARNING
,
...
...
@@ -496,18 +498,6 @@ int controller_sample_shell_add(void)
}
//TODO deprecated
double
controller_sample_period
(
struct
controller_block
*
block
)
{
struct
controller_time
*
t
=
NULL
;
if
(
block
)
t
=
block
->
time
;
log_send
(
LOG_T_WARNING
,
"controller_sample_period() is deprecated!"
);
return
controller_time_period_get
(
t
);
}
void
controller_sample_start_hook
(
void
(
*
func
)(
void
*
arg
),
void
*
arg
)
{
controller_sample_start_hooks
=
realloc
(
...
...
controller/controller/controller_time.c
View file @
99329e9e
...
...
@@ -20,6 +20,12 @@
#include
<stdlib.h>
#include
<math.h>
uint64_t
controller_time_nseconds
=
0
;
uint32_t
controller_time_seconds
=
0
;
uint32_t
controller_time_samplenr
=
0
;
uint32_t
controller_samplenr
=
0
;
struct
controller_time
{
double
frequency
;
double
delay
;
...
...
controller/controller/controller_time.h
View file @
99329e9e
...
...
@@ -19,6 +19,16 @@
#define _INCLUDE_CONTROLLER_TIME_H_
#include
<stdbool.h>
#include
<stdint.h>
/* 64bit continuous counter */
extern
uint64_t
controller_time_nseconds
;
extern
uint32_t
controller_time_seconds
;
extern
uint32_t
controller_time_samplenr
;
extern
uint32_t
controller_samplenr
;
void
controller_time_param_set
(
double
frequency
,
double
delay
);
...
...
controller/test/block_test_command.c
View file @
99329e9e
...
...
@@ -23,6 +23,7 @@
#include
<controller/controller_block.h>
#include
<controller/controller_command.h>
#include
<controller/controller_time.h>
#include
<test/test_block.h>
#include
<log/log.h>
...
...
Write
Preview
Supports
Markdown
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