var color = Color.WHITE
try
{
- if (currentRemainBatteryPercent < 30)
+ if (currentRemainBatteryPercent <= 30.1)
{
color = Color.RED
}
- else if (currentRemainBatteryPercent < 50)
+ else if (currentRemainBatteryPercent <= 50.1)
{
color = Color.YELLOW
}
currentCameraStatus = parseEventStatus(currentCameraStatus, jsonObject, "cameraStatus", "cameraStatus", 1)
currentExposureMode = parseEventStatus(currentExposureMode, jsonObject, "exposureMode", "currentExposureMode", 18)
currentShootMode = parseEventStatus(currentShootMode, jsonObject, "shootMode", "currentShootMode",21)
- currentExposureCompensation = parseEventStatus(currentExposureCompensation, jsonObject, "exposureCompensation", "currentExposureCompensation",25)
+ currentExposureCompensation = parseExposureCompensation(currentExposureCompensation, jsonObject)
currentFlashMode = parseEventStatus(currentFlashMode, jsonObject, "flashMode", "currentFlashMode",26)
currentFNumber = parseEventStatus(currentFNumber, jsonObject, "fNumber", "currentFNumber",27)
currentRemainBattery = parseBatteryInfo(currentRemainBattery, jsonObject)
}
+ private fun parseExposureCompensation(currentStatus: String, replyJson: JSONObject) : String
+ {
+ val indexOfCameraStatus = 25
+ var eventStatus = currentStatus
+ try
+ {
+ val resultsObj = replyJson.getJSONArray("result")
+ if ((resultsObj.length() > indexOfCameraStatus)&&(!resultsObj.isNull(indexOfCameraStatus)))
+ {
+ val cameraStatusObj = resultsObj.getJSONObject(indexOfCameraStatus)
+ val type = cameraStatusObj.getString("type")
+ if ("exposureCompensation" == type)
+ {
+ val currentIndex = cameraStatusObj.getInt("currentExposureCompensation")
+ val currentStep = cameraStatusObj.getInt("stepIndexOfExposureCompensation")
+ val showValue = currentIndex.toDouble() / if (currentStep == 2) { 2.0 } else { 3.0 }
+ eventStatus = String.format("%+1.1f", showValue)
+ }
+ else
+ {
+ Log.w(TAG, "Event reply: Illegal Index ($indexOfCameraStatus) $type : $cameraStatusObj")
+ }
+ }
+ }
+ catch (e: Exception)
+ {
+ e.printStackTrace()
+ }
+ return (eventStatus)
+ }
+
private fun parseBatteryInfo(currentStatus: String, replyJson: JSONObject) : String
{
val indexOfCameraStatus = 56
val type = cameraStatusObj.getString("type")
if ("batteryInfo" == type)
{
- Log.v(TAG, " =====> $batteryInfoObj")
+ //Log.v(TAG, " =====> $batteryInfoObj")
//eventStatus = cameraStatusObj.getString(key)
-
val numerator = batteryInfoObj.getInt("levelNumer")
val denominator = batteryInfoObj.getInt("levelDenom")
if ((numerator <= 0)||(denominator <= 0))
class SonyStatusCandidates()
{
private lateinit var cameraApi: ISonyCameraApi
+
+ private var expRevCurrentIndex: Int = 0
+ private var expRevUpperIndex: Int = 0
+ private var expRevLowerIndex: Int = 0
+ private var expRevStepIndex: Int = 0
+
fun setCameraApi(sonyCameraApi: ISonyCameraApi)
{
cameraApi = sonyCameraApi
fun getAvailableExpRev(): List<String?>
{
-/*
- val apertureList : ArrayList<String> = ArrayList()
+ val availableExpRevList : ArrayList<String> = ArrayList()
try
{
if (::cameraApi.isInitialized)
val resultsObj = replyJson?.getJSONArray("result")
if (resultsObj?.isNull(1) == false)
{
- val availableItemArray = resultsObj.getJSONArray(1)
- for (index in 0 until availableItemArray.length())
+ Log.v(TAG, " getAvailableExposureCompensation: $resultsObj")
+ expRevCurrentIndex = resultsObj.getInt(0)
+ expRevUpperIndex = resultsObj.getInt(1)
+ expRevLowerIndex = resultsObj.getInt(2)
+ expRevStepIndex = resultsObj.getInt(3) // 1: 1/3EV, 2: 1/2EV
+ for (index in expRevLowerIndex..expRevUpperIndex)
{
- val itemString = availableItemArray.getString(index)
- apertureList.add(itemString)
+ val showValue = index.toDouble() / if (expRevStepIndex == 2) { 2.0 } else { 3.0 }
+ availableExpRevList.add(String.format("%+1.1f", showValue))
}
}
}
{
e.printStackTrace()
}
-*/
- return (ArrayList())
+ return (availableExpRevList)
}
fun getAvailableCaptureMode(): List<String?>
{
try
{
-/*
- val replyJson = cameraApi.callGenericSonyApiMethod("camera", "setxxx", JSONArray().put(value), "1.0")
- if (cameraApi.isErrorReply(replyJson))
+ val doubleValue = value.toDoubleOrNull()
+ val step : Double = if (expRevStepIndex == 2) { 2.0 } else { 3.0 }
+ if (doubleValue == null)
{
- Log.v(TAG, " REPLY ERROR(aperture) : $replyJson")
+ Log.v(TAG," ----- setExposureCompensation : cannot convert to double : $value" )
+ return
}
-*/
+
+ Log.v(TAG, " ----- setExpRev($value) : $doubleValue ($expRevLowerIndex..$expRevUpperIndex) step:$step")
+
+ for (index in expRevLowerIndex..expRevUpperIndex)
+ {
+ val checkValue = index.toDouble() / step
+ if ((doubleValue - checkValue) <= 0.0f)
+ {
+ Log.v(TAG, " ----- SET exposureCompensation : $doubleValue (index:$index)")
+ val replyJson = cameraApi.callGenericSonyApiMethod("camera", "setExposureCompensation", JSONArray().put(index), "1.0")
+ if (cameraApi.isErrorReply(replyJson))
+ {
+ Log.v(TAG, " REPLY ERROR(exposureCompensation) : $replyJson")
+ }
+ return
+ }
+ }
+ Log.v(TAG, " --- exposureCompensation IS NOT UPDATED ---")
}
catch (e: Exception)
{
{
try
{
- Log.v(TAG, "setTorchMode($value)")
+ Log.v(TAG, "setRemainBattery($value)")
}
catch (e: Exception)
{