Exemple #1
0
    def HandleScreen(self, newscr=True):

        # stop any watching for device stream
        config.toDaemon.put([])
        print self.NormalOn
        print self.NormalOff
        checknodes = [
            nm for nm in config.ISY.NodesByName
            if ((nm in self.NormalOn) or (nm in self.NormalOff))
        ]
        print checknodes
        states = isy.get_real_time_status(
            [config.ISY.NodesByName[x].address for x in checknodes])
        print states
        outspecnodes = []
        for node in states:
            nodename = config.ISY.NodesByAddr[node]
            if ((nodename in self.NormalOn) and
                (states[node] == 0)) or ((nodename in self.NormalOff) and
                                         (states[node] <> 0)):
                outspecnodes.append(node)
        for node in outspecnodes:
            print node, config.ISY.NodesByAddr[node].name, states[node]

        self.PaintBase()

        pygame.display.update()

        while 1:
            choice = config.DS.NewWaitPress(self)
            if choice[0] == WAITEXIT:
                return choice[1]
Exemple #2
0
	def HandleScreen(self, newscr=True):

		# stop any watching for device stream
		config.toDaemon.put([])
		print self.NormalOn
		print self.NormalOff
		checknodes = [nm for nm in config.ISY.NodesByName if ((nm in self.NormalOn) or (nm in self.NormalOff))]
		print checknodes
		states = isy.get_real_time_status([config.ISY.NodesByName[x].address for x in checknodes])
		print states
		outspecnodes = []
		for node in states:
			nodename = config.ISY.NodesByAddr[node]
			if ((nodename in self.NormalOn) and (states[node] == 0)) or (
						(nodename in self.NormalOff) and (states[node] <> 0)):
				outspecnodes.append(node)
		for node in outspecnodes:
			print node, config.ISY.NodesByAddr[node].name, states[node]

		self.PaintBase()

		pygame.display.update()

		while 1:
			choice = config.DS.NewWaitPress(self)
			if choice[0] == WAITEXIT:
				return choice[1]
Exemple #3
0
	def HandleScreen(self, newscr=True):

		def BlinkKey(scr, key, cycle):
			# thistime = finalstate if cycle % 2 <> 0 else not finalstate
			key.State = not key.State
			key.PaintKey()

		if newscr:
			# key screen change actually occurred
			self.PaintBase()
			self.subscriptionlist = {}
			debugPrint('Main', "Switching to screen: ", self.name)
			for K in self.keysbyord:
				if K.MonitorObj is not None:
					# skip program buttons
					self.subscriptionlist[K.MonitorObj.address] = K
			states = isy.get_real_time_status(self.subscriptionlist.keys())
			for K in self.keysbyord:
				if K.MonitorObj is not None:
					K.State = not (states[K.MonitorObj.address] == 0)  # K is off (false) only if state is 0

			debugPrint('Main', "Active Subscription List will be:")
			addressestoscanfor = ["Status"]
			for i in self.subscriptionlist:
				debugPrint('Main', "  Subscribe: ", i, self.subscriptionlist[i].name, " : ",
						   self.subscriptionlist[i].RealObj.name, ' via ', self.subscriptionlist[i].MonitorObj.name)
				addressestoscanfor.append(i)
			config.toDaemon.put(addressestoscanfor)
			self.PaintKeys()
		else:
			debugPrint('Main', "Skipping screen recreation: ", self.name)

		blinkproc = None
		blinktime = 0
		blinks = 0

		while 1:
			choice = config.DS.NewWaitPress(self, callbackint=blinktime, callbackproc=blinkproc, callbackcount=blinks)
			blinkproc = None
			blinktime = 0
			blinks = 0
			if (choice[0] == WAITNORMALBUTTON) or (choice[0] == WAITNORMALBUTTONFAST):
				# handle various keytype cases
				K = self.keysbyord[choice[1]]
				if K.type == "ONOFF":
					K.State = not K.State
					if K.RealObj is not None:
						K.RealObj.SendCommand(K.State, choice[0] <> WAITNORMALBUTTON)
					# config.Logs.Log("Sent command to " + K.RealObj.name)
					else:
						config.Logs.Log("Screen: " + self.name + " press unbound key: " + K.name, severity=logsupport.ConsoleWarning)
					K.PaintKey()
				elif K.type == "ONBLINKRUNTHEN":
					# force double tap for programs for safety - too easy to accidentally single tap with touchscreen
					if choice[0] == WAITNORMALBUTTONFAST:
						K.RealObj.runThen()
						blinkproc = functools.partial(BlinkKey, config.screen, K)
						blinktime = .5
						blinks = 8  # even number leaves final state of key same as initial state
						K.PaintKey()
					# leave K.State as is - key will return to off at end
				elif K.type == "ONOFFRUN":
					pass
			elif choice[0] == WAITEXIT:
				return choice[1]
			elif choice[0] == WAITISYCHANGE:
				K = self.subscriptionlist[choice[1][0]]
				ActState = int(choice[1][1]) <> 0

				if ActState <> K.State:
					K.State = ActState
					K.PaintKey()
