Skip to content

Commit 0a213c1

Browse files
authored
Merge pull request #34 from target/nonScale_changes
Check Scale connect status before acquiring lock
2 parents 6a4421f + 4b65180 commit 0a213c1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/com/target/devicemanager/components/scale/ScaleDevice.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ void startStableWeightRead(int timeout) {
203203
return;
204204
} catch (JposException jposException) {
205205
if(isConnected()) {
206-
LOGGER.error(MARKER, "Scale Failed to Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
206+
LOGGER.trace("Scale Failed to Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
207207
} else {
208-
LOGGER.error(MARKER, "Scale not connected in Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
208+
LOGGER.trace("Scale not connected in Read Stable Weight: " + jposException.getErrorCode() + ", " + jposException.getErrorCodeExtended());
209209
}
210210
if(jposException.getErrorCode() != JposConst.JPOS_E_TIMEOUT) {
211211
fireScaleWeightErrorEvent(jposException);

src/main/java/com/target/devicemanager/components/scale/ScaleManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void subscribeToLiveWeight(SseEmitter liveWeightEmitter) throws IOException {
113113
}
114114

115115
public FormattedWeight getStableWeight(CompletableFuture<FormattedWeight> stableWeightClient) throws ScaleException {
116-
if (scaleDevice.tryLock() && isScaleReady()) {
116+
if (isScaleReady() && scaleDevice.tryLock()) {
117117
//Create new future and add it to the list
118118
stableWeightClients.add(stableWeightClient);
119119
scaleDevice.startStableWeightRead(STABLE_WEIGHT_TIMEOUT_MSEC);

0 commit comments

Comments
 (0)