• R/O
  • HTTP
  • SSH
  • HTTPS

A01d: Commit

OPC(Olympus Air)用望遠鏡アプリ。


Commit MetaInfo

Revisão7c85a0fa22dba9a50d601cdd76e2d51bae598506 (tree)
Hora2020-03-08 21:07:07
AutorMRSa <mrsa@myad...>
CommiterMRSa

Mensagem de Log

g06だと安定していた。g06+での安定模索中。

Mudança Sumário

Diff

--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/canon/wrapper/CanonInterfaceProvider.java
@@ -63,7 +63,7 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
6363 public CanonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
6464 {
6565 this.activity = context;
66- commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
66+ commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false, false);
6767 liveViewControl = new CanonLiveViewControl(context, this, 10); //
6868 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
6969 statusChecker = new CanonStatusChecker(context, commandPublisher, CAMERA_IP, EVENT_PORT);
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/operation/NikonFocusingControl.java
@@ -34,7 +34,8 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
3434 private float maxPointLimitWidth;
3535 private float maxPointLimitHeight;
3636 private RectF preFocusFrameRect = null;
37- private boolean isDumpLog = false;
37+ private boolean not_support_focus_lock = false;
38+ private boolean isDumpLog = true;
3839
3940 public NikonFocusingControl(@NonNull Activity context, @NonNull PtpIpCommandPublisher commandPublisher, IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator)
4041 {
@@ -57,7 +58,8 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
5758 maxPointLimitWidth = 6000.0f;
5859 maxPointLimitHeight = 4000.0f;
5960 }
60- Log.v(TAG, "FOCUS RESOLUTION : " + maxPointLimitWidth + "," + maxPointLimitHeight);
61+ not_support_focus_lock = preferences.getBoolean(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, false);
62+ Log.v(TAG, "FOCUS RESOLUTION : " + maxPointLimitWidth + "," + maxPointLimitHeight + " FOCUS LOCK : " + not_support_focus_lock);
6163 }
6264 catch (Exception e)
6365 {
@@ -137,8 +139,11 @@ public class NikonFocusingControl implements IFocusingControl, IPtpIpCommandCall
137139 int x = (0x0000ffff & (Math.round(point.x * maxPointLimitWidth) + 1));
138140 int y = (0x0000ffff & (Math.round(point.y * maxPointLimitHeight) + 1));
139141 Log.v(TAG, "Lock AF: [" + x + ","+ y + "]");
140- commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, isDumpLog, 0, 0x9205, 8, x, y));
141- //commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
142+ if (!not_support_focus_lock) {
143+ commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_LOCK, isDumpLog, 0, 0x9205, 8, x, y));
144+ } else {
145+ commandPublisher.enqueueCommand(new PtpIpCommandGeneric(this, FOCUS_MOVE, isDumpLog, 0, 0x90c1));
146+ }
142147 }
143148 catch (Exception e)
144149 {
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/NikonInterfaceProvider.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/NikonInterfaceProvider.java
@@ -63,7 +63,7 @@ public class NikonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay
6363 public NikonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver)
6464 {
6565 this.activity = context;
66- commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false);
66+ commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, true, false);
6767 liveViewControl = new NikonLiveViewControl(context, this, 20);
6868 asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT);
6969 statusChecker = new NikonStatusChecker(activity, commandPublisher, CAMERA_IP, EVENT_PORT);
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/nikon/wrapper/liveview/NikonLiveViewControl.java
@@ -199,11 +199,26 @@ public class NikonLiveViewControl implements ILiveViewControl, ILiveViewListene
199199 {
200200 e.printStackTrace();
201201 }
202- //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x1015, 4, 0x5007, 0x00, 0x00, 0x00));
203- commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
204202 commandIssued = false;
203+ sendNextMessage();
205204 }
206205
206+ private void sendNextMessage()
207+ {
208+ try
209+ {
210+ Thread.sleep(delayMs);
211+ //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_GET_DEVICE_PROP1, 30, isDumpLog, 0, 0x1015, 4, 0x5007, 0x00, 0x00, 0x00));
212+ //commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_CHECK_EVENT, 30, isDumpLog, 0, 0x90c7, 0, 0x00, 0x00, 0x00, 0x00));
213+ commandIssuer.enqueueCommand(new NikonLiveViewRequestMessage(imageReceiver, 35, isDumpLog));
214+ }
215+ catch (Exception e)
216+ {
217+ e.printStackTrace();
218+ }
219+ }
220+
221+
207222 private int searchJpegHeader(byte[] data)
208223 {
209224 try
--- a/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/camera/ptpip/wrapper/command/PtpIpCommandPublisher.java
@@ -10,6 +10,7 @@ import java.io.BufferedReader;
1010 import java.io.ByteArrayOutputStream;
1111 import java.io.DataOutputStream;
1212 import java.io.InputStream;
13+import java.net.InetSocketAddress;
1314 import java.net.Socket;
1415 import java.util.ArrayDeque;
1516 import java.util.Arrays;
@@ -33,6 +34,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
3334 private boolean isStart = false;
3435 private boolean isHold = false;
3536 private boolean tcpNoDelay;
37+ private boolean waitForever;
3638 private int holdId = 0;
3739 private Socket socket = null;
3840 private DataOutputStream dos = null;
@@ -41,11 +43,12 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
4143 private Queue<IPtpIpCommand> commandQueue;
4244 private Queue<IPtpIpCommand> holdCommandQueue;
4345
44- public PtpIpCommandPublisher(@NonNull String ip, int portNumber, boolean tcpNoDelay)
46+ public PtpIpCommandPublisher(@NonNull String ip, int portNumber, boolean tcpNoDelay, boolean waitForever)
4547 {
4648 this.ipAddress = ip;
4749 this.portNumber = portNumber;
4850 this.tcpNoDelay = tcpNoDelay;
51+ this.waitForever = waitForever;
4952 this.commandQueue = new ArrayDeque<>();
5053 this.holdCommandQueue = new ArrayDeque<>();
5154 commandQueue.clear();
@@ -64,11 +67,21 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
6467 try
6568 {
6669 Log.v(TAG, " connect()");
67- socket = new Socket(ipAddress, portNumber);
70+ //socket = new Socket(ipAddress, portNumber);
71+ socket = new Socket();
6872 socket.setTcpNoDelay(tcpNoDelay);
69- socket.setKeepAlive(true);
70- //socket.setReceiveBufferSize(32768);
71- //socket.setTrafficClass(0x10);
73+ if (tcpNoDelay)
74+ {
75+ socket.setKeepAlive(false);
76+ socket.setPerformancePreferences(0, 1, 0);
77+ //socket.setSoLinger(true, 3000);
78+ socket.setOOBInline(true);
79+ socket.setReuseAddress(false);
80+ //socket.setReceiveBufferSize(2097152);
81+ //socket.setSendBufferSize(524288);
82+ socket.setTrafficClass(0x80);
83+ }
84+ socket.connect(new InetSocketAddress(ipAddress, portNumber), 0);
7285 return (true);
7386 }
7487 catch (Exception e)
@@ -280,7 +293,11 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
280293 {
281294 if (!command.isRetrySend())
282295 {
283- // コマンドを再送信しない場合はここで抜ける
296+ while (retry_over)
297+ {
298+ // コマンドを再送信しない場合はここで応答を待つ...
299+ retry_over = receive_from_camera(command);
300+ }
284301 break;
285302 }
286303 if (!command.isIncrementSequenceNumberToRetry())
@@ -376,6 +393,19 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
376393 {
377394 delayMs = COMMAND_SEND_RECEIVE_DURATION_MS;
378395 }
396+
397+ try
398+ {
399+ if (socket != null)
400+ {
401+ Log.v(TAG, " SOCKET : send " + socket.getSendBufferSize() + " recv " + socket.getReceiveBufferSize() + " " + socket.getTcpNoDelay() + " " + socket.getOOBInline() + " " + socket.getKeepAlive() + " " + socket.getReuseAddress() + " " + socket.getSoLinger() + " " + socket.getSoTimeout() + " " + socket.getTrafficClass());
402+ }
403+ }
404+ catch (Exception e)
405+ {
406+ e.printStackTrace();
407+ }
408+
379409 if ((callback != null)&&(callback.isReceiveMulti()))
380410 {
381411 // 受信したら逐次「受信したよ」と応答するパターン
@@ -685,7 +715,7 @@ public class PtpIpCommandPublisher implements IPtpIpCommandPublisher, IPtpIpComm
685715 isLogOutput = false;
686716 }
687717 retry_count--;
688- if (retry_count < 0)
718+ if ((!waitForever)&&(retry_count < 0))
689719 {
690720 return (-1);
691721 }
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/IPreferencePropertyAccessor.java
@@ -79,6 +79,8 @@ public interface IPreferencePropertyAccessor
7979 String NIKON_FOCUS_XY = "nikon_focus_xy";
8080 String NIKON_FOCUS_XY_DEFAULT_VALUE = "6000,4000";
8181
82+ String NIKON_NOT_SUPPORT_FOCUS_LOCK = "nikon_not_support_focus_lock";
83+
8284 /*
8385 int CHOICE_SPLASH_SCREEN = 10;
8486
--- a/app/src/main/java/net/osdn/gokigen/a01d/preference/nikon/NikonPreferenceFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/a01d/preference/nikon/NikonPreferenceFragment.java
@@ -127,6 +127,12 @@ public class NikonPreferenceFragment extends PreferenceFragmentCompat implements
127127 if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
128128 editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
129129 }
130+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_FOCUS_XY)) {
131+ editor.putString(IPreferencePropertyAccessor.NIKON_FOCUS_XY, IPreferencePropertyAccessor.NIKON_FOCUS_XY_DEFAULT_VALUE);
132+ }
133+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK)) {
134+ editor.putBoolean(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, false);
135+ }
130136 editor.apply();
131137 }
132138 catch (Exception e)
@@ -158,6 +164,11 @@ public class NikonPreferenceFragment extends PreferenceFragmentCompat implements
158164 Log.v(TAG, " " + key + " , " + value);
159165 break;
160166
167+ case IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK:
168+ value = preferences.getBoolean(key, false);
169+ Log.v(TAG, " " + key + " , " + value);
170+ break;
171+
161172 default:
162173 String strValue = preferences.getString(key, "");
163174 setListPreference(key, key, strValue);
@@ -177,7 +188,7 @@ public class NikonPreferenceFragment extends PreferenceFragmentCompat implements
177188 try
178189 {
179190 //super.onCreate(savedInstanceState);
180- addPreferencesFromResource(R.xml.preferences_olympuspen);
191+ addPreferencesFromResource(R.xml.preferences_nikon);
181192
182193 ListPreference connectionMethod = findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
183194 connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@@ -313,6 +324,7 @@ public class NikonPreferenceFragment extends PreferenceFragmentCompat implements
313324 // Preferenceの画面に反映させる
314325 setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, defaultValue);
315326 setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
327+ setBooleanPreference(IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, IPreferencePropertyAccessor.NIKON_NOT_SUPPORT_FOCUS_LOCK, false);
316328 }
317329 catch (Exception e)
318330 {
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -256,5 +256,7 @@
256256 <string name="pref_canon_zoom_resolution">ズームステップ</string>
257257 <string name="pref_summary_canon_zoom_resolution">ズームを何段階にするか指定します (標準: 25)</string>
258258
259+ <string name="pref_nikon_not_support_focus_lock">フォーカスロック未対応機</string>
260+ <string name="pref_summary_nikon_not_support_focus_lock">フォーカスロックでライブビューが止まる場合にチェックを入れてください。</string>
259261
260262 </resources>
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -261,4 +261,7 @@
261261 <string name="pref_canon_zoom_resolution">Zoom Step</string>
262262 <string name="pref_summary_canon_zoom_resolution"> </string>
263263
264+ <string name="pref_nikon_not_support_focus_lock">Not support Focus-Lock</string>
265+ <string name="pref_summary_nikon_not_support_focus_lock"> </string>
266+
264267 </resources>
--- a/app/src/main/res/xml/preferences_nikon.xml
+++ b/app/src/main/res/xml/preferences_nikon.xml
@@ -32,6 +32,11 @@
3232 android:summary="@string/pref_summary_nikon_focus_xy" />
3333
3434 <CheckBoxPreference
35+ android:key="nikon_not_support_focus_lock"
36+ android:title="@string/pref_nikon_not_support_focus_lock"
37+ android:summary="@string/pref_summary_nikon_not_support_focus_lock" />
38+
39+ <CheckBoxPreference
3540 android:key="capture_both_camera_and_live_view"
3641 android:title="@string/pref_capture_both_camera_and_live_view" />
3742
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
66 google()
77 }
88 dependencies {
9- classpath 'com.android.tools.build:gradle:3.6.0'
9+ classpath 'com.android.tools.build:gradle:3.6.1'
1010
1111 // NOTE: Do not place your application dependencies here; they belong
1212 // in the individual module build.gradle files
Show on old repository browser