From: Thibaut VARÈNE Date: 2022年5月31日 10:37:23 +0000 (+0200) Subject: PME-PMI: working parser X-Git-Tag: v2.3~5 X-Git-Url: http://vcs.slashdirt.org/git/?a=commitdiff_plain;h=52311e35bfc0cc0c8f8d5eb09015a32d8a47d207;p=sw%2Ftic2json.git PME-PMI: working parser --- diff --git a/src/tic.c b/src/tic.c index 016ec00..debda43 100644 --- a/src/tic.c +++ b/src/tic.c @@ -2,7 +2,7 @@ // tic.c // Common routines for TIC parsers // -// (C) 2021 Thibaut VARENE +// (C) 2021-2022 Thibaut VARENE // License: GPLv2 - http://www.gnu.org/licenses/gpl-2.0.html // @@ -29,6 +29,8 @@ void make_field(struct tic_field *field, const struct tic_etiquette *etiq, char memcpy(&field->etiq, etiq, sizeof(field->etiq)); switch ((etiq->unittype & 0xF0)) { + case T_IGN: + return; case T_STRING: field->data.s = data; return; diff --git a/src/tic.h b/src/tic.h index ff60db1..6fcdb6f 100644 --- a/src/tic.h +++ b/src/tic.h @@ -2,7 +2,7 @@ // tic.h // Interface for TIC parsers // -// (C) 2021 Thibaut VARENE +// (C) 2021-2022 Thibaut VARENE // License: GPLv2 - http://www.gnu.org/licenses/gpl-2.0.html // @@ -32,16 +32,20 @@ /** * TIC units. - * @warning The code assumes this fits on 4 bits + * @warning The code assumes this fits on 4 bits (16 values) */ enum tic_unit { U_SANS = 0x00, + U_VAH, + U_KWH, U_WH, + U_KVARH, U_VARH, U_A, U_V, U_KVA, U_VA, + U_KW, U_W, U_MIN, U_DAL, @@ -55,6 +59,8 @@ enum tic_unit { enum data_type { T_STRING = 0x10, T_HEX = 0x20, + T_DATE = 0x30, + T_IGN = 0x40, }; /** Internal parser representation of a TIC etiquette */ diff --git a/src/ticv01pme.y b/src/ticv01pme.y new file mode 100644 index 0000000..04b727f --- /dev/null +++ b/src/ticv01pme.y @@ -0,0 +1,221 @@ +// +// ticv01pme.y +// A parser for ENEDIS TIC version 01 protocol +// +// (C) 2022 Thibaut VARENE +// License: GPLv2 - http://www.gnu.org/licenses/gpl-2.0.html +// +// Development of this file was sponsored by Wiztivi - www.wiztivi.com + +/** + * @file + * This parser implements a complete grammar that supports TIC version 01 - PME-PMI variant + * as specified in Enedis-NOI-CPT_02E.pdf version 6. + * + * This parser does not allocate memory, except if a filter configuration is used in + * which case the etiq_en array will be allocated (it's a few hundred bytes). + * A left-recursion grammar has been implemented to keep the memory usage to the bare + * minimum as well. As a tradeoff, valid datasets are always emitted regardless of the + * overall status of the containing frame. + * + * Compteurs supportés: + * - PME-PMI (tous paliers) + * + * Certains champs ne sont actuellement pas supportés par ce code: ils ne sont pas émis. + * Il s'agit des champs relatifs à la tarification dynamique et aux mesures de tangente phi. + * Me contacter pour implémentation: + * - ETATDYN1 PREAVIS1 TDYN1CD TDYN1CF TDYN1FD TDYN1FF + * - ETATDYN2 PREAVIS2 TDYN2CD TDYN2CF TDYN2FD TDYN2FF + * - TGPHI_s TGPHI_i + */ + +%{ +#include +#include "tic.h" + +int ticv01pmeyylex(); +int ticv01pmeyylex_destroy(); +extern FILE *ticv01pmeyyin; +static void yyerror(const char *); + +extern bool filter_mode; +extern bool *etiq_en; +%} + +%union { + char *text; + const char *label; + struct tic_etiquette etiq; + struct tic_field field; +} + +%verbose + +%token TOK_STX TOK_ETX TOK_EOT TOK_SEP +%token FIELD_START FIELD_OK FIELD_KO +%token TICFILTER +%token ET_IGNORED + +%token TOK_DATA TOK_HDATE + +%token