Subversion Repositories HomeAutomation

Rev

Rev 740 | Rev 742 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 740 Rev 741
Line 22... Line 22...
22
   
22
   
23
    cfg = None
23
    cfg = None
24
    nodeIf = None
24
    nodeIf = None
25
    ifNotifier = None
25
    ifNotifier = None
26
    terminated = False
26
    terminated = False
-
 
27
   
27
    command_list = []
28
    command_list = []
28
    command_map = {}
29
    command_map = {}
-
 
30
    CMDLIST_NAME = 0
-
 
31
    CMDLIST_HANDLER = 1
-
 
32
    CMDLIST_PARAMINFO = 2
-
 
33
    CMDLIST_HELP = 3
-
 
34
 
-
 
35
    logHelp = 'usage:\t log [options]\n\n' \
-
 
36
              '\t options:\n' \
-
 
37
              '\t level <num>, where: 0 < num < 3\n'
-
 
38
    stateHelp = 'usage: state [name/add/rem]'
-
 
39
    filterHelp = 'usage: filter [name/add/rem]'
-
 
40
    addifHelp = 'usage: addif [name] [options]'
-
 
41
    addbridgeHelp = 'usage: addbridge [interface names]'
-
 
42
    tcpdHelp = 'usage: tcpd [start/stop/configure] [options]'
-
 
43
    tlsdHelp = 'usage: tlsd [start/stop/configure] [options]'
-
 
44
    canctldHelp = 'usage: canctld [start/stop/configure] [options]'
-
 
45
    simHelp = 'usage: sim [record/play/add/rem/save/load] [options]'
29
    help_command_map = {}
46
    help_command_map = {}
30
 
47
   
-
 
48
    logOptions = {}
-
 
49
    ifOptions = {}
-
 
50
    bridgeOptions = {}
-
 
51
    tcpdOptions = {}
-
 
52
    tlsdOptions = {}
-
 
53
    canctldOptions = {}
-
 
54
    simOptions = {}
-
 
55
 
-
 
56
    logValidOptions = {'level' : ['range', 0, 3]}
-
 
57
    ifValidOptions = {'type' : ['alt', 'serial','udp']}
-
 
58
   
-
 
59
    ifSerialOptions = {'' : []}
-
 
60
    ifCanStimOptions = {'' : []}
-
 
61
    ifTelnetOptions = {'' : []}
-
 
62
    ifTcpTlsOptions = {'' : []}
-
 
63
    ifUDPOptions = {'' : []}
-
 
64
   
-
 
65
    bridgeValidOptions = {'' : ['']}
-
 
66
    tcpdValidOptions = {'' : []}
-
 
67
    tlsdValidOptions = {'' : []}
-
 
68
    canctldValidOptions = {'' : []}
-
 
69
    simValidOptions = {'' : []}
-
 
70
 
31
    def __init__ (self):
71
    def __init__ (self):
-
 
72
       
