forked from keionbis/2001_Field_Controller
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This PR is the log of changes for the Warehouse project #4
Open
madhephaestus
wants to merge
25
commits into
WPIRoboticsEngineering:2001_Field
Choose a base branch
from
WPI-Warehouse-System:2001_Field
base: 2001_Field
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
425599f
added Welcome Screen and set up skeleton for list of parts
Nick-L-1996 29467e5
Added JSON file reader for inventory, populates item list
Nick-L-1996 915e960
App now stores inventory changes, borrow inventory changes and update…
Nick-L-1996 c3dacb8
App now stores inventory changes, borrow inventory changes and update…
Nick-L-1996 f8e7fe2
Added Basic Backend and Maintenance screen for robots. GUI defaults t…
Nick-L-1996 d53d4a8
Adding Status Retrieval for robot for testing
Nick-L-1996 6b44683
Adding Status Retrieval for robot for testing
Nick-L-1996 bd87b34
Adding Status Retrieval for robot for testing
Nick-L-1996 01c6ba1
Adding Status Retrieval for robot for testing
Nick-L-1996 617c1d4
Added logic for full procurement execution and added buttons for test…
Nick-L-1996 39be7f2
Robot now parks after returning a bin
Nick-L-1996 5ee5470
changed byte packet to float packet
gentov 802d34f
added commands to test lift mechanism
Nick-L-1996 10ff0d1
Merge remote-tracking branch 'origin/2001_Field' into 2001_Field
Nick-L-1996 cc657f1
fixed states
Nick-L-1996 158114d
updates to switch/case statement in robot interface
gentov 7133786
Added Procurement Gui Intergration
Nick-L-1996 ce694c3
Added Procurement Gui Intergration
Nick-L-1996 d481a76
Added Procurement Gui Intergration
Nick-L-1996 ca190ad
Added Procurement Gui Intergration
Nick-L-1996 e09eea4
Added Procurement Gui Intergration
Nick-L-1996 0731eaa
Added Procurement Gui Intergration
Nick-L-1996 e54dc61
changed error message
Nick-L-1996 89b7a49
cleaned up code a little
Nick-L-1996 ccb5b99
added documentation
Nick-L-1996 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/gui/InventoryManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package edu.wpi.rbe.rbe2001.fieldsimulator.gui; | ||
import javafx.collections.FXCollections; | ||
import org.json.simple.JSONArray; | ||
import org.json.simple.JSONObject; | ||
import org.json.simple.parser.JSONParser; | ||
|
||
import java.io.*; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Iterator; | ||
public class InventoryManager { | ||
private String InventoryLoc; | ||
private String BorrowedInventoryLoc; | ||
private JSONObject Inventory; | ||
private JSONObject BorrowedInventory; | ||
|
||
public InventoryManager(String InventoryLocation, String BorrowedInventoryLocation){ | ||
this.InventoryLoc = System.getProperty("user.home")+ File.separator+"Documents"+File.separator+"WareHouseRobot"+File.separator+InventoryLocation; | ||
this.BorrowedInventoryLoc = System.getProperty("user.home")+ File.separator+"Documents"+File.separator+"WareHouseRobot"+File.separator+BorrowedInventoryLocation; | ||
verifyFoldersExist(); | ||
|
||
} | ||
public void verifyFoldersExist(){ | ||
String localDirectory = System.getProperty("user.home")+ File.separator+"Documents"; | ||
File dir = new File(localDirectory+File.separator+"WareHouseRobot"); | ||
File Inventory = new File(InventoryLoc); | ||
File BorrowedInventory = new File(BorrowedInventoryLoc); | ||
try{//This verifies the files are there and if not creates them | ||
dir.mkdir(); | ||
Inventory.createNewFile(); | ||
BorrowedInventory.createNewFile(); | ||
} | ||
catch (IOException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void removeItemsFromInventory(ListViewPart part, int numBorrowed){ | ||
JSONArray InventoryList = (JSONArray)Inventory.get("inventory"); | ||
JSONArray tempList = new JSONArray(); | ||
Iterator<JSONObject> iterator = InventoryList.iterator(); | ||
while (iterator.hasNext()) { | ||
JSONObject it = iterator.next(); | ||
if((it.get("name")).equals(part.getName())) { | ||
it.put("numberAvailable", (long)it.get("numberAvailable")-numBorrowed); | ||
|
||
} | ||
tempList.add(it); | ||
} | ||
Inventory.put("inventory", tempList); | ||
writeInventory(); | ||
//refresh observable list | ||
Main.partList = FXCollections.observableArrayList(); | ||
JSONArray inventoryList2 = (JSONArray) Inventory.get("inventory"); | ||
Iterator<JSONObject> iterator2 = inventoryList2.iterator(); | ||
int i = 0; | ||
while (iterator2.hasNext()) { | ||
JSONObject it = iterator2.next(); | ||
Main.partList.add(new ListViewPart((String)it.get("name"), (long)it.get("numberAvailable"), (long)it.get("row"), (long)it.get("col"), (long)it.get("height"),(boolean)it.get("returnRequired"))); | ||
i++; | ||
} | ||
} | ||
|
||
public void addBorrowedParts(ListViewPart part, int numBorrowed, long ID, String forClass){ | ||
JSONArray borrowedList = (JSONArray)BorrowedInventory.get("borrowedInventory"); | ||
Iterator<JSONObject> iterator = borrowedList.iterator(); | ||
JSONArray tempBorrowedList = new JSONArray(); | ||
boolean idFound = false; | ||
while (iterator.hasNext()) { | ||
JSONObject it = iterator.next(); | ||
if((long)it.get("ID")==ID){ | ||
idFound = true; | ||
JSONArray parts = (JSONArray)it.get("Parts"); | ||
JSONObject newPart = new JSONObject(); | ||
newPart.put("name", part.getName()); | ||
newPart.put("numberBorrowed",numBorrowed); | ||
newPart.put("Class", forClass); | ||
parts.add(newPart); | ||
it.put("Parts", parts); | ||
} | ||
tempBorrowedList.add(it); | ||
} | ||
if(!idFound){ | ||
JSONObject newUser = new JSONObject(); | ||
newUser.put("ID", ID); | ||
JSONArray parts = new JSONArray(); | ||
JSONObject newPart = new JSONObject(); | ||
newPart.put("name", part.getName()); | ||
newPart.put("numberBorrowed",numBorrowed); | ||
newPart.put("Class", forClass); | ||
parts.add(newPart); | ||
newUser.put("Parts", parts); | ||
tempBorrowedList.add(newUser); | ||
} | ||
BorrowedInventory.put("borrowedInventory", tempBorrowedList); | ||
writeBorrowedInventory(); | ||
} | ||
|
||
public void loadInventory(){ | ||
JSONParser parser = new JSONParser(); | ||
try { | ||
Object obj = parser.parse(new FileReader(InventoryLoc)); | ||
Inventory = (JSONObject) obj; | ||
JSONArray inventoryList = (JSONArray) Inventory.get("inventory"); | ||
Iterator<JSONObject> iterator = inventoryList.iterator(); | ||
while (iterator.hasNext()) { | ||
JSONObject it = iterator.next(); | ||
Main.partList.add(new ListViewPart((String)it.get("name"), (long)it.get("numberAvailable"), (long)it.get("row"), (long)it.get("col"),(long)it.get("height"), (boolean)it.get("returnRequired"))); | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
public void loadBorrowedInventory(){ | ||
JSONParser parser = new JSONParser(); | ||
try { | ||
Object obj = parser.parse(new FileReader(BorrowedInventoryLoc)); | ||
BorrowedInventory = (JSONObject) obj; | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private void writeInventory(){ | ||
try (FileWriter file = new FileWriter(InventoryLoc)) { | ||
file.write(Inventory.toJSONString()); | ||
file.flush(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private void writeBorrowedInventory(){ | ||
try (FileWriter file = new FileWriter(BorrowedInventoryLoc)) { | ||
file.write(BorrowedInventory.toJSONString()); | ||
file.flush(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/gui/ItemCheckOutScreenController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package edu.wpi.rbe.rbe2001.fieldsimulator.gui; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.gui.Main; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.text.DecimalFormat; | ||
import java.util.ArrayList; | ||
import java.util.ResourceBundle; | ||
|
||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.IRBE2001Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.IRBE2002Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.RBE2001Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.RBE3001Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.ISimplePIDRobot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.WarehouseRobotStatus; | ||
import javafx.application.Platform; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.chart.LineChart; | ||
import javafx.scene.chart.ScatterChart; | ||
import javafx.scene.control.*; | ||
import javafx.scene.chart.XYChart; | ||
import javafx.scene.chart.XYChart.Series; | ||
|
||
public class ItemCheckOutScreenController implements Initializable { | ||
|
||
@FXML | ||
private Label name; | ||
|
||
@FXML | ||
private Label numStock; | ||
|
||
@FXML | ||
private Label PartReturn; | ||
|
||
@FXML | ||
private Spinner<Integer> quantityDesired; | ||
|
||
@FXML | ||
private Button confirm; | ||
|
||
@FXML | ||
private Button cancel; | ||
|
||
@FXML | ||
private TextField rbeclassEntry; | ||
|
||
public void initialize(URL location, ResourceBundle resources) { | ||
SpinnerValueFactory<Integer> valueFactory = // | ||
new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 10, 1); | ||
quantityDesired.setValueFactory(valueFactory); | ||
} | ||
public void setScreenInfo(String nameOfPart, long numberInStock, boolean needToReturn){ | ||
name.setText(nameOfPart); | ||
if(needToReturn){ | ||
PartReturn.setText("End Of Term"); | ||
} | ||
else{ | ||
PartReturn.setText("Do Not Return"); | ||
} | ||
rbeclassEntry.setText(""); | ||
if(numberInStock==0){ | ||
numStock.setText("0"); | ||
confirm.setDisable(true); | ||
quantityDesired.getValueFactory().setValue(1); | ||
quantityDesired.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1, 1)); | ||
} | ||
else{ | ||
confirm.setDisable(false); | ||
numStock.setText(Integer.toString((int)numberInStock)); | ||
quantityDesired.getValueFactory().setValue(1); | ||
quantityDesired.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, (int)numberInStock, 1)); | ||
} | ||
} | ||
public void confirm(){ | ||
Main.numberRequested = quantityDesired.getValue(); | ||
Main.updateInventory(Main.currentPart, Main.numberRequested, Main.currentIDNum, rbeclassEntry.getText()); | ||
Main.BackendRobotController.setDeliverIsTest(false); | ||
Main.BackendRobotController.sendDeliverBin(Main.currentPart.getRow(), Main.currentPart.getCol(), Main.currentPart.getHeight()); | ||
Main.setRobotActionScene(0); | ||
} | ||
|
||
public void cancelCallback(){ | ||
Main.setItemSelectScene(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/gui/ItemSelectScreenController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package edu.wpi.rbe.rbe2001.fieldsimulator.gui; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.text.DecimalFormat; | ||
import java.util.ArrayList; | ||
import java.util.ResourceBundle; | ||
|
||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.IRBE2001Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.IRBE2002Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.RBE2001Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.RBE3001Robot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.ISimplePIDRobot; | ||
import edu.wpi.rbe.rbe2001.fieldsimulator.robot.WarehouseRobotStatus; | ||
import javafx.application.Platform; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.chart.LineChart; | ||
import javafx.scene.chart.ScatterChart; | ||
import javafx.scene.control.*; | ||
import javafx.scene.chart.XYChart; | ||
import javafx.scene.chart.XYChart.Series; | ||
|
||
public class ItemSelectScreenController implements Initializable { | ||
@FXML | ||
private Button Finished; | ||
|
||
@FXML | ||
private ListView<ListViewPart> partsList; | ||
|
||
public ItemSelectScreenController(){ | ||
|
||
} | ||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
partsList.setItems(Main.partList); | ||
partsList.setCellFactory(partListView->new ListViewPartCell()); | ||
} | ||
public void finishedCallback(){ | ||
Main.setWelcomeScene(); | ||
Main.BackendRobotController.sendPark(Main.BackendRobotController.defaultParkLocation[0], Main.BackendRobotController.defaultParkLocation[1]);} | ||
|
||
public void itemSelectedCallback(){ | ||
ListViewPart sP = partsList.getSelectionModel().getSelectedItem(); | ||
Main.currentPart = sP; | ||
Main.setItemCheckOutScene(sP.getName(), sP.getNumAvailable(), sP.getreturnRequired()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/gui/ListViewPart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package edu.wpi.rbe.rbe2001.fieldsimulator.gui; | ||
|
||
public class ListViewPart { | ||
private String Name; | ||
private long NumAvailable; | ||
private long Row; | ||
private long Col; | ||
private long height; | ||
private boolean returnRequired; | ||
public ListViewPart(String name, long numAvailable, long row, long col, long height, boolean returnRequired) | ||
{ | ||
this.Name = name; | ||
this.NumAvailable = numAvailable; | ||
this.Row = row; | ||
this.Col = col; | ||
this.height =height; | ||
this.returnRequired = returnRequired; | ||
} | ||
public String getName(){ | ||
return Name; | ||
} | ||
public long getNumAvailable(){ | ||
return NumAvailable; | ||
} | ||
public long getRow(){ | ||
return Row; | ||
} | ||
public long getCol(){ | ||
return Col; | ||
} | ||
public long getHeight(){ return height;} | ||
public boolean getreturnRequired(){return returnRequired;} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the location for this file should be a system property passed at runtime with the -D options. For testing this file should be in the version control with the code.