solettaproject / soletta

Soletta Project is a framework for making IoT devices. With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.
http://solettaproject.org
Apache License 2.0
227 stars 109 forks source link

fbp: easier constants #1565

Open barbieri opened 8 years ago

barbieri commented 8 years ago

We could translate constants to node-types with option "value" being the actual contents. The node-type to be used depends on the connecting port. Examples:

'abc' -> IN _(console) # defaults to string if input port is any
'true' -> IN _(gpio/writer)

Would be automatically converted to:

_(constant/string:value="abc") OUT -> IN _(console)
_(constant/boolean:value="true") OUT -> IN _(gpio/writer)

@glima you did a previous attempt at initial packets before, would you see a problem with this approach? it just come to me recently and would not require changes to the core, no new methods or "from string" as we tried before -- it was my personal issue with that. With this we'd need to change the parser to do some conversion and deeper look at the structure to do the replacement with the actual node.

@cmarcelo ^

otaviobp commented 8 years ago

That would be really a good improvement.

cmarcelo commented 8 years ago

'abc' -> IN (console) # defaults to string if input port is any 'true' -> IN (gpio/writer)

I think we never disagreed on this idea at FBP level. So looks good to me.

With this we'd need to change the parser to do some conversion

Change code in sol-flow-parser.c and above it. I would still represent these as separate entities at the syntax level (the code in files named fbp).

no new methods or "from string" as we tried before

The node will do a conversion, so "from string" is there, just the way to reach it is different. Will this feature be available for non-builtin packets? If so, how to select which node to create for each packet type?

One idea would be to have some sort of naming convention: given a packet type xyz, if a certain named node type exists (and that had appropriate characteristics), it would be used. Another option is starting without supporting this for custom packet types.

barbieri commented 8 years ago

I'd not do that for non-builtin, looks like a good compromise. Buit-in would have to be more explicit, unless we find a way to extend the concept.