Exemple #1
0
def startOsc():
    """start up the communication between service and main app"""
    osc.init()
    oscid = osc.listen(ipAddr='127.0.0.1', port=IPCServicePort)
    osc.bind(oscid, device_callback, '/device')
    osc.bind(oscid, stop_callback, '/stop')
    return oscid
Exemple #2
0
	def build(self):
		self.service = None
		self.start_service()
		global RootApp
		RootApp = self

		# NavigationDrawer
		self.navigationdrawer = NavDrawer()

		# SidePanel
		side_panel = SidePanel()
		self.navigationdrawer.add_widget(side_panel)

		# MainPanel
		self.main_panel = MainPanel()

		# color picker
		self.color_selector = ColorSelector()

		# size selector
		self.size_selector = SizeSelector()

		self.navigationdrawer.anim_type = 'slide_above_simple'
		self.navigationdrawer.add_widget(self.main_panel)

		osc.init()
		oscid = osc.listen(port=3002)
		osc.bind(oscid, self.reCallback, '/date')
		Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

		return self.navigationdrawer
Exemple #3
0
 def build(self):
     # the root is created in pictures.kv
     self.root
     self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
     # get any files into images directory
     curdir = dirname(__file__)
     list = glob(join(curdir, 'images', '*'))
     Logger.debug("{}".format(list))
     shuffle(list)
     Logger.debug("{}".format(list))
     for filename in list:
         try:
             # load the image
             picture = Picture(source=filename, id=filename, rotation=randint(-30, 30))
             # add to the main field
             self.root.add_widget(picture)
         except Exception as e:
             Logger.exception('Pictures: Unable to load <%s>' % filename)
     osc.init()
     self.last_name = ""
     osc.sendMsg('/say', ["La ap di Michele e' pronta", ], port=service_port)
     return self.root
Exemple #4
0
	def build(self):
		if platform == 'android':
			self.start_service()
			from jnius import autoclass
			self.Locale = autoclass('java.util.Locale')
			self.PythonActivity = autoclass('org.renpy.android.PythonActivity')
			self.TextToSpeech = autoclass('android.speech.tts.TextToSpeech')
			self.tts = self.TextToSpeech(self.PythonActivity.mActivity, None)
			self.locales = {
				'CANADA':self.Locale.CANADA,
				'FRANCE':self.Locale.FRANCE,
				'GERMANY':self.Locale.GERMANY,
				'ITALY':self.Locale.ITALY,
				'JAPAN':self.Locale.JAPAN,
				'KOREA':self.Locale.KOREA,
				'CHINA':self.Locale.SIMPLIFIED_CHINESE,
				'UK':self.Locale.UK,
				'US':self.Locale.US
				}
		osc.init()
		oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
		osc.bind(oscid, self.some_api_callback, '/some_api')
		Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
		self.service_enabled = False
		self.toggle_service()
		self.load_settings()
		self.chosen_locale = self.config.get('example','optionsexample')
		self.tts_enabled = bool(int(self.config.get('example','boolexample')))
		return
Exemple #5
0
 def build(self):
     """config = ConfigParser()
     config.read('conf.ini')
     self.config = Settings()
     # s.add_json_panel('My custom panel', config, 'settings_custom.json')"""
     self.icon = 'images/ic_launcher.png'
     self.osc_activities = []
     self.speechs = []
     self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
     self.count_requests = 0
     self.timer_value = "40.10.10.1"
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
         self.folder_music = "/storage/emulated/legacy/Music/PerAttivita"
     elif platform == 'win':
         self.folder_music = "C:\\Mao\\Progetti\\Musica\\MusicaSuNexus\\PerAttivita"
     else:
         self.folder_music = ".\\music"
     Logger.info("Folder music: {}".format(self.folder_music))
     self.sequences = mentor_lib.Sequences()
     self.sequences.load_sequences()
     self.root = MentorWidget()
     text_input = TextInput(text=self.timer_value, font_size=40, multiline=False)  #, size_hint=(None, None))  # font_size=20,
     text_input.foreground_color = [1, 1, 1, 1]
     text_input.background_color = [0, 0, 0, 0]
     text_input.shorten_from = 'center'
     #text_input.center_x = True
     #text_input.center_y = True
     text_input.bind(text=self.on_text_input_text)
     self.root.ids.grid_main.add_widget(text_input)
     btn = Button(text="Custom Timer")  #, size_hint_y=None, height=40)
     #btn.height = text_input.content_height
     btn.bind(on_press=partial(self.start_sequence, "timer"))
     self.root.ids.grid_main.add_widget(btn)
     for title in self.sequences.titles:
         btn = Button(text=title)#, size_hint_y=None, height=40)
         btn.bind(on_press=partial(self.start_sequence, title))
         self.root.ids.grid_main.add_widget(btn)
     #if len(self.sequences.titles)%2:
     #    btn = Button(text="_     _", id='pippo')  #, size_hint_y=None, height=40)
     #    self.root.ids.grid_main.add_widget(btn)
     #self.start_sequence_ok = False
     #self.sequence_buttons = []
     #for i in self.sequences.titles:
         #self.sequence_buttons.append(Button(text=str(i)))
         #self.sequence_buttons[-1].bind(on_press=self.start_sequence(str(i)))
         #self.sequence_buttons[-1].bind(on_release=self.start_sequence(str(i)))
         #btn.bind(state=self.start_sequence(str(i)))
         #btn.bind(on_release=self.root.start_sequence(btn.text))
         #self.root.ids.grid_main.add_widget(self.sequence_buttons[-1])
         #self.root.ids.grid_main.add_widget(Button(text=str(i), on_press=self.start_sequence(str(i))))
     #self.start_sequence_ok = True
     osc.init()
     osc.bind(self.osc_id, self.msg_from_server, '/msg')
     osc.bind(self.osc_id, self.root.write_cockpit, '/osd')
     Clock.schedule_interval(self.timed_ops, .1)
     return self.root