32
        self.command_list = [['help', self.helpCmd, 'display help'],
73
        self.command_list = [['help', self.helpCmd, '', 'display help'],
33
                       ['log', self.logCmd, 'log control: \"help log\"'],
74
                       ['log', self.logCmd, '<options>', 'log control: \"help log\"'],
34
                       ['exec', self.execCmd,  'run command listing <filename>\n'],
75
                       ['exec', self.execCmd, '<filename>', 'run command listing\n'],
35
                       ['filter', self.filterCmd, 'filter commands: \"help filter\"'],
76
                       ['filter', self.filterCmd, '<cmd>', 'filter commands: \"help filter\"'],
36
                       ['state', self.stateCmd, 'state commands: \"help state\"\n'],
77
                       ['state', self.stateCmd, '<cmd>', 'state commands: \"help state\"\n'],
37
                       ['addif', self.ifAddCmd, 'add interface: \"help addif\"'],
78
                       ['addif', self.ifAddCmd, '<options>', 'add interface: \"help addif\"'],
38
                       ['remif', self.ifRemCmd, 'remove interface <name>'],
79
                       ['remif', self.ifRemCmd, '<name>', 'remove interface'],
39
                       ['ifup', self.ifUpCmd, 'bring up interface <name>'],
80
                       ['ifup', self.ifUpCmd, '<name>', 'bring up interface'],
40
                       ['ifdown', self.ifDownCmd, 'bring down interface <name>\n'],
81
                       ['ifdown', self.ifDownCmd, '<name>', 'bring down interface\n'],
41
                       ['addbrigde', self.addBridgeCmd, 'add bridge: \"help addbridge\"'],
82
                       ['addbrigde', self.addBridgeCmd, '<options>', 'add bridge: \"help addbridge\"'],
42
                       ['rembridge', self.remBridgeCmd, 'remove bridge <name>\n'],
83
                       ['rembridge', self.remBridgeCmd, '<id>', 'remove bridge\n'],
43
                       ['tcpd', self.tcpdCmd, 'tcpd server control: \"help tcpd\"'],
84
                       ['tcpd', self.tcpdCmd, '<cmd>', 'tcpd server control: \"help tcpd\"'],
44
                       ['tlsd', self.tlsdCmd, 'tlsd server control: \"help tlsd\"'],
85
                       ['tlsd', self.tlsdCmd, '<cmd>', 'tlsd server control: \"help tlsd\"'],
45
                       ['canctld', self.canCtldCmd, 'canctld server control: \"help canctld\"\n'],
86
                       ['canctld', self.canCtldCmd, '<cmd>', 'canctld server control: \"help canctld\"\n'],
46
                       ['status', self.statusCmd, 'show daemon status'],
87
                       ['status', self.statusCmd, '', 'show daemon status'],
47
                       ['stats', self.statsCmd, 'show statistics\n'],
88
                       ['stats', self.statsCmd, '', 'show statistics\n'],
48
                       ['nodelist', self.nodesCmd, 'list can nodes'],
89
                       ['nodelist', self.nodesCmd, '', 'list can nodes'],
49
                       ['filterlist', self.filterlistCmd, 'list active filters\n'],
90
                       ['filterlist', self.filterlistCmd, '', 'list active filters\n'],
50
                       ['sim', self.simCmd, 'simulator commands: \"help sim\"']]
91
                       ['sim', self.simCmd, '<cmd>', 'simulator commands: \"help sim\"']]
51
       
92
       
52
        index = 0
93
        index = 0
53
        for cmd in self.command_list:
94
        for cmd in self.command_list:
54
            self.command_map[cmd[0]] = index
95
            self.command_map[cmd[0]] = index
55
            index += 1
96
            index += 1
56
 
97
 
57
        logHelp = 'not implemented'
-
 
58
        stateHelp = 'not implemented'
98
        self.help_command_map = {'log' : self.logHelp,
59
        addifHelp = 'not implemented'
-
 
60
        addbridgeHelp = 'not implemented'
-
 
61
        tcpdHelp = 'not implemented'
-
 
62
        tlsdHelp = 'not implemented'
-
 
63
        canctldHelp = 'not implemented'
-
 
64
        simHelp = 'not implemented'
-
 
65
        self.help_command_map = {'log' : logHelp,
99
                                'filter' : self.filterHelp,
66
                                'state' : stateHelp,
100
                                'state' : self.stateHelp,
67
                                'addif' : addifHelp,
101
                                'addif' : self.addifHelp,
68
                                'addbridge' : addbridgeHelp,
102
                                'addbridge' : self.addbridgeHelp,
69
                                'tcpd' : tcpdHelp,
103
                                'tcpd' : self.tcpdHelp,
70
                                'tlsd' : tlsdHelp,
104
                                'tlsd' : self.tlsdHelp,
71
                                'canctld' : canctldHelp,
105
                                'canctld' : self.canctldHelp,
72
                                'sim' : simHelp}
106
                                'sim' : self.simHelp}
73
 
107
 
74
        self.cfg = DaemonConfig()
108
        self.cfg = DaemonConfig()
75
   
109
   
76
    class IfNotifier():
110
    class IfNotifier():
77
        """ Used by if threads to send messages to the main program thread """
111
        """ Used by if threads to send messages to the main program thread """
78
        UNDEFINED = 0
112
        UNDEFINED = 0
79
        TERMINATE = 1
113
        TERMINATE = 1
80
   
114
   
81
        def notify(self, msg):
115
        def notify(self, msg):
82
            if msg == self.TERMINATE:
116
            if msg == self.TERMINATE:
83
                print 'Main terminate notify'
117
                print 'Main terminate notify'
84
                self.terminated = True
118
                self.terminated = True
85
            else:
119
            else:
86
                print 'UNDEFINED NOTIFY'
120
                print 'UNDEFINED NOTIFY'
