[imp] hw_scale: Disable Adam if not used
Adam scales give a beep if it has no changed value to send. This commit disable the beeping outside the weight screen
This commit is contained in:
committed by
Gert Pellin - GPE
parent
7fda09549c
commit
bb015818ea
@@ -81,6 +81,7 @@ Toledo8217Protocol = ScaleProtocol(
|
|||||||
clearCommand=b'C',
|
clearCommand=b'C',
|
||||||
emptyAnswerValid=False,
|
emptyAnswerValid=False,
|
||||||
autoResetWeight=False,
|
autoResetWeight=False,
|
||||||
|
disable=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# The ADAM scales have their own RS232 protocol, usually documented in the scale's manual
|
# The ADAM scales have their own RS232 protocol, usually documented in the scale's manual
|
||||||
@@ -110,6 +111,7 @@ ADAMEquipmentProtocol = ScaleProtocol(
|
|||||||
clearCommand=None, # No clear command -> Tare again
|
clearCommand=None, # No clear command -> Tare again
|
||||||
emptyAnswerValid=True, # AZExtra does not answer unless a new non-zero weight has been detected
|
emptyAnswerValid=True, # AZExtra does not answer unless a new non-zero weight has been detected
|
||||||
autoResetWeight=True, # AZExtra will not return 0 after removing products
|
autoResetWeight=True, # AZExtra will not return 0 after removing products
|
||||||
|
disable=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -131,6 +133,7 @@ class Scale(Thread):
|
|||||||
self.device = None
|
self.device = None
|
||||||
self.path_to_scale = ''
|
self.path_to_scale = ''
|
||||||
self.protocol = None
|
self.protocol = None
|
||||||
|
self.disabled = False
|
||||||
|
|
||||||
def lockedstart(self):
|
def lockedstart(self):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
@@ -258,6 +261,8 @@ class Scale(Thread):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_weight(self):
|
def get_weight(self):
|
||||||
|
self.repeats = 5
|
||||||
|
self.disabled = False
|
||||||
self.lockedstart()
|
self.lockedstart()
|
||||||
return self.weight
|
return self.weight
|
||||||
|
|
||||||
@@ -338,23 +343,30 @@ class Scale(Thread):
|
|||||||
self.device = None
|
self.device = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if self.device:
|
if not self.disabled:
|
||||||
old_weight = self.weight
|
if self.device:
|
||||||
self.read_weight()
|
old_weight = self.weight
|
||||||
if self.weight != old_weight:
|
self.read_weight()
|
||||||
_logger.info('New Weight: %s, sleeping %ss', self.weight, self.protocol.newWeightDelay)
|
if self.weight != old_weight:
|
||||||
time.sleep(self.protocol.newWeightDelay)
|
_logger.info('New Weight: %s, sleeping %ss', self.weight, self.protocol.newWeightDelay)
|
||||||
if self.weight and self.protocol.autoResetWeight:
|
time.sleep(self.protocol.newWeightDelay)
|
||||||
self.weight = 0
|
if self.weight and self.protocol.autoResetWeight:
|
||||||
|
self.weight = 0
|
||||||
|
else:
|
||||||
|
_logger.info('Weight: %s, sleeping %ss', self.weight, self.protocol.weightDelay)
|
||||||
|
time.sleep(self.protocol.weightDelay)
|
||||||
|
self.disabled = True
|
||||||
else:
|
else:
|
||||||
_logger.info('Weight: %s, sleeping %ss', self.weight, self.protocol.weightDelay)
|
with self.scalelock:
|
||||||
time.sleep(self.protocol.weightDelay)
|
self.device = self.get_device()
|
||||||
|
if not self.device:
|
||||||
|
# retry later to support "plug and play"
|
||||||
|
time.sleep(10)
|
||||||
|
else:
|
||||||
|
self.disabled = self.protocol.disable
|
||||||
else:
|
else:
|
||||||
with self.scalelock:
|
time.sleep(10)
|
||||||
self.device = self.get_device()
|
|
||||||
if not self.device:
|
|
||||||
# retry later to support "plug and play"
|
|
||||||
time.sleep(10)
|
|
||||||
|
|
||||||
scale_thread = None
|
scale_thread = None
|
||||||
if serial:
|
if serial:
|
||||||
|
|||||||
Reference in New Issue
Block a user