Repository navigation
Multi input AND/OR; - #4720
Multi input AND/OR; #4720
Conversation
…olled unconnected pin value that helps during machine conversation and an easier to read name.
| option default_personality 8; | ||
| option default_count 1; | ||
|
|
||
| license "ASLv2"; |
There was a problem hiding this comment.
What type of license is that?
It would probably fail for RTAI because anything not GPL will taint the kernel.
Besides, if you need this specific license, then it must also be added to debian/copyright, which needs consensus to ensure compatibility.
There was a problem hiding this comment.
changed to GPL; Was the Apache Software License v2
| @@ -0,0 +1,36 @@ | |||
| component and "Multi input AND gate"; | |||
| pin in bool in##[128:personality] = 1 "input pins, up to personality-1"; | |||
There was a problem hiding this comment.
Is 128 not excessive?
Can you give an example where you'd need more than 40..50 inputs AND'ed together?
There was a problem hiding this comment.
So the case I have here/that started here was steps control in a 2D conveyer belt/palletrizer is 4x5 position = 20 pallets x (8 mount sensors) + 5 normal interlocks. So I rounded up to the next multiple of 2. Happy to make that 64.
There was a problem hiding this comment.
The other case is a pneumatic sorter where I have two sets(in/out) of blockage/low-pressure/high pressure detects in each of the 41 (don't ask -- I suspect the designer mixed inches v.s metric) linear stations. Though in this case you could roll up each of the 2x3 sets into a 41 OR and then combine each pair with a normal OR into the 3 outputs needed for the pump/tank.
There was a problem hiding this comment.
Convinced. I guess it would probably be better to use 255 instead of 128. That would give pins in-00 through in-99 and then three digits up til in-254.
The reason for not having this at 256 is that logic uses the last byte (does personality & 0xff). That effectively creates pins 0..254 on the outset in logic.
| @@ -0,0 +1,33 @@ | |||
| component or "Arbitrary input OR gate"; | |||
| pin in bool in##[128:personality] = 0 "in"; | |||
There was a problem hiding this comment.
The doc string "in" is a bit thin, isn't it?
There was a problem hiding this comment.
Grin :) took it from one of the other modules - elaborated :)
There was a problem hiding this comment.
Ok - was not able to remove it - as a "" or none will give corrupted output / seems to concatenate the in and out. So have instead made it a more elaborate string.
| @@ -0,0 +1,33 @@ | |||
| component or "Arbitrary input OR gate"; | |||
There was a problem hiding this comment.
The AND gate you use the term "Multi". Why is this "Arbitrary"? What is arbitrary about these inputs?
Why not retain the comp doc string I wrote?
| @@ -0,0 +1,36 @@ | |||
| component and "Multi input AND gate"; | |||
There was a problem hiding this comment.
The component naming and and or may prove confusing with and2 and or2. That is why I called them and_n and or_n. The underscore is converted into a dash for the hal internals, but if you don't like that, then you can use names=.
So, any particular reason to the naming?
There was a problem hiding this comment.
None particularly; but _n seeded a bit extra. Changed to _n.
| function _ "Logical AND"; | ||
|
|
||
| see_also """ | ||
| *or*(9), |
There was a problem hiding this comment.
Please don't use emphasis. The post-processor cannot handle it and links will no longer be provided in the html version.
There was a problem hiding this comment.
Grin :) took it from one of the other modules; now removed.
|
|
||
| option period no; | ||
| option default_personality 8; | ||
| option default_count 1; |
There was a problem hiding this comment.
The default count is implicitly one. Why set it?
There was a problem hiding this comment.
Grin :) took it from one of the other modules - removed :)
| is TRUE. | ||
| """; | ||
|
|
||
| function _ "Logical AND"; |
There was a problem hiding this comment.
Here you add a doc string. But in the or you don't. Not consistent. You may also want to elaborate... I think it is rather obvious that it calculates the logical AND. But what makes this so special, that is why you document it.
There was a problem hiding this comment.
ok - will fix by removing this for the AND
|
If the main improvement over "logic" is that this one allows for a default value for unconnected inputs, would it make more sense to modify "logic" to support this? |
|
That was exaxtly my first approach - the problem is that this gets quite complex/weird for things like an xor/xand and so on; you almost have to introduce third HiZ style state (which makes things slow as you need to do it every loop - as halcmd can chance something). And given how trivial and AND and OR are; and how common these are (lots of stations on a line all needing to request hydraulics or air and this OR-ed together for the main pump; or lots of interlocks getting combined) -- this was easy/natural and also makes the hal files easy to read/understand. Obviously the other approach would be to generate more of the HAL files with some m4 or similar macro language; and make the numbering/creation much more automatic/generated. But that makes the CE/machine directive and other paperwork a lot more complex. So hence this strawman. |
|
would these replace and2 and or2? |
I don't think so, these seems to be useful for when you have to group together alarm signals or similar into one single output, but and2/or2 are much more versatile than that. |
|
@andypugh Why was this merged? I had a lot of comments that were replied upon but never changed in the code. |
I mis-read and thought that the issues had been addressed. |
|
It does not appear to be possible to re-open the PR, which is going to complicate matters. |
|
@dirkx are you able to work on the review pointers, and send in a new PR? |
Yeah, that is a bummer... @dirkx you should re-submit the PR with the suggested changes, which you also acknowledged. Then it will run through review once again. |
|
Ack. Done as #4746. |
Multi input AND/OR; much along the lines of logic(9) but with a controlled unconnected pin value that helps during machine conversation (as you can simply comment out some feed) and an easier to read name.
Should implement all @BsAtHome and others their suggestions in issue #4711 and #4721. Manual pages converted to adoc.