Hide debug info, uncomment main menu

This commit is contained in:
Blizzard Finnegan 2023-03-08 15:22:43 -05:00
parent 1ef2fecb57
commit f22d9f7b8d
No known key found for this signature in database
GPG key ID: DE547EDF547DDA49
2 changed files with 85 additions and 74 deletions

View file

@ -81,11 +81,11 @@ public class Cli
ErrorLogging.logError("Version: " + version); ErrorLogging.logError("Version: " + version);
ErrorLogging.logError("========================"); ErrorLogging.logError("========================");
try{ try{
//inputScanner = new Scanner(System.in); inputScanner = new Scanner(System.in);
//ConfigFacade.init(); ConfigFacade.init();
//int userInput = 0; int userInput = 0;
ErrorLogging.logError("Calibrating motor movement. This may take several minutes..."); ErrorLogging.logError("Calibrating motor movement. This may take several minutes...");
ErrorLogging.logError("The piston will fire momentarily when the motor calibration is complete."); ErrorLogging.logError("The piston will fire momentarily when the motor calibration is complete.");
@ -95,66 +95,66 @@ public class Cli
MovementFacade.goDown(); MovementFacade.goDown();
MovementFacade.goUp(); MovementFacade.goUp();
//do do
//{ {
// printMainMenu(); printMainMenu();
// userInput = (int)inputFiltering(inputScanner.nextLine()); userInput = (int)inputFiltering(inputScanner.nextLine());
// switch (userInput) switch (userInput)
// { {
// case 1: case 1:
// println("Setting up cameras..."); println("Setting up cameras...");
// println("This may take a moment..."); println("This may take a moment...");
// configureCameras(); configureCameras();
// camerasConfigured = true; camerasConfigured = true;
// break; break;
// case 2: case 2:
// setDUTSerials(); setDUTSerials();
// break; break;
// case 3: case 3:
// setIterationCount(); setIterationCount();
// break; break;
// case 4: case 4:
// setActiveCameras(); setActiveCameras();
// break; break;
// case 5: case 5:
// if(!camerasConfigured) if(!camerasConfigured)
// { {
// prompt("You have not configured the cameras yet! Are you sure you would like to continue? (y/N): "); prompt("You have not configured the cameras yet! Are you sure you would like to continue? (y/N): ");
// String input = inputScanner.nextLine().toLowerCase().trim(); String input = inputScanner.nextLine().toLowerCase().trim();
// if( input.isBlank() || input.charAt(0) != 'y' ) break; if( input.isBlank() || input.charAt(0) != 'y' ) break;
// else else
// ErrorLogging.logError("DEBUG: Potential for error: Un-initialised cameras."); ErrorLogging.logError("DEBUG: Potential for error: Un-initialised cameras.");
// } }
// serialsSet = true; serialsSet = true;
// for(String cameraName : OpenCVFacade.getCameraNames()) for(String cameraName : OpenCVFacade.getCameraNames())
// { {
// if(ConfigFacade.getValue(cameraName,ConfigProperties.ACTIVE) != 0 && if(ConfigFacade.getValue(cameraName,ConfigProperties.ACTIVE) != 0 &&
// ConfigFacade.getSerial(cameraName) == null ) ConfigFacade.getSerial(cameraName) == null )
// serialsSet = false; serialsSet = false;
// } }
// if(!serialsSet) if(!serialsSet)
// { {
// prompt("You have not set the serial numbers for your DUTs yet! Are you sure you would like to continue? (y/N): "); prompt("You have not set the serial numbers for your DUTs yet! Are you sure you would like to continue? (y/N): ");
// String input = inputScanner.nextLine().toLowerCase().trim(); String input = inputScanner.nextLine().toLowerCase().trim();
// if( input.isBlank() || input.charAt(0) != 'y' ) break; if( input.isBlank() || input.charAt(0) != 'y' ) break;
// else else
// ErrorLogging.logError("DEBUG: Potential for error: Un-initialised DUT Serial numbers."); ErrorLogging.logError("DEBUG: Potential for error: Un-initialised DUT Serial numbers.");
// } }
// runTests(); runTests();
// break; break;
// case 6: case 6:
// printHelp(); printHelp();
// break; break;
// case 8: case 8:
// break; break;
// default: default:
// //Input handling already done by inputFiltering() //Input handling already done by inputFiltering()
// } }
//} while (userInput != mainMenuOptionCount); } while (userInput != mainMenuOptionCount);
} }
//If anything ever goes wrong, catch the error and exit //If anything ever goes wrong, catch the error and exit

