Beispiel #1
0
def main():
    #
    global running
    running = False
    #
    chans = prolog()
    #
    # init threads' list and CTRL+C handler
    # threaded parts are not getting signals:
    # -> all threads are daemonized
    # -> the stop_event Event() signals each thread to stop listening over USB
    threads = []
    stop_event = Event()
    interpreter._THREADED = True
    interpreter._STOP_EVENT = stop_event
    GPS_reader._THREADED = True
    GPS_reader._STOP_EVENT = stop_event
    receiver._THREADED = True
    receiver._STOP_EVENT = stop_event
    #
    def int_handler(signum, frame):
        print('SIGINT: quitting')
        stop_event.set()
        #for c, t in threads:
        #    print('stopping thread: %s' % repr(t))
        global running
        running = False
    signal.signal(signal.SIGINT, int_handler)
    #
    running = True
    # start interpreter (/server)
    interp = interpreter()
    threads.append( (interp, threadit(interp.process)) )
    #
    # start gps reader
    gps = GPS_reader()
    receiver.GPS = gps
    threads.append( (gps, threadit(gps.listen)) )
    #
    # start CC2531 receivers
    ccs = prepare_receiver(chans)
    for cc in ccs:
        threads.append( (cc, threadit(cc.listen)) )
    #
    # loop infinitely until SIGINT is caught
    # this loop lets all daemonized threads running
    while running:
        sleep(1)
    #
    # finally, wait for each thread to stop properly after they received
    # the stop_event signal
    for c, t in threads:
        t.join()
Beispiel #2
0
 def __init__(self, botBrain): 
     self.botBrain = botBrain
     self.bot = onedBot(self.botBrain)
     self.intprt = interpreter()
     sensorVal = self.intprt.getInitialSensor()
     self.bot.brain.setSensorValues(sensorVal)
     # graphics
     fig=plt.figure(1)
     fig.clf()
     ax=fig.add_subplot(111)
     ax.axis('scaled')
     # modify size of the world here
     w = config.WIDTH
     h = config.HEIGHT
     ax.axis([-w/2-10, w/2+10, -h/2-10, h/2+10])
     plt.grid()
     ax.add_artist(self.bot.shape)
     plt.show()
                directory_prepare()
                # clean up target

                start_time = time.time()
                total_event = 0

                p = parser()
                parsed_result = p.parsingFile(data_path + file_name)
                p.structurePrettyPrint(parsed_result)

                db = database(db_name)
                v = validator(p, db)
                v.validate_rule_parameters()
                v.validate_source_database()

                i = interpreter(p, db)
                i.field_mappings()

                i.events_generator()
                total_event += i.event_count

                sorting_csv_files()
                exe_time = time.time() - start_time
                execution_time.append(exe_time)
                count_dir_lines()
                directory_prepare(True)
                time.sleep(1)
            save_experiment_to_csv(
                "per_db_per_rule",
                [db_name, file_name, str(total_event)])
            save_experiment_to_csv("per_db_per_rule", execution_time)
Beispiel #4
0
from simple_rdbms import *
from interpreter import *

sdb = SimpleRDBMS() #Singleton RDBMS
bc = BackupCreator()
visitor = Visitor(sdb,bc)

#Start up the interpreter
interpreter(visitor)
Beispiel #5
0
from simple_rdbms import *
from interpreter import *

sdb = SimpleRDBMS()  #Singleton RDBMS
bc = BackupCreator()
visitor = Visitor(sdb, bc)

#Start up the interpreter
interpreter(visitor)
Beispiel #6
0
import psycopg2
from config import config
from init import init
import sys
import json.decoder
from json_objects import *
from functions import *
from interpreter import *

# more than 2 args:
# arg[0] is the name of the file,
# arg[1] = '--init',
# arg[2] is the name of the file with input

try:
    if len(sys.argv) == 2:
        if (sys.argv[1] == '--init'):
            interpreter()
        else:
            print(
                ERROR_status(
                    'Wrong program argument! The data base is closed'))
    elif len(sys.argv) == 1:
        interpreter()
    else:
        print(ERROR_status(""))

except (Exception, psycopg2.DatabaseError, EOFError) as error:
    print(ERROR_status(str(error)))