Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix integer connections to enumerations #1012

Merged
merged 2 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion src/OMSimulatorLib/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ oms_status_enu_t oms::System::addConnection(const oms::ComRef& crefA, const oms:
{
// allow non-real connections to tables
}
else if(conA->getType() == oms_signal_type_integer && conB->getType() == oms_signal_type_enum)
else if((conA->getType() == oms_signal_type_integer || conA->getType() == oms_signal_type_enum) && (conB->getType() == oms_signal_type_enum || conB->getType() == oms_signal_type_integer))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoudln't it be like this?
else if((conA->getType() == oms_signal_type_integer && conB->getType() == oms_signal_type_enum) || (conA->getType() == oms_signal_type_enum && conB->getType() == oms_signal_type_integer))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed with bb23e8d

{
// allow integer connection to enum types
}
Expand Down
52 changes: 52 additions & 0 deletions testsuite/OMSimulator/Enumeration2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-- status: correct
-- linux: yes
-- mingw: yes
-- win: no
-- mac: no

oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./temp-Enumeration2/")

oms_newModel("test")
oms_addSystem("test.root", oms_system_sc)
oms_addSubModel("test.root.A", "../resources/Int1.fmu")
oms_addSubModel("test.root.B", "../resources/Enum1.fmu")

-- valid connection
oms_addConnection("test.root.B.u", "test.root.A.y")

oms_setResultFile("test", "enumeration2.mat")

oms_instantiate("test")
print("info: Instantiation")
print("info: test.root.A.y : " .. oms_getInteger("test.root.A.y"))
print("info: test.root.B.u : " .. oms_getInteger("test.root.B.u"))

oms_initialize("test")
print("info: Initialization")
print("info: test.root.A.y : " .. oms_getInteger("test.root.A.y"))
print("info: test.root.B.u : " .. oms_getInteger("test.root.B.u"))

oms_simulate("test")
print("info: Simulation")
print("info: test.root.A.y : " .. oms_getInteger("test.root.A.y"))
print("info: test.root.B.u : " .. oms_getInteger("test.root.B.u"))

oms_terminate("test")
oms_delete("test")



-- Result:
-- info: model doesn't contain any continuous state
-- info: Instantiation
-- info: test.root.A.y : 2
-- info: test.root.B.u : 0
-- info: Result file: enumeration2.mat (bufferSize=1)
-- info: Initialization
-- info: test.root.A.y : 2
-- info: test.root.B.u : 2
-- info: Simulation
-- info: test.root.A.y : 2
-- info: test.root.B.u : 2
-- endResult
1 change: 1 addition & 0 deletions testsuite/OMSimulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ deleteStartValues.lua \
deleteStartValuesInSSV.lua \
DualMassOscillator.lua \
Enumeration.lua \
Enumeration2.lua \
exportConnectorsToResultFile.lua \
exportSSMTemplate.lua \
exportSSMTemplate.py \
Expand Down