Exemple #4
0
    def HandleScreen(self, newscr=True):
        def BlinkKey(scr, key, cycle):
            # thistime = finalstate if cycle % 2 <> 0 else not finalstate
            key.State = not key.State
            key.PaintKey()

        if newscr:
            # key screen change actually occurred
            self.PaintBase()
            self.subscriptionlist = {}
            debugprint(config.dbgMain, "Switching to screen: ", self.name)
            for K in self.keysbyord:
                if K.MonitorObj is not None:
                    # skip program buttons
                    self.subscriptionlist[K.MonitorObj.address] = K
            states = isy.get_real_time_status(self.subscriptionlist.keys())
            for K in self.keysbyord:
                if K.MonitorObj is not None:
                    K.State = not (states[K.MonitorObj.address] == 0
                                   )  # K is off (false) only if state is 0

            debugprint(config.dbgMain, "Active Subscription List will be:")
            addressestoscanfor = ["Status"]
            for i in self.subscriptionlist:
                debugprint(config.dbgMain, "  Subscribe: ", i,
                           self.subscriptionlist[i].name, " : ",
                           self.subscriptionlist[i].RealObj.name, ' via ',
                           self.subscriptionlist[i].MonitorObj.name)
                addressestoscanfor.append(i)
            config.toDaemon.put(addressestoscanfor)
            self.PaintKeys()
        else:
            debugprint(config.dbgMain, "Skipping screen recreation: ",
                       self.name)

        blinkproc = None
        blinktime = 0
        blinks = 0

        while 1:
            choice = config.DS.NewWaitPress(self,
                                            callbackint=blinktime,
                                            callbackproc=blinkproc,
                                            callbackcount=blinks)
            blinkproc = None
            blinktime = 0
            blinks = 0
            if (choice[0] == WAITNORMALBUTTON) or (choice[0]
                                                   == WAITNORMALBUTTONFAST):
                # handle various keytype cases
                K = self.keysbyord[choice[1]]
                if K.type == "ONOFF":
                    K.State = not K.State
                    if K.RealObj is not None:
                        K.RealObj.SendCommand(K.State,
                                              choice[0] <> WAITNORMALBUTTON)
                    # config.Logs.Log("Sent command to " + K.RealObj.name)
                    else:
                        config.Logs.Log("Screen: " + self.name +
                                        " press unbound key: " + K.name,
                                        severity=logsupport.ConsoleWarning)
                    K.PaintKey()
                elif K.type == "ONBLINKRUNTHEN":
                    # force double tap for programs for safety - too easy to accidentally single tap with touchscreen
                    if choice[0] == WAITNORMALBUTTONFAST:
                        K.RealObj.runThen()
                        blinkproc = functools.partial(BlinkKey, config.screen,
                                                      K)
                        blinktime = .5
                        blinks = 8  # even number leaves final state of key same as initial state
                        K.PaintKey()
                    # leave K.State as is - key will return to off at end
                elif K.type == "ONOFFRUN":
                    pass
            elif choice[0] == WAITEXIT:
                return choice[1]
            elif choice[0] == WAITISYCHANGE:
                K = self.subscriptionlist[choice[1][0]]
                ActState = int(choice[1][1]) <> 0

                if ActState <> K.State:
                    K.State = ActState
                    K.PaintKey()