News:

  • October 13, 2025, 07:24:02 AM

Login with username, password and session length

Author Topic: Feedback wanted: Instantiable programs concept  (Read 34927 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Feedback wanted: Instantiable programs concept
« Reply #45 on: April 22, 2022, 05:12:56 PM »
Quote
Example MATH Function Usage that calculates the diagonal in feet of 2 sides that are in inches using the Pythagorean Function code block
MATH R0 "12.0 * Pythagorean(V0, V1)"

Does this imply that we would also be able to create our own Functions? In this case Pythagorean?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Feedback wanted: Instantiable programs concept
« Reply #46 on: April 22, 2022, 05:25:38 PM »
Quote
Example MATH Function Usage that calculates the diagonal in feet of 2 sides that are in inches using the Pythagorean Function code block
MATH R0 "12.0 * Pythagorean(V0, V1)"

Does this imply that we would also be able to create our own Functions? In this case Pythagorean?

Yes, this is ALL about USER CREATED MATH Functions, User Boxes, and Objects.  I just used Pythagorean as an example, along with the CART2POLAR and KETTLE object.

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Re: Feedback wanted: Instantiable programs concept
« Reply #47 on: April 25, 2022, 08:05:55 AM »
Just for clarification...
The Math Function and User Box execute the logic and return a result AT THE POINT the instruction is evaluated...right?
The Objects example, however, is only enabling a program block and the code is not evaluated and executed until the scan reaches the this code block.  So, placement of this code block within the Execution Order can determine whether the block is evaluated on the current scan or subsequent scan...correct?
I'm just trying to make sure I have an understanding of your intentions with each example.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Feedback wanted: Instantiable programs concept
« Reply #48 on: April 25, 2022, 09:13:54 AM »
Just for clarification...
The Math Function and User Box execute the logic and return a result AT THE POINT the instruction is evaluated...right?
The Objects example, however, is only enabling a program block and the code is not evaluated and executed until the scan reaches the this code block.  So, placement of this code block within the Execution Order can determine whether the block is evaluated on the current scan or subsequent scan...correct?
I'm just trying to make sure I have an understanding of your intentions with each example.

You got it!

The location of the object code block above or below the corresponding RUN instruction containing code block(s) should not matter 99.9% of the time, although it could, so yes, you can definitely organize the execution order of objects on an INSTANCE by INSTANCE basis.  For example, if you have 10 instances of a specific object type, 5 could be above $Main, 5 could be below $Main in execution order (you decide), even though there is only 1 copy of the logic (that code will utilize indirect reference type parameters for each object parameter).  That's the plan.

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Re: Feedback wanted: Instantiable programs concept
« Reply #49 on: April 25, 2022, 11:41:19 AM »
You got it!

The location of the object code block above or below the corresponding RUN instruction containing code block(s) should not matter 99.9% of the time, although it could, so yes, you can definitely organize the execution order of objects on an INSTANCE by INSTANCE basis.  For example, if you have 10 instances of a specific object type, 5 could be above $Main, 5 could be below $Main in execution order (you decide), even though there is only 1 copy of the logic (that code will utilize indirect reference type parameters for each object parameter).  That's the plan.

Thank you for the clarification, Franji.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Feedback wanted: Instantiable programs concept
« Reply #50 on: April 25, 2022, 01:33:25 PM »
Side Question
Any plans to allow passing of entire UDT's  in the USER BOX parameters?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Feedback wanted: Instantiable programs concept
« Reply #51 on: April 25, 2022, 01:36:50 PM »
Side Question
Any plans to allow passing of entire UDT's  in the USER BOX parameters?
That should work.  All structures (including UDTs) would be passed as a reference.

The one thing we probably could NOT support is a data-block/array, but there may be some alternatives in the future to allow for processing of large blocks of data.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Feedback wanted: Instantiable programs concept
« Reply #52 on: April 25, 2022, 01:54:07 PM »
What about a simple array or strings?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Feedback wanted: Instantiable programs concept
« Reply #53 on: April 25, 2022, 02:12:30 PM »
What about a simple array?

Currently, no.
For example, say you wanted to take an average of a block of simple numeric types called MyAvg, currently there are no plans to do
MyAvg D
MyAvg V
MyAvg N
MyAvg D1000 D1999

HOWEVER, we will be providing a DIFFERENT MECHANISM (using the concept of Tables), which can provide capabilities you are probably wanting.


Quote
or strings?
A single string?  Yes.  An array (i.e. block) of strings?  No.  However, regarding TABLEs, we probably need to incorporate Tables of UDTs or Strings or other structures.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Feedback wanted: Instantiable programs concept
« Reply #54 on: April 25, 2022, 03:22:47 PM »
Private memory inside the functions and objects would be nice to have (as well as a hierarchy of memory visibility throughout the project), but that's a minor point, comparatively.   Some future version could implement that.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

PLCwannabe

  • Hero Member
  • *****
  • Posts: 197
Re: Feedback wanted: Instantiable programs concept
« Reply #55 on: April 25, 2022, 04:12:03 PM »
Could one of you experts post a bare-bones programming example of what this thread is about?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Feedback wanted: Instantiable programs concept
« Reply #56 on: April 25, 2022, 04:21:10 PM »
Could one of you experts post a bare-bones programming example of what this thread is about?

Is this what you are seeking:
https://forum.hosteng.com/index.php?topic=3401.msg27501#msg27501

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Feedback wanted: Instantiable programs concept
« Reply #57 on: April 26, 2022, 11:29:09 AM »

For example, say you wanted to take an average of a block of simple numeric types called MyAvg, currently there are no plans to do
MyAvg D
MyAvg V
MyAvg N
MyAvg D1000 D1999

HOWEVER, we will be providing a DIFFERENT MECHANISM (using the concept of Tables), which can provide capabilities you are probably wanting.



I have used the BRX for a co-processor to receive data from a serial or EIP device and crunch a bunch of numbers on different data sets.  It seems that I had to either duplicate code to be work on each specific data set or copy large chunks of data from a memory area, but that takes time . If I had a mechanism to just specify that here is the UDT of data, use that. I hope tables could help that situation. 
« Last Edit: April 26, 2022, 12:06:09 PM by ATU »

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Feedback wanted: Instantiable programs concept
« Reply #58 on: April 26, 2022, 12:18:37 PM »
I have used the BRX for a co-processor to receive data from a serial EIP device and crunch a bunch of numbers on different data sets.  It seems that I had to either duplicate code to be work on each specific data sets or copy large chunks of data from a memory area, but that takes time . If I had a mechanism to just specify that here is the UDT of data, use that. I hope tables could help that situation.

Currently, could the REF MATH function work with that?
REF(V0, V1)
So if you had 3 user blocks at #32, #33, and #34, then you could set the block # (V0) to 32 (then 33 then  34) before each call of your code?  (I would guess that V1 is just a FOR loop in your crunching?).

If you need to massage the data, the REFWRITE BOX (not MATH function) is the WRITE version of REF.  It takes 3 parameters, the new value, the block#, and the ID#.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Feedback wanted: Instantiable programs concept
« Reply #59 on: April 27, 2022, 08:11:52 AM »
Quote
Example MATH Function Usage that calculates the diagonal in feet of 2 sides that are in inches using the Pythagorean Function code block
MATH R0 "12.0 * Pythagorean(V0, V1)"

Does this imply that we would also be able to create our own Functions? In this case Pythagorean?

Yes, this is ALL about USER CREATED MATH Functions, User Boxes, and Objects.  I just used Pythagorean as an example, along with the CART2POLAR and KETTLE object.

Is Pythagorean defined within a normal MATH instruction or would it be defined in its own type of function Code-Block?