source: subversion/applications/routing/pyroute/base.py @ 5746

Last change on this file since 5746 was 5746, checked in by ojw, 12 years ago

Move the events-handler into its own module

File size: 1.8 KB
Line 
1#!/usr/bin/python
2#-----------------------------------------------------------------------------
3# Projection code (lat/long to screen conversions)
4#
5# Usage:
6#   * Derive all pyroute modules fom this class
7#   * Put "pyrouteModule.__init__(self,modules)" in your init function
8#   * Instantiate using modules.append(yourmodule(modules))
9#      where "modules" is the list of all pyroute modules
10#
11# Features:
12#   * Get and set data from the global table
13#   * Send messages or trigger events
14#   * Access other modules (using "self.m['modulename']")
15#-----------------------------------------------------------------------------
16# Copyright 2007, Oliver White
17#
18# This program is free software: you can redistribute it and/or modify
19# it under the terms of the GNU General Public License as published by
20# the Free Software Foundation, either version 3 of the License, or
21# (at your option) any later version.
22#
23# This program is distributed in the hope that it will be useful,
24# but WITHOUT ANY WARRANTY; without even the implied warranty of
25# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26# GNU General Public License for more details.
27#
28# You should have received a copy of the GNU General Public License
29# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30#----------------------------------------------------------------------------
31class pyrouteModule:
32  def __init__(self, modules):
33    self.= modules
34  def reportModuleConnectivity(self):
35    for name, data in self.m.items():
36      print "* %s" % name
37  def get(self, name, default=None):
38    return(self.m['data'].getData(name, default))
39  def set(self, name, value):
40    return(self.m['data'].setData(name, value))
41  def action(self, message):
42    self.m['events'].handleEvent(message)
43  def ownPos(self):
44    return(self.m['position'].get())
Note: See TracBrowser for help on using the repository browser.