This code executes the user function CP_HAPropsSI, which is a wrapper for the CoolProp.HAPropsSI() function, used to extract humid air properties in base-SI units
| 605 | // This code executes the user function CP_HAPropsSI, which is a wrapper for |
| 606 | // the CoolProp.HAPropsSI() function, used to extract humid air properties in base-SI units |
| 607 | static LRESULT CP_HAPropsSI(LPCOMPLEXSCALAR Prop, // pointer to the result |
| 608 | LPCMCSTRING OutputName, // string with a valid CoolProp Output Name |
| 609 | LPCMCSTRING InputName1, // CoolProp InputName1 |
| 610 | LPCCOMPLEXSCALAR InputProp1, // CoolProp InputProp1 |
| 611 | LPCMCSTRING InputName2, // CoolProp InputName2 |
| 612 | LPCCOMPLEXSCALAR InputProp2, // CoolProp InputProp2 |
| 613 | LPCMCSTRING InputName3, // CoolProp InputName3 |
| 614 | LPCCOMPLEXSCALAR InputProp3) // CoolProp InputProp3 |
| 615 | { |
| 616 | unsigned int errPos = 0; |
| 617 | std::string OutName(OutputName->str); |
| 618 | OutName = "[" + OutName + "]"; |
| 619 | std::string Prop1Name(InputName1->str); |
| 620 | Prop1Name = "[" + Prop1Name + "]"; |
| 621 | std::string Prop2Name(InputName2->str); |
| 622 | Prop2Name = "[" + Prop2Name + "]"; |
| 623 | std::string Prop3Name(InputName3->str); |
| 624 | Prop3Name = "[" + Prop3Name + "]"; |
| 625 | |
| 626 | // check that the 3 scalar arguments are real or throw error using inline helper function above |
| 627 | LRESULT r = CheckRealOrError(InputProp1, 3); |
| 628 | if (r) return r; |
| 629 | |
| 630 | r = CheckRealOrError(InputProp2, 5); |
| 631 | if (r) return r; |
| 632 | |
| 633 | r = CheckRealOrError(InputProp3, 7); |
| 634 | if (r) return r; |
| 635 | |
| 636 | // pass the arguments to the HumidAirProp.HAProps() function |
| 637 | Prop->real = |
| 638 | HumidAir::HAPropsSI(OutputName->str, InputName1->str, InputProp1->real, InputName2->str, InputProp2->real, InputName3->str, InputProp3->real); |
| 639 | |
| 640 | // Note: HAPropsSI does not throw exceptions, but instead |
| 641 | // sets global parameter "errstring" and returns _HUGE. |
| 642 | // Use ValidNumber(val) to see if HAPropsSI failed with an error message... |
| 643 | if (!ValidNumber(Prop->real)) { |
| 644 | std::string emsg = CoolProp::get_global_param_string("errstring"); |
| 645 | CoolProp::set_error_string(emsg); // reset error string so Mathcad can retrieve it |
| 646 | return HandleHAPropsSIError(emsg, OutName, Prop1Name, Prop2Name, Prop3Name); |
| 647 | } |
| 648 | |
| 649 | // normal return |
| 650 | return 0; |
| 651 | } |
| 652 | |
| 653 | // ******************************************************************************************************** |
| 654 | // Pseudo-Low-Level Functions for mixture information & settings |
nothing calls this directly
no test coverage detected