Read and write demand categories names

Fixes #290
This commit is contained in:
Elad Salomons
2018-09-22 11:19:05 +03:00
parent 054c48c48a
commit cc21b55b68
3 changed files with 8 additions and 4 deletions

View File

@@ -333,7 +333,7 @@ int saveinpfile(EN_Project *pr, const char *fname)
sprintf(s1, " %s", net->Pattern[j].ID); sprintf(s1, " %s", net->Pattern[j].ID);
else else
strcpy(s1, ""); strcpy(s1, "");
fprintf(f, "\n%s %s", s, s1); fprintf(f, "\n%s %s ;%s", s, s1, demand->Name);
} }
} }

View File

@@ -111,6 +111,7 @@ int juncdata(EN_Project *pr)
} }
demand->Base = y; demand->Base = y;
demand->Pat = p; demand->Pat = p;
strncpy(demand->Name, "", MAXMSG);
demand->next = NULL; demand->next = NULL;
node->D = demand; node->D = demand;
hyd->NodeDemand[Njuncs] = y; hyd->NodeDemand[Njuncs] = y;
@@ -775,6 +776,7 @@ int demanddata(EN_Project *pr)
// with what is specified in this section // with what is specified in this section
demand->Base = y; demand->Base = y;
demand->Pat = p; demand->Pat = p;
strncpy(demand->Name, par->Comment, MAXMSG);
hyd->NodeDemand[j] = MISSING; // marker - next iteration will append a new category. hyd->NodeDemand[j] = MISSING; // marker - next iteration will append a new category.
} }
else { // add new demand to junction else { // add new demand to junction
@@ -787,6 +789,7 @@ int demanddata(EN_Project *pr)
return (101); return (101);
demand->Base = y; demand->Base = y;
demand->Pat = p; demand->Pat = p;
strncpy(demand->Name, par->Comment, MAXMSG);
demand->next = NULL; demand->next = NULL;
cur_demand->next = demand; cur_demand->next = demand;
} }

View File

@@ -361,6 +361,7 @@ struct Sdemand /* DEMAND CATEGORY OBJECT */
{ {
double Base; /* Baseline demand */ double Base; /* Baseline demand */
int Pat; /* Pattern index */ int Pat; /* Pattern index */
char Name[MAXMSG+1]; /* Demand category name */
struct Sdemand *next; /* Next record */ struct Sdemand *next; /* Next record */
}; };
typedef struct Sdemand *Pdemand; /* Pointer to demand object */ typedef struct Sdemand *Pdemand; /* Pointer to demand object */