Пример #1
0
Файл: SAX.py Проект: fganz/UMWSN
def compareTwoRooms(id1, id2):
    symbol_count = 6
    phrase_length = 12
    samples = 30
    entries = SensorController.getEntriesFromId(id1, samples, 1)
    nd = []
    for e in entries:
        nd.append(int(e["value"]))

    entries = SensorController.getEntriesFromId(id2, samples, 1)
    nd2 = []
    for e in entries:
        nd2.append(int(e["value"]))

    sax1 = convertToSax(phrase_length, symbol_count, nd)
    sax2 = convertToSax(phrase_length, symbol_count, nd2)
    print sax1[1][0]
    print sax2[1][0]

    lookupTable = createLookup(symbol_count, sax1[0])
    print saxDistance(sax1[1][0], sax2[1][0], samples, lookupTable, phrase_length, symbol_count)

    pp = convertSaxBackToContinious(phrase_length, symbol_count, nd)
    pp1 = convertSaxBackToContinious(phrase_length, symbol_count, nd2)
    ts1 = pandas.Series(pp)
    ts2 = pandas.Series(pp1)
    ts1.plot(label="First Argument")
    ts2.plot(label="Second Argument")
    plt.legend(loc="upper left")
    plt.show()
Пример #2
0
    def eventProcessing1(self):

        for n in SensorController.getAvailableNodes():
            #print n,Loop.getEntriesFromId(n).count()
            if SensorController.getEntriesFromId(n).count() >= frame_length:

                data = check(n, frame_length)
                (points, cur) = SAX.convertToSax(phrase_length,symbol_count, data)
                #print n, cur[0]
                lookupTable = SAX.createLookup(symbol_count,points)
                #print SAX.convertSaxBackToContinious(phrase_length, symbol_count, data)
               # print SAX.saxDistance(cur[0],"aaaddddddd",frame_length,lookupTable,phrase_length,symbol_count),n
                if SAX.saxDistance(cur[0],"aaaddddddd",frame_length,lookupTable,phrase_length,symbol_count) < 2:
                 #   print "something happening at sensor "+str(n)
                    thereIsMovementIn(n)
Пример #3
0
Файл: SAX.py Проект: fganz/UMWSN
def check(id):
    entries = SensorController.getEntriesFromId(id,10,1)
    nd = []
    for e in entries:
            nd.append((float(e["value"])))
    if checkEqual3(nd):
        nd[0] = (nd[0]+0.1)
    return nd
Пример #4
0
def check(id, frames):

    entries = SensorController.getEntriesFromId(id,frames,1)
    nd = []

    for e in entries:
        if e["value"] is not None:
            nd.append((float(e["value"])))
            if nd[1:] == nd[:-1]:
                nd[0] = (nd[0]+0.1)
    return nd
Пример #5
0
 def run(self):
     while not self.event.is_set():
         for n in SensorController.getAvailableNodes():
             self.eventProcessing1()
         self.event.wait(self.number_of_seconds_to_wait)