mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-08 16:28:00 -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.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ScoutingDataWriter {
|
public class ScoutingDataWriter {
|
||||||
// private static final int int_type_id = 255;
|
// 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;
|
String alliance_position;
|
||||||
int cur_match_num;
|
int cur_match_num;
|
||||||
String username;
|
String username;
|
||||||
|
String fileUsernames = "";
|
||||||
String filename;
|
String filename;
|
||||||
boolean edited = false;
|
boolean edited = false;
|
||||||
boolean rescout = 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);
|
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, DataManager.match_values, DataManager.match_transferValues);
|
||||||
DataType[] types = psdr.data.array;
|
DataType[] types = psdr.data.array;
|
||||||
|
fileUsernames = psdr.username;
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < DataManager.match_latest_values.length; i++){
|
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();
|
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!");
|
System.out.println("Saved!");
|
||||||
else
|
else
|
||||||
System.out.println("Error saving");
|
System.out.println("Error saving");
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class PitScoutingFragment extends Fragment {
|
|||||||
String filename;
|
String filename;
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
|
String fileUsernames = "";
|
||||||
ToggleTitleView[] titles;
|
ToggleTitleView[] titles;
|
||||||
|
|
||||||
AutoSaveManager asm = new AutoSaveManager(this::save);
|
AutoSaveManager asm = new AutoSaveManager(this::save);
|
||||||
@@ -83,7 +84,7 @@ public class PitScoutingFragment extends Fragment {
|
|||||||
types[i] = pit_latest_values[i].getViewValue();
|
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!");
|
System.out.println("Saved!");
|
||||||
AlertManager.toast("Saved " + filename);
|
AlertManager.toast("Saved " + filename);
|
||||||
}else
|
}else
|
||||||
@@ -221,6 +222,8 @@ public class PitScoutingFragment extends Fragment {
|
|||||||
|
|
||||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, pit_values, pit_transferValues);
|
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, pit_values, pit_transferValues);
|
||||||
DataType[] types = psdr.data.array;
|
DataType[] types = psdr.data.array;
|
||||||
|
fileUsernames = psdr.username;
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < pit_latest_values.length; i++){
|
for(int i = 0; i < pit_latest_values.length; i++){
|
||||||
pit_latest_values[i].setViewValue(types[i]);
|
pit_latest_values[i].setViewValue(types[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user