Page 2 of 2

Posted: Tue May 17, 2016 4:04 pm
by The Robman
How versatile is IRP in documenting protocols that basically have IF statements in them? In other words, if a protocol sends one type of signal for OBCs in the range 0-127 and another for OBCs in the range 128-255, does IRP support that?

Obviously, many of our executors do that sort of thing, but many of them are "combo" executors which means that, if you were to learn the signals, they would report different protocols and/or device codes.

Posted: Wed May 18, 2016 12:53 am
by Barf
You are right. Probably some extension of IRP is needed for this. But this can be done. For example, I wrote this back in 2011.

A possible syntax might be something like this, for a three protocol combo, basically using the syntax of the ternary ?: operator as in C and derived languages, like Java:

Code: Select all

mode == 0 ? ( /* IRP of first version */ )  \
: mode == 1 ?  (/* IRP of second version */  \
: (/* IRP of third version */)

Posted: Wed May 18, 2016 11:48 am
by mathdon
As I have mentioned elsewhere, I have developed a program that converts MAXQ executor code into IRP notation. This brought to light two requirements that standard IRP notation does not handle. One is the If .. Then .. Else construction that Rob has raised, the other is the use of arrays, where one or two bits of a variable byte form an index into the array formed by the fixed bytes. I handled these in an informal way that is intended to be reasonably self-explanatory to a human reader. Here, as a simple example, is the output for the Sony Combo protocol:

Code: Select all

Sony Combo (12/15/20): PID=0027.new

4 fixed bytes: bit-reversed A B C D
2 variable bytes: bit-reversed X Y

If X:1:7=0

Preamble:
N1=A[Y:-2:5]

{40.0k,600}<1,-1|2,-1>(4,-1,X:7,Y:5,^45000u)3+  // when Y=0xxxxxxx

{40.0k,600}<1,-1|2,-1>(4,-1,X:7,Y:5,N1:8,^45000u)3+  // when Y=1xxxxxxx

If X:1:7=1

{40.0k,600}<1,-1|2,-1>(4,-1,X:7,Y:8,^45000u)3+
The preamble is a pre-processor that in the general case may itself contain conditional statements. This gives three levels of conditionals, an outer one before any required preamble, conditionals within any preambles, and finally an inner one after the preamble. There may be executors that even this structure does not cover, as my program handles most, but not all, known MAXQ executors.

I would be interested in seeing an extension of IRP notation that could cover these requirements in a way that is machine-processable while retaining reasonable readability for human readers. Over to you, Barf?

Posted: Thu May 19, 2016 1:38 pm
by Barf
I am not quite sure what your array notation means, but, with a few guesses, some not introduced notation, and a few assumptions swept under the table, how about this (line breaks introduced for readability):

Code: Select all

{40.0k,600}<1,-1|2,-1>(                                         
                       X:1:7 ?          (4,-1,X:7,Y:8,^45000u)    
                             : (y:1:7 ? (4,-1,X:7,Y:5,N1:8,^45000u) 
                                      : (4,-1,X:7,Y:5,^45000u)      
                               )                                   
		                         )3+                                       
{A=fixed:-8:24, B=fixed:-8:16, C=fixed:-8:8, D=fixed:-8,            
X=variable:-8:8, Y=variable:-8,                                     
N1 =  Y:-2:5==0 ? A                                                 
    : Y:-2:5==1 ? B                                                 
    : Y:-2:5==2 ? C                                                 
    : Y:-2:5==3 ? D }
Basically, it is a matter of allowing the conditional operator af a few places.