News:

  • October 13, 2025, 05:54:24 PM

Login with username, password and session length

Author Topic: Updating Program to Match Another Program  (Read 2839 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Updating Program to Match Another Program
« on: December 18, 2020, 01:26:37 PM »
What I really need for a project is an AOI. What I could use is a Program with indirect references replicated several times. Is there a way to create a "Master" program, modify the master and then copy or update the other instances to match the "Master". If done this way I could then just update my indirect reference variable in each of the programs which would be relatively simple. 

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Updating Program to Match Another Program
« Reply #1 on: December 18, 2020, 02:28:39 PM »
We've talked about separating the "code" from the PROGRAM structure heap item/memory, so that you can re-use the same code logic, but with multiple PROGRAM based structures (basically a nested PROGRAM structure inside your AOI structure, then have 10 copies/instances of the AOI structure).

All this is in the "TODO" list, but is non-trivial.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #2 on: December 18, 2020, 07:24:16 PM »
Would a subroutine work?   They do take input and output references.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Updating Program to Match Another Program
« Reply #3 on: December 19, 2020, 07:57:08 AM »
Need to be able to use timers and other multi-scan instructions.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #4 on: December 19, 2020, 02:52:10 PM »
Ah, yeah I knew that was only good for certain circumstances.   I ran into the same thing.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Updating Program to Match Another Program
« Reply #5 on: December 20, 2020, 03:28:22 PM »
If done this way I could then just update my indirect reference variable in each of the programs which would be relatively simple.

Scratch this. Indirect references mess up termination logic when used in programs.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #6 on: December 20, 2020, 04:50:15 PM »
You lost me there.  Could you expand on that, please?  Thanks.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Updating Program to Match Another Program
« Reply #7 on: December 20, 2020, 05:30:39 PM »
For example, if I have two Programs, Program1 and Program2.

Program1
Move 0 to V50
$On ----- Out Y[V50]

Program2
Move 1 to V50
$On ---- Out Y[V50]

When Program2 is enabled, Executing Exit command in Program1 will leave Y0 on instead of turning it off.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #8 on: December 20, 2020, 05:41:16 PM »
I obviously don't know what you're doing in your program, but I'd normally not reuse an index register in two separate code blocks that can run at the same time and need the index to be different.  What's the use case for that?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Updating Program to Match Another Program
« Reply #9 on: December 20, 2020, 05:49:22 PM »
It gets back to the need for an AOI. I thought I could change the index register at the top of each Program and keep the all subsequent code the same same, but this will not work correctly. Every Program will be the same code with the Index changed. It looks like I'll have to write the first Program and then do a Replace to update the Index with a static value.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #10 on: December 20, 2020, 06:00:24 PM »
OK, so the programs are multi scan, and yield, so they don't run top to bottom between executions of the other program, and you're using the indices to parameterize the "identical" programs.   I see your point.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #11 on: December 20, 2020, 06:09:23 PM »
Would it help to make all your yields explicit, and reinitialize the index on return?  IOW, don't let it yield based on time slice only on a YIELD.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Updating Program to Match Another Program
« Reply #12 on: December 20, 2020, 06:13:23 PM »
The Programs are running sections of the machine which are essentially the same mechanically but only portions of the machine are needed based on load demand. The sections are parallel operations which are coupled through the process variables but are not intrinsically linked to another section of the machine operating. Hence the need for Programs which are the same but can operate independently of one another. I would attempt subroutines if they could deal with timers.   

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Updating Program to Match Another Program
« Reply #13 on: December 20, 2020, 06:16:56 PM »
My thinking about the explicit yields is that with finite, known reentry points, you can reset the index to the right value as you reenter the program.  (Which would also requre per-copy edits, unfortunately)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.