87
       
121
       
88
   
122
   
89
    def __rightAdjust(self, refstr, str):
123
    def __rightAdjust(self, refstr, str):
90
        spcstr = ''
124
        spcstr = ''
91
        endpos = 20-len(refstr)
125
        endpos = 25-len(refstr)
92
        for i in range(1,endpos):
126
        for i in range(1,endpos):
93
            if i == endpos-5:
127
            if i == endpos-5:
94
                spcstr += ':'
128
                spcstr += ':'
95
            else:
129
            else:
96
                spcstr += ' '
130
                spcstr += ' '
97
        return (spcstr+str)
131
        return (spcstr+str)
98
   
132
   
99
    def helpCmd(self, *args):
133
    def helpCmd(self, *args):
-
 
134
        try:
100
        args = args[0]
135
            args = args[0]
-
 
136
        except:
-
 
137
            args = []
101
        if len(args) < 1:
138
        if len(args) < 1:
102
            quitStr = 'quit, exit'
139
            quitStr = 'quit, exit'
103
            print quitStr, self.__rightAdjust(quitStr, 'shutdown pyCanDaemon')
140
            print quitStr, self.__rightAdjust(quitStr, 'shutdown pyCanDaemon')
104
            for cmd in self.command_list:
141
            for cmd in self.command_list:
-
 
142
                cmdstr = cmd[self.CMDLIST_NAME] + ' ' + cmd[self.CMDLIST_PARAMINFO]
-
 
143
                print cmdstr, \
105
                print cmd[0], self.__rightAdjust(cmd[0], cmd[2])
144
                      self.__rightAdjust(cmdstr, cmd[self.CMDLIST_HELP])
106
        elif len(args) < 2:
145
        elif len(args) < 2:
107
            subCmd = args[0]
146
            subCmd = args[0]
108
            if self.help_command_map.has_key(subCmd):
147
            if self.help_command_map.has_key(subCmd):
109
                print self.help_command_map[subCmd]
148
                print self.help_command_map[subCmd]
110
            else:
149
            else:
111
                print 'no help for ' + subCmd
150
                print 'no help for ' + subCmd
112
        else:
151
        else:
113
            print 'usage: help [topic]'
152
            print 'usage: help [topic]'
114
 
153
 
115
    def filterCmd(self, *args):
154
    def filterCmd(self, *args):
-
 
155
        try:
-
 
156
            args = args[0]
-
 
157
        except:
-
 
158
            args = []
-
 
159
        log.debug('filterCmd ' + str(args))
-
 
160
        if len(args) < 2:
-
 
161
            print 'Invalid arguments\n' + self.filterHelp
-
 
162
            return
116
        cmd = args[0]
163
        cmd = args[0]
117
        filterName = args[1]
164
        filterName = args[1]
118
        # FIXME: verify 
165
        # FIXME: verify 
119
        if cmd == 'add':
166
        if cmd == 'add':
120
            print 'Importing filter: ' + filterName
167
            print 'Importing filter: ' + filterName
121
            self.cfg.filterCfg.importFilter(filterName)
168
            self.cfg.filterCfg.importFilter(filterName)
122
        elif cmd == 'rem' or cmd == 'remove':
169
        elif cmd == 'rem' or cmd == 'remove':
123
            print 'Deleting filter: ' + filterName
170
            print 'Deleting filter: ' + filterName
124
            # FIXME: actually delete
171
            # FIXME: actually delete
-
 
172
            raise 'Not implemented'
125
   
173
   
126
    def stateCmd(self, *args):
174
    def stateCmd(self, *args):
-
 
175
        try:
-
 
176
            args = args[0]
-
 
177
        except:
-
 
178
            args = []
-
 
179
        log.debug('stateCmd ' + str(args))
-
 
180
        if len(args) < 2:
-
 
181
            print 'Invalid arguments\n' + self.stateHelp
-
 
182
            return
127
        cmd = args[0]
183
        cmd = args[0]
128
        spaceName = args[1]
184
        spaceName = args[1]
-
 
185
        # FIXME: verify 
129
        if cmd == 'add':
186
        if cmd == 'add':
130
            print 'Importing state space: ' + spaceName
187
            print 'Importing state space: ' + spaceName
131
            self.cfg.stateSpaceCfg.importSpace(spaceName)
188
            self.cfg.stateSpaceCfg.importSpace(spaceName)
