state of a process

state of a process

carlos_s3
Not applicable
115 Views
4 Replies
Message 1 of 5

state of a process

carlos_s3
Not applicable

Hello,

I'm trying to code the states of a certain processor. That is, I want to be able to determine the state: if it's busy or idle. Is there a way to code it?

Accepted solutions (1)
116 Views
4 Replies
Replies (4)
Message 2 of 5

arunTTT2P
Contributor
Contributor
Accepted solution

Hi @Carlos S3,

Yes, you can use an if condition along with an object property method to access the state of the processor. Here I have used a state string. Similarly, you can use a state number.

State number and state string can be known from stats node of the processor tree.

string State = Processor.stats.state().valueString; // returns the state of an object as string
int Statenum = Processor.stats.state().value// returns the state of an object as integer

if condition along with the object property.

Object Processor = model().find("Processor1");
if(Processor.stats.state().valueString == "idle") // Similarly use busy state
{
	Processor.color = Color.red;
}

state-profile screen shot- statenum and statestring are taken from the profile node.

8969-state.png

Regards,state.fsm

Arun KR

Message 3 of 5

mischa_spelt
Advisor
Advisor

Except instead of

Processor.stats.state().valueString == "idle"

I would recommend using numeric constants:

Processor.stats.state().value == STATE_IDLE
Message 4 of 5

carlos_s3
Not applicable

Hi, I tried your suggestion but I think my version doesn't let me proceed. I'm using an old one. Version 7.3.6

0 Likes
Message 5 of 5

joerg_vogel_HsH
Mentor
Mentor
setstate(node("/Processor",model()),STATE_IDLE);

Pre-Dot-syntax-time

getstatenum(node("/Processor",model())) == STATE_IDLE;