Exemple #6
0
 def __init__(self):
     osc.init()
     self.last_update = 0
     self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT)
     osc.bind(self.oscid, self.pocket_connect, '/pocket/connect')
     osc.bind(self.oscid, self.pocket_list, '/pocket/list')
     osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read')
    def _test_2_test_service_control(self):
        # Run main
        _proc = subprocess.Popen(args = ["python", os.path.normpath(Test_Script_Dir + "/../main.py")], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)


        # Connect to it and sent message

        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3002)
        osc.bind(self.oscid, self._status_result, '/status')

        self.test_2_result = None
        sleep(1)
        osc.sendMsg(oscAddress ='/status', ipAddr="0.0.0.0", dataArray=[""], port=3000)

        while self.test_2_result is None:
            osc.readQueue(self.oscid)
            sleep(.1)
        if self.test_2_result is True:
            self.assertTrue(True)
        else:
            self.assertTrue(False, "Test failed, service returned:" + str(self.test_2_result))

        osc.sendMsg(oscAddress ='/stop', ipAddr="0.0.0.0", dataArray=[], port=3000)
        osc.dontListen(self.oscid)
Exemple #8
0
    def build(self):
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('irc1\'s service', 'running')
            service.start('service started')
            self.service = service

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        osc.bind(oscid, self.main_api_callback, '/api/main')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.1)

        self.icon = 'data/icon.png'
        self.servers = DictStore('servers.db')
        self.msg_animation = Animation(opacity=1, transition='out_cubic')
        self.screenmain = ScreenMain()
        self.running = {}
        self.boxes = {}

        for name in sorted(dict(self.servers.find()).keys()):
            data = self.servers.get(name)
            box = ServerBox(name=name)
            self.boxes[name] = box
            self.screenmain.ids.servers.add_widget(box)

        manager = ScreenManager(transition=SlideTransition(duration=0.2))
        manager.add_widget(self.screenmain)
        return manager
Exemple #9
0
 def __init__(self):
     osc.init()
     self.oscid = osc.listen(ipAddr='127.0.0.1', port=SERVICE_PORT)
     osc.bind(self.oscid, self.handle_incoming_message, API_OFFSET)
     osc.bind(self.oscid, self.handle_request_for_pending_alerts,
              API_OFFSET + "pending-alerts")
     osc.bind(self.oscid, self.handle_classify_alert,
              API_OFFSET + "classify-alert")
Exemple #10
0
    def __init__(self, **kwargs):
        super(UpdateClient, self).__init__(**kwargs)

        osc.init()
        oscid = osc.listen('127.0.0.1', CLIENT_PORT)
        osc.bind(oscid, self.recv_osc, SERVICE_PATH)
        Clock.schedule_interval(lambda _: osc.readQueue(oscid), 0)

        self.current_version = str(get_current_version())
Exemple #11
0
	def __init__(self, **kwargs):
		super(UpdateClient, self).__init__(**kwargs)
		
		osc.init()
		oscid = osc.listen('127.0.0.1', CLIENT_PORT)
		osc.bind(oscid, self.recv_osc, SERVICE_PATH)
		Clock.schedule_interval(lambda _: osc.readQueue(oscid), 0)
		
		self.current_version = str(get_current_version())
