|
|
@ -5,6 +5,10 @@ import com.dreamworks.boditech.utils.AppError; |
|
|
|
import com.dreamworks.boditech.utils.AppRuntimeException; |
|
|
|
import com.dreamworks.boditech.utils.MyCommon; |
|
|
|
public class ActIncubator extends ActMotor { |
|
|
|
// init exit slot index |
|
|
|
public static final Integer INIT_EXIT_SLOT_INDEX = 10; |
|
|
|
// incubator slot count |
|
|
|
public static final Integer SLOT_COUNT = 20; |
|
|
|
// slots |
|
|
|
private final IncubatorSlot[] slots; |
|
|
|
// alloc index |
|
|
@ -15,8 +19,8 @@ public class ActIncubator extends ActMotor { |
|
|
|
super(mid, device); |
|
|
|
|
|
|
|
this.allocStartIndex = 0; |
|
|
|
this.slots = new IncubatorSlot[20]; |
|
|
|
for ( int i = 0; i < 20; i++ ) { |
|
|
|
this.slots = new IncubatorSlot[ActIncubator.SLOT_COUNT]; |
|
|
|
for ( int i = 0; i < ActIncubator.SLOT_COUNT; i++ ) { |
|
|
|
IncubatorSlot slot = new IncubatorSlot(this); |
|
|
|
slot.index = i; |
|
|
|
slot.isFree = true; |
|
|
@ -36,9 +40,9 @@ public class ActIncubator extends ActMotor { |
|
|
|
|
|
|
|
// get free slot |
|
|
|
public IncubatorSlot allocSlot() { |
|
|
|
for ( int i = this.allocStartIndex; i < 20; i++ ) { |
|
|
|
for ( int i = this.allocStartIndex; i < ActIncubator.SLOT_COUNT; i++ ) { |
|
|
|
if ( this.slots[i].isFree ) { |
|
|
|
this.allocStartIndex = (i + 1) % 20; |
|
|
|
this.allocStartIndex = (i + 1) % ActIncubator.SLOT_COUNT; |
|
|
|
return this.slots[i]; |
|
|
|
} |
|
|
|
} |
|
|
@ -59,7 +63,7 @@ public class ActIncubator extends ActMotor { |
|
|
|
|
|
|
|
// has locked slot |
|
|
|
public Boolean hasLockedSlot() { |
|
|
|
for ( int i = 0; i < 20; i++ ) { |
|
|
|
for ( int i = 0; i < ActIncubator.SLOT_COUNT; i++ ) { |
|
|
|
if ( !this.slots[i].isFree ) { |
|
|
|
return true; |
|
|
|
} |
|
|
@ -67,6 +71,16 @@ public class ActIncubator extends ActMotor { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// has free slot |
|
|
|
public Boolean hasFreeSlot() { |
|
|
|
for ( int i = 0; i < ActIncubator.SLOT_COUNT; i++ ) { |
|
|
|
if ( this.slots[i].isFree ) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// update runtime slot status |
|
|
|
private void updateRuntimeSlotStatus() { |
|
|
|
this.getDevice().runtimeVariableService.setString( |
|
|
|