Shop OBEX P1 Docs P2 Docs Learn Events
Call a parent object's functions from a child? — Parallax Forums

Call a parent object's functions from a child?

photomankcphotomankc Posts: 943
edited 2009-08-11 14:01 in Propeller 1
I have not been able to find out how to do this, if you can. I have an object MainProg and spawns a child in a new cog named UserInterface. While UserInterface is running I need it to call a method from MainProg. I can't seem to find a way to do that.

if I add the declaration:

OBJ
  parent: "MainProg"
.
.
.
.
PRI SomeFunc
  parent.GetValue(valueAdr)





I get an error saying that I have an illegal circular reference. I can't find any other keyword that would seem to fit this and I'm stumped. If I missed it in the manual I'm sorry but I am not seeing it. Would seem kind of odd though if you can only communicate downstream.

Post Edited (photomankc) : 8/11/2009 5:37:37 AM GMT

Comments

  • mparkmpark Posts: 1,305
    edited 2009-08-11 06:50
    Not possible in Spin.
  • heaterheater Posts: 3,370
    edited 2009-08-11 07:08
    So why not do this the other way around?

    Have the user interface run first as your "main" program.
    Have it start your worker object.
    It can then call methods of the worker to get/set stuff as required by user input.

    Basically the model used by most (all) drivers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • photomankcphotomankc Posts: 943
    edited 2009-08-11 13:40
    Yeah, more and more I wish I had started that way. It started out all on one cog, as just a way to monitor a voltage then it grew into a complete replacement for my PBASIC Battery Monitor system, and then I began splitting it up into cogs. I guess I can rearrange it to let the UI startup first and then have it spawn the analog monitor cog off of that. A few items will make that a little painful. I just hate to rip it all up after getting everything else working so well. Oh well, half the fun is tearing it up and trying something new I guess. lol.gif

    I want to allow the user to switch to 'disposable' mode and set the cut-off voltage lower for the monitor loop but to do that it needs to communicate back and forth about what the current setting is and let it know to alter it with the new setting. The UI needs to know what the new setting is so it can display the proper notification to the user.

    Post Edited (photomankc) : 8/11/2009 1:52:12 PM GMT
  • Agent420Agent420 Posts: 439
    edited 2009-08-11 13:52
    As an old fart with a conventional 8 bit ideology stuck in my firmware [noparse]:)[/noparse] , I too have fallen prey to some of the complexities of multiple cog design.· Although many aspects of the Propeller are advertised as easy-to-use, there are design considerations with parallel processing that bear additional thought before implementing them, and in my limited Prop experience they are not always as easy to modify as simply reordering the sequence in which they are called.
  • cessnapilotcessnapilot Posts: 182
    edited 2009-08-11 14:01
    Transfer the parameters via the DAT section.
Sign In or Register to comment.