Exemplo n.º 1
0
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()
Exemplo n.º 2
0
Arquivo: SAX.py Projeto: 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()
Exemplo n.º 3
0
def UploadData(Data):
    SensorController.Display_LCD1602("Data Uploading..", 3)
    url = "https://iot.pomelo072.top/FGD/upload?device_id=" + str(
        Data[0]) + "&temperature=" + str(Data[1]) + "&humidity=" + str(
            Data[2]) + "&light=" + str(Data[3]) + "&solid=" + str(Data[4])
    response = urequests.get(url)
    print(response.json())
    SensorController.Display_LCD1602("Data Uploading..\nSuccess.", 1)
Exemplo n.º 4
0
def do_connect(essid, password):
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        SensorController.Display_LCD1602('connecting to\nnetwork...', 2)
        sta_if.active(True)
        sta_if.connect(essid, password)
        while not sta_if.isconnected():
            pass
    SensorController.Display_LCD1602("WIFI connected.", 1)
    SensorController.Display_LCD1602('network config\n' + sta_if.ifconfig()[0],
                                     2)
Exemplo n.º 5
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)
Exemplo n.º 6
0
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
Exemplo n.º 7
0
Arquivo: SAX.py Projeto: 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
Exemplo n.º 8
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)
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
0
def main():
    try:
        WIFISSID, WIFIPassWord, ReloadTime = LoadJSON.LoadJSON()
        LCD = machine.Pin(13, machine.Pin.OUT)
        LCD.on()
        ConnectWIFI.do_connect(WIFISSID, WIFIPassWord)
        SensorData = SensorController.SensorController()
        UploadData.UploadData(SensorData)
        LCD.off()
    except:
        machine.reset()
    else:
        DeepSleep.deepsleep(300)
Exemplo n.º 12
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)
Exemplo n.º 13
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)