OSDN Git Service

LVエラー発生時の情報を出力するようにした。
authorMRSa <mrsa@myad.jp>
Fri, 18 Feb 2022 13:25:45 +0000 (22:25 +0900)
committerMRSa <mrsa@myad.jp>
Fri, 18 Feb 2022 13:25:45 +0000 (22:25 +0900)
.idea/deploymentTargetDropDown.xml
app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/panasonic/liveview/PanasonicLiveViewControl.kt
app/src/main/java/jp/osdn/gokigen/gokigenassets/camera/vendor/panasonic/wrapper/PanasonicCameraControl.kt
app/src/main/java/jp/osdn/gokigen/gokigenassets/scene/IInformationReceiver.kt
app/src/main/java/jp/osdn/gokigen/gokigenassets/scene/ShowMessage.kt

index eeca1c6..cb13bd8 100644 (file)
@@ -12,6 +12,6 @@
         </deviceKey>
       </Target>
     </runningDeviceTargetSelectedWithDropDown>
-    <timeTargetWasSelectedWithDropDown value="2022-02-17T14:40:45.113298700Z" />
+    <timeTargetWasSelectedWithDropDown value="2022-02-18T12:36:26.894010400Z" />
   </component>
 </project>
\ No newline at end of file
index d6f6fea..a0c2490 100644 (file)
@@ -4,13 +4,14 @@ import android.util.Log
 import jp.osdn.gokigen.gokigenassets.camera.vendor.panasonic.IPanasonicCamera
 import jp.osdn.gokigen.gokigenassets.camera.vendor.panasonic.status.ICameraEventObserver
 import jp.osdn.gokigen.gokigenassets.liveview.image.CameraLiveViewListenerImpl
+import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
 import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
 import java.net.DatagramPacket
 import java.net.DatagramSocket
 
-class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewListenerImpl, private val camera: IPanasonicCamera, private val eventObserver: ICameraEventObserver, number: Int)
+class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewListenerImpl, private val camera: IPanasonicCamera, private val eventObserver: ICameraEventObserver, private val informationReceiver: IInformationReceiver, private val portNumber: Int)
 {
-    private val liveViewPortNumber = 49151 + number   // Base : 49152
+    private val liveViewPortNumber = 49151 + portNumber  // Base port number : 49152
     private var receiverSocket: DatagramSocket? = null
     private var whileStreamReceive = false
     private var errorOccur = 0
@@ -22,8 +23,6 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
         private const val ERROR_MAX = 30
         private const val RECEIVE_BUFFER_SIZE = 1024 * 1024 * 4
         private const val TIMEOUT_MS = 3500
-        //private const val LIVEVIEW_PORT = 49152
-        //private const val LIVEVIEW_START_REQUEST = "cam.cgi?mode=startstream&value=49152"
         private const val LIVEVIEW_START_REQUEST = "cam.cgi?mode=startstream&value="
         private const val LIVEVIEW_STOP_REQUEST = "cam.cgi?mode=stopstream"
     }
@@ -122,11 +121,13 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
         }
     }
 
