INTO-CPS-Association / pyfmu

https://into-cps-application.readthedocs.io/en/latest/submodules/pyfmu/docs/index.html
7 stars 2 forks source link

Handling of value reference uniqueness and type #9

Closed clegaard closed 4 years ago

clegaard commented 4 years ago

The FMI standard allows duplicate value references, as long as its possible to distinguish the variables somehow, possibly by type.

Currently, an exception is thrown if get_xxx is called and a variable with another type exists. Correct behavior would be to ignore it.

    def __get_integer__(self, vrs, refs):
        for i in range(len(vrs)):
            vr = vrs[i]
            var = self.vars[vr]
            if var.is_integer():
                refs[i] = getattr(self, var.name)
            else:
                raise Exception(
                    f"Variable with valueReference={vr} is not of type Integer!")
clegaard commented 4 years ago

In hindsight this is sound as Python do not allow duplicates variable names.