elemy-sensortree 1.0.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
el_sensortree.h File Reference
#include "elsensortree/el_sensorsnode.h"
#include "elutils/c_decls.h"
Include dependency graph for el_sensortree.h:
This graph shows which files directly or indirectly include this file:

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
 

Detailed Description

Created on: 10 нояб. 2023 г. Author: ps

Macro Definition Documentation

◆ ST_TREE_NODES

#define ST_TREE_NODES (   ST_TREE_SIZE)    ((int)((ST_TREE_SIZE - sizeof(st_tree_t))/sizeof(tree_node_t)))

◆ ST_TREE_SIZE

#define ST_TREE_SIZE (   NODES)    (sizeof(tree_node_t) * NODES + sizeof(st_tree_t))

◆ TREE_NODE

#define TREE_NODE (   TREE,
  NODE 
)    (TREE->nodes[NODE])

◆ TREE_NODE_ADDR

#define TREE_NODE_ADDR (   TREE,
  NODE 
)    (TREE->nodes[NODE].addr)

Typedef Documentation

◆ p_tree_node

typedef tree_node_t* p_tree_node

◆ st_tree_t

typedef struct _st_tree_t st_tree_t

node with addr 0 - WRONG NODE with specialmean. used for impasse

◆ st_tree_walk_t

struct to walk through

Enumeration Type Documentation

◆ ST_NODES_ADD

Enumerator
ST_NODES_NOT_ADD 
ST_NODES_DO_ADD 

Function Documentation

◆ __attribute__()

__BEGIN_DECLS struct _tree_node __attribute__ ( (packed)  )

SensorTree ST in shared memory allocated pool of tree_node

!!! all works with ptr to struct

◆ _st_get_free()

int _st_get_free ( st_tree_t tree)

get free node from list.

Returns
free node ndx or 0 if absent
Here is the caller graph for this function:

◆ el_st_say()

void el_st_say ( void  )

first function in library. ащк тще уьзкн дшиекфкн

◆ st_add_free()

static void st_add_free ( st_tree_t tree,
int  node 
)
inlinestatic
Here is the caller graph for this function:

◆ st_del_node()

void st_del_node ( st_tree_t tree,
node_addr_t  addr 
)

delete node and empty upper

Parameters
treeST ptr
addraddress of node
Here is the call graph for this function:

◆ st_find_node()

int st_find_node ( st_tree_t tree,
node_addr_t  addr,
ST_NODES_ADD  add 
)

find node with address

Parameters
treeptr to sensorstree area
addraddress of node to find
addif 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

Returns
index if addressed node is found. or 0 if absent free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st_init()

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.

Here is the caller graph for this function:

◆ st_list_tree()

void st_list_tree ( st_tree_t tree,
int  num 
)

print num nodes from node's pool

Parameters
treeST ptr
numnumber of nodes to print
Here is the call graph for this function:

◆ st_print_tree()

void st_print_tree ( st_tree_t tree,
node_addr_t  addr 
)
Here is the call graph for this function:

◆ st_sn_get()

sensors_node_t * st_sn_get ( st_tree_t tree,
sensors_node_t *  s_node,
node_addr_t  addr 
)

SensorTree_SensorNode_GET.

Parameters
treeptr to tree struct
s_nodeptr to sensors node data
addraddress for node
Returns
ptr to sensor node data on success; NULL on error (absent node with this address)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st_sn_set()

int st_sn_set ( st_tree_t tree,
sensors_node_t *  s_node,
node_addr_t  addr 
)

SensorTree_SensorNode_SET.

Parameters
treesensors nodes tree
s_nodeSENSOR node
addraddress of SENSOR node
Returns
1 - successfully set; 0 - not set (cannot find TREE node with address)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st_tree_node()

void st_tree_node ( st_tree_t tree,
int  node,
char *  msg 
)

print tree info of node

Here is the caller graph for this function:

◆ st_tree_walk()

int st_tree_walk ( st_tree_walk_t walker)

walk through tree starting with node addr, walk though childs and lower

Parameters
walkerstruct with walker data for continious walking
Returns
next node, or 0 as end
Here is the call graph for this function:
Here is the caller graph for this function:

◆ st_tree_walk_prepare()

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.

Parameters
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:

  1. init walker.
  2. call st_tree_walk() serially until get 0
Here is the caller graph for this function:

Variable Documentation

◆ addr

◆ child

int child

ndxs of children

◆ lvl

int lvl

◆ next

int next

ndxs of prev and nect on same level where .0. is upper level (parent) Also used in free nodes list

◆ nn

int nn

◆ node

sensors_node_t node

◆ parent

int parent

NodeNumber.

parent ndx

◆ prev

int prev