mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
Add mutli-user scouting data attribution
This commit is contained in:
@@ -15,6 +15,8 @@ import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ScoutingDataWriter {
|
||||
// private static final int int_type_id = 255;
|
||||
@@ -113,4 +115,15 @@ public class ScoutingDataWriter {
|
||||
}
|
||||
}
|
||||
|
||||
// A function that takes in a list of names seperated by commas, and adds a name if it is not included
|
||||
// This is used for multi-scouter attribution to data.
|
||||
public static String checkAddName(String prevnames, String name){
|
||||
List<String> names = new ArrayList<>(List.of(prevnames.split(", ")));
|
||||
|
||||
if(!names.contains(name))
|
||||
names.add(name);
|
||||
|
||||
return String.join(", ", names);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
String alliance_position;
|
||||
int cur_match_num;
|
||||
String username;
|
||||
String fileUsernames = "";
|
||||
String filename;
|
||||
boolean edited = false;
|
||||
boolean rescout = false;
|
||||
@@ -341,6 +342,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, DataManager.match_values, DataManager.match_transferValues);
|
||||
DataType[] types = psdr.data.array;
|
||||
fileUsernames = psdr.username;
|
||||
|
||||
|
||||
for(int i = 0; i < DataManager.match_latest_values.length; i++){
|
||||
@@ -367,7 +369,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
types[i] = DataManager.match_latest_values[i].getViewValue();
|
||||
}
|
||||
|
||||
if(ScoutingDataWriter.save(DataManager.match_values.length-1, username, filename, types))
|
||||
if(ScoutingDataWriter.save(DataManager.match_values.length-1, ScoutingDataWriter.checkAddName(fileUsernames, username), filename, types))
|
||||
System.out.println("Saved!");
|
||||
else
|
||||
System.out.println("Error saving");
|
||||
|
||||
@@ -67,6 +67,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
String filename;
|
||||
String username;
|
||||
|
||||
String fileUsernames = "";
|
||||
ToggleTitleView[] titles;
|
||||
|
||||
AutoSaveManager asm = new AutoSaveManager(this::save);
|
||||
@@ -83,7 +84,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
types[i] = pit_latest_values[i].getViewValue();
|
||||
}
|
||||
|
||||
if(ScoutingDataWriter.save(pit_values.length-1, username, filename, types)) {
|
||||
if(ScoutingDataWriter.save(pit_values.length-1, ScoutingDataWriter.checkAddName(fileUsernames, username), filename, types)) {
|
||||
System.out.println("Saved!");
|
||||
AlertManager.toast("Saved " + filename);
|
||||
}else
|
||||
@@ -221,6 +222,8 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, pit_values, pit_transferValues);
|
||||
DataType[] types = psdr.data.array;
|
||||
fileUsernames = psdr.username;
|
||||
|
||||
|
||||
for(int i = 0; i < pit_latest_values.length; i++){
|
||||
pit_latest_values[i].setViewValue(types[i]);
|
||||
|
||||
Reference in New Issue
Block a user