132
        elif cmd == 'rem' or cmd == 'remove':
189
        elif cmd == 'rem' or cmd == 'remove':
133
            print 'Deleting state space: ' + spaceName
190
            print 'Deleting state space: ' + spaceName
134
            # FIXME: actually delete statespace
191
            # FIXME: actually delete statespace
-
 
192
            raise 'Not implemented'
135
   
193
   
136
    def ifAddCmd(self, *args):
194
    def ifAddCmd(self, *args):
137
        print 'not implemented'
195
        raise 'not implemented'
138
   
196
   
139
    def ifRemCmd(self, *args):
197
    def ifRemCmd(self, *args):
140
        print 'not implemented'
198
        raise 'not implemented'
141
 
199
 
142
    def ifUpCmd(self, *args):
200
    def ifUpCmd(self, *args):
143
        print 'not implemented'
201
        raise 'not implemented'
144
 
202
 
145
    def ifDownCmd(self, *args):
203
    def ifDownCmd(self, *args):
146
        print 'not implemented'
204
        raise 'not implemented'
147
        pass
-
 
148
   
205
   
149
    def addBridgeCmd(self, *args):
206
    def addBridgeCmd(self, *args):
150
        print 'not implemented'
207
        raise 'not implemented'
151
 
208
 
152
    def remBridgeCmd(self, *args):
209
    def remBridgeCmd(self, *args):
153
        print 'not implemented'
210
        raise 'not implemented'
154
   
211
   
155
    def tcpdCmd(self, *args):
212
    def tcpdCmd(self, *args):
156
        print 'not implemented'
213
        raise 'not implemented'
157
   
214
   
158
    def tlsdCmd(self, *args):
215
    def tlsdCmd(self, *args):
159
        print 'not implemented'
216
        raise 'not implemented'
160
   
-
 
161
    def canCtldCmd(self, *args):
-
 
162
        print 'not implemented'
-
 
163
   
217
   
164
    def statusCmd(self, *args):
218
    def canCtldCmd(self, *args):
165
        print 'not implemented'
219
        raise 'not implemented'
166
   
220
   
167
    def statsCmd(self, *args):
221
    def statusCmd(self, *args):
168
        print 'not implemented'
222
        raise 'not implemented'
169
   
223
   
170
    def nodesCmd(self, *args):
224
    def statsCmd(self, *args):
171
        print 'not implemented'
225
        raise 'not implemented'
172
   
226
   
173
    def filterlistCmd(self, *args):
227
    def nodesCmd(self, *args):
174
        print 'not implemented'
228
        raise 'not implemented'
175
   
229
   
176
    def simCmd(self, *args):
230
    def filterlistCmd(self, *args):
177
        print 'not implemented'
231
        raise 'not implemented'
178
   
232
   
-
 
233
    def simCmd(self, *args):
-
 
234
        raise 'not implemented'
-
 
235
   
179
    def logCmd(self, *args):
236
    def logCmd(self, *args):
180
        print 'not implemented'
237
        raise 'not implemented'
181
 
238
 
182
    def execCmd(self, *args):
239
    def execCmd(self, *args):
-
 
240
        raise 'not implemented'
-
 
241
   
-
 
242
    def parseCommand(self, cmdstr):
-
 
243
        incmd = cmdstr.strip()
-
 
244
        cmd = incmd.split(' ')
-
 
245
        if len(cmd[0]) < 2:
-
 
246
            return
-
 
247
        cmd[0] = cmd[0].lower()
-
 
248
        if cmd[0] == 'quit' or cmd[0] == 'exit':
-
 
249
            self.terminated = True
-
 
250
        elif self.command_map.has_key(cmd[0]):
-
 
251
            self.command_list[self.command_map[cmd[0]]][self.CMDLIST_HANDLER](cmd[1:])
183
        pass
252
        else:
-
 
253
            print 'unknown command: ' + cmd[0]
184
   
254
   
185
    def exitHelper(self):
255
    def exitHelper(self):
186
        if self.nodeIf is not None and self.nodeIf.running():
256
        if self.nodeIf is not None and self.nodeIf.running():
187
            self.nodeIf.stop()
257
            self.nodeIf.stop()
188
           
258
           
Line 194... Line 264...
194
        self.exitHelper()
264
        self.exitHelper()
195
 #       sys.exit(-1)
265
 #       sys.exit(-1)
196
 
266
 
197
    def run(self):
