sci-bots / base-node-rpc

Base classes for Arduino RPC node/device
0 stars 2 forks source link

Redesign device `properties` handling #7

Open cfobel opened 7 years ago

cfobel commented 7 years ago

Current behaviour

Currently, each of the following properties MUST exist as a method on the proxy class that returns a np.array:

The properties attribute is defined as a Python property that calls each of the methods (if they exist as attributes) and combines the results into a pandas.Series.

See also #6.

Reasoning behind current behaviour

Part of the reason why the above device properties are combined into a properties attribute is that the methods are returning np.array instances which must be converted to strings using the np.array.tostring() method. This is because the only supported way to return a string at the moment is by casting it as the data attribute of a UInt8Array in the C++ firmware.

The properties attribute was introduced to make things a bit easier, while explicitly defining the subset of methods to be queried as device properties. However, this behaviour is not very intuitive and is a bit clunky.

cfobel commented 7 years ago

Proposed behaviour

As part of this new project, more information about the class members is available during code generation. This includes:

One way to handle the concept of properties given this information is to map any public C++ member that is defined as const (either attribute or method) to a read-only Python property.

Advantages