Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
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
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
4 changes: 4 additions & 0 deletions mcx/mcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,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 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
84 changes: 25 additions & 59 deletions src/components/comp_constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "components/comp_constant.h"

#include "core/channels/ChannelValue.h"
#include "core/Databus.h"
#include "reader/model/components/specific_data/ConstantInput.h"

Expand All @@ -23,31 +24,27 @@ static McxStatus Read(Component * comp, ComponentInput * input, const struct Con
ConstantInput * constantInput = (ConstantInput *)input;

Databus * db = comp->GetDatabus(comp);
size_t numVecOut = DatabusGetOutVectorChannelsNum(db);
size_t numOut = DatabusGetOutChannelsNum(db);

// We read each vector channel (scalars are vectors of length 1)
// and the corresponding values from the input file.
compConstant->values = (ChannelValue **)mcx_calloc(numVecOut, sizeof(ChannelValue *));
compConstant->values = (ChannelValue **)mcx_calloc(numOut, sizeof(ChannelValue *));

if (constantInput->values) {
ConstantValuesInput * values = constantInput->values;
size_t i = 0;

for (i = 0; i < numVecOut; i++) {
for (i = 0; i < numOut; i++) {
ConstantValueInput * value = (ConstantValueInput *)values->values->At(values->values, i);
if (value->type == CONSTANT_VALUE_SCALAR) {
compConstant->values[i] = (ChannelValue *)mcx_calloc(1, sizeof(ChannelValue));
ChannelValueInit(compConstant->values[i], value->value.scalar->type);
ChannelValueSetFromReference(compConstant->values[i], &value->value.scalar->value);
compConstant->values[i] = ChannelValueNewScalar(value->value.scalar->type, &value->value.scalar->value);
if (!compConstant->values[i]) {
ComponentLog(comp, LOG_ERROR, "Could not set channel value");
return RETURN_ERROR;
}
} else {
size_t j = 0;
size_t size = ChannelValueTypeSize(value->value.array->type);
compConstant->values[i] = (ChannelValue *)mcx_calloc(value->value.array->numValues,
sizeof(ChannelValue));
for (j = 0; j < value->value.array->numValues; j++) {
ChannelValueInit(compConstant->values[i] + j, value->value.array->type);
ChannelValueSetFromReference(compConstant->values[i] + j,
(char *)value->value.array->values + j * size);
compConstant->values[i] = ChannelValueNewArray(1, &value->value.array->numValues, value->value.array->type, value->value.array->values);
if (!compConstant->values[i]) {
ComponentLog(comp, LOG_ERROR, "Could not set channel value");
return RETURN_ERROR;
}
}
}
Expand All @@ -59,36 +56,15 @@ static McxStatus Read(Component * comp, ComponentInput * input, const struct Con
static ChannelValue * GetValue(CompConstant * compConstant, size_t idx) {
Component * comp = (Component *) (compConstant);
Databus * db = comp->GetDatabus(comp);
size_t numVecOut = DatabusGetOutVectorChannelsNum(db);
size_t i = 0;
size_t sum = 0;
size_t numOut = DatabusGetOutChannelsNum(db);
ChannelValue * value = NULL;
VectorChannelInfo * vInfo = NULL;
size_t numCh = 0;
size_t startIdx = 0;
size_t endIdx = 0;

for (i = 0; i < numVecOut; i++) {
vInfo = DatabusGetOutVectorChannelInfo(db, i);
startIdx = vInfo->GetStartIndex(vInfo);
endIdx = vInfo->GetEndIndex(vInfo);
numCh = endIdx - startIdx + 1;

sum += numCh;
if (sum > idx) {
break;
}
}

if (i >= numVecOut) {
if (idx >= numOut) {
ComponentLog(comp, LOG_ERROR, "GetValue: Invalid index (%zu) provided", idx);
return NULL;
}

value = compConstant->values[i];
if (!vInfo->IsScalar(vInfo)) {
value += idx - (sum - numCh);
}
value = compConstant->values[idx];

return value;
}
Expand All @@ -97,16 +73,12 @@ static McxStatus Setup(Component * comp) {
CompConstant * constComp = (CompConstant *)comp;
McxStatus retVal = RETURN_OK;
Databus * db = comp->GetDatabus(comp);
size_t numVecOut = DatabusGetOutVectorChannelsNum(db);
size_t numOut = DatabusGetOutChannelsNum(db);

size_t i = 0;

for (i = 0; i < numVecOut; i++) {
VectorChannelInfo * vInfo = DatabusGetOutVectorChannelInfo(db, i);
size_t startIdx = vInfo->GetStartIndex(vInfo);
size_t endIdx = vInfo->GetEndIndex(vInfo);
size_t numCh = endIdx - startIdx;
retVal = DatabusSetOutRefVectorChannel(db, i, startIdx, endIdx, constComp->values[i]);
for (i = 0; i < numOut; i++) {
retVal = DatabusSetOutReference(db, i, (void *) &constComp->values[i]->value, constComp->values[i]->type);
if (RETURN_OK != retVal) {
ComponentLog(comp, LOG_ERROR, "Could not register out channel reference");
return RETURN_ERROR;
Expand All @@ -128,18 +100,12 @@ static void CompConstantDestructor(CompConstant * compConst) {
Component * comp = (Component *)compConst;
McxStatus retVal = RETURN_OK;
Databus * db = comp->GetDatabus(comp);
size_t numVecOut = DatabusGetOutVectorChannelsNum(db);

if (numVecOut > 0 && compConst->values != NULL) {
size_t i, j;
for (i = 0; i < numVecOut; i++) {
VectorChannelInfo * vInfo = DatabusGetOutVectorChannelInfo(db, i);
size_t startIdx = vInfo->GetStartIndex(vInfo);
size_t endIdx = vInfo->GetEndIndex(vInfo);
size_t numCh = endIdx - startIdx + 1;
for (j = 0; j < numCh; j++) {
ChannelValueDestructor(&compConst->values[i][j]);
}
size_t numOut = DatabusGetOutChannelsNum(db);

if (numOut > 0 && compConst->values != NULL) {
size_t i;
for (i = 0; i < numOut; i++) {
ChannelValueDestructor(compConst->values[i]);
mcx_free(compConst->values[i]);
}
mcx_free(compConst->values);
Expand Down
Loading