Register a variable as FMU interface. Args: var (ScalarVariable): The variable to be registered nested (bool): Optional, does the "." in the variable name reflect an object hierarchy to access it? Default True
(self, var: ScalarVariable, nested: bool = True)
| 151 | var.start = refs[0] |
| 152 | |
| 153 | def register_variable(self, var: ScalarVariable, nested: bool = True): |
| 154 | """Register a variable as FMU interface. |
| 155 | |
| 156 | Args: |
| 157 | var (ScalarVariable): The variable to be registered |
| 158 | nested (bool): Optional, does the "." in the variable name reflect an object hierarchy to access it? Default True |
| 159 | """ |
| 160 | variable_reference = len(self.vars) |
| 161 | self.vars[variable_reference] = var |
| 162 | # Set the unique value reference |
| 163 | var.value_reference = variable_reference |
| 164 | owner = self |
| 165 | if var.getter is None and nested and "." in var.name: |
| 166 | split = var.name.split(".") |
| 167 | split.pop(-1) |
| 168 | for s in split: |
| 169 | owner = getattr(owner, s) |
| 170 | if var.getter is None: |
| 171 | var.getter = lambda: getattr(owner, var.local_name) |
| 172 | if var.setter is None and hasattr(owner, var.local_name) and var.variability != Fmi2Variability.constant: |
| 173 | var.setter = lambda v: setattr(owner, var.local_name, v) |
| 174 | |
| 175 | def setup_experiment(self, start_time: float, stop_time: Optional[float], tolerance: Optional[float]): |
| 176 | pass |