Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
295 commits
Select commit Hold shift + click to select a range
24d9626
fmu2: Filter out connected inputs
Vaan5 Feb 1, 2022
98be115
Do not set unconnected variables in every DoStep
Vaan5 Feb 1, 2022
eba29f2
component: Add SyncStart/EndWallClockTime timing results
klausschuch Dec 16, 2021
381c2d7
component: Measure additional times
klausschuch Jan 31, 2022
639c44a
Do not use uninitialized rtGlobalSimStart
klausschuch Feb 1, 2022
e5da00e
Extract common code into a function
Vaan5 Feb 4, 2022
15f5444
Enable profiling times with a development flag
Vaan5 Feb 4, 2022
b0680ad
Restructure timings
Vaan5 Feb 8, 2022
69f1e8e
Avoid premature simulation end in case of only NeverFinishing components
Vaan5 Mar 4, 2022
a63defc
Ignore FLUSH_STORE in case of parallel
Vaan5 Mar 7, 2022
7ea746b
Change time format in log file header
Vaan5 Mar 7, 2022
cae9ce6
Fix const warnings regarding ChannelValue
klausschuch Jan 24, 2022
1630ee5
Convert path to a normalized absolute path prior to _waccess call
Vaan5 Mar 16, 2022
118cb96
Implement a memory filter
Vaan5 Feb 15, 2022
be4a159
Forward correct argument to CompPostDoUpdateState
Vaan5 Feb 15, 2022
0224c67
Use the MemoryFilter when possible
Vaan5 Feb 15, 2022
e291799
Add a switch to disable the MemoryFilter on demand
Vaan5 Feb 21, 2022
89d3a9c
Check for cycles when determining the buffer size
Vaan5 Feb 21, 2022
51d02a2
Use >= to check for buffer overflow
Vaan5 Mar 22, 2022
1c95704
Use SIZE_MAX instead of MEM_FILTER_IDX_FLAG
Vaan5 Mar 22, 2022
a7631c1
Print user's input as a string instead of the converted int value
Vaan5 Mar 22, 2022
80aa0c3
Fix compiler warnings
Vaan5 Mar 22, 2022
254d521
Define a Vector of pure C objects
Vaan5 Feb 24, 2022
2702ae2
Inline ConnectionInfo into the Connection
Vaan5 Feb 25, 2022
a84098a
Remove ConnectionData
Vaan5 Feb 23, 2022
836e97d
Vector: Add SetAt method
Vaan5 Feb 28, 2022
563936e
Vector: Hide Resize and expose a Reserve method
Vaan5 Mar 2, 2022
edd73e6
Inline ChannelInfo into the Channel
Vaan5 Feb 28, 2022
8dc290f
Drop ChannelData
Vaan5 Mar 2, 2022
5448247
Inline Channel::GetInfo
Vaan5 Mar 2, 2022
27a29e0
Vector optimizations
Vaan5 Mar 22, 2022
b5c256b
Remove unused variables
Vaan5 Mar 22, 2022
f8bb70f
Move variables closer to the place where they are used
Vaan5 Mar 22, 2022
5854fa6
Simplify ResultStorage
klausschuch Mar 9, 2024
1ef31f4
Check that the Databus channels were set before trying to update thei…
klausschuch Mar 9, 2024
bdb8500
Define a ContainsComponent method
Vaan5 Apr 6, 2022
35259ba
Submodel utility to properly check container-like components
Vaan5 Apr 6, 2022
0727977
Make sure ComponentStorage->Finished is called for comp_solver compon…
Vaan5 Apr 6, 2022
e08d0dd
common_fmu2: Add Fmi2TypeToString() function
klausschuch Sep 30, 2021
08f298a
Use %zu for size_t prints
klausschuch Feb 28, 2025
dc0cf49
signals: Add framework for printing function on signal
Oct 18, 2021
3a57742
signals: Upgrade current function storage to stack
Oct 18, 2021
31a9632
signals: Add possibility to omit redundant argument
Oct 19, 2021
2fffc22
signals: Add get for function name
Oct 19, 2021
b6fb3ed
signals: Add function name to error message on linux
Oct 19, 2021
195f272
signals: Log function on error in component dosteps
Oct 27, 2021
0d789f3
signals: Improve naming of functions
Oct 27, 2021
72d3a55
signals: Make callstack handling faster and more straight forward
Oct 27, 2021
6633767
signals: Check stack integrity only on Debug
Feb 16, 2022
7c86732
signals: Populate call stack more often
Mar 8, 2022
2983350
signals: Populate call stack on important blocks
Mar 15, 2022
9ccabe8
signals: Populate call stack around cleanup
Mar 18, 2022
57483aa
signals: Populate call stack on fmu calls
Mar 22, 2022
229dd4d
signals: Increase call stack size 3->5
Mar 24, 2022
73dbc21
signals: Remove individual fmu set/get calls
klausschuch Apr 7, 2022
98c1431
signals: Add fmi batch functions
klausschuch Apr 7, 2022
631acec
Set channel reference for outputs as well
Vaan5 Mar 15, 2022
493d8f6
Define info object for storing variable data from the model description
Vaan5 Mar 15, 2022
056e751
Construct proxies to array parameters during read
Vaan5 Apr 8, 2022
5c6e07d
Only take into account fully tunable maps/curves
Vaan5 May 9, 2022
bd270ab
Add ParameterProxies
Vaan5 May 10, 2022
2d03c7a
Component: Distinguish error/warning in DoStep
klausschuch Jun 3, 2022
08da9f9
results: Make CSV component files resettable
Vaan5 Jul 4, 2022
d777f0b
channel: Add return value to SetFromReference
Jul 5, 2021
6772175
channel: Add return value to SetToReference
Jul 5, 2021
06e7555
channel: Add CHANNEL_ARRAY
Jul 5, 2021
d2e4b57
Add ChannelTypeMatch
Jul 6, 2021
d848a9e
channel: Use ChannelTypeMatch in ChannelInSetReference
Jul 6, 2021
133ae56
channel: Use ChannelValueDataSetFromReference in ChannelInUpdate
Jul 6, 2021
d1c5545
channel: Add error messages
Jul 6, 2021
92ccb83
channel: Remove unnecessary type checks
Jul 6, 2021
36065ec
channel: Add nameInModel to ChannelInfoInit
Jul 6, 2021
b43a7e9
Add ChannelValueDestroy to free ChannelValues on heap
Jul 7, 2021
56e5bb5
channel: Use writeResults as scalar for vectors
Jul 7, 2021
75a4c3a
channel: Make ChannelType a struct
Jul 12, 2021
ea3030c
channel: Use ChannelType only via references
Jul 13, 2021
7517e8b
channel: Use ChannelInfo with Dimension instead of VectorChannelInfo
Jul 20, 2021
458edde
storage: Expand arrays to scalars in the csv backend
Jul 20, 2021
24cbf75
channel: Add ChannelTypeBaseType
Sep 6, 2021
0de5c26
channel: Add ChannelValueNewScalar
Jul 22, 2021
888534e
constant: Remove use of VectorChannelInfo
Jul 22, 2021
e8e1495
value: Add array_destroy
Sep 10, 2021
67c0d1b
vector_integrator: Remove use of VectorChannelInfo
Aug 20, 2021
b790646
ChannelValueToString: Support ChannelTypeArray
Sep 7, 2021
d1f3404
channel: Add ChannelTypeArrayInner
Sep 7, 2021
acb52ef
fmu: Support ChannelTypeArray
Sep 7, 2021
257b6d8
channel: Let ChannelValueInit take ownership of type
Jul 27, 2021
e675ea3
fmu: Move Fmu2ReadFmu2{Scalar,Array}Value to Fmu2Value.c
Sep 7, 2021
97935ae
fmu: Check status of Fmu2ReadFmu2{Scalar,Array}Value
Sep 7, 2021
bf5d66d
fmu: Improve error message for "unknown type"
Aug 24, 2021
6be2623
fmu: Extend Fmu2ValueSetup to handle arrays
Sep 7, 2021
d18c5ec
icos: Refactor ports and remove VectorChannelInfo
Aug 20, 2021
a3839e3
channel: Replace double with ChannelValueData for proc functions
Aug 31, 2021
c3d9c55
Move CreateIndexedName to ChannelValue
Aug 23, 2021
1c29e10
db: Remove DatabusGet{In,Out}VectorChannel{Info,Num}
Sep 1, 2021
7f54ae7
db: Remove DatabusSet{In,Out}RefVector{Channel}
Sep 2, 2021
ae6ba5d
channel: Remove VectorChannelInfo
Sep 7, 2021
cfea69b
fmu: Fix memory cleanup of Fmu2Value
Sep 7, 2021
13b38d0
channel: Fix memory cleanup of ChannelInfo
Sep 7, 2021
373b5b4
reader: Fix memory cleanup
Sep 7, 2021
3772aed
channel: ChannelOutUpdate: Add error messages to all error returns
Sep 7, 2021
358768d
Rename array -> mcx_array
Sep 9, 2021
378e3b6
Move mcx_copy to util/stdlib
Sep 10, 2021
a9cccb7
value: Cleanup ChannelValueToString
Sep 10, 2021
d7f36b3
value: Remove obsolete TODOs
Sep 13, 2021
9bc1237
fmu: Add defaults in actuation switch statement
Sep 14, 2021
e4227e4
Fix binary channel initialization
Sep 20, 2021
2677d06
values: Fix printing of binary values
Sep 20, 2021
d39476c
channel: Store type of registered inport reference
Sep 20, 2021
94c171d
fmu: Get start value for binary channels
Sep 14, 2021
dd3324f
monitoring: Add array support to Online Monitor
Sep 23, 2021
863cf39
Fix: Correctly set up ChannelInfo
Vaan5 May 12, 2022
7683fc4
Fix: Vector does not have PushBackNamed
Vaan5 May 12, 2022
d2b80fb
Fix: Pass the correct pointer value
Vaan5 May 12, 2022
3625303
Make FilterFactory arguments explicit
Vaan5 Sep 17, 2021
6e7077f
Create a separate filter for every array element
Vaan5 Sep 27, 2021
0a9c099
Remove unused function
Vaan5 Oct 6, 2021
378e26b
Add functions for calculating the number of in/out databus elements
Vaan5 Oct 12, 2021
15b9966
Pre-allocate memory for channel value data used by channel functions
Vaan5 Oct 12, 2021
2d7da56
Do not allocate memory for arrays in UpdateToOutput
Vaan5 Oct 14, 2021
d3842b8
Properly initialize the type in ChannelInData
Vaan5 Oct 14, 2021
fc8a20b
Do not forget to call ChannelInfoInit
Vaan5 May 13, 2022
0530ea2
Fix indentation
Vaan5 May 13, 2022
2106dd4
Fix ChannelDimension definition
Vaan5 May 13, 2022
2178a44
Remove obsolete explicit destruction of channel info
Vaan5 May 13, 2022
eeece33
Do not forget to clone types
Vaan5 May 13, 2022
92567b7
Fix ChannelInfo
Vaan5 May 13, 2022
1dd1f5c
Fix Constant::GetValue
Vaan5 May 13, 2022
dce9d34
Fix ConnectionInfo construction
Vaan5 May 13, 2022
a70a831
Extend ConnectionInfo with slice information
Vaan5 Oct 18, 2021
3899951
Do not fill internalValue as it is not used anywhere
Vaan5 Oct 18, 2021
8079f30
Allow registering multiple connections with the same ChannelIn
Vaan5 Oct 29, 2021
497b743
Modify type conversions to work with destination/source arguments
Vaan5 Nov 3, 2021
f01ff41
Fix ChannelValueRef definition
Vaan5 Nov 3, 2021
ff0c24e
Define 1 type conversion per connection
Vaan5 Nov 3, 2021
f7948fc
Avoid getting connection string (mem allocation) during runtime
Vaan5 Nov 3, 2021
efcde04
Fix vector integrator
Vaan5 Nov 3, 2021
cb154dc
Make filtered connections operate on sliced data
Vaan5 Nov 4, 2021
8ae0b54
Drop indexed vector element indexing in connection definitions
Vaan5 Nov 5, 2021
afa3ef0
Add ChannelTypeNumElements
Vaan5 Nov 8, 2021
1c1dd60
Add const qualifiers
Vaan5 Nov 8, 2021
b1ec113
Add type conversions scalar -> double array
Vaan5 Nov 8, 2021
6c24cb3
Add ChannelDimension utility functions
Vaan5 Nov 8, 2021
7e7c135
Remove const qualifier
Vaan5 Nov 8, 2021
79dbc0c
Extend ChannelValueRefSetFromReference to work with slice conversions
Vaan5 Nov 8, 2021
d08347c
Forward correct types to TypeConversion constructor
Vaan5 Nov 8, 2021
1d51dd6
Define writeResults flag as a scalar for SSP as well
Vaan5 Nov 9, 2021
374777e
Define mcx_array_set_elem
Vaan5 Nov 10, 2021
dc5fc05
Define mcx_array_all and mcx_array_leq
Vaan5 Nov 10, 2021
b94183c
Implement conditional ChannelValueData element-wise setter
Vaan5 Nov 10, 2021
4536533
Support array in RangeConversion
Vaan5 Nov 10, 2021
a5c6860
Do not define ChannelValueArrays if min/max/offset/etc. are not speci…
Vaan5 Nov 10, 2021
85b9c3c
Fix ChannelDimensionNormalize
Vaan5 Nov 10, 2021
ba594c2
Define scale and offset operation on ChannelValue
Vaan5 Nov 10, 2021
e310562
Linear conversion for arrays
Vaan5 Nov 10, 2021
52bb364
Adapt Dependency matrix generation wrt. array channels
Vaan5 Nov 11, 2021
a7d81f4
Adapt UnitConversion to arrays
Vaan5 Nov 11, 2021
588461c
Fix log message
Vaan5 Nov 11, 2021
9b8f42e
Implement ChannelValueRefSetFromReference
Vaan5 Nov 11, 2021
8e9946e
Add a function to check whether dimensions are conformable (same sizes)
Vaan5 Nov 11, 2021
c177617
Add ChannelDimensionsConform
Vaan5 Nov 12, 2021
4417a44
Add ChannelDimensionGetSliceIndex
Vaan5 Nov 12, 2021
ead2a51
Add Type and Dimension getters for Connection value reference
Vaan5 Nov 12, 2021
b5bea2a
Extend arguments of fChannelValueRefElemMapFunc
Vaan5 Nov 12, 2021
c0baed1
Implement ChannelValueRefGetType
Vaan5 Nov 12, 2021
64fbbb3
Compare inner types in ChannelTypeEq as well
Vaan5 Nov 12, 2021
caa252b
Fix return value of mcx_array_get_elem_reference
Vaan5 Nov 12, 2021
36241d2
Define ChannelTypeConformable
Vaan5 Nov 12, 2021
267895b
Adapt TypeConversion to arrays
Vaan5 Nov 12, 2021
7f93f35
Take into account arrays in dependency matrix creation
Vaan5 Nov 15, 2021
ec18455
Change connection->data->store to the size of the input slice
Vaan5 Nov 15, 2021
edcc8d4
Support array channels in FMU 1
Vaan5 Nov 19, 2021
f44dd6d
Extend conversions to slices
Vaan5 May 24, 2022
1060769
Check for duplicate ports and read specific data
Vaan5 May 24, 2022
0d13275
Apply conversions only if necessary
Vaan5 May 24, 2022
9f262cb
Use the correct reference
Vaan5 May 24, 2022
bf420c9
Use function instead of member function
Vaan5 May 24, 2022
f484a2e
Fix target/source channel reading during ConnectionInfo construction
Vaan5 May 24, 2022
a89fc6a
Expose the whole source value (not just a slice) in direct connections
Vaan5 May 23, 2022
1112661
Disable support for co-sim init with vector ports
Vaan5 May 27, 2022
10b6893
ChannelDimension cleanup
Vaan5 May 27, 2022
8335ddb
Replace IsValid functions with their channel counterparts
Vaan5 May 31, 2022
e2aaaa8
FMU2: Take into account vector elements during dependency matrix gene…
Vaan5 Jun 1, 2022
505c849
Move dependency matrix generation code to common
Vaan5 Jun 1, 2022
b1fb63d
Optimize const connections away only if the whole destination channel…
Vaan5 Jun 1, 2022
d0d8dfd
Rename ChannelValueReference -> ChannelValueDataPointer
Vaan5 Jun 1, 2022
30a69df
Mark tunable params as discrete for arrays as well
Vaan5 Jun 2, 2022
722ae11
Free the dimension of the ChannelValueReference slice
Vaan5 Jun 2, 2022
8510e66
Make ChannelValueRef a normal struct
Vaan5 Jun 28, 2022
3ab7d69
Rename ChannelValueRef -> ChannelValueReference
Vaan5 Jun 28, 2022
cfbee10
Make sure DirectConnection has the correct store size
Vaan5 Jun 28, 2022
6832d17
ConnectionInfo: free dimensions
Vaan5 Jun 28, 2022
3a0fe55
GetInConnectionInfos: Use Vector instead of ObjectContainer
Vaan5 Jun 29, 2022
31c26d3
Make sure to provide a type clone to ChannelValueInit
Vaan5 Jun 29, 2022
7e988a5
Use Vector to store ChannelValueReferences
Vaan5 Jun 29, 2022
aef1a3b
Get rid of TODOs
Vaan5 Jun 29, 2022
dcd906a
Rename ChannelDimensionSetDimension argument
Vaan5 Jul 7, 2022
63ffb63
Remove obsolete code
Vaan5 Jul 7, 2022
b9cd4a4
Avoid memory allocations due to C/C++ interface
Vaan5 Jul 7, 2022
d6dc19e
storage: Make utility function accessible to all backends
Jul 8, 2022
6cc43b2
storage: Make function ANSI C compliant
Jul 15, 2022
d61a172
Move variables closer to the place where they are used
Vaan5 Jul 29, 2022
0c1e5cc
Update element channels prior to exiting init mode in connections
Vaan5 Jul 27, 2022
95302f6
Make additional init step configurable via an environment variable
Vaan5 Jul 25, 2022
2cb5d63
ChannelValue: Return error when failing to allocate memory
Aug 16, 2022
1cdbcf4
Task: Change default of sumTime to TRUE
klausschuch Sep 4, 2021
fe56fa4
task/results: Store RTFactor in Task->Initialize
May 13, 2022
c754c71
util: Convert relative Dll paths to absolute ones
Oct 4, 2022
75c167a
util: Use goto cleanup strategy for handling errors
Oct 13, 2022
c91257f
util: Log (Debug) absolute path of Dll
Oct 10, 2022
cd6d38f
Calculate first larger sync time multiple differently depending on SU…
Vaan5 Oct 10, 2022
3afd503
util: Expose function for absolute epsilon comparison
Vaan5 Oct 17, 2022
59f20cc
Use absolute epsilon comparison to determine synchronization slots
Vaan5 Oct 17, 2022
54456a6
Use same way of checking for sync slots both in component and step type
Vaan5 Oct 17, 2022
c05f575
Remove obsolete code
Vaan5 Oct 19, 2022
0b8f30c
Define a leq comparison function using absolute epsilon comparison
Vaan5 Oct 20, 2022
c9bd0be
Add const qualifiers
Vaan5 Sep 5, 2022
b002c77
Add const qualifier
Vaan5 Sep 16, 2022
29458bf
FMU2: Correctly use dimensions of naming convention arrays
Vaan5 Sep 26, 2022
53cddb3
Correctly check if cloning was successful
Vaan5 Oct 27, 2022
1251484
fmu: Remove check for valid dimension_1/2
Jul 15, 2022
79a57c0
Use %zu for size_t
klausschuch Mar 5, 2025
edf094d
FMI2: Read unit of local values
Vaan5 Sep 21, 2022
0d36722
Add error log messages
Vaan5 Nov 7, 2022
6cf3233
Check the reference only once at the beginning
Vaan5 Nov 7, 2022
0f7fcf1
Define a typedef for the dimension type
Vaan5 Nov 9, 2022
c260ddc
Use McxStatus as return type of channel functions
Vaan5 Nov 9, 2022
d13a9a0
Remove obsolete return
Vaan5 Nov 16, 2022
fb7b2cd
Calculate for loop bounds outside
Vaan5 Nov 16, 2022
5f6ddf0
Indentation
Vaan5 Nov 16, 2022
aaae41d
Add log message
Vaan5 Nov 16, 2022
accab58
Remove rebase artifacts
Vaan5 Nov 16, 2022
5b8f138
Fix indexing formula
Vaan5 Nov 16, 2022
344f53f
channel: Inline ChannelInData (Performance!)
Nov 10, 2022
856f2b5
channel: Inline ChannelOutData (Performance!)
Oct 25, 2022
5085248
channel: Reduce redirections on in connections (Performance!)
Oct 25, 2022
4860551
channel: Reduce redirections of ValueReferences (Performance!)
Nov 10, 2022
192ebb1
channel: Reduce redirections of conversions (Performance!)
Oct 25, 2022
1f65e6c
channel: Reduce redirections of out connections (Performance!)
Oct 25, 2022
605e667
channel: Fix datatype of function argument
Oct 25, 2022
ef92ee2
connection: Inline FilteredConnectionData (Performance!)
Oct 25, 2022
fb198e0
FilteredConnection: Store single filter pointer directly (Performance!)
Oct 27, 2022
189ca7d
channel: Write message only in debug (Performance!)
Oct 28, 2022
5bc0728
Fmu2: Create separate SetVariable for Init (Performance!)
Nov 2, 2022
42d3a1a
channel: Skip unnecessary type checks (Performance!)
Oct 31, 2022
0619675
fmu2: Remove variable only needed for warnings/errors (Performance!)
Oct 31, 2022
4533d79
channel: Call IsFullyConnected only once (Performance!)
Oct 31, 2022
d4f8915
channel: Only calculate isFullyConnected on demand (Performance!)
Nov 2, 2022
3858ee9
channel: Fix Channel dimension index in calculation
Vaan5 Nov 18, 2022
abe6e21
Use %zu for size_t
klausschuch Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 59 additions & 19 deletions libs/util/src/win/libs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#define _WINSOCKAPI_ // stops windows.h including winsock.h
#include <windows.h>
#include <shlwapi.h>

