Browse Source

멀티제어시 다른층에서 소리나는거 막음. 모바일 앱 응답 오류 수정. 멀티제어 일부 예외처리.

jslee(madeinlab) 3 years ago
parent
commit
32fdbf36d8

+ 22 - 1
WallPadHomeCtrl/src/main/java/kr/co/icontrols/wallpadhomectrl/MainActivity.java

@@ -336,7 +336,10 @@ public class MainActivity extends WpadActivity {
 		// @ AutoScale 설정
 		WpadScale.setAutoScale(true);
 
-		if (Common.CHECK_DEV_SERVICE) StartDevService();
+		if (Common.CHECK_DEV_SERVICE) {
+			StartDevService();
+			runMultiControlService();
+		}
 
 		super.AppVersionLogOut();   // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
 		Log.i("[onCreate] Version", "<><><><>  WallPadAPI     Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
@@ -1416,6 +1419,7 @@ public class MainActivity extends WpadActivity {
 			Log.d(TAG, "[setTitleName] nScreenId [" + nScreenId + "]");
 			switch (nScreenId) {
 				case API_Menu.SubMenuCtrl.HDC_LivingLamp:
+				case ID.screen.LightKnxMainTestScreen:
 					SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
 					ret = true;
 					break;
@@ -2771,6 +2775,23 @@ public class MainActivity extends WpadActivity {
 		}
 	}
 
+	private void runMultiControlService() {
+		ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
+		List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
+
+		for (int i = 0; i < RunningAppList.size(); i++) {
+			ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
+
+			if (RunningAppListInfo.processName.equals("kr.co.icontrols.wallpadmulticontrolservice")) {
+				Log.w(TAG, "[runMultiControlService] runMultiControlService is already running");
+				return;
+			}
+		}
+		Log.i(TAG, "[runMultiControlService] Start runMultiControlService!!");
+		Intent mIntent = new Intent("wallpadmulticontrolservice.DataSenderService");
+		startService(mIntent);
+	}
+
 
 	/**
 	 * DB 에서 룸이름 정보를 가져온다.

+ 29 - 23
WallPadHomeCtrl/src/main/java/kr/co/icontrols/wallpadhomectrl/screen/screen_multi/HeatingV2TestScreen.java

@@ -510,13 +510,14 @@ public class HeatingV2TestScreen extends WpadScreen {
     }
 
     private void resetTimer(){
-        if(TT != null)
-        {
-            TT.cancel();
-            TT = null;
-        }
-        if (timer != null)
-            timer.purge();
+        try {
+            if (TT != null) {
+                TT.cancel();
+                TT = null;
+            }
+            if (timer != null)
+                timer.purge();
+        }catch (Exception e){}
     }
 
     private void requestMultiCommand(int kind, int reason, int position, String category, int number, int state){
@@ -561,7 +562,7 @@ public class HeatingV2TestScreen extends WpadScreen {
                         if(resultData.getType().equals("controlResponse")&&resultData.getResult().equals("ok")) {
                             //제어 명령을 내리고 제대로 응답이 오면 상태를 다시 조회해서 UI 갱신하도록 한다.
                             Sound().Play(SND.effect.TOUCH_LATCHED);
-                            startRefreshTimer();
+                            startRefreshTimer(1300);
                         }
                         else if(resultData.getType().equals("updateResponse")) {
                             //상태 조회 응답이 오면, data를 갱신한다.
@@ -603,23 +604,27 @@ public class HeatingV2TestScreen extends WpadScreen {
         if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) astrRoomTitle = mKNXDefaultRoomNameList;
         else astrRoomTitle = roomNameList;
 
+        nCurrentPageNo = 1;
+
         mData = new Data();
         timer = new Timer();
-        startRefreshTimer();
+        startRefreshTimer(500);
         //updateData();
         //Sample_DataDefaultSetting();
     }
 
-    private void startRefreshTimer(){
-        resetTimer();
-        TT = new TimerTask() {
-            @Override
-            public void run() {
-                // 반복실행할 구문
-                updateData();
-            }
-        };
-        timer.schedule(TT, 500, 3500); //Timer 실행
+    private void startRefreshTimer(int delay){
+        try {
+            resetTimer();
+            TT = new TimerTask() {
+                @Override
+                public void run() {
+                    // 반복실행할 구문
+                    updateData();
+                }
+            };
+            timer.schedule(TT, delay, 2500); //Timer 실행
+        }catch (Exception e){}
     }
 
     /**
@@ -630,10 +635,11 @@ public class HeatingV2TestScreen extends WpadScreen {
         super.onClose();
         // 보일러 지원 여부에 따라 아이콘 안보이기
         if (mData.heatingV2.Device.info.Support.Boiler) ((MainActivity)(getContext())).setTopBoilerBtnVisible(false);
-
-        resetTimer();
-        if (timer != null)
-            timer.cancel();
+        try {
+            resetTimer();
+            if (timer != null)
+                timer.cancel();
+        }catch (Exception e){}
     }
 
     /**

+ 27 - 20
WallPadHomeCtrl/src/main/java/kr/co/icontrols/wallpadhomectrl/screen/screen_multi/KnxSystemAirconMainTestScreen.java

@@ -440,13 +440,14 @@ public class KnxSystemAirconMainTestScreen extends WpadScreen {
     }
 
     private void resetTimer(){
-        if(TT != null)
-        {
-            TT.cancel();
-            TT = null;
-        }
-        if (timer != null)
-            timer.purge();
+        try {
+            if (TT != null) {
+                TT.cancel();
+                TT = null;
+            }
+            if (timer != null)
+                timer.purge();
+        }catch (Exception e){}
     }
 
     private void requestMultiCommand(int kind, int reason, int position, String category, int number, int state){
@@ -495,7 +496,7 @@ public class KnxSystemAirconMainTestScreen extends WpadScreen {
                         if(resultData.getType().equals("controlResponse")&&resultData.getResult().equals("ok")) {
                             //제어 명령을 내리고 제대로 응답이 오면 상태를 다시 조회해서 UI 갱신하도록 한다.
                             Sound().Play(SND.effect.TOUCH_LATCHED);
-                            startRefreshTimer(2000);
+                            startRefreshTimer(2600);
                         }
                         else if(resultData.getType().equals("updateResponse")) {
                             //상태 조회 응답이 오면, data를 갱신한다.
@@ -539,6 +540,8 @@ public class KnxSystemAirconMainTestScreen extends WpadScreen {
         mData = new Data();
         //mDataLouver = new DataLouver();
 
+        CurrentPageNum = 1;
+
         //madeinLab-- UX_MODE 필요 시 적용.
         //UX_MODE = ((MainActivity) context).GetEasyModeUXUse() ? Common.UX_EASY_MODE : Common.UX_NORMAL_MODE;
         inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -560,15 +563,17 @@ public class KnxSystemAirconMainTestScreen extends WpadScreen {
     }
 
     private void startRefreshTimer(int delay){
-        resetTimer();
-        TT = new TimerTask() {
-            @Override
-            public void run() {
-                // 반복실행할 구문
-                updateData();
-            }
-        };
-        timer.schedule(TT, delay, 3000); //Timer 실행
+        try {
+            resetTimer();
+            TT = new TimerTask() {
+                @Override
+                public void run() {
+                    // 반복실행할 구문
+                    updateData();
+                }
+            };
+            timer.schedule(TT, delay, 2000); //Timer 실행
+        }catch (Exception e){}
     }
 
 
@@ -576,9 +581,11 @@ public class KnxSystemAirconMainTestScreen extends WpadScreen {
     protected void onClose() {
         super.onClose();
 
-        resetTimer();
-        if (timer != null)
-            timer.cancel();
+        try {
+            resetTimer();
+            if (timer != null)
+                timer.cancel();
+        }catch (Exception e){}
     }
 
     @Override

+ 26 - 19
WallPadHomeCtrl/src/main/java/kr/co/icontrols/wallpadhomectrl/screen/screen_multi/LightKnxMainTestScreen.java

@@ -429,13 +429,14 @@ public class LightKnxMainTestScreen extends WpadScreen {
     }
 
     private void resetTimer(){
-        if(TT != null)
-        {
-            TT.cancel();
-            TT = null;
-        }
-        if (timer != null)
-            timer.purge();
+        try {
+            if (TT != null) {
+                TT.cancel();
+                TT = null;
+            }
+            if (timer != null)
+                timer.purge();
+        }catch (Exception e){}
     }
 
     private void requestMultiControl(int kind, int reason, int position, String category, int number, int state) {
@@ -522,6 +523,8 @@ public class LightKnxMainTestScreen extends WpadScreen {
         DebugLogOutput("[Create] - Step1 : Data Create");
         OPERATION_MODE = operationMode;
 
+        CurrentPageNum = 1;
+
         mData = new Data_KnxLiv();
         timer = new Timer();
 
@@ -543,15 +546,17 @@ public class LightKnxMainTestScreen extends WpadScreen {
     }
 
     private void startRefreshTimer(int delay){
-        resetTimer();
-        TT = new TimerTask() {
-            @Override
-            public void run() {
-                // 반복실행할 구문
-                updateData();
-            }
-        };
-        timer.schedule(TT, delay, 4000); //Timer 실행
+        try {
+            resetTimer();
+            TT = new TimerTask() {
+                @Override
+                public void run() {
+                    // 반복실행할 구문
+                    updateData();
+                }
+            };
+            timer.schedule(TT, delay, 3000); //Timer 실행
+        }catch (Exception e){}
     }
 
     private void Set_TotalPageNum(int AllNum) {
@@ -583,9 +588,11 @@ public class LightKnxMainTestScreen extends WpadScreen {
 
         wd.closeDB();
 
-        resetTimer();
-        if (timer != null)
-            timer.cancel();
+        try {
+            resetTimer();
+            if (timer != null)
+                timer.cancel();
+        }catch (Exception e){}
     }
 
     @Override

+ 2 - 2
WallPadMain/src/main/java/kr/co/icontrols/wallpadmain/util/iMapServer.java

@@ -5482,7 +5482,7 @@ public class iMapServer extends Service {
 
             if (strResult != null) return strResult;
             else
-                strResult = XMLHeader + "   <service type=\"reply\" name=\"remote_get_home_devices\" result=";
+                strResult = XMLHeader + "   <service type=\"reply\" name=\"remote_get_home_devices\" ";
 
             String target = "null", tid = "null", msgno = "null";
             NodeList items = ele.getElementsByTagName("target");
@@ -5529,7 +5529,7 @@ public class iMapServer extends Service {
             } else {
                 devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "smartlight", "cooktop", "sysaircon"};
             }
-            strResult += "\"ok\">\r\n";
+            strResult += "result=\"ok\">\r\n";
             strResult += "      <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
             strResult += "         <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
             //strResult += "         <devlist total_count=\""+devlist.length+"\"/>\r\n";

+ 10 - 8
WallPadMultiControlService/src/main/java/kr/co/icontrols/wallpadmulticontrolservice/DataSenderService.java

@@ -571,6 +571,8 @@ public class DataSenderService extends Service {
                         outputStream.writeObject(result);
                         outputStream.close();
                         Log.d("ServerThread", "result 보냄 : " + result);
+                    } else{
+                        outputStream.close();
                     }
                     inputStream.close();
                     socket.close(); // 연결을 유지할 필요 없으면 끊어줌.
@@ -968,8 +970,8 @@ public class DataSenderService extends Service {
             }
         }
         int ret = mKnxAPI.SetLightOnOff((byte) (index), define.DEVICE_ALL_OR_NOTHING, OnOff);
-        if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-        else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+        //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+        //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         return ret;
     }
 
@@ -987,8 +989,8 @@ public class DataSenderService extends Service {
             }
         }
         int ret = mKnxAPI.SetLightSwitchOnOff((byte) (index), define.DEVICE_ALL_OR_NOTHING, OnOff);
-        if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-        else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+        //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+        //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         return ret;
     }
 
@@ -1040,8 +1042,8 @@ public class DataSenderService extends Service {
                     Log.e(TAG, "[Device_LightOnOff] - Error (" + ret + ")   ErrorCode = " + mKnxAPI.ErrorCode.ErrStr());
                 }
             }
-            if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-            else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+            //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+            //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         } catch (RuntimeException re) {
             LogUtil.errorLogInfo("", TAG, re);
             ret = JSON.ERROR.RuntimeException;
@@ -1113,8 +1115,8 @@ public class DataSenderService extends Service {
                     Log.e(TAG, "[Device_LightOnOff] - Error (" + ret + ")   ErrorCode = " + mKnxAPI.ErrorCode.ErrStr());
                 }
             }
-            if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-            else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+            //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+            //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         } catch (RuntimeException re) {
             LogUtil.errorLogInfo("", TAG, re);
             ret = JSON.ERROR.RuntimeException;

+ 6 - 6
WallPadMultiControlService/src/main/java/kr/co/icontrols/wallpadmulticontrolservice/control/HeatingControl.java

@@ -56,8 +56,8 @@ public class HeatingControl {
                 ret = Common.JSON.ERROR.Exception;
             }
         }
-        if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-        else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+        //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+        //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         return ret;
     }
 
@@ -94,8 +94,8 @@ public class HeatingControl {
                 ret = Common.JSON.ERROR.Exception;
             }
         }
-        if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-        else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+        //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+        //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         return ret;
     }
 
@@ -129,8 +129,8 @@ public class HeatingControl {
                 ret = Common.JSON.ERROR.Exception;
             }
         }
-        if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-        else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+        //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+        //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         return ret;
     }
 

+ 2 - 2
WallPadMultiControlService/src/main/java/kr/co/icontrols/wallpadmulticontrolservice/control/LightControl.java

@@ -47,8 +47,8 @@ public class LightControl {
             LogUtil.errorLogInfo("", TAG, e);
             ret = JSON.ERROR.Exception;
         }
-        if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
-        else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
+        //if (ret >= 0) mSound.Play(WpadSound.SND.effect.TOUCH_LATCHED);
+        //else mSound.Play(WpadSound.SND.effect.TOUCH_UNLATCHED);
         return ret;
     }