Beispiel #1
0
    def testVariablesSmooth(self):

        o1 = OOCSI()
        ov1 = o1.variable('variableChannel', 'testVarS')

        o2 = OOCSI()
        ov2 = o2.variable('variableChannel', 'testVarS').smooth(2)

        # check default
        self.assertEquals(ov1.get(), ov2.get())

        ov1.set(10)
        ov1.set(20)

        time.sleep(0.5)

        self.assertEquals(20, ov1.get())
        self.assertEquals(15, ov2.get())

        ov1.set(10)
        time.sleep(0.1)
        ov1.set(10)
        time.sleep(0.1)
        ov1.set(10)
        time.sleep(0.1)

        self.assertEquals(10, ov1.get())
        self.assertEquals(10, ov2.get())

        o1.stop()
        o2.stop()
Beispiel #2
0
    def testVariablesSmoothSigma1(self):

        o1 = OOCSI()
        ov11 = o1.variable('variableChannel', 'testVarSS11').smooth(2, 1)
        ov12 = o1.variable('variableChannel', 'testVarSS12').smooth(2, 2)

        o2 = OOCSI()
        ov21 = o2.variable('variableChannel', 'testVarSS11').smooth(2, 1)
        ov22 = o2.variable('variableChannel', 'testVarSS12').smooth(2, 2)

        # check default
        self.assertEquals(ov11.get(), ov21.get())

        ov11.set(1)
        time.sleep(0.1)
        ov11.set(2)
        time.sleep(0.1)
        ov12.set(1)
        time.sleep(0.1)
        ov12.set(2)
        time.sleep(0.1)

        self.assertEquals(1.5, ov21.get())
        self.assertEquals(1.5, ov22.get())

        # move up a lot

        ov21.set(10.2)
        time.sleep(0.1)

        ov22.set(10.2)
        time.sleep(0.1)

        self.assertEquals(2, ov11.get())
        self.assertTrue(ov11.get() < ov12.get())

        # do it again

        ov21.set(10.2)
        time.sleep(0.1)
        ov21.set(10.2)
        time.sleep(0.1)

        self.assertEquals(2.625, ov11.get())

        ov21.set(-10.2)
        time.sleep(0.1)
        ov21.set(10.2)
        time.sleep(0.1)

        self.assertEquals(2.53125, ov11.get())

        o1.stop()
        o2.stop()
Beispiel #3
0
    def testVariablesSmoothSigma2(self):

        o1 = OOCSI()
        ov1 = o1.variable('variableChannel', 'testVarSS2')

        o2 = OOCSI()
        ov2 = o2.variable('variableChannel', 'testVarSS2').smooth(2, 1)

        # check default
        self.assertEquals(ov1.get(), ov2.get())

        ov1.set(10)
        ov1.set(20)
        time.sleep(0.1)

        self.assertEquals(20, ov1.get())

        # should be half sigma
        self.assertEquals(10.5, ov2.get())

        # do it again

        print(ov1.value)
        print(ov2.values)

        ov1.set(20)
        time.sleep(0.1)

        print(ov1.value)
        print(ov2.values)

        self.assertEquals(20, ov1.get())

        # should be half sigma ((10 + 11)/2 + 0.5)
        # only because the first "mean" will be calculated by division of 1
        self.assertEquals(11, ov2.get())

        ov1.set(10)
        time.sleep(0.1)
        ov1.set(10)
        time.sleep(0.1)
        ov1.set(10)
        time.sleep(0.1)

        self.assertEquals(10, ov1.get())
        self.assertEquals(10, ov2.get())

        o1.stop()
        o2.stop()
Beispiel #4
0
    def testVariablesBasic(self):

        o1 = OOCSI()
        ov1 = o1.variable('variableChannel', 'testVar')

        o2 = OOCSI()
        ov2 = o2.variable('variableChannel', 'testVar')

        # check default
        self.assertEquals(ov1.get(), ov2.get())

        ov1.set(10)

        time.sleep(0.5)

        self.assertEquals(ov1.get(), ov2.get())

        o1.stop()
        o2.stop()
Beispiel #5
0
    def testVariablesMinMax(self):

        o1 = OOCSI()
        ov1 = o1.variable('variableChannel', 'testVarMM').min(2).max(5)

        o2 = OOCSI()
        ov2 = o2.variable('variableChannel', 'testVarMM').min(3).max(6)

        # check default
        self.assertEquals(2, ov1.get())
        self.assertEquals(3, ov2.get())

        ov1.set(10)

        time.sleep(0.5)

        self.assertEquals(5, ov1.get())
        self.assertEquals(6, ov2.get())

        o1.stop()
        o2.stop()
Beispiel #6
0
            if i == j:
                count = count+ i
                #print(count)
        #print(e, df_rec['recipe_name'].loc[e], count)
        if count>0:
           # print (df_rec['recipe_name'].loc[e], df_rec["family_favorites"].loc[e]) 
            if (df_rec['family_favorites'].loc[e] ==1):
                #print(df_rec['recipe_name'].loc[e])
                      
                #print (df_rec['recipe_name'].loc[e], count)
                df_famfav =df_famfav.append({'recept': df_rec['recipe_name'].loc[e]}, ignore_index=True)

    
# connect to OOCSI running on a webserver
oocsi = OOCSI('Your_Unique_Handler', "oocsi.id.tue.nl")
ing = oocsi.variable('RecipeRecommender', 'ingredients')
filterVar = oocsi.variable('RecipeRecommender', 'filter')
oldFilter= filterVar.get()
filterVar.set("popular")
ing.set('garlic')
v1= ing.get()

v1= ing.get()


while True:
   if (v1 != ing.get()) or filterVar.get() != oldFilter:
       if filterVar.get() == "popular":
            pos_recipes(ing.get())
            print(df_recipes['recept'][:10])
            message = {}
Beispiel #7
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

# start responder OOCSI client
responder = OOCSI('variable1', 'localhost')
# create variable 'color' for first client
v1 = responder.variable('colorChannel', 'color')

# start caller OOCSI client
caller = OOCSI('variable2', 'localhost')
# create variable 'color' for second client
v2 = caller.variable('colorChannel', 'color')

# assign an int
v1.set(100)
print('value of first variable: ', v1.get())

time.sleep(0.1)

print('value of second variable: ', v2.get())

# assign a float
v2.set(200.1)
print('value of second variable: ', v2.get())

time.sleep(0.1)
Beispiel #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

# start responder OOCSI client
responder = OOCSI('variable1', 'localhost')
# create variable 'color' for first client
v1 = responder.variable('colorChannel', 'color')
v1p = responder.variable('colorChannel', 'position')

# start caller OOCSI client
caller = OOCSI('variable2', 'localhost')
# create variable 'color' for second client
v2 = caller.variable('colorChannel', 'color')
v2p = caller.variable('colorChannel', 'position')

# assign a string
v1.set(40)
v1p.set(210)
print('value of first color: ', v1.get())
print('value of first position: ', v1p.get())

time.sleep(0.1)

print('value of second color: ', v2.get())
print('value of second position: ', v2p.get())