solstice

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

solparser_mtl_data.c (1835B)


      1 /* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2016-2018 CNRS
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     16 
     17 #include "solparser_c.h"
     18 
     19 /*******************************************************************************
     20  * Local function
     21  ******************************************************************************/
     22 res_T
     23 parse_mtl_data
     24   (struct solparser* parser,
     25    yaml_document_t* doc,
     26    yaml_node_t* mtl_data,
     27    const double lower_bound,
     28    const double upper_bound,
     29    struct solparser_mtl_data* data)
     30 {
     31   res_T res = RES_OK;
     32   ASSERT(doc && mtl_data && data);
     33 
     34   if(mtl_data->type == YAML_SCALAR_NODE) {
     35     data->type = SOLPARSER_MTL_DATA_REAL;
     36     res = parse_real
     37       (parser, mtl_data, lower_bound, upper_bound, &data->value.real);
     38   } else if(mtl_data->type == YAML_SEQUENCE_NODE) {
     39     data->type = SOLPARSER_MTL_DATA_SPECTRUM;
     40     res = parse_spectrum
     41       (parser, doc, mtl_data, lower_bound, upper_bound, &data->value.spectrum);
     42   } else {
     43     log_err(parser, mtl_data, "expect a real or a spectrum definition.\n");
     44     res = RES_BAD_ARG;
     45     goto error;
     46   }
     47   if(res != RES_OK) {
     48     log_node(parser, mtl_data);
     49     goto error;
     50   }
     51 
     52 exit:
     53   return res;
     54 error:
     55   goto exit;
     56 }
     57