Skip to content

Commit

Permalink
optionally exclude macro values from IOCs for the web dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
rerpha committed Dec 6, 2024
1 parent b796f76 commit a65d8d8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions BlockServer/config/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _dict_to_list(in_dict: Dict[str, Any]) -> List[Any]:
def __str__(self) -> str:
return f"{self.__class__.__name__}(name={self.name}, component={self.component})"

def to_dict(self) -> Dict[str, Union[str, bool, List[Any]]]:
def to_dict(self, exclude_macros: bool = False) -> Dict[str, Union[str, bool, List[Any]]]:
"""Puts the IOC's details into a dictionary.
Returns:
Expand All @@ -120,7 +120,7 @@ def to_dict(self) -> Dict[str, Union[str, bool, List[Any]]]:
"simlevel": self.simlevel,
"pvs": self._dict_to_list(self.pvs),
"pvsets": self._dict_to_list(self.pvsets),
"macros": self._dict_to_list(self.macros),
"macros": self._dict_to_list(self.macros) if not exclude_macros else [],
"component": self.component,
"remotePvPrefix": self.remotePvPrefix,
}
Expand Down
10 changes: 5 additions & 5 deletions BlockServer/core/config_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _add_ioc(
f"Can't add IOC '{name}' to component '{component}': component does not exist"
)

def get_config_details(self) -> Dict[str, Any]:
def get_config_details(self, exclude_macros: bool = False) -> Dict[str, Any]:
"""Get the details of the configuration.
Returns:
Expand All @@ -333,8 +333,8 @@ def get_config_details(self) -> Dict[str, Any]:
"blocks": self._blocks_to_list(True),
"groups": self._groups_to_list(),
"iocs": self._iocs_to_list(),
"component_iocs": self._iocs_to_list_with_components(),
"components": self._comps_to_list(), # Just return the names of the components
"component_iocs": self._iocs_to_list_with_components(exclude_macros),
"components": self._comps_to_list(exclude_macros), # Just return the names of the components
"name": self._config.get_name(),
"description": self._config.meta.description,
"synoptic": self._config.meta.synoptic,
Expand Down Expand Up @@ -402,10 +402,10 @@ def _groups_to_list(self):
grps.append(groups[GRP_NONE.lower()].to_dict())
return grps

def _iocs_to_list(self):
def _iocs_to_list(self, exclude_macros: bool = False):
return [ioc.to_dict() for ioc in self._config.iocs.values()]

def _iocs_to_list_with_components(self):
def _iocs_to_list_with_components(self, exclude_macros: bool = False):
ioc_list = self._iocs_to_list()

for component in self._components.values():
Expand Down
12 changes: 11 additions & 1 deletion block_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
initial_dbs = {
BlockserverPVNames.BLOCKNAMES: char_waveform(16000),
BlockserverPVNames.HEARTBEAT: {"type": "int", "count": 1, "value": [0]},
BlockserverPVNames.BLOCK_DETAILS: char_waveform(16000),
BlockserverPVNames.WD_CONF_DETAILS: char_waveform(16000),
BlockserverPVNames.GROUPS: char_waveform(16000),
BlockserverPVNames.COMPS: char_waveform(16000),
BlockserverPVNames.LOAD_CONFIG: char_waveform(1000),
Expand Down Expand Up @@ -465,6 +465,7 @@ def _initialise_config(self, full_init=False):
self.update_blocks_monitors()

self.update_get_details_monitors()
self.update_wd_details_monitors()
self.update_curr_config_name_monitors()
self._active_configserver.update_archiver(full_init)
for handler in self.on_the_fly_handlers:
Expand Down Expand Up @@ -656,6 +657,15 @@ def update_get_details_monitors(self):
)
self.updatePVs()

def update_wd_details_monitors(self):
"""Updates the monitor for the active configuration, so the clients can see any changes."""
with self.monitor_lock:
config_details_json = convert_to_json(self._active_configserver.get_config_details(exclude_macros=True))
self.setParam(
BlockserverPVNames.WD_CONF_DETAILS, compress_and_hex(config_details_json)
)
self.updatePVs()

def update_curr_config_name_monitors(self):
"""Updates the monitor for the active configuration name, so the clients can see any changes."""
with self.monitor_lock:
Expand Down
2 changes: 1 addition & 1 deletion server_common/pv_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BlockserverPVNames:
"""Holds and manages blockserver PV names"""

BLOCKNAMES = prepend_blockserver("BLOCKNAMES")
BLOCK_DETAILS = prepend_blockserver("BLOCK_DETAILS")
WD_CONF_DETAILS = prepend_blockserver("WD_CONF_DETAILS")
BLOCK_RULES = prepend_blockserver("BLOCK_RULES")
GROUPS = prepend_blockserver("GROUPS")
GROUP_RULES = prepend_blockserver("GROUP_RULES")
Expand Down

0 comments on commit a65d8d8

Please sign in to comment.