Exemple #12
0
 def build(self):
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(ipAddr='127.0.0.1', port=3002)
     osc.bind(oscid, self.temp_data, '/sensordata')
     osc.bind(oscid, self.notification_data, '/notification')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.7)
     return presentation
Exemple #13
0
    def init_osc(self):
        from kivy.lib import osc
        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=self.receive_port)

        osc.bind(self.oscid, self.receive_osc_message, b'/stdout')
        osc.bind(self.oscid, self.receive_osc_message, b'/stderr')
        osc.bind(self.oscid, self.receive_osc_message, b'/interpreter')
        osc.bind(self.oscid, self.receive_osc_message, b'/pong')
Exemple #14
0
	def __init__(self, **kwargs):
		super(BestVibratorAppServiceController, self).__init__(**kwargs)
		self.SERVICE_ACTIVE=False
		if platform=="android":
			from android import AndroidService
			self.service=AndroidService("Best Vibrator Service", "running")
			self.service.start("Best Vibrator Service started")
			self.SERVICE_ACTIVE=True
		osc.init()
Exemple #15
0
 def init_osc(self):
     """Initialisation of the OSC communication.
     Bindings are donne for some kings of messages.
     """
     osc.init()
     oscid = osc.listen(ipAddr='127.0.0.1', port=kivytrek_port)
     osc.bind(oscid, self.gps_pos_callback, '/gps_pos')
     osc.bind(oscid, self.gps_daemon_recording_callback, '/gpx_status')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)
Exemple #16
0
 def build(self):
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=3002)
     osc.bind(oscid, self.display_message, '/message')
     osc.bind(oscid, self.date, '/date')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.root = Builder.load_string(kv)
     return self.root
Exemple #17
0
 def __init__(self, queue):
     self.queue = queue
     self.stopped = False
     self.thread = threading.Thread(name='query', target=self.run)
     osc.init()
     self.oscid = osc.listen(ipAddr='127.0.0.1', port=3334)
     osc.bind(self.oscid, self.handle_message, '/android_park')
     self.thread.start()
     self.pending = {}
     self.next_id = 0
Exemple #18
0
 def build(self):
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=3002)
     osc.bind(oscid, self.display_message, '/message')
     osc.bind(oscid, self.date, '/date')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.root = Builder.load_string(kv)
     return self.root
Exemple #19
0
    def build(self):
        self.start_service()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        # activity port
        osc.bind(oscid, self.api_callback, '/some_api')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)

        return ServiceInterface()
Exemple #20
0
    def build(self):
        self.start_service()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        # activity port
        osc.bind(oscid, self.api_callback, '/some_api')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)

        return ServiceInterface()
Exemple #21
0
 def get_curency(self,req,data):
     currency=json.loads(data.decode("utf-8")) if  isinstance(data,dict) else data
     self.load_currency(currency)
     if self.started==True:
         return
     self.started=True
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=self.port)#3002
     osc.bind(oscid, self.get_currency_from_service, '/currency')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
Exemple #22
0
    def boot(self, configurestation=False):

        print "background boot station"

        ####   osc IPC   ####
        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
        osc.bind(self.oscid, self.rpcin, '/rpc')

        #force trip for mobile station in background
        self.trip = self.ismobile()

        try:
            self.starttransport()
        except:
            print "start transport failed"

        notok = True
        while notok:
            try:
                if configurestation:
                    self.configurestation()
                try:
                    self.sensorssetup()
                except:
                    print "sensorssetup failed"

                if self.trip:
                    self.gps.start()
                self.startmqtt()
                notok = False
            except:
                print "Error booting station"
                time.sleep(5)

                osc.readQueue(self.oscid)
                if self.rpcin_message == "stop":
                    print "received stop message from rpc"
                    self.on_stop()
                    print "send stopped message to rpc"
                    self.rpcout("stopped")
                    raise SystemExit(0)
                    #time.sleep(60) # wait for kill from father

                if self.transport_name == "bluetooth":
                    self.bluetooth.close()
                    self.transport = self.bluetooth.connect()
                    try:
                        self.sensorssetup()
                    except:
                        print "sensorssetup failed"

        print "background end boot"
