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()
from oocsi import OOCSI from NAO_Speak import NAO_Speak # (file name followed by class name) import unidecode ################################# IP = "IP_OF_PEPPER_ROBOT" text = "" my_nao = NAO_Speak(IP, 9559) ################################## def receiveEvent(sender, recipient, event): print('from ', sender, ' -> ', event) # this will convert unicode string to plain string msg = str(event['message']) sender = str(sender) x, y = sender.split('_') if x == 'webclient': my_nao.say_text(msg) if __name__ == "__main__": #o = OOCSI('abc', "oocsi.id.tue.nl", callback=receiveEvent) o = OOCSI('pepper_receiver', 'oocsi.id.tue.nl') o.subscribe('__test123__', receiveEvent)
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()
#! /usr/bin/python3 from oocsi import OOCSI import sys if len(sys.argv) < 2: print('usage:', sys.argv[0], '<channel>') exit() oocsi = OOCSI('Testerinator', 'oocsi.id.tue.nl') def printMessage(sender, recipient, event): print('from', sender, '->', event) oocsi.subscribe(sys.argv[1], printMessage)
#! /usr/bin/python3 from oocsi import OOCSI import sys if len(sys.argv) < 2: print('usage:', sys.argv[0], '<channel>') exit() oocsi = OOCSI('Testerinator', 'oocsi.id.tue.nl') def printMessage(sender, recipient, event): print('from', sender, '->', event) for channel in sys.argv[1:]: oocsi.subscribe(channel, printMessage)
def main(): hours = int(time.strftime('%H')) # Section 1: Title st.title('Affective Foreteller') st.subheader('What is your name?') # Participant's randomly assigned identifier which will show in the app interface nickname = st.selectbox( 'Select your nickname.', ('--', 'Alex', 'Ben', 'Chris', 'Don', 'Eddie', 'Fem', 'Greta', 'Hans', 'Iris', 'Jon', 'Kim', 'Leo', 'Mark', 'Nora', 'Oz', 'Paul', 'Quinn', 'Roy', 'Sam', 'Tom')) if nickname != '--': st.write('Hello', nickname, '!') # Section 2: Mood selection st.subheader('How are you feeling right now?') mood_option = st.radio( 'Select an option of words that best describe your mood.', ('Excited, elated, ebullient', 'Happy, pleased, content', 'Calm, serene, tranquil', 'Tense, nervous, upset', 'Miserable, unhappy, discontent', 'Depressed, bored, lethargic') ) # Section 3: Additional question selection if hours in range(5, 11): # morning question st.subheader('How many hours did you sleep last night?') sleep_time = st.slider( label='', min_value=0.0, max_value=16.0, step=0.5, format='%1f' ) food_options = 'food_options' activity_options = 'activity_options' elif hours in range(11, 17): # afternoon question st.subheader('What was your last meal?') food_options = st.text_input('Type or use emojis to describe what you ate.', value='', max_chars=50) sleep_time = 'sleep_time' activity_options = 'activity_options' else: # evening question st.subheader('What were your activities today?') activity_options = st.multiselect( 'You can select multiple options.', ['⚽ sport️', '🧘️ meditation', '🎼 music', '🎨 hobbies', '🚗 commute', '📱 apps', '🛏 rest', '🛍 shopping', '📚 read', '💻 work', '🍽 meals', '🍻 drinks']) sleep_time = 'sleep_time' food_options = 'food_options' # send data to oocsi def send_data(): oocsi.send('Affective_Foretell_Self_Report', { 'name': nickname, 'mood': mood_option, 'sleep': sleep_time, 'food': food_options, 'activities':activity_options}) if st.button('Submit'): if nickname == '--': st.write('Please select your nickname.') else: st.write('Thank you for your submission!') oocsi = OOCSI('Affective_Foretell', 'oocsi.id.tue.nl') oocsi.subscribe('Affective_Foretell_Self_Report', send_data()) oocsi.stop() st.balloons()
# 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 def receiveEvent(sender, recipient, event): print('from ', sender, ' -> ', event) o = OOCSI('testreceiver', 'localhost') o.subscribe('testchannel', receiveEvent)