Commit c232777c authored by GromeTT's avatar GromeTT
Browse files

ENH: Weight in gramm

parent f8bc20c7
...@@ -17,7 +17,7 @@ def calculate_trail_status(self, load, moisture): ...@@ -17,7 +17,7 @@ def calculate_trail_status(self, load, moisture):
tmp_moisture = float(moisture) tmp_moisture = float(moisture)
wet_upper_bound = 300 wet_upper_bound = 300
dry_lower_bound = 450 dry_lower_bound = 450
weight_threshold = 10 weight_threshold = 8
if tmp_moisture <= wet_upper_bound: if tmp_moisture <= wet_upper_bound:
# Nass, Nicht befahrbar # Nass, Nicht befahrbar
......
...@@ -103,7 +103,7 @@ def update_load(self, resource): ...@@ -103,7 +103,7 @@ def update_load(self, resource):
if response.ok: if response.ok:
new_load_hex = response.json()["payloads"][0] # contains a hex string new_load_hex = response.json()["payloads"][0] # contains a hex string
new_load = struct.unpack("<f", bytes.fromhex(new_load_hex))[0] # to float new_load = struct.unpack("<f", bytes.fromhex(new_load_hex))[0] # to float
new_load = new_load * 100 # 0.11 gram => 11 tons # new_load = new_load * 100 # 0.11 gram => 11 tons
timestamp = response.json()["timestamps"][0] timestamp = response.json()["timestamps"][0]
current_load = self.load.get_value() current_load = self.load.get_value()
if current_load != new_load: if current_load != new_load:
...@@ -113,5 +113,5 @@ def update_load(self, resource): ...@@ -113,5 +113,5 @@ def update_load(self, resource):
) )
self._weight = new_load self._weight = new_load
print( print(
f"Update load value: {current_load} -> {new_load} ({new_load_str}t) (Timestamp: {timestamp})" f"Update load value: {current_load} -> {new_load} ({new_load_str}g) (Timestamp: {timestamp})"
) )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment