News:

  • October 13, 2025, 03:50:05 AM

Login with username, password and session length

Author Topic: Structures within UDT's  (Read 5741 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Structures within UDT's
« on: April 23, 2020, 01:29:33 PM »
How difficult is it to add functionality to place structures within UDT's? For example, incorporating a TMR into a UDT.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #1 on: April 23, 2020, 02:14:54 PM »
Definitely looking to expand that functionality in a future version.  It is not trivial.  A includes B includes C etc.

One work around is to have multiple blocks where the index matches.  Say you have a RecipeStruct
Create blocks called
Recipe 100 long Recipe Struct
RecTimer 100 long Timer Struct
RecCounter 100 long Counter Struct
RecPID 100 long PID Struct

where all the indexes match.  Recipe5 goes with RecTimer5, RecCounter5, RecPID5.  Auto-complete will help with entry since the prefix is the same on all the blocks (Rec).

It's a hack, but it can work.  If you need multi-level nesting, that's a different story altogether.

Mike@Forshock

  • Sr. Member
  • ****
  • Posts: 58
Re: Structures within UDT's
« Reply #2 on: April 30, 2020, 12:28:04 PM »
Definitely looking to expand that functionality in a future version.  It is not trivial.  A includes B includes C etc.

One work around is to have multiple blocks where the index matches.  Say you have a RecipeStruct
Create blocks called
Recipe 100 long Recipe Struct
RecTimer 100 long Timer Struct
RecCounter 100 long Counter Struct
RecPID 100 long PID Struct

where all the indexes match.  Recipe5 goes with RecTimer5, RecCounter5, RecPID5.  Auto-complete will help with entry since the prefix is the same on all the blocks (Rec).

It's a hack, but it can work.  If you need multi-level nesting, that's a different story altogether.

That is exactly how we solved it ourselves, not as "clean" but very effective.
For HEAP items it can become a bit more of an oversight problem (Create each item, match names, etc.)


RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Structures within UDT's
« Reply #3 on: December 18, 2020, 01:08:39 PM »
Has much progress been made in this area? I've got another project where structures in UDT's (not nested) would be very helpful.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #4 on: December 18, 2020, 01:21:03 PM »
Has much progress been made in this area? I've got another project where structures in UDT's (not nested) would be very helpful.
Sorry, no.

If you do something like the RecipeT Timer block, RecipeCT Counter block with your Recipe UDT block, all that is missing is the dot  ;D
Recipe42.CookTemperature
RecipeT42.Acc vs. Recipe42.T.Acc
RecipeCT42.Acc vs. Recipe42.CT.Acc

Nested structures are non-trivial.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Structures within UDT's
« Reply #5 on: December 19, 2020, 03:39:19 PM »
It's a good workaround.  Starts to break down if you need more than one time or counter per recipe, etc.  Then you have to have RecTimer1[0..99]  and RecTimer2[0..99], or start doing index math, etc.  Generally a good approach but will still be happy when we can nest em!    :)
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: Structures within UDT's
« Reply #6 on: April 06, 2022, 06:56:07 PM »
Now that the functionality is available for structures in UDTs, can I easily convert all of my helper timer data blocks to get them in my UDTs.

MaintTimerBlock -->Main.tTimerBlock

I was attempting to do this with replace, but I have to use the "exact match" option. Unfortunately, I see that this didn't convert MaintTimerBlock.done --> Main.tTimerBock.done


Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Structures within UDT's
« Reply #7 on: April 06, 2022, 08:10:11 PM »
Maybe export the code, search and replace outside & reimport.
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: Structures within UDT's
« Reply #8 on: April 07, 2022, 08:24:50 AM »
Maybe export the code, search and replace outside & reimport.

I tried that and I get a boatload of errors trying to re-import.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #9 on: April 07, 2022, 09:18:00 AM »
I was able to duplicate it.  It should be easy to fix.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Structures within UDT's
« Reply #10 on: April 07, 2022, 12:55:07 PM »
I was able to duplicate it.  It should be easy to fix.

I'm seeing "P1 Bit: ID is missing" and the like.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #11 on: April 07, 2022, 01:17:39 PM »
Now that the functionality is available for structures in UDTs, can I easily convert all of my helper timer data blocks to get them in my UDTs.

MaintTimerBlock -->Main.tTimerBlock

I was attempting to do this with replace, but I have to use the "exact match" option. Unfortunately, I see that this didn't convert MaintTimerBlock.done --> Main.tTimerBock.done

This what I can duplicate in that you are forced to check Exact Match.  Once that limitation is removed for whole nested structures, it should work.

I do not see the "P1 bit" issue you mentioned.  Please provide exact steps to duplicate that.

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Structures within UDT's
« Reply #12 on: April 07, 2022, 02:01:01 PM »
Now that the functionality is available for structures in UDTs, can I easily convert all of my helper timer data blocks to get them in my UDTs.

MaintTimerBlock -->Main.tTimerBlock

I was attempting to do this with replace, but I have to use the "exact match" option. Unfortunately, I see that this didn't convert MaintTimerBlock.done --> Main.tTimerBock.done

This what I can duplicate in that you are forced to check Exact Match.  Once that limitation is removed for whole nested structures, it should work.

I do not see the "P1 bit" issue you mentioned.  Please provide exact steps to duplicate that.

I think I messed up the copy/replace is why I'm getting the errors. I'll look it over again and let you know. It would still be easier to do this natively in DmD if possible.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Structures within UDT's
« Reply #13 on: April 07, 2022, 03:51:30 PM »
I was able to duplicate it.  It should be easy to fix.

Fixed.  Will be out in Designer 2.9.3

RBPLC

  • Hero Member
  • *****
  • Posts: 585
Re: Structures within UDT's
« Reply #14 on: July 09, 2022, 01:59:09 PM »
Now that the functionality is available for structures in UDTs, can I easily convert all of my helper timer data blocks to get them in my UDTs.

MaintTimerBlock -->Main.tTimerBlock

I was attempting to do this with replace, but I have to use the "exact match" option. Unfortunately, I see that this didn't convert MaintTimerBlock.done --> Main.tTimerBock.done

I tried this again after updating to 2.9.4 and the .done is still not replaced.