예제 #1
0
파일: plugin.py 프로젝트: OpenESI/Wetek-ESI
	def gotoXcalc(satlon, sitelat, sitelon):
		def azimuth2Rotorcode(angle):
			gotoXtable = (0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E)
			a = int(round(abs(angle) * 10.0))
			return ((a / 10) << 4) + gotoXtable[a % 10]

		satHourAngle = rotor_calc.calcSatHourangle(satlon, sitelat, sitelon)
		if sitelat >= 0: # Northern Hemisphere
			rotorCmd = azimuth2Rotorcode(180 - satHourAngle)
			if satHourAngle <= 180: # the east
				rotorCmd |= 0xE000
			else:					# west
				rotorCmd |= 0xD000
		else: # Southern Hemisphere
			if satHourAngle <= 180: # the east
				rotorCmd = azimuth2Rotorcode(satHourAngle) | 0xD000
			else: # west
				rotorCmd = azimuth2Rotorcode(360 - satHourAngle) | 0xE000
		return rotorCmd
예제 #2
0
	def gotoXcalc(satlon, sitelat, sitelon):
		def azimuth2Rotorcode(angle):
			gotoXtable = (0x00, 0x02, 0x03, 0x05, 0x06, 0x08, 0x0A, 0x0B, 0x0D, 0x0E)
			a = int(round(abs(angle) * 10.0))
			return ((a / 10) << 4) + gotoXtable[a % 10]

		satHourAngle = rotor_calc.calcSatHourangle(satlon, sitelat, sitelon)
		if sitelat >= 0: # Northern Hemisphere
			rotorCmd = azimuth2Rotorcode(180 - satHourAngle)
			if satHourAngle <= 180: # the east
				rotorCmd |= 0xE000
			else:					# west
				rotorCmd |= 0xD000
		else: # Southern Hemisphere
			if satHourAngle <= 180: # the east
				rotorCmd = azimuth2Rotorcode(satHourAngle) | 0xD000
			else: # west
				rotorCmd = azimuth2Rotorcode(360 - satHourAngle) | 0xE000
		return rotorCmd
