https://github.com/LakeEffectRobotics/LakeEffectScoutingServerApp
This is an app made for a FIRST robotics team.
One of the most important strategic parts of the competition is scouting. Scouting is recording data about other robots to analyse and see what robots are good at what and bad at what.
This is an app to do scouting. Recording data on paper and then putting it in a database is convoluted and wasteful, so we built an app to replace this system. 6 people use the app independently on Android > devices and record data about one robot each per game. A server app can then pull data from all the devices to combine it all in one.
When a name was removed while selected, it was removed from the allNames list but not the
selectedNames list.
For scouting, there are 6 robots per match that need to be watched. This function needs to figure out who to switch on and off when, and which robot each person is watching (scouting). This does this by simulating someone swapping names every match like you would do on paper.
It creates a list of the on and off scouts
//scouts currently scouting or not
Scout[] scoutsOn = new Scout[6];
ArrayList<Scout> scoutsOff = new ArrayList<>();
It then finds who needs to swap with who if there is someone to swap with.
//calculate the schedule for this match
//find scouts to switch on (the scouts that have been off >= targetTimeOff)
ArrayList<Scout> scoutsToSwitchOn = new ArrayList<>();
for (int i = 0; i < scoutsOff.size(); i++) {
if (matchNum - scoutsOff.get(i).timeOff >= targetTimeOff && scoutsToSwitchOn.size() < 6) {
scoutsToSwitchOn.add(scoutsOff.get(i));
}
}
//find scouts to switch off (scouts with the highest time)
ArrayList<Scout> scoutsToSwitchOff = new ArrayList<>();
//sort by time on
for (int i = 0; i < scoutsOn.length; i++) {
//the index to add this scout when sorted
int indexToAdd = scoutsToSwitchOff.size();
for (int s = 0; s < scoutsToSwitchOff.size(); s++) {
if (matchNum - scoutsOn[i].timeOn > matchNum - scoutsToSwitchOff.get(s).timeOn) {
indexToAdd = s;
break;
}
}
//add at index
scoutsToSwitchOff.add(indexToAdd, scoutsOn[i]);
}
The second for loop sorts the scouts on by how long they have been on. This is then used to switch the people ready to switch back on with the people who have been working the longest.
Using that information, it swaps the scouts.
//swap scouts on with scouts off
for (int i = 0; i < scoutsToSwitchOn.size(); i++) {
//scout switching on and off
Scout switchingOn = scoutsToSwitchOn.get(i);
Scout switchingOff = scoutsToSwitchOff.get(i);
scoutsOn[getScout(switchingOff.id, scoutsOn)] = switchingOn;
scoutsOff.remove(switchingOn);
scoutsOff.add(switchingOff);
//update timeOff and timeOn
switchingOn.timeOn = matchNum;
switchingOff.timeOff = matchNum;
}
This is then repeated for all the matches
This is a very important feature. If someone needs to leave and do something else, you can type what match they are leaving or starting at to make that user only matter during certain matches.
(The names in the image above are customisable, I put them as numbers for testing purposes)
To do this, a history of every time a user was selected and deselected is required to be kept.
This was required to make sure that when you returned, it looks exactly like when you closed the app. Before, if the scout was EVER checked off, it would start checked next time you opened the app.
Made time off be changed based on match number
Renamed mislabeled variables (Changed TextView to EditText)
https://github.com/LakeEffectRobotics/LakeEffectScoutingServerApp/pull/17