Skip to main content

KeyManager

class KeyManager

Description: This class is the MSDK Key management class. MSDK provides a set of methods to access the parameters of the hardware module and control the behavior of the hardware module, including the Value setting of AutelKey, Value acquisition, Value monitoring and Action execution. Create an AutelKey instance more conveniently through the createKey method provided by the KeyTools class.

    class KeyManager{
/**
* list of listener with key as keylistner and value as protomessagelistener
*/
private val listenerMap = HashMap<CommonCallbacks.KeyListener<*>, OnProtoMsgReceiveListener>()
}

method getDeviceId

     private fun getDeviceId(): Int 

Description: Obtain the device id (the remote control is different from the aircraft)

Input parameters: None。

Output parameters: None。

Related parameters: None。

method createProtoMsg

    private fun createProtoMsg(key: AutelKey<*>, type: Int): BaseProtoMsg 

Description: Creating prototype message

Input parameters: key: key objetc of Autel type: defined type of key

Output parameters: None。

Related parameters: None。

method onSuccessCallback

    private fun <Result> onSuccessCallback(
callback: CommonCallbacks.CompletionCallbackWithParam<Result>,
bean: Result?,
msg: BaseProtoMsg?
)

Description: Callback after success (switch to main thread)

Input parameters: callback: callback object of completion with result bean: result object msg: message of prototype

Output parameters: None。

Related parameters: CompletionCallbackWithParam。

method onSuccessWithNoData

    private fun onSuccessWithNoData(
callback: CommonCallbacks.CompletionCallback,
msg: BaseProtoMsg?
)

Description: Callback after success, no return value (switch to main thread)

Input parameters: callback: callback object of completion msg: message of prototype

Output parameters: None。

Related parameters: CompletionCallback。

method onFailCallback

    private fun <Result> onFailCallback(
callback: CommonCallbacks.CompletionCallbackWithParam<Result>?,
error: AutelStatusCode, errorMsg: String?, msg: BaseProtoMsg?
)

Description: Callback after failure (switch to main thread)

Input parameters: callback: callback object of completion with result object error: error code errorMsg: message of prototype msg: message of prototype

Output parameters: None。

Related parameters: None。

method onFailWithNoData

    private fun onFailWithNoData(
callback: CommonCallbacks.CompletionCallback?,
error: IAutelCode, errorMsg: String? = null, msg: BaseProtoMsg?
)

Description: Callback after failure, no return value (switch to main thread)

Input parameters: callback: callback object of completion error: error code errorMsg: message of prototype msg: message of prototype

Output parameters: None。

Related parameters: None。

method showReportLog

    private fun showReportLog(keyName: String, msg: BaseProtoMsg, result: Any?) 

Description: Show report log of key manager

Input parameters: keyName: key name msg: message about report result: result object of any type

Output parameters: None。

Related parameters: None。

method convertProtoMsg

    private fun convertProtoMsg(dst: BaseProtoMsg?): List<DroneParamResponse>? 

Description: Parse the return value into a DroneParamResponse collection

Input parameters: dst: proto message of proto base

Output parameters: Passing list of all drone params

Related parameters: DroneParamResponse。

method getResultString

    private fun getResultString(dst: BaseProtoMsg?): String 

Description: Parse the data returned by the master control into String, if the parsing error occurs, add corresponding prompts

Input parameters: dst proto message of proto base

Output parameters: returning string of header

Related parameters: None。

method convertProtoData

    private fun <Result> convertProtoData(
dst: BaseProtoMsg?,
callback: CommonCallbacks.CompletionCallbackWithParam<Result>?
): RspMessage?

Description: Parse proto data into RspMessage (because the data structures of get/set and action responses are different)

Input parameters: dst: proto message of proto base callback: call back object with result

Output parameters: response message returning

Related parameters: None。

method jointRspMessageParseFail

    private fun jointRspMessageParseFail(autelMessage: AutelMessageOuterClass.AutelMessage?): String 

Description: RspMessage parsing failed

Input parameters: autelMessage: message

Output parameters: string value append with message

Related parameters: None。

method jointDroneParamMessageResponseParseFail

     private fun jointDroneParamMessageResponseParseFail(
autelMessage: AutelMessageOuterClass.AutelMessage?,
rspMessage: RspMessage
): String

Description: DroneParamMessageResponse parsing failed

Input parameters: autelMessage: message rspMessage: response message

Output parameters: string value append with message and response message

Related parameters: AutelMessage,RspMessage。

method jointResponseListNull

    private fun jointResponseListNull(
autelMessage: AutelMessageOuterClass.AutelMessage?,
rspMessage: RspMessage
): String

Description: DroneParamMessageResponse responseList is null or empty

Input parameters: autelMessage: message rspMessage: response message

Output parameters: string value append with message and response message

Related parameters: None。

method jointResponseCodeError

    private fun jointResponseCodeError(response: DroneParamResponse): String 

Description: The responseCode of DroneParamResponse is not success

Input parameters: response: response message

Output parameters: String value append with response code and response message

Related parameters: None。

method jointBeanParseFail

    private fun jointBeanParseFail(response: DroneParamResponse): String  

Description: Data parsing of DroneParamResponse failed

Input parameters: response: response message

Output parameters: string value append with response

Related parameters: None。

method jointRspMessageDataParseFail

    private fun jointRspMessageDataParseFail(rspMessage: RspMessage): String  

Description: Data parsing of RspMessage failed

Input parameters: rspMessage: response message

Output parameters: string value append with response message

Related parameters: None。

method jointRspMessageCodeError

    private fun jointRspMessageCodeError(rspMessage: RspMessage): String 

Description: The responseCode of RspMessage is not success

Input parameters: rspMessage: response message

Output parameters: string value append with response code and response message

Related parameters: None。

method send

    private fun <T : BaseProtoMsg> send(msg: T, monitor: ProtoMsgSendMonitor?) 

Description: Sending base proto message

Input parameters: msg: T type monitor: prototype message send monitor object

Output parameters: None。

Related parameters: None。