if __name__ == '__main__': from kervi.application import Application APP = Application({ "network": { "ip": "127.0.0.1", "ipc_root_address": "127.0.0.1", "ws_port": 9000, } }) #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard", "Dynamic number test", is_default=True) DASHBOARD.add_panel(DashboardPanel("number", width=33, title="Number")) DASHBOARD.add_panel(DashboardPanel("number_inline", title="number inline")) DASHBOARD.add_panel(DashboardPanel("number_gauge", width=20)) DASHBOARD.add_panel(DashboardPanel("number_chart")) DASHBOARD.add_panel(DashboardPanel("number_chart_x", width=100)) DASHBOARD.add_panel(DashboardPanel("log", title="Log", user_log=True)) from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver cpu_sensor = Sensor("CPULoadSensor", "CPU", CPULoadSensorDeviceDriver()) cpu_sensor.link_to_dashboard("dashboard", "number_chart", type="chart") cpu_sensor.link_to_dashboard("dashboard", "number_chart", link_to_header=True) cpu_sensor.link_to_dashboard("*", "header_right", show_sparkline=True) cpu_sensor.link_to_dashboard(
if __name__ == '__main__': from kervi.application import Application APP = Application() #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard.ctrl", "Adafruit char lcd test", is_default=True) DASHBOARD.add_panel( DashboardPanel("input", columns=2, rows=4, title="input")) DASHBOARD.add_panel( DashboardPanel("log", columns=3, rows=4, title="Log", user_log=True)) #define a light controller from kervi.hal import GPIO from kervi.controllers import Controller from kervi.values import * from kervi.devices.displays.HD44780_i2c_PCF8574 import CharLCDDeviceDriver class TestController(Controller): def __init__(self): Controller.__init__(self, "controller.test", "test") self.type = "test" self.lcd = CharLCDDeviceDriver() self.lcd.enable_display(True) self.lcd.message("test") self.lcd.set_backlight(True) self.inputs.add("text", "LCD text", StringValue)
if __name__ == '__main__': from kervi.module import Module APP_MODULE = Module() #Important GPIO must be imported after module creation from kervi.hal import GPIO from kervi.dashboards import Dashboard, DashboardPanel Dashboard("module-{id}", "{{name}}", [DashboardPanel("light", title="Light")], is_default=True) from kervi.sensors.sensor import Sensor from kervi.devices.platforms.common.sensors.memory_use import MemUseSensorDeviceDriver #build in sensor that measures cpu use SENSOR_1 = Sensor("MemUseSensor", "Memory", MemUseSensorDeviceDriver()) #link to sys area top right SENSOR_1.link_to_dashboard("*", "sys-header") #link to a panel, show value in panel header and chart in panel body SENSOR_1.link_to_dashboard("module-{id}", "memory", type="value", link_to_header=True) SENSOR_1.link_to_dashboard("module-{id}", "memory", type="chart") #More on sensors https://kervi.github.io/sensors.html APP_MODULE.run()
""" bootstrap your kervi dashboards here """ from kervi.dashboards import Dashboard, DashboardPanel, DashboardPanelGroup #Create the dashboards for your Kervi application here. #Standard dashboard with several panels where sensors are placed. #Each sensor create links to one or more dashboard panels APP_DASHBOARD = Dashboard( "app", "My dashboard", [ DashboardPanelGroup([ DashboardPanelGroup([ DashboardPanelGroup([ DashboardPanel("fan", width=70, title="Lightx"), DashboardPanel("sensors", width=30, title="Sensors"), ], ), DashboardPanelGroup([ DashboardPanel("fanx", title="Panel 1"), DashboardPanel("sensorsx", title="Panel 2"), DashboardPanel("logx", title="Panel 3") ], ), ], width=60, layout="column"), DashboardPanel("log", width=40, title="Log", user_log=True) ]), ], is_default=True) # SYSTEM_DASHBOARD = Dashboard("system", "System", panels=[
if __name__ == '__main__': from kervi.application import Application APP = Application() #Important GPIO must be imported after application creation from kervi.hal import GPIO from kervi.dashboards import Dashboard, DashboardPanel Dashboard("app", "App", [DashboardPanel("fan", title="CPU fan")], is_default=True) Dashboard( "system", "System", [DashboardPanel("cpu"), DashboardPanel("cam")]) #Create a streaming camera server from kervi.vision.camera import CameraStreamer CAMERA = CameraStreamer("cam1", "camera 1") #link camera as background CAMERA.link_to_dashboard("app") #link camera to a panel CAMERA.link_to_dashboard("system", "cam") from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver from kervi.devices.sensors.system import CPUTempSensorDeviceDriver #build in sensor that measures cpu use SENSOR_CPU_LOAD = Sensor("CPULoadSensor", "CPU", CPULoadSensorDeviceDriver()) #link to sys area top right SENSOR_CPU_LOAD.link_to_dashboard("*", "sys-header")
""" bootstrap your kervi dashboards here """ from kervi.dashboards import Dashboard, DashboardPanel #Create the dashboards for your Kervi application here. #Standard dashboard with several panels where sensors are placed. #Each sensor create links to one or more dashboard panels Dashboard("app", "My dashboard", [ DashboardPanel("fan", title="Fan"), DashboardPanel("sensors", title="Sensors") ], is_default=True) Dashboard("system", "System", [ DashboardPanel("cpu"), DashboardPanel("memory"), DashboardPanel("disk"), DashboardPanel("device", title="device"), DashboardPanel("log", title="Log", user_log=True) ], user_groups=["admin"])
if __name__ == '__main__': from kervi.application import Application APP = Application() #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("main", "Controller Buttons", is_default=True) DASHBOARD.add_panel(DashboardPanel("gpio", columns=3, rows=3, title="GPIO")) from kervi.hal import GPIO GPIO["GPIO1"].define_as_input() GPIO["GPIO2"].define_as_output() GPIO["GPIO3"].define_as_pwm(60, 0) GPIO["GPIO1"].link_to_dashboard("main", "gpio") GPIO["GPIO2"].link_to_dashboard("main", "gpio") GPIO["GPIO3"].pwm["duty_cycle"].link_to_dashboard("main", "gpio") APP.run()
if __name__ == '__main__': from kervi.application import Application APP = Application() from kervi.dashboards import Dashboard, DashboardPanel #Define dashboards and panels Dashboard( "app", "App", [ DashboardPanel("fan", title="CPU fan") ], is_default=True ) Dashboard( "system", "System", [ DashboardPanel("cpu-load"), DashboardPanel("cpu-temp") ] ) from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver from kervi.devices.sensors.system import CPUTempSensorDeviceDriver from kervi.devices.sensors.dummy_sensor import DummySensorDeviceDriver #build in sensor that measures cpu use
import time if __name__ == '__main__': from kervi.application import Application APP = Application({ "modules": ["action_tests"], "network": { "ip": "127.0.0.1", "ip_root_address": "127.0.0.1" } }) from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("app", "App", [DashboardPanel("actions", width="200px")], is_default=True) from kervi.actions import action, Actions interupt_action = False @action def action_start(): print("action_start") while not interupt_action: time.sleep(0.1) print("action_start done") @action_start.set_interrupt def action_interupt(): global interupt_action print("action interupt")
if __name__ == '__main__': from kervi.application import Application APP = Application() #Important GPIO must be imported after application creation from kervi.hal import GPIO from kervi.dashboards import Dashboard, DashboardPanel Dashboard( "app", "App", [ DashboardPanel("fan", title="CPU fan") ], is_default=True ) Dashboard( "system", "System", [ DashboardPanel("cpu"), DashboardPanel("cam") ] ) #Create a streaming camera server from kervi.vision.camera import CameraStreamer CAMERA = CameraStreamer("cam1", "camera 1") #link camera as background CAMERA.link_to_dashboard("app") #link camera to a panel
if __name__ == '__main__': from kervi.application import Application APP = Application() #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard", "GPIO", is_default=True) DASHBOARD.add_panel( DashboardPanel("gpio", columns=2, rows=4, title="GPIO Width 0")) DASHBOARD.add_panel( DashboardPanel("gpio_inline", columns=3, rows=4, title="button inline")) from kervi.hal import GPIO GPIO["GPIO1"].define_as_output() GPIO["GPIO1"].link_to_dashboard("dashboard", "gpio") GPIO["GPIO1"].pwm["duty_cycle"].link_to_dashboard("dashboard", "gpio") GPIO["GPIO1"].pwm["active"].link_to_dashboard("dashboard", "gpio") GPIO["DAC1"].link_to_dashboard("dashboard", "gpio") APP.run()
if __name__ == '__main__': from kervi.application import Application APP = Application({ "network":{ "ip": "127.0.0.1", "ipc_root_address": "127.0.0.1", "ws_port": 9000, } }) #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard", "Dynamic boolean test", is_default=True) DASHBOARD.add_panel(DashboardPanel("boolean", title="Boolean")) DASHBOARD.add_panel(DashboardPanel("boolean_inline", title="boolean inline")) DASHBOARD.add_panel(DashboardPanel("log", title="Log", user_log=True)) from kervi.hal import GPIO from kervi.controllers import Controller from kervi.values import BooleanValue from kervi.messaging import Messaging class TestController(Controller): def __init__(self): Controller.__init__(self, "controller.test", "test") self.type = "test" #define an input and link it to the dashboard panel self.inputs.add("boolean", "Boolean", BooleanValue) self.inputs["boolean"].link_to_dashboard("dashboard", "boolean") self.inputs["boolean"].link_to_dashboard("dashboard", "boolean", label="1", label_icon="bulb", on_text="active", off_text="inactive")
if __name__ == '__main__': from kervi.application import Application APP = Application() #Important GPIO must be imported after application creation from kervi.hal import GPIO from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("app", "App", is_default=True) DASHBOARD.add_panel( DashboardPanel("fan", columns=3, rows=2, title="CPU fan")) SYSTEMBOARD = Dashboard("system", "System") SYSTEMBOARD.add_panel(DashboardPanel("cpu", columns=2, rows=2)) SYSTEMBOARD.add_panel(DashboardPanel("cam", columns=2, rows=2)) #Create a streaming camera server from kervi.vision.camera import CameraStreamer CAMERA = CameraStreamer("cam1", "camera 1") #link camera as background CAMERA.link_to_dashboard("app") #link camera to a panel CAMERA.link_to_dashboard("system", "cam") CAMERA.pan.link_to_dashboard("system", "cpu") CAMERA.tilt.link_to_dashboard("system", "cpu") from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver from kervi.devices.sensors.system import CPUTempSensorDeviceDriver #build in sensor that measures cpu use SENSOR_CPU_LOAD = Sensor("CPULoadSensor", "CPU", CPULoadSensorDeviceDriver())
from kervi.dashboards import Dashboard, DashboardPanel #Define dashboards and panels Dashboard("layout", "Layout", [ DashboardPanel("fan", title="CPU fan", width=50), DashboardPanel("p1", title="Panel 2", width=25), DashboardPanel("p2", title="Panel 3", width=25) ], is_default=False) #create sensor from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver from kervi.devices.sensors.system import CPUTempSensorDeviceDriver from kervi.devices.sensors.dummy_sensor import DummySensorDeviceDriver #create a senors that uses CPU load device driver cpu_load_sensor = Sensor("CPULoadSensor", "CPU", CPULoadSensorDeviceDriver()) #link to dashboard cpu_load_sensor.link_to_dashboard("*", "header_right", show_sparkline=True) cpu_load_sensor.link_to_dashboard("layout", "p1", type="value", show_sparkline=True, link_to_header=True) cpu_load_sensor.link_to_dashboard("layout", "p1", type="chart") cpu_load_sensor.link_to_dashboard("layout", "p2", type="chart") #create a senors that uses CPU temp device driver cpu_temp_sensor = Sensor("CPUTempSensor", "CPU temp", DummySensorDeviceDriver())
""" bootstrap your kervi dashboards here """ from kervi.dashboards import Dashboard, DashboardPanel #Create the dashboards for your Kervi application here. #Standard dashboard with several panels where sensors are placed. #Each sensor create links to one or more dashboard panels APP_DASHBOARD = Dashboard("app", "Main dahsboard", is_default=True) APP_DASHBOARD.add_panel(DashboardPanel("steering", title="Steering")) APP_DASHBOARD.add_panel(DashboardPanel("balance_pid", title="Balance PID ")) APP_DASHBOARD.add_panel(DashboardPanel("sensors", title="Sensors")) SYSTEM_DASHBOARD = Dashboard("system", "System") SYSTEM_DASHBOARD.add_panel(DashboardPanel("cpu")) SYSTEM_DASHBOARD.add_panel(DashboardPanel("memory")) SYSTEM_DASHBOARD.add_panel(DashboardPanel("disk")) SYSTEM_DASHBOARD.add_panel(DashboardPanel("power", title="Power")) SYSTEM_DASHBOARD.add_panel(DashboardPanel("log", title="Log", user_log=True))
if __name__ == '__main__': import time from kervi.application import Application APP = Application() from kervi.dashboards import Dashboard, DashboardPanel Dashboard("app", "App", [DashboardPanel("gate", title="Gate")], is_default=True) Dashboard("settings", "Settings", [DashboardPanel("gate", width="200px", title="Gate")]) from kervi.devices.motors.dummy_motor_driver import DummyMotorBoard motor_board = DummyMotorBoard() from kervi.hal import GPIO hi_end_stop = GPIO["GPIO2"] lo_end_stop = GPIO["GPIO3"] hi_end_stop.define_as_input() lo_end_stop.define_as_input() stop_move = False from kervi.actions import action @action(name="Move gate") def move_gate(open=True):
if __name__ == '__main__': from kervi.application import Application APP = Application( { # "network":{ # "ip": "127.0.0.1", # "ipc_root_address": "127.0.0.1" # } } ) #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard.app", "app dashboard", is_default=True) DASHBOARD.add_panel(DashboardPanel("cpu", columns=2, rows=4, title=None)) from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver SENSOR_1 = Sensor("CPULoadSensor", "CPU", CPULoadSensorDeviceDriver()) #link to sys area top right SENSOR_1.link_to_dashboard("*", "sys-header") #link to a panel, show value in panel header and chart in panel body SENSOR_1.link_to_dashboard("dashboard.app", "cpu", type="value", size=2, link_to_header=True) SENSOR_1.link_to_dashboard("dashboard.app", "cpu", type="chart", size=2) APP.actions.shutdown.link_to_dashboard("*", "header_right", inline=True, label=None, button_text="App shutdown") APP.run()
if __name__ == '__main__': from kervi.application import Application APP = Application({ "network": { "ip": "127.0.0.1", "ipc_root_address": "127.0.0.1", "ws_port": 9000, } }) #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dahsboard.ctrl", "Controller test", is_default=True) DASHBOARD.add_panel( DashboardPanel("textinput", title="date time value", width="50%")) DASHBOARD.add_panel(DashboardPanel("text_inline", title="inline")) DASHBOARD.add_panel(DashboardPanel("log", title="Log", user_log=True)) #define a light controller from kervi.hal import GPIO from kervi.controllers import Controller from kervi.values import DateTimeValue from kervi.messaging import Messaging class TestController(Controller): def __init__(self): Controller.__init__(self, "controller.test", "test") self.type = "test" #define an input and link it to the dashboard panel self.input1 = self.inputs.add("d1", "DateTime 1", DateTimeValue)
if __name__ == '__main__': from kervi.module import Module APP_MODULE = Module() #Important GPIO must be imported after module creation from kervi.hal import GPIO from kervi.dashboards import Dashboard, DashboardPanel Dashboard( "module-{id}", "{{name}}", [ DashboardPanel("light", title="Light") ], is_default=True ) from kervi.sensors import Sensor from kervi.devices.sensors.system importMemoryUseSensorDeviceDriver #build in sensor that measures cpu use SENSOR_1 = Sensor("MemUseSensor", "Memory",MemoryUseSensorDeviceDriver()) #link to sys area top right SENSOR_1.link_to_dashboard("*", "sys-header") #link to a panel, show value in panel header and chart in panel body SENSOR_1.link_to_dashboard("module-{id}", "memory", type="value", link_to_header=True) SENSOR_1.link_to_dashboard("module-{id}", "memory", type="chart") #More on sensors https://kervi.github.io/sensors.html
if __name__ == '__main__': from kervi.application import Application APP = Application() #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard.app", "Test LSM9DS1.py", is_default=True) DASHBOARD.add_panel(DashboardPanel("accl", title="Acceleration")) DASHBOARD.add_panel(DashboardPanel("gyro", title="Gyro")) DASHBOARD.add_panel(DashboardPanel("magnetic", title="Magnetic")) from kervi.hal import GPIO from kervi.sensors import Sensor import kervi.devices.sensors.LSM9DS1 as LSM9DS1 SENSOR_ACCL = Sensor("accl", "Acceleration", LSM9DS1.LSM9DS1AccelerationDeviceDriver()) SENSOR_ACCL.link_to_dashboard("dashboard.app", "accl") SENSOR_GYRO = Sensor("gyro", "gyro", LSM9DS1.LSM9DS1GyroDeviceDriver()) SENSOR_GYRO.link_to_dashboard("dashboard.app", "gyro") SENSOR_MAG = Sensor("magnetic", "Magnetic", LSM9DS1.LSM9DS1MagneticDeviceDriver()) SENSOR_MAG.link_to_dashboard("dashboard.app", "magnetic") APP.run()
"ip": "127.0.0.1", "ipc_root_address": "127.0.0.1", "ws_port": 9000, }, "location": { # greenwich "longitude": 61.563300, "latitude": -6.838634, "time_zone": 0 }, }) #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("system", "Sensor test", is_default=True) DASHBOARD.add_panel(DashboardPanel("multi_sensor", title="Multi sensor")) DASHBOARD.add_panel( DashboardPanel("multi_sensor_single", title="Multi sensor single")) DASHBOARD.add_panel( DashboardPanel("color_sensor", title="Color sensor single ----xxx---")) DASHBOARD.add_panel(DashboardPanel("sun_sensor", title="Sun sensor")) DASHBOARD.add_panel(DashboardPanel("gauge", title="Gauge")) DASHBOARD.add_panel(DashboardPanel("log", title="Log", user_log=True)) from kervi.sensors import Sensor from kervi.devices.sensors.system import CPULoadSensorDeviceDriver from kervi.devices.sensors.dummy_sensor import DummyMultiDimSensorDeviceDriver cpu_sensor = Sensor("CPULoadSensor", "CPU", CPULoadSensorDeviceDriver()) cpu_sensor.store_to_db = False cpu_sensor.link_to_dashboard("*", "header_right", show_sparkline=True)
if __name__ == '__main__': from kervi.application import Application APP = Application({ "network": { "ip": "127.0.0.1", "ipc_root_address": "127.0.0.1", "ws_port": 9000, } }) #add dashboard and panel from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard", "colortest", is_default=True) DASHBOARD.add_panel(DashboardPanel("color", width=25, title="Color")) DASHBOARD.add_panel(DashboardPanel("color_inline", title="Color inline")) DASHBOARD.add_panel(DashboardPanel("log", title="Log", user_log=True)) from kervi.controllers import Controller from kervi.values import ColorValue from kervi.messaging import Messaging class TestController(Controller): def __init__(self): Controller.__init__(self, "controller.test", "test") self.type = "test" #define an input and link it to the dashboard panel self.color = self.inputs.add("color", "Boolean", ColorValue) self.color.value = "#000f00" self.color.persist_value = True self.color.link_to_dashboard("dashboard", "boolean")
"id":"module.id", "name":"Module name" }, "log":{ "file":"kervi-module.log" }, "network" : { "ipc_root_port": 9500, "ipc_root_address": "192.168.0.137" } }) from kervi.dashboards import Dashboard, DashboardPanel DASHBOARD = Dashboard("dashboard.module", "module dashboard", is_default=True) DASHBOARD.add_panel(DashboardPanel("panel", columns=2, rows=2, title="Panel dashboard")) from kervi.sensors import Sensor from kervi.devices.sensors.system import MemoryUseSensorDeviceDriver SENSOR_1 = Sensor("MemLoadSensor", "MEM", MemoryUseSensorDeviceDriver()) #link to sys area top right SENSOR_1.link_to_dashboard("*", "sys-header") #link to a panel, show value in panel header and chart in panel body SENSOR_1.link_to_dashboard("dashboard.module", "panel", type="value", size=2, link_to_header=True) SENSOR_1.link_to_dashboard("dashboard.module", "panel", type="chart", size=2) APP_MODULE.actions.shutdown.link_to_dashboard("*", "header_right", inline=True, label=None, button_text="Module shutdown") from kervi.streams import stream_observer from kervi.streams import stream_images, stream_observer