Commit 4887c141 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange Committed by Matias Guijarro
Browse files

axis: Use client redis cache for axis.

+ link settings with configuration
parent 278946fd
...@@ -663,7 +663,6 @@ class Axis: ...@@ -663,7 +663,6 @@ class Axis:
def __init__(self, name, controller, config): def __init__(self, name, controller, config):
self.__name = name self.__name = name
self.__controller = controller self.__controller = controller
self.__settings = AxisSettings(self)
self.__move_done = gevent.event.Event() self.__move_done = gevent.event.Event()
self.__move_done_callback = gevent.event.Event() self.__move_done_callback = gevent.event.Event()
self.__move_done.set() self.__move_done.set()
...@@ -676,6 +675,7 @@ class Axis: ...@@ -676,6 +675,7 @@ class Axis:
if self.__encoder is not None: if self.__encoder is not None:
self.__encoder.axis = self self.__encoder.axis = self
self.__config = StaticConfig(config) self.__config = StaticConfig(config)
self.__settings = AxisSettings(self)
self.__init_config_properties() self.__init_config_properties()
self._group_move = GroupMove() self._group_move = GroupMove()
self._beacon_channels = dict() self._beacon_channels = dict()
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
from bliss.common import event from bliss.common import event
from bliss.common.greenlet_utils import KillMask from bliss.common.greenlet_utils import KillMask
from bliss.config import settings from bliss.config import settings, settings_cache
import sys import sys
...@@ -85,8 +85,7 @@ class ControllerAxisSettings: ...@@ -85,8 +85,7 @@ class ControllerAxisSettings:
if self.persistent_setting[setting_name]: if self.persistent_setting[setting_name]:
with KillMask(): with KillMask():
hash_setting = settings.HashSetting("axis.%s" % axis.name) value = axis.settings._hash.get(setting_name)
value = hash_setting.get(setting_name)
else: else:
chan = axis._beacon_channels.get(setting_name) chan = axis._beacon_channels.get(setting_name)
if chan: if chan:
...@@ -100,7 +99,7 @@ class ControllerAxisSettings: ...@@ -100,7 +99,7 @@ class ControllerAxisSettings:
return value return value
def _clear(self, axis, setting_name): def _clear(self, axis, setting_name):
settings.HashSetting("axis.%s" % axis.name)[setting_name] = None axis.settings._hash[setting_name] = None
def set(self, axis, setting_name, value): def set(self, axis, setting_name, value):
""" """
...@@ -118,7 +117,7 @@ class ControllerAxisSettings: ...@@ -118,7 +117,7 @@ class ControllerAxisSettings:
if self.persistent_setting[setting_name]: if self.persistent_setting[setting_name]:
with KillMask(): with KillMask():
settings.HashSetting("axis.%s" % axis.name)[setting_name] = value axis.settings._hash[setting_name] = value
axis._beacon_channels[setting_name].value = value axis._beacon_channels[setting_name].value = value
event.send(axis, "internal_" + setting_name, value) event.send(axis, "internal_" + setting_name, value)
...@@ -132,6 +131,14 @@ class AxisSettings: ...@@ -132,6 +131,14 @@ class AxisSettings:
def __init__(self, axis): def __init__(self, axis):
self.__axis = axis self.__axis = axis
self.__state = None self.__state = None
cnx_cache = settings_cache.get_redis_client_cache()
self._hash = settings.HashSetting(
"axis.%s" % axis.name,
default_values=axis.config.config_dict,
connection=cnx_cache,
)
# Activate prefetch
cnx_cache.add_prefetch(self._hash)
def set(self, setting_name, value): def set(self, setting_name, value):
if setting_name == "state": if setting_name == "state":
......
Supports Markdown
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