Compare commits
12 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
9374866174 | 4 years ago |
|
|
3d04af8427 | 5 years ago |
|
|
b15686f264 | 5 years ago |
|
|
fc6552470d | 5 years ago |
|
|
d6b91ee47e | 5 years ago |
|
|
432f1aed84 | 5 years ago |
|
|
563ecd2e31 | 5 years ago |
|
|
7ea8e32498 | 5 years ago |
|
|
9781d7f77b | 5 years ago |
|
|
82cc667cbb | 5 years ago |
|
|
0c4184d692 | 5 years ago |
|
|
ce09435b11 | 5 years ago |
@ -1,77 +1,48 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import shepherd.config
|
import shepherd.config as shconf
|
||||||
import shepherd.module
|
import shepherd.plugin
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from gpiozero import OutputDevice, Device
|
|
||||||
from gpiozero.pins.pigpio import PiGPIOFactory
|
|
||||||
|
|
||||||
from shepherd.modules.betterservo import BetterServo
|
class AphidtrapModule(shepherd.plugin.Plugin):
|
||||||
|
@staticmethod
|
||||||
|
def define_config(confdef):
|
||||||
|
pass
|
||||||
|
|
||||||
Device.pin_factory = PiGPIOFactory()
|
def __init__(self, pluginInterface, config):
|
||||||
|
super().__init__(pluginInterface, config)
|
||||||
|
|
||||||
|
self.config = config
|
||||||
APHIDTRAP_LED_PIN = 5 #Out2
|
self.interface = pluginInterface
|
||||||
|
self.plugins = pluginInterface.other_plugins
|
||||||
|
self.hooks = pluginInterface.hooks
|
||||||
class AphidtrapConfDef(shepherd.config.ConfDefinition):
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
|
|
||||||
class AphidtrapModule(shepherd.module.SimpleModule):
|
|
||||||
conf_def = AphidtrapConfDef()
|
|
||||||
|
|
||||||
def setup(self):
|
|
||||||
|
|
||||||
print("Aphidtrap config:")
|
print("Aphidtrap config:")
|
||||||
print(self.config)
|
print(self.config)
|
||||||
|
|
||||||
self.led_power = OutputDevice(APHIDTRAP_LED_PIN,
|
if "picam" in self.plugins:
|
||||||
active_high=True,
|
self.interface.attach_hook("picam", "pre_cam", self.led_on)
|
||||||
initial_value=False)
|
self.interface.attach_hook("picam", "post_cam", self.led_off)
|
||||||
|
elif "usbcam" in self.plugins:
|
||||||
|
self.interface.attach_hook("usbcam", "pre_cam", self.led_on)
|
||||||
|
self.interface.attach_hook("usbcam", "post_cam", self.led_off)
|
||||||
|
else:
|
||||||
|
raise ValueError("Need to either have picam or usbcam plugin loaded")
|
||||||
|
|
||||||
def setup_other_modules(self):
|
self.interface.register_function(self.test)
|
||||||
self.modules.picam.hook_pre_cam.attach(self.led_on)
|
|
||||||
self.modules.picam.hook_post_cam.attach(self.led_off)
|
|
||||||
|
|
||||||
def led_on(self):
|
def led_on(self):
|
||||||
self.led_power.on()
|
self.plugins["scout"].set_out2(True)
|
||||||
|
|
||||||
def led_off(self):
|
def led_off(self):
|
||||||
self.led_power.off()
|
self.plugins["scout"].set_out2(False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def test(self):
|
||||||
argparser = argparse.ArgumentParser(
|
self.led_on()
|
||||||
description='Module for aphidtrap control functions. Run for testing')
|
|
||||||
argparser.add_argument("configfile", nargs='?', metavar="configfile",
|
|
||||||
help="Path to configfile", default="conf.toml")
|
|
||||||
|
|
||||||
|
|
||||||
args = argparser.parse_args()
|
|
||||||
confman = shepherd.config.ConfigManager()
|
|
||||||
|
|
||||||
srcdict = {"aphidtrap": {}}
|
|
||||||
|
|
||||||
if os.path.isfile(args.configfile):
|
|
||||||
confman.load(args.configfile)
|
|
||||||
else:
|
|
||||||
confman.load(srcdict)
|
|
||||||
|
|
||||||
aphidtrap_mod = AphidtrapModule(confman.get_config("aphidtrap", AphidtrapConfDef()),
|
|
||||||
shepherd.module.Interface(None))
|
|
||||||
|
|
||||||
aphidtrap_mod.led_on()
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
aphidtrap_mod.led_off()
|
self.led_off()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv[1:])
|
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
[shepherd]
|
||||||
|
hostname = "DPIRD-test"
|
||||||
|
id = "DPIRD-test"
|
||||||
|
plugin_dir = "/home/pi/plugins/"
|
||||||
|
plugins = ["scout", "picam", "uploader", "mothtrap"]
|
||||||
|
root_dir = "/home/pi/"
|
||||||
|
conf_edit_path = "/boot/shepherd.toml"
|
||||||
|
control_server = "api.shepherd.distreon.net"
|
||||||
|
api_key = "v2EgvYzx79c8fCP4P7jlWxTZ3pc"
|
||||||
|
[scout]
|
||||||
|
boardver = "3"
|
||||||
|
serialport = "/dev/ttyS0"
|
||||||
|
[uploader]
|
||||||
|
[[uploader.destination]]
|
||||||
|
name = "agricSFTP"
|
||||||
|
protocol = "sftp"
|
||||||
|
address = "agric.files.distreon.net"
|
||||||
|
port = 2222
|
||||||
|
path = "/mothtraps"
|
||||||
|
username = "agric"
|
||||||
|
password = "asherhaze"
|
||||||
|
[[uploader.bucket]]
|
||||||
|
name = "imageupload"
|
||||||
|
open_link_on_new = true
|
||||||
|
keep_copy = false
|
||||||
|
destination = "agricSFTP"
|
||||||
|
[picam]
|
||||||
|
upload_images = true
|
||||||
|
upload_bucket = "imageupload"
|
||||||
|
[[picam.trigger]]
|
||||||
|
hour = "*"
|
||||||
|
minute ="*/15"
|
||||||
|
second = "0"
|
||||||
|
[mothtrap]
|
||||||
|
servo_open_pulse = 900
|
||||||
|
servo_closed_pulse = 2100
|
||||||
|
servo_open_time = 3
|
||||||
|
# shepherd_message: Successfully applied this config at:2020-03-29 18:29:28.566836
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
[shepherd]
|
||||||
|
hostname = "DPIRD-test"
|
||||||
|
id = "DPIRD-test"
|
||||||
|
plugin_dir = "/home/pi/plugins/"
|
||||||
|
plugins = ["scout", "usbcam", "uploader", "flytrap"]
|
||||||
|
root_dir = "/home/pi/"
|
||||||
|
conf_edit_path = "/boot/shepherd.toml"
|
||||||
|
control_server = "api.shepherd.distreon.net"
|
||||||
|
api_key = "v2EgvYzx79c8fCP4P7jlWxTZ3pc"
|
||||||
|
[scout]
|
||||||
|
boardver = "3"
|
||||||
|
serialport = "/dev/ttyS0"
|
||||||
|
[uploader]
|
||||||
|
[[uploader.destination]]
|
||||||
|
name = "agricSFTP"
|
||||||
|
protocol = "sftp"
|
||||||
|
address = "agric.files.distreon.net"
|
||||||
|
port = 2222
|
||||||
|
path = "/mothtraps"
|
||||||
|
username = "agric"
|
||||||
|
password = "asherhaze"
|
||||||
|
[[uploader.bucket]]
|
||||||
|
name = "imageupload"
|
||||||
|
open_link_on_new = true
|
||||||
|
keep_copy = false
|
||||||
|
destination = "agricSFTP"
|
||||||
|
[usbcam]
|
||||||
|
upload_images = true
|
||||||
|
upload_bucket = "imageupload"
|
||||||
|
[[usbcam.camera]]
|
||||||
|
name = "USB1"
|
||||||
|
usb_port = "1.2"
|
||||||
|
[[usbcam.camera]]
|
||||||
|
name = "USB2"
|
||||||
|
usb_port = "1.3"
|
||||||
|
[[usbcam.camera]]
|
||||||
|
name = "USB3"
|
||||||
|
usb_port = "1.1"
|
||||||
|
[[usbcam.camera]]
|
||||||
|
name = "USB"
|
||||||
|
usb_port = "*"
|
||||||
|
[[usbcam.trigger]]
|
||||||
|
hour = "*"
|
||||||
|
minute ="0"
|
||||||
|
second = "0"
|
||||||
|
[flytrap]
|
||||||
|
servo_open_pulse = 2100
|
||||||
|
servo_closed_pulse = 900
|
||||||
|
servo_open_time = 3
|
||||||
|
# shepherd_message: Successfully applied this config at:2019-12-16 00:59:30.985447
|
||||||
Loading…
Reference in new issue