i m trying to interact with the simulation model. if i m using the method of sending a request to http address. how can i get one http server that i can use in codes
i m trying to interact with the simulation model. if i m using the method of sending a request to http address. how can i get one http server that i can use in codes
Hi @Asif A, I am having difficulties understanding what you are asking.
Until then, here is the documentation on the FlexSim webserver that might be helpful:
https://docs.flexsim.com/en/19.1/Reference/DeveloperAdvancedUser/Webserver/
hi @Benjamin W2, i m trying to create a model that can get the live feeds from the external signal. by which the model can be updated in the real time. for example in simple model having a breakdown every 100 minutes, using the live feed the when the breakdown takes place the operator can be called to fix it or the model can be told to resume the processing, like wise similar operations can be done by updating the model using the live feed interaction with the help of sockets.
i was able to get the live feed from the external signal. Basically the flexsim works as the server and will accept the connections. then using the external script that works as the client and arguments or text are sent to the flexsim. the flexsim model will then update in the real time and will display the text on the model screen in the real time.
though we were enable to develop the codes for operations related to breakdown or more complex changes. but we were successful to develop a simple live feed interaction using the node.ja and visual studio for the flexsim.
is it possible to use this method or any other method to do so for more complex updates such as resuming the breakdowns in the model? if it is possible then how can it be done. i need some help for codes for operations like breakdown. i have attached the flexsim model and the screen shot of the external node.js code written in visual studio.
@Asif A If I understand you correctly, you have successfully established a live feed between your process and FlexSim. Your question is how to use the input received from your process to change the state of your processors in Flexsim to reflect the actual process. Is that correct?
If so, I would assign the input text to a global variable in your model. Then on some model trigger, I would have your processors evaluate the state of that global variable and change their state accordingly.
Where are you currently storing your input from the socket connection?
thank u so much @Benjamin W2 .yes its correct, i have established a live feed connection..and my question is how to change the state of the processors for example breakdowns. can u please give little brief explanations. it will b really helpfull for me. may b with en example model..if possible
Hi @Asif A,
I think that this code should work, however you will have to test it on your end since I don't have access to your client.
On your Tools tab, click into your recieveOnSocket User command.
I added this code underneath line 18:
// Add Logic for processor if (input == "Down") { Model.find("Processor1").as(Object).stop(STATE_STOPPED); } else if (input == "Resume") { Model.find("Processor1").as(Object).resume(STATE_IDLE); }
Note that you will need to change "Down" and "Resume" in the if statements to whatever you are reading from your client.
I hope this helps!
Thanks @Benjamin W2, this was really helpful. i had to made few changes, but at last it was working. what i did was added a simple processing line with one source, queue, processor, and a sink. when i ran the script the processor successfully stooped and resumed.
but i had another problem. when i clicked on reset and then on run button for running the model, and then when i clicked on the play button on the script for starting the socket the processing line stopped and the flexsim crashed. so if i want to start and stop the running processing line what changes i can to make or can i use the same code?. similarly if i set the breakdown and the processor stops due to breakdown, can i use the run the same code to resume the processor?
i have attached the working flexsim model. tahir-sockets-server.fsm
Your current code is built to listen to a single command from another socket, then closes the connection. You even close the connections twice both in the recieveSockets and in endSockets. It is crashing because it is waiting for an input from your client. Do you want the server continuously running and receiving inputs? Also I wouldn't use a global variable for the connectionID. If you hit reset then it will default back to 0 and you don't have anything built in to close any sockets you might have open and this will prevent you from reestablishing a connection. I would do what the original code was doing and use a node to hold that information if a connection was made.
yes i wish the server to be continuously running and receive the inputs. what i want to do is run the model and then use the input from the client to start and stop the processor.
so what changes i can make here. can u help me with the replacement code to do so.
I used the original template and the process flow controls the connections. See if this works for you.
@Joshua S, @Benjamin W2. i had made this model with that was able to interact with the external signal as mentioned in the above question. it was working fine. it still works but i m facing one problem now. i have tried running it and its working fine but i cant find the custom code written to startSocket, endSocket, recieveOnSocket. to be exact i have forget how to open the custom code window that i had written previously.how to open the custom code for startSocket, endSocket, recieveOnSocket so if i want to edit the codes. can you please help me with this. i have also attached the model. it is the same model mentioned in the above comments.tahir-sockets-server-copy.fsm
10 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved