You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two bit field properties are used for device definitions: filesystems and storage. While this works for computers, it is not very friendly for human users. One needs to know what binary means, what binary OR is, what hexadecimal numbers are, etc. This is all fine for programmers but even to us it could be more intuitive to see a more verbose value that is spelled out in human terms.
A potentially better way to handle this in JSON would be to make both of those into objects and have a boolean property in the objects for each bit.
Parsing this schema into something that is usable in C would not be difficult. The final result could still be kept in an integer. The default value should be set to zero however.
One could check for the presence of filesystems and storage. If they are numbers, then they could just be parsed as such.
If they are objects then one could iterate over all the possible keys and for those that are present in the object, and the value is true, the corresponding bit could be set in the bit field integer.
Another possibility is to use arrays for filesystems and storage where the arrays contain a set of keys. There would be a key for each possible bit. Each key would have a corresponding offset in the final bit field integer, and for each valid key that is present in the filesystems / storage array, the corresponding bit would be set.
Neither formats would compromise on the robustness of using a bit field for configuration:
Objects by definition cannot have duplicate keys therefore a bit cannot be set to true and false at the same time
The arrays could have duplicate values but those would not make any difference because the only thing that would be inferred from the presence of a key is to set a bit
The parsing logic could either silently ignore the unknown keys or potentially show a warning but there would not be a need to treat those as errors. This would have an application in testing a unreleased version of Elektroid and then going back to the stable version.
I recognize that having an object instead of a bit field would make the device definitions longer and more verbose, but in this case that would actually be a good thing because the device definitions would be more human readable than they are today.
The text was updated successfully, but these errors were encountered:
Two bit field properties are used for device definitions:
filesystems
andstorage
. While this works for computers, it is not very friendly for human users. One needs to know what binary means, what binary OR is, what hexadecimal numbers are, etc. This is all fine for programmers but even to us it could be more intuitive to see a more verbose value that is spelled out in human terms.A potentially better way to handle this in JSON would be to make both of those into objects and have a boolean property in the objects for each bit.
Before:
After:
Omitted properties could be evaluated as
false
, in which case the device definition could be simplified to this:Parsing this schema into something that is usable in C would not be difficult. The final result could still be kept in an integer. The default value should be set to zero however.
One could check for the presence of
filesystems
andstorage
. If they are numbers, then they could just be parsed as such.If they are objects then one could iterate over all the possible keys and for those that are present in the object, and the value is
true
, the corresponding bit could be set in the bit field integer.Another possibility is to use arrays for
filesystems
andstorage
where the arrays contain a set of keys. There would be a key for each possible bit. Each key would have a corresponding offset in the final bit field integer, and for each valid key that is present in thefilesystems
/storage
array, the corresponding bit would be set.Example:
Neither formats would compromise on the robustness of using a bit field for configuration:
true
andfalse
at the same timeThe parsing logic could either silently ignore the unknown keys or potentially show a warning but there would not be a need to treat those as errors. This would have an application in testing a unreleased version of Elektroid and then going back to the stable version.
I recognize that having an object instead of a bit field would make the device definitions longer and more verbose, but in this case that would actually be a good thing because the device definitions would be more human readable than they are today.
The text was updated successfully, but these errors were encountered: