Changeset 19

Show
Ignore:
Timestamp:
09/17/07 06:24:21 (1 year ago)
Author:
devja..@anarkystic.com
Message:

added simple network connection sensor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fizzjik/fizzjik/event.py

    r17 r19  
    1717        return False 
    1818 
     19class ExceptionEvent(Event): 
     20    pass 
     21 
    1922class ServiceStartEvent(Event): 
    2023    pass 
  • fizzjik/fizzjik/hub.py

    r17 r19  
    2626    def startService(self, *args, **kw): 
    2727        service.MultiService.startService(self, *args, **kw) 
    28         self.observe(ServiceStartEvent(self.__class__)) 
     28        #self.observe(ServiceStartEvent(self.__class__)) 
    2929     
    3030    def stopService(self, *args, **kw): 
    3131        service.MultiService.stopService(self, *args, **kw) 
    32         self.observe(ServiceStopEvent(self.__class__)) 
     32        #self.observe(ServiceStopEvent(self.__class__)) 
    3333 
    3434    def observe(self, evt): 
  • fizzjik/fizzjik/input/basic.py

    r17 r19  
    11from twisted.protocols import basic 
    2 from twisted.internet import protocol 
     2from twisted.internet import protocol, task 
    33 
    44from twisted.application import internet 
     
    66from fizzjik.interfaces import IInput, implements 
    77from fizzjik.event import Event 
    8 from fizzjik.config import ConfigurableTCPServer 
     8from fizzjik.config import ConfigurableTCPServer, ConfigurableService, \ 
     9        if_config 
    910 
    1011 
     
    3940 
    4041 
     42class Input(ConfigurableService): 
     43    implements(IInput) 
     44 
     45    def observe(self, evt): 
     46        self.parent.observe(evt) 
     47 
     48class PollingInput(Input): 
     49    delay = 10 
     50    startDelayed = True 
     51 
     52    def __init__(self): 
     53        self.poller = task.LoopingCall(self.poll) 
     54 
     55    @if_config('enabled') 
     56    def startService(self): 
     57        Input.startService(self) 
     58        self.poller.start(self.delay, not self.startDelayed) 
     59     
     60    @if_config('enabled') 
     61    def stopService(self): 
     62        Input.stopService(self) 
     63        self.poller.stop() 
     64 
     65    def poll(self): 
     66        self.observe(Event("POLL")) 
  • fizzjik/fizzjik/input/sonmicro.py

    r17 r19  
    3636    @if_config("enabled") 
    3737    def stopService(self): 
    38         self._stopReadLoop() 
     38        if self.running: 
     39            self._stopReadLoop() 
    3940        SerialPortClient.stopService(self) 
    4041 
  • fizzjik/fizzjik/serial.py

    r17 r19  
    77from fizzjik.interfaces import IInput, IConfigurable, implements 
    88from fizzjik.config import ConfigurableMixin, if_config 
     9from fizzjik.event import ServiceStartEvent, ServiceStopEvent, ExceptionEvent 
    910 
    1011 
     
    2829        if self.config: 
    2930            protoInst.receiveConfig(self.config) 
    30  
    31         return getattr(reactor, 'connect'+self.method)(SerialPortConnector
    32                                                        protoInst
    33                                                        self.device
    34                                                        *self.args, 
    35                                                        **self.kwargs) 
     31            return getattr(reactor, 'connect'+self.method)(SerialPortConnector, 
     32                                                           protoInst
     33                                                           self.device
     34                                                           *self.args
     35                                                           **self.kwargs) 
     36             
    3637 
    3738    startService = if_config("enabled", GenericClient.startService) 
     39 
    3840 
    3941    def observe(self, evt): 
  • fizzjik/test.cfg

    r17 r19  
    1313 
    1414[SonMicroMifareSensor] 
    15 enabled = Tru
     15enabled = Fals
    1616#device = /dev/tty.USA19H1d1P1.1 
    1717device = /dev/tty.usbserial-A3Q5UJ69 
  • fizzjik/test.py

    r17 r19  
    1717from fizzjik.input.bluetooth import BluetoothSensor 
    1818from fizzjik.input.basic import LineReceiver 
     19from fizzjik.input.network import NetworkConnectionSensor 
     20 
    1921from fizzjik.output.basic import Echo 
    2022from fizzjik.output.growl import GrowlService 
     
    3335#easyident.setServiceParent(hub) 
    3436 
     37network = NetworkConnectionSensor() 
     38network.setServiceParent(hub) 
     39 
    3540echo = Echo() 
    3641echo.setServiceParent(hub)