-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Myoldmopar/Toward940
Toward 9.4.0
- Loading branch information
Showing
11 changed files
with
196 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project({TARGET_NAME}) | ||
add_executable({TARGET_NAME} {SOURCE_FILE}) | ||
target_link_libraries({TARGET_NAME} ${{CMAKE_DL_LIBS}}) |
87 changes: 87 additions & 0 deletions
87
ep_testing/tests/api_templates/delayed_cpp_source_linux_mac.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <cassert> | ||
#include <iostream> | ||
#include <dlfcn.h> | ||
int main() { | ||
const char *dlsym_error; | ||
std::cout << "Opening eplus shared library...\n"; | ||
void* handle = dlopen("{EPLUS_INSTALL_NO_SLASH}{LIB_FILE_NAME}", RTLD_LAZY); | ||
if (!handle) { | ||
std::cerr << "Cannot open library: \n"; | ||
return 1; | ||
} | ||
dlerror(); // resets errors | ||
// | ||
std::cout << "Getting a new state instance...\n"; | ||
typedef void *(*fNewState)(); | ||
auto stateNew = (fNewState) dlsym(handle, "stateNew"); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot load symbol stateNew\n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
auto state = stateNew(); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot instantiate a new state from stateNew\n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
// | ||
std::cout << "Calling to initialize...\n"; | ||
typedef void (*init_t)(void *); | ||
auto init = (init_t) dlsym(handle, "initializeFunctionalAPI"); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot load symbol 'initializeFunctionalAPI': \n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
init(state); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Could not call initialize function \n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
// | ||
std::cout << "Getting a new Glycol instance...\n"; | ||
typedef void* (*newGly)(void *, const char *); | ||
auto thisNewGly = (newGly) dlsym(handle, "glycolNew"); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot load symbol 'glycolNew': \n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
auto glycolInstance = thisNewGly(state, "water"); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot get a new glycol instance via glycolNew': \n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
// | ||
std::cout << "Calculating Cp at T = 25C...\n"; | ||
typedef double(*cp)(void *, void *, double); | ||
auto glycolCp = (cp) dlsym(handle, "glycolSpecificHeat"); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot load symbol 'glycolSpecificHeat': \n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
auto cpValue = glycolCp(state, glycolInstance, 25); | ||
dlsym_error = dlerror(); | ||
if (dlsym_error) { | ||
std::cerr << "Cannot calculate Cp with glycolSpecificHeat': \n"; | ||
dlclose(handle); | ||
return 1; | ||
} | ||
// | ||
std::cout << "Calculated Cp = " << cpValue << "\n"; | ||
assert(cpValue > 4150); | ||
assert(cpValue < 4200); | ||
std::cout << "Closing library...\n"; | ||
dlclose(handle); | ||
} |
22 changes: 22 additions & 0 deletions
22
ep_testing/tests/api_templates/delayed_cpp_source_windows.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <windows.h> | ||
#include <iostream> | ||
int main() { | ||
std::cout << "Opening eplus shared library...\\n"; | ||
HINSTANCE hInst; | ||
hInst = LoadLibrary("{EPLUS_INSTALL_NO_SLASH}{LIB_FILE_NAME}"); | ||
if (!hInst) { | ||
std::cerr << "Cannot open library: \\n"; | ||
return 1; | ||
} | ||
typedef void (*INITFUNCTYPE)(); | ||
INITFUNCTYPE init; | ||
init = (INITFUNCTYPE)GetProcAddress((HINSTANCE)hInst, "initializeFunctionalAPI"); | ||
if (!init) { | ||
std::cerr << "Cannot get function \\n"; | ||
return 1; | ||
} | ||
std::cout << "Calling to initialize\\n"; | ||
init(); | ||
std::cout << "Closing library\\n"; | ||
FreeLibrary((HINSTANCE)hInst); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project({TARGET_NAME}) | ||
include_directories("{EPLUS_INSTALL_NO_SLASH}/include") | ||
add_executable({TARGET_NAME} {SOURCE_FILE}) | ||
set(DLL_PATH "{EPLUS_INSTALL_NO_SLASH}/{LIB_FILE_NAME}") | ||
target_link_libraries({TARGET_NAME} ${{DLL_PATH}}) | ||
if (APPLE) | ||
add_custom_command( | ||
TARGET TestCAPIAccess POST_BUILD | ||
COMMAND | ||
${{CMAKE_COMMAND}} | ||
-DDLL_PATH=${{DLL_PATH}} -DTARGET_PATH=$<TARGET_FILE:{TARGET_NAME}> | ||
-P "${{CMAKE_SOURCE_DIR}}/fixup.cmake" | ||
DEPENDS "${{CMAKE_SOURCE_DIR}}/fixup.cmake" | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
include(GetPrerequisites) | ||
get_prerequisites(${TARGET_PATH} PR 0 0 "" "") | ||
foreach(P IN LISTS PR) | ||
string(FIND ${P} "energyplus" EPFOUND) | ||
if (NOT EPFOUND EQUAL -1) | ||
execute_process(COMMAND install_name_tool -change ${P} "${DLL_PATH}" ${TARGET_PATH}) | ||
endif() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stddef.h> | ||
#include <stdio.h> | ||
#include <EnergyPlus/api/state.h> | ||
#include <EnergyPlus/api/func.h> | ||
int main() { | ||
EnergyPlusState state = stateNew(); | ||
initializeFunctionalAPI(state); | ||
Glycol glycol = NULL; | ||
glycol = glycolNew(state, "WatEr"); | ||
for (int temp=5; temp<35; temp+=10) { | ||
Real64 thisTemp = (float)temp; | ||
Real64 specificHeat = glycolSpecificHeat(state, glycol, thisTemp); | ||
printf("Cp = %8.3f\\n", specificHeat); | ||
} | ||
glycolDelete(state, glycol); | ||
printf("Hello, world!\\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
sys.path.insert(0, '%s') | ||
from pyenergyplus.api import EnergyPlusAPI # noqa: E402 | ||
api = EnergyPlusAPI() | ||
state = api.state_manager.new_state() | ||
glycol = api.functional.glycol(state, u"water") | ||
for t in [5.0, 15.0, 25.0]: | ||
cp = glycol.specific_heat(state, t) | ||
rho = glycol.density(state, t) |