Could you not change it to a subprograms call instead of using a program line? Something like:
Before:
# do_something_previous
if digital_input[0] == On:
# do_something_previous
if digital_input[1] == On:
# do_something_next
After:
def subProgram_1:
# do_something_previous
end
def_subProgram_2:
# do_something_next
end
# main
RobotProgram:
if digital_input[0]:
subProgram_1
end
if digital_input[1]:
subProgram_2
end
If you place all the logic for each “action” as a subprogram like @cags suggests, I don’t fully see why combinations matter. That’s the benefit of having single purpose functions, is that you can call them whenever, and trust the result of their actions.
There’s a few other simple, key design decisions you’ll have to make. Do you want the inputs to be able to interrupt each other? Do you want to latch the inputs and service their functions only after the previous action has finished? Should it always be sequential, such that if action 1 is called, action 2 and 3 execute in order?
Not knowing your specific use case, I’ll just give you an example of latching the action request, and sequentially advancing through them:
There’s some obvious problems/differences with this example. Notably, I am using digital outputs as my flag instead of inputs. This is just so I can manually trigger them on my simulator for testing. I also am not debouncing the trigger signal, so the program will constantly loop with whatever output you turn on.
Regardless of implementation, you will likely need a Thread to monitor the inputs and assign flagging variables appropriately, and subprograms to contain all the necessary logic that should happen. In this way, your entire program could simply be any combination of action_X() calls. Just remember the function will always return back to where it was called initially.