Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
#	src/main/java/org/usfirst/frc/team25/scouting/data/BlueAlliance.java
  • Loading branch information
spencerng committed Feb 7, 2019
2 parents dcf0907 + 400be5d commit 8811c86
Show file tree
Hide file tree
Showing 13 changed files with 267 additions and 228 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jfx {
appName="raider-client"
}

mainClassName = 'org.usfirst.frc.team25.scouting.client.ui.Main'
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Controller {
private ArrayList<File> jsonFileList;
private String eventName;

private File currentDataDirectory;
private File currentDataDirectory, teamNameList;

public void initialize() {

Expand Down Expand Up @@ -85,12 +85,6 @@ public void initialize() {

retrieveEventReport();

File teamNameList = FileManager.getTeamNameList(currentDataDirectory);

if (teamNameList != null) {
eventReport.setTeamNameList(teamNameList);
}

if (backupJson.isSelected()) {
FileManager.createBackup(jsonFileList, currentDataDirectory);
status += "\nBackup JSON files created";
Expand Down Expand Up @@ -165,30 +159,42 @@ public void initialize() {
int teamNum;
try {
teamNum = Integer.parseInt(analysisTeamOne.getText());
if (!eventReport.isTeamPlaying(teamNum)) {
addStatus("Invalid team number for event " + eventName + ". Please try again.");
} else {
addStatus(eventReport.getTeamReport(teamNum).getQuickStatus());
}
} catch (NumberFormatException e) {
addStatus("Invalid or missing team number. Please try again.");
return;
}

addStatus(eventReport.getTeamReport(teamNum).getQuickStatus());

} else {
int teamOne, teamTwo, teamThree;

try {
teamOne = Integer.parseInt(analysisTeamOne.getText());
teamTwo = Integer.parseInt(analysisTeamTwo.getText());
teamThree = Integer.parseInt(analysisTeamThree.getText());
if (!eventReport.isTeamPlaying(teamOne) || !eventReport.isTeamPlaying(teamTwo) || !eventReport.isTeamPlaying(teamThree)) {
addStatus("Invalid team number(s) for event " + eventName + ". Please try again.");
} else {
addStatus(eventReport.getAllianceReport(teamOne, teamTwo, teamThree).getQuickAllianceReport());
}
} catch (NumberFormatException e) {
addStatus("Invalid or missing team number(s). Please try again.");
return;

}

addStatus(eventReport.getAllianceReport(teamOne, teamTwo, teamThree).getQuickAllianceReport());
}
});

}

/**
* Retrieves JSON data files from the selected data directory and converts them into an EventReport for data
* processing
*/
private void retrieveEventReport() {
this.jsonFileList = FileManager.getDataFiles(currentDataDirectory);

Expand All @@ -203,10 +209,22 @@ private void retrieveEventReport() {

ArrayList<ScoutEntry> scoutEntries = FileManager.deserializeData(jsonFileList);

this.teamNameList = FileManager.getTeamNameList(currentDataDirectory);

this.eventReport = new EventReport(scoutEntries, eventName, currentDataDirectory);

if (teamNameList != null) {
eventReport.setTeamNameList(teamNameList);
}

eventReport.processTeamReports();
}

/**
* Adds a status display to the user-facing text box, with a separator between statuses
*
* @param message Text to display to the user
*/
private void addStatus(String message) {
statusTextBox.setText(message + "\n====================\n" + statusTextBox.getText());
}
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/org/usfirst/frc/team25/scouting/data/Alliance.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.usfirst.frc.team25.scouting.data;

/**
* Class for alliance-based calculations and stats
* Not used during the 2018 season
*/
public class AllianceReport {

private TeamReport[] teamReports;

//Add more here
private double expectedScore, expectedAutoPoints, expectedClimbPoints, expectedTeleOpPoints, expectedBonusRp;

public AllianceReport(TeamReport teamOne, TeamReport teamTwo, TeamReport teamThree) {

this.teamReports = new TeamReport[]{teamOne, teamTwo, teamThree};
}


public void calculateStats() {
//Calculate declared variables here
}

public String getQuickAllianceReport() {
//TODO write this
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public static void initializeApi(Class c) throws IOException {


String apiKey = IOUtils.toString(c.getClassLoader().getResourceAsStream("apikey/secret.txt"), "utf-8");

TBA = new TBA(apiKey);
}

Expand Down Expand Up @@ -98,7 +97,7 @@ public static boolean exportSimpleTeamList(String eventCode, String fileName) th
StringBuilder teamList = new StringBuilder();
ArrayList<Team> teams;
try {
teams = Sorters.sortByTeamNum(new ArrayList<>(Arrays.asList(TBA.eventRequest.getTeams(eventCode))));
teams = SortersFilters.sortByTeamNum(new ArrayList<>(Arrays.asList(TBA.eventRequest.getTeams(eventCode))));
} catch (IOException e) {
e.printStackTrace();
return false;
Expand Down Expand Up @@ -131,7 +130,7 @@ private static boolean exportTeamList(String eventCode, String fileName) throws

try {
for (Team team :
Sorters.sortByTeamNum(new ArrayList<>(Arrays.asList(TBA.eventRequest.getTeams(eventCode))))) {
SortersFilters.sortByTeamNum(new ArrayList<>(Arrays.asList(TBA.eventRequest.getTeams(eventCode))))) {
teamList.append(team.getTeamNumber()).append(",").append(team.getNickname()).append(",\n");
}
} catch (IOException e) {
Expand Down Expand Up @@ -159,7 +158,7 @@ private static boolean exportMatchList(String eventCode, String fileName) throws
StringBuilder matchList = new StringBuilder();
try {
for (Match match :
Sorters.sortByMatchNum(Sorters.filterQualification(new ArrayList<>(Arrays.asList(TBA.eventRequest.getMatches(eventCode)))))) {
SortersFilters.sortByMatchNum(SortersFilters.filterQualification(new ArrayList<>(Arrays.asList(TBA.eventRequest.getMatches(eventCode)))))) {

matchList.append(match.getMatchNumber()).append(",");
for (int i = 0; i < 2; i++) //iterate through two alliances
Expand Down Expand Up @@ -209,7 +208,7 @@ public static void downloadTeamEvents(File outputFolder, int year, int teamNum)

public static boolean downloadEventMatchData(String eventCode, File outputDirectory) throws IOException {
ArrayList<Match> matches =
Sorters.sortByMatchNum(Sorters.filterQualification(new ArrayList<>(Arrays.asList(TBA.eventRequest.getMatches(eventCode)))));
SortersFilters.sortByMatchNum(SortersFilters.filterQualification(new ArrayList<>(Arrays.asList(TBA.eventRequest.getMatches(eventCode)))));

if (matches.size() == 0) {
return false;
Expand Down
57 changes: 13 additions & 44 deletions src/main/java/org/usfirst/frc/team25/scouting/data/EventReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ public class EventReport {
private HashMap<Integer, TeamReport> teamReports;
private String inaccuracyList;
private File teamNameList;
private HashMap<Integer, Integer> pickPoints;

public EventReport(ArrayList<ScoutEntry> entries, String event, File directory) {
teamReports = new HashMap<>();
inaccuracyList = "";

scoutEntries = entries;
this.scoutEntries = entries;
this.event = event;
this.directory = directory;

Expand All @@ -53,6 +52,7 @@ public EventReport(ArrayList<ScoutEntry> entries, String event, File directory)
teamReports.get(teamNum).addEntry(entry);
}


}

public void fixInaccuraciesTBA() {
Expand Down Expand Up @@ -122,9 +122,9 @@ public void fixInaccuraciesTBA() {
"Climbing");
}

if (actualAutoRun != entry.getAuto().isReachHabLine()) {
if (actualAutoRun != entry.getAutonomous().isReachHabLine()) {
inaccuracies += "auto run, ";
entry.getAuto().setReachHabLine(actualAutoRun);
entry.getAutonomous().setReachHabLine(actualAutoRun);
}


Expand Down Expand Up @@ -167,17 +167,13 @@ public void processTeamReports() {

TeamReport report = teamReports.get(key);
if (teamNameList != null) {

report.autoGetTeamName(teamNameList);

}
report.calculateStats();


teamReports.put(key, report);

report.findFrequentComments();
}


}

/**
Expand All @@ -191,7 +187,8 @@ public boolean generateRawSpreadsheet(File outputDirectory) {

for (ScoutEntry entry : scoutEntries) {

Object[] dataObjects = {entry.getPreMatch(), entry.getAuto(), entry.getTeleOp(), entry.getPostMatch()};
Object[] dataObjects = {entry.getPreMatch(), entry.getAutonomous(), entry.getTeleOp(),
entry.getPostMatch()};


for (Object dataObject : dataObjects) {
Expand Down Expand Up @@ -268,47 +265,19 @@ private String generateSpreadsheetHeader() {
if (i == 1 || i == 2) {
header.append(shortNames[i] + " - ");
}
header.append(convertCamelToSentenceCase(metric.getName()) + ",");
header.append(StringProcessing.convertCamelToSentenceCase(metric.getName()) + ",");
}
}

for (String key : scoutEntries.get(0).getPostMatch().getRobotQuickCommentSelections().keySet()) {
header.append(removeCommas(key)).append(",");
header.append(StringProcessing.removeCommasBreaks(key)).append(",");
}


return header.toString();
}

/**
* @param camelCaseString A string in lower camelCase
* @return The string in sentence case, with space separations. E.g., "numRocketHatches" becomes "Num rocket
* hatches"
*/
public static String convertCamelToSentenceCase(String camelCaseString) {
//TODO write this

return camelCaseString;
}

/**
* Helper method to prevent manual comments with commas
* from changing CSV format
*
* @param s String to be processed
* @return String without commas
*/
private String removeCommas(String s) {
StringBuilder newString = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) != ',') {
newString.append(s.charAt(i));
} else {
newString.append("; ");
}
}
return newString.toString();
}

/**
* Serializes the ArrayList of all ScoutEntrys into a JSON file
Expand All @@ -329,7 +298,7 @@ public boolean generateCombineJson(File outputDirectory) {
}

public void setTeamNameList(File list) {
teamNameList = list;
this.teamNameList = list;
}


Expand Down Expand Up @@ -378,8 +347,8 @@ public TeamReport getTeamReport(int teamNum) {
return teamReports.get(teamNum);
}

public Alliance getAllianceReport(int teamOne, int teamTwo, int teamThree) {
return new Alliance(teamReports.get(teamOne), teamReports.get(teamTwo), teamReports.get(teamThree));
public AllianceReport getAllianceReport(int teamOne, int teamTwo, int teamThree) {
return new AllianceReport(teamReports.get(teamOne), teamReports.get(teamTwo), teamReports.get(teamThree));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public void generateComparePointList() {
* @return Formatted list, with tree levels not clamped down
*/
private String hashMapToStringList(HashMap<Integer, Integer> teamPointsMap) {
teamPointsMap = Sorters.sortByComparator(teamPointsMap, false);
teamPointsMap = SortersFilters.sortByComparator(teamPointsMap, false);
StringBuilder result = new StringBuilder();
int rank = 1;
for (Map.Entry<Integer, Integer> entry : teamPointsMap.entrySet()) {
Expand Down Expand Up @@ -529,4 +529,22 @@ public void generatePickPointList() {

}

/**
* Generates a list based on a calculated ability to be a good first pick robot
* Calculated ability derived from collected metrics (e.g. climbs, cargo, hatches)
* TODO write this
*/
public void generateCalculatedFirstPicklist() {

}

/**
* Generates a list based on a calculated ability to be a good first pick robot
* Calculated ability derived from collected metrics (e.g. climbs, cargo, hatches)
* TODO write this
*/
public void generateCalculatedSecondPicklist() {

}

}
Loading

0 comments on commit 8811c86

Please sign in to comment.