View file

@ -44,7 +44,7 @@ public class MovementFacade
/** /**
* Amount of buffer between the found absolute speed, and used speed. * Amount of buffer between the found absolute speed, and used speed.
*/ */
private static final int SPEED_BUFFER = 4000; private static final int SPEED_BUFFER = 5000;
/** /**
* Minimum allowed speed of the fixture arm; also used for reset travels. * Minimum allowed speed of the fixture arm; also used for reset travels.
@ -366,7 +366,7 @@ public class MovementFacade
} }
} }
motorEnable.off(); motorEnable.off();
ErrorLogging.logError("Motor returned after " + counter + " polls."); ErrorLogging.logError("DEBUG: Motor returned after " + counter + " polls.");
ErrorLogging.logError("DEBUG: --------------------------------------"); ErrorLogging.logError("DEBUG: --------------------------------------");
return counter; return counter;
} }
@ -380,10 +380,10 @@ public class MovementFacade
findDistance(); findDistance();
ErrorLogging.logError("Resetting arm to set speed."); ErrorLogging.logError("Resetting arm to set speed.");
resetArm(); resetArm();
ErrorLogging.logError("Coarse calibrating..."); ErrorLogging.logError("Calibrating...");
FREQUENCY = calib(MIN_FREQUENCY, MAX_FREQUENCY, 10000); FREQUENCY = calib(MIN_FREQUENCY, MAX_FREQUENCY, 10000);
ErrorLogging.logError("Fine calibrating..."); //ErrorLogging.logError("Fine calibrating...");
FREQUENCY = calib(FREQUENCY,(FREQUENCY+10000),1000); //FREQUENCY = calib(FREQUENCY,(FREQUENCY+10000),1000);
ErrorLogging.logError("Calibration complete!"); ErrorLogging.logError("Calibration complete!");
ErrorLogging.logError("DEBUG: Speed set to " + (FREQUENCY - SPEED_BUFFER)); ErrorLogging.logError("DEBUG: Speed set to " + (FREQUENCY - SPEED_BUFFER));
setFrequency(FREQUENCY - SPEED_BUFFER); setFrequency(FREQUENCY - SPEED_BUFFER);
@ -410,11 +410,11 @@ public class MovementFacade
} }
} }
motorEnable.off(); motorEnable.off();
if(lowerLimit.isOff()) ErrorLogging.logError("False positive on findDistance down!"); if(lowerLimit.isOff()) ErrorLogging.logError("DEBUG: False positive on findDistance down!");
int downTravelDist = downTravelCounter * MIN_FREQUENCY; int downTravelDist = downTravelCounter * MIN_FREQUENCY;
ErrorLogging.logError("DEBUG: Down travel distance found to be: " + downTravelDist); ErrorLogging.logError("DEBUG: Down travel distance found to be: " + downTravelDist);
ErrorLogging.logError("Down travel count: " + downTravelCounter); ErrorLogging.logError("DEBUG: Down travel count: " + downTravelCounter);
motorDirection.high(); motorDirection.high();
motorEnable.on(); motorEnable.on();
@ -428,11 +428,11 @@ public class MovementFacade
} }
} }
motorEnable.off(); motorEnable.off();
if(upperLimit.isOff()) ErrorLogging.logError("False positive on findDistance up!"); if(upperLimit.isOff()) ErrorLogging.logError("DEBUG: False positive on findDistance up!");
int upTravelDist = upTravelCounter * MIN_FREQUENCY; int upTravelDist = upTravelCounter * MIN_FREQUENCY;
ErrorLogging.logError("DEBUG: Up travel distance found to be: " + upTravelDist); ErrorLogging.logError("DEBUG: Up travel distance found to be: " + upTravelDist);
ErrorLogging.logError("Up travel count: " + downTravelCounter); ErrorLogging.logError("DEBUG: Up travel count: " + downTravelCounter);
if(Math.abs(upTravelCounter - downTravelCounter) > 3) if(Math.abs(upTravelCounter - downTravelCounter) > 3)
{ {
@ -526,7 +526,6 @@ public class MovementFacade
* Internal function to send the fixture to a given limit switch. * Internal function to send the fixture to a given limit switch.
* *
* Detects if the limit switch is active before activating motor. * Detects if the limit switch is active before activating motor.
* Motor movement is written to slow down at {@link #STEP_1} and {@link #STEP_2}
* *
* @param moveUp Whether to send the fixture up or down. (True = up, False = down) * @param moveUp Whether to send the fixture up or down. (True = up, False = down)
* @return true if movement was successful; otherwise false * @return true if movement was successful; otherwise false
@ -551,20 +550,28 @@ public class MovementFacade
if(limitSense.isHigh()) return FinalState.SAFE; if(limitSense.isHigh()) return FinalState.SAFE;
pwm.on(DUTY_CYCLE, FREQUENCY); pwm.on(DUTY_CYCLE, FREQUENCY);
int travelTime = (int)(TRAVEL_DIST / FREQUENCY); int totalPollCount = (int)(TRAVEL_DIST / FREQUENCY);
int totalPollCount = travelTime * TIME_CONVERSION;
int highSpeedPolls = (int)(totalPollCount * SLOW_POLL_FACTOR); int highSpeedPolls = (int)(totalPollCount * SLOW_POLL_FACTOR);
int notHighSpeedPolls = totalPollCount - highSpeedPolls; int notHighSpeedPolls = totalPollCount - highSpeedPolls;
int medSpeedPolls = (int)(notHighSpeedPolls * SLOW_POLL_FACTOR); int medSpeedPolls = (int)(notHighSpeedPolls * SLOW_POLL_FACTOR);
int lowSpeedPolls = notHighSpeedPolls - medSpeedPolls; int lowSpeedPolls = notHighSpeedPolls - medSpeedPolls;
ErrorLogging.logError("DEBUG: =============================");
ErrorLogging.logError("DEBUG: Travel time: " + totalPollCount);
ErrorLogging.logError("DEBUG: High speed poll count: " + highSpeedPolls);
ErrorLogging.logError("DEBUG: Medium speed poll count: " + medSpeedPolls);
ErrorLogging.logError("DEBUG: Low speed poll count: " + lowSpeedPolls);
ErrorLogging.logError("DEBUG: =============================");
motorEnable.on(); motorEnable.on();
for(int i = 0; i < highSpeedPolls; i++) for(int i = 0; i < highSpeedPolls; i++)
{ {
try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); } try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); }
if(limitSense.isOn()) if(limitSense.isOn())
{ {
ErrorLogging.logError("DEBUG: Motor moved too fast! Stopping motor early.");
motorEnable.off(); motorEnable.off();
ErrorLogging.logError("DEBUG: Motor moved too fast! Stopping motor early.");
ErrorLogging.logError("DEBUG: Breaking high-speed loop and turning off motor!");
ErrorLogging.logError("DEBUG: Iteration count: " + i);
output = FinalState.FAILED; output = FinalState.FAILED;
break; break;
} }
@ -579,8 +586,10 @@ public class MovementFacade
try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); } try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); }
if(limitSense.isOn()) if(limitSense.isOn())
{ {
ErrorLogging.logError("DEBUG: Motor only partially slowed down! Stopping motor early.");
motorEnable.off(); motorEnable.off();
ErrorLogging.logError("DEBUG: Motor only partially slowed down! Stopping motor early.");
ErrorLogging.logError("DEBUG: Breaking medium-speed loop and turning off motor!");
ErrorLogging.logError("DEBUG: Iteration count: " + i);
break; break;
} }
} }
@ -595,8 +604,10 @@ public class MovementFacade
try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); } try{ Thread.sleep(POLL_WAIT); } catch(Exception e){ ErrorLogging.logError(e); }
if(limitSense.isOn()) if(limitSense.isOn())
{ {
ErrorLogging.logError("DEBUG: Motor slowed down completely, but hit limit switch early.");
motorEnable.off(); motorEnable.off();
ErrorLogging.logError("DEBUG: Motor slowed down completely, but hit limit switch early.");
ErrorLogging.logError("DEBUG: Breaking low-speed loop and turning off motor!");
ErrorLogging.logError("DEBUG: Iteration count: " + i);
break; break;
} }
} }