scouting: Fix types for action timestamps and cycle times
Since we measure in nanoseconds (to be in line with what the robot
code does) we need a bigger type than `int32`. This patch changes
these fields to be `int64` instead.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: Ibffc37e74b333ae12330ab1c4fedd34879113a9d
diff --git a/scouting/db/db.go b/scouting/db/db.go
index adf1eae..bc32e12 100644
--- a/scouting/db/db.go
+++ b/scouting/db/db.go
@@ -75,7 +75,7 @@
LowConesAuto, MiddleConesAuto, HighConesAuto, ConesDroppedAuto int32
LowCubes, MiddleCubes, HighCubes, CubesDropped int32
LowCones, MiddleCones, HighCones, ConesDropped int32
- AvgCycle int32
+ AvgCycle int64
// The username of the person who collected these statistics.
// "unknown" if submitted without logging in.
// Empty if the stats have not yet been collected.
diff --git a/scouting/webserver/requests/messages/request_2023_data_scouting_response.fbs b/scouting/webserver/requests/messages/request_2023_data_scouting_response.fbs
index d9d36b3..93583ce 100644
--- a/scouting/webserver/requests/messages/request_2023_data_scouting_response.fbs
+++ b/scouting/webserver/requests/messages/request_2023_data_scouting_response.fbs
@@ -24,7 +24,8 @@
middle_cones:int (id:16);
high_cones:int (id:17);
cones_dropped:int (id:18);
- avg_cycle:int (id:19);
+ // Time in nanoseconds.
+ avg_cycle:int64 (id:19);
collected_by:string (id:20);
}
@@ -33,4 +34,4 @@
stats_list:[Stats2023] (id:0);
}
-root_type Request2023DataScoutingResponse;
\ No newline at end of file
+root_type Request2023DataScoutingResponse;
diff --git a/scouting/webserver/requests/messages/submit_actions.fbs b/scouting/webserver/requests/messages/submit_actions.fbs
index ebbaa5c..5488a79 100644
--- a/scouting/webserver/requests/messages/submit_actions.fbs
+++ b/scouting/webserver/requests/messages/submit_actions.fbs
@@ -50,7 +50,7 @@
}
table Action {
- timestamp:int (id:0);
+ timestamp:int64 (id:0);
action_taken:ActionType (id:2);
}
@@ -61,4 +61,4 @@
comp_level:string (id: 3);
actions_list:[Action] (id:4);
collected_by:string (id: 5);
-}
\ No newline at end of file
+}
diff --git a/scouting/webserver/requests/requests.go b/scouting/webserver/requests/requests.go
index 39f344e..6f83bfe 100644
--- a/scouting/webserver/requests/requests.go
+++ b/scouting/webserver/requests/requests.go
@@ -590,7 +590,7 @@
}
}
if cycles != 0 {
- stat.AvgCycle = int32(overall_time / cycles)
+ stat.AvgCycle = overall_time / cycles
} else {
stat.AvgCycle = 0
}
diff --git a/scouting/www/entry/entry.component.ts b/scouting/www/entry/entry.component.ts
index 44fc958..aef97f7 100644
--- a/scouting/www/entry/entry.component.ts
+++ b/scouting/www/entry/entry.component.ts
@@ -118,7 +118,6 @@
matchStartTimestamp: number = 0;
addAction(action: ActionT): void {
- action.timestamp = Math.floor(Date.now() / 1000);
if (action.type == 'startMatchAction') {
// Unix nanosecond timestamp.
this.matchStartTimestamp = Date.now() * 1e6;
@@ -193,7 +192,7 @@
StartMatchAction.createStartMatchAction(builder, action.position);
actionOffset = Action.createAction(
builder,
- action.timestamp || 0,
+ BigInt(action.timestamp || 0),
ActionType.StartMatchAction,
startMatchActionOffset
);
@@ -208,7 +207,7 @@
);
actionOffset = Action.createAction(
builder,
- action.timestamp || 0,
+ BigInt(action.timestamp || 0),
ActionType.PickupObjectAction,
pickupObjectActionOffset
);
@@ -223,7 +222,7 @@
);
actionOffset = Action.createAction(
builder,
- action.timestamp || 0,
+ BigInt(action.timestamp || 0),
ActionType.AutoBalanceAction,
autoBalanceActionOffset
);
@@ -239,7 +238,7 @@
);
actionOffset = Action.createAction(
builder,
- action.timestamp || 0,
+ BigInt(action.timestamp || 0),
ActionType.PlaceObjectAction,
placeObjectActionOffset
);
@@ -250,7 +249,7 @@
RobotDeathAction.createRobotDeathAction(builder, action.robotOn);
actionOffset = Action.createAction(
builder,
- action.timestamp || 0,
+ BigInt(action.timestamp || 0),
ActionType.RobotDeathAction,
robotDeathActionOffset
);
@@ -264,7 +263,7 @@
);
actionOffset = Action.createAction(
builder,
- action.timestamp || 0,
+ BigInt(action.timestamp || 0),
ActionType.EndMatchAction,
endMatchActionOffset
);