Permalink
Browse files

Events modularized

  • Loading branch information...
riot
riot committed Aug 9, 2016
1 parent 57f9d17 commit aa053d50f4b5969827bdaa94974fd712c782c842
@@ -13,7 +13,7 @@
from circuits import handler
from hfos.component import ConfigurableComponent
from hfos.logger import hfoslog, error, warn, verbose, critical
from hfos.events import broadcast, send
from hfos.events.client import broadcast, send
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -14,13 +14,20 @@
from circuits.tools import tryimport
import six
from hfos.component import ConfigurableComponent
from hfos.events import send
from hfos.events.client import send
from hfos.events.system import authorizedevent, AuthorizedEvents
from hfos.logger import error, debug
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
opencv = tryimport("cv2")
# Camera requests
class camerarequest(authorizedevent):
"""A new camera event has been generated by the client"""
class CameraManager(ConfigurableComponent):
"""
@@ -58,8 +65,12 @@ def __init__(self, maxcams=16, *args):
self.log("Found cameras: ", self._cameras, lvl=debug)
else:
self.log("No opencv, no cameras.")
AuthorizedEvents['camera'] = camerarequest
self.log("Started")
def rec(self):
"""Records a single snapshot"""
@@ -13,11 +13,22 @@
from time import time
from hfos.component import ConfigurableComponent
from hfos.logger import hfoslog, error, warn
from hfos.events import broadcast
from hfos.events.client import broadcast
from hfos.events.system import authorizedevent, AuthorizedEvents
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
# Chat events
class chatrequest(authorizedevent):
"""A new chat event has been generated by the client"""
# Components
class Chat(ConfigurableComponent):
"""
Chat manager
@@ -33,6 +44,8 @@ class Chat(ConfigurableComponent):
def __init__(self, *args):
super(Chat, self).__init__("CHAT", *args)
AuthorizedEvents['chat'] = chatrequest
self.log("Started")
def _getusername(self, event):
@@ -12,13 +12,13 @@
from hfos.component import ConfigurableComponent
from hfos.database import objectmodels
from hfos.logger import hfoslog, error, warn, critical, events
from hfos.events import AuthorizedEvent, AuthorizedEvents
from hfos.events.system import authorizedevent, AuthorizedEvents
from pprint import pprint
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
class countrequest(AuthorizedEvent):
class countrequest(authorizedevent):
def __init__(self, *args):
super(countrequest, self).__init__(*args)
hfoslog('Counterrequest generated:', args, emitter='COUNTER',
@@ -14,7 +14,7 @@
# from hfos.database import objectmodels
# from datetime import datetime
# from hfos.events import updatesubscriptions, send
# from hfos.events.system import updatesubscriptions, send
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -10,9 +10,9 @@
"""
from time import time
from hfos.component import ConfigurableComponent
from hfos.logger import error, warn
# from hfos.logger import error, warn
# from time import time
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -14,7 +14,7 @@
# from hfos.database import objectmodels
# from datetime import datetime
# from hfos.events import updatesubscriptions, send
# from hfos.events.system import updatesubscriptions, send
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -13,7 +13,8 @@
from hfos.database import objectmodels
from hfos.logger import hfoslog, error, warn, critical
from datetime import datetime
from hfos.events import updatesubscriptions, send
from hfos.events.system import updatesubscriptions, AuthorizedEvents, authorizedevent
from hfos.events.client import send
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -36,6 +37,10 @@
}
class libraryrequest(authorizedevent):
pass
class Library(ConfigurableComponent):
"""
The Library manages stored media objects
@@ -58,6 +63,8 @@ def __init__(self, *args):
super(Library, self).__init__("LIB", *args)
self.config.creator = "Hackerfleet"
AuthorizedEvents['library'] = libraryrequest
self.log("Started")
def libraryrequest(self, event):
@@ -3,26 +3,45 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/alert" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/chat" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dash" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/library" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maps" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/nmea" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/project" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/robot" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/shareables" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/wiki" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/navdata" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/comms" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/camera" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/ldap" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/busrepeater" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/countables" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dev" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/garden" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/switchboard" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/alert/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/busrepeater/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/camera/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/chat/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/chat/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/comms/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dev/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dev/templates" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/crew/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/library/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/countables/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/countables/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/crew/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/ldap/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/logbook/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/garden/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dash/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/crew/docs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/logbook/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/garden/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dash/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/library/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/dash/docs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maps/docs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/logbook/docs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maps/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/maps/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/navdata/docs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/navdata/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/navdata/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/nmea/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/project/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/project/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/protocols/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/robot/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/robot/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/shareables/frontend" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/shareables/hfos" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/wiki/hfos" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -0,0 +1,66 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from circuits import Event
from hfos.logger import hfoslog, events
from hfos.events.system import authorizedevent
__license__ = """
Hackerfleet Operating System
============================
Copyright (C) 2011 - 2016 riot <riot@hackerfleet.org> and others.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# UI events
class navdatarequest(authorizedevent):
def __init__(self, *args):
super(navdatarequest, self).__init__(*args)
hfoslog('Navdatarequest created:', args, emitter='NAVDATA', lvl=events)
# Internal Navigation Events
class sensordata(Event):
"""New sensordata has been parsed"""
def __init__(self, data, timestamp, bus):
"""
:param data: Parsed NMEA? Data
"""
super(sensordata, self).__init__()
self.data = data
self.timestamp = timestamp
self.bus = bus
class referenceframe(Event):
"""New sensordata has been parsed"""
def __init__(self, data):
"""
:param data: Parsed NMEA? Data
"""
super(referenceframe, self).__init__()
self.data = data
hfoslog("[NAVDATA-EVENT] Reference frame generated: ", data,
lvl=events)
@@ -19,9 +19,9 @@
from decimal import Decimal
from hfos.component import ConfigurableComponent
from hfos.database import ValidationError
from hfos.events import sensordata
from hfos.logger import hfoslog, verbose, debug, warn, critical, error, hilight
from pprint import pprint
from hfos.navdata.events import sensordata
# from pprint import pprint
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -33,27 +33,27 @@
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
class MachineroomEvent(Event):
class machineroomevent(Event):
"""
:param value:
:param args:
"""
def __init__(self, value, *args):
super(MachineroomEvent, self).__init__(*args)
super(machineroomevent, self).__init__(*args)
self.controlvalue = value
class machine(MachineroomEvent):
class machine(machineroomevent):
"""Skipper wants us to change the engine speed/direction"""
class pump(MachineroomEvent):
class pump(machineroomevent):
"""Skipper wants us to turn on/off the coolant pump"""
class rudder(MachineroomEvent):
class rudder(machineroomevent):
"""Skipper wants us to change the rudder angle"""
@@ -13,10 +13,28 @@
from hfos.component import ConfigurableComponent
from hfos.logger import error, warn, critical
from hfos.events import remotecontrolupdate, send
from hfos.events.system import AuthorizedEvents, authorizedevent
from circuits import Event
from hfos.events.client import send
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
# Remote Control requests
class remotecontrolrequest(authorizedevent):
"""A client wants to remote control a servo"""
# Remote Control events
class remotecontrolupdate(Event):
"""A client wants to remote control a servo"""
def __init__(self, controldata, *args):
super(remotecontrolupdate, self).__init__(*args)
self.controldata = controldata
class RemoteControlManager(ConfigurableComponent):
"""
@@ -34,6 +52,8 @@ def __init__(self, *args):
self.remotecontroller = None
AuthorizedEvents['remotectrl'] = remotecontrolrequest
self.log("Started")
def clientdisconnect(self, event):
@@ -12,7 +12,7 @@
from hfos.component import ConfigurableComponent
# from hfos.database import objectmodels
# from hfos.logger import hfoslog, error, warn, critical, events
# from hfos.events import AuthorizedEvent, AuthorizedEvents
# from hfos.events.system import AuthorizedEvent, AuthorizedEvents
# from pprint import pprint
__author__ = "Heiko 'riot' Weinen <riot@hackerfleet.org>"
@@ -13,7 +13,7 @@
from uuid import uuid4
from hfos.component import ConfigurableComponent
from hfos.logger import hfoslog, error, warn
from hfos.events import send
from hfos.events.client import send
from hfos.database import ValidationError, objectmodels
import pymongo

0 comments on commit aa053d5

Please sign in to comment.