OSDN Git Service

とりあえずこれで。
authorMRSa <mrsa@myad.jp>
Sun, 8 Mar 2020 12:35:38 +0000 (21:35 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 8 Mar 2020 12:35:38 +0000 (21:35 +0900)
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonCaptureControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/connection/NikonCameraConnectSequence.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/connection/NikonConnection.java
app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml

index ab66390..7baf2ab 100644 (file)
@@ -19,7 +19,6 @@ public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallba
     private final String TAG = this.toString();
     private final PtpIpCommandPublisher commandPublisher;
     //private final IAutoFocusFrameDisplay frameDisplayer;
-    private boolean isDumpLog = false;
 
     public NikonCaptureControl(@NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer)
     {
@@ -30,6 +29,7 @@ public class NikonCaptureControl implements ICaptureControl, IPtpIpCommandCallba
     @Override
     public void doCapture(int kind)
     {
+        boolean isDumpLog = false;
         try
         {
             // シャッター
index e1b323a..3321caa 100644 (file)
@@ -35,7 +35,7 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
     private float maxPointLimitHeight;
     private RectF preFocusFrameRect = null;
     private boolean not_support_focus_lock = false;
-    private boolean isDumpLog = true;
+    private boolean isDumpLog = false;
 
     public NikonFocusingControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
     {
index 65964c1..37fda95 100644 (file)
@@ -110,14 +110,14 @@ public class NikonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
                 break;
 
             case SEQ_EVENT_INITIALIZE:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting1), false, false, 0);
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.nikon_connect_connecting1), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_INIT_SESSION, 50, isDumpLog, 0, 0x1001, 0, 0, 0, 0, 0));  // GetDeviceInfo
                 break;
 
             case SEQ_INIT_SESSION:
                 if (checkEventInitialize(rx_body))
                 {
-                    interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting2), false, false, 0);
+                    interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.nikon_connect_connecting2), false, false, 0);
                     commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_OPEN_SESSION, 50, isDumpLog, 0, 0x1002, 4, 0x41, 0, 0, 0));  // OpenSession
                 }
                 else
@@ -126,14 +126,12 @@ public class NikonCameraConnectSequence implements Runnable, IPtpIpCommandCallba
                 }
                 break;
             case SEQ_OPEN_SESSION:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting3), false, false, 0);
+                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.nikon_connect_connecting3), false, false, 0);
                 commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHANGE_REMOTE, 50, isDumpLog, 0, 0x902c, 4, 0x01, 0, 0, 0));  //
                 break;
 
             case SEQ_CHANGE_REMOTE:
             case SEQ_SET_EVENT_MODE:
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting4), false, false, 0);
-                interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting5), false, false, 0);
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connect_finished), false, false, 0);
                 connectFinished();
                 Log.v(TAG, "  CONNECT TO CAMERA : DONE.");
index 3889e31..22b27c1 100644 (file)
@@ -212,7 +212,7 @@ public class NikonConnection implements ICameraConnection
      */
     private void disconnectFromCamera(final boolean powerOff)
     {
-        Log.v(TAG, " disconnectFromCamera()");
+        Log.v(TAG, " disconnectFromCamera() : " + powerOff);
         try
         {
             cameraExecutor.execute(disconnectSequence);
index dc93d73..c028c05 100644 (file)
@@ -14,7 +14,6 @@ import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommunication;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.PtpIpResponseReceiver;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.liveview.IPtpIpLiveViewImageCallback;
-import net.osdn.gokigen.a01d.camera.utils.SimpleLogDumper;
 import net.osdn.gokigen.a01d.liveview.liveviewlistener.IImageDataReceiver;
 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
 
@@ -37,7 +36,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
     private NikonLiveViewImageReceiver imageReceiver;
     private IImageDataReceiver dataReceiver = null;
     private boolean liveViewIsReceiving = false;
-    private boolean commandIssued = false;
+    //private boolean commandIssued = false;
     private boolean isDumpLog = false;
 
     public NikonLiveViewControl(@NonNull Activity context, @NonNull IPtpIpInterfaceProvider interfaceProvider, int delayMs)
@@ -64,7 +63,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
         Log.v(TAG, " startLiveView() ");
         try
         {
-            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 30, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
+            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, delayMs, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
         }
         catch (Exception e)
         {
@@ -81,7 +80,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
             if (liveViewIsReceiving)
             {
                 liveViewIsReceiving = false;
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(null), SEQ_STOP_LIVEVIEW, 30, isDumpLog, 0, 0x9202, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(new PtpIpResponseReceiver(null), SEQ_STOP_LIVEVIEW, delayMs, isDumpLog, 0, 0x9202, 0, 0x00, 0x00, 0x00, 0x00));
             }
         }
         catch (Exception e)
@@ -90,6 +89,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
         }
     }
 
+/*
     private void startLiveviewImpl()
     {
         liveViewIsReceiving = true;
@@ -131,6 +131,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
             e.printStackTrace();
         }
     }
+*/
 
     @Override
     public void updateDigitalZoom()
@@ -199,7 +200,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
         {
             e.printStackTrace();
         }
-        commandIssued = false;
+        //commandIssued = false;
         sendNextMessage();
     }
 
@@ -210,7 +211,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
             Thread.sleep(delayMs);
             //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x1015, 4, 0x5007, 0x00, 0x00, 0x00));
             //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
