Closed fabianvo closed 1 month ago
I'm curious to learn the use case for this.
It is somewhat exotic, but could be used for systems with redundancy. For example 2 or more submerged pumps, but only one may be active at any given time. You can then use XOR to at least be notified of multiple devices running concurrently, if there is no automatic fallback on failures.
Or a mechanism to have automatic and manual heating/cooling and only allowing one input method, but not both at the same time.
In general, XOR is a basic logic operation and currently not available. For my use case, the "1 of n" variant is sufficient, but there are 2 ways of implementing it. The other would be to have the result be true, if an odd number of inputs is true.
Albrecht JUNG strongly supports this
Can you show a concrete example (items, rules, or sitemap/ UI) of how exactly you're going to use it?
Even if you were to have an "XOR" group function, it seems that you'd still need a rule to process it anyway? Implementing this functionality in a rule is trivial.
e.g. in JRuby
# For 1-of-n
changed(MyGroup.members) { |event| event.group.update(event.group.members.count(&:on?) == 1) }
# For odd
changed(MyGroup.members) { |event| event.group.update(event.group.members.count(&:on?).odd?) }
given the items:
Group:Switch MyGroup
If it were to be added as a group function, both variants would need to be supported
XOR(ON,OFF)
for "1 of n" variant (probably more useful than the other variant?) vs ODD(ON,OFF)
?
Then eventually someone would say they need XNOR.
It would be nice to be able to XOR (not just AND, OR, NAND, NOR) states.