diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-08 21:15:03 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:59 +0200 |
| commit | 0c15fdab70d433b6f5338176c3359e7a6ff0ff57 (patch) | |
| tree | b98a15e9ac65586a606bb31e3bce2dc131d60976 /src/sagas | |
| parent | 8db9161553ece681a0c9a6f50b710ce6cbd3c8dc (diff) | |
Implement unit count limit per machine
Diffstat (limited to 'src/sagas')
| -rw-r--r-- | src/sagas/topology.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/sagas/topology.js b/src/sagas/topology.js index d674c695..9c5087cc 100644 --- a/src/sagas/topology.js +++ b/src/sagas/topology.js @@ -22,6 +22,11 @@ import { updateRackOnTile } from "../api/routes/tiles"; import { + DEFAULT_RACK_POWER_CAPACITY, + DEFAULT_RACK_SLOT_CAPACITY, + MAX_NUM_UNITS_PER_MACHINE +} from "../components/map/MapConstants"; +import { fetchAndStoreAllCPUs, fetchAndStoreAllGPUs, fetchAndStoreAllMemories, @@ -236,8 +241,8 @@ export function* onAddRackToTile(action) { const rack = yield call(addRackToTile, action.tileId, { id: -1, name: "Rack", - capacity: 42, - powerCapacityW: 100 + capacity: DEFAULT_RACK_SLOT_CAPACITY, + powerCapacityW: DEFAULT_RACK_POWER_CAPACITY }); rack.machineIds = new Array(rack.capacity).fill(null); yield put(addToStore("rack", rack)); @@ -286,6 +291,11 @@ export function* onAddUnit(action) { const position = yield select(state => state.interactionLevel.position); const machine = yield select(state => state.objects.machine[state.objects.rack[ state.objects.tile[tileId].objectId].machineIds[position - 1]]); + + if (machine[action.unitType + "Ids"].length >= MAX_NUM_UNITS_PER_MACHINE) { + return; + } + const updatedMachine = Object.assign({}, machine, {[action.unitType + "Ids"]: [...machine[action.unitType + "Ids"], action.id]}); |