Exemple #23
0
 def serve(self):
     self.state = 'open'
     osc.init()
     self.oscid = osc.listen(ipAddr=self.net.server_host, port=self.net.server_port)
     osc.bind(self.oscid, self.osc_handle_ping, '/ping')
     osc.bind(self.oscid, self.osc_handle_join, '/join')
     osc.bind(self.oscid, self.osc_handle_leave, '/leave')
     osc.bind(self.oscid, self.osc_handle_start, '/start')
     osc.bind(self.oscid, self.osc_handle_pos, '/pos')
     while True:
         self.loop()
         sleep(.05)
    def __init__(self, **kwargs):
        super(BoxLayout, self).__init__( **kwargs)
        self.scroller = self.children[-1]

        self.grid = GridLayout(cols=1, spacing=1, size_hint_y=None)
        self.scroller.add_widget(self.grid)
        self.grid.bind(minimum_height=self.grid.setter('height'))

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=3002)
        osc.bind(oscid, self.add_more, '/some_api')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)
Exemple #25
0
def main():

    oscid = osc.listen(ipAddr=hostname, port=serviceport)
    osc.init()

    osc.bind(oscid, update_notification, '/update')

    br = BroadcastReceiver(intent_callback,["GET_CONTENT",]) # no prefix ACTION_ required
    br.start()

    while True:
        osc.readQueue(oscid)
        time.sleep( .1 )
Exemple #26
0
def _main():
    osc.init()
    start_time = int(time.time())
    oscid = osc.listen(ipAddr='0.0.0.0', port=MAIN_PROG_RCV)
    osc.bind(oscid, play, '/play')
    osc.bind(oscid, pause, '/pause')
    osc.bind(oscid, stop, '/stop')
    osc.bind(oscid, volume, '/volume')
    osc.bind(oscid, kill, '/kill')
    while True:
        osc.readQueue(oscid)
        osc.sendMsg('/ping', [start_time], port=MAIN_PROG_PORT)
        sleep(.1)
Exemple #27
0
 def _init_services(self):
     osc.init()
     self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
     osc.bind(self.osc_id, self._msg_from_server, '/msg')
     osc.bind(self.osc_id, self._sequence_loaded, '/sld')
     osc.bind(self.osc_id, self._write_cockpit, '/osd')
     osc.bind(self.osc_id, self._write_timer, '/tmr')
     #osc.bind(self.osc_id, self.root.write_cockpit, '/osd')
     if is_android:
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
     Clock.schedule_interval(self.timed_ops, 1.0)
Exemple #28
0
 def build(self):
     self.title = "GoshenApp"
     #from kivy.core.window import Window
     #Window.size = (450, 600)
     #self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=3002)
     osc.bind(oscid, self.display_message, '/message')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.theme_cls.theme_style = 'Dark'
     self.theme_cls.primary_palette = 'Indigo'
     self.nav_drawer = Drawer()
     return GbeeRoot()
Exemple #29
0
 def __init__(self, **kwargs):
     self.port = kwargs.get('port')
     _reader_should_run = None
     _reader_thread = None
     self._rx_queue = Queue.Queue()
     osc.init()
     oscid = osc.listen(ipAddr='0.0.0.0', port=CLIENT_API_PORT)
     osc.bind(oscid, self.on_rx, RX_API)
     osc.bind(oscid, self.on_command, CMD_API)
     self._oscid = oscid
     
     service = AndroidService('RC comms service', 'running')
     service.start('service started')
     self._service = service
Exemple #30
0
    def boot(self,configurestation=False):

        print "background boot station"

        ####   osc IPC   ####
        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
        osc.bind(self.oscid, self.rpcin, '/rpc')

        try:
            self.starttransport()
        except:
            print "start transport failed"

        notok=True
        while notok:
            try:
                if configurestation:
                    self.configurestation()
                try:
                    self.sensorssetup()
                except:
                    print "sensorssetup failed"

                if self.trip:
                    self.gps.start()
                self.startmqtt()
                notok=False
            except:
                print "Error booting station"
                time.sleep(5)

                osc.readQueue(self.oscid)
                if self.rpcin_message == "stop":
                    print "received stop message from rpc"
                    self.on_stop()
                    print "send stopped message to rpc"
                    self.rpcout("stopped")
                    raise SystemExit(0)
                    #time.sleep(60) # wait for kill from father

                if self.transport_name == "bluetooth":
                    self.bluetooth.close()
                    self.transport=self.bluetooth.connect()
                    try:
                        self.sensorssetup()
                    except:
                        print "sensorssetup failed"

        print "background end boot"