267
    def run(self):
198
        try:
268
        try:
199
            demoPath = os.path.dirname(__file__)
269
            myPath = os.path.dirname(__file__)
200
            os.chdir(demoPath)
270
            os.chdir(myPath)
201
        except:
271
        except:
202
            return
272
            return
203
       
273
       
204
        print 'INIT: Start logging'
274
        print 'INIT: Start logging'
205
        log.basicConfig(level=log.DEBUG)
275
        log.basicConfig(level=log.DEBUG)
206
       
276
       
-
 
277
        """command parameters only dictate verbosity and use of config file"""
207
        print 'INIT: Get config options from command line / config file'
278
        print 'INIT: Get config options from command line / config file'
208
        try:
279
        try:
209
            opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
280
            opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
210
        except getopt.GetoptError:
281
        except getopt.GetoptError:
211
            print 'Invalid usage'
282
            print 'Invalid usage'
Line 222... Line 293...
222
                sys.exit()
293
                sys.exit()
223
            if o in ("-o", "--output"):
294
            if o in ("-o", "--output"):
224
                pass
295
                pass
225
    #            output = a
296
    #            output = a
226
 
297
 
-
 
298
        """load config defaults, or last config if exists"""
-
 
299
        """run startup.cfg"""
-
 
300
       
227
        print 'INIT: Loading filters and spaces'
301
#        print 'INIT: Loading filters and spaces'
228
#       self.cfg.filterCfg.importFilter('DefaultFilter')
302
#       self.cfg.filterCfg.importFilter('DefaultFilter')
229
#       self.cfg.stateSpaceCfg.importSpace('DefaultStateSpace')
303
#       self.cfg.stateSpaceCfg.importSpace('DefaultStateSpace')
230
        self.cfg.stateSpaceCfg.loadSpaces()
304
#        self.cfg.stateSpaceCfg.loadSpaces()
231
        self.cfg.filterCfg.loadFilters()
305
#        self.cfg.filterCfg.loadFilters()
232
        self.cfg.setupFilterBindings()
306
#        self.cfg.setupFilterBindings()
233
        self.cfg.setupFilterChain()
307
#        self.cfg.setupFilterChain()
234
 
308
 
235
        print 'INIT: Starting selected can interface'
309
#        print 'INIT: Starting selected can interface'
236
        ''' nodeif thread launch '''
310
#        ''' nodeif thread launch '''
237
        self.ifNotifier = self.IfNotifier()
311
#        self.ifNotifier = self.IfNotifier()
238
        pktHandler = CanPktHandler1(self.cfg)
312
#        pktHandler = CanPktHandler1(self.cfg)
239
       
313
#        
240
        ifConfig = NodeIfCanStim.DEFAULT_CONFIG
314
#        ifConfig = NodeIfCanStim.DEFAULT_CONFIG
241
        self.nodeIf = NodeIfCanStim(ifConfig, pktHandler, self.ifNotifier)
315
#        self.nodeIf = NodeIfCanStim(ifConfig, pktHandler, self.ifNotifier)
242
 #       ifConfig = NodeIfSerial.DEFAULT_CONFIG
316
# #       ifConfig = NodeIfSerial.DEFAULT_CONFIG
243
   
317
#    
244
        atexit.register(self.exitHelper)
318
#        atexit.register(self.exitHelper)
245
        sys.excepthook = self.exceptHelper
319
#        sys.excepthook = self.exceptHelper
246
 #       self.nodeIf = NodeIfSerial(pktHandler, ifConfig)
320
 #       self.nodeIf = NodeIfSerial(pktHandler, ifConfig)
247
       
321
#        
248
        if not self.nodeIf.start():
322
#        if not self.nodeIf.start():
249
            print 'FATAL: Failed to initialize node interface.'
323
#            print 'FATAL: Failed to initialize node interface.'
250
            print 'This may indicate that the interface is unavailable, ' \
324
#            print 'This may indicate that the interface is unavailable, ' \
251
                  'or that you do not have permission to access it.'
325
#                  'or that you do not have permission to access it.'
252
            sys.exit(-1)
326
#            sys.exit(-1)
253
 
327
 
254
        print 'Initialize/gather info on connected can nodes and load associated state'
328
        print 'Initialize/gather info on connected can nodes and load associated state'
255
        print 'Start selected TCP and UDP server(s)'
329
        print 'Start selected TCP and UDP server(s)'
