elemy-sensortree 1.0.0
Macros | Functions | Variables
el_sensortree.c File Reference
#include <sys/types.h>
#include "stdint.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
#include <argp.h>
#include <unistd.h>
#include "elutils/el_utils.h"
#include "elsensortree/el_sensorsnode.h"
#include "elsensortree/el_sensortree.h"
Include dependency graph for el_sensortree.c:

Macros

#define _GNU_SOURCE
 

Functions

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 int _st_find_node_child (st_tree_t *tree, int node, node_addr_t addr, ST_NODES_ADD add)
 internal search addr in node More...
 
int st_find_node (st_tree_t *tree, node_addr_t addr, ST_NODES_ADD add)
 find node with address More...
 
static void _st_del_node_children (st_tree_t *tree, int node)
 delete children (with sub children) of node 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

static uint16_t _st_node_masks [] = { 0x000f, 0x00f0, 0x0f00, 0xf000 }
 
static uint16_t _st_tot_masks [] = { 0x000f, 0x00ff, 0x0fff, 0xffff }
 

Detailed Description

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

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Function Documentation

◆ _st_del_node_children()

static void _st_del_node_children ( st_tree_t tree,
int  node 
)
static

delete children (with sub children) of node

Parameters
treeST ptr
nodeindex of node.

Delete children of node, as result child == 0

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _st_find_node_child()

static int _st_find_node_child ( st_tree_t tree,
int  node,
node_addr_t  addr,
ST_NODES_ADD  add 
)
static

internal search addr in node

Parameters
tree- memory area with tree
node- node in tree in which children search addr
addr- addr to search
add- if (add) add ansent node else return 0;
Returns
node index of node which found or 0 if not find and no free node to assign
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _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_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

◆ _st_node_masks

uint16_t _st_node_masks[] = { 0x000f, 0x00f0, 0x0f00, 0xf000 }
static

◆ _st_tot_masks

uint16_t _st_tot_masks[] = { 0x000f, 0x00ff, 0x0fff, 0xffff }
static