question

Gabriel Morgante avatar image
0 Likes"
Gabriel Morgante asked Gabriel Morgante commented

How to get the cycletime variable

@phil.bobo
I am creating a new post as you suggested but I think your previous answer is right on the spot


The only problem is that it's not acting as it should as you can see in the following images:

Here I'm trying to store the value in a label



It should be '4000' but instead it's recording '200'

In fact this item has no variable with a value of '200'

What am I doing wrong?

I have attached the model so you can take a look if you want...operadores.fsm

FlexSim 19.0.0
scriptvariables
print0.png (17.0 KiB)
print1.png (6.2 KiB)
print3.png (13.2 KiB)
print2.png (22.0 KiB)
operadores.fsm (4.0 MiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Gabriel Morgante commented

You don't want to put your code in either place (OnSetupFinish or OnProcessFinish).

Move your code from OnSetupFinish into OnMessage.

In your OnSetupFinish, send a delayed message in 0 time.

OnSetupFinish fires before the Process Time field. You need a trigger right after the Process Time field. You can do that with OnMessage.

You could customize your Process Time code to store that value on a label before returning it, but again, that's still going to fire AFTER the OnSetupFinish code that would be trying to read that label. You are trying to use a value that hasn't been determined yet. You need to change it so that you are using that value after it has been calculated.

· 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.

Gabriel Morgante avatar image Gabriel Morgante commented ·

Phil,

I'm trying to implemente what you said but when I use the code 'getitemvar(item, 2)' in the 'OnMessage' trigger it sees 'item' as a node(text in blue) and then I get an error message (attached). How should I reference the incoming Item when using the 'OnMessage' trigger?

Thanks a lot!

0 Likes 0 ·
print0.png (63.1 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ Gabriel Morgante commented ·

Pass the item as the "From" object. Reference it in the On Message trigger using fromObject or msgsendingobject.

1 Like 1 ·
Gabriel Morgante avatar image Gabriel Morgante Phil BoBo ♦♦ commented ·

It worked! Thanks a lot Phil!

0 Likes 0 ·
David Seo avatar image
0 Likes"
David Seo answered Phil BoBo converted comment to answer

@Gabriel Morgante

You need to set the command of getitemvar(item, 2) in 'OnProcessFinish' instead of OnSetupFinish.

The cycletime (process time) is set after 'SetupFinish' trigger.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Gabriel Morgante avatar image Gabriel Morgante commented ·

When I set it to the 'OnProcessFinish' trigger it works fine. But the problem is it will only record the cycle time AFTER it's done. I wanted to get it when it starts so I can feed the time to the keyframe gap of the progress bar I'm trying to animate...

I'm trying other triggers but no luck so far.. Would it be possible to add a code into the process time script that records the generated value in a label or something?

0 Likes 0 ·