question

Nikhil_p K avatar image
0 Likes"
Nikhil_p K asked Nikhil_p K commented

Error while implementing the Module Class

Hello

I'm trying to implement the Snowflake Processor example from Module SDK https://docs.flexsim.com/en/21.0/Reference/DeveloperAdvancedUser/ModuleSDK/ExampleModuleClass/

I can successfully create the Snowflake Processor, but when I'm trying to reset the model i'm getting this error

exception: Exception Caught in ObjectFunction441__project_events_OnResetModel_move_objects_to_reset_positions object: MAIN:/project/events/OnResetModel/move objects to reset positions i: MAIN:/project/events/OnResetModel/move objects to reset positions class: MAIN:/project/events/OnResetModel/move objects to reset positions

exception: Exception caught in TreeNode::callMemberFunction() c++/dll execution. Throwing... MAIN:/project/events/OnResetModel/move objects to reset positions c: MAIN:/project/events/OnResetModel/move objects to reset positions i: MAIN:/project/events/OnResetModel/move objects to reset positions thisClass: MAIN:/project/events/OnResetModel/move objects to reset positions

Can someone please help?

FlexSim 21.2.1
module sdkmodulesflexsim 21.2.1
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

You'll get a better, faster answer if you post your source code and replication steps so that we can duplicate what you are seeing in order to debug what is going wrong.

We can't tell you what went wrong based on a simple exception output.

If you configured everything correctly, then you shouldn't be getting exceptions.

Please provide enough information for us to be able to replicate your issue and determine what went wrong.

0 Likes 0 ·
Nikhil_p K avatar image Nikhil_p K commented ·

Replication Steps:

1. Created a new module folder named SnowFlake in \modules(attached)

2. Added the files Snowflake.h, Snowflake.cpp, SnowProcessor.h and Snowflake.cpp as given in the guide

3. Edited the module.cpp according to the guide

3. Copied the Processor node from MAIN:/project/library/fixedresources into a new node and added the new node as an addition to the SnowFlake module.

4. Changed class, superclass, variables, stats and behavior subnodes according to the guide.


Attaching the fsm and module files

snowflake.fsm

Module code https://drive.google.com/drive/folders/1L8ZF8g4mzXPUa_XcqHoetS_zyvah4_54?usp=sharing

0 Likes 0 ·
snowflake.fsm (25.8 KiB)

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Nikhil_p K commented

Your module directory only contains SnowFlake_86.dll and not a SnowFlake.dll, so it appears that you compiled an x86 Win32 DLL instead of a x64 DLL. You are probably using 64-bit FlexSim, so you need to compile your module in 64-bit by selecting x64 from the dropdown at the top. Also ensure that your project settings are set properly for the x64 configuration.

1630344530243.png

You didn't actually save your module, as specified in step 16 of Example Module Class (flexsim.com) so I can't actually see what changes you made in the tree. You need to use your Save Defaults button after making module changes in order to actually save your changes into your module. The module you attached is empty and does nothing.

Based on the model you attached though, it appears that you named your class [SnowFlake]::SnowProcessor instead of SnowFlake::SnowProcessor. Remove the brackets. The brackets in the documentation are to indicate that you replace that part of the text with your module name. You shouldn't include the brackets.

1630344651804.png


1630344530243.png (115.3 KiB)
1630344651804.png (50.4 KiB)
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Nikhil_p K avatar image Nikhil_p K commented ·

Hello Phil, Thanks for your response. As suggested by you I built the module as x64 DLL and updated the class name to SnowFlake::SnowProcessor.


capture-2.png

I'm still getting the same error.(Attaching the updated module, fsm model and model tree screenshot for your reference)

capture.png

Model: snowflake.fsm

Module: https://drive.google.com/drive/folders/1L8ZF8g4mzXPUa_XcqHoetS_zyvah4_54?usp=sharing


0 Likes 0 ·
capture.png (44.0 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ Nikhil_p K commented ·

What version of FlexSim are you trying to use?

The model you attached previously has a version of 21.1. Your question is tagged 21.2.1. The module you have attached includes header files and library files from FlexSim 20.2.0.

The module sdk depends on the version of FlexSim you are using. If you are using 21.1, then you need to use the header and library files from FlexSim 21.1, following the instructions in Module SDK Quick Start (flexsim.com)

0 Likes 0 ·
Nikhil_p K avatar image Nikhil_p K commented ·

Hi @Phil BoBo

I tried using module_template.zip given in Module SDK Quick Start for adding the .h and .cpp files, but the module's flexsimcontent folder is empty and requires dllmain.cpp and FlexsimDefs.h to be built.

capture.png

I tried using flexsimcontent folder from the template_module from the flexsim_module_sdk I downloaded from Flexsim Downloads which I'm assuming is for the older version.

I don't know if this is causing the problem.

0 Likes 0 ·
capture.png (13.9 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ Nikhil_p K commented ·

The flexsimcontent folder SHOULD be empty when you start.

The next 2 steps in the instructions tell you what files you need to copy into that folder from the FlexSim installation directory:

4. Copy the files from FlexSim\program\system\include to the flexsimcontent directory.

5. Copy flexsim.lib from FlexSim\program\system\lib to the flexsimcontent directory.

You need to copy the header files and library files from the FlexSim version you are trying to use. For example, the default installation directory for FlexSim 21.2 is: "C:\Program Files\FlexSim 2021 Update 2\". You need to copy the files from "C:\Program Files\FlexSim 2021 Update 2\program\system\include" and "C:\Program Files\FlexSim 2021 Update 2\program\system\lib\flexsim.lib".

0 Likes 0 ·
Nikhil_p K avatar image Nikhil_p K Phil BoBo ♦♦ commented ·
Thanks @Phil BoBo! It finally worked!
0 Likes 0 ·