question

Mustafa Furkan SV avatar image
0 Likes"
Mustafa Furkan SV asked Jason Lightfoot commented

Processor stops working unexpectedly

I am creating a basic simulation with a line of 4 Processors connected with queues. I use javascript code in GUI listening to a WebSocket. Using the incoming message from that socket, I change the parameters of a Processor.

socket.onmessage = function(e) {
    var data = JSON.parse(e.data);   
    for (var object in data) {
        for (var type in data[object]) {
            var val = data[object][type];
            fireFlexsimEvent("receiveInput", object, type, String(val));
        }
    }
};

Above is a cleaner and simpler version of the function used for handling incoming messages to the socket. Below is an example form of an incoming message.

{
    "Processor1": {
        cycletime: 6
    },
    "Processor2": {
        cycletime: 7
    }
}

Basically, I am iterating all the elements in the JSON object to get the corresponding Processor name and its property to change and update the value of the property of that Processor.

Below is the cleaner and simpler version of the receiveInput Flexscript.

string objName = param(1);
string type = param(2);
string _value = param(3);
double value = _value.toNum();

print("Setting", objName + "." + type, "to", value

Model.find(objName + ">variables/" + type).value = value;

I also have an external dashboard to trigger a socket message. Updating property values works generally fine. However, sometimes with no apparent reason, the Processor whose property I want to change stops processing. When this happens, the connection coming into the Processor has a red triangle instead of green on the processor end. All Processors work fine after I reset the simulation. I assumed that it might be because in the for loop in the socket.onmessage function, receiveInput script might be fired a second time before it finishes running for the first time and this might have messed things up but I am not sure and I do not know how to fix it. Please help, any help will be greatly appreciated. Thank you.

mymodel.fsm

FlexSim 19.0.0
processorflexsim 19.0.0socketfireflexsimeventprocessor stops working
mymodel.fsm (25.2 KiB)
· 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.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Hi @Mustafa Furkan SV,

Figuring out exactly what is happening in your custom JavaScript code is beyond the scope of normal technical support and what can be reasonably expected from community members. This is likely why your question has not attracted any attention. We'll need you to help us more.

If you could please simplify the question with replication steps that demonstrate the issue it would greatly help any 3rd parties in helping you resolve the issue you're encountering.

You can also reach out directly to your local FlexSim distributor for live help.

1 Like 1 ·
Mustafa Furkan SV avatar image Mustafa Furkan SV Ben Wilson ♦♦ commented ·

Hi @Ben Wilson,

Thank you for your feedback. I will update my question as soon as possible.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Ben Wilson ♦♦ commented ·

@Ben Wilson Is anyone looking at this? It seems claimed.

0 Likes 0 ·

0 Answers