Roger W avatar image
Roger W asked Ben Wilson edited

Running Webkit to call a FlexScript function (fireFlexSimEvent())

I am trying to get a Javascript to run a flexscript through this fireflexsimevent() command I have been seeing around the forums. I have the flexscript to open and close the port of a processor. However, I am clueless with how to work with JS to execute this flexscript command. the examples I downloaded from forums ( are probably different version to mines as I cannot see what they are doing. (I use version 16.1.2).

Could anyone point my in the right direction on how this is done?

Choose One
FlexSim 16.1.2
· 3
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

Do NOT use close or open port on a Fixed Resource Object. Instead try to use open or close Input or Output of a Fixed Resource Object. There exists only some very small bounded situations and objects on which you can use the commands which close and open ports directly. They are commands which works directly on the internal processes of the Flexsim engine and have side effects you have to consider all. If you depend on a edge to or from an object to be closed then insert a queue between the two involved objects and close or open the input or output of this inserted queue. Sometimes you have to insert more objects into a model than there are in reality to build the process.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Joerg Vogel commented ·

@Roger W, you can look in the manual to see the same information on openip(..).

0 Likes 0 ·
Roger W avatar image Roger W Joerg Vogel commented ·

Thanks for the tips and heads up, I will look into openip

0 Likes 0 ·

1 Answer

Ben Wilson avatar image
Ben Wilson answered Ben Wilson edited

Hi @Roger W,

Please carefully review this comment and attached sample model:

There you'll find a 16.0.0 sample model that demonstrates both:

  1. callwebscriptmethod() - calls a Javascript function living in your Webkit GUI from within FlexSim. You can find this example in the Processor's OnEntry trigger.
  2. fireFlexsimEvent() - calls FlexScript inside the model from within the Webkit window's HTML/Javascript. Find this example in the htmlWidget's html code.

Also, please take note of @Jörg Vogel's comment above regarding closing of ports. My answer is an answer to your top question (how to use fireFlexsimEvent()), but you want to be sure that the functionality you're calling within FlexSim is still best practices for FlexSim modeling.

Comment back with any Webkit related questions.

Or start a new question for other topics, like ports, etc.

· 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.

Roger W avatar image Roger W commented ·

Thank you @Ben Wilson, This comment is very helpful. I now understand that the GUI in flexsim can control the model, is it possible to move the GUI onto a website so users can click the "button" and control the model from the site

0 Likes 0 ·
Ben Wilson avatar image Ben Wilson ♦♦ Roger W commented ·

@Roger W,

This previous question you asked has some good answers already. In particular I would read up on the FlexSim webserver. You can find documentation for it within FlexSim 16.1.2's user manual under Miscellaneous Concepts. This is probably the easiest of the options, since it allows FlexSim itself to the the web server.

Other options mentioned on that previous question probably require additional servers to be configured:

  • websockets - "an advanced technology that makes it possible to open an interactive communication session between the user's browser and a server". Could be used for communication between a webserver and a FlexSim Webkit gui.
  • FlexSim's sockets implementation - could be used for communication between a webserver and FlexSim model.
  • Implement your own communication layer via a DLL.

If you have any questions regarding any of these specific approaches, please start a new question, as this question regarding fireFlexsimEvent() has been answered.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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