Skip to content

Commit

Permalink
Merge pull request #34 from target/nonScale_changes
Browse files Browse the repository at this point in the history
Check Scale connect status before acquiring lock
  • Loading branch information
arpal7 authored Feb 14, 2024
2 parents 6a4421f + 4b65180 commit 0a213c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ void startStableWeightRead(int timeout) {
return;
} catch (JposException jposException) {
if(isConnected()) {
LOGGER.error(MARKER, "Scale Failed to Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
LOGGER.trace("Scale Failed to Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
} else {
LOGGER.error(MARKER, "Scale not connected in Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
LOGGER.trace("Scale not connected in Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
}
if(jposException.getErrorCode() != JposConst.JPOS_E_TIMEOUT) {
fireScaleWeightErrorEvent(jposException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void subscribeToLiveWeight(SseEmitter liveWeightEmitter) throws IOException {
}

public FormattedWeight getStableWeight(CompletableFuture<FormattedWeight> stableWeightClient) throws ScaleException {
if (scaleDevice.tryLock() && isScaleReady()) {
if (isScaleReady() && scaleDevice.tryLock()) {
//Create new future and add it to the list
stableWeightClients.add(stableWeightClient);
scaleDevice.startStableWeightRead(STABLE_WEIGHT_TIMEOUT_MSEC);
Expand Down

0 comments on commit 0a213c1

Please sign in to comment.