+/*
     fun changeLiveViewSize(size: String?) {}
     fun updateDigitalZoom() {}
     fun updateMagnifyingLiveViewScale(isChangeScale: Boolean) {}
     fun getMagnifyingLiveViewScale(): Float { return 1.0f }
     fun getDigitalZoomScale(): Float { return 1.0f }
+*/
 
     private fun startReceiveStream()
     {
@@ -231,6 +232,7 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
             }
             catch (e: Exception)
             {
+                showExceptionInformation()
                 exceptionCount++
                 e.printStackTrace()
                 if (exceptionCount > TIMEOUT_MAX)
@@ -245,6 +247,10 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
                         {
                             Log.v(TAG, "LV : RETRY COMMAND FAIL...")
                         }
+                        else
+                        {
+                            clearExceptionInformation()
+                        }
                     }
                     catch (ee: Exception)
                     {
@@ -258,6 +264,39 @@ class PanasonicLiveViewControl(private val liveViewListener : CameraLiveViewList
         System.gc()
     }
 
+    private fun showExceptionInformation()
+    {
+        try
+        {
+            val msgToShow = "l${portNumber}e"
+            if (!informationReceiver.getCurrentMessage().contains(msgToShow))
+            {
+                informationReceiver.appendMessage(" $msgToShow")
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
+    private fun clearExceptionInformation()
+    {
+        try
+        {
+            val msgToShow = "l${portNumber}e"
+            val currentMessage = informationReceiver.getCurrentMessage()
+            if (currentMessage.contains(msgToShow))
+            {
+                informationReceiver.updateMessage(currentMessage.replace(msgToShow, ""))
+            }
+        }
+        catch (e: Exception)
+        {
+            e.printStackTrace()
+        }
+    }
+
     private fun closeReceiveSocket()
     {
         Log.v(TAG, "closeReceiveSocket()")
index 3a8eeb8..e05250d 100644 (file)
@@ -29,7 +29,7 @@ import jp.osdn.gokigen.gokigenassets.scene.IInformationReceiver
 import jp.osdn.gokigen.gokigenassets.scene.IVibrator
 import jp.osdn.gokigen.gokigenassets.utils.communication.SimpleHttpClient
 
-class PanasonicCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, informationNotify: IInformationReceiver, private val preference: ICameraPreferenceProvider, provider: ICameraStatusReceiver, private val cameraCoordinator: ICameraControlCoordinator, private val number: Int) : IPanasonicCameraHolder, IDisplayInjector,ILiveViewController, ICameraControl, View.OnClickListener, View.OnLongClickListener, ICameraShutter, IKeyDown
+class PanasonicCameraControl(private val context: AppCompatActivity, private val vibrator : IVibrator, private val informationNotify: IInformationReceiver, private val preference: ICameraPreferenceProvider, provider: ICameraStatusReceiver, private val cameraCoordinator: ICameraControlCoordinator, private val number: Int) : IPanasonicCameraHolder, IDisplayInjector,ILiveViewController, ICameraControl, View.OnClickListener, View.OnLongClickListener, ICameraShutter, IKeyDown
 {
     private val cardSlotSelector = PanasonicCardSlotSelector()
     private val liveViewListener = CameraLiveViewListenerImpl(context, informationNotify)
@@ -66,7 +66,7 @@ class PanasonicCameraControl(private val context: AppCompatActivity, private val
                 }
                 if (liveViewControl == null)
                 {
-                    liveViewControl = PanasonicLiveViewControl(liveViewListener, panasonicCamera, statusChecker.getCameraStatusEventObserver(), number)
+                    liveViewControl = PanasonicLiveViewControl(liveViewListener, panasonicCamera, statusChecker.getCameraStatusEventObserver(), informationNotify, number)
                 }
                 focusControl?.setCamera(panasonicCamera)
                 captureControl?.setCamera(panasonicCamera)
index 5dae5d7..41c3df1 100644 (file)
@@ -5,4 +5,6 @@ import android.graphics.Color
 interface IInformationReceiver
 {
     fun updateMessage(message: String = "", isBold: Boolean = false, isColor: Boolean = false, color: Int = Color.BLACK)
+    fun appendMessage(message: String = "", isBold: Boolean = false, isColor: Boolean = false, color: Int = Color.BLACK)
+    fun getCurrentMessage() : String
 }
index 6a42171..a4d4277 100644 (file)
@@ -8,8 +8,10 @@ import jp.osdn.gokigen.gokigenassets.constants.IApplicationConstantConvert.Compa
 
 class ShowMessage(private val activity : AppCompatActivity) : IInformationReceiver
 {
+    private var currentMessage : String = ""
     override fun updateMessage(message: String, isBold: Boolean, isColor: Boolean, color: Int)
     {
+        currentMessage = message
         val messageArea = activity.findViewById<TextView>(ID_AREA_MESSAGE)
         activity.runOnUiThread {
             messageArea?.text = message
@@ -28,4 +30,15 @@ class ShowMessage(private val activity : AppCompatActivity) : IInformationReceiv
             messageArea?.invalidate()
         }
     }
+
+    override fun appendMessage(message: String, isBold: Boolean, isColor: Boolean, color: Int)
+    {
+        updateMessage(currentMessage + message, isBold, isColor, color)
+    }
+
+    override fun getCurrentMessage(): String
+    {
+        return (currentMessage)
+    }
+
 }