Diego
Diego

Reputation: 93

AnyLogic: How can I measure total busy/idle time?

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:

Approach

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

Answers (1)

Diego
Diego

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.

  1. I created a Resource Type M1_Extra (this would be my machine).
  2. In M1_Extra I defined: a) Variable: Extra, b) Function: fnBusy, c) Event: fnUpdate.
  3. In fnBusy: Extra= timeInState(ResourceUsageState.USAGE_BUSY, TimeUnits.HOUR);
  4. In fnUpdate: fnBusy();
  5. Then, in Main I created: a) Variable: HE
  6. In the resourcePool,On Release: HE = ((M1_Extra)unit).Extra; And Unit type M1_Extra

That way you can acess the Resource Functions. Thanks!

Upvotes: 1

Related Questions