Home AMX User Forum NetLinx Studio

do_online_event()

Is there a way to trigger the online event handler through code, similar to do_push or do_custom_event? I know I can do a function, and just have my online event call the function, but I'm just curious.

Comments

  • ericmedleyericmedley Posts: 4,177
    mstocum wrote: »
    Is there a way to trigger the online event handler through code, similar to do_push or do_custom_event? I know I can do a function, and just have my online event call the function, but I'm just curious.

    Hmmm... this may be a case where there's a better way to do whatever you have in mind to do. why would you want to fake an online event??? And, if whatever it is you want to make happen via a fake online_event is going to a function, why not just call the function?

    What were you planning on doing code-wise to start the fake online event? whereever that was just call the function and avoid the middle man.

    Post some code with your idea and we'll see if we can help.
    e
  • mstocummstocum Posts: 120
    ericmedley wrote: »
    Hmmm... this may be a case where there's a better way to do whatever you have in mind to do. why would you want to fake an online event??? And, if whatever it is you want to make happen via a fake online_event is going to a function, why not just call the function?

    What were you planning on doing code-wise to start the fake online event? whereever that was just call the function and avoid the middle man.

    Post some code with your idea and we'll see if we can help.
    e

    I'm just looking for a way to send some initialization commands to DXLink devices in response to a REINIT command to a module or when they come online without writing the same code in both sections. As for why I'm looking to emulate the online event, because that's where the code lives, and I'm being lazy.

    In general, the ability to control when an online event occurs for modules would be nice. It's always struck me as weird to use the DATA_INITIALIZED channel event, instead of allowing the module to just control the online and offline events, but that's a whole other issue.
  • ericmedleyericmedley Posts: 4,177
    Define_function   Fn_Stuff_i_want_to_do(){
      // a whole bunch of stuff I only want to code once
      //
      }
    
    Data_event[vdvDevice]{
        Online_event:{
            Fn_Stuff_i_want_to_do()
          }
      }
    
    Chaneel_event[dv_a_device,1]{
        On:{
            Fn_Stuff_i_want_to_do()
          }
      }
    
    DEFINE_START
    
    WAIT 456{   Fn_Stuff_i_want_to_do() }
    
  • mstocummstocum Posts: 120
    Yeah, that's definitely the right way to do it. Like I said, I was being lazy (my own project, this isn't for anyone external or anything) and then got curious if it was even possible. do_push() can be pretty useful, and it's arguably just as bad as do_online_event() would be.
  • ericmedleyericmedley Posts: 4,177
    hmmm.. that's interesting. I don't code differently for my personal projects. I typically keep it all consistent. It does evolve over time.
  • a_riot42a_riot42 Posts: 1,624
    I've wondered about that as well, but have never found a way to simulate an online event. If you figure out a way, please post it here.
    Paul
  • DHawthorneDHawthorne Posts: 4,584
    Easiest way to do this is to create a function for your init routine. Pass it whatever you need to from the online event, but make the function your only code in the event. Then when you need it elsewhere, call the function directly.
Sign In or Register to comment.