Exemple #31
0
	def __init__(self,**kwargs):
		super(testapp, self).__init__(**kwargs)
		self.client_id = '001'
		self.mqtt_topics = []
		self.server_ip = ''
		self.broker_1 = ''
		self.broker_2 = ''
		self.send_topic = ''
		self.ack_topic = ''
		self.connected = False
		osc.init()
		self.oscid = osc.listen(ipAddr='127.0.0.1', port=3000)	
		osc.bind(self.oscid, self.get_serverIP, '/serverIP')
		osc.bind(self.oscid, self.get_clientID, '/clientID')
		osc.bind(self.oscid, self.send_command, '/command')
Exemple #32
0
    def build(self):
        self.service = None
        #self.start_service()
        global interface
        osc.init()
        oscid = osc.listen(port=3002)
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

        if settings.exists("db"):
            pass
        else:
            settings.put("db", created=True)
            db.create_table(Todo)
        interface = Interface()
        return interface
Exemple #33
0
 def start_client(self):
     osc.init()
     oscid = osc.listen(ipAddr=self.net.client_host,
                        port=self.net.client_port)
     osc.bind(oscid, self.osc_handle_pong, '/pong')
     osc.bind(oscid, self.osc_handle_log, '/log')
     osc.bind(oscid, self.osc_handle_players, '/players')
     osc.bind(oscid, self.osc_handle_joined, '/joined')
     osc.bind(oscid, self.osc_handle_left, '/left')
     osc.bind(oscid, self.osc_handle_draw, '/draw')
     osc.bind(oscid, self.osc_handle_pos, '/pos')
     osc.bind(oscid, self.osc_handle_go, '/go')
     osc.bind(oscid, self.osc_handle_win, '/win')
     Clock.schedule_interval(lambda dt: osc.readQueue(oscid), 0)
     Clock.schedule_interval(lambda dt: self.gui.update(), 1 / 60.0)
     Clock.schedule_interval(lambda dt: self.osc_send_ping(), 0.25)
Exemple #34
0
    def build(self):
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('My Activity', 'running')
            service.start('service started')
            self.service = service

        osc.init()
        osc_id = osc.listen(ipAddr='127.0.0.1', port=activity_port)
        osc.bind(osc_id, self.my_callback, '/message')

        # Listen for messages regularly
        Clock.schedule_interval(lambda *x: osc.readQueue(osc_id), 0)

        btn = Button(text='Push me to see OSC working')
        btn.bind(on_release=self.send_msg_to_service)
        return btn
    def _test_3_test_service_job(self):
        # Run main
        _proc = subprocess.Popen(args = ["python", os.path.normpath(Test_Script_Dir + "/../main.py")], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        # Connect to it and sent message

        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3002)
        osc.bind(self.oscid, self._status_result, "/status")

        sleep(1)

        osc.sendMsg(oscAddress ='/run_job', ipAddr="0.0.0.0", dataArray=["Default", ], port=3000)

        sleep(10)

        osc.sendMsg(oscAddress ='/stop', ipAddr="0.0.0.0", dataArray=[], port=3000)
Exemple #36
0
    def build(self):
        #EventLoop.window.bind(on_keyboard=self.hook_keyboard)

        if platform == 'android':
            service = AndroidService('Sister Radio', 'running')
            service.start('service started!')
            self.service = service
            self.wakelock.start()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        osc.bind(oscid, self.is_playing, '/is_playing')
        osc.bind(oscid, self.is_stopped, '/is_stopped')

        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

        menu = Menu()
        return menu
Exemple #37
0
    def __init__(self, **kwargs):
        if platform == 'android':
            sp = {'service':3000, 'app':3001}
            serv = 'APPIX_SERVICE' in os.environ
            self.send_port = sp['service' if serv else 'app']
            self.listen_port = sp['service' if not serv else 'app']
            print self.listen_port, 'port', serv,  'APPIX_APP' in os.environ
            super(AppixComm, self).__init__()
            osc.init()
            self.keep_listening = False
            self.oscid = osc.listen(ipAddr='127.0.0.1', port=self.listen_port)
            osc.bind(self.oscid, self.read_message, '/AppixCom')
            self.bluetooth_standby_time = 0
            self.app = App.get_running_app()
            self.time_since_app_paused = 0

            self.debug = DEBUG
            self.admin_app = ADMIN_APP
Exemple #38
0
    def start_service(self):

        if platform == "android":
            Logger.info("main: Creating Android Service")
            from android import AndroidService
            service = AndroidService('Notification Demo', 'running')
            service.start('service started')
            self.service = service
        else:
            # purely for testing on non-android platforms,
            # although notification will not work
            Logger.info("main: Creating Service as Secondary Process")
            self.pid = Popen([sys.executable, "service/main.py"])

        osc.init()
        oscid = osc.listen(ipAddr=hostname, port=activityport)

        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
