Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Master robot designation fixed (#693)
Browse files Browse the repository at this point in the history
* Polar bear renaming

* Changed master robot designation
  • Loading branch information
ewc340 authored Apr 18, 2019
1 parent 2486d35 commit 41bb24d
Show file tree
Hide file tree
Showing 5 changed files with 6,985 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dawn/renderer/actions/FieldActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const updateHeart = () => ({

export const updateMaster = msg => ({
type: ActionTypes.UPDATE_MASTER,
alliance: msg.alliance,
teamNumber: msg.team_number,
blueMaster: msg.blue,
goldMaster: msg.gold,
});

export const updateMatch = msg => ({
Expand Down
12 changes: 6 additions & 6 deletions dawn/renderer/components/DNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class DNavComponent extends React.Component {
connectionStatus={this.props.connectionStatus}
runtimeStatus={this.props.runtimeStatus}
masterStatus={this.props.masterStatus}
teamColor={this.props.teamColor}
teamNumber={this.props.teamNumber}
blueMaster={this.props.blueMaster}
goldMaster={this.props.goldMaster}
ipAddress={this.props.ipAddress}
fieldControlStatus={this.props.fieldControlStatus}
/>
Expand Down Expand Up @@ -142,14 +142,14 @@ DNavComponent.propTypes = {
robotState: PropTypes.number.isRequired,
heart: PropTypes.bool.isRequired,
fieldControlStatus: PropTypes.bool.isRequired,
teamColor: PropTypes.string.isRequired,
teamNumber: PropTypes.number.isRequired,
blueMaster: PropTypes.number.isRequired,
goldMaster: PropTypes.number.isRequired,
};

const mapStateToProps = state => ({
masterStatus: state.fieldStore.masterStatus,
teamNumber: state.fieldStore.teamNumber,
teamColor: state.fieldStore.teamColor,
blueMaster: state.fieldStore.blueMaster,
goldMaster: state.fieldStore.goldMaster,
robotState: state.info.robotState,
heart: state.fieldStore.heart,
ipAddress: state.info.ipAddress,
Expand Down
20 changes: 12 additions & 8 deletions dawn/renderer/components/StatusLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ const StatusLabelComponent = (props) => {
let labelText = 'Disconnected';
const masterRobotHeader = 'Master Robot: Team ';
const teamIP = props.ipAddress.substring(props.ipAddress.length - 2, props.ipAddress.length);
const shouldDisplayMaster = teamNumber => parseInt(teamIP, 10) === teamNumber
&& props.fieldControlStatus;
let masterRobot = null;
let masterRobotStyle = ' ';
if (props.teamColor === 'blue') {
if (shouldDisplayMaster(props.blueMaster)) {
masterRobot = props.blueMaster;
masterRobotStyle = 'primary';
} else if (props.teamColor === 'gold') {
} else if (shouldDisplayMaster(props.goldMaster)) {
masterRobot = props.goldMaster;
masterRobotStyle = 'warning';
}

Expand All @@ -33,8 +38,7 @@ const StatusLabelComponent = (props) => {
<Label bsStyle={labelStyle}>{labelText}</Label>
{' '}
<Label bsStyle={masterRobotStyle !== ' ' ? masterRobotStyle : labelStyle}>
{(parseInt(teamIP, 10) === props.teamNumber &&
props.fieldControlStatus) ? masterRobotHeader + teamIP : null}
{masterRobot !== null ? masterRobotHeader + masterRobot : null}
</Label>
</div>
);
Expand All @@ -45,8 +49,8 @@ StatusLabelComponent.propTypes = {
runtimeStatus: PropTypes.bool.isRequired,
batteryLevel: PropTypes.number.isRequired,
batterySafety: PropTypes.bool.isRequired,
teamColor: PropTypes.string.isRequired,
teamNumber: PropTypes.number.isRequired,
blueMaster: PropTypes.number.isRequired,
goldMaster: PropTypes.number.isRequired,
ipAddress: PropTypes.string.isRequired,
fieldControlStatus: PropTypes.bool.isRequired,
};
Expand All @@ -56,8 +60,8 @@ const mapStateToProps = state => ({
batteryLevel: state.peripherals.batteryLevel,
batterySafety: state.peripherals.batterySafety,
masterStatus: state.fieldStore.masterStatus,
teamNumber: state.fieldStore.teamNumber,
teamColor: state.fieldStore.teamColor,
blueMaster: state.fieldStore.blueMaster,
goldMaster: state.fieldStore.goldMaster,
ipAddress: state.info.ipAddress,
fieldControlStatus: state.fieldStore.fieldControl,
});
Expand Down
4 changes: 2 additions & 2 deletions dawn/renderer/reducers/FieldStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const fieldStore = (state = initialFieldState, action) => {
return {
...state,
masterStatus: true,
teamNumber: action.teamNumber,
teamColor: action.alliance,
blueMaster: action.blueMaster,
goldMaster: action.goldMaster,
};
case ActionTypes.UPDATE_MATCH:
return {
Expand Down
Loading

0 comments on commit 41bb24d

Please sign in to comment.