|
|
|
@ -74,13 +74,16 @@ class ComPortTestWriter:
|
|
|
|
|
|
|
|
|
|
|
|
def generate_scales_data(self) -> str:
|
|
|
|
def generate_scales_data(self) -> str:
|
|
|
|
"""Generate simulated scales data"""
|
|
|
|
"""Generate simulated scales data"""
|
|
|
|
# Simulate scales value fluctuating slightly
|
|
|
|
# Step through the range and reverse at each end
|
|
|
|
variation = random.uniform(-0.1, 0.1)
|
|
|
|
if not hasattr(self, '_direction'):
|
|
|
|
self.current_scales_value += variation
|
|
|
|
self._direction = 1
|
|
|
|
|
|
|
|
step = random.uniform(SCALES_INCREMENT * 0.8, SCALES_INCREMENT * 1.2)
|
|
|
|
# Keep within bounds
|
|
|
|
self.current_scales_value += step * self._direction
|
|
|
|
|
|
|
|
if self.current_scales_value >= SCALES_MAX:
|
|
|
|
|
|
|
|
self._direction = -1
|
|
|
|
|
|
|
|
elif self.current_scales_value <= SCALES_MIN:
|
|
|
|
|
|
|
|
self._direction = 1
|
|
|
|
self.current_scales_value = max(SCALES_MIN, min(SCALES_MAX, self.current_scales_value))
|
|
|
|
self.current_scales_value = max(SCALES_MIN, min(SCALES_MAX, self.current_scales_value))
|
|
|
|
|
|
|
|
|
|
|
|
return f"{self.current_scales_value:.2f} kg"
|
|
|
|
return f"{self.current_scales_value:.2f} kg"
|
|
|
|
|
|
|
|
|
|
|
|
def generate_counter_data(self) -> str:
|
|
|
|
def generate_counter_data(self) -> str:
|
|
|
|
|