Exemple #39
0
	def __init__(self,**kwargs):
		super(NotificationDemo, self).__init__(**kwargs)
		self.temp = [0,0,0,0]
		self.tempchg = None
		self.humchg = None
		self.dataRecv = '[0,0,0,0]'
		self.broker='106.201.235.43'
		self.service = 3000
		osc.init()
		self.oscid = osc.listen(ipAddr='127.0.0.1', port=3000)
		osc.bind(self.oscid, self.settings_data, '/settings_data')
		self.alert_settings = [20,40,20,50]
		self.notifications_received = ObjectProperty(None)
		self.notification_title = ObjectProperty(None)
		self.notification_text = ObjectProperty(None)
		self.olddat = [0,0,0,0]
		self.notification_msg = ['No Notification', '', '','down2.png']
		self.a = 0
    def __init__(self):
        sleep(1)
        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=3001)
        try:
            osc.sendMsg('/some_api', ['Init'], port=3002)
            self.mplayer = M_Player(self)
            osc.bind(oscid, self.mplayer.osc_callback, '/some_api')
            self.queue = ''

            while True:
                osc.readQueue(oscid)
                if self.queue != '':
                    self.mplayer.osc_callback(['','',self.queue])
                    self.queue = ''
                    sleep(.3)
        except Exception as e:
            osc.sendMsg('/some_api', ['Service crash '+str(e)], port=3002)
Exemple #41
0
    def __init__(self, **kwargs):
        super(ZbarQrcodeDetector, self).__init__(**kwargs)
        self._camera = AndroidCamera(
                size=self.camera_size,
                size_hint=(None, None))
        self._camera.bind(on_preview_frame=self._detect_qrcode_frame)
        self.add_widget(self._camera)

        # create a scanner used for detecting qrcode
        self._scanner = ImageScanner()
        self._scanner.setConfig(0, Config.ENABLE, 0)
        self._scanner.setConfig(Symbol.QRCODE, Config.ENABLE, 1)
        self._scanner.setConfig(0, Config.X_DENSITY, 3)
        self._scanner.setConfig(0, Config.Y_DENSITY, 3)
        


        osc.init()
        self._sound = SoundLoader.load('sound.wav')
    def init(self, _cfg_file=None):
        self.ids.destination_host.ids.input_selection.bind(text=self._update_host)
        self.ids.destination_path.on_status = self.do_on_smbselector_status
        self.load_settings(_cfg_file)
        self.service = None
        osc.init()
        self.oscid = osc.listen(port=3002)
        osc.bind(self.oscid, self.progress_callback, "/progress_callback")
        osc.bind(self.oscid, self.status_callback, "/status_callback")

        # Check if service is running
        self.service_running = False
        osc.sendMsg("/status", [], port=3000)
        osc.sendMsg("/progress", [], port=3000)
        sleep(0.3)
        osc.readQueue(self.oscid)


        Clock.schedule_interval(self.process_messages, 1)
Exemple #43
0
    def build(self):
        """
        Construct the screen manager with the appropriate screens
        """
        Window.clearcolor = (1, 1, 1, 1)
        
        self.lines = deque([])
        self.screens = {'anontunnels': AnonTunnelScreen(name='anontunnels'),
                        'settings': SettingsScreen(name='settings')}
        self.screen_manager = ScreenManager()
        for screen in self.screens.values():
            self.screen_manager.add_widget(screen)
        
        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=9000)
        osc.bind(self.oscid, self.received_status, '/status')
        Clock.schedule_interval(lambda *x: osc.readQueue(), 0)

        return self.screen_manager
Exemple #44
0
    def __init__(self, **kargs):
        super(PedidosWidget, self).__init__(**kargs)
        Logger.debug('Cagada')
        self.listapedidos = []
        self.modify_pedidos = []
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('TpvB3 receptor', 'running')
            service.start('service started')
            self.service = service
        else:
            import os, threading
            #threading.Thread(target=os.system, args=("python ./service/main.py",)).start()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        osc.bind(oscid, self.mostrar_pedidos, '/sync_pedidos')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
        self.mostrar_pedidos('ok')