256
        # server threads launch
330
        # server threads launch
257
       
331
       
258
        print 'CanDaemon v1 ready'
332
        print 'CanDaemon v1 ready'
259
        print 'Enter command or type \"help\" for a list of commands'
333
        print 'Enter command or type \"help\" for a list of commands'
260
        while not self.terminated:
334
        while not self.terminated:
261
            input = raw_input('> ').strip().lower()
335
            input = raw_input('> ')
262
            cmd = input.split(' ')
-
 
263
            if len(cmd[0]) < 2:
-
 
264
                continue
-
 
265
            if cmd[0] == 'quit' or cmd[0] == 'exit':
-
 
266
                self.terminated = True
-
 
267
            elif self.command_map.has_key(cmd[0]):
-
 
268
                self.command_list[self.command_map[cmd[0]]][1](cmd[1:])
-
 
269
            else:
-
 
270
                print 'unknown command: ' + cmd[0]
-
 
271
 
-
 
272
        """ -- suggested commands -- p n = priority to implement (1 is highest)
-
 
273
            base: (p 1)
-
 
274
            filter add <name>
-
 
275
            filter rem <name>
-
 
276
            state add <name>
-
 
277
            state rem <name>
-
 
278
            state reset <name>
-
 
279
           
-
 
280
                node interfaces:  (p 1)
-
 
281
            addif <serial/sim/udp/telnet> <options> (help protocol gives options)
-
 
282
            remif <name> - delete an interface
-
 
283
            ifup <name> - bring up an interface
-
 
284
            ifdown <name> - bring down an interface
-
 
285
           
-
 
286
                bridging: (p 2)
-
 
287
            addbridge <name> <ifname1> <ifname2> <ifname3> ... - create if bridge
-
 
288
            rembridge <name>
-
 
289
           
-
 
290
                servers:
-
 
291
            tcpd start [port] - raw tcp (telnet, compat) server, all pkts  (p 1)
-
 
292
            tcpd stop
-
 
293
            tlsd start [port] - tcp+tls server, all pkts  (p 2)
-
 
294
            tlsd stop
-
 
295
            canctld start [port] - pyCanGUI server (tcp/tls)  (p 2)
-
 
296
            canctld stop
-
 
297
           
-
 
298
            info commands: (p 3)
-
 
299
            status - shows active settings, interfaces, servers
-
 
300
            stats - shows some traffic statistics
-
 
301
            nodes - shows active nodes
-
 
302
            filters - shows active filters
-
 
303
            state [name] - shows active states, opt specific state info\
-
 
304
            log - log control (TBD)
-
 
305
           
-
 
306
            simulator commands: (p 2)
336
            self.parseCommand(input)
307
            simrecord <file> - record incoming packets
-
 
308
            simplay <file> [timescale] - play recorded stream, opt accel time:
-
 
309
            simadd <nodeid> (nodetype)
-
 
310
            simrem <nodeid>
-
 
311
            simsave <config>
-
 
312
            simload <config>
-
 
313
        """
-
 
314
 
-
 
315
        """ -- other features --
-
 
316
            startup.cfg - script to run at startup (command listing)
-
 
317
            ie: ifup 0
-
 
318
                tlsd start
-
 
319
                canguid start
-
 
320
            config.cfg - last daemon config (param override)
-
 
321
            default.cfg - default daemon config (only read if config.cfg does not exist)
-
 
322
        """
-
 
323
 
337
 
324
        print 'Shutdown'
338
        print 'Shutdown'
325
        if self.nodeIf.running():
339
#        if self.nodeIf.running():
326
            print 'Stopping If thread'
340
#            print 'Stopping If thread'
327
            self.nodeIf.stop()
341
#            self.nodeIf.stop()
328
 
342
 
329
        self.cfg.stateSpaceCfg.saveSpaces()
343
#        self.cfg.stateSpaceCfg.saveSpaces()
330
        self.cfg.filterCfg.saveFilters()
344
#        self.cfg.filterCfg.saveFilters()
331
       
345
       
332
        print 'Waiting 0.1..'
346
        print 'Waiting 0.1..'
333
        time.sleep(0.1) # wait for threads
347
        time.sleep(0.1) # wait for threads
334
        print 'Terminating'
348
        print 'Terminating'
335
        sys.exit(0) # will except if there are threads remaining
349
        sys.exit(0) # will except if there are threads remaining