Posted: Sun Sep 01, 2019 11:31 am
What problem am I addressing? Constructing a set of values for the device parameters of an executor (in protocols.ini) from a set of learned signal decodes (from IrpTransmogrifier) of one or more protocols that are all supported by that executor. In my Sony 12/15 example the relevant lines in its protocols.ini entry are:
DevParms=Device 1=0,Force Sony15:bool,Device 2=[0],Force Sony15:bool
CmdParms=Device:0|1,OBC=0
Consider the decodes
Sony15 D=26 F=88, Sony12 D=1 F=67, Sony12 D=1 F=72
which are the first three in the test set I was using. Initially the user values of the DevParms and CmdParms are all null. The first two decodes can each be generated by setting the first two parameters, giving (26,1,null,null) and (12,0,null,null) but these are inconsistent, so the second needs to go into the second parameter pair, giving (26,1,12,0). The third decode is consistent with this. The command parameters for the three signals are (0,88), (1,67), (1,72).
The additional assignment X=D<32 (thank you for the simplification, also I mistyped it in my earlier message) needs a name, X, as it is referenced in the executor parameters. The executor parameters do not need names, just values, so they are expressions rather than assignments. Indeed, using the parameter names from protocols.ini would just make things more difficult, as the RMIR code references the parameters by their position in the DevParms and CmdParms lists, not by their name. I accept that I could achieve this without by notation extensions, but I find:
[D?0,X?0,D?1,X?1;??,F]
simpler to write and more readable than
[N=0?D: (-1),N=0?X: (-1),N=1? D: (-1),N=1?X: (-1);N,F]
which would have the same effect for N=0,1 as a negative value could be treated as equivalent to null. But also I would have to add an assignment to N into the list of assignments passed to the evaluator and I see no way of knowing what values of N are valid (without preprocessing the expression list
).
Finally, thank you for your comments on CDATA, < etc. These are very helpful as I have very little familiarity with XML and your own extensions of the IRP notation such as the conditional expression.
DevParms=Device 1=0,Force Sony15:bool,Device 2=[0],Force Sony15:bool
CmdParms=Device:0|1,OBC=0
Consider the decodes
Sony15 D=26 F=88, Sony12 D=1 F=67, Sony12 D=1 F=72
which are the first three in the test set I was using. Initially the user values of the DevParms and CmdParms are all null. The first two decodes can each be generated by setting the first two parameters, giving (26,1,null,null) and (12,0,null,null) but these are inconsistent, so the second needs to go into the second parameter pair, giving (26,1,12,0). The third decode is consistent with this. The command parameters for the three signals are (0,88), (1,67), (1,72).
The additional assignment X=D<32 (thank you for the simplification, also I mistyped it in my earlier message) needs a name, X, as it is referenced in the executor parameters. The executor parameters do not need names, just values, so they are expressions rather than assignments. Indeed, using the parameter names from protocols.ini would just make things more difficult, as the RMIR code references the parameters by their position in the DevParms and CmdParms lists, not by their name. I accept that I could achieve this without by notation extensions, but I find:
[D?0,X?0,D?1,X?1;??,F]
simpler to write and more readable than
[N=0?D: (-1),N=0?X: (-1),N=1? D: (-1),N=1?X: (-1);N,F]
which would have the same effect for N=0,1 as a negative value could be treated as equivalent to null. But also I would have to add an assignment to N into the list of assignments passed to the evaluator and I see no way of knowing what values of N are valid (without preprocessing the expression list
Yes, I intend to let the user choose the executor if there is more than one that is compatible with the selected learned signals and the remote in question.There can be more than one element <irp:parameter name="uei-executor">: it is up to subsequent processing to select one candidate.
Why? I have implemented it and tested it robustly and it does exactly what I want. I would accept that it might not be the best solution, but I have no idea why it should be considered not a sensible one. I appreciate you offering an alternative, but at present I still prefer mine.I really doubt that a preprocessor is a sensible solution.
Finally, thank you for your comments on CDATA, < etc. These are very helpful as I have very little familiarity with XML and your own extensions of the IRP notation such as the conditional expression.