From 7211af7a8f9608633b6550822cbb7e6c76ed5b76 Mon Sep 17 00:00:00 2001 From: MRSa Date: Fri, 24 Sep 2021 23:52:37 +0900 Subject: [PATCH] =?utf8?q?OMDS=E6=A9=9F=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?utf8?q?=E3=82=92=E8=A1=8C=E3=81=86=EF=BC=88=E5=86=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../vendor/omds/status/OmdsCameraStatusWatcher.kt | 170 +++++++++++++++++---- 1 file changed, 143 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/omds/status/OmdsCameraStatusWatcher.kt b/app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/omds/status/OmdsCameraStatusWatcher.kt index be54ce5..2c36762 100644 --- a/app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/omds/status/OmdsCameraStatusWatcher.kt +++ b/app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/omds/status/OmdsCameraStatusWatcher.kt @@ -151,8 +151,11 @@ class OmdsCameraStatusWatcher(userAgent: String = "OlympusCameraKit", private va // OMDS機のイベント受信 val omdsEventUrl = "$executeUrl/get_camprop.cgi?com=desc&propname=desclist" latestEventResponse = http.httpGetWithHeader(omdsEventUrl, headerMap, null, TIMEOUT_MS) ?: "" - dumpLog(omdsEventUrl, latestEventResponse) - parseOmdsProperties(latestEventResponse) + if (latestEventResponse.isNotEmpty()) + { + dumpLog(omdsEventUrl, latestEventResponse) + parseOmdsProperties(latestEventResponse) + } } catch (e: Exception) { @@ -188,7 +191,7 @@ class OmdsCameraStatusWatcher(userAgent: String = "OlympusCameraKit", private va currentIsoSensitivity = "ISO " + getPropertyValue(eventResponse, "isospeedvalue") currentExpRev = getPropertyValue(eventResponse, "expcomp") - currentWhiteBalance = decideWhiteBalance(getPropertyValue(eventResponse, "wbvalue")) + currentWhiteBalance = "WB: " + decideWhiteBalance(getPropertyValue(eventResponse, "wbvalue")) currentPictureEffect = getPropertyValue(eventResponse, "colortone") currentCaptureMode = " DRIVE: " + getPropertyValue(eventResponse, "drivemode") @@ -201,10 +204,61 @@ class OmdsCameraStatusWatcher(userAgent: String = "OlympusCameraKit", private va private fun decideWhiteBalance(wbValue: String) : String { - - return ("WB: ($wbValue)") + try + { + return (when (wbValue) + { + "0" -> "AUTO" + "18" -> "Daylight" + "16" -> "Shade" + "17" -> "Cloudy" + "20" -> "Incandescent" + "35" -> "Fluorescent" + "64" -> "Underwater" + "23" -> "Flash" + "256" -> "WB1" + "257" -> "WB2" + "258" -> "WB3" + "259" -> "WB4" + "512" -> "CWB" + else -> "($wbValue)" + }) + } + catch (e: Exception) + { + e.printStackTrace() + } + return ("($wbValue)") } + private fun decideWhiteBalanceValue(wbName: String) : String + { + try + { + return (when (wbName) + { + "AUTO" -> "0" + "Daylight" -> "18" + "Shade" -> "16" + "Cloudy" -> "17" + "Incandescent" -> "20" + "Fluorescent" -> "35" + "Underwater" -> "64" + "Flash" -> "23" + "WB1" -> "256" + "WB2" -> "257" + "WB3" -> "258" + "WB4" -> "259" + "CWB" -> "512" + else -> "0" + }) + } + catch (e: Exception) + { + e.printStackTrace() + } + return ("0") + } private fun getPropertySelectionList(responseString: String, propertyString: String) : List { @@ -402,38 +456,107 @@ class OmdsCameraStatusWatcher(userAgent: String = "OlympusCameraKit", private va override fun getStatusList(key: String): List { -/**/ + if (useOpcProtocol) + { + return (getStatusListOpc(key, latestEventResponse)) + } + else + { + return (getStatusListOmds(key, latestEventResponse)) + } + } + + private fun getStatusListOpc(key: String, eventString: String): List + { try { - Log.v(TAG, " getStatusList($key)") + Log.v(TAG, " getStatusListOpc($key)") return (when (key) { +/* ICameraStatus.TAKE_MODE -> getPropertySelectionList(latestEventResponse, "takemode") ICameraStatus.SHUTTER_SPEED -> getPropertySelectionList(latestEventResponse, "shutspeedvalue") ICameraStatus.APERTURE -> getPropertySelectionList(latestEventResponse, "focalvalue") - ICameraStatus.EXPREV -> getPropertySelectionList(latestEventResponse, "expcomp") + ICameraStatus.ISO_SENSITIVITY -> getPropertySelectionList(latestEventResponse, "isospeedvalue") + ICameraStatus.EXPREV -> getPropertySelectionList(latestEventResponse, "expcomp") + + ICameraStatus.WHITE_BALANCE -> getAvailableWhiteBalance(latestEventResponse) + ICameraStatus.EFFECT -> getPropertySelectionList(latestEventResponse, "colortone") + ICameraStatus.CAPTURE_MODE -> getPropertySelectionList(latestEventResponse, "drivemode") + + ICameraStatus.AE -> getAvailableMeteringMode() + ICameraStatus.TORCH_MODE -> getAvailableTorchMode() + ICameraStatus.BATTERY -> getAvailableRemainBattery() + ICameraStatus.FOCUS_STATUS -> getAvailableFocusStatus() + ICameraStatus.FOCAL_LENGTH -> getAvailableFocalLength() + ICameraStatus.REMAIN_SHOTS -> getAvailableRemainShots() +*/ + else -> ArrayList() + }) + } + catch (e: Exception) + { + e.printStackTrace() + } + return (ArrayList()) + } + + + private fun getStatusListOmds(key: String, eventString: String): List + { + try + { + Log.v(TAG, " getStatusListOmds($key)") + return (when (key) { + ICameraStatus.TAKE_MODE -> getPropertySelectionList(eventString, "takemode") + ICameraStatus.SHUTTER_SPEED -> getPropertySelectionList(eventString, "shutspeedvalue") + ICameraStatus.APERTURE -> getPropertySelectionList(eventString, "focalvalue") + + ICameraStatus.ISO_SENSITIVITY -> getPropertySelectionList(eventString, "isospeedvalue") + ICameraStatus.EXPREV -> getPropertySelectionList(eventString, "expcomp") + + ICameraStatus.WHITE_BALANCE -> getAvailableWhiteBalance(eventString) + ICameraStatus.EFFECT -> getPropertySelectionList(eventString, "colortone") + ICameraStatus.CAPTURE_MODE -> getPropertySelectionList(eventString, "drivemode") + /* - ICameraStatus.CAPTURE_MODE -> getAvailableCaptureMode() - ICameraStatus.WHITE_BALANCE -> getAvailableWhiteBalance() ICameraStatus.AE -> getAvailableMeteringMode() - ICameraStatus.EFFECT -> getAvailablePictureEffect() ICameraStatus.TORCH_MODE -> getAvailableTorchMode() ICameraStatus.BATTERY -> getAvailableRemainBattery() ICameraStatus.FOCUS_STATUS -> getAvailableFocusStatus() ICameraStatus.FOCAL_LENGTH -> getAvailableFocalLength() ICameraStatus.REMAIN_SHOTS -> getAvailableRemainShots() */ - else -> java.util.ArrayList() + else -> ArrayList() }) } catch (e: Exception) { e.printStackTrace() } -/**/ return (ArrayList()) } + private fun getAvailableWhiteBalance(eventResponse: String) : List + { + try + { + val wbValueList = getPropertySelectionList(eventResponse, "wbvalue") + val wbItemList : ArrayList = ArrayList() + for (wbValue in wbValueList) + { + wbItemList.add(decideWhiteBalance(wbValue)) + } + return (wbItemList) + } + catch (e: Exception) + { + e.printStackTrace() + } + return (ArrayList()) + } + + override fun getStatus(key: String): String { try @@ -470,20 +593,13 @@ class OmdsCameraStatusWatcher(userAgent: String = "OlympusCameraKit", private va override fun setStatus(key: String, value: String) { - try + if (useOpcProtocol) { - if (useOpcProtocol) - { - setStatusOpc(key, value) - } - else - { - setStatusOmds(key, value) - } + setStatusOpc(key, value) } - catch (e: Exception) + else { - e.printStackTrace() + setStatusOmds(key, value) } } @@ -498,10 +614,10 @@ class OmdsCameraStatusWatcher(userAgent: String = "OlympusCameraKit", private va ICameraStatus.APERTURE -> sendStatusRequestOmds("focalvalue", value) ICameraStatus.EXPREV -> sendStatusRequestOmds("expcomp", value) ICameraStatus.ISO_SENSITIVITY -> sendStatusRequestOmds("isospeedvalue", value) - ICameraStatus.CAPTURE_MODE -> { } - ICameraStatus.WHITE_BALANCE -> { } + ICameraStatus.CAPTURE_MODE -> sendStatusRequestOmds("drivemode", value) + ICameraStatus.WHITE_BALANCE -> sendStatusRequestOmds("wbvalue", decideWhiteBalanceValue(value)) + ICameraStatus.EFFECT -> sendStatusRequestOmds("colortone", value) ICameraStatus.AE -> { } - ICameraStatus.EFFECT -> { } ICameraStatus.TORCH_MODE -> { } ICameraStatus.BATTERY -> { } ICameraStatus.FOCUS_STATUS -> { } -- 2.11.0