예제 #3
0
    def fncAddCommand(self, lObjItem):
        lStrConfig = lObjItem.getProperty('config')
        lStrValue = lObjItem.getProperty('value')
        lStrTyp = lObjItem.getProperty('typ')
        lStrIndex = lObjItem.getProperty('idx')
        if self.lIntSelectedConfig == -1:
            self.lIntSelectedConfig = self.getControl(
                1000).getSelectedPosition()
        lArrValue = [_(32148), _(32149), _(32305), _(32151)]
        #lArrValue = [_(32148), _(32149), _(32151)]
        lObjSelectDialog = xbmcgui.Dialog()
        lIntResult = lObjSelectDialog.select(_(32150), lArrValue)
        if lIntResult == 0:  #Set Switch
            lArrNotUsable = ["User-defined", "Tune-22k", "Disabled"]
            for lStrVersion in self.lDicDiSEqC['modes']:
                lBolExist = False
                for lStrCommand in self.lDicDiSEqCLNBs[lStrConfig]['commands']:
                    if lStrVersion == self.lDicDiSEqCLNBs[lStrConfig][
                            'commands'][lStrCommand]['mode']:
                        lBolExist = True
                if lBolExist == True:
                    lArrNotUsable.append(lStrVersion)
            lStrSwitchVersion = self.fncSelectCustomPortVersion(lArrNotUsable)
            if lStrSwitchVersion == "Disabled":
                return 0
            if not lStrSwitchVersion is None:
                lStrSwitchPort = int(
                    self.fncSelectCustomPortNumber(lStrSwitchVersion))
                if not lStrSwitchPort is None:
                    if lStrSwitchVersion == "Tune-22k":
                        if lStrSwitchPort == 1:
                            lStrCommand = "t"
                            lStrSwitchPort = "t"
                        elif lStrSwitchPort == 2:
                            lStrCommand = "T"
                            lStrSwitchPort = "T"
                    elif lStrSwitchVersion == "Toneburst":
                        if lStrSwitchPort == 1:
                            lStrCommand = "A"
                            lStrSwitchPort = "A"
                        elif lStrSwitchPort == 2:
                            lStrCommand = "B"
                            lStrSwitchPort = "B"
                    elif lStrSwitchVersion == "DiSEqC-1.0":
                        lStrCommand = "W50 [E0 00 00] W50 [E0 00 03] W150 [E0 10 38 F%X]" % (
                            2 + ((lStrSwitchPort - 1) * 4))
                    else:
                        lStrCommand = "W50 [E0 00 00] W50 [E0 00 03] W150 [E0 10 39 F%X]" % (
                            (lStrSwitchPort - 1))

                    if str(lStrIndex) != '':
                        lIntCmdEntry = lStrIndex
                    else:
                        if len(self.lDicDiSEqCLNBs[lStrConfig]
                               ['commands']) == 0:
                            lIntCmdEntry = 1
                        else:
                            lIntCmdEntry = max(
                                int(x) for x in self.lDicDiSEqCLNBs[lStrConfig]
                                ['commands'].keys()) + 1

                    self.lDicDiSEqCLNBs[lStrConfig]['commands'][str(
                        lIntCmdEntry)] = {
                            'name': 32148,
                            'value': str(lStrSwitchPort),
                            'mode': lStrSwitchVersion,
                            'cmd': lStrCommand
                        }

        elif lIntResult == 1:  #Set Position
            lObjDialog = xbmcDialog = xbmcgui.Dialog()
            lIntReturn = lObjDialog.numeric(0, _(32153), '')
            if lIntReturn >= 0:
                if str(lStrIndex) != '':
                    lIntCmdEntry = int(lStrIndex)
                else:
                    if len(self.lDicDiSEqCLNBs[lStrConfig]['commands']) == 0:
                        lIntCmdEntry = 1
                    else:
                        lIntCmdEntry = max(
                            int(x) for x in self.lDicDiSEqCLNBs[lStrConfig]
                            ['commands'].keys()) + 1

                lStrCommand = "W50 [E0 31 60] W150 [E0 31 6B %02X]" % int(
                    lIntReturn)
                self.lDicDiSEqCLNBs[lStrConfig]['commands'][str(
                    lIntCmdEntry)] = {
                        'name': 32149,
                        'value': str(lIntReturn),
                        'mode': "DiSEqC-1.2",
                        'cmd': lStrCommand
                    }

        elif lIntResult == 2:  #Set Position (USALS)
            lObjDialog = xbmcDialog = xbmcgui.Dialog()
            lDblLong = float(lObjDialog.input(_(32306), ''))
            if lDblLong >= 0:
                lDblLat = float(lObjDialog.input(_(32307), ''))
                if lDblLat >= 0:
                    lDblSat = float(lObjDialog.input(_(32308), ''))
                    if lDblSat >= 0:
                        lDblHA = rotor_calc.calcSatHourangle(
                            lDblSat, lDblLat, lDblLong)
                        if lDblLat >= 0:
                            rotorCmd = rotor_calc.azimuth2Rotorcode(180 -
                                                                    lDblHA)
                            if lDblHA <= 180:
                                rotorCmd |= 0xE000
                            else:
                                rotorCmd |= 0xD000
                        else:
                            if lDblHA <= 180:
                                rotorCmd = rotor_calc.azimuth2Rotorcode(
                                    lDblHA) | 0xD000
                            else:
                                rotorCmd = rotor_calc.azimuth2Rotorcode(
                                    360 - lDblHA) | 0xE000
                        lStrCommand = "W50 [E0 31 60] W150 [E010%X]" % rotorCmd

                        if str(lStrIndex) != '':
                            lIntCmdEntry = lStrIndex
                        else:
                            if len(self.lDicDiSEqCLNBs[lStrConfig]
                                   ['commands']) == 0:
                                lIntCmdEntry = 1
                            else:
                                lIntCmdEntry = max(
                                    int(x)
                                    for x in self.lDicDiSEqCLNBs[lStrConfig]
                                    ['commands'].keys()) + 1

                        self.lDicDiSEqCLNBs[lStrConfig]['commands'][str(
                            lIntCmdEntry)] = {
                                'name': 32149,
                                'value': 'USALS',
                                'mode': "DiSEqC-1.2",
                                'cmd': lStrCommand
                            }

        elif lIntResult == 3:  #Delete
            del self.lDicDiSEqCLNBs[lStrConfig]['commands'][lStrIndex]

        self.fncLnbConfigMenu(lObjItem)
    def fncAddCommand(self, lObjItem):
        lStrConfig = lObjItem.getProperty('config')
        lStrValue = lObjItem.getProperty('value')
        lStrTyp = lObjItem.getProperty('typ')
        lStrIndex = lObjItem.getProperty('idx')
        if self.lIntSelectedConfig == -1:
            self.lIntSelectedConfig = self.getControl(1000).getSelectedPosition()      
        lArrValue = [_(32148), _(32149), _(32305), _(32151)]
        #lArrValue = [_(32148), _(32149), _(32151)]
        lObjSelectDialog = xbmcgui.Dialog()
        lIntResult = lObjSelectDialog.select(_(32150), lArrValue)
        if lIntResult == 0: #Set Switch
            lArrNotUsable = ["User-defined", "Tune-22k", "Disabled"]
            for lStrVersion in self.lDicDiSEqC['modes']:
                lBolExist = False
                for lStrCommand in self.lDicDiSEqCLNBs[lStrConfig]['commands']:
                    if lStrVersion == self.lDicDiSEqCLNBs[lStrConfig]['commands'][lStrCommand]['mode']:
                        lBolExist = True
                if lBolExist == True:
                    lArrNotUsable.append(lStrVersion)
            lStrSwitchVersion = self.fncSelectCustomPortVersion(lArrNotUsable)
            if lStrSwitchVersion == "Disabled":
                return 0               
            if not lStrSwitchVersion is None: 
                lStrSwitchPort = int(self.fncSelectCustomPortNumber(lStrSwitchVersion))             
                if not lStrSwitchPort is None: 
                    if lStrSwitchVersion == "Tune-22k":
                        if lStrSwitchPort == 1:
                            lStrCommand = "t"
                            lStrSwitchPort = "t"
                        elif lStrSwitchPort == 2:
                            lStrCommand = "T"
                            lStrSwitchPort = "T"
                    elif lStrSwitchVersion == "Toneburst":
                        if lStrSwitchPort == 1:
                            lStrCommand = "A"
                            lStrSwitchPort = "A"
                        elif lStrSwitchPort == 2:
                            lStrCommand = "B"
                            lStrSwitchPort = "B"
                    elif lStrSwitchVersion == "DiSEqC-1.0":
                        lStrCommand = "W50 [E0 00 00] W50 [E0 00 03] W150 [E0 10 38 F%X]" % (2 + ((lStrSwitchPort-1) * 4))
                    else:
                        lStrCommand = "W50 [E0 00 00] W50 [E0 00 03] W150 [E0 10 39 F%X]" % ((lStrSwitchPort-1))
                    
                    if str(lStrIndex) != '':
                        lIntCmdEntry = lStrIndex
                    else:
                        if len(self.lDicDiSEqCLNBs[lStrConfig]['commands']) == 0:
                            lIntCmdEntry = 1
                        else:                   
                            lIntCmdEntry = max(int(x) for x in self.lDicDiSEqCLNBs[lStrConfig]['commands'].keys()) + 1
                        
                    self.lDicDiSEqCLNBs[lStrConfig]['commands'][str(lIntCmdEntry)] = {'name':32148, 'value':str(lStrSwitchPort), 
                        'mode':lStrSwitchVersion, 'cmd':lStrCommand}
            
        elif lIntResult == 1: #Set Position
            lObjDialog = xbmcDialog = xbmcgui.Dialog()
            lIntReturn = lObjDialog.numeric(0, _(32153), '')
            if lIntReturn >= 0:
                if str(lStrIndex) != '':
                    lIntCmdEntry = int(lStrIndex)
                else:
                    if len(self.lDicDiSEqCLNBs[lStrConfig]['commands']) == 0:
                        lIntCmdEntry = 1
                    else:                   
                        lIntCmdEntry = max(int(x) for x in self.lDicDiSEqCLNBs[lStrConfig]['commands'].keys()) + 1

                lStrCommand = "W50 [E0 31 60] W150 [E0 31 6B %02X]" % int(lIntReturn)  
                self.lDicDiSEqCLNBs[lStrConfig]['commands'][str(lIntCmdEntry)] = {'name':32149, 'value':str(lIntReturn), 
                    'mode':"DiSEqC-1.2", 'cmd':lStrCommand}            
                
        elif lIntResult == 2: #Set Position (USALS)
            lObjDialog = xbmcDialog = xbmcgui.Dialog()
            lDblLong = float(lObjDialog.input(_(32306), ''))
            if lDblLong >= 0:
                lDblLat = float(lObjDialog.input(_(32307), ''))
                if lDblLat >= 0:                
                    lDblSat = float(lObjDialog.input(_(32308), ''))
                    if lDblSat >= 0:
                        lDblHA = rotor_calc.calcSatHourangle(lDblSat, lDblLat, lDblLong)
                        if lDblLat >= 0:
                            rotorCmd = rotor_calc.azimuth2Rotorcode(180 - lDblHA)
                            if lDblHA <= 180:
                                rotorCmd |= 0xE000
                            else:
                                rotorCmd |= 0xD000
                        else: 
                            if lDblHA <= 180:
                                rotorCmd = rotor_calc.azimuth2Rotorcode(lDblHA) | 0xD000
                            else:
                                rotorCmd = rotor_calc.azimuth2Rotorcode(360 - lDblHA) | 0xE000                       
                        lStrCommand = "W50 [E0 31 60] W150 [E010%X]" % rotorCmd  
                        
                        if str(lStrIndex) != '':
                            lIntCmdEntry = lStrIndex
                        else:
                            if len(self.lDicDiSEqCLNBs[lStrConfig]['commands']) == 0:
                                lIntCmdEntry = 1
                            else:                   
                                lIntCmdEntry = max(int(x) for x in self.lDicDiSEqCLNBs[lStrConfig]['commands'].keys()) + 1
                            
                        self.lDicDiSEqCLNBs[lStrConfig]['commands'][str(lIntCmdEntry)] = {'name':32149, 'value':'USALS', 
                            'mode':"DiSEqC-1.2", 'cmd':lStrCommand}  
                    
        elif lIntResult == 3: #Delete
            del self.lDicDiSEqCLNBs[lStrConfig]['commands'][lStrIndex]

        self.fncLnbConfigMenu(lObjItem)