-            commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
+            commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog));
         }
         catch (Exception e)
         {
@@ -249,7 +250,7 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
     public void onErrorOccurred(Exception e)
     {
         Log.v(TAG, " onErrorOccurred () : " + e.getLocalizedMessage());
-        commandIssued = false;
+        //commandIssued = false;
     }
 
     @Override
@@ -285,29 +286,29 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
             Log.v(TAG, String.format(" ----- OK REPLY (ID : %d) ----- ", id));
             if (id == SEQ_START_LIVEVIEW)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 30, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, delayMs, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_DEVICE_READY)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 30, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, delayMs, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_CHECK_EVENT)
             {
-                commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
+                commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog));
             }
             else if (id == SEQ_GET_DEVICE_PROP1)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP2, 30, isDumpLog, 0, 0x1015, 4, 0xd100, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP2, delayMs, isDumpLog, 0, 0x1015, 4, 0xd100, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_GET_DEVICE_PROP2)
             {
-                commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
+                commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog));
             }
             else  // SEQ_AFDRIVE
             {
                 // ライブビューの開始。
                 //startLiveviewImpl();
-                commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 80, isDumpLog));
+                commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, delayMs, isDumpLog));
             }
         }
         catch (Exception e)
@@ -335,27 +336,27 @@ public class NikonLiveViewControl  implements ILiveViewControl, ILiveViewListene
             waitSleep();
             if (id == SEQ_START_LIVEVIEW)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, 30, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_START_LIVEVIEW, delayMs, isDumpLog, 0, 0x9201, 0, 0x00, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_DEVICE_READY)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, 30, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_DEVICE_READY, delayMs, isDumpLog, 0, 0x90c8, 0, 0x00, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_CHECK_EVENT)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, delayMs, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_GET_DEVICE_PROP1)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x5007, 4, 0x5007, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, delayMs, isDumpLog, 0, 0x5007, 4, 0x5007, 0x00, 0x00, 0x00));
             }
             else if (id == SEQ_GET_DEVICE_PROP2)
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP2, 30, isDumpLog, 0, 0x1015, 4, 0xd100, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP2, delayMs, isDumpLog, 0, 0x1015, 4, 0xd100, 0x00, 0x00, 0x00));
             }
             else
             {
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, 30, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_AFDRIVE, delayMs, isDumpLog, 0, 0x90c1, 0, 0x00, 0x00, 0x00, 0x00));
             }
         }
         catch (Exception e)
index c4dd0af..92747ec 100644 (file)
@@ -73,13 +73,13 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
             if (tcpNoDelay)
             {
                 socket.setKeepAlive(false);
-                socket.setPerformancePreferences(0, 1, 0);
-                //socket.setSoLinger(true, 3000);
+                socket.setPerformancePreferences(0, 2, 0);
                 socket.setOOBInline(true);
                 socket.setReuseAddress(false);
+                socket.setTrafficClass(0x80);
+                //socket.setSoLinger(true, 3000);
                 //socket.setReceiveBufferSize(2097152);
                 //socket.setSendBufferSize(524288);
-                socket.setTrafficClass(0x80);
             }
             socket.connect(new InetSocketAddress(ipAddress, portNumber), 0);
             return (true);
@@ -393,7 +393,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
         {
             delayMs = COMMAND_SEND_RECEIVE_DURATION_MS;
         }
-
+/*
         try
         {
             if (socket != null)
@@ -405,6 +405,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
         {
             e.printStackTrace();
         }
+*/
 
         if ((callback != null)&&(callback.isReceiveMulti()))
         {
@@ -518,11 +519,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                 }
             }
 
-            boolean read_retry = false;
-            int target_length = 0;
-            int received_length = 0;
+            int target_length;
+            int received_length;
 
-            do
+            //boolean read_retry = false;
+            //do
             {
                 // 初回データの読み込み...
                 read_bytes = is.read(byte_array, 0, receive_message_buffer_size);
@@ -540,7 +541,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
                     return (false);
                 }
 
-            } while (read_retry);
+            } //while (read_retry);
 
             //  一時的な処理
             if (callback != null)
index 0f22435..8de5348 100644 (file)
     <string name="canon_connect_connecting11">接続中&#8230;(11/12)</string>
     <string name="canon_connect_connecting12">接続中&#8230;(12/12)</string>
 
+    <string name="nikon_connect_connecting1">接続中&#8230;(1/5)</string>
+    <string name="nikon_connect_connecting2">接続中&#8230;(2/5)</string>
+    <string name="nikon_connect_connecting3">接続中&#8230;(3/5)</string>
+
     <string name="connect_error_message">接続失敗</string>
 
     <string name="connect_error_message_olympus">接続失敗 (OLYMPUS)</string>
index ebeff1d..4b2b3f1 100644 (file)
     <string name="canon_connect_connecting11">Connecting&#8230;(11/12)</string>
     <string name="canon_connect_connecting12">Connecting&#8230;(12/12)</string>
 
+    <string name="nikon_connect_connecting1">Connecting&#8230;(1/5)</string>
+    <string name="nikon_connect_connecting2">Connecting&#8230;(2/5)</string>
+    <string name="nikon_connect_connecting3">Connecting&#8230;(3/5)</string>
+
     <string name="connect_error_message">CONNECTION ERROR</string>
 
     <string name="connect_error_message_olympus">CONNECTION ERROR (OLYMPUS)</string>