question

Jye S avatar image
3 Likes"
Jye S asked Phil BoBo edited

Module Development for C++ User Commands

I've recently been going over and over the Module SDK documentation as our team is hoping to make use of this functionality, particularly for developing user commands in C++ and within an IDE. I went through the documentation and the included examples, I was able to get the Snow Processor example to work just fine and I tried to use this knowledge to work out how we could add user commands to FlexSim through a DLL.

I've worked over this for a few days and I've yet to quite work it out so I was hoping to get some guidance on where I'm going wrong. I've started with the basic visual studio project template from the FlexSim site and have followed the documentation for setting up and building the DLL. I'm able to get the project to build just fine and I've gone into the FlexSim tree to set up a new user command through a test module as shown in the screenshot below. I'm able to get FlexSim to recognise the function but the actual linking to the DLL seems to throw errors as you can see in the system console.

fs.pngI've included a link to the module here (couldn't upload it due to size limits) and hopefully between that and seeing how I've set up the tree you can let me know where I'm going wrong. The documentation doesn't specify where exactly to place the function within the VS project, so I played around with placing the function in the module class, as well as its own C++ class, then using the createsdtderivative() function to try create that individual class.


Thanks for you help.

FlexSim 21.1.4
module sdkuser commandsdkuser commandsmodule development
fs.png (44.8 KiB)
5 |100000

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

1 Answer

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Phil BoBo edited

1. Your output is a file without an extension. Make sure your project target is generating a dll file:

1627479981885.png

2. Your flexsimcontent files are not from the target FlexSim version, so the dll has unsuccessful bindings that prevent it from loading:

1627480044172.png

Copy the correct flexsimcontent headers from the target version of FlexSim that you are compiling against:

1627480072152.png

3. Your function needs to have the correct signature in order to be accessed as a user command. It must return a double and have a particular set of parameters. The FLEXSIMINTERFACE macro defines these parameters:

1627480194305.png

4. The text of your node has to be correctly formatted with the path to the dll and function. You have 2 semicolon characters where you should only have 1.

1627480297125.png


1627479981885.png (133.1 KiB)
1627480044172.png (29.3 KiB)
1627480072152.png (234.8 KiB)
1627480194305.png (91.5 KiB)
1627480297125.png (42.2 KiB)
· 8
5 |100000

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