Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

How to execute a specific instruction in a program

#1
What command or method could be used to execute (in simulation) a single specific instruction in a program? Similar to what happens when double clicking an instruction in the GUI tree, or right click>execute instruction.

I'm looking for something like "prog.InstructionExecute(ins_id)", to execute existing instruction number "ins_id" of program "prog".

I found commands InstructionSelect, InstructionDelete, Instruction, setInstruction, RunInstruction, but can't seem to find a command to execute an appointed instruction.

Kind regards,

Maarten
#2
You can run one instruction like this:
Code:
program.setParam("StartOne", ins_id)
This has the same effect as double clicking on that instruction. Only that instruction is executed.

Alternatively, you can start from that instruction and keep moving the program pointer by using the Start parameter:
Code:
program.setParam("Start", ins_id)
#3
Thanks Albert, that's what I was looking for!

Maarten
#4
Albert,

I would like to run this instruction:
Code:
program.setParam("Start", ins_id)

and then be able to programmatically stop/pause the simulation once a specific instruction id has been reached.

Is there a way to do this?

I tried running,
Code:
program.setParam("StartOne", ins_id)

for each desired instruction id, but that didn't work very well when I was making a "start thread" call during parallel calls. Do you have any ideas for a solution?

Thank you,
Samuel
#5
One way to know what program instruction you are running is to have a loop where you are constantly checking for the instruction being run. For example:
Code:
while True:
    if int(prog.setParam("CurrentInstruction")) == stop_instruction:
        break
You can then stop the program when you reach that instruction.

On the other hand, you could miss events using the Python API. So if you want to have better accuracy you should implement your solution using the plugin interface and check for new events and stop immediately after you get a specific event callback.
#6
(06-19-2024, 11:05 AM)Albert Wrote: One way to know what program instruction you are running is to have a loop where you are constantly checking for the instruction being run. For example:
Code:
while True:
    if int(prog.setParam("CurrentInstruction")) == stop_instruction:
        break
You can then stop the program when you reach that instruction.

On the other hand, you could miss events using the Python API. So if you want to have better accuracy you should implement your solution using the plugin interface and check for new events and stop immediately after you get a specific event callback.

Great! Thanks for your response!
  




Users browsing this thread:
1 Guest(s)