Exemple #45
0
	def run(self):
		print 'updater run'
		osc.init()
		oscid = osc.listen('127.0.0.1', SERVICE_PORT)
		osc.bind(oscid, self.recv_osc, SERVICE_PATH)
		print 'listening for OSC'
		self.current_version = self.downloaded_version = self.get_current_version()
		
		while True:
			if not self.last_check or (self.last_check + self.frequency) < time():
				if self.check_for_update():
					self.download_update()
			
			if self.dlready.is_set():
				self.notify_client()
				self.dlready.clear()
			
			osc.readQueue(oscid)
			
			sleep(.1)
    def __init__(self, **args):
        global _wna

        super(WhiteNoiseBackground, self).__init__(**args)
        self.setup_config()
        _wna = self
        
        self.last_ping = time.time()
        self.service_start = 0

        self.service = None
        self.start_service()
        osc.init()
        oscid = osc.listen(port=SERVICE_SND_PORT)
        
        osc.bind(oscid, self.service_ping, '/ping')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
        Clock.schedule_interval(self.check_for_srvc, 0.5)
        self.service_warn = False

        self.init_gui()
Exemple #47
0
    def build(self):
        """
        Construct the screen manager with the appropriate screens
        """
        Window.clearcolor = (1, 1, 1, 1)

        self.lines = deque([])
        self.screens = {
            'anontunnels': AnonTunnelScreen(name='anontunnels'),
            'settings': SettingsScreen(name='settings')
        }
        self.screen_manager = ScreenManager()
        for screen in self.screens.values():
            self.screen_manager.add_widget(screen)

        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=9000)
        osc.bind(self.oscid, self.received_status, '/status')
        Clock.schedule_interval(lambda *x: osc.readQueue(), 0)

        return self.screen_manager
Exemple #48
0
    def run(self):
        print 'updater run'
        osc.init()
        oscid = osc.listen('127.0.0.1', SERVICE_PORT)
        osc.bind(oscid, self.recv_osc, SERVICE_PATH)
        print 'listening for OSC'
        self.current_version = self.downloaded_version = self.get_current_version(
        )

        while True:
            if not self.last_check or (self.last_check +
                                       self.frequency) < time():
                if self.check_for_update():
                    self.download_update()

            if self.dlready.is_set():
                self.notify_client()
                self.dlready.clear()

            osc.readQueue(oscid)

            sleep(.1)
Exemple #49
0
 def __init__(self):
     L.debug("Service is running")
     # Initialize internal queue
     self.thread = threading.Thread(name='execution', target=self.async_run)
     self.internal_queue = Queue()
     self.thread.start()
     # Initialize OSC
     osc.init()
     self.oscid = osc.listen(ipAddr='127.0.0.1', port=3333)
     osc.bind(self.oscid, self.handle_message, '/android_park')
     self.server = ServerInterface()
     self.pending = {}
     self.last_time = None
     self.notified = True
     self.config = None
     # set to indicate that a month has been processed by the pattern
     self.pattern_processed=set()
     # Initialize timezones
     self.met = pytz.timezone('Europe/Madrid')
     self.t1 = datetime.time(hour=0, minute=0, second=0, tzinfo=self.met)  # 00:00
     self.t2 = datetime.time(hour=15, minute=0, second=0, tzinfo=self.met)  # 15:00
     self.t3 = datetime.time(hour=17, minute=30, second=0, tzinfo=self.met)  # 17:30
     self.t4 = datetime.time(hour=23, minute=59, second=59, tzinfo=self.met)  # 23:59
Exemple #50
0
    def build(self):
        self.title = "Traffic simulator"

        # Android
        self.service = None
        self.start_service()

        # osc messages init
        osc.init()
        oscid = osc.listen(port=3002)
        # Send start/stop simulation
        osc.bind(oscid, self.start_simulation, '/send_start')
        # Receive hello world
        osc.bind(oscid, self.output_hello, '/receive_hello')
        # Retrieve simulation status
        osc.bind(oscid, self.simulation_status_receive, '/simu-status')
        # Retrieve server stopped
        osc.bind(oscid, self.server_stopped, '/server-stop')
        # Read received messages
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
        # Receive grid status
        osc.bind(oscid, self.grid_update, '/states')

        # Send message asking for simulation status
        osc.sendMsg('/simu-status_ask', [], port=3000)

        # Grid changes
        # self._size_handler_trigger = Clock.schedule_once(self._size_handler)  # Clock.create_trigger
        # self.bind(grid=self._size_handler_trigger)

        # normal variables
        self.grid_spots = []

        if not self.server_running:
            print("Simulation server not running")
            self.root.ids.label.text = "Simulation server not running :(\n"
