| 1 | package TestEvalExt
|
|---|
| 2 | record MyRecord "a record whose members are assigned by an external fuuction"
|
|---|
| 3 | Real p1 = extfunc1(), p2 = 2. * extfunc1();
|
|---|
| 4 | end MyRecord;
|
|---|
| 5 |
|
|---|
| 6 | parameter MyRecord myParams(p1 = 0.1 * extfunc1(), p2 = extfunc1());
|
|---|
| 7 | parameter MyRecord[1] myParamsArray = {myParams};
|
|---|
| 8 | parameter MyRecord[1] myParamsArray2;
|
|---|
| 9 |
|
|---|
| 10 | model test1 "initialzing a constant by an external function (NOT WORKING!)"
|
|---|
| 11 | constant MyRecord params(p1 = 0.1 * extfunc1(), p2 = extfunc1());
|
|---|
| 12 | //<-- it's a constant assigned by an external function..
|
|---|
| 13 | end test1;
|
|---|
| 14 |
|
|---|
| 15 | model test2 "initialzing a parameter by an external function (WORKING!)"
|
|---|
| 16 | parameter MyRecord params(p1 = 0.1 * extfunc1(), p2 = extfunc1());
|
|---|
| 17 | //<-- it's a parameter assigned by an external function..
|
|---|
| 18 | end test2;
|
|---|
| 19 |
|
|---|
| 20 | model test3 "initialzing a parameter and an array (WORKING!)"
|
|---|
| 21 | parameter MyRecord params(p1 = 0.1 * extfunc1(), p2 = extfunc1());
|
|---|
| 22 | // <-- a parameter
|
|---|
| 23 | parameter MyRecord[2] params_array = {params, params};
|
|---|
| 24 | // <-- a array of the parameter
|
|---|
| 25 | end test3;
|
|---|
| 26 |
|
|---|
| 27 | model test4 "getting a subelement from the initialized parameter (WORKING!)"
|
|---|
| 28 | extends test3;
|
|---|
| 29 | parameter Real p1 = params_array[2].p1;
|
|---|
| 30 | //from an inherited array
|
|---|
| 31 | parameter Real p2 = myParams.p2;
|
|---|
| 32 | //from a parameter in the package (initialized outside..)
|
|---|
| 33 | end test4;
|
|---|
| 34 |
|
|---|
| 35 | model test5 "getting a subelement from the parameter array (NOT WORKING!)"
|
|---|
| 36 | extends test3;
|
|---|
| 37 | parameter Real p2 = myParamsArray[1].p2;
|
|---|
| 38 | // <-- from an array of paramater of the package (initialized outside..)
|
|---|
| 39 | parameter Real p2 = myParamsArray2[1].p2;
|
|---|
| 40 | // <-- it doesn't work too..
|
|---|
| 41 | end test5;
|
|---|
| 42 |
|
|---|
| 43 | function extfunc1
|
|---|
| 44 | output Real ret;
|
|---|
| 45 |
|
|---|
| 46 | external "C" annotation(
|
|---|
| 47 | Include = "
|
|---|
| 48 | double extfunc1(void){
|
|---|
| 49 | return 1.234;
|
|---|
| 50 | }
|
|---|
| 51 | ");
|
|---|
| 52 | end extfunc1;
|
|---|
| 53 | end TestEvalExt;
|
|---|