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
It seems Element state conversion functions for 4ms elements are never called. That is, the convertState() overloads in 4ms_element_state_conversions.hh are not called. The reason is that SmartCoreProcessor getState() creates a reference to the variant-alternative type, and calls convertState() using that type. So, given a Toggle3posHoriz type, it will call convertState(FlipSwitch&), and ignores the overload for convertState(Toggle3posHoriz&). This can be verified by having the overload return bogus values and noticing nothing changes in the modules.
Second, this is tied into the issue that the 4ms_element_state_conversions.hh header needs to be included before the SmartCoreProcessor.hh header. Doing this is easy to forget or overlook.
In the PI PR #267 I moved the FlipSwitch overload to the general state conversion header, so at least the second point above is not an issue for now, but we still are just getting lucky that the generic FlipSwitch conversion values matches the underlying enum values.
This whole issue would go away if we insisted that any State_t enum's values were all calculated in the same way as their parent Element-variant type. In that case we wouldn't need brand-specific conversion functions. But we'd lose the safety and flexibility of enum classes.
Another solution would be to have SmartCoreProcessor call the right convertState() function. I played with this a bit, but didn't find any simple answer.
The text was updated successfully, but these errors were encountered:
It seems Element state conversion functions for 4ms elements are never called. That is, the
convertState()
overloads in4ms_element_state_conversions.hh
are not called. The reason is that SmartCoreProcessorgetState()
creates a reference to the variant-alternative type, and callsconvertState()
using that type. So, given aToggle3posHoriz
type, it will callconvertState(FlipSwitch&)
, and ignores the overload forconvertState(Toggle3posHoriz&)
. This can be verified by having the overload return bogus values and noticing nothing changes in the modules.Second, this is tied into the issue that the
4ms_element_state_conversions.hh
header needs to be included before theSmartCoreProcessor.hh
header. Doing this is easy to forget or overlook.In the PI PR #267 I moved the FlipSwitch overload to the general state conversion header, so at least the second point above is not an issue for now, but we still are just getting lucky that the generic FlipSwitch conversion values matches the underlying enum values.
This whole issue would go away if we insisted that any State_t enum's values were all calculated in the same way as their parent Element-variant type. In that case we wouldn't need brand-specific conversion functions. But we'd lose the safety and flexibility of enum classes.
Another solution would be to have SmartCoreProcessor call the right convertState() function. I played with this a bit, but didn't find any simple answer.
The text was updated successfully, but these errors were encountered: