question

Kari Payton avatar image
0 Likes"
Kari Payton asked Mischa Spelt answered

Update code for Open/Close ports on reset trigger for fluid generator.

Idk why this is, but whenever I tried the option close port on the reset trigger for the FluidGenerator it didn't work. After some hours I saw something to use clopeop for fluids. I went in and used the custom code trigger on reset option to use closeop function instead of closeoutput and it works. Maybe update the standard fluid trigger options with this function or make functions all the same for fluid and solids?

FlexSim 18.0.1
fluid libraryfluids
· 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.

1 Answer

Mischa Spelt avatar image
1 Like"
Mischa Spelt answered

In case anyone finds this topic in the future let me complement this thread with the FloWorks answer: because FloWorks does not use time slicing but events, you need to make sure that the engine is aware of ports being opened or closed so the flow rates through your network can be recalculated. In pre-17.2 FloWorks separate commands CloseFlowOp and CloseFlowOutput were provided that you had to use instead of FlexSim's closeop and closeoutput. Since version 17.2 FloWorks supports 'dot syntax' which allows you to write:

  1. // Note: type of the variable is FlowObject instead of Object
  2. FlowObject flowObject = model.find("...");
  3.  
  4. // "Red bar" for all output, just like in regular FlexSim
  5. flowObject.output.close();
  6.  
  7. // Close a single port, equivalent of 'old' closeop/CloseFlowOp
  8. flowObject.output.ports[1].close();

or directly through

  1. // note the use of .as(..) to ensure that the treenode is treated as flow object
  2. model.find("...").as(FlowObject).output.close();
  3. model.find("...").as(FlowObject).output.ports[1].close();
5 |100000

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