From cc21b55b6883fea01832d41eebe8048c42765993 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Sat, 22 Sep 2018 11:19:05 +0300 Subject: [PATCH] Read and write demand categories names Fixes #290 --- src/inpfile.c | 2 +- src/input3.c | 3 +++ src/types.h | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/inpfile.c b/src/inpfile.c index 1d7c11e..5948f9d 100644 --- a/src/inpfile.c +++ b/src/inpfile.c @@ -333,7 +333,7 @@ int saveinpfile(EN_Project *pr, const char *fname) sprintf(s1, " %s", net->Pattern[j].ID); else strcpy(s1, ""); - fprintf(f, "\n%s %s", s, s1); + fprintf(f, "\n%s %s ;%s", s, s1, demand->Name); } } diff --git a/src/input3.c b/src/input3.c index 58f9ce2..4ba7f04 100644 --- a/src/input3.c +++ b/src/input3.c @@ -111,6 +111,7 @@ int juncdata(EN_Project *pr) } demand->Base = y; demand->Pat = p; + strncpy(demand->Name, "", MAXMSG); demand->next = NULL; node->D = demand; hyd->NodeDemand[Njuncs] = y; @@ -775,6 +776,7 @@ int demanddata(EN_Project *pr) // with what is specified in this section demand->Base = y; demand->Pat = p; + strncpy(demand->Name, par->Comment, MAXMSG); hyd->NodeDemand[j] = MISSING; // marker - next iteration will append a new category. } else { // add new demand to junction @@ -787,6 +789,7 @@ int demanddata(EN_Project *pr) return (101); demand->Base = y; demand->Pat = p; + strncpy(demand->Name, par->Comment, MAXMSG); demand->next = NULL; cur_demand->next = demand; } diff --git a/src/types.h b/src/types.h index 61c2cdb..278d98c 100755 --- a/src/types.h +++ b/src/types.h @@ -359,9 +359,10 @@ typedef struct /* Coord OBJECT */ struct Sdemand /* DEMAND CATEGORY OBJECT */ { - double Base; /* Baseline demand */ - int Pat; /* Pattern index */ - struct Sdemand *next; /* Next record */ + double Base; /* Baseline demand */ + int Pat; /* Pattern index */ + char Name[MAXMSG+1]; /* Demand category name */ + struct Sdemand *next; /* Next record */ }; typedef struct Sdemand *Pdemand; /* Pointer to demand object */