Exemple #51
0
 def setupOsc(self):
     osc.init()
     oscid = osc.listen(ipAddr='127.0.0.1', port=IPCPort)
     osc.bind(oscid, self.main.on_update_from_service, '/update')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
Exemple #52
0
 def __init__(self):
     super(OSCClient, self).__init__()
     osc.init()
     osc_id = osc.listen(ipAddr='127.0.0.1', port=OSCServer.client_port)
     osc.bind(osc_id, OSCClient.kivy_client, 'kivy_client')
     Clock.schedule_interval(lambda *x: osc.readQueue(osc_id), 0)
Exemple #53
0
def stop_notification_service():
    if platform == 'android':
        osc.init()
        osc.sendMsg('/stop', [], port=3000)
Exemple #54
0
    def build(self):
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('my pong service', 'running')
            service.start('service started')
            self.service = service

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=ACTIVITY_PORT)
        osc.bind(oscid, self.some_api_callback, API_OFFSET)
        osc.bind(oscid, self.handle_alerts, API_OFFSET + "pending-alerts")
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

        Window.size = 640, 480

        self.layout = TabbedPanel()
        self.layout.do_default_tab = True


        #self.status_tab = GridLayout()
        #self.layout.default_tab_content = self.status_tab
        #self.layout.default_tab_text = "Status"
        #self.status_tab.add_widget(Button(text="TODO make this page..."))

        #self.alert_tab = TabbedPanelHeader(text="Alert")
        self.alert_tab_box = BoxLayout()
        self.alert_tab_box.orientation = 'vertical'
        self.alert_tab_box.size_hint = 1, 1
        #self.alert_tab.content = self.alert_tab_box

        self.alert_tab_scroll = ScrollView(
                        size_hint=(1, 1),
                        size=self.alert_tab_box.size,
                        #size=Window.size,
                        scroll_type=['bars', 'content'],
                        do_scroll_y=True,
                        do_scroll_x=False
                    )
        self.alert_tab_box.add_widget(self.alert_tab_scroll)


        self.alert_tab_alert_buttons = ButtonList()
        self.alert_tab_alert_buttons.bind(minimum_height=self.alert_tab_alert_buttons.setter('height'))
        self.alert_tab_alert_buttons.cols = 1
        self.alert_tab_alert_buttons.size_hint_y = None
        self.alert_tab_alert_buttons.row_default_height = '30dp'
        self.alert_tab_alert_buttons.row_force_default = True
        self.alert_tab_alert_buttons.spacing = 0, 0
        self.alert_tab_alert_buttons.padding = 0, 0

        self.alert_tab_scroll.add_widget(self.alert_tab_alert_buttons)


        #self.requests_tab = TabbedPanelHeader(text="Requests")

        self.layout.default_tab_content = self.alert_tab_box
        self.layout.default_tab_text = "Alerts"
        #self.layout.add_widget(self.status_tab)
        #self.layout.add_widget(self.alert_tab)
        #self.layout.add_widget(self.requests_tab)

        self.request_pending_alerts()

        return self.layout
Exemple #55
0
 def __init__(self, rx_port, tx_port):
     self._rx_port, self._tx_port = rx_port, tx_port
     osc.init()
     self.oscid = osc.listen(port=rx_port)
     Clock.schedule_interval(lambda *x: osc.readQueue(self.oscid), 0)
Exemple #56
0
 def __init__(self):
     """ Create a listener and start managing comms. """
     osc.init()
     self.osc_id = osc.listen(ipAddr='127.0.0.1', port=OSCServer.server_port)
     osc.bind(self.osc_id, self.kivy_server, 'kivy_server')
Exemple #57
0
        my_id.locked = 1
        stopAll()
        sleep(random.uniform(0, 3))
        if f9.is_available == 0:
            f9.is_available = 1
            f9.videoPlay()
        print ('id 9 touched')
    if int(message[2]) == 0:
        stopAll()
        sleep(random.uniform(0, 3))
        if my_video.is_available == 0:
            my_video.is_available = 1
            my_video.self_video_play()
        my_id.locked = 0
        print ('Play My video')


if __name__ == '__main__':
    osc.init()
    oscid = osc.listen(ipAddr='0.0.0.0', port=serviceport)
    osc.bind(oscid, derrick_osc, '/derrick/osc')

    Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
    print (my_id.id_to_set, 'id_to_set')
    print (croparea_setter(my_id.id_to_set))

    if my_video.is_available == 0:
        my_video.is_available = 1
        my_video.self_video_play()

    DerrickApp().run()