Machine Statistics request

Hello everyone,

I am working on the CAD file of the machine from VC.

I added a statistical function to the properties to the machine I’m working on.
In addition, we were able to check the System State for Busy, Idle in the statistical properties.

I think we can use these two to draw Busy Percent from a statistical graph.

What I want is for the Machine to change the status to busy at the start of the process and to change the status to Idle when the process is over.

I’d like to do this in a Python script.
Is there a way to change the status of the Machine I’m working on in Python to Busy, Idle?

Best regards,

Just assign name of the state to the “State” property in the statistics behavior to change the current state.

https://help.visualcomponents.com/4.10/Premium/en/Python_API/vcStatistics.htm?rhhlterm=State&rhsearch=State

Hello, thank you for your help.

I understood how it worked through the explanation and reference.
But I haven’t solved this problem yet.

I’ve added 2 Behaviours properties (Python scripting, statistics) to the modeling component I’m working on.

And I wrote the code as below, but an error message came out.

from vcScript import *
comp = getComponent()
test = comp.getBehaviour(“Statistics”)

def OnSignal( signal ):
pass

def OnRun():
print test.States[0]
test.States(“Busy”,1)
test.States(“Busy”,[2])
delay(15)
test.States(“Busy”,3)

What I want is to define the state of this modeling component as Busy and Idle.

EX) State is in a Idle state before processing and busy during processing

How can I define the State here?

Simply:

def OnRun():
  statistics = getComponent().findBehaviour("Statistics")
  statistics.State = "Busy"

Thanks a lot TSy,

I solved this issue.

I will often use this skill. :slight_smile:

I’m sorry, but I have one more question.

We applied it with the relevant content and confirmed that the state is applied well.

However, when I updated the initial state to Idle at the start of the simulation and pulled the machine’s BusyPercent data with statistics, I was able to see BusyPercent rise in the beginning.

May I know the reason for that?

The code is as follows.

def OnRun():
#초기조건 #Warm up
servo.move(775) #Door Open
static.State = “Idle”

Hi,

That may have something to do with the servo.move command, not sure if it automatically sets the sate to “busy” if a servo is moving something. Although you are setting the state to “idle” right afterwards, the servo.move is a “blocking” function, meaning that it consumes time before going to the next line (to set the state to idle)

br,
Lefa

1 Like

Hello Lefa,

I don’t think it’s a matter of Servo’s movement.
I made python and statistical Behaviours for Component with no function to test this statistic and found BusyPercent rising in the beginning.

Set statistics interval to 1s
image

1 Like

Thanks idkfa,

i solved that problem.