Graphics

 View Only
  • 1.  Send Rosstalk/Message Via API to Windows Forms app?

    Posted 12-03-2023 22:04

    Hello,

    I am writing a Windows Forms app that is dependent on refreshing the data in itself whenever an XPression keyboard macro script runs. Essentially, whenever the keyboard script runs, it needs to invoke the Windows Forms app to refresh a rendered frame displayed in the app. However, I cannot figure out a good way to trigger an event from XPression Studio to my app, since I do not want it rendering frames constantly. The best option I see is to use an engine.Sequencer.OnFocusItemChanged event, however this does not work correctly and only fires the event once before hanging the app. There is some issue between this event and the xpTools library.

    I was wondering if there was a way to send a Rosstalk message from a keyboard script TO an external C# app to trigger this function. I'm not sure how I could set the app to receive Rosstalk commands.

    Appreciate any help, and also open to any better ways of doing this (GPI...?). Thanks!



    ------------------------------
    Jack Reynolds
    ------------------------------



  • 2.  RE: Send Rosstalk/Message Via API to Windows Forms app?

    Posted 12-04-2023 04:51

    Hi Jack

    I've sent message over TCP from XPression back to Dashboard, so this would work for you too.

    In your hardware setup, do something like the below. If you are running your app on the same machine as XPression make sure your TCP port is different to your incoming network settings port.  I've used TCP, but you can use UDP if your app is on the same machine as it's slightly easier to implement.

    Then I have a global function (Edit->Scripting->Global Methods) as per below.

    You can call this from anywhere in your project. I've assumed that the GPI board with the return connection is the first one in your hardware list.

    You can then send any string message you like. I tend to send messages with pipe delimiters so I can send a data field and a value, (eg "Goals|3" ) then end it all with a VBcr.

    This makes parsing it in your app quite easy.

    sub sendMessageToDashboard(engine as xpEngine,message as string)
    dim gpiBoard as xpGPIBoard
    
    engine.GetGPIBoard(0,gpiBoard)
    gpiBoard.SendMessage(message)
    end sub

    As to where to put calls to this function, depends on what you are trying to achieve. If you are looking at the sequencer OnFocusItemChanged, you could put a call in the OnPreviewRender function of each scene.  Bit of a pain to have to add it to each scene though!

    If I think of a better way i'll let you know!

    Hope this helps,

    Simon



    ------------------------------
    Simon Latus
    Simon Latus Media Ltd
    United Kingdom
    ------------------------------



  • 3.  RE: Send Rosstalk/Message Via API to Windows Forms app?

    Posted 12-04-2023 09:28

    Hey Simon,

    Thanks so much for this, this is incredibly helpful. I had started playing with this before I called it a night. A follow up, the sending message makes complete sense. How do I listen for the message on the other end? The engine.OnGPI event only receives a pin state, so what would be listening for a string?



    ------------------------------
    Jack Reynolds
    ------------------------------



  • 4.  RE: Send Rosstalk/Message Via API to Windows Forms app?

    Posted 12-04-2023 13:54

    Hi

    You don't listen for the message from XPression in the API, you need to use Winsock to create either a TCP or UDP listener.

    I'm assuming you are connecting to XPression via the API? Do you need too?  Are you getting data into XPression via your app and the API, or Datalinq?

    Simon



    ------------------------------
    Simon Latus
    Simon Latus Media Ltd
    United Kingdom
    ------------------------------



  • 5.  RE: Send Rosstalk/Message Via API to Windows Forms app?

    Posted 12-04-2023 16:55

    Ah I see, I'll look into that. I am connecting via the API, and I need to. I am generating a preview frame and displaying it in the app whenever the keyboard macro executes. No data going back into XPression, and no Datalinq in this one. Thank you for your help!

    Edit: All is working perfectly. Thanks again.



    ------------------------------
    Jack Reynolds
    ------------------------------