Skip to content

Commit ee31e13

Browse files
committed
Show current number of bots on field
1 parent ffb99fa commit ee31e13

File tree

6 files changed

+64
-20
lines changed

6 files changed

+64
-20
lines changed

internal/rcon/ssl_gc_rcon_remotecontrol.pb.go

Lines changed: 30 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ssl_gc_rcon_remotecontrol.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ message RemoteControlTeamState {
8181
// max number of robots currently allowed
8282
optional int32 max_robots = 7;
8383

84+
// current number of robots visible on field
85+
optional int32 robots_on_field = 9;
86+
8487
// list of due times for each active yellow card (in seconds)
8588
repeated float yellow_cards_due = 8;
8689
}

src/components/StatusBar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import {inject, ref} from 'vue';
55
const defaultYellowCardsDue: number[] = []
66
const online = ref(false)
77
const maxRobots = ref(0)
8+
const numRobots = ref(0)
89
const yellowCardsDue = ref(defaultYellowCardsDue)
910
const api = inject<ApiController>('api')
1011
let onlineTimer: NodeJS.Timeout
1112
1213
api?.RegisterStateConsumer((s) => {
1314
online.value = true
1415
maxRobots.value = s.maxRobots
16+
numRobots.value = s.robotsOnField
1517
yellowCardsDue.value = s.yellowCardsDue.sort((a: number, b: number) => a - b)
1618
if (onlineTimer) {
1719
clearTimeout(onlineTimer)
@@ -30,7 +32,7 @@ api?.RegisterStateConsumer((s) => {
3032
</div>
3133
<div class="right-bar-element online-state" :class="{online: online, offline: !online}"/>
3234
<div class="right-bar-element">
33-
Max robots: <strong>{{ maxRobots }}</strong>
35+
Robots: <strong>{{ numRobots }}</strong> / <strong>{{ maxRobots }}</strong>
3436
</div>
3537
</div>
3638
</template>

src/proto/ssl_gc_rcon_remotecontrol.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ export interface RemoteControlTeamState {
158158
challengeFlagsLeft: number;
159159
/** max number of robots currently allowed */
160160
maxRobots: number;
161+
/** current number of robots visible on field */
162+
robotsOnField: number;
161163
/** list of due times for each active yellow card (in seconds) */
162164
yellowCardsDue: number[];
163165
}
@@ -560,6 +562,7 @@ const baseRemoteControlTeamState: object = {
560562
timeoutsLeft: 0,
561563
challengeFlagsLeft: 0,
562564
maxRobots: 0,
565+
robotsOnField: 0,
563566
yellowCardsDue: 0,
564567
};
565568

@@ -593,6 +596,9 @@ export const RemoteControlTeamState = {
593596
if (message.maxRobots !== 0) {
594597
writer.uint32(56).int32(message.maxRobots);
595598
}
599+
if (message.robotsOnField !== 0) {
600+
writer.uint32(72).int32(message.robotsOnField);
601+
}
596602
writer.uint32(66).fork();
597603
for (const v of message.yellowCardsDue) {
598604
writer.float(v);
@@ -649,6 +655,9 @@ export const RemoteControlTeamState = {
649655
case 7:
650656
message.maxRobots = reader.int32();
651657
break;
658+
case 9:
659+
message.robotsOnField = reader.int32();
660+
break;
652661
case 8:
653662
if ((tag & 7) === 2) {
654663
const end2 = reader.uint32() + reader.pos;
@@ -696,6 +705,10 @@ export const RemoteControlTeamState = {
696705
object.maxRobots !== undefined && object.maxRobots !== null
697706
? Number(object.maxRobots)
698707
: 0;
708+
message.robotsOnField =
709+
object.robotsOnField !== undefined && object.robotsOnField !== null
710+
? Number(object.robotsOnField)
711+
: 0;
699712
message.yellowCardsDue = (object.yellowCardsDue ?? []).map((e: any) =>
700713
Number(e)
701714
);
@@ -726,6 +739,8 @@ export const RemoteControlTeamState = {
726739
message.challengeFlagsLeft !== undefined &&
727740
(obj.challengeFlagsLeft = message.challengeFlagsLeft);
728741
message.maxRobots !== undefined && (obj.maxRobots = message.maxRobots);
742+
message.robotsOnField !== undefined &&
743+
(obj.robotsOnField = message.robotsOnField);
729744
if (message.yellowCardsDue) {
730745
obj.yellowCardsDue = message.yellowCardsDue.map((e) => e);
731746
} else {
@@ -745,6 +760,7 @@ export const RemoteControlTeamState = {
745760
message.timeoutsLeft = object.timeoutsLeft ?? 0;
746761
message.challengeFlagsLeft = object.challengeFlagsLeft ?? 0;
747762
message.maxRobots = object.maxRobots ?? 0;
763+
message.robotsOnField = object.robotsOnField ?? 0;
748764
message.yellowCardsDue = (object.yellowCardsDue ?? []).map((e) => e);
749765
return message;
750766
},

src/services/ApiController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class ApiController {
2020
yellowCardsDue: [120, 100.111],
2121
keeperId: 1,
2222
maxRobots: 11,
23+
robotsOnField: 9,
2324
challengeFlagsLeft: 3,
2425
emergencyStopIn: 3,
2526
timeoutsLeft: 4,

src/views/ControlButtons.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import router from '../router';
55
import {
66
RemoteControlTeamState,
77
RemoteControlRequestType,
8-
RemoteControlToController_Request
98
} from '../proto/ssl_gc_rcon_remotecontrol';
109
import {ApiController} from '../services/ApiController';
1110
import {computed, inject, ref} from 'vue';
@@ -22,6 +21,16 @@ const canRequestRobotSubstitution = computed(() => state.value.availableRequests
2221
const emergencyStopRequested = computed(() => state.value.activeRequests.includes(RemoteControlRequestType.EMERGENCY_STOP))
2322
const timeoutRequested = computed(() => state.value.activeRequests.includes(RemoteControlRequestType.TIMEOUT))
2423
const robotSubstitutionRequested = computed(() => state.value.activeRequests.includes(RemoteControlRequestType.ROBOT_SUBSTITUTION))
24+
const robotDiff = computed(() => {
25+
const diff = state.value.maxRobots - state.value.robotsOnField
26+
if (diff > 0) {
27+
return `Add ${diff} more`
28+
}
29+
if (diff < 0) {
30+
return `Remove ${diff}`
31+
}
32+
return ''
33+
})
2534
2635
const requestChallengeFlag = () => router.push('/confirm-challenge-flag')
2736
const requestEmergencyStop = (request: boolean) => api?.Send({
@@ -82,6 +91,7 @@ const requestRobotSubstitution = (request: boolean) => api?.Send({
8291
:requested="robotSubstitutionRequested"
8392
text="Robot Substitution"
8493
text-requested="Cancel Robot Substitution"
94+
:text-additional="robotDiff"
8595
@request="requestRobotSubstitution"
8696
/>
8797
</div>

0 commit comments

Comments
 (0)