]> vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

vcs.slashdirt.org Git - sw/tic2json.git/commitdiff

git git / sw / tic2json.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e65a513)
tic: disambiguate PME-PMI kVA/kW units
2022年5月31日 13:06:22 +0000 (15:06 +0200)
2022年6月21日 07:37:02 +0000 (09:37 +0200)

diff --git a/src/tic.c b/src/tic.c
index debda4378d5fcdf38584128b84471592723ffe45..009ff1c6e1560481f59547b061a7122c4508739b 100644 (file)
--- a/src/tic.c
+++ b/src/tic.c
@@ -24,6 +24,7 @@ void make_field(struct tic_field *field, const struct tic_etiquette *etiq, char
{
// args come from the bison stack
int base;
+ char *rem;
field->horodate = horodate;
memcpy(&field->etiq, etiq, sizeof(field->etiq));
@@ -41,7 +42,24 @@ void make_field(struct tic_field *field, const struct tic_etiquette *etiq, char
base = 10;
break;
}
- field->data.i = (int)strtol(data, NULL, base);
+ field->data.i = (int)strtol(data, &rem, base);
+
+#ifdef TICV01pme
+ if (U_SANS == etiq->unittype && *data != '0円' && *rem != '0円') {
+ // int sans unit but with a suffix: either kVA or kW - try to disambiguate
+ switch (rem[strlen(rem)-1]) {
+ case 'A':
+ field->etiq.unittype = U_KVA;
+ break;
+ case 'W':
+ field->etiq.unittype = U_KW;
+ break;
+ default:
+ break;
+ }
+ }
+#endif
+
free(data);
}
tic2json TIC parser/converter
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /