elemy-sensortree 1.0.0
|
Go to the source code of this file.
Data Structures | |
struct | _tree_node |
struct | _st_tree_t |
struct | _st_tree_walk_t |
Macros | |
#define | TREE_NODE(TREE, NODE) (TREE->nodes[NODE]) |
#define | TREE_NODE_ADDR(TREE, NODE) (TREE->nodes[NODE].addr) |
#define | ST_TREE_SIZE(NODES) (sizeof(tree_node_t) * NODES + sizeof(st_tree_t)) |
#define | ST_TREE_NODES(ST_TREE_SIZE) ((int)((ST_TREE_SIZE - sizeof(st_tree_t))/sizeof(tree_node_t))) |
Typedefs | |
typedef tree_node_t * | p_tree_node |
typedef struct _st_tree_t | st_tree_t |
typedef struct _st_tree_walk_t | st_tree_walk_t |
Enumerations | |
enum | ST_NODES_ADD { ST_NODES_NOT_ADD = 0 , ST_NODES_DO_ADD } |
Functions | |
__BEGIN_DECLS struct _tree_node | __attribute__ ((packed)) tree_node_t |
void | st_init (st_tree_t *tree, int count) |
initialize memory area for using as tree More... | |
int | _st_get_free (st_tree_t *tree) |
get free node from list. More... | |
static void | st_add_free (st_tree_t *tree, int node) |
int | st_find_node (st_tree_t *tree, node_addr_t addr, ST_NODES_ADD add) |
find node with address More... | |
void | st_del_node (st_tree_t *tree, node_addr_t addr) |
delete node and empty upper More... | |
void | st_tree_walk_prepare (st_tree_t *tree, st_tree_walk_t *walker, node_addr_t addr) |
init walker struct for walking through tree. More... | |
int | st_tree_walk (st_tree_walk_t *walker) |
walk through tree starting with node addr, walk though childs and lower More... | |
int | st_sn_set (st_tree_t *tree, sensors_node_t *s_node, node_addr_t addr) |
SensorTree_SensorNode_SET. More... | |
sensors_node_t * | st_sn_get (st_tree_t *tree, sensors_node_t *s_node, node_addr_t addr) |
SensorTree_SensorNode_GET. More... | |
void | st_print_tree (st_tree_t *tree, node_addr_t addr) |
void | st_tree_node (st_tree_t *tree, int node, char *msg) |
print tree info of node More... | |
void | st_list_tree (st_tree_t *tree, int num) |
print num nodes from node's pool More... | |
void | el_st_say (void) |
first function in library. ащк тще уьзкн дшиекфкн More... | |
Variables | |
int | nn |
int | parent |
NodeNumber. More... | |
int | prev |
int | next |
ndxs of prev and nect on same level where .0. is upper level (parent) Also used in free nodes list More... | |
int | child |
ndxs of children More... | |
int | lvl |
node_addr_t | addr |
sensors_node_t | node |
Created on: 10 нояб. 2023 г. Author: ps
#define ST_TREE_NODES | ( | ST_TREE_SIZE | ) | ((int)((ST_TREE_SIZE - sizeof(st_tree_t))/sizeof(tree_node_t))) |
#define ST_TREE_SIZE | ( | NODES | ) | (sizeof(tree_node_t) * NODES + sizeof(st_tree_t)) |
#define TREE_NODE | ( | TREE, | |
NODE | |||
) | (TREE->nodes[NODE]) |
typedef tree_node_t* p_tree_node |
typedef struct _st_tree_t st_tree_t |
node with addr 0 - WRONG NODE with specialmean. used for impasse
typedef struct _st_tree_walk_t st_tree_walk_t |
struct to walk through
enum ST_NODES_ADD |
__BEGIN_DECLS struct _tree_node __attribute__ | ( | (packed) | ) |
SensorTree ST in shared memory allocated pool of tree_node
!!! all works with ptr to struct
int _st_get_free | ( | st_tree_t * | tree | ) |
get free node from list.
void el_st_say | ( | void | ) |
first function in library. ащк тще уьзкн дшиекфкн
|
inlinestatic |
void st_del_node | ( | st_tree_t * | tree, |
node_addr_t | addr | ||
) |
delete node and empty upper
tree | ST ptr |
addr | address of node |
int st_find_node | ( | st_tree_t * | tree, |
node_addr_t | addr, | ||
ST_NODES_ADD | add | ||
) |
find node with address
tree | ptr to sensorstree area |
addr | address of node to find |
add | if ST_NODES_DO_ADD - add not existing nodes, ST_NODES_NOT_ADD - not add nodes, return error (0) |
Find node with address in level of tree. If node not exists - create (include free node into tree). If cannot add node (no free node or smth else) return 0.
possibile addresses xx.yy.zz.ww if xx/yy/zz/ww == 0 - end of search. Another end if all 4 levels done
if (add != 0) add node to tree
void st_init | ( | st_tree_t * | tree, |
int | count | ||
) |
initialize memory area for using as tree
free list is one way list [0]->1; [1]->2; [2]->0;
'0' node is tree root.
void st_list_tree | ( | st_tree_t * | tree, |
int | num | ||
) |
print num nodes from node's pool
tree | ST ptr |
num | number of nodes to print |
void st_print_tree | ( | st_tree_t * | tree, |
node_addr_t | addr | ||
) |
sensors_node_t * st_sn_get | ( | st_tree_t * | tree, |
sensors_node_t * | s_node, | ||
node_addr_t | addr | ||
) |
SensorTree_SensorNode_GET.
tree | ptr to tree struct |
s_node | ptr to sensors node data |
addr | address for node |
int st_sn_set | ( | st_tree_t * | tree, |
sensors_node_t * | s_node, | ||
node_addr_t | addr | ||
) |
SensorTree_SensorNode_SET.
tree | sensors nodes tree |
s_node | SENSOR node |
addr | address of SENSOR node |
void st_tree_node | ( | st_tree_t * | tree, |
int | node, | ||
char * | msg | ||
) |
print tree info of node
int st_tree_walk | ( | st_tree_walk_t * | walker | ) |
walk through tree starting with node addr, walk though childs and lower
walker | struct with walker data for continious walking |
void st_tree_walk_prepare | ( | st_tree_t * | tree, |
st_tree_walk_t * | walker, | ||
node_addr_t | addr | ||
) |
init walker struct for walking through tree.
tree | - ptr to tree to walk |
walker | - struct for walking to prepare |
addr | - start walking addresslevel of start walking compute from address: 0.0.0.0 -> all tree, xx.0.0.0 level 0 and subtree, xx.yy.0.0 level 1 and subtree xx.yy.zz.0 level 2 and subtree xx.yy.zz.ww level 3 one node |
Walking procedure:
node_addr_t addr |
int child |
ndxs of children
int lvl |
int next |
ndxs of prev and nect on same level where .0. is upper level (parent) Also used in free nodes list
int nn |
sensors_node_t node |
int parent |
NodeNumber.
parent ndx
int prev |