Free AnyLogic basic lessions - Learning AnyLogic by examples is made by Khoi Tran.
In this example you can learn, how to access the root object from another active object.
1. Become an AnyLogic Expert Step by Step How to access a root active object
2. About me khoi.tran@simbean.com 2 My name is Khoi Tran and I’m living in beautiful Stuttgart, Germany. As a 12-years expert in the software industry and 6-years expert in simulation with AnyLogic, I would like to share my experiences with you on a simple and fast path.
3.
4. Create a new model khoi.tran@simbean.com 4 Write the name of the model e.g. „DemoRootAccessControl“ Choose menu item „Model“ Right mouse click on the Project view Create a new model
5.
6. Choose this menu itemWrite „SpeedControl“ instead of „MyClass“ Create an active object called “SpeedControl” in the model project
7. Insert a control object to an active object khoi.tran@simbean.com 6 Choose control tab on the palette on the right side Drag and drop the slider on the graphical editor of the active object Drag & drop the slider onto the graghical editor
8. Set properties for control object „slider“ khoi.tran@simbean.com 7 Enable the “icon” checkbox Set maximum value to 300
22. Select “Create a group”Rename the picture group to “groupCar”
23. Set properties for „source“ khoi.tran@simbean.com 12 Write “groupCar” for the entity animation shape Set the unique shape for each entity
24. Create embedded active object khoi.tran@simbean.com Drag & drop the “SpeedControl” active object onto the graphical editor of the “Main” active object 13
25. Code for changing the conveyor behaviour in „Main“ or so called „Root“ active object khoi.tran@simbean.com 14 Write this two lines of code in “Action” property Click on the “SpeedControl” active object to get back to the graphical editor Put the two lines of code Main main = ((Main)getEngine().getRoot()); main.conveyor.set_speed(value);
26. Run the model khoi.tran@simbean.com Click on the run button and choose the simulation 15 You can run the model and see the result Try to change or set properties to see some small effects e.g. Where the property is put on “false”, you can turn it on with “true”. Set and unset the checkboxes. You need to restart the model to see the effects
27. Thank You khoi.tran@simbean.com 16 IF YOU HAVE ANY QUESTION, IDEA, FEEDBACK or DID FIND ANY MISTAKE, PLEASE SEND ME an EMAIL khoi.tran@simbean.com BECAUSE I WANT to IMPROVE CONTINUOUSLY this PRESENTATION. I APPRECIATE a lot YOUR TIME.