parent
8a32a252d4
commit
9c1dda6372
@ -1,8 +1,9 @@
|
||||
[shepherd]
|
||||
plugin_path = "~/shepherd/"
|
||||
plugins = ["picam"]
|
||||
plugins = ["picam","test"]
|
||||
root_dir = "~/shepherd/"
|
||||
conf_edit_path = "~/shepherd.toml"
|
||||
test =1
|
||||
[picam]
|
||||
[[picam.trigger]]
|
||||
hour = "00-23"
|
||||
|
||||
|
Before Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import shepherd.config as shconf
|
||||
import shepherd.plugin
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import argparse
|
||||
|
||||
|
||||
|
||||
class FlytrapPlugin(shepherd.plugin.Plugin):
|
||||
@staticmethod
|
||||
def define_config(confdef):
|
||||
confdef.add_def('servo_open_pulse', shconf.IntDef(default=1200, minval=800, maxval=2200))
|
||||
confdef.add_def('servo_closed_pulse', shconf.IntDef(default=1800, minval=800, maxval=2200))
|
||||
confdef.add_def('servo_open_time', shconf.IntDef(default=5))
|
||||
|
||||
def __init__(self, pluginInterface, config):
|
||||
super().__init__(pluginInterface, config)
|
||||
self.config = config
|
||||
self.interface = pluginInterface
|
||||
self.plugins = pluginInterface.other_plugins
|
||||
self.hooks = pluginInterface.hooks
|
||||
|
||||
self.root_dir = os.path.expanduser(pluginInterface.coreconfig["root_dir"])
|
||||
self.id = pluginInterface.coreconfig["id"]
|
||||
|
||||
print("Flytrap config:")
|
||||
print(self.config)
|
||||
|
||||
self.interface.attach_hook("usbcam", "pre_cam", self.led_on)
|
||||
self.interface.attach_hook("usbcam", "post_cam", self.uv_camera)
|
||||
|
||||
self.interface.register_function(self.test)
|
||||
|
||||
def uv_camera(self):
|
||||
self.led_off()
|
||||
self.led_uv_on()
|
||||
self.plugins["usbcam"].run_cameras(" UV")
|
||||
self.led_uv_off()
|
||||
self.run_servo()
|
||||
|
||||
def led_on(self):
|
||||
self.plugins["scout"].set_out1(True)
|
||||
|
||||
def led_off(self):
|
||||
self.plugins["scout"].set_out1(False)
|
||||
|
||||
def led_uv_on(self):
|
||||
self.plugins["scout"].set_out2(True)
|
||||
|
||||
def led_uv_off(self):
|
||||
self.plugins["scout"].set_out2(False)
|
||||
|
||||
def run_servo(self):
|
||||
self.plugins["scout"].set_aux5v(True)
|
||||
#self.door_servo_power.on()
|
||||
time.sleep(0.5)
|
||||
|
||||
self.plugins["scout"].set_pwm1(True, self.config["servo_open_pulse"])
|
||||
#self.door_servo.pulse_width = self.config["servo_open_pulse"] / 1000000
|
||||
time.sleep(self.config["servo_open_time"])
|
||||
|
||||
self.plugins["scout"].set_pwm1(True, self.config["servo_closed_pulse"])
|
||||
#self.door_servo.pulse_width = self.config["servo_closed_pulse"] / 1000000
|
||||
time.sleep(self.config["servo_open_time"])
|
||||
self.plugins["scout"].set_pwm1(False, self.config["servo_closed_pulse"])
|
||||
#self.door_servo.detach()
|
||||
self.plugins["scout"].set_aux5v(False)
|
||||
#self.door_servo_power.off()
|
||||
|
||||
def test(self):
|
||||
self.led_on()
|
||||
time.sleep(1)
|
||||
self.led_off()
|
||||
self.run_servo()
|
||||
|
Before Width: | Height: | Size: 954 KiB |
@ -1,28 +1,13 @@
|
||||
[shepherd]
|
||||
plugin_dir = "~/shepherd/"
|
||||
plugins = ["scout"]
|
||||
name = "test-node"
|
||||
plugin_dir = "./"
|
||||
root_dir = "~/shepherd/"
|
||||
conf_edit_path = "~/shepherd.toml"
|
||||
id = "testnode"
|
||||
hostname = "shepherd-test"
|
||||
control_server = "api.shepherd.distreon.net"
|
||||
#control_server = "127.0.0.1:5000"
|
||||
api_key = "v2EgvYzx79c8fCP4P7jlWxTZ3pc"
|
||||
control_api_key = "v2EgvYzx79c8fCP4P7jlWxTZ3pc"
|
||||
[scout]
|
||||
boardver = "3"
|
||||
serialport = "/dev/ttyUSB0"
|
||||
[usbcam]
|
||||
[[usbcam.camera]]
|
||||
name = "USB1"
|
||||
usb_port = "*"
|
||||
[[usbcam.camera]]
|
||||
name = "USB2"
|
||||
usb_port = "*"
|
||||
[[usbcam.camera]]
|
||||
name = "USB3"
|
||||
usb_port = "3.1.2.1"
|
||||
[[usbcam.trigger]]
|
||||
hour = "*"
|
||||
minute ="*/10"
|
||||
second = "1"
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
import shepherd.config as config
|
||||
|
||||
def test_freeze():
|
||||
confdef = config.ConfDefinition()
|
||||
conf_def_dict = confdef.add_def('dictval', config.DictDef())
|
||||
conf_def_dict.add_def('intval', config.IntDef())
|
||||
conf_def_dict.add_def('strtval', config.StringDef())
|
||||
|
||||
confman = config.ConfigManager()
|
||||
confman.add_confdef("test_bundle",confdef)
|
||||
confman.load({"test_bundle": {'dictval': {'intval': 34, 'strval': "a"}}})
|
||||
|
||||
confman.freeze_value("test_bundle","dictval", "intval")
|
||||
|
||||
confman.load({"test_bundle": {'dictval': {'intval': 34, 'strval': "b"}}})
|
||||
breakpoint()
|
||||
print(confman.root_config)
|
||||
|
||||
Loading…
Reference in new issue