Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michel Roelofs
dt_ctrl
Commits
884b320d
Commit
884b320d
authored
Jun 03, 2013
by
Jeroen Vreeken
Browse files
move controller_block.h to common include
parent
360842c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
common/include/controller_block.h
deleted
120000 → 0
View file @
360842c8
..
/
..
/
controller
/
controller
/
controller_block
.
h
\ No newline at end of file
common/include/controller_block.h
0 → 100644
View file @
884b320d
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2007, 2009, 2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2007, 2009, 2013
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _INCLUDE_CONTROLLER_BLOCK_H_
#define _INCLUDE_CONTROLLER_BLOCK_H_
#include
<stddef.h>
#include
<stdint.h>
#include
<stdbool.h>
#include
<math.h>
#include
<pthread.h>
#include
<semaphore.h>
#include
<stdarg.h>
enum
controller_block_term_type
{
CONTROLLER_BLOCK_TERM_VOID
,
/* Special case for checks... do NOT use! */
CONTROLLER_BLOCK_TERM_FLOAT
,
CONTROLLER_BLOCK_TERM_BOOL
,
CONTROLLER_BLOCK_TERM_UINT8
,
CONTROLLER_BLOCK_TERM_UINT16
,
CONTROLLER_BLOCK_TERM_UINT32
,
CONTROLLER_BLOCK_TERM_SINT8
,
CONTROLLER_BLOCK_TERM_SINT16
,
CONTROLLER_BLOCK_TERM_SINT32
,
};
/* Each off the inputs and outputs of the block is described with this struct.
For inputs: the value pointer pointer has to be filled in when building the
network.
For outputs: the value pointer is filled at block creation.
*/
struct
controller_block_outterm
{
char
*
name
;
enum
controller_block_term_type
type
;
union
{
void
*
v
;
float
*
f
;
bool
*
b
;
uint8_t
*
u8
;
uint16_t
*
u16
;
uint32_t
*
u32
;
int8_t
*
s8
;
int16_t
*
s16
;
int32_t
*
s32
;
}
value
;
struct
controller_block
*
source
;
/* terminal of source (if not this one) */
struct
controller_block_outterm
*
sourceterm
;
};
struct
controller_block_interm
{
char
*
name
;
enum
controller_block_term_type
type
;
union
{
void
**
v
;
float
**
f
;
bool
**
b
;
uint8_t
**
u8
;
uint16_t
**
u16
;
uint32_t
**
u32
;
int8_t
**
s8
;
int16_t
**
s16
;
int32_t
**
s32
;
}
value
;
struct
controller_block
*
otherside
;
struct
controller_block_interm
*
ghostof
;
/* link back to owning block */
struct
controller_block
*
block
;
};
/* List of interms which must be created in the block's input pointer.
This structure and its helper functions can only be used for normal
inputs which have no 'ghosts' and which are located in the private
structure.
name: name of the input terminal
type: type of the input terminal
priv_offset: offset within the private structure where the target
pointer is located.
*/
struct
controller_block_interm_list
{
char
*
name
;
enum
controller_block_term_type
type
;
size_t
priv_offset
;
};
/* List of outterms which must be created in the block's output pointer.
This structure and its helper functions can only be used for normal
outputs which have no 'ghosts' and which are located in the private
structure.
name: name of the output terminal
type: type of the output terminal
priv_offset: offset within the private structure where the source
pointer is located.
*/
struct
controller_block_outterm_list
{
char
*
name
;
enum
controller_block_term_type
type
;
size_t
priv_offset
;
};
/* Starting point for a block.
Additional data a block might need can be pointed to by the private pointer.
*/
struct
controller_block
{
char
*
name
;
/* instance name this block */
char
*
type
;
/* generic type of the block */
char
*
context
;
/* Which context 'owns' this block */
/* List of inputs */
int
inputs
;
struct
controller_block_interm
*
input
;
/* List of outputs */
int
outputs
;
struct
controller_block_outterm
*
output
;
/* List of params */
int
params
;
struct
controller_block_param_list
*
param
;
void
(
*
calculate
)(
struct
controller_block
*
);
void
(
*
param_get
)(
struct
controller_block
*
,
int
,
void
*
);
void
(
*
param_set
)(
struct
controller_block
*
,
int
,
va_list
);
/* Incomplete type for private data */
struct
controller_block_private
*
private
;
};
struct
controller_trace
{
void
*
ptr
;
enum
controller_block_term_type
type
;
float
*
buffer
;
size_t
len
;
size_t
wr_pos
;
size_t
rd_pos
;
};
struct
controller_block_link
{
char
*
outblock
;
char
*
outterm
;
char
*
inblock
;
char
*
interm
;
int
chain
;
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
);
int
controller_block_nr
(
void
);
struct
controller_block
*
controller_block_get
(
int
nr
);
struct
controller_block_outterm
*
controller_block_find_outterm
(
struct
controller_block
*
block
,
char
*
output
);
int
controller_block_add_float_input
(
struct
controller_block
*
blk
,
char
*
name
,
float
**
ptr
);
int
controller_block_add_bool_input
(
struct
controller_block
*
blk
,
char
*
name
,
bool
**
ptr
);
int
controller_block_add_sint16_input
(
struct
controller_block
*
blk
,
char
*
name
,
int16_t
**
ptr
);
int
controller_block_add_sint32_input
(
struct
controller_block
*
blk
,
char
*
name
,
int32_t
**
ptr
);
int
controller_block_add_float_output
(
struct
controller_block
*
blk
,
char
*
name
,
float
*
ptr
);
int
controller_block_add_bool_output
(
struct
controller_block
*
blk
,
char
*
name
,
bool
*
ptr
);
int
controller_block_add_uint16_output
(
struct
controller_block
*
blk
,
char
*
name
,
uint16_t
*
ptr
);
int
controller_block_add_sint32_output
(
struct
controller_block
*
blk
,
char
*
name
,
int32_t
*
ptr
);
int
controller_block_add_sint16_output
(
struct
controller_block
*
blk
,
char
*
name
,
int16_t
*
ptr
);
int
controller_block_interm_list_init
(
struct
controller_block
*
block
,
struct
controller_block_interm_list
*
list
);
int
controller_block_outterm_list_init
(
struct
controller_block
*
block
,
struct
controller_block_outterm_list
*
list
);
int
controller_block_output_get_float
(
char
*
block
,
char
*
param
,
float
*
value
);
int
controller_block_connect
(
char
*
outblock
,
char
*
outterm
,
char
*
inblock
,
char
*
interm
,
int
chain
);
int
controller_block_link
(
void
);
struct
controller_block_link
*
controller_block_link_get
(
int
nr
);
int
controller_block_link_nr
(
void
);
int
controller_block_sample_init
(
void
);
void
controller_block_calculate
(
void
);
char
*
controller_block_context_get
(
void
);
void
controller_block_context_set
(
char
*
new_context
);
/* Helper function to create a new block */
struct
controller_block
*
controller_block_alloc
(
char
*
type
,
char
*
name
,
size_t
private_size
);
void
controller_block_free
(
struct
controller_block
*
blk
);
#define RPM2RADS(val) ((val)*2.0*M_PI/60.0)
#define RADS2RPM(val) ((val)*60.0/(2.0*M_PI))
#define DEG2RAD(val) ((val)*2.0*M_PI/360.0)
#define RAD2DEG(val) ((val)*360.0/(2.0*M_PI))
/*
controller_block_param
*/
/* List of params which must be initialized in the block's param pointer */
struct
controller_block_param_list
{
char
*
name
;
bool
sample
;
/* True: all access to params must be 'sample safe' */
};
void
controller_block_param_init
(
void
);
int
controller_block_param_list_init
(
struct
controller_block
*
block
,
struct
controller_block_param_list
*
list
);
int
controller_block_param_set
(
char
*
block
,
char
*
param
,
va_list
);
int
controller_block_param_get
(
char
*
block
,
char
*
param
,
void
*
value
);
void
controller_block_param_handle
(
void
);
/*
controller_block_trace
*/
void
controller_block_trace_init
(
int
max
);
int
controller_block_trace_add
(
char
*
block
,
char
*
outterm
,
struct
controller_trace
*
trace
);
void
controller_block_trace_del
(
struct
controller_trace
*
trace
);
void
controller_block_trace_wait
(
void
);
void
controller_block_trace
(
void
);
#endif
controller/controller/controller_block.h
View file @
884b320d
...
...
@@ -180,6 +180,26 @@ struct controller_block *controller_block_get(int nr);
struct
controller_block_outterm
*
controller_block_find_outterm
(
struct
controller_block
*
block
,
char
*
output
);
int
controller_block_add_float_input
(
struct
controller_block
*
blk
,
char
*
name
,
float
**
ptr
);
int
controller_block_add_bool_input
(
struct
controller_block
*
blk
,
char
*
name
,
bool
**
ptr
);
int
controller_block_add_sint16_input
(
struct
controller_block
*
blk
,
char
*
name
,
int16_t
**
ptr
);
int
controller_block_add_sint32_input
(
struct
controller_block
*
blk
,
char
*
name
,
int32_t
**
ptr
);
int
controller_block_add_float_output
(
struct
controller_block
*
blk
,
char
*
name
,
float
*
ptr
);
int
controller_block_add_bool_output
(
struct
controller_block
*
blk
,
char
*
name
,
bool
*
ptr
);
int
controller_block_add_uint16_output
(
struct
controller_block
*
blk
,
char
*
name
,
uint16_t
*
ptr
);
int
controller_block_add_sint32_output
(
struct
controller_block
*
blk
,
char
*
name
,
int32_t
*
ptr
);
int
controller_block_add_sint16_output
(
struct
controller_block
*
blk
,
char
*
name
,
int16_t
*
ptr
);
int
controller_block_interm_list_init
(
struct
controller_block
*
block
,
struct
controller_block_interm_list
*
list
);
int
controller_block_outterm_list_init
(
struct
controller_block
*
block
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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