Skip to content

Commit

Permalink
Merge pull request #33 from target/remove_scale_workaround
Browse files Browse the repository at this point in the history
Removed Scale Workaround
  • Loading branch information
rrenkor authored Jan 25, 2024
2 parents 010e951 + c919263 commit 6a4421f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class ScaleDevice implements StatusUpdateListener, ErrorListener {
private static final Marker MARKER = MarkerFactory.getMarker("FATAL");
private boolean deviceConnected = false;
private int[] weight;
private boolean readyForStableWeight;

/**
* Initializes the Scale Device.
Expand Down Expand Up @@ -171,13 +170,6 @@ public void setStableWeightInProgress(boolean stableWeightInProgress) {
this.stableWeightInProgress = stableWeightInProgress;
}

/**
* This method is only used to set 'readyForStableWeight' for unit testing
* @param readyForStableWeight
*/
public void setReadyForStableWeight(boolean readyForStableWeight) {
this.readyForStableWeight = readyForStableWeight;
}
/**
* This method is only used to set 'weight' for unit testing
* @param weight
Expand All @@ -203,15 +195,12 @@ void startStableWeightRead(int timeout) {
while(currentTimeMsec <= endTimeMsec) {
LOGGER.trace("Read Weight Time Remaining " + (endTimeMsec - currentTimeMsec));
try {
if(readyForStableWeight){
scale.readWeight(weight, STABLE_WEIGHT_READ_TIMEOUT);
LOGGER.trace("After ReadWeight " + weight[0]);
fireScaleStableWeightDataEvent(new FormattedWeight(weight[0]));
stableWeightInProgress = false;
weight = new int[1];
readyForStableWeight = false;
return;
}
} catch (JposException jposException) {
if(isConnected()) {
LOGGER.error(MARKER, "Scale Failed to Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
Expand All @@ -238,7 +227,6 @@ void startStableWeightRead(int timeout) {
public void statusUpdateOccurred(StatusUpdateEvent statusUpdateEvent) {
LOGGER.trace("statusUpdateOccurred(): " + statusUpdateEvent.getStatus());
int status = statusUpdateEvent.getStatus();
readyForStableWeight = false;
switch (status) {
case JposConst.JPOS_SUE_POWER_OFF:
case JposConst.JPOS_SUE_POWER_OFF_OFFLINE:
Expand All @@ -249,7 +237,6 @@ public void statusUpdateOccurred(StatusUpdateEvent statusUpdateEvent) {
connect();
return;
case ScaleConst.SCAL_SUE_STABLE_WEIGHT:
readyForStableWeight = true;
Scale theScale = dynamicScale.getDevice();
try {
int scaleWeight = theScale.getScaleLiveWeight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ public void startStableWeightRead_NotInProgress() throws JposException {
public void startStableWeightRead_InProgress() throws JposException {
//arrange
scaleDeviceListLock.setStableWeightInProgress(false);
scaleDeviceListLock.setReadyForStableWeight(true);
scaleDeviceListLock.addScaleEventListener(mockScaleEventListener);
int[] weight = new int[] {3000, 0};
doAnswer(invocation -> {
Expand All @@ -551,7 +550,6 @@ public void startStableWeightRead_InProgress() throws JposException {
public void startStableWeightRead_ThrowsException() throws JposException {
//arrange
scaleDeviceListLock.setStableWeightInProgress(false);
scaleDeviceListLock.setReadyForStableWeight(true);
scaleDeviceListLock.addScaleEventListener(mockScaleEventListener);
JposException jposException = new JposException(JposConst.JPOS_E_OFFLINE);
doThrow(jposException).when(mockScale).readWeight(any(), anyInt());
Expand All @@ -571,7 +569,6 @@ public void startStableWeightRead_ThrowsException() throws JposException {
public void startStableWeightRead_TimesOut() throws JposException {
//arrange
scaleDeviceListLock.setStableWeightInProgress(false);
scaleDeviceListLock.setReadyForStableWeight(true);
scaleDeviceListLock.addScaleEventListener(mockScaleEventListener);
JposException jposException = new JposException(JposConst.JPOS_E_TIMEOUT);
doThrow(jposException).when(mockScale).readWeight(any(), anyInt());
Expand Down

0 comments on commit 6a4421f

Please sign in to comment.