• R/O
  • HTTP
  • SSH
  • HTTPS

FujiCam: Commit

Fujifilm X Series Remote Control for Android (Prototype)

Fujifilm Xシリーズカメラの遠隔操作アプリ for Android (プロトタイプ)


Commit MetaInfo

Revisão46173f8999c29dd5579299420bc1765aba4832b8 (tree)
Hora2019-05-26 00:36:17
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

フィルムシミュレーションを変えられるようにした。(これで機能は一通り。)

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/cameratest/camtest/CamTest.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/camtest/CamTest.java
@@ -211,7 +211,7 @@ public class CamTest implements View.OnClickListener, View.OnTouchListener, ILiv
211211 changeFilmSimulation();
212212 break;
213213 case R.id.button4:
214- changeImageAspect();
214+ queryCameraCapability();
215215 break;
216216 default:
217217 showMessageText("Unknown : " + id);
@@ -352,6 +352,29 @@ public class CamTest implements View.OnClickListener, View.OnTouchListener, ILiv
352352 }
353353 }
354354
355+ private void queryCameraCapability()
356+ {
357+ try
358+ {
359+ Thread thread = new Thread(new Runnable() {
360+ @Override
361+ public void run() {
362+ boolean ret = connection.execute_query_camera_capability();
363+ if (!ret)
364+ {
365+ showMessageText("Query Camera Capability...");
366+ }
367+ }
368+ });
369+ thread.start();
370+ Snackbar.make(activity.findViewById(R.id.constraintLayout), R.string.query_capability, Snackbar.LENGTH_SHORT).show();
371+ }
372+ catch (Exception e)
373+ {
374+ e.printStackTrace();
375+ }
376+ }
377+
355378
356379 @Override
357380 public void updateImage(ReceivedDataHolder receivedData)
--- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Communication.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Communication.java
@@ -9,6 +9,8 @@ import java.io.BufferedReader;
99 import java.io.DataOutputStream;
1010 import java.io.InputStream;
1111 import java.net.Socket;
12+import java.util.concurrent.ExecutorService;
13+import java.util.concurrent.Executors;
1214
1315 class Communication
1416 {
@@ -30,11 +32,13 @@ class Communication
3032
3133 private final FujiStreamReceiver stream;
3234 private final FujiAsyncResponseReceiver response;
35+ //private ExecutorService executor;
3336
3437 Communication(@NonNull Activity activity, @NonNull ILiveViewImage imageViewer)
3538 {
3639 this.stream = new FujiStreamReceiver(activity, CAMERA_IP, STREAM_PORT, imageViewer);
3740 this.response = new FujiAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
41+ //this.executor = Executors.newFixedThreadPool(1);
3842 }
3943
4044 void connect_socket()
@@ -83,10 +87,14 @@ class Communication
8387 }
8488 socket = null;
8589 sequenceNumber = SEQUENCE_START_NUMBER;
90+ //if (!executor.isShutdown())
91+ //
92+ // executor.shutdownNow();
93+ //}
8694 System.gc();
8795 }
8896
89- void send_to_camera(byte[] byte_array, boolean useSeqNumber)
97+ void send_to_camera(byte[] byte_array, boolean useSequenceNumber, boolean isIncrementSeqNumber)
9098 {
9199 //Log.v(TAG, "send_to_camera() : " + byte_array.length + " bytes.");
92100 try
@@ -102,17 +110,19 @@ class Communication
102110 sendData[3] = 0x00;
103111 System.arraycopy(byte_array,0,sendData,4, byte_array.length);
104112
105- if (useSeqNumber)
113+ if (useSequenceNumber)
106114 {
107- sendData[8] = (byte) ((0x000000ff & sequenceNumber));
108- sendData[9] = (byte) (((0x0000ff00 & sequenceNumber) >>> 8) & 0x000000ff);
115+ // Sequence Number を反映させる
116+ sendData[8] = (byte) ((0x000000ff & sequenceNumber));
117+ sendData[9] = (byte) (((0x0000ff00 & sequenceNumber) >>> 8) & 0x000000ff);
109118 sendData[10] = (byte) (((0x00ff0000 & sequenceNumber) >>> 16) & 0x000000ff);
110119 sendData[11] = (byte) (((0xff000000 & sequenceNumber) >>> 24) & 0x000000ff);
111- if (isDumpReceiveLog)
112- {
120+ if (isDumpReceiveLog) {
113121 Log.v(TAG, "SEQ No. : " + sequenceNumber);
114122 }
115-
123+ }
124+ if (isIncrementSeqNumber)
125+ {
116126 // シーケンス番号を増やす
117127 sequenceNumber++;
118128 }
--- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Connection.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/Connection.java
@@ -23,6 +23,7 @@ public class Connection implements IFujiStatusRequest
2323 private final MessageSequence sequence;
2424 private final Communication comm;
2525 private final FujiStatusChecker statusChecker;
26+ private boolean pauseRequestStatus = false;
2627
2728 public Connection(@NonNull Activity activity, @NonNull ILiveViewImage imageViewer, @NonNull IFujiStatusNotify notify)
2829 {
@@ -54,7 +55,7 @@ public class Connection implements IFujiStatusRequest
5455 ReceivedDataHolder rx_bytes;
5556 comm.connect_socket();
5657
57- comm.send_to_camera(sequence.registration_message(), false);
58+ comm.send_to_camera(sequence.registration_message(), false, false);
5859 rx_bytes = comm.receive_from_camera();
5960 dump_bytes(0, rx_bytes);
6061 Thread.sleep(50);
@@ -73,19 +74,19 @@ public class Connection implements IFujiStatusRequest
7374 }
7475
7576 // start_messageを送信
76- comm.send_to_camera(sequence.start_message(), true);
77+ comm.send_to_camera(sequence.start_message(), true, true);
7778 rx_bytes = comm.receive_from_camera();
7879 dump_bytes(1, rx_bytes);
7980 Thread.sleep(50);
8081
8182 // なんだろう?? (送信が必要なようだが)
82- comm.send_to_camera(sequence.start_message2(), true);
83+ comm.send_to_camera(sequence.start_message2(), true, true);
8384 rx_bytes = comm.receive_from_camera();
8485 dump_bytes(2, rx_bytes);
8586 Thread.sleep(50);
8687
8788 // two_part messageを発行 (その1)
88- comm.send_to_camera(sequence.start_message3_1(), true);
89+ comm.send_to_camera(sequence.start_message3_1(), true, true);
8990 rx_bytes = comm.receive_from_camera();
9091 dump_bytes(3, rx_bytes);
9192 Thread.sleep(50);
@@ -93,14 +94,14 @@ public class Connection implements IFujiStatusRequest
9394 if (rx_bytes.getData().length <= 50)
9495 {
9596 // two_part messageを発行 (その2)
96- comm.send_to_camera(sequence.start_message3_2(), false);
97+ comm.send_to_camera(sequence.start_message3_2(), false, false);
9798 rx_bytes = comm.receive_from_camera();
9899 dump_bytes(4, rx_bytes);
99100 Thread.sleep(50);
100101 }
101102
102103 // remote mode
103- comm.send_to_camera(sequence.start_message4(), true);
104+ comm.send_to_camera(sequence.start_message4(), true, true);
104105 rx_bytes = comm.receive_from_camera();
105106 dump_bytes(5, rx_bytes);
106107 Thread.sleep(50);
@@ -108,38 +109,38 @@ public class Connection implements IFujiStatusRequest
108109 if (!isBothLiveView)
109110 {
110111 // two_part messageを発行 (その1)
111- comm.send_to_camera(sequence.start_message5_1(), true);
112+ comm.send_to_camera(sequence.start_message5_1(), true, false);
112113 rx_bytes = comm.receive_from_camera();
113114 dump_bytes(6, rx_bytes);
114115 Thread.sleep(50);
115116
116117 // two_part messageを発行 (その2)
117- comm.send_to_camera(sequence.start_message5_2(), false);
118+ comm.send_to_camera(sequence.start_message5_2(), true, true);
118119 rx_bytes = comm.receive_from_camera();
119120 dump_bytes(7, rx_bytes);
120121 Thread.sleep(50);
121122
122123 // ????
123- comm.send_to_camera(sequence.start_message6(), true);
124+ comm.send_to_camera(sequence.start_message6(), true, true);
124125 rx_bytes = comm.receive_from_camera();
125126 dump_bytes(8, rx_bytes);
126127 Thread.sleep(50);
127128
128129 // ????
129- comm.send_to_camera(sequence.start_message7(), true);
130+ comm.send_to_camera(sequence.query_camera_capabilities(), true, true);
130131 rx_bytes = comm.receive_from_camera();
131132 dump_bytes(9, rx_bytes);
132133 Thread.sleep(50);
133134
134135 // ????
135- comm.send_to_camera(sequence.start_message8(), true);
136+ comm.send_to_camera(sequence.start_message8(), true, true);
136137 rx_bytes = comm.receive_from_camera();
137138 dump_bytes(10, rx_bytes);
138139 Thread.sleep(50);
139140 }
140141
141142 // リモート制御の開始!
142- comm.send_to_camera(sequence.camera_remote_message(), true);
143+ comm.send_to_camera(sequence.camera_remote_message(), true, true);
143144
144145 // 応答OKの場合は、8バイト ({0x03, 0x00, 0x01, 0x20} + {0x10, 0x02, 0x00, 0x00} )が応答されるはず
145146 rx_bytes = comm.receive_from_camera();
@@ -166,7 +167,7 @@ public class Connection implements IFujiStatusRequest
166167 {
167168 try
168169 {
169- comm.send_to_camera(sequence.reset_message(), true);
170+ comm.send_to_camera(sequence.reset_message(), true, true);
170171 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
171172 dump_bytes(0, rx_bytes);
172173 statusChecker.stop();
@@ -217,9 +218,14 @@ public class Connection implements IFujiStatusRequest
217218 @Override
218219 public boolean requestStatus()
219220 {
221+ if (pauseRequestStatus)
222+ {
223+ // ステータス更新を一時停止する。
224+ return (false);
225+ }
220226 try
221227 {
222- comm.send_to_camera(sequence.status_request_message(), true);
228+ comm.send_to_camera(sequence.status_request_message(), true, true);
223229 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
224230 if (rx_bytes.getData().length > 0)
225231 {
@@ -268,7 +274,7 @@ public class Connection implements IFujiStatusRequest
268274 byte y = (byte) (0x000000ff & Math.round(point.y));
269275 Log.v(TAG, "DRIVE AF (" + x + "," + y + ")");
270276
271- comm.send_to_camera(sequence.execute_focus_lock(x, y), true);
277+ comm.send_to_camera(sequence.execute_focus_lock(x, y), true, true);
272278
273279 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
274280 dump_bytes(16, rx_bytes);
@@ -291,7 +297,7 @@ public class Connection implements IFujiStatusRequest
291297 {
292298 currentValue = FILM_SIMULATION_MIN;
293299 }
294- return (updateProperty(FILM_SIMULATION, currentValue));
300+ return (updateProperty(FILM_SIMULATION, currentValue, true));
295301 }
296302 catch (Exception e)
297303 {
@@ -311,12 +317,30 @@ public class Connection implements IFujiStatusRequest
311317 {
312318 currentValue = IMAGE_ASPECT_MIN;
313319 }
314- return (updateProperty(IMAGE_ASPECT, currentValue));
320+ return (updateProperty(IMAGE_ASPECT, currentValue, true));
321+ }
322+ catch (Exception e)
323+ {
324+ e.printStackTrace();
325+ }
326+ return (false);
327+ }
328+
329+ public boolean execute_query_camera_capability()
330+ {
331+ pauseRequestStatus = true;
332+ try
333+ {
334+ comm.send_to_camera(sequence.query_camera_capabilities(), true, true);
335+ Thread.sleep(50);
336+ ReceivedDataHolder rx_bytes = comm.receive_from_camera();
337+ dump_bytes(21, rx_bytes);
315338 }
316339 catch (Exception e)
317340 {
318341 e.printStackTrace();
319342 }
343+ pauseRequestStatus = false;
320344 return (false);
321345 }
322346
@@ -325,7 +349,7 @@ public class Connection implements IFujiStatusRequest
325349 {
326350 try
327351 {
328- comm.send_to_camera(sequence.execute_focus_unlock(), true);
352+ comm.send_to_camera(sequence.execute_focus_unlock(), true, true);
329353
330354 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
331355 dump_bytes(17, rx_bytes);
@@ -341,7 +365,7 @@ public class Connection implements IFujiStatusRequest
341365 {
342366 try
343367 {
344- comm.send_to_camera(sequence.execute_shutter_message(), true);
368+ comm.send_to_camera(sequence.execute_shutter_message(), true, true);
345369
346370 ReceivedDataHolder rx_bytes = comm.receive_from_camera();
347371 dump_bytes(14, rx_bytes);
@@ -353,8 +377,9 @@ public class Connection implements IFujiStatusRequest
353377 return (false);
354378 }
355379
356- public boolean updateProperty(int commandCode, int setValue)
380+ private boolean updateProperty(int commandCode, int setValue, boolean isShort)
357381 {
382+ pauseRequestStatus = true;
358383 ReceivedDataHolder rx_bytes;
359384 try {
360385 byte high = (byte) ((0x0000ff00 & commandCode) >> 8);
@@ -366,20 +391,28 @@ public class Connection implements IFujiStatusRequest
366391 byte data3 = (byte)((0x000000ff & setValue));
367392
368393 // two_part messageを発行 (その1)
369- comm.send_to_camera(sequence.update_property_1(high, low), true);
394+ comm.send_to_camera(sequence.update_property_1(high, low), true, false);
395+ Thread.sleep(50);
370396 rx_bytes = comm.receive_from_camera();
371- dump_bytes(15, rx_bytes);
397+ dump_bytes(19, rx_bytes);
398+/*
399+ // two_part messageを発行 (その1) : ダミーでもう一発...!
400+ comm.send_to_camera(sequence.update_property_1(high, low), true, false);
372401 Thread.sleep(50);
373-
402+ rx_bytes = comm.receive_from_camera();
403+ dump_bytes(15, rx_bytes);
404+*/
374405 // two_part messageを発行 (その2)
375- comm.send_to_camera(sequence.update_property_2(data0, data1, data2, data3), false);
406+ comm.send_to_camera((isShort) ? sequence.update_property_2(data2, data3) : sequence.update_property_2(data0, data1, data2, data3), true, true);
407+ Thread.sleep(50);
376408 rx_bytes = comm.receive_from_camera();
377- dump_bytes(16, rx_bytes);
409+ dump_bytes(20, rx_bytes);
378410 }
379411 catch (Exception e)
380412 {
381413 e.printStackTrace();
382414 }
415+ pauseRequestStatus = false;
383416 return (false);
384417 }
385418 }
--- a/app/src/main/java/net/osdn/gokigen/cameratest/fuji/MessageSequence.java
+++ b/app/src/main/java/net/osdn/gokigen/cameratest/fuji/MessageSequence.java
@@ -200,7 +200,7 @@ class MessageSequence
200200 }
201201
202202
203- byte[] start_message7()
203+ byte[] query_camera_capabilities()
204204 {
205205 return (new byte[] {
206206 // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
@@ -400,7 +400,24 @@ class MessageSequence
400400 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
401401
402402 // command code
403- low, high,
403+ low, high, (byte)0x00, (byte)0x00,
404+ });
405+ }
406+
407+ byte[] update_property_2(byte data0, byte data1)
408+ {
409+ return (new byte[] {
410+ // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
411+ (byte)0x02, (byte)0x00,
412+
413+ // message_header.type : two_part (0x1016)
414+ (byte)0x16, (byte)0x10,
415+
416+ // message_id (0~1づつ繰り上がる...けど two-part messageなので同じ)
417+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
418+
419+ // data...
420+ data1, data0,
404421 });
405422 }
406423
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -60,4 +60,5 @@
6060
6161 <string name="dialog_message_power_off">Power Off</string>
6262
63+ <string name="query_capability">Query Camera Capability</string>
6364 </resources>
Show on old repository browser