1 package jp.osdn.gokigen.gokigenassets.camera.vendor.panasonic.status
3 import android.util.Log
4 import jp.osdn.gokigen.gokigenassets.camera.interfaces.ICameraStatus
5 import jp.osdn.gokigen.gokigenassets.camera.vendor.panasonic.IPanasonicCamera
6 import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
7 import java.util.ArrayList
9 class CameraStatusListHolder(private val remote: IPanasonicCamera)
11 val http = SimpleHttpClient()
14 private val TAG = CameraStatusListHolder::class.java.simpleName
15 private const val TIMEOUT_MS = 3000
16 private const val MAX_RETRY_COUNT = 2
23 fun getAvailableItemList(key: String): List<String>
28 ICameraStatus.TAKE_MODE -> getAvailableTakeMode()
29 ICameraStatus.SHUTTER_SPEED -> getAvailableShutterSpeed()
30 ICameraStatus.APERTURE -> getAvailableAperture()
31 ICameraStatus.EXPREV -> getAvailableExpRev()
32 ICameraStatus.CAPTURE_MODE -> getAvailableCaptureMode()
33 ICameraStatus.ISO_SENSITIVITY -> getAvailableIsoSensitivity()
34 ICameraStatus.WHITE_BALANCE -> getAvailableWhiteBalance()
35 ICameraStatus.AE -> getAvailableMeteringMode()
36 ICameraStatus.EFFECT -> getAvailablePictureEffect()
37 ICameraStatus.TORCH_MODE -> getAvailableTorchMode()
38 //ICameraStatus.BATTERY -> getAvailableRemainBattery()
41 //Log.v(TAG, " ----- getAvailableItemList($key) ")
42 //sendCamGetSettingCmd("colormode")
51 private fun getAvailableTakeMode() : List<String>
56 private fun getAvailableTorchMode() : List<String>
58 return (listOf("OFF", "EXP. BRACKET", "FOCAL BRACKET", "WB BRACKET", "FOCUS BRACKET"))
61 private fun getAvailableShutterSpeed() : List<String>
129 private fun getAvailableAperture() : List<String>
168 private fun getAvailableExpRev() : List<String>
205 private fun getAvailablePictureEffect() : List<String>
207 return (listOf("OFF",
232 private fun getAvailableIsoSensitivity() : List<String>
234 return (listOf("ISO-i",
265 private fun getAvailableWhiteBalance() : List<String>
267 return (listOf("AWB",
286 private fun getAvailableMeteringMode() : List<String>
289 //return (listOf("MULTI", "CENTER", "SPOT", "HIGHLIGHT")) // SPOT測光に切り替えると、LVがうまく取れないので...
292 private fun getAvailableCaptureMode() : List<String>
320 fun setStatus(key: String, value: String)
322 Log.v(TAG, " setStatus(key:$key, value:$value)")
326 ICameraStatus.TAKE_MODE -> setTakeMode(value)
327 ICameraStatus.SHUTTER_SPEED -> setShutterSpeed(value)
328 ICameraStatus.APERTURE -> setAperture(value)
329 ICameraStatus.EXPREV -> setExpRev(value)
330 ICameraStatus.CAPTURE_MODE -> setCaptureMode(value)
331 ICameraStatus.ISO_SENSITIVITY -> setIsoSensitivity(value)
332 ICameraStatus.WHITE_BALANCE -> setWhiteBalance(value)
333 ICameraStatus.AE -> setMeteringMode(value)
334 ICameraStatus.EFFECT -> setPictureEffect(value)
335 ICameraStatus.TORCH_MODE -> setTorchMode(value)
336 //ICameraStatus.BATTERY -> setRemainBattery(value)
346 private fun setTakeMode(value: String)
348 Log.v(TAG, " setTakeMode($value)")
352 private fun setTorchMode(value: String)
354 val setValue = when (value) {
356 "EXP. BRACKET" -> "exposure"
357 "FOCAL BRACKET" -> "focal"
359 "FOCUS BRACKET" -> "focus"
362 sendCamSetSettingCmd("bracket", setValue, null)
365 private fun setShutterSpeed(value: String)
367 val setValue = when (value) {
368 "16000" -> "3584/256"
369 "13000" -> "3499/256"
370 "10000" -> "3414/256"
432 sendCamSetSettingCmd("shtrspeed", setValue, null)
435 private fun setAperture(value: String)
437 val setValue = when (value) {
473 sendCamSetSettingCmd("focal", setValue, null)
476 private fun setExpRev(value: String)
478 val setValue = when (value) {
512 sendCamSetSettingCmd("exposure", setValue, null)
515 private fun setCaptureMode(value: String)
517 //Log.v(TAG, " ===== setCaptureMode($value) =====")
518 val setValue = when (value) {
521 "NATURAL" -> "natural"
524 "SCENERY" -> "scenery"
525 "PORTRAIT" -> "portrait"
527 "CUSTOM1" -> "custom1"
528 "CUSTOM2" -> "custom2"
529 "CUSTOM3" -> "custom3"
530 "CUSTOM4" -> "custom4"
531 "CINELIKE_D" -> "cinelike_d"
532 "CINELIKE_V" -> "cinelike_v"
533 "L.MONO D" -> "l_bw_d"
534 "Like709" -> "709like"
537 "VLOG-GAMMA" -> "vlog-gamma"
539 "L.CLAS N" -> "l_cla_neo"
540 "L.MONO S" -> "l_bw_s"
543 sendCamSetSettingCmd("colormode", setValue, null)
546 private fun setIsoSensitivity(value: String)
548 val setValue = when (value) {
553 sendCamSetSettingCmd("iso", setValue, null)
556 private fun setWhiteBalance(value: String)
558 val setValue = when (value) {
560 "Daylight" -> "daylight"
563 "Incandescent" -> "halogen"
565 "Custom1" -> "white_set1"
566 "Custom2" -> "white_set2"
567 "Custom3" -> "white_set3"
568 "Custom4" -> "white_set4"
569 "Color Temp." -> "color_temp"
570 "K1" -> "color_temp1"
571 "K2" -> "color_temp2"
572 "K3" -> "color_temp3"
573 "K4" -> "color_temp4"
574 "AWBc" -> "auto_cool"
575 "AWBw" -> "auto_warm"
578 sendCamSetSettingCmd("whitebalance", setValue, null)
581 private fun setMeteringMode(value: String)
583 val setValue = when (value) {
587 "HIGHLIGHT" -> "highlight"
590 sendCamSetSettingCmd("lightmetering", setValue, null)
593 private fun setPictureEffect(value: String)
595 val setValue = when (value) {
603 "D.MONO" -> "dynamic_monochro"
604 "R.MONO" -> "rough_monochro"
605 "S.MONO" -> "silky_monochro"
606 "IART" -> "impressive_art"
607 "HDYN" -> "high_dynamic"
608 "XPRO" -> "cross_proc"
611 "BLEA" -> "bleach_bypass"
613 "SOFT" -> "soft_focus"
615 "STAR" -> "cross_filter"
616 "1CLR" -> "one_point_color"
620 sendCamSetSettingCmd("filter_setting", setValue, null)
623 private fun sendCamGetSettingCmd(type: String)
627 val urlToSend = remote.getCmdUrl() + "cam.cgi?mode=getsetting&type=$type"
628 val thread = Thread {
635 val reply: String = http.httpGet(urlToSend, TIMEOUT_MS)
636 if (reply.indexOf("<result>ok</result>") > 0)
639 Log.v(TAG, " ===== $urlToSend (OK) : $reply")
643 // エラー発生時は何回か(MAX_RETRY_COUNT分)再送する
644 Log.v(TAG, " $urlToSend (NG) : $reply ")
645 Thread.sleep(1000) // 1秒待つ
647 if(retryCount >= MAX_RETRY_COUNT)
667 private fun sendCamSetSettingCmd(msgType: String, msgValue: String, value2: String?)
671 //Log.v(TAG, " ------- sendCamSetSettingCmd($msgType, $msgValue, $value2)")
672 val sendMessage = if (value2 != null) { "cam.cgi?mode=setsetting&type=$msgType&value=$msgValue&value2=$value2" } else { "cam.cgi?mode=setsetting&type=$msgType&value=$msgValue" }
673 val thread = Thread {
680 val urlToSend = remote.getCmdUrl() + sendMessage
681 val reply: String = http.httpGet(urlToSend, TIMEOUT_MS)
682 if (reply.indexOf("<result>ok</result>") > 0)
685 // Log.v(TAG, " --- SET SETTING ($msgType,$msgValue): $reply")
689 // エラー発生時は何回か(MAX_RETRY_COUNT分)再送する
690 Log.v(TAG, " $urlToSend (NG) : $reply ")
691 Thread.sleep(1000) // 1秒待つ
693 if(retryCount >= MAX_RETRY_COUNT)