Skip to content

Commit

Permalink
Merge pull request #110 from ctrlaltf2/ctc-office/pls
Browse files Browse the repository at this point in the history
Fix occupancy message or something
  • Loading branch information
ctrlaltf2 authored Aug 4, 2022
2 parents 6e5a6c5 + ae24c7a commit 29e8482
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/modules/CTCOffice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,24 @@ class CTCOffice extends React.Component {
case 'throughput':
// TODO: message validation
const throughput = _.cloneDeep(this.state.throughput);
throughput[payload.line] = payload.value;
throughput[payload.line.toLowerCase()] = payload.value;

this.setState({
throughput: throughput
});
break;
case 'occupancy':
console.log(payload);
// TODO: message validation
payload.line = payload.line.toLowerCase();
// console.log(payload);
this.updateBlockOccupancy(payload.line, payload.block_id, payload.value);
this.updateBlockOccupancy(payload.line, payload.block_id.toString(), payload.value);
break;
case 'switch':
const { line, root, pointing_to } = payload;
let { line, root, pointing_to } = payload;

line = line.toLowerCase();

const switches = _.cloneDeep(this.state.switches);

if(!switches[line]) {
Expand Down Expand Up @@ -187,16 +191,7 @@ class CTCOffice extends React.Component {
};

this.nextTrainID = 1;
this.trains = {
'-1': new Train(
'-1',
'green',
'nodestination',
0,
29,
[]
)
};
this.trains = {};
this.trainPositions = {
'red': {},
'green': {},
Expand Down Expand Up @@ -1048,6 +1043,8 @@ class CTCOffice extends React.Component {
activeLine: 'red'
});

const occupancy = _.cloneDeep(this.state.occupancy);

// Clean up modals and stuff
this.setState({
lineSelection: undefined,
Expand All @@ -1056,7 +1053,8 @@ class CTCOffice extends React.Component {
editingSwitch: undefined,
editingBlock: undefined,
switchModalOpen: false,
blockModalOpen: false
blockModalOpen: false,
occupancy: occupancy
});
}

Expand Down

0 comments on commit 29e8482

Please sign in to comment.