1 package jp.osdn.gokigen.gokigenassets.camera.theta.operation
3 import android.util.Log
4 import jp.osdn.gokigen.gokigenassets.camera.theta.status.IThetaSessionIdProvider
5 import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
7 class ThetaOptionGetControl(private val sessionIdProvider: IThetaSessionIdProvider, private val executeUrl : String = "http://192.168.1.1")
9 private val httpClient = SimpleHttpClient()
15 fun getOptions(options: String, useOSCv2: Boolean, callBack: IOperationCallback? = null)
17 Log.v(TAG, "getOptions() OSCv2:$useOSCv2 MSG : $options")
23 val getOptionsUrl = "${executeUrl}/osc/commands/execute"
24 val postData = if (useOSCv2) "{\"name\":\"camera.getOptions\",\"parameters\":{\"timeout\":0, \"optionNames\": $options}}" else "{\"name\":\"camera.getOptions\",\"parameters\":{\"sessionId\": \"" + sessionIdProvider.sessionId + "\", \"optionNames\": $options}}"
25 val result: String? = httpClient.httpPostWithHeader(getOptionsUrl, postData, null, "application/json;charset=utf-8", timeoutMs)
26 if ((result != null) && (result.isNotEmpty()))
28 Log.v(TAG, " getOptions() : $result")
29 callBack?.operationExecuted(0, result)
33 Log.v(TAG, "getOptions() reply is null or empty. $postData")
34 callBack?.operationExecuted(-1, "")
40 callBack?.operationExecuted(-1, e.localizedMessage)
48 callBack?.operationExecuted(-1, e.localizedMessage)
54 private val TAG = ThetaOptionGetControl::class.java.simpleName
55 private const val timeoutMs = 1500