Update EN_setcurvetype to support EN_VALVE_CURVE

This commit is contained in:
Luke Butler
2023-09-15 11:53:02 -04:00
parent 39ffaebcf9
commit 05c0528862
2 changed files with 7 additions and 2 deletions

View File

@@ -4907,7 +4907,7 @@ int DLLEXPORT EN_setcurvetype(EN_Project p, int index, int type)
Network *net = &p->network; Network *net = &p->network;
if (!p->Openflag) return 102; if (!p->Openflag) return 102;
if (index < 1 || index > net->Ncurves) return 206; if (index < 1 || index > net->Ncurves) return 206;
if (type < 0 || type > EN_GENERIC_CURVE) return 251; if (type < 0 || type > EN_VALVE_CURVE) return 251;
net->Curve[index].Type = type; net->Curve[index].Type = type;
return 0; return 0;
} }

View File

@@ -28,7 +28,7 @@ BOOST_FIXTURE_TEST_CASE(test_PCV_valve, FixtureOpenClose)
double x[] = { 0.0, 25., 50., 75., 100. }; double x[] = { 0.0, 25., 50., 75., 100. };
double y[] = {0.0, 8.9, 18.4, 40.6, 100.0}; double y[] = {0.0, 8.9, 18.4, 40.6, 100.0};
double v; double v;
int linkIndex, curveIndex; int linkIndex, curveIndex, curveType;
// Make steady state run // Make steady state run
error = EN_settimeparam(ph, EN_DURATION, 0); error = EN_settimeparam(ph, EN_DURATION, 0);
@@ -50,6 +50,11 @@ BOOST_FIXTURE_TEST_CASE(test_PCV_valve, FixtureOpenClose)
BOOST_REQUIRE(error == 0); BOOST_REQUIRE(error == 0);
error = EN_setcurve(ph, curveIndex, x, y, npts); error = EN_setcurve(ph, curveIndex, x, y, npts);
BOOST_REQUIRE(error == 0); BOOST_REQUIRE(error == 0);
error = EN_setcurvetype(ph, curveIndex, EN_VALVE_CURVE);
BOOST_REQUIRE(error == 0);
error = EN_getcurvetype(ph, curveIndex, &curveType);
BOOST_REQUIRE(error == 0);
BOOST_REQUIRE(curveType == EN_VALVE_CURVE);
// Assign curve & initial setting to PCV // Assign curve & initial setting to PCV
error = EN_setlinkvalue(ph, linkIndex, EN_PCV_CURVE, curveIndex); error = EN_setlinkvalue(ph, linkIndex, EN_PCV_CURVE, curveIndex);