Reputation: 93
I've been trying to use Resource Function timeInState(ResourceUsageState.USAGE_BUSY, TimeUnits.Hour)
to measure how may hours a machine is busy. This is my approach using HorasExtra as a variable:
I get this error: class com.anylogic.engine.Agent cannot be cast to class horas_extra.M1_Extra (com.anylogic.engine.Agent and horas_extra.M1_Extra are in unnamed module of loader 'app')
I really would like to use the ResourceFunctions but I think I'm missing something. I'm most likely not completely understanding this: "The resources seized by an agent can be accessed via the unmodifiable LinkedList resourceUnits collection of the agent".
There's no further information about the topic on AnyLogic nor other websites. Please advice. Thank you!
Upvotes: 0
Views: 678
Reputation: 93
I found a solution to my problem I'd like to share in case it's helpful for somebody or if there's anything I should be warned.
M1_Extra
(this would be my machine).Extra
, b) Function: fnBusy
, c) Event: fnUpdate
.Extra= timeInState(ResourceUsageState.USAGE_BUSY, TimeUnits.HOUR);
fnBusy();
HE
HE = ((M1_Extra)unit).Extra;
And Unit type M1_Extra
That way you can acess the Resource Functions. Thanks!
Upvotes: 1