Work on Field Editor, Improve capitalization of classes

This commit is contained in:
Michael Mikovsky
2025-04-04 14:15:30 -06:00
parent a371f2f449
commit eaa14adbd9
56 changed files with 849 additions and 733 deletions
@@ -1,22 +1,22 @@
package com.ridgebotics.ridgescout.scoutingData;
import com.ridgebotics.ridgescout.types.input.checkboxType;
import com.ridgebotics.ridgescout.types.input.dropdownType;
import com.ridgebotics.ridgescout.types.input.fieldposType;
import com.ridgebotics.ridgescout.types.input.inputType;
import com.ridgebotics.ridgescout.types.input.numberType;
import com.ridgebotics.ridgescout.types.input.tallyType;
import com.ridgebotics.ridgescout.types.input.textType;
import com.ridgebotics.ridgescout.types.input.sliderType;
import com.ridgebotics.ridgescout.types.input.CheckboxType;
import com.ridgebotics.ridgescout.types.input.DropdownType;
import com.ridgebotics.ridgescout.types.input.FieldposType;
import com.ridgebotics.ridgescout.types.input.FieldType;
import com.ridgebotics.ridgescout.types.input.NumberType;
import com.ridgebotics.ridgescout.types.input.TallyType;
import com.ridgebotics.ridgescout.types.input.TextType;
import com.ridgebotics.ridgescout.types.input.SliderType;
import com.ridgebotics.ridgescout.utility.AlertManager;
import com.ridgebotics.ridgescout.utility.fileEditor;
import com.ridgebotics.ridgescout.utility.FileEditor;
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
import com.ridgebotics.ridgescout.utility.ByteBuilder;
import java.util.ArrayList;
import java.util.UUID;
public class fields {
public class Fields {
// public static ScoutingVersion sv = new ScoutingVersion();
public static final String matchFieldsFilename = "matches.fields";
@@ -26,77 +26,77 @@ public class fields {
return UUID.randomUUID().toString();
}
public static final inputType[][] default_match_fields = new inputType[][] {
public static final FieldType[][] default_match_fields = new FieldType[][] {
{
new fieldposType(uuid(),"Auto start pos", "Where does the robot start its auto?", new int[]{0,0}),
new FieldposType(uuid(),"Auto start pos", "Where does the robot start its auto?", new int[]{0,0}),
new tallyType(uuid(),"Auto L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
new tallyType(uuid(),"Auto L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
new tallyType(uuid(),"Auto L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
new tallyType(uuid(),"Auto L1/Trough Coral", "How many coral did this robot score in L1 during auto?", 0),
new tallyType(uuid(),"Auto Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
new tallyType(uuid(),"Auto Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
new TallyType(uuid(),"Auto L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
new TallyType(uuid(),"Auto L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
new TallyType(uuid(),"Auto L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
new TallyType(uuid(),"Auto L1/Trough Coral", "How many coral did this robot score in L1 during auto?", 0),
new TallyType(uuid(),"Auto Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
new TallyType(uuid(),"Auto Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
new dropdownType(uuid(),"Auto Quality", "How did the robot drive during auto?", new String[]{"Smooth", "Jittery"}, 0),
new textType(uuid(),"Auto Comments", "Anything interesting about auto", ""),
new DropdownType(uuid(),"Auto Quality", "How did the robot drive during auto?", new String[]{"Smooth", "Jittery"}, 0),
new TextType(uuid(),"Auto Comments", "Anything interesting about auto", ""),
new tallyType(uuid(),"Teleop L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
new tallyType(uuid(),"Teleop L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
new tallyType(uuid(),"Teleop L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
new tallyType(uuid(),"Teleop L1 Coral", "How many coral did this robot score in L1 during auto?", 0),
new tallyType(uuid(),"Teleop Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
new tallyType(uuid(),"Teleop Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
new TallyType(uuid(),"Teleop L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
new TallyType(uuid(),"Teleop L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
new TallyType(uuid(),"Teleop L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
new TallyType(uuid(),"Teleop L1 Coral", "How many coral did this robot score in L1 during auto?", 0),
new TallyType(uuid(),"Teleop Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
new TallyType(uuid(),"Teleop Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
new checkboxType(uuid(),"Upper Algae Removal", "Did the robot remove upper Algae?", 0),
new checkboxType(uuid(),"Lower Algae Removal", "Did the robot remove lower Algae?", 0),
new CheckboxType(uuid(),"Upper Algae Removal", "Did the robot remove upper Algae?", 0),
new CheckboxType(uuid(),"Lower Algae Removal", "Did the robot remove lower Algae?", 0),
new dropdownType(uuid(),"Teleop Quality", "How did the robot drive during Teleop?", new String[]{"Smooth", "Jittery"}, 0),
new textType(uuid(),"Teleop Comments", "Anything interesting about Teleop", ""),
new DropdownType(uuid(),"Teleop Quality", "How did the robot drive during Teleop?", new String[]{"Smooth", "Jittery"}, 0),
new TextType(uuid(),"Teleop Comments", "Anything interesting about Teleop", ""),
new dropdownType(uuid(),"Climb State", "What was the final condition of the robot?", new String[]{"Nothing", "Continued Cycling", "Park", "Attempted Shallow", "Shallow", "Attempted Deep", "Deep"}, 0),
new DropdownType(uuid(),"Climb State", "What was the final condition of the robot?", new String[]{"Nothing", "Continued Cycling", "Park", "Attempted Shallow", "Shallow", "Attempted Deep", "Deep"}, 0),
new dropdownType(uuid(),"Robot Condition", "Was anything broken?", new String[]{"Everything was working", "Something was maybe broken", "Something was broken", "Robot was disabled for part of the match", "Missing robot"}, 0),
new DropdownType(uuid(),"Robot Condition", "Was anything broken?", new String[]{"Everything was working", "Something was maybe broken", "Something was broken", "Robot was disabled for part of the match", "Missing robot"}, 0),
new textType(uuid(),"Other Comments", "Any other comments you have", "")
new TextType(uuid(),"Other Comments", "Any other comments you have", "")
}
};
public static final inputType[][] default_pit_fields = new inputType[][] {
public static final FieldType[][] default_pit_fields = new FieldType[][] {
{
new dropdownType(uuid(),"Drivetrain type", "What type of drivetrain does this team have?", new String[]{"Swerve Drive", "Tank Drive (Differential)", "Other, Info in comments"}, 0),
new dropdownType(uuid(),"Intake type", "What type of intake does this team have?", new String[]{"Ground only", "Player Station only", "Both", "Other, Info in comments"}, 0),
new dropdownType(uuid(),"Intake Consistency", "How consistent is the robot at intakeing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new DropdownType(uuid(),"Drivetrain type", "What type of drivetrain does this team have?", new String[]{"Swerve Drive", "Tank Drive (Differential)", "Other, Info in comments"}, 0),
new DropdownType(uuid(),"Intake type", "What type of intake does this team have?", new String[]{"Ground only", "Player Station only", "Both", "Other, Info in comments"}, 0),
new DropdownType(uuid(),"Intake Consistency", "How consistent is the robot at intakeing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new dropdownType(uuid(),"Score Area", "What does this robot score?", new String[]{"Only Algae", "Mostly Algae", "Both", "Mostly Coral", "Only Coral"}, 0),
new DropdownType(uuid(),"Score Area", "What does this robot score?", new String[]{"Only Algae", "Mostly Algae", "Both", "Mostly Coral", "Only Coral"}, 0),
new checkboxType(uuid(),"L4 Scoring", "Will the robot score in Layer 4?", 0),
new checkboxType(uuid(),"L3 Scoring", "Will the robot score in Layer 3?", 0),
new checkboxType(uuid(),"L2 Scoring", "Will the robot score in Layer 3?", 0),
new checkboxType(uuid(),"L1/Trough Scoring", "Will the robot score in Layer 1?", 0),
new checkboxType(uuid(),"Processor Scoring", "Will the robot score in the Processor?", 0),
new checkboxType(uuid(),"Barge Scoring", "Will the robot score algae in the Barge?", 0),
new dropdownType(uuid(),"Scoring Consistency", "How consistent is the robot at Scoring?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new CheckboxType(uuid(),"L4 Scoring", "Will the robot score in Layer 4?", 0),
new CheckboxType(uuid(),"L3 Scoring", "Will the robot score in Layer 3?", 0),
new CheckboxType(uuid(),"L2 Scoring", "Will the robot score in Layer 3?", 0),
new CheckboxType(uuid(),"L1/Trough Scoring", "Will the robot score in Layer 1?", 0),
new CheckboxType(uuid(),"Processor Scoring", "Will the robot score in the Processor?", 0),
new CheckboxType(uuid(),"Barge Scoring", "Will the robot score algae in the Barge?", 0),
new DropdownType(uuid(),"Scoring Consistency", "How consistent is the robot at Scoring?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new textType(uuid(),"Auto Capability", "What autos does this team have?", ""),
new dropdownType(uuid(),"Auto Consistency", "How consistent is the robot at Auto?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new TextType(uuid(),"Auto Capability", "What autos does this team have?", ""),
new DropdownType(uuid(),"Auto Consistency", "How consistent is the robot at Auto?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new dropdownType(uuid(),"Climb type", "What does the robot do to climb?", new String[]{"No Climb", "Only Shallow", "Only Deep", "Both Shallow and Deep"}, 0),
new dropdownType(uuid(),"Climb Consistency", "How consistent is the robot at climbing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new DropdownType(uuid(),"Climb type", "What does the robot do to climb?", new String[]{"No Climb", "Only Shallow", "Only Deep", "Both Shallow and Deep"}, 0),
new DropdownType(uuid(),"Climb Consistency", "How consistent is the robot at climbing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
new textType(uuid(),"Cool Comments", "Is there anything cool about the robot?", ""),
new TextType(uuid(),"Cool Comments", "Is there anything cool about the robot?", ""),
new textType(uuid(),"Comments", "Things go here", "Day 1:\n\nDay 2:\n\nDay 3:\n")
new TextType(uuid(),"Comments", "Things go here", "Day 1:\n\nDay 2:\n\nDay 3:\n")
}
};
public static boolean save(String filename, inputType[][] values){
public static boolean save(String filename, FieldType[][] values){
try {
ByteBuilder bb = new ByteBuilder();
for (int i = 0; i < values.length; i++) {
bb.addRaw(127, save_version(values[i]));
}
fileEditor.writeFile(filename, bb.build());
FileEditor.writeFile(filename, bb.build());
return true;
}catch (ByteBuilder.buildingException e) {
AlertManager.error(e);
@@ -105,7 +105,7 @@ public class fields {
}
}
private static byte[] save_version(inputType[] values) throws ByteBuilder.buildingException {
private static byte[] save_version(FieldType[] values) throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
for(int i =0; i < values.length; i++){
bb.addRaw(values[i].get_byte_id(), values[i].encode());
@@ -113,15 +113,15 @@ public class fields {
return bb.build();
}
public static inputType[][] load(String filename){
byte[] bytes = fileEditor.readFile(filename);
public static FieldType[][] load(String filename){
byte[] bytes = FileEditor.readFile(filename);
// System.out.println(bytes);
try {
BuiltByteParser bbp = new BuiltByteParser(bytes);
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
inputType[][] values = new inputType[objects.size()][];
FieldType[][] values = new FieldType[objects.size()][];
for(int i = 0 ; i < objects.size(); i++){
values[i] = load_version((byte[]) objects.get(i).get());
@@ -135,35 +135,35 @@ public class fields {
}
}
private static inputType[] load_version(byte[] bytes) throws BuiltByteParser.byteParsingExeption{
private static FieldType[] load_version(byte[] bytes) throws BuiltByteParser.byteParsingExeption{
BuiltByteParser bbp = new BuiltByteParser(bytes);
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
inputType[] output = new inputType[objects.size()];
FieldType[] output = new FieldType[objects.size()];
for(int i = 0 ; i < objects.size(); i++){
BuiltByteParser.parsedObject obj = objects.get(i);
inputType t = null;
FieldType t = null;
switch (obj.getType()){
case inputType.slider_type_id:
t = new sliderType();
case FieldType.slider_type_id:
t = new SliderType();
break;
case inputType.dropdownType:
t = new dropdownType();
case FieldType.dropdownType:
t = new DropdownType();
break;
case inputType.notesType:
t = new textType();
case FieldType.notesType:
t = new TextType();
break;
case inputType.tallyType:
t = new tallyType();
case FieldType.tallyType:
t = new TallyType();
break;
case inputType.numberType:
t = new numberType();
case FieldType.numberType:
t = new NumberType();
break;
case inputType.checkboxType:
t = new checkboxType();
case FieldType.checkboxType:
t = new CheckboxType();
break;
case inputType.fieldposType:
t = new fieldposType();
case FieldType.fieldposType:
t = new FieldposType();
break;
}
@@ -1,14 +1,14 @@
package com.ridgebotics.ridgescout.scoutingData;
import com.ridgebotics.ridgescout.scoutingData.transfer.transferType;
import com.ridgebotics.ridgescout.scoutingData.transfer.TransferType;
import com.ridgebotics.ridgescout.types.ScoutingArray;
import com.ridgebotics.ridgescout.types.data.dataType;
import com.ridgebotics.ridgescout.types.data.intArrType;
import com.ridgebotics.ridgescout.types.data.stringType;
import com.ridgebotics.ridgescout.types.input.inputType;
import com.ridgebotics.ridgescout.types.data.intType;
import com.ridgebotics.ridgescout.types.data.DataType;
import com.ridgebotics.ridgescout.types.data.IntArrType;
import com.ridgebotics.ridgescout.types.data.StringType;
import com.ridgebotics.ridgescout.types.input.FieldType;
import com.ridgebotics.ridgescout.types.data.IntType;
import com.ridgebotics.ridgescout.utility.AlertManager;
import com.ridgebotics.ridgescout.utility.fileEditor;
import com.ridgebotics.ridgescout.utility.FileEditor;
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
import com.ridgebotics.ridgescout.utility.ByteBuilder;
@@ -19,7 +19,7 @@ public class ScoutingDataWriter {
// private static final int int_type_id = 255;
// private static final int string_type_id = 254;
public static boolean save(int version, String username, String filename, dataType[] data){
public static boolean save(int version, String username, String filename, DataType[] data){
ByteBuilder bb = new ByteBuilder();
try {
bb.addInt(version);
@@ -40,7 +40,7 @@ public class ScoutingDataWriter {
}
}
byte[] bytes = bb.build();
fileEditor.writeFile(filename, bytes);
FileEditor.writeFile(filename, bytes);
return true;
} catch (ByteBuilder.buildingException e) {
AlertManager.error(e);
@@ -55,12 +55,12 @@ public class ScoutingDataWriter {
public ScoutingArray data;
}
public static ParsedScoutingDataResult load(String filename, inputType[][] values , transferType[][] transferValues){
byte[] bytes = fileEditor.readFile(filename);
public static ParsedScoutingDataResult load(String filename, FieldType[][] values , TransferType[][] transferValues){
byte[] bytes = FileEditor.readFile(filename);
BuiltByteParser bbp = new BuiltByteParser(bytes);
try {
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
dataType[] dataTypes = new dataType[objects.size()-2];
DataType[] dataTypes = new DataType[objects.size()-2];
int version = ((int)objects.get(0).get());
// System.out.println(version);
@@ -69,17 +69,17 @@ public class ScoutingDataWriter {
for(int i = 0; i < values[version].length; i++){
switch (objects.get(i+2).getType()){
case 1: // Int
dataTypes[i] = intType.newNull(values[version][i].name);
dataTypes[i] = IntType.newNull(values[version][i].name);
dataTypes[i].forceSetValue(objects.get(i+2).get());
System.out.println("Loaded INT: " + values[version][i].name + ", ("+ dataTypes[i].get() +")");
break;
case 2: // String
dataTypes[i] = stringType.newNull(values[version][i].name);
dataTypes[i] = StringType.newNull(values[version][i].name);
dataTypes[i].forceSetValue(objects.get(i+2).get());
System.out.println("Loaded STR: " + values[version][i].name + ", ("+ dataTypes[i].get() +")");
break;
case 3: // Int array
dataTypes[i] = intArrType.newNull(values[version][i].name);
dataTypes[i] = IntArrType.newNull(values[version][i].name);
dataTypes[i].forceSetValue(objects.get(i+2).get());
System.out.println("Loaded intARR: " + values[version][i].name + ", ("+ Arrays.toString((int[])dataTypes[i].get()) +")");
break;
@@ -1,8 +1,8 @@
package com.ridgebotics.ridgescout.scoutingData.transfer;
public class createTransferType extends transferType {
public class CreateTransferType extends TransferType {
public transferValue getType() {return transferValue.CREATE;}
public createTransferType(String name){
public CreateTransferType(String name){
super(name);
}
}
@@ -1,8 +1,8 @@
package com.ridgebotics.ridgescout.scoutingData.transfer;
public class directTransferType extends transferType {
public class DirectTransferType extends TransferType {
public transferValue getType() {return transferValue.DIRECT;}
public directTransferType(String name){
public DirectTransferType(String name){
super(name);
}
}
@@ -1,20 +1,20 @@
package com.ridgebotics.ridgescout.scoutingData.transfer;
import com.ridgebotics.ridgescout.types.input.inputType;
import com.ridgebotics.ridgescout.types.input.FieldType;
public abstract class transferType {
public abstract class TransferType {
public enum transferValue {
DIRECT,
CREATE
}
public String name;
public abstract transferValue getType();
public transferType(String name){
public TransferType(String name){
this.name = name;
}
private static inputType get_input_type_by_name(inputType[] values, String name){
for(inputType it : values){
private static FieldType get_input_type_by_name(FieldType[] values, String name){
for(FieldType it : values){
if(it.name.equals(name)){
return it;
}
@@ -22,16 +22,16 @@ public abstract class transferType {
return null;
}
public static transferType[][] get_transfer_values(inputType[][] values) {
transferType[][] output = new transferType[values.length][];
public static TransferType[][] get_transfer_values(FieldType[][] values) {
TransferType[][] output = new TransferType[values.length][];
for(int a = 1; a < values.length; a++){
transferType[] v = new transferType[values[a].length];
TransferType[] v = new TransferType[values[a].length];
for(int b = 0; b < values[a].length; b++){
String name = values[a][b].name;
if(get_input_type_by_name(values[a-1], name) != null){
v[b] = new directTransferType(name);
v[b] = new DirectTransferType(name);
}else{
v[b] = new createTransferType(name);
v[b] = new CreateTransferType(name);
}
}
output[a-1] = v;