|
@ -0,0 +1,53 @@ |
|
|
|
|
|
package a8k.app.service.statemgr; |
|
|
|
|
|
|
|
|
|
|
|
import a8k.app.a8ktype.device.ConsumableGroup; |
|
|
|
|
|
import a8k.app.a8ktype.device.consumables.PreReactionAreaState; |
|
|
|
|
|
import a8k.app.a8ktype.device.consumables.PreReactionGridGroup; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
@Component |
|
|
|
|
|
@Slf4j |
|
|
|
|
|
public class PreReactionAreaStateMgrService { |
|
|
|
|
|
public PreReactionAreaState preReactionAreaState = new PreReactionAreaState(); |
|
|
|
|
|
|
|
|
|
|
|
public synchronized PreReactionAreaState getState() { |
|
|
|
|
|
return preReactionAreaState; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized void takeAwayMixLiquid(ConsumableGroup group, Integer posoff) { |
|
|
|
|
|
var grid = preReactionAreaState.gridGroups.get(group.ordinal()).grids.get(posoff); |
|
|
|
|
|
grid.inUse = false; |
|
|
|
|
|
grid.projectTaskCxtId = null; |
|
|
|
|
|
grid.startTime = 0l; |
|
|
|
|
|
grid.remainTimeS = 0; |
|
|
|
|
|
grid.preReactionTotleTimeS = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized void startPreIncubation(ConsumableGroup group, Integer posoff, String projectTaskCxtId, Integer preIncubationTotleTimeS) { |
|
|
|
|
|
var grid = preReactionAreaState.gridGroups.get(group.ordinal()).grids.get(posoff); |
|
|
|
|
|
grid.inUse = true; |
|
|
|
|
|
grid.projectTaskCxtId = projectTaskCxtId; |
|
|
|
|
|
grid.startTime = System.currentTimeMillis(); |
|
|
|
|
|
grid.remainTimeS = preIncubationTotleTimeS; |
|
|
|
|
|
grid.preReactionTotleTimeS = preIncubationTotleTimeS; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 500) |
|
|
|
|
|
synchronized public void updateRemainTime() { |
|
|
|
|
|
for (PreReactionGridGroup group : preReactionAreaState.gridGroups) { |
|
|
|
|
|
group.grids.forEach(grid -> { |
|
|
|
|
|
if (grid.inUse) { |
|
|
|
|
|
grid.remainTimeS = (int) ((grid.preReactionTotleTimeS * 1000 - (System.currentTimeMillis() - grid.startTime)) / 1000); |
|
|
|
|
|
if (grid.remainTimeS <= 0) { |
|
|
|
|
|
grid.remainTimeS = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |