Skip to content

Commit 1f7f6a4

Browse files
committed
ensure we are calling ourselve, even when overloaded
1 parent 45fde2e commit 1f7f6a4

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

examples/simple_ws.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def command_active_monitor(command: str, active: bool):
3737
dataref = ws.dataref("sim/cockpit2/clock_timer/local_time_seconds")
3838
ws.monitor_dataref(dataref)
3939

40-
arrdref = ws.dataref("sim/weather/aircraft/wind_direction_degt[0]")
41-
ws.monitor_dataref(arrdref)
40+
arrdrefall = ws.dataref("sim/weather/region/wind_altitude_msl_m") # does not change a lot when not moving
41+
ws.monitor_dataref(arrdrefall)
42+
43+
arrdref1 = ws.dataref("sim/weather/aircraft/wind_direction_degt[0]")
44+
ws.monitor_dataref(arrdref1)
4245

4346
ws.monitor_command_active(ws.command("sim/map/show_current"))
4447

xpwebapi/api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ def value(self, value):
473473
if self.auto_save:
474474
self.write()
475475

476+
def get_value(self):
477+
"""Return current value of dataref in local application"""
478+
return self._new_value if self._new_value is not None else self.api.dataref_value(self)
479+
476480
def get_string_value(self, encoding: str) -> str | None:
477481
"""Decodes current dataref value and replaces it with the decoded string value
478482
@@ -485,7 +489,8 @@ def get_string_value(self, encoding: str) -> str | None:
485489
if self.value_type not in ["data"]:
486490
logger.warning("value type is not data")
487491
return None
488-
value_bytes = self.value
492+
# https://stackoverflow.com/questions/1021464/how-to-call-a-property-of-the-base-class-if-this-property-is-being-overwritten-i
493+
value_bytes = Dataref.value.fget(self) # make sure we call OUT .value property (if overwritten)
489494
if value_bytes is None:
490495
logger.debug("no value")
491496
return None

0 commit comments

Comments
 (0)