solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit c6b00d83262a6dbccbd88e18efb355dc234174dc
parent 12b8c7329e89f5d0d0c61780f7298d5edc4894e3
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Mon,  6 Feb 2017 14:07:09 +0100

Issue #16: misnaming of 2 axis pivots.

Diffstat:
Msrc/parser/solparser.c | 76++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/parser/solparser.h | 6+++---
Msrc/parser/solparser_entity.h | 4++--
Msrc/parser/solparser_pivot.h | 16++++++++--------
Msrc/parser/test_solparser3.c | 14+++++++-------
Msrc/solstice_entity.c | 22+++++++++++-----------
6 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/src/parser/solparser.c b/src/parser/solparser.c @@ -151,10 +151,10 @@ struct target_alias { #define DARRAY_FUNCTOR_INIT solparser_x_pivot_init #include <rsys/dynamic_array.h> -/* Declare the array of xz_pivots */ -#define DARRAY_NAME xz_pivot -#define DARRAY_DATA struct solparser_xz_pivot -#define DARRAY_FUNCTOR_INIT solparser_xz_pivot_init +/* Declare the array of zx_pivots */ +#define DARRAY_NAME zx_pivot +#define DARRAY_DATA struct solparser_zx_pivot +#define DARRAY_FUNCTOR_INIT solparser_zx_pivot_init #include <rsys/dynamic_array.h> /* Declare the hash table that maps the address of a YAML node to the id of its @@ -207,7 +207,7 @@ struct solparser { /* Miscellaneous */ struct darray_anchor anchors; struct darray_x_pivot x_pivots; - struct darray_xz_pivot xz_pivots; + struct darray_zx_pivot zx_pivots; ref_T ref; struct mem_allocator* allocator; @@ -236,10 +236,10 @@ parse_x_pivot struct solparser_pivot_id* out_isolpivot); static res_T -parse_xz_pivot +parse_zx_pivot (struct solparser* parser, yaml_document_t* doc, - const yaml_node_t* xz_pivot, + const yaml_node_t* zx_pivot, struct solparser_pivot_id* out_isolpivot); static res_T @@ -404,7 +404,7 @@ parser_clear(struct solparser* parser) /* Miscellaneous */ darray_anchor_clear(&parser->anchors); darray_x_pivot_clear(&parser->x_pivots); - darray_xz_pivot_clear(&parser->xz_pivots); + darray_zx_pivot_clear(&parser->zx_pivots); } static void @@ -454,7 +454,7 @@ parser_release(ref_T* ref) /* Miscellaneous */ darray_anchor_release(&parser->anchors); darray_x_pivot_release(&parser->x_pivots); - darray_xz_pivot_release(&parser->xz_pivots); + darray_zx_pivot_release(&parser->zx_pivots); MEM_RM(parser->allocator, parser); } @@ -2561,10 +2561,10 @@ parse_entity SETUP_MASK(DATA, "data"); solent.type = SOLPARSER_ENTITY_X_PIVOT; res = parse_x_pivot(parser, doc, val, &solent.data.x_pivot); - } else if(!strcmp((char*) key->data.scalar.value, "xz_pivot")) { + } else if(!strcmp((char*) key->data.scalar.value, "zx_pivot")) { SETUP_MASK(DATA, "data"); - solent.type = SOLPARSER_ENTITY_XZ_PIVOT; - res = parse_xz_pivot(parser, doc, val, &solent.data.xz_pivot); + solent.type = SOLPARSER_ENTITY_ZX_PIVOT; + res = parse_zx_pivot(parser, doc, val, &solent.data.zx_pivot); } else if(!strcmp((char*)key->data.scalar.value, "transform")) { SETUP_MASK(TRANSFORM, "transform"); res = parse_transform @@ -2880,53 +2880,53 @@ error: } static res_T -parse_xz_pivot +parse_zx_pivot (struct solparser* parser, yaml_document_t* doc, - const yaml_node_t* xz_pivot, + const yaml_node_t* zx_pivot, struct solparser_pivot_id* out_isolpivot) { enum { SPACING, REF_POINT, TARGET }; - struct solparser_xz_pivot* solxzpivot = NULL; + struct solparser_zx_pivot* solxzpivot = NULL; size_t isolpivot = SIZE_MAX; int mask = 0; /* Register the parsed attributes */ intptr_t i, n; res_T res = RES_OK; - ASSERT(doc && xz_pivot && out_isolpivot); + ASSERT(doc && zx_pivot && out_isolpivot); - if(xz_pivot->type != YAML_MAPPING_NODE) { - log_err(parser, xz_pivot, "expect a xz_pivot definition.\n"); + if(zx_pivot->type != YAML_MAPPING_NODE) { + log_err(parser, zx_pivot, "expect a zx_pivot definition.\n"); res = RES_BAD_ARG; goto error; } /* Allocate the solstice pivot */ - isolpivot = darray_xz_pivot_size_get(&parser->xz_pivots); - res = darray_xz_pivot_resize(&parser->xz_pivots, isolpivot + 1); + isolpivot = darray_zx_pivot_size_get(&parser->zx_pivots); + res = darray_zx_pivot_resize(&parser->zx_pivots, isolpivot + 1); if(res != RES_OK) { - log_err(parser, xz_pivot, "could not allocate the xz_pivot.\n"); + log_err(parser, zx_pivot, "could not allocate the zx_pivot.\n"); res = RES_BAD_ARG; goto error; } - solxzpivot = darray_xz_pivot_data_get(&parser->xz_pivots) + isolpivot; + solxzpivot = darray_zx_pivot_data_get(&parser->zx_pivots) + isolpivot; - n = xz_pivot->data.mapping.pairs.top - xz_pivot->data.mapping.pairs.start; + n = zx_pivot->data.mapping.pairs.top - zx_pivot->data.mapping.pairs.start; FOR_EACH(i, 0, n) { yaml_node_t* key; yaml_node_t* val; - key = yaml_document_get_node(doc, xz_pivot->data.mapping.pairs.start[i].key); + key = yaml_document_get_node(doc, zx_pivot->data.mapping.pairs.start[i].key); val = yaml_document_get_node( - doc, xz_pivot->data.mapping.pairs.start[i].value); + doc, zx_pivot->data.mapping.pairs.start[i].value); if(key->type != YAML_SCALAR_NODE) { - log_err(parser, key, "expect xz_pivot parameters.\n"); + log_err(parser, key, "expect zx_pivot parameters.\n"); res = RES_BAD_ARG; goto error; } #define SETUP_MASK(Flag, Name) { \ if(mask & BIT(Flag)) { \ log_err(parser, key, \ - "the xz_pivot parameter `"Name"' is already defined.\n"); \ + "the zx_pivot parameter `"Name"' is already defined.\n"); \ res = RES_BAD_ARG; \ goto error; \ } \ @@ -2942,11 +2942,11 @@ parse_xz_pivot } else if(!strcmp((char*) key->data.scalar.value, "target")) { struct solparser_pivot_id pivot_id; pivot_id.i = - (size_t) (solxzpivot - darray_xz_pivot_cdata_get(&parser->xz_pivots)); + (size_t) (solxzpivot - darray_zx_pivot_cdata_get(&parser->zx_pivots)); SETUP_MASK(TARGET, "target"); res = parse_target(parser, doc, val, &solxzpivot->target, pivot_id); } else { - log_err(parser, key, "unknown xz_pivot parameter `%s'.\n", + log_err(parser, key, "unknown zx_pivot parameter `%s'.\n", key->data.scalar.value); res = RES_BAD_ARG; goto error; @@ -2959,8 +2959,8 @@ parse_xz_pivot } #define CHECK_PARAM(Flag, Name) \ if(!(mask & BIT(Flag))) { \ - log_err(parser, xz_pivot, \ - "the xz_pivot parameter `"Name"' is missing.\n"); \ + log_err(parser, zx_pivot, \ + "the zx_pivot parameter `"Name"' is missing.\n"); \ res = RES_BAD_ARG; \ goto error; \ } (void)0 @@ -2982,7 +2982,7 @@ exit: return res; error: if(solxzpivot) { - darray_xz_pivot_pop_back(&parser->xz_pivots); + darray_zx_pivot_pop_back(&parser->zx_pivots); isolpivot = SIZE_MAX; } goto exit; @@ -3359,7 +3359,7 @@ solparser_create /* Anchors and pivot(2)s */ darray_anchor_init(mem_allocator, &parser->anchors); darray_x_pivot_init(mem_allocator, &parser->x_pivots); - darray_xz_pivot_init(mem_allocator, &parser->xz_pivots); + darray_zx_pivot_init(mem_allocator, &parser->zx_pivots); exit: *out_parser = parser; @@ -3698,13 +3698,13 @@ solparser_get_x_pivot return darray_x_pivot_cdata_get(&parser->x_pivots) + x_pivot.i; } -const struct solparser_xz_pivot* -solparser_get_xz_pivot +const struct solparser_zx_pivot* +solparser_get_zx_pivot (const struct solparser* parser, - const struct solparser_pivot_id xz_pivot) + const struct solparser_pivot_id zx_pivot) { - ASSERT(parser && xz_pivot.i < darray_xz_pivot_size_get(&parser->xz_pivots)); - return darray_xz_pivot_cdata_get(&parser->xz_pivots) + xz_pivot.i; + ASSERT(parser && zx_pivot.i < darray_zx_pivot_size_get(&parser->zx_pivots)); + return darray_zx_pivot_cdata_get(&parser->zx_pivots) + zx_pivot.i; } const struct solparser_shape* diff --git a/src/parser/solparser.h b/src/parser/solparser.h @@ -122,10 +122,10 @@ solparser_get_x_pivot (const struct solparser* parser, const struct solparser_pivot_id x_pivot); -extern LOCAL_SYM const struct solparser_xz_pivot* -solparser_get_xz_pivot +extern LOCAL_SYM const struct solparser_zx_pivot* +solparser_get_zx_pivot (const struct solparser* parser, - const struct solparser_pivot_id xz_pivot); + const struct solparser_pivot_id zx_pivot); extern LOCAL_SYM const struct solparser_shape* solparser_get_shape diff --git a/src/parser/solparser_entity.h b/src/parser/solparser_entity.h @@ -30,7 +30,7 @@ enum solparser_entity_type { SOLPARSER_ENTITY_EMPTY, SOLPARSER_ENTITY_GEOMETRY, SOLPARSER_ENTITY_X_PIVOT, - SOLPARSER_ENTITY_XZ_PIVOT + SOLPARSER_ENTITY_ZX_PIVOT }; struct solparser_entity_id { size_t i; }; @@ -68,7 +68,7 @@ struct solparser_entity { union { struct solparser_geometry_id geometry; struct solparser_pivot_id x_pivot; - struct solparser_pivot_id xz_pivot; + struct solparser_pivot_id zx_pivot; } data; /* Internal data. Should not be acceded directly. */ diff --git a/src/parser/solparser_pivot.h b/src/parser/solparser_pivot.h @@ -98,23 +98,23 @@ solparser_x_pivot_init ASSERT(x_pivot); *x_pivot = SOLPARSER_X_PIVOT_NULL; } -struct solparser_xz_pivot { +struct solparser_zx_pivot { double spacing; double ref_point[3]; struct solparser_target target; }; -#define SOLPARSER_XZ_PIVOT_NULL__ { 0, {0,0,0}, SOLPARSER_TARGET_NULL__ } -static const struct solparser_xz_pivot SOLPARSER_XZ_PIVOT_NULL = - SOLPARSER_XZ_PIVOT_NULL__; +#define SOLPARSER_zx_PIVOT_NULL__ { 0, {0,0,0}, SOLPARSER_TARGET_NULL__ } +static const struct solparser_zx_pivot SOLPARSER_zx_PIVOT_NULL = + SOLPARSER_zx_PIVOT_NULL__; static INLINE void -solparser_xz_pivot_init - (struct mem_allocator* allocator, struct solparser_xz_pivot* xz_pivot) +solparser_zx_pivot_init + (struct mem_allocator* allocator, struct solparser_zx_pivot* zx_pivot) { (void) allocator; - ASSERT(xz_pivot); - *xz_pivot = SOLPARSER_XZ_PIVOT_NULL; + ASSERT(zx_pivot); + *zx_pivot = SOLPARSER_zx_PIVOT_NULL; } #endif /* SOLPARSER_PIVOT_H */ diff --git a/src/parser/test_solparser3.c b/src/parser/test_solparser3.c @@ -56,7 +56,7 @@ static const char* input[] = { " target: { anchor: \"entity0.entity0b.anchor0\" }\n", "- entity:\n", " name: entity2\n", - " xz_pivot:\n", + " zx_pivot:\n", " spacing: 1\n", " ref_point: [1, 2, 3]\n", " target: { anchor: \"entity0.entity0b.anchor0\" }\n", @@ -69,7 +69,7 @@ const struct solparser_anchor* entity0_entity0b_anchor0; const struct solparser_anchor* entity0_entity0b_entity0b; const struct solparser_geometry* geom; const struct solparser_x_pivot* x_pivot; -const struct solparser_xz_pivot* xz_pivot; +const struct solparser_zx_pivot* zx_pivot; static void check_entity0 @@ -200,14 +200,14 @@ check_entity2 NCHECK(entity2, NULL); CHECK(strcmp(str_cget(&entity2->name), "entity2"), 0); - CHECK(entity2->type, SOLPARSER_ENTITY_XZ_PIVOT); + CHECK(entity2->type, SOLPARSER_ENTITY_ZX_PIVOT); CHECK(solparser_entity_get_anchors_count(entity2), 0); CHECK(solparser_entity_get_children_count(entity2), 0); - xz_pivot = solparser_get_xz_pivot(parser, entity2->data.xz_pivot); - CHECK(xz_pivot->spacing, 1); - CHECK(d3_eq(xz_pivot->ref_point, d3(tmp, 1, 2, 3)), 1); - CHECK(xz_pivot->target.type, SOLPARSER_TARGET_ANCHOR); + zx_pivot = solparser_get_zx_pivot(parser, entity2->data.zx_pivot); + CHECK(zx_pivot->spacing, 1); + CHECK(d3_eq(zx_pivot->ref_point, d3(tmp, 1, 2, 3)), 1); + CHECK(zx_pivot->target.type, SOLPARSER_TARGET_ANCHOR); } int diff --git a/src/solstice_entity.c b/src/solstice_entity.c @@ -158,39 +158,39 @@ error: } static struct solstice_node* -create_xz_pivot_node +create_zx_pivot_node (struct solstice* solstice, const struct solparser_entity* entity) { struct solstice_node* node = NULL; struct solstice_node* target = NULL; - const struct solparser_xz_pivot* parser_xz_pivot = NULL; + const struct solparser_zx_pivot* parser_zx_pivot = NULL; struct sanim_pivot anim_pivot = SANIM_PIVOT_NULL; struct sanim_tracking anim_tracking = SANIM_TRACKING_NULL; res_T res = RES_OK; ASSERT(solstice && entity); - parser_xz_pivot = solparser_get_xz_pivot(solstice->parser, entity->data.xz_pivot); + parser_zx_pivot = solparser_get_zx_pivot(solstice->parser, entity->data.zx_pivot); anim_pivot.type = PIVOT_TWO_AXIS; - anim_pivot.data.pivot2.spacing = parser_xz_pivot->spacing; - d3_set(anim_pivot.data.pivot2.ref_point, parser_xz_pivot->ref_point); + anim_pivot.data.pivot2.spacing = parser_zx_pivot->spacing; + d3_set(anim_pivot.data.pivot2.ref_point, parser_zx_pivot->ref_point); /* Setup the tracking descriptor */ - switch (parser_xz_pivot->target.type) { + switch (parser_zx_pivot->target.type) { case SOLPARSER_TARGET_ANCHOR: anim_tracking.policy = TRACKING_NODE_TARGET; target = *htable_anchor_find - (&solstice->anchors, &parser_xz_pivot->target.data.anchor.i); + (&solstice->anchors, &parser_zx_pivot->target.data.anchor.i); solstice_node_target_get_tracking(target, &anim_tracking); break; case SOLPARSER_TARGET_DIRECTION: anim_tracking.policy = TRACKING_OUT_DIR; - d3_set(anim_tracking.data.out_dir.u, parser_xz_pivot->target.data.direction); + d3_set(anim_tracking.data.out_dir.u, parser_zx_pivot->target.data.direction); break; case SOLPARSER_TARGET_POSITION: anim_tracking.policy = TRACKING_POINT; - d3_set(anim_tracking.data.point.target, parser_xz_pivot->target.data.position); + d3_set(anim_tracking.data.point.target, parser_zx_pivot->target.data.position); anim_tracking.data.point.target_is_local = 0; /* TODO */ break; case SOLPARSER_TARGET_SUN: @@ -239,8 +239,8 @@ create_node(struct solstice* solstice, const struct solparser_entity* entity) case SOLPARSER_ENTITY_X_PIVOT: node = create_x_pivot_node(solstice, entity); break; - case SOLPARSER_ENTITY_XZ_PIVOT: - node = create_xz_pivot_node(solstice, entity); + case SOLPARSER_ENTITY_ZX_PIVOT: + node = create_zx_pivot_node(solstice, entity); break; default: FATAL("Unreachable code.\n"); break; }