elemy-sensortree 1.0.0
|
#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"
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 } |
Created on: 10 нояб. 2023 г. Author: ps
#define _GNU_SOURCE |
|
static |
delete children (with sub children) of node
tree | ST ptr |
node | index of node. |
Delete children of node, as result child == 0
|
static |
internal search addr in node
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; |
int _st_get_free | ( | st_tree_t * | tree | ) |
get free node from list.
void el_st_say | ( | void | ) |
first function in library. ащк тще уьзкн дшиекфкн
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:
|
static |
|
static |