Add rescout option

This commit is contained in:
Michael Mikovsky
2025-03-26 10:56:05 -06:00
parent d2c075da9c
commit 967dc3c967
10 changed files with 189 additions and 25 deletions
@@ -128,7 +128,7 @@ public class BuiltByteParser {
intArrayObject ia = new intArrayObject();
ia.arr = intArr;
System.out.println(Arrays.toString(intArr));
// System.out.println(Arrays.toString(intArr));
objects.add(ia);
break;
case 4:
@@ -5,6 +5,11 @@ import com.ridgebotics.ridgescout.scoutingData.transfer.transferType;
import com.ridgebotics.ridgescout.types.frcEvent;
import com.ridgebotics.ridgescout.types.input.inputType;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class DataManager {
public static String evcode;
public static frcEvent event;
@@ -19,6 +24,8 @@ public class DataManager {
AlertManager.addSimpleError("Failed to load event!");
settingsManager.setEVCode("unset");
evcode = "unset";
}else{
reload_rescout_list();
}
}
@@ -35,7 +42,7 @@ public class DataManager {
match_latest_values = match_values[match_values.length - 1];
match_transferValues = transferType.get_transfer_values(match_values);
} catch (Exception e){
AlertManager.error(e);
AlertManager.error("Error reading match fields", e);
}
}
@@ -48,7 +55,38 @@ public class DataManager {
pit_latest_values = pit_values[pit_values.length-1];
pit_transferValues = transferType.get_transfer_values(pit_values);
} catch (Exception e){
AlertManager.error(e);
AlertManager.error("Error reading pit fields", e);
}
}
public static List<String> rescout_list = new ArrayList<>();
public static void reload_rescout_list(){
if(!fileEditor.fileExist(evcode + ".rescout")) {rescout_list = new ArrayList<>(); return;}
byte[] file = fileEditor.readFile(evcode + ".rescout");
if(file == null) {rescout_list = new ArrayList<>(); return;}
try {
BuiltByteParser bbp = new BuiltByteParser(file);
rescout_list = new ArrayList<>(Arrays.asList((String[]) (bbp.parse().get(0).get())));
} catch (Exception e){
AlertManager.error("Error loading scout fields", e);
rescout_list = new ArrayList<>();
}
}
public static void save_rescout_list() {
try {
if(rescout_list.size() == 0){
fileEditor.deleteFile(evcode + ".rescout");
return;
}
ByteBuilder bb = new ByteBuilder();
bb.addStringArray(rescout_list.toArray(new String[0]));
fileEditor.writeFile(evcode + ".rescout", bb.build());
} catch (Exception e){
AlertManager.error("Error saving scout fields", e);
}
}
}
@@ -264,6 +264,14 @@ public final class fileEditor {
}
}
public static boolean deleteFile(String filepath){
if(fileExist(filepath)){
return true;
}
File file = new File(baseDir + filepath);
return file.delete();
}
public static boolean fileExist(String path){
File f = new File(baseDir + path);
return f.exists() && !f.isDirectory();