}
@Override
public void onUpdateTick()
{
TickTracker tt = null;
try
{
currentTick++;
while (!upcomingTicks.isEmpty())
{
tt = upcomingTicks.peek();
int diff = (int) (currentTick - tt.lastTick);
if ( diff >= tt.current_rate )
{
// remove tt..
upcomingTicks.poll();
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
switch (mod)
{
case FASTER:
tt.setRate( tt.current_rate - 2 );
break;
case IDLE:
tt.setRate( tt.request.maxTickRate );
break;
case SAME:
break;
case SLEEP:
sleepDevice( tt.node );
break;
case SLOWER:
tt.setRate( tt.current_rate + 1 );
break;
case URGENT:
tt.setRate( 0 );
break;
default:
break;
}
if ( awake.containsKey( tt.node ) )
addToQueue( tt );
}
else
return; // done!
}
}
catch( Throwable t )
{
CrashReport crashreport = CrashReport.makeCrashReport(t, "Ticking GridNode");
CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.gt.getClass().getSimpleName() + " being ticked." );
tt.addEntityCrashInfo(crashreportcategory);
throw new ReportedException(crashreport);
}
}