1 package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper;
3 import android.util.Log;
4 import android.util.SparseIntArray;
6 import androidx.annotation.NonNull;
7 import androidx.annotation.Nullable;
8 import androidx.collection.SparseArrayCompat;
9 import androidx.fragment.app.FragmentActivity;
11 import net.osdn.gokigen.gr2control.R;
12 import net.osdn.gokigen.gr2control.camera.ICameraStatus;
13 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.FujiXReplyMessageReceiver;
14 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandPublisher;
15 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.SetPropertyValue;
16 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXBatteryMode;
17 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXCameraProperties;
18 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFSSControl;
19 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFilmSimulation;
20 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFlashMode;
21 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXFocusingMode;
22 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXImageAspectMode;
23 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXImageFormatMode;
24 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXShootingMode;
25 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXTimerMode;
26 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.values.IFujiXWhiteBalanceMode;
27 import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Locale;
33 class FujiXStatusHolder
35 private final String TAG = toString();
36 private final FragmentActivity activity;
37 private final IFujiXCommandPublisher publisher;
38 private static final boolean logcat = true;
39 private SparseIntArray statusHolder;
40 private SparseArrayCompat<String> statusNameArray;
42 FujiXStatusHolder(@NonNull FragmentActivity activity, @NonNull IFujiXCommandPublisher publisher)
44 statusHolder = new SparseIntArray();
47 this.activity = activity;
48 this.publisher = publisher;
49 statusNameArray = new SparseArrayCompat<>();
50 prepareStatusNameArray();
53 private void prepareStatusNameArray()
55 statusNameArray.clear();
56 statusNameArray.append(IFujiXCameraProperties.BATTERY_LEVEL, IFujiXCameraProperties.BATTERY_LEVEL_STR);
57 statusNameArray.append(IFujiXCameraProperties.WHITE_BALANCE, IFujiXCameraProperties.WHITE_BALANCE_STR);
58 statusNameArray.append(IFujiXCameraProperties.APERTURE, IFujiXCameraProperties.APERTURE_STR);
59 statusNameArray.append(IFujiXCameraProperties.FOCUS_MODE, IFujiXCameraProperties.FOCUS_MODE_STR);
60 statusNameArray.append(IFujiXCameraProperties.SHOOTING_MODE, IFujiXCameraProperties.SHOOTING_MODE_STR);
61 statusNameArray.append(IFujiXCameraProperties.FLASH, IFujiXCameraProperties.FLASH_STR);
62 statusNameArray.append(IFujiXCameraProperties.EXPOSURE_COMPENSATION, IFujiXCameraProperties.EXPOSURE_COMPENSATION_STR);
63 statusNameArray.append(IFujiXCameraProperties.SELF_TIMER, IFujiXCameraProperties.SELF_TIMER_STR);
64 statusNameArray.append(IFujiXCameraProperties.FILM_SIMULATION, IFujiXCameraProperties.FILM_SIMULATION_STR);
65 statusNameArray.append(IFujiXCameraProperties.IMAGE_FORMAT, IFujiXCameraProperties.IMAGE_FORMAT_STR);
66 statusNameArray.append(IFujiXCameraProperties.RECMODE_ENABLE, IFujiXCameraProperties.RECMODE_ENABLE_STR);
67 statusNameArray.append(IFujiXCameraProperties.F_SS_CONTROL, IFujiXCameraProperties.F_SS_CONTROL_STR);
68 statusNameArray.append(IFujiXCameraProperties.ISO, IFujiXCameraProperties.ISO_STR);
69 statusNameArray.append(IFujiXCameraProperties.MOVIE_ISO, IFujiXCameraProperties.MOVIE_ISO_STR);
70 statusNameArray.append(IFujiXCameraProperties.FOCUS_POINT, IFujiXCameraProperties.FOCUS_POINT_STR);
71 statusNameArray.append(IFujiXCameraProperties.DEVICE_ERROR, IFujiXCameraProperties.DEVICE_ERROR_STR);
72 statusNameArray.append(IFujiXCameraProperties.IMAGE_FILE_COUNT, IFujiXCameraProperties.IMAGE_FILE_COUNT_STR);
73 statusNameArray.append(IFujiXCameraProperties.SDCARD_REMAIN_SIZE, IFujiXCameraProperties.SDCARD_REMAIN_SIZE_STR);
74 statusNameArray.append(IFujiXCameraProperties.FOCUS_LOCK, IFujiXCameraProperties.FOCUS_LOCK_STR);
75 statusNameArray.append(IFujiXCameraProperties.MOVIE_REMAINING_TIME, IFujiXCameraProperties.MOVIE_REMAINING_TIME_STR);
76 statusNameArray.append(IFujiXCameraProperties.SHUTTER_SPEED, IFujiXCameraProperties.SHUTTER_SPEED_STR);
77 statusNameArray.append(IFujiXCameraProperties.IMAGE_ASPECT, IFujiXCameraProperties.IMAGE_ASPECT_STR);
78 statusNameArray.append(IFujiXCameraProperties.BATTERY_LEVEL_2, IFujiXCameraProperties.BATTERY_LEVEL_2_STR);
79 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF00, IFujiXCameraProperties.UNKNOWN_DF00_STR);
80 statusNameArray.append(IFujiXCameraProperties.PICTURE_JPEG_COUNT, IFujiXCameraProperties.PICTURE_JPEG_COUNT_STR);
81 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D400, IFujiXCameraProperties.UNKNOWN_D400_STR);
82 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D401, IFujiXCameraProperties.UNKNOWN_D401_STR);
83 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D52F, IFujiXCameraProperties.UNKNOWN_D52F_STR);
84 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_D245, IFujiXCameraProperties.UNKNOWN_D245_STR);
85 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF41, IFujiXCameraProperties.UNKNOWN_DF41_STR);
86 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF26, IFujiXCameraProperties.UNKNOWN_DF26_STR);
87 statusNameArray.append(IFujiXCameraProperties.UNKNOWN_DF27, IFujiXCameraProperties.UNKNOWN_DF27_STR);
90 void updateValue(@Nullable ICameraStatusUpdateNotify notifier, int id, byte data0, byte data1, byte data2, byte data3)
94 int value = ((((int) data3) & 0xff) << 24) + ((((int) data2) & 0xff) << 16) + ((((int) data1) & 0xff) << 8) + (((int) data0) & 0xff);
95 int currentValue = statusHolder.get(id, -1);
96 //logcat(String.format(Locale.US, " STATUS [id: 0x%04x] 0x%08x(%d) -> 0x%08x(%d)", id, currentValue, currentValue, value, value));
97 if ((notifier != null) && (currentValue != value))
99 statusHolder.put(id, value);
100 //logcat(String.format(Locale.US," STATUS UPDATE [id: 0x%04x] 0x%08x(%d) -> 0x%08x(%d)", id, currentValue, currentValue, value, value));
101 updateDetected(notifier, id, currentValue, value);
110 private void updateDetected(@NonNull ICameraStatusUpdateNotify notifier, int id, int previous, int current)
114 //String idName = statusNameArray.get(id, "Unknown");
115 //logcat(String.format(Locale.US, " << UPDATE STATUS >> id: 0x%04x[%s] 0x%08x(%d) -> 0x%08x(%d)", id, idName, previous, previous, current, current));
118 case IFujiXCameraProperties.FOCUS_LOCK:
119 updateFocusedStatus(notifier, previous, current);
121 case IFujiXCameraProperties.SHOOTING_MODE:
122 updatedTakeMode(notifier, previous, current);
124 case IFujiXCameraProperties.BATTERY_LEVEL:
125 case IFujiXCameraProperties.BATTERY_LEVEL_2:
126 updateBatteryLevel(notifier, previous, current);
128 case IFujiXCameraProperties.FOCUS_MODE:
129 updateFocusMode(notifier, previous, current);
131 case IFujiXCameraProperties.APERTURE:
132 updateAperture(notifier, previous, current);
134 case IFujiXCameraProperties.SHUTTER_SPEED:
135 updateShutterSpeed(notifier, previous, current);
137 case IFujiXCameraProperties.WHITE_BALANCE:
138 updateWhiteBalance(notifier, previous, current);
140 case IFujiXCameraProperties.EXPOSURE_COMPENSATION:
141 updateExposureCompensation(notifier, previous, current);
143 case IFujiXCameraProperties.ISO:
144 updateIsoSensitivity(notifier, previous, current);
146 case IFujiXCameraProperties.DEVICE_ERROR:
147 updateDeviceError(notifier, previous, current);
149 case IFujiXCameraProperties.SELF_TIMER:
150 updateSelfTimer(notifier, previous, current);
152 case IFujiXCameraProperties.SDCARD_REMAIN_SIZE:
153 updateSdCardRemainSize(notifier, previous, current);
155 case IFujiXCameraProperties.MOVIE_REMAINING_TIME:
156 updateMovieRemainTime(notifier, previous, current);
158 case IFujiXCameraProperties.FOCUS_POINT:
159 updateFocusPoint(notifier, previous, current);
161 case IFujiXCameraProperties.F_SS_CONTROL:
162 updateFSSControl(notifier, previous, current);
164 case IFujiXCameraProperties.IMAGE_ASPECT:
165 updateImageAspect(notifier, previous, current);
167 case IFujiXCameraProperties.FILM_SIMULATION:
168 updateFilmSimulation(notifier, previous, current);
170 case IFujiXCameraProperties.FLASH:
171 updateFlashMode(notifier, previous, current);
173 case IFujiXCameraProperties.IMAGE_FORMAT:
174 updateImageFormat(notifier, previous, current);
176 case IFujiXCameraProperties.UNKNOWN_D245:
177 case IFujiXCameraProperties.UNKNOWN_DF41:
178 case IFujiXCameraProperties.UNKNOWN_DF26:
179 case IFujiXCameraProperties.UNKNOWN_DF27:
181 updateUnknownValue(id, previous, current);
191 private void updateImageFormat(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
196 case IFujiXImageFormatMode.IMAGE_FORMAT_RAW:
199 case IFujiXImageFormatMode.IMAGE_FORMAT_FINE:
202 case IFujiXImageFormatMode.IMAGE_FORMAT_NORMAL:
205 case IFujiXImageFormatMode.IMAGE_FORMAT_FINE_RAW:
208 case IFujiXImageFormatMode.IMAGE_FORMAT_NORMAL_RAW:
212 value = "UNKNOWN : " + current;
215 logcat(" Image Format : " + value);
218 private void updateFlashMode(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
223 case IFujiXFlashMode.FLASH_AUTO:
226 case IFujiXFlashMode.FLASH_OFF:
229 case IFujiXFlashMode.FLASH_FILL:
232 case IFujiXFlashMode.FLASH_REDEYE_AUTO:
233 value = "REDEYE_AUTO";
235 case IFujiXFlashMode.FLASH_REDEYE_FILL:
236 value = "REDEYE_FILL";
238 case IFujiXFlashMode.FLASH_EXTERNAL_SYNC:
239 value = "EXTERNAL_SYNC";
241 case IFujiXFlashMode.FLASH_ON:
244 case IFujiXFlashMode.FLASH_REDEYE:
247 case IFujiXFlashMode.FLASH_REDEYE_ON:
250 case IFujiXFlashMode.FLASH_REDEYE_SYNC:
251 value = "REDEYE_SYNC";
253 case IFujiXFlashMode.FLASH_REDEYE_REAR:
254 value = "REDEYE_REAR";
256 case IFujiXFlashMode.FLASH_SLOW_SYNC:
259 case IFujiXFlashMode.FLASH_REAR_SYNC:
262 case IFujiXFlashMode.FLASH_COMMANDER:
265 case IFujiXFlashMode.FLASH_DISABLE:
268 case IFujiXFlashMode.FLASH_ENABLE:
272 value = " UNKNOWN : " + current;
275 logcat(" FLASH MODE : " + value);
278 private void updateFilmSimulation(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
283 case IFujiXFilmSimulation.FILM_SIMULATION_PROVIA:
284 value = IFujiXFilmSimulation.FILM_SIMULATION_PROVIA_STR;
286 case IFujiXFilmSimulation.FILM_SIMULATION_VELVIA:
287 value = IFujiXFilmSimulation.FILM_SIMULATION_VELVIA_STR;
289 case IFujiXFilmSimulation.FILM_SIMULATION_ASTIA:
290 value = IFujiXFilmSimulation.FILM_SIMULATION_ASTIA_STR;
292 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME:
293 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_STR;
295 case IFujiXFilmSimulation.FILM_SIMULATION_SEPIA:
296 value = IFujiXFilmSimulation.FILM_SIMULATION_SEPIA_STR;
298 case IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI:
299 value = IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI_STR;
301 case IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD:
302 value = IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD_STR;
304 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER:
305 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER_STR;
307 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER:
308 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER_STR;
310 case IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER:
311 value = IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER_STR;
313 case IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME:
314 value = IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME_STR;
316 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS:
317 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_STR;
319 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y:
320 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y_STR;
322 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R:
323 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R_STR;
325 case IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G:
326 value = IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G_STR;
328 case IFujiXFilmSimulation.FILM_SIMULATION_ETERNA:
329 value = IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_STR;
331 case IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE:
332 value = IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE_STR;
334 case IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS:
335 value = IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS_STR;
338 value = "??? " + current;
341 logcat(" FILM SIMULATION : " + value);
344 private void updateImageAspect(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
349 case IFujiXImageAspectMode.IMAGE_ASPECT_S_3x2:
352 case IFujiXImageAspectMode.IMAGE_ASPECT_S_16x9:
355 case IFujiXImageAspectMode.IMAGE_ASPECT_S_1x1:
358 case IFujiXImageAspectMode.IMAGE_ASPECT_M_3x2:
361 case IFujiXImageAspectMode.IMAGE_ASPECT_M_16x9:
364 case IFujiXImageAspectMode.IMAGE_ASPECT_M_1x1:
367 case IFujiXImageAspectMode.IMAGE_ASPECT_L_3x2:
370 case IFujiXImageAspectMode.IMAGE_ASPECT_L_16x9:
373 case IFujiXImageAspectMode.IMAGE_ASPECT_L_1x1:
377 value = "? " + current;
380 logcat(" Image Aspect : " + value);
384 private void updateFSSControl(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
389 case IFujiXFSSControl.F_SS_CTRL_BOTH:
392 case IFujiXFSSControl.F_SS_CTRL_F:
395 case IFujiXFSSControl.F_SS_CTRL_SS:
398 case IFujiXFSSControl.F_SS_CTRL_NONE:
402 value = "? " + current;
405 logcat(" F_SS : " + value);
408 private void updateUnknownValue(int id, int previous, int current)
410 logcat(String.format(Locale.US,"<< UPDATE UNKNOWN STATUS >> id: 0x%04x 0x%08x(%d) -> 0x%08x(%d)", id, previous, previous, current, current));
413 private void updateFocusPoint(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
415 logcat(String.format(Locale.ENGLISH, " Focus Point : %x ", current));
418 private void updateMovieRemainTime(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
420 logcat(" MOVIE REMAIN : " + current);
423 private void updateSdCardRemainSize(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
425 logcat(" SDCARD REMAIN : " + current);
428 private void updateSelfTimer(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
435 case IFujiXTimerMode.TIMER_OFF:
439 case IFujiXTimerMode.TIMER_1SEC:
443 case IFujiXTimerMode.TIMER_2SEC:
447 case IFujiXTimerMode.TIMER_5SEC:
451 case IFujiXTimerMode.TIMER_10SEC:
465 logcat(" SELF TIMER IS OFF (" + value + ")");
469 logcat(" SELF TIMER IS " + value + " sec.");
473 private void updateDeviceError(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
477 notifier.updateWarning("ERROR " + current);
481 private void updateIsoSensitivity(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
486 int isoValue = (0x0000ffff & current);
487 if ((0xffff0000 & current) != 0)
489 iso = "AUTO_" + isoValue;
491 else if (isoValue > 12800)
493 iso = "H" + isoValue;
496 else if (isoValue < 200)
498 iso = "L" + isoValue;
509 logcat(" ISO SENSITIVITY : " + iso);
510 notifier.updateIsoSensitivity(iso);
513 private void updateExposureCompensation(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
515 String exposureCompensation = "";
518 float value = ((float) current / 1000.0f);
519 exposureCompensation = String.format(Locale.ENGLISH, "%+1.1f", value);
525 notifier.updatedExposureCompensation(exposureCompensation);
528 private void updateWhiteBalance(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
535 case IFujiXWhiteBalanceMode.WHITE_BALANCE_AUTO:
538 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FINE:
541 case IFujiXWhiteBalanceMode.WHITE_BALANCE_INCANDESCENT:
542 value = "Incandescent";
544 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FLUORESCENT_1:
545 value = "Fluorescent 1";
547 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FLUORESCENT_2:
548 value = "Fluorescent 2";
550 case IFujiXWhiteBalanceMode.WHITE_BALANCE_FLUORESCENT_3:
551 value = "Fluorescent 3";
553 case IFujiXWhiteBalanceMode.WHITE_BALANCE_SHADE:
556 case IFujiXWhiteBalanceMode.WHITE_BALANCE_UNDERWATER:
557 value = "Underwater";
559 case IFujiXWhiteBalanceMode.WHITE_BALANCE_TEMPERATURE:
562 case IFujiXWhiteBalanceMode.WHITE_BALANCE_CUSTOM:
574 notifier.updatedWBMode(value);
577 private void updateShutterSpeed(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
579 String shutterSpeed = "--";
582 if ((0x80000000 & current) != 0)
584 int value = 0x0fffffff & current;
585 shutterSpeed = ("1/" + (value / 1000));
589 shutterSpeed = (current + "");
596 notifier.updatedShutterSpeed(shutterSpeed);
599 private void updateAperture(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
601 String aperature = "---";
604 float value = ((float) current / 100.0f);
605 aperature = String.format(Locale.ENGLISH, "%1.1f", value);
611 notifier.updatedAperture(aperature);
614 private void updateFocusMode(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
619 if (current == IFujiXFocusingMode.FOCUS_MANUAL)
623 else if (current == IFujiXFocusingMode.FOCUS_CONTINUOUS_AUTO)
627 else if (current == IFujiXFocusingMode.FOCUS_SINGLE_AUTO)
633 mode = mode + current;
635 logcat(" Focus Mode : " + mode);
638 private void updateFocusedStatus(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
643 notifier.updateFocusedStatus(true, true);
648 notifier.updateFocusedStatus(false, false);
652 private void updatedTakeMode(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
657 case IFujiXShootingMode.SHOOTING_MANUAL:
660 case IFujiXShootingMode.SHOOTING_PROGRAM:
663 case IFujiXShootingMode.SHOOTING_APERTURE:
666 case IFujiXShootingMode.SHOOTING_SHUTTER:
669 case IFujiXShootingMode.SHOOTING_CUSTOM:
672 case IFujiXShootingMode.SHOOTING_AUTO:
676 mode = mode + current;
679 notifier.updatedTakeMode(mode);
682 private void updateBatteryLevel(@NonNull ICameraStatusUpdateNotify notifier, int previous, int current)
685 if ((current == IFujiXBatteryMode.BATTERY_CRITICAL) || (current == IFujiXBatteryMode.BATTERY_126S_CRITICAL))
689 else if (current == IFujiXBatteryMode.BATTERY_126S_ONE_BAR)
693 else if ((current == IFujiXBatteryMode.BATTERY_ONE_BAR) || (current == IFujiXBatteryMode.BATTERY_126S_TWO_BAR))
697 else if (current == IFujiXBatteryMode.BATTERY_126S_THREE_BAR)
701 else if ((current == IFujiXBatteryMode.BATTERY_TWO_BAR) || (current == IFujiXBatteryMode.BATTERY_126S_FOUR_BAR))
705 else // if ((current == IFujiXBatteryMode.BATTERY_FULL) || (current == IFujiXBatteryMode.BATTERY_126S_FULL))
709 notifier.updateRemainBattery(level);
714 * 認識したカメラのステータス名称のリストを応答する
717 private List<String> getAvailableStatusNameList()
719 ArrayList<String> selection = new ArrayList<>();
722 for (int index = 0; index < statusHolder.size(); index++)
724 int key = statusHolder.keyAt(index);
725 selection.add(statusNameArray.get(key, String.format(Locale.US, "0x%04x", key)));
736 List<String> getAvailableItemList(String listKey)
738 if ((listKey == null)||(listKey.isEmpty()))
741 return (getAvailableStatusNameList());
743 if (listKey.matches(ICameraStatus.EFFECT))
745 return (getAvailableEffectItemList());
747 if (listKey.matches(ICameraStatus.AE))
749 return (new ArrayList<>());
751 if (listKey.matches(ICameraStatus.WHITE_BALANCE))
753 return (getAvailableResourceArrayItemList(R.array.fuji_x_white_balance));
755 if (listKey.matches(ICameraStatus.ISO_SENSITIVITY))
757 return (getAvailableResourceArrayItemList(R.array.fuji_x_iso_sensitivity));
761 ///// 選択可能なステータスの一覧を取得する : でも以下はアイテム名の一覧... /////
763 ArrayList<String> selection = new ArrayList<>();
766 for (int index = 0; index < statusHolder.size(); index++)
768 int key = statusHolder.keyAt(index);
769 selection.add(statusNameArray.get(key));
777 return (new ArrayList<>());
780 private List<String> getAvailableEffectItemList()
782 // EFFECTの選択肢をリストにして返す : Film Simulation にした。
783 ArrayList<String> selection = new ArrayList<>();
784 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_PROVIA_STR);
785 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_VELVIA_STR);
786 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ASTIA_STR);
787 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_STR);
788 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_SEPIA_STR);
789 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_HI_STR);
790 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_PRO_NEG_STD_STR);
791 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_Y_FILTER_STR);
792 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_R_FILTER_STR);
793 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_MONOCHROME_G_FILTER_STR);
794 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_CHROME_STR);
795 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_STR);
796 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_Y_STR);
797 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_R_STR);
798 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ACROS_G_STR);
799 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_STR);
800 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_CLASSIC_NEGATIVE_STR);
801 selection.add(IFujiXFilmSimulation.FILM_SIMULATION_ETERNA_BLEACH_BYPASS_STR);
805 private List<String> getAvailableResourceArrayItemList(int id)
807 // リソースのの選択肢をリストにして返す
808 ArrayList<String> selection = new ArrayList<>();
810 String[] items = activity.getResources().getStringArray(id);
811 for (String item : items)
818 private String getCurrentEffectStatus()
820 // EFFECTの現在状態を応答する : FILM Simulationにした
823 int value = statusHolder.get(IFujiXCameraProperties.FILM_SIMULATION);
824 List<String> itemList = getAvailableEffectItemList();
825 if ((value >= IFujiXFilmSimulation.FILM_SIMULATION_MIN)&&(value < itemList.size()))
827 return (itemList.get(value - 1));
837 private String getCurrentWhiteBalanceStatus()
839 // White Balanceの現在状態を取得する
842 int value = statusHolder.get(IFujiXCameraProperties.WHITE_BALANCE);
843 String[] items = activity.getResources().getStringArray(R.array.fuji_x_white_balance);
844 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_white_balance_value);
846 for (String itemValue : itemValues)
848 int itemValueInt = Integer.parseInt(itemValue);
849 if (itemValueInt == value)
851 return (items[index]);
863 private String getCurrentIsoSensitivityStatus()
868 int current = statusHolder.get(IFujiXCameraProperties.ISO);
869 int isoValue = (0x0000ffff & current);
870 if ((0xffff0000 & current) != 0)
872 iso = "AUTO_" + isoValue;
874 else if (isoValue > 12800)
876 iso = "H" + isoValue;
879 else if (isoValue < 200)
881 iso = "L" + isoValue;
892 logcat(" ISO SENSITIVITY : " + iso);
896 private void setEffectItem(String value)
901 List<String> itemList = getAvailableEffectItemList();
902 for (String item : itemList)
904 if (item.matches(value))
907 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set Film Simulation", true), IFujiXCameraProperties.FILM_SIMULATION, 4, index));
919 private void setCurrentWhiteBalanceStatus(String value)
921 // White Balanceを設定する
924 String[] items = activity.getResources().getStringArray(R.array.fuji_x_white_balance);
925 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_white_balance_value);
927 for (String item : items)
929 if (item.matches(value))
932 String itemValue = itemValues[index];
933 int itemValueInt = Integer.parseInt(itemValue);
934 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set White Balance", true), IFujiXCameraProperties.WHITE_BALANCE, 4, itemValueInt));
946 private void setCurrentIsoSensitivityStatus(String value)
951 String[] items = activity.getResources().getStringArray(R.array.fuji_x_iso_sensitivity);
952 String[] itemValues = activity.getResources().getStringArray(R.array.fuji_x_iso_sensitivity_value);
954 for (String item : items)
956 Log.v(TAG, " ===== ISO : " + value + " " + item + " ===== ");
957 if (item.matches(value))
960 String itemValue = itemValues[index];
961 int itemValueInt = (int) Long.parseLong(itemValue,16);
962 logcat(" SET ISO SENSITIVITY : " + value + " " + itemValueInt);
963 publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyMessageReceiver(" Set ISO", true), IFujiXCameraProperties.ISO, 8, itemValueInt));
975 String getItemStatus(String key)
977 if (key.matches(ICameraStatus.EFFECT))
979 return (getCurrentEffectStatus());
981 if (key.matches(ICameraStatus.WHITE_BALANCE))
983 return (getCurrentWhiteBalanceStatus());
985 if (key.matches(ICameraStatus.ISO_SENSITIVITY))
987 return (getCurrentIsoSensitivityStatus());
989 if (key.matches(ICameraStatus.TAKE_MODE))
995 int strIndex = key.indexOf("x");
996 Log.v(TAG, "getItemStatus() : " + key + " [" + strIndex + "]");
999 key = key.substring(strIndex + 1);
1002 int id = Integer.parseInt(key, 16);
1003 int value = statusHolder.get(id);
1004 logcat("getItemStatus() value : " + value + " key : " + key + " [" + id + "]");
1006 return (value + "");
1010 e.printStackTrace();
1014 for (int index = 0; index < statusNameArray.size(); index++)
1016 int id = statusNameArray.keyAt(index);
1017 String strKey = statusNameArray.valueAt(index);
1018 if (key.contentEquals(strKey))
1020 int value = statusHolder.get(id);
1021 return (value + "");
1027 e.printStackTrace();
1029 return ("? [" + key + "]");
1032 void setItemStatus(@NonNull String key, @NonNull String value)
1038 Log.v(TAG, "setStatus(" + key + ", " + value + ")");
1040 if (key.matches(ICameraStatus.EFFECT))
1042 setEffectItem(value);
1045 if (key.matches(ICameraStatus.WHITE_BALANCE))
1047 setCurrentWhiteBalanceStatus(value);
1050 if (key.matches(ICameraStatus.ISO_SENSITIVITY))
1052 setCurrentIsoSensitivityStatus(value);
1060 e.printStackTrace();
1065 private void dumpStatus()
1069 Log.v(TAG, " - - - status - - - ");
1070 for (int index = 0; index < statusHolder.size(); index++)
1072 int key = statusHolder.keyAt(index);
1073 int value = statusHolder.get(key);
1074 Log.v(TAG, String.format("id : 0x%x value : %d (0x%x) ", key, value, value));
1076 Log.v(TAG, " - - - status - - - ");
1080 e.printStackTrace();
1084 private void logcat(String message)
1088 Log.v(TAG, message);