Hello Chris, On Tue, 2022-02-15 at 12:20 +0000, Christofer Dutz wrote: > Hi all, > > I'm currently working on Plc4C. Here I need to save the datatype > along with the plcvalue as there is no such thing as a "instanceof" > in C. > While initially this was fixed to a pre-defined list of built-in > types, I'm currently making this more dynamic. > > This got me thinking: Wouldn't this generally make sense in other > languages too? > > For example, in KNX there are multiple datatypes which result in the > same type of PLCValue. However, one is a Power-Consumption in Watt, > another is a Temperature in °C. > When parsing this generally isn't an issue, however when serializing > the representation might vary (One might be that crazy KNX 16-bit > float, another might be a real IEC Float). > So we need to keep the datatype in parallel with the PLcValue. > Single precision floating point is one thing this could help with I guess, but it would really be beneficial when you are thinking about the complex data-types most of the large-ish PLC's & PAC's have, like the axis data-type for instance. This makes working with things like Rockwells Logix family of processors easier I would think. And also very likely Siemens family of Sinumerik S7 PLC/PAC.
> I think having it IN the plcvalue would be better. > > What do you think? > > If it makes sense then yes. Are there caveats to this? > Chris Stephen
