-
Notifications
You must be signed in to change notification settings - Fork 236
/
example.py
76 lines (57 loc) · 2.74 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
""" BlueSky plugin template. The text you put here will be visible
in BlueSky as the description of your plugin. """
# Import the global bluesky objects. Uncomment the ones you need
from bluesky import stack #, settings, navdb, traf, 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():
# Addtional initilisation code
# Configuration parameters
config = {
# The name of your plugin
'plugin_name': 'EXAMPLE',
# The type of this plugin. For now, only simulation plugins are possible.
'plugin_type': 'sim',
# Update interval in seconds. By default, your plugin's update function(s)
# are called every timestep of the simulation. If your plugin needs less
# frequent updates provide an update interval.
'update_interval': 2.5,
# The update function is called after traffic is updated. Use this if you
# want to do things as a result of what happens in traffic. If you need to
# something before traffic is updated please use preupdate.
'update': update,
# The preupdate function is called before traffic is updated. Use this
# function to provide settings that need to be used by traffic in the current
# timestep. Examples are ASAS, which can give autopilot commands to resolve
# a conflict.
'preupdate': preupdate,
# If your plugin has a state, you will probably need a reset function to
# clear the state in between simulations.
'reset': reset
}
stackfunctions = {
# The command name for your function
'MYFUN': [
# A short usage string. This will be printed if you type HELP <name> in the BlueSky console
'MYFUN ON/OFF',
# A list of the argument types your function accepts. For a description of this, see ...
'[onoff]',
# The name of your function in this plugin
myfun,
# a longer help text of your function.
'Print something to the bluesky console based on the flag passed to MYFUN.']
}
# init_plugin() should always return these two dicts.
return config, stackfunctions
### Periodic update functions that are called by the simulation. You can replace
### this by anything, so long as you communicate this in init_plugin
def update():
stack.stack('ECHO MY_PLUGIN update: creating a random aircraft')
stack.stack('MCRE 1')
def preupdate():
pass
def reset():
pass
### Other functions of your plugin
def myfun(flag=True):
return True, 'My plugin received an o%s flag.' % ('n' if flag else 'ff')