Skip to content

Commit

Permalink
Added battery launch arguments to support launching the valence bms node
Browse files Browse the repository at this point in the history
  • Loading branch information
hilary-luo committed Jan 19, 2024
1 parent e14423f commit 726aef1
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions clearpath_config/platform/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class BatteryConfig(BaseConfig):

# Configurations
CONFIGURATION = "configuration"
LAUNCH_ARGS = 'launch_args'
S1P1 = "S1P1"
S1P2 = "S1P2"
S1P3 = "S1P3"
Expand Down Expand Up @@ -101,22 +102,25 @@ class BatteryConfig(BaseConfig):
TEMPLATE = {
BATTERY: {
MODEL: MODEL,
CONFIGURATION: CONFIGURATION
CONFIGURATION: CONFIGURATION,
LAUNCH_ARGS: LAUNCH_ARGS
}
}

KEYS = flip_dict(TEMPLATE)

DEFAULTS = {
MODEL: UNKNOWN,
CONFIGURATION: UNKNOWN
CONFIGURATION: UNKNOWN,
LAUNCH_ARGS: {}
}

def __init__(
self,
config: dict = {},
model: str = DEFAULTS[MODEL],
configuration: str = DEFAULTS[CONFIGURATION],
launch_args: dict = DEFAULTS[LAUNCH_ARGS]
) -> None:
# Initialization
self._config = {}
Expand All @@ -130,10 +134,16 @@ def __init__(
self.configuration = self.DEFAULTS[self.CONFIGURATION]
else:
self.configuration = configuration
if launch_args == self.DEFAULTS[self.LAUNCH_ARGS] or not launch_args:
self.launch_args = self.DEFAULTS[self.LAUNCH_ARGS]
else:
self.launch_args = launch_args

# Setter Template
setters = {
self.KEYS[self.MODEL]: BatteryConfig.model,
self.KEYS[self.CONFIGURATION]: BatteryConfig.configuration,
self.KEYS[self.LAUNCH_ARGS]: BatteryConfig.launch_args,
}
super().__init__(setters, config, self.BATTERY)

Expand Down Expand Up @@ -197,3 +207,19 @@ def configuration(self, value: str) -> None:
platform, self.model, list(self.VALID[platform][self.model]))
))
self._configuration = value

@property
def launch_args(self) -> dict:
self.set_config_param(
key=self.KEYS[self.LAUNCH_ARGS],
value=self._launch_args
)
return self._launch_args

@launch_args.setter
def launch_args(self, value: dict) -> None:
assert isinstance(value, dict), ((
"Battery Launch args %s are invalid. " % value +
"They must be in the format of a dictionary."
))
self._launch_args = value

0 comments on commit 726aef1

Please sign in to comment.