article

Paul Toone avatar image
0 Likes"
Paul Toone posted Brandon Peterson edited

ModelLibraries Node   

You can add many facets to a model, such as user commands, global variables, global macros, etc. where the definition is "hidden" from the user, so that they don't see it in their User Commands window, Global Variables window, etc. These can also simply refer back to structures in your library, so that you don't have to continually copy stuff into the model when updating. This is done by adding a node named "ModelLibraries" to the model's Tools folder and giving its substructure various data. While you don't need to have a custom library loaded to have this feature be part of a model, it will probably be most used for user libraries, hence we include this information with this topic.

To create this functionality, add a node into model/Tools, and give it the name "ModelLibraries". Inside of that node, add another node, and give it the name of your library, i.e. MyLib. Inside of that node, there are several nodes that can be added. Their name defines their meaning to FlexSim. Names and meanings are listed below:

  • commands - If you add a node named "commands", you can place commands inside that node. These commands will be accessible to the user to call, and will be documented in the commands documentation, but won't be visible in the User Commands window. The structure of each command should be the exact same as the structure of model/Tools/UserCommands.

  • commandspath - You can add a node named "commandspath" and give it text data that specifies a path to an alternate location that holds the definition of the commands. In this case the structure of the path's destination should be the exact same as the structure of model/Tools/UserCommands. This allows you to leave your command definitions in the user library, and then just have this node refer to it.

  • globalvariables - You can add a node named "globalvariables" and give it the same sub-structure as found in Tools/GlobalVariables to define additional global variables that are available to the end user but "hidden" from the "Global Variables" window.

  • globalvariablespath - Like commandspath, you can redirect the location of where global variables are defined

  • fsmacros - Here you can add a node named "fsmacros", give it text data with multiple #define macros. These macros will be visible (blue) to the user and will be added as options in auto-completion hints.

  • fsmacrospath - Like commandspath, you can redirect the location of where flexscript global macros are defined with the "fsmacrospath" option.

  • binaries - You can add a node named "binaries" and give it text data that specifies a list of additional .lib or .obj files that you want to link to when FlexSim is compiled. This is only needed if you have c++ toggled code that must be compiled, or if you expect your end users to define c++ code that can access pre-compiled functionality. This text will be added to the "Additional Library Dependency" field during the C++ linker phase. The linker's library path is specified as /program/system/lib in FlexSim's install directory, so to link with a lib file in FlexSim's libraries directory, you would specify a path like: ../../../libraries/MyLib...

  • binariespath - Like commandspath, you can redirect the location of where linker options are specified with the "binariespath" option.

  • triggers - You can also add several triggers to fire at certain points. To do this add a node and give it the name "triggers", and add various nodes into that triggers node.

  • Valid triggers are:
  • OnModelPreOpen - Fired immediately after a model tree is loaded, and before any model initialization code is fired.
  • OnModelOpen - Fired after a model has been opened and all initialization code has finished.
  • OnModelPreSave - Fired just before a model is saved to file.
  • OnModelSave - Fired just after a model has been saved to file.
  • OnLoadState - Fired when a state load is performed.
  • OnSaveState - Fired when a state save is performed.
  • OnRunStart - Fired whenever the user presses the "Run" button, as well as whenever the go() command is called.
  • OnRunStop - Fired whenever the user presses the "Stop" button, as well as whenever the stop() command is called.
  • OnModelReset - Fired whenever the user presses the "Reset" button, as well as whenever resetmodel() is called.
  • OnPostCompile - Fired after the user compiles the model.



flexsim users manualuser commandtools node
5 |100000

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

Article

Contributors

brandon.peterson contributed to this article paul.t contributed to this article

Navigation

FlexSim 2016.1