question

Tom S4 avatar image
1 Like"
Tom S4 asked Jordan Johnson commented

ProcessFlow Module SDK help

I'm trying my hand at a "Hello World"-ish ProcessFlow module. This is to create a new PF delay that multiplies the delay by 1000. I was successful in using the examples provided for vanilla FlexSim, but haven't been able to get anything to work for a ProcessFlow add-on yet.

I am getting a ton of errors when compiling - I think this is the primary error:

  1. C:\Users\<user>\Desktop\FlexSimDev\FlexSim 2023\modules\MyDelayModule\ModuleDLL\flexsimcontent\processflow\ProcessFlowObject.h(19,1): warning C4275: non dll-interface class 'FlexSim::ObjectDataType' used as base for dll-interface class 'ProcessFlow::ProcessFlowObject'


I got the FlexSim header files and DLLMain.cpp from "/program/system/include",

the FlexSim .lib file from "/program/system/lib",

the ProcessFlow .lib and header files "/modules/ProcessFlow/include".

and my files are:

  1. // MyDelay.h \\
  2. #pragma once
  3. #include "FlexsimDefs.h"
  4. #include "Delay.h"
  5.  
  6. namespace ProcessFlow
  7. {
  8. class MyDelay : public Delay {
  9. virtual void bindVariables() override;
  10. virtual double getDelayTime(Token* token) override;
  11. };
  12. }
  1. // MyDelay.cpp \\
  2. #include "MyDelay.h"
  3. #include "Delay.h"
  4.  
  5. namespace ProcessFlow
  6. {
  7. void MyDelay::bindVariables()
  8. {
  9. __super::bindVariables();
  10. }
  11.  
  12. double MyDelay::getDelayTime(Token* token)
  13. {
  14. return 1000 * Delay::getDelayTime(token);
  15. }
  16. }
  1. // module.h \\
  2. #pragma once
  3.  
  4. #include "FlexsimDefs.h"
  5. #include "allobjects.h"
  1. // module.cpp \\
  2. #include "module.h"
  3. #include "MyDelay.h"
  4.  
  5. visible ObjectDataType* createodtderivative(char* classname)
  6. {
  7. if (strcmp(classname, "MyDelay") == 0) {
  8. return new ProcessFlow::MyDelay();
  9. }
  10. return NULL;
  11. }
  12.  
  13. visible SimpleDataType* createsdtderivative(char* classname)
  14. {
  15. return NULL;
  16. }
  17.  
  18. visible void dllinitialize()
  19. {
  20.  
  21. }
  22.  
  23. visible void dllcleanup()
  24. {
  25.  
  26. }

Thank you.

FlexSim 23.0.1
processflowmodule sdkdll error
· 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.

1 Answer

Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered Tom S4 commented

If you are using the default module SDK, then that SDK doesn't link ProcessFlow.lib.

For people new to C++ development: one way to share code is by creating header files that define an API (what you want your code to do). You can implement that API (the secrets of how your code does what it does) in cpp files, and compile those into a .lib or .dll object. You can then share your header files and .lib files. For other people to use this code in their projects, they need to include the header files and link the .lib file.

For this question: these (the errors you shared in the comments of the original question) are linker errors. Basically, you have included the header files, so that all the symbols (e.g. function/class names) are recognized, but you haven't linked the library. Take the last error, which essentially says "you are trying to call ProcessFlow::Delay::bindVariables(), but I can't find a definition for that function anywhere." The answer is to link ProcessFlow.lib in your project.

To fix this error, you just have to add ProcessFlow.lib to your additional dependencies in your project's properties, under Linker/Input:

1673974047807.png

Note that I copied the process flow headers/lib into a folder called pfcontent, next to the flexsimcontent folder. If your paths are different, you may need to adjust the include.


1673974047807.png (38.8 KiB)
· 1
5 |100000

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