How can webserver's job access the model parameters and performance measures?

How can webserver's job access the model parameters and performance measures?

yokota_t
Not applicable
32 Views
3 Replies
Message 1 of 4

How can webserver's job access the model parameters and performance measures?

yokota_t
Not applicable

[ FlexSim 21.0.6 ]

Hi everyone.

I'm trying to submitting jobs to FlexSim webserver. I've succeeded in creating an instance of my model and running the simulation. But I'm having difficulty changing the values of model parameters and getting the values of the performance measures by JSON data. What should I do?

My HTML form and the result of the job are below.


<form action="http://127.0.0.1/webserver.dll?submitjob" method="POST">

<input type="hidden" name="job" value='{"modelname":"my%20model%20parameter","timeout":3600,"priority":5,"setupcommands":

[{"command":"settable=/Tools/ParameterTables/Parameters","data":"values=[\"Parameter1\", 10]"},

{"command":"setrunspeed=1000000"},{"command":"setstoptime=86400"},{"command":"toolsnodefunction=setupscript"},{"command":"run"}],

"resultcommands":[{"command":"getnodedata=/Tools/PerformanceMeasureTables/PerformanceMeasures"}]}'>

<input type="submit">

</form>


{"status":"complete","setupcommands":[{"command":"settable=/Tools/ParameterTables/Parameters","data":"values=[\"Parameter1\", 10]","verb":"GET","reply":"HTTP/1.1 404 Not Found"},{"command":"setrunspeed=1000000","data":"","verb":"GET","reply":"HTTP/1.1 200 OK"},{"command":"setstoptime=86400","data":"","verb":"GET","reply":"HTTP/1.1 200 OK"},{"command":"toolsnodefunction=setupscript","data":"","verb":"GET","reply":"HTTP/1.1 200 OK"},{"command":"run","data":"","verb":"GET","reply":"HTTP/1.1 200 OK"}],"resultcommands":[{"command":"getnodedata=/Tools/PerformanceMeasureTables/PerformanceMeasures","data":"","verb":"","reply":"{\"name\":\"PerformanceMeasures\",\"classes\":[\"PerformanceMeasureTable\"],\"superclasses\":[\"FlexSimEventHandler\"],\"behaviour\":\"behaviour\",\"spatial\":[0,0,0,1,1,1,0,0,0],\"special\":[\"\",\"VIEW:/standardviews/tools/PerformanceMeasureTable\",\"VIEW:/standardviews/tools/PerformanceMeasureTable\"],\"variable_performanceMeasures\":[[\"PerformanceMeasure1\",[1,\"reference\",\"extraData\"],\"\",\"\"]]}"}]}
0 Likes
Accepted solutions (1)
33 Views
3 Replies
Replies (3)
Message 2 of 4

philboboADSK
Autodesk
Autodesk
Accepted solution

You can use FlexScript to set model parameters and get performance measures.

For example:

Model.parameters["ParamName"].value = 5;
Array pfms = function_s(Model.find("Tools/PerformanceMeasureTables/1"), "getAllPFMs");
for (int i = 1; i <= pfms.length; i++) {
    string name = pfms.up.first.value;
    string value = pfms.value;
}

To execute FlexScript using a default query handler, you can use the "toolsnodefunction" query handler.

The FlexScript function you want to execute needs to be in the model before you run it. Add FlexScript functions to the model that you will execute with the "toolsnodefunction" query handler.

Attached is an example model and webpage with example code that submits a job to the webserver to open the model, set the values of the model parameters, run the model, and get the results of the performance measures.

set_param_get_perf_example.zip

The model has a "setupscript" nodefunction for setting the model parameters based on the job specification, a "processresults" nodefunction for getting the performance measures when the model is finished running, and a "modeloutput" node where it stores those values.40391-1623358871896.png

Values can be passed using a web form:

40373-1623358990807.png

Results can be retrieved:

40385-1623359089398.png

The setup script and results processing scripts are defined within the model and executed by the "toolsnodefunction" query handler.

If you want to configure FlexSim to be able to do this for any arbitrary model without any modifications to the model, then you should use the Module SDK to add query handlers to FlexSim instead of putting them in the model. Otherwise, you should configure the model itself with setup and result scripts as shown in the attached example.



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 3 of 4

Jeanette_Fullmer
Community Manager
Community Manager

Hi @Yokota T, was Phil BoBo's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes
Message 4 of 4

yokota_t
Not applicable

I'm sorry I didn't notice your answer immediately.

I understand. Thank you for your advice.

0 Likes