Giter Site home page Giter Site logo

Comments (4)

Ellislee1 avatar Ellislee1 commented on June 12, 2024

@leonardocfor I came across this and thought I'd have a look at it. I can get updating to run with the following code. The text appears before the Successfully loaded plugin TEST. This also sits in a file ./plugins/test.py. I think as well you need to make sure the function init_plugin() is configured properly. I copied this using the plugins that come with BlueSky to generate this MWE. Hope this helps.

""" BlueSky plugin template. The text you put here will be visible
    in BlueSky as the description of your plugin. """
from bluesky import core, stack, traf  #, settings, navdb, sim, scr, tools

### Initialization function of your plugin. Do not change the name of this
### function, as it is the way BlueSky recognises this file as a plugin.
def init_plugin():
    ''' Plugin initialisation function. '''
    # Instantiate our example entity
    test = Test()

    # Configuration parameters
    config = {
        # The name of your plugin
        'plugin_name':     'TEST',

        # The type of this plugin. For now, only simulation plugins are possible.
        'plugin_type':     'sim',
        }

    # init_plugin() should always return a configuration dict.
    return config


class Test(core.Entity):
    ''' Example new entity object for BlueSky. '''
    def __init__(self):
        super().__init__()
        self.update()


    # Functions that need to be called periodically can be indicated to BlueSky
    # with the timed_function decorator
    @core.timed_function(name='test', dt=5)
    def update(self):
        """Updating function"""
        print("Updating ...")

image

from bluesky.

jooste avatar jooste commented on June 12, 2024

Hi @leonardocfor,

To add to @Ellislee1 's answer: Don't forget to instantiate your Test class (typically in the init_plugin function), and note that periodic functions are only triggered when the simulation is in Operate mode (so not in Hold, which is what you have when you start up BlueSky).

from bluesky.

leonardocfor avatar leonardocfor commented on June 12, 2024

Hi @Ellislee1 and @jooste,

Thank you for your prompt reply. I confirm that the update function is executed upon the class initialization. However, to your comment @jooste, how can I force the simulation to go to Operate mode? i.e. without having to send a command or else to kick off the simulation. I ask this because we need to allow constant checking of a remote API in the update function.

from bluesky.

jooste avatar jooste commented on June 12, 2024

You could do the following:

from bluesky import sim

def init_plugin():
    ...
    sim.op()

from bluesky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.