Skip to content
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
wants to merge 25 commits into
base: 2001_Field
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Oct 20, 2020
29467e5
Added JSON file reader for inventory, populates item list
Nick-L-1996 Oct 20, 2020
915e960
App now stores inventory changes, borrow inventory changes and update…
Nick-L-1996 Oct 21, 2020
c3dacb8
App now stores inventory changes, borrow inventory changes and update…
Nick-L-1996 Oct 21, 2020
f8e7fe2
Added Basic Backend and Maintenance screen for robots. GUI defaults t…
Nick-L-1996 Oct 27, 2020
d53d4a8
Adding Status Retrieval for robot for testing
Nick-L-1996 Oct 28, 2020
6b44683
Adding Status Retrieval for robot for testing
Nick-L-1996 Oct 28, 2020
bd87b34
Adding Status Retrieval for robot for testing
Nick-L-1996 Oct 28, 2020
01c6ba1
Adding Status Retrieval for robot for testing
Nick-L-1996 Oct 28, 2020
617c1d4
Added logic for full procurement execution and added buttons for test…
Nick-L-1996 Oct 29, 2020
39be7f2
Robot now parks after returning a bin
Nick-L-1996 Oct 29, 2020
5ee5470
changed byte packet to float packet
gentov Nov 1, 2020
802d34f
added commands to test lift mechanism
Nick-L-1996 Nov 12, 2020
10ff0d1
Merge remote-tracking branch 'origin/2001_Field' into 2001_Field
Nick-L-1996 Nov 12, 2020
cc657f1
fixed states
Nick-L-1996 Nov 13, 2020
158114d
updates to switch/case statement in robot interface
gentov Nov 14, 2020
7133786
Added Procurement Gui Intergration
Nick-L-1996 Nov 20, 2020
ce694c3
Added Procurement Gui Intergration
Nick-L-1996 Nov 20, 2020
d481a76
Added Procurement Gui Intergration
Nick-L-1996 Nov 20, 2020
ca190ad
Added Procurement Gui Intergration
Nick-L-1996 Nov 20, 2020
e09eea4
Added Procurement Gui Intergration
Nick-L-1996 Nov 20, 2020
0731eaa
Added Procurement Gui Intergration
Nick-L-1996 Nov 20, 2020
e54dc61
changed error message
Nick-L-1996 Nov 23, 2020
89b7a49
cleaned up code a little
Nick-L-1996 Dec 4, 2020
ccb5b99
added documentation
Nick-L-1996 Dec 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added UI Documentation.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {

implementation "com.neuronrobotics:SimplePacketComsJava:0.10.1"
implementation "com.neuronrobotics:SimplePacketComsJava-HID:0.13.1"
compile 'com.googlecode.json-simple:json-simple:1.1.1'
//implementation project(":SimplePacketComsJava")

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public class InterfaceController {
private LineChart<Double, Double> pidGraphVel;
// private ArrayList<XYChart.Series> pidGraphSeriesVel = new ArrayList<>();
// private ArrayList<XYChart.Series> pidGraphSeries = new ArrayList<>();
private WarehouseRobotStatus status = WarehouseRobotStatus.Fault_E_Stop_pressed;
private WarehouseRobotStatus status = WarehouseRobotStatus.Halting;
private ObservableList<String> weights = FXCollections.observableArrayList("Aluminum", "Plastic");
private ObservableList<String> sides = FXCollections.observableArrayList("25", "45");
private ObservableList<String> pos = FXCollections.observableArrayList("1", "2");
Expand Down Expand Up @@ -421,8 +421,8 @@ private void setFieldSim(ISimplePIDRobot r) {
heartBeat.setText(status.name());
});
Platform.runLater(() -> {
if (status == WarehouseRobotStatus.Waiting_for_approval_to_pickup
|| status == WarehouseRobotStatus.Waiting_for_approval_to_dropoff)
if (status == WarehouseRobotStatus.Initial_State//This will no longer work since we changed the statuses in Warehouse robot. Changed status so this compiles
|| status == WarehouseRobotStatus.HomingLift)
approveButton.setDisable(false);
else
approveButton.setDisable(true);
Expand Down
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";
Copy link
Author

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.

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();
}
}
}
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();
}
}
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());
}
}
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;}
}
Loading