コード例 #1
0
    def SendCommand(self,
                    oAction: cAction,
                    oSetting: cInterFaceSettings,
                    uRetVar: str,
                    bNoLogOut: bool = False) -> eReturnCode:
        super().SendCommand(oAction=oAction,
                            oSetting=oSetting,
                            uRetVar=uRetVar,
                            bNoLogOut=bNoLogOut)

        eRet: eReturnCode = eReturnCode.Error

        if oAction.uCCF_Code != u"":
            # noinspection PyUnresolvedReferences
            oAction.oIRCode = CCfToAndroidIR(oAction.uCCF_Code,
                                             ToInt(oAction.uRepeatCount))
            oAction.uCCF_Code = u""

        uCmd: str = ReplaceVars(oAction.uCmd)

        self.ShowInfo(uMsg=u'Sending Command: ' + uCmd + u' to ' +
                      oSetting.uConfigName)

        oSetting.Connect()
        if oSetting.bIsConnected:
            try:
                Logger.debug("Sending IR Commend to IRBLASTER")
                irblaster.transmit(oAction.oIRCode.iFrequency,
                                   oAction.oIRCode.aPattern)
                eRet = eReturnCode.Success
            except Exception as ex:
                self.ShowWarning(uMsg=u'Can\'t send message: ' + str(ex))
        else:
            Logger.debug("Not Connected")
        return eRet
コード例 #2
0
    def SendCommand(self,
                    oAction: cAction,
                    oSetting: cInterFaceSettings,
                    uRetVar: str,
                    bNoLogOut: bool = False) -> eReturnCode:
        super().SendCommand(oAction=oAction,
                            oSetting=oSetting,
                            uRetVar=uRetVar,
                            bNoLogOut=bNoLogOut)
        eRet: eReturnCode = eReturnCode.Error

        if oAction.uCCF_Code:
            # noinspection PyUnresolvedReferences
            oAction.uCmd = CCF2ITach(oAction.uCCF_Code,
                                     ToInt(oAction.uRepeatCount))
            oAction.uCCF_Code = u""

        uCmd: str = ReplaceVars(oAction.uCmd,
                                self.uObjectName + u'/' + oSetting.uConfigName)
        uCmd = ReplaceVars(uCmd)
        self.ShowInfo(uMsg=u'Sending Command: ' + uCmd + u' to ' +
                      oSetting.aIniSettings.uHost + ':' +
                      oSetting.aIniSettings.uPort)

        oSetting.Connect()
        if oSetting.bIsConnected:
            uMsg: str = uCmd + u'\r\n'
            try:
                oSetting.oSocket.sendall(ToBytes(uMsg))
                byResponse = oSetting.oSocket.recv(self.iBufferSize)
                self.ShowDebug(uMsg=u'Response' + ToUnicode(byResponse),
                               uParConfigName=oSetting.uConfigName)
                if 'completeir' in ToUnicode(byResponse):
                    eRet = eReturnCode.Success
                else:
                    eRet = eReturnCode.Error
            except Exception as e:
                self.ShowError(uMsg=u'can\'t Send Message',
                               uParConfigName=u'',
                               oException=e)
                eRet = eReturnCode.Error

        self.CloseSettingConnection(oSetting=oSetting, bNoLogOut=bNoLogOut)
        return eRet
コード例 #3
0
    def SendCommand(self,oAction:cAction,oSetting:cInterFaceSettings,uRetVar:str,bNoLogOut:bool=False) -> eReturnCode:
        super().SendCommand(oAction=oAction,oSetting=oSetting,uRetVar=uRetVar,bNoLogOut=bNoLogOut)

        eRet:eReturnCode = eReturnCode.Error

        if oAction.uCCF_Code != u"":
            # noinspection PyUnresolvedReferences
            oAction.uCmd=CCfToKeene(oAction.uCCF_Code,ToInt(oAction.uRepeatCount))
            oAction.uCCF_Code = u""

        uCmd:str=ReplaceVars(oAction.uCmd)

        self.ShowInfo(uMsg=u'Sending Command: '+uCmd + u' to '+oSetting.aIniSettings.uHost+':'+oSetting.aIniSettings.uPort)

        oSetting.Connect()
        if oSetting.bIsConnected:
            uMsg=uCmd+u'\r\n'
            try:
                uMsg=ReplaceVars(uMsg,self.uObjectName+'/'+oSetting.uConfigName)
                oSetting.oSocket.sendto(ToBytes(uMsg), (oSetting.aIniSettings.uHost, int(oSetting.aIniSettings.uPort)))
                byResponse, addr =  oSetting.oSocket.recvfrom(self.iBufferSize)
                uResponse = ToUnicode(byResponse)
                self.ShowDebug(uMsg=u'Response'+uResponse,uParConfigName=oSetting.uConfigName)
                if 'ACK' in uResponse:
                    eRet = eReturnCode.Success
                else:
                    eRet = eReturnCode.Error
            except Exception as e:
                if str(e)!="timed out":
                    self.ShowError(uMsg=u'Can\'t send message',uParConfigName=oSetting.uConfigName,oException=e)
                else:
                    self.ShowWarning(uMsg=u'Can\'t send message: time out',uParConfigName=oSetting.uConfigName)

                eRet = eReturnCode.Error

        self.CloseSettingConnection(oSetting=oSetting, bNoLogOut=bNoLogOut)
        return eRet
コード例 #4
0
 def ReadAction(self, oAction: cAction) -> None:
     super().ReadAction(oAction)
     oAction.uCCF_Code = oAction.dActionPars.get(u'cmd_ccf', u'')
     oAction.uRepeatCount = oAction.dActionPars.get(
         u'repeatcount', u'´1')