Ejemplo n.º 1
0
    def testDirectCommunication(self):

        eventSink = []

        def receiveEvent(sender, recipient, event):
            eventSink.append(event)

        o1 = OOCSI(handle='testclient1', callback=receiveEvent)

        o2 = OOCSI()

        message = {}
        message['color'] = int(400)
        message['position'] = int(255)
        o2.send('testclient1', message)

        time.sleep(0.5)

        self.assertEquals(1, len(eventSink))

        o1.stop()
        o2.stop()
Ejemplo n.º 2
0
    def testChannelCommunication(self):

        eventSink = []

        def receiveEvent(sender, recipient, event):
            eventSink.append(event)

        o1 = OOCSI()
        o1.subscribe('testchannel', receiveEvent)

        o2 = OOCSI()

        message = {}
        message['color'] = int(400)
        message['position'] = int(255)
        o2.send('testchannel', message)

        time.sleep(0.5)

        self.assertEquals(1, len(eventSink))

        o1.stop()
        o2.stop()
Ejemplo n.º 3
0
    def testChannelCommunicationBurst(self):

        eventSink = []
        eventSink2 = []

        def receiveEvent(sender, recipient, event):
            eventSink.append(event)

        def receiveEvent2(sender, recipient, event):
            eventSink2.append(event)

        o11 = OOCSI()
        o11.subscribe('testchannel', receiveEvent)
        o11.subscribe('OOCSI_events', receiveEvent2)
        o12 = OOCSI()
        o12.subscribe('testchannel', receiveEvent)
        o12.subscribe('OOCSI_events', receiveEvent2)
        o13 = OOCSI()
        o13.subscribe('testchannel', receiveEvent)
        o13.subscribe('OOCSI_events', receiveEvent2)

        o2 = OOCSI()

        message = {}
        message['burst'] = int(400)
        o2.send('testchannel', message)

        time.sleep(0.5)

        self.assertEquals(3, len(eventSink2))
        self.assertEquals(3, len(eventSink))

        o11.stop()
        o12.stop()
        o13.stop()
        o2.stop()
Ejemplo n.º 4
0
#! /usr/bin/python3

from oocsi import OOCSI
import sys

if len(sys.argv) < 4:
    print("Usage:", sys.argv[0], "<channel> <message key> <message value>")
    exit()

oocsi_inst = OOCSI('Testerinator', 'oocsi.id.tue.nl')

message = {sys.argv[2] : sys.argv[3]}
#message['weight'] = 666

oocsi_inst.send(sys.argv[1], message)
oocsi_inst.stop()
Ejemplo n.º 5
0
# Copyright (c) 2017-2022 Mathias Funk
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php

from oocsi import OOCSI
import time
from random import random

o = OOCSI('testsender', 'localhost')

while 1:   
    message = {}
    message['color'] = int(random() * 400)
    message['position'] = int(random() * 255)

    o.send('testreceiver', message)
    print('to ', 'testreceiver', ' -> ', message)


    # wait and continue
    time.sleep(1)
Ejemplo n.º 6
0
# a light with name, channel, LED type, spectrum, default value, brightness default, min/max, and icon name
device.addLight("light_name", "light_channel", "RGBW", "WHITE", False, 0,
                [0, 255], "lamp")

# don't forget to send the description off to the OOCSI server
device.sayHi()

# -----------------------------------------------------------------------------------------------

# run normal device-OOCSI communication with random messages
# that activate and deactivate the entities
while 1:
    # sensor data: random
    messageS = {}
    messageS['value'] = random()
    o.send('sensor_channel', messageS)
    time.sleep(1)

    # binary sensor data: on/off
    messageBS = {}
    messageBS['state'] = True
    o.send('sensor_channel2', messageBS)
    time.sleep(0.5)
    messageBS['state'] = False
    o.send('sensor_channel2', messageBS)
    time.sleep(1)

    # switch data: off/on
    messageSW = {}
    messageSW['state'] = False
    o.send('switch_channel', messageSW)
Ejemplo n.º 7
0
            family_recipes(ing.get())
            print(df_famfav['recept'][:10])
            message = {}
            if len(df_famfav['recept']) >10:
                 
                for i in range(10):
                    try:
                        message['Recipe'+ str(i)] = df_famfav['recept'].loc[i]
                    except:
                        print("No recipes")
            else:
                for i in range(len(df_famfav['recept'])):
                    message['Recipe'+ str(i)] = df_famfav['recept'].loc[i]
     
       
       oocsi.send('RecipeRecommender', message)
       # print(ing.get(), df_recipes['recept'].loc[0])
       v1= ing.get()
       oldFilter= filterVar.get()
       time.sleep(1)
     
   try:
         if keyboard.is_pressed('esc'):
             oocsi.stop()
             break
   except:
        break
    

    
Ejemplo n.º 8
0
# Copyright (c) 2017-2022 Mathias Funk
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php

from oocsi import OOCSI
import time
from random import random

o = OOCSI('testsender', 'localhost')

while 1:
    message = {}
    message['color'] = int(random() * 400)
    message['position'] = int(random() * 255)

    o.send('testchannel', message)

    # wait and continue
    time.sleep(1)