#include "common/logging.h"
#include "common/memory.h"
Expand All @@ -23,24 +24,12 @@ extern "C" {
#endif /* __cplusplus */


McxStatus mcx_dll_load(DllHandle * handle, const char * dllPath) {
DllHandleCheck compValue;

wchar_t * wDllPath = mcx_string_to_widechar(dllPath);

* handle = LoadLibraryExW(wDllPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
mcx_free(wDllPath);

compValue = (DllHandleCheck) * handle;
if (compValue <= HINSTANCE_ERROR) {
LPVOID lpMsgBuf;
DWORD err = GetLastError();

mcx_log(LOG_ERROR, "Util: Dll (%s) could not be loaded", dllPath);

switch (err) {
static void print_last_error() {
LPVOID lpMsgBuf;
DWORD err = GetLastError();
switch (err) {
case ERROR_BAD_EXE_FORMAT:
mcx_log(LOG_ERROR, "Util: There is a mismatch in bitness (32/64) between current Model.CONNECT Execution Engine and the dynamic library", dllPath);
mcx_log(LOG_ERROR, "Util: There is a mismatch in bitness (32/64) between current Model.CONNECT Execution Engine and the dynamic library");
break;
default:
FormatMessage(
Expand All @@ -56,11 +45,62 @@ McxStatus mcx_dll_load(DllHandle * handle, const char * dllPath) {
mcx_log(LOG_ERROR, "Util: Error %d: %s", err, lpMsgBuf);
LocalFree(lpMsgBuf);
break;
}
}


McxStatus mcx_dll_load(DllHandle * handle, const char * dllPath) {
DllHandleCheck compValue;

wchar_t * wDllPath = mcx_string_to_widechar(dllPath);

McxStatus retVal = RETURN_OK;

if (PathIsRelativeW(wDllPath)) {
wchar_t * wFullDllPath = NULL;
DWORD length = GetFullPathNameW(wDllPath, 0, NULL, NULL);
if (length == 0) {
mcx_log(LOG_ERROR, "Util: Error retrieving length of absolute path of Dll (%s)", dllPath);
print_last_error();
retVal = RETURN_ERROR;
goto relpath_cleanup;
}
wFullDllPath = (wchar_t *) mcx_malloc(sizeof(wchar_t) * length);
length = GetFullPathNameW(wDllPath, length, wFullDllPath, NULL);
if (length == 0) {
mcx_log(LOG_ERROR, "Util: Error creating absolute path for Dll (%s)", dllPath);
print_last_error();
retVal = RETURN_ERROR;
goto relpath_cleanup;
}
return RETURN_ERROR;
relpath_cleanup:
if (wDllPath) {
mcx_free(wDllPath);
}
if (retVal != RETURN_OK) {
goto cleanup;
}
wDllPath = wFullDllPath;
}

mcx_log(LOG_DEBUG, "Util: Loading Dll %S", wDllPath);

* handle = LoadLibraryExW(wDllPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);

compValue = (DllHandleCheck) * handle;
if (compValue <= HINSTANCE_ERROR) {
mcx_log(LOG_ERROR, "Util: Dll (%s) could not be loaded", dllPath);
print_last_error();
retVal = RETURN_ERROR;
goto cleanup;
}

cleanup:
if (wDllPath) {
mcx_free(wDllPath);
}

return RETURN_OK;
return retVal;
}


Expand Down
19 changes: 17 additions & 2 deletions libs/util/src/win/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,25 @@ const char * mcx_os_get_errno_descr(int errnum) {

int mcx_os_path_exists(const char * path) {
int ret;
wchar_t * wPath = mcx_string_to_widechar(path);
char * absoluteNormalizedPath = NULL;
wchar_t * wPath = NULL;

absoluteNormalizedPath = mcx_os_path_normalize(path);
if (path && !absoluteNormalizedPath) {
mcx_log(LOG_ERROR, "Util: Could not convert path '%s' to a normalized absolute path", path);
return 0;
}

wPath = mcx_string_to_widechar(absoluteNormalizedPath);

if (absoluteNormalizedPath) {
mcx_free(absoluteNormalizedPath);
}

ret = (_waccess(wPath, 0) != -1);
mcx_free(wPath);
if (wPath) {
mcx_free(wPath);
}

return ret;
}
Expand Down
34 changes: 34 additions & 0 deletions mcx/mcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,20 @@ McxStatus RunMCX(int argc, char *argv[]) {
goto cleanup;
}

mcx_signal_handler_set_function("ConfigSetupFromCmdLine");
retVal = config->SetupFromCmdLine(config, argc, argv);
mcx_signal_handler_unset_function();
if (retVal == RETURN_ERROR) {
goto cleanup;
}

mcx_signal_handler_set_function("SetupLogFiles");
SetupLogFiles(config->logFile, config->writeAllLogFile);
mcx_signal_handler_unset_function();
logInitialized = 1;
mcx_signal_handler_set_function("ConfigSetupFromEnvironment");
retVal = config->SetupFromEnvironment(config);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
mcx_log(LOG_INFO, "Setting up configuration from environment failed");
retVal = RETURN_ERROR;
Expand All @@ -337,22 +343,28 @@ McxStatus RunMCX(int argc, char *argv[]) {
goto cleanup;
}

mcx_signal_handler_set_function("ReaderSetup");
retVal = reader->Setup(reader, config->modelFile, config);
mcx_signal_handler_unset_function();
if (retVal == RETURN_ERROR) {
mcx_log(LOG_ERROR, "Input reader setup failed");
retVal = RETURN_ERROR;
goto cleanup;
}

mcx_signal_handler_set_function("ReaderRead");
mcxInput = reader->Read(reader, config->modelFile);
mcx_signal_handler_unset_function();
if (!mcxInput) {
mcx_log(LOG_ERROR, "Parsing of input file failed");
retVal = RETURN_ERROR;
goto cleanup;
}
element = (InputElement *) mcxInput;

mcx_signal_handler_set_function("ConfigSetupFromInput");
retVal = config->SetupFromInput(config, mcxInput->config);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
mcx_log(LOG_ERROR, "Setting up configuration from input file failed");
retVal = RETURN_ERROR;
Expand Down Expand Up @@ -387,20 +399,26 @@ McxStatus RunMCX(int argc, char *argv[]) {
mcx_cpu_time_get(&clock_read_begin);
mcx_time_get(&time_read_begin);

mcx_signal_handler_set_function("TaskRead");
retVal = task->Read(task, mcxInput->task);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
}

mcx_signal_handler_set_function("ModelRead");
retVal = model->Read(model, mcxInput->model);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
}

object_destroy(mcxInput);
mcx_signal_handler_set_function("ReaderCleanup");
reader->Cleanup(reader);
mcx_signal_handler_unset_function();
object_destroy(reader);

mcx_cpu_time_get(&clock_read_end);
Expand All @@ -421,19 +439,25 @@ McxStatus RunMCX(int argc, char *argv[]) {
mcx_cpu_time_get(&clock_setup_begin);
mcx_time_get(&time_setup_begin);

mcx_signal_handler_set_function("TaskSetup");
retVal = task->Setup(task, model);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
}

mcx_signal_handler_set_function("ModelSetup");
retVal = model->Setup(model);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
}

mcx_signal_handler_set_function("TaskPrepareRun");
retVal = task->PrepareRun(task, model);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
Expand All @@ -457,7 +481,9 @@ McxStatus RunMCX(int argc, char *argv[]) {
mcx_cpu_time_get(&clock_init_begin);
mcx_time_get(&time_init_begin);

mcx_signal_handler_set_function("TaskInitialize");
retVal = task->Initialize(task, model);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
Expand All @@ -481,7 +507,9 @@ McxStatus RunMCX(int argc, char *argv[]) {
mcx_log(LOG_INFO, " ");
mcx_cpu_time_get(&clock_sim_begin);
mcx_time_get(&time_sim_begin);
mcx_signal_handler_set_function("TaskRun");
retVal = task->Run(task, model);
mcx_signal_handler_unset_function();
if (RETURN_OK != retVal) {
retVal = RETURN_ERROR;
goto cleanup;
Expand Down Expand Up @@ -512,6 +540,7 @@ McxStatus RunMCX(int argc, char *argv[]) {
mcx_cpu_time_get(&clock_cleanup_begin);
mcx_time_get(&time_cleanup_begin);

mcx_signal_handler_set_function("RunMCX:Cleanup");
object_destroy(task);
object_destroy(model);
object_destroy(config);
Expand Down Expand Up @@ -544,6 +573,10 @@ McxStatus RunMCX(int argc, char *argv[]) {


cleanup:
if (reader) {
reader->Cleanup(reader);
object_destroy(reader);
}
if (mcxInput) { object_destroy(mcxInput); }

if (model) { object_destroy(model); }
Expand All @@ -554,6 +587,7 @@ McxStatus RunMCX(int argc, char *argv[]) {
mcx_log(LOG_INFO, "**********************************************************************");
}

mcx_signal_handler_unset_function(); // RunMCX:Cleanup

return retVal;
}
Expand Down
6 changes: 1 addition & 5 deletions scripts/SSP/Ports.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<xs:list itemType="xs:int"/>
</xs:simpleType>

<xs:simpleType name="BooleanVectorT">
<xs:list itemType="xs:boolean"/>
</xs:simpleType>

<!-- common attributes -->
<xs:attributeGroup name="CommonScalarPortAttributes">
<xs:attribute name="writeResults" type="xs:boolean"/>
Expand All @@ -38,7 +34,7 @@
<xs:attribute name="startIndex" type="xs:unsignedInt" use="required"/>
<xs:attribute name="endIndex" type="xs:unsignedInt" use="required"/>

<xs:attribute name="writeResults" type="mse:BooleanVectorT"/>
<xs:attribute name="writeResults" type="xs:boolean"/>
</xs:attributeGroup>

<!-- scalar ports -->
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ file(GLOB MCX_SRC_COMMON
"core/channels/*.c" "core/channels/*.cpp"
"core/connections/*.c" "core/connections/*.cpp"
"core/connections/filters/*.c" "core/connections/filters/*.cpp"
"core/parameters/*.c" "core/parameters/*.cpp"
"components/*.c" "components/*.cpp"
"fmu/*.c" "fmu/*.cpp"
"objects/*.c" "objects/*.cpp"
Expand Down
2 changes: 1 addition & 1 deletion src/CentralParts.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ typedef enum DecoupleTypeDef {
DECOUPLE_ALWAYS = 0x4
} DecoupleType;

// Note: the enum values are mandatory because the enum is used in integer context
typedef enum PolyOrderTypeDef {
POLY_CONSTANT = 0
, POLY_LINEAR = 1
Expand Down Expand Up @@ -150,6 +149,7 @@ typedef enum StoreLevel {
STORE_NONE = 1,
STORE_SYNCHRONIZATION = 2,
STORE_COUPLING = 3,
STORE_MICRO = 4,
} StoreLevel;

typedef enum {
Expand Down
4 changes: 3 additions & 1 deletion src/components/ComponentTypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ OBJECT_CLASS(ComponentType, Object);
/*****************************************************************************/
/* ComponentTypeConstant */
/*****************************************************************************/
const char * const compConstantTypeString = "CONSTANT";

static const char * ComponentTypeConstantToString(ComponentType * type) {
return "CONSTANT";
return compConstantTypeString;
}

static void ComponentTypeConstantDestructor(ComponentTypeConstant * type) {
Expand Down
1 change: 1 addition & 0 deletions src/components/ComponentTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct ComponentType {
};


extern const char * const compConstantTypeString;
extern const ObjectClass _ComponentTypeConstant;
typedef struct ComponentTypeConstant {
ComponentType _;
Expand Down
Loading
Loading