Welcome to Our Community

Some features disabled for guests. Register Today.

Variables across js macros and sockets questions

Discussion in 'Control Software' started by JakeNull, Oct 4, 2023.

  1. JakeNull

    JakeNull New
    Builder

    Joined:
    Nov 13, 2018
    Messages:
    13
    Likes Received:
    7
    Hello there,

    Just looking for a couple tips to point me in the right direction.

    Question one, can I share a variable from one JS macro to another macro run second?

    Two, Are there any limits to building a websocket (to a deferent controller) in JS/chromium from inside a macro?
     
  2. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    15,506
    Likes Received:
    4,422
    You can set global variables yes Window Variable JavaScript | Declare Global Variables inside a function

    We don't impose any limits. You can overwrite existing functions, anything you need. We kept everything global so its easy to access / overwrite etc


    That gets trickier. the nodejs backend handles comms. Not the frontend. To cater for a 3rd party firmware would need more than Macros. What did you have in mind?
     
    sharmstr likes this.
  3. sharmstr

    sharmstr OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 23, 2018
    Messages:
    2,059
    Likes Received:
    1,449
    Yes. What peter said. But depending on your need another option is to set and use localStorage.
     
    Peter Van Der Walt likes this.
  4. JakeNull

    JakeNull New
    Builder

    Joined:
    Nov 13, 2018
    Messages:
    13
    Likes Received:
    7
    Great, thanks guys. I guess i should have tested globals myself first...

    I have a bit of a franken-setup where I control a mobile controller via WS + Web GUI from a stationary workstation.
    Its used for a couple different devices and i physically move it between them as needed.
    I guess a websocket via Macro would have just been a shortcut really....

    I've dug in a bit tonight.
    I figured out how to re-compile CONTROL, add some custom sections and started up an addition WebSocket connection.
    This is the way!
     
    Peter Van Der Walt and sharmstr like this.
  5. sharmstr

    sharmstr OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 23, 2018
    Messages:
    2,059
    Likes Received:
    1,449
  6. JakeNull

    JakeNull New
    Builder

    Joined:
    Nov 13, 2018
    Messages:
    13
    Likes Received:
    7
    Hey guys,
    I've gotta saying developing some custom features into CONTROL has been great!
    The design is layed out so well and easy to follow.
    I've managed to developed a solid set of custom features in days and have them working
    seamlessly right inside CONTROL itself.

    Part 1, An independent A axis that also has the ability to hook into the main gcode jobs and run as a true 4th axis.
    upload_2023-10-6_15-44-26.png

    What a great product Peter!
    Thanks.
     
    #6 JakeNull, Oct 6, 2023
    Last edited: Oct 6, 2023
    sharmstr likes this.
  7. sharmstr

    sharmstr OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Mar 23, 2018
    Messages:
    2,059
    Likes Received:
    1,449
    Excellent. Now do something about all that wasted horizontal space.

    upload_2023-10-6_17-26-55.png
     
    David the swarfer likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice