PV780T Modbus and Angelscript

Discuss issues and ideas you have to configuring displays with PowerVision
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

PV780T Modbus and Angelscript

Post by Ocelot » Wed Nov 01, 2017 2:01 pm

Hello,

I had a question regarding scripting.

I am currently performing a lookup from a pre-populated list to get a variables guid, writing a new value to that guid id, then firing a sendEvent() that transmits Modbus.

I am noticing that it seems 50/50, or unreliable, as to whether or not the new value is transmitted over modbus, or the old value.

simplified ex script,

Code: Select all

void $Transmit New Modbus$ () 
{
	int var_guid = 0;
	double number = 0;

	smRead(VariableIDs.Number_GUID, var_guid); //where Number_Guid is a pre-populated list lookup value defined as a global variable
	smWrite(var_guid, number); // Write the number value to the PowerVision Variable
	
	sendEvent(EventIDs.Transmit_Modbus); //This state machine is a simple one, all it does is fire a RefreshMappingGroup Action containing the PowerVision Variable.
	
	sendEvent(EventIDs.Close_Keypad); // Close the keypad the user was using to enter the new setting value
}
I was wondering if there is a asynchronous vs synchronous issue where one process is being executed before the other has had time to finish. If there is, is there any 'await' option in Angelscript so one task finishes before the other starts? I tried a while loop of old val != new val smWrite(newval) and it locks up the display.

Any advice as to how to handle something like this would be appreciated.
Kyle Bruneau
Applications Engineer - MurCal Inc
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: PV780T Modbus and Angelscript

Post by boyce » Wed Nov 01, 2017 2:58 pm

There is nothing like a 'wait' command because all events are placed in a queue and the events are executed synchronously. I assume the var_guid is the VariableIDs variable ID for a variable. The smRead and smWrite would be processed immediately but the sendEvents are all queued. When you send an event from a script that event is not executed until after the function in the script returns. When the function in the script returns it then takes the next event from the queue to execute.
Is it possible that the value of the variable (for the var_guid variable) is being updated before the Modbus event is executed?
I talked to the test engineers and they said, assuming it is the master, it is best to stop the Modbus read polls to do the write.
Boyce Schrack
Enovation Controls
Ocelot
Posts: 77
Joined: Thu Oct 06, 2011 10:43 am

Re: PV780T Modbus and Angelscript

Post by Ocelot » Wed Nov 01, 2017 3:14 pm

Boyce,

Thanks for answering the async vs snyc question.

The display is a modbus master and I am indeed stopping the modbus read polls, followed by a very short pause to let anything currently buffering to complete, then perform the writes, I then restart the reads later on.

What I may do instead of trying to see if the var_guid variable is being overwritten by something elsewhere is change a couple of things and move it from being a global variable to a local variable, to eliminate that possibility.
Kyle Bruneau
Applications Engineer - MurCal Inc