Pārlūkot izejas kodu

[전동커튼v1]
1. 내부 변수명 수정
2. API 전송 시, 그룹 정보 같이 넘겨줌(거실, 안방 비교를 위해)

DESKTOP-FBA840V\icontrols 4 gadi atpakaļ
vecāks
revīzija
a480a34e19

+ 2 - 17
WallPadAPI/src/main/java/com/artncore/commons/DataClasses.java

@@ -7138,11 +7138,11 @@ public class DataClasses {
     public static class CurtainCtrl {
 
         public Info info;
-        public Curtain crutain;
+        public Curtain curtain;
 
         public CurtainCtrl() {
             info = new Info();
-            crutain = new Curtain();
+            curtain = new Curtain();
         }
 
         /** 보드정보 */
@@ -7296,21 +7296,6 @@ public class DataClasses {
             }
         }
 
-
-        ///////////////////////////////////////////////////////////////////////////////////////////////
-        // 디바이스 ID
-        ///////////////////////////////////////////////////////////////////////////////////////////////
-        public static final class DEVICE_ID {
-            public final static byte ID_MIN = (byte)0x01;   // 최소 ID
-            public final static byte ID_MAX = (byte)0x0F;   // 최대 ID
-
-            public static boolean checkRange(byte value) {
-                if (value < ID_MIN || ID_MAX < value) return false;
-                else return true;
-            }
-        }
-
-
         ///////////////////////////////////////////////////////////////////////////////////////////////
         // 디바이스 동작 상태
         ///////////////////////////////////////////////////////////////////////////////////////////////

+ 7 - 5
WallPadAPI/src/main/java/com/artncore/wallpadapi/CurtainAPI.java

@@ -108,13 +108,15 @@ public class CurtainAPI extends WallPadDevAPI {
              * [Format]
              *
              * SUCCESS;                         - (String) 성공
+             * Index;                           - (byte) Index
              *
              * [Info]
              * bInstall                          - (boolean) 설치여부
              *
              * [Circuit]
              * 회로 정보
-             *     hIndex            - (byte) 제어기 Index (ID)
+             *     hGroupID           - (byte) 제어기 GroupID (안방 또는 거실)
+             *     hIndex             - (byte) 제어기 Index (ID)
              *     hStatus              - (byte) 제어기 동작 상태
              *     hErrorStatus             - (byte) 에러 상태
              *
@@ -130,10 +132,10 @@ public class CurtainAPI extends WallPadDevAPI {
             if (bInstall) {
                 // Info
                 Device.info.bInstall = bInstall;
-
-                Device.crutain.setCurtainID(Byte.parseByte(retData[index++]));
-                Device.crutain.setCurtainStatus(Byte.parseByte(retData[index++]));
-                Device.crutain.setErrorStatus(Byte.parseByte(retData[index++]));
+                Device.curtain.setCurtainGroupID(Byte.parseByte(retData[index++]));
+                Device.curtain.setCurtainID(Byte.parseByte(retData[index++]));
+                Device.curtain.setCurtainStatus(Byte.parseByte(retData[index++]));
+                Device.curtain.setErrorStatus(Byte.parseByte(retData[index++]));
             }
             else {
                 Device.info.bInstall = false;

+ 2 - 2
WallPadDevService/src/main/java/com/artncore/wallpaddevservice/ServiceMain.java

@@ -2006,8 +2006,8 @@ public class ServiceMain extends Service {
 					"<driver name = \"SensorAP_Controller\"						module =\"Ctrl_Module\"         		startaddr = \"0xB1\"    endaddr = \"0xB3\"    option = \"null\"  />"+
 					"<driver name = \"InRoomDetectSensor_Controller\"		module =\"Ctrl_Module\"         	 	startaddr = \"0xB7\"    endaddr = \"0xBE\"    option = \"null\"  />"+
 					"<driver name = \"Louver_Controller\"  						module =\"Ctrl_Module\"         	 	startaddr = \"0x91\"    endaddr = \"0x91\"    option = \"null\"  />"+
-					"<driver name = \"Curtain_LivingRoom_Driver\"  						module =\"Ctrl_Module\"         	 	startaddr = \"0x80\"    endaddr = \"0x8F\"    option = \"null\"  />"+
-					"<driver name = \"Curtain_Room_Driver\"  						module =\"Ctrl_Module\"         	 	startaddr = \"0x90\"    endaddr = \"0x9F\"    option = \"null\"  />"+
+					"<driver name = \"Curtain_LivingRoom_Driver\"  						module =\"Ctrl_Module\"         	 	startaddr = \"0x81\"    endaddr = \"0x8F\"    option = \"null\"  />"+
+					"<driver name = \"Curtain_Room_Driver\"  						module =\"Ctrl_Module\"         	 	startaddr = \"0x91\"    endaddr = \"0x9F\"    option = \"null\"  />"+
 
 					// COM3 - SmartSwitch_Module
 					"<driver name = \"SmartSwitchPol_Controller\"     			module =\"SmartSwitch_Module\"        startaddr = \"0xC1\"    endaddr = \"0xC1\"    option = \"null\"  />"+

+ 28 - 24
WallPadDevService/src/main/java/com/artncore/wallpaddevservice/driver/CurtainV1_Controller.java

@@ -36,7 +36,7 @@ public class CurtainV1_Controller extends DeviceManager {
     private byte DEVICE_ADDRESS  = (byte) 0x80;
 
     /** 최대 기기 개수 1~F */
-    private final byte MAX_DEVICE_CNT = 16;
+    private final byte MAX_DEVICE_CNT = 15; //1~F
 
     /** 초기 기기 검색 횟수  */
     private final int MAX_SEARCH_COUNT   = 3;
@@ -186,10 +186,11 @@ public class CurtainV1_Controller extends DeviceManager {
             // 1. 디바이스 검색
             byte MaxDeviceID = 0;
             for (byte DeviceIdx = 0; DeviceIdx < MAX_DEVICE_CNT; DeviceIdx++) {
+                //1~F 실제 데이터 전송 시, 1을 더함
                 DataClasses.CurtainCtrl.Curtain curtain = sendGetUnitCurtainStatus(DEVICE_ADDRESS, DeviceIdx);
                 if (curtain != null) {
                     MaxDeviceID = (byte) (DeviceIdx+1);
-                    mDriver.Device[DeviceIdx].crutain = curtain;
+                    mDriver.Device[DeviceIdx].curtain = curtain;
                     mDriver.Device[DeviceIdx].info = new DataClasses.CurtainCtrl.Info();
                     mDriver.Device[DeviceIdx].info.bInstall = true;
                     Log.i(TAG, "SearchDevice     DeviceNum = " + (byte)(DeviceIdx+1) + "      OK!!!");
@@ -229,9 +230,9 @@ public class CurtainV1_Controller extends DeviceManager {
         /* [[ FirstTimeOut ]]
          * 초기 디바이스 검색하지못함. */
         else if (mDriver.Polling.Status == Driver.PollingList.STATUS.FirstTimeOut) {
-            DataClasses.CurtainCtrl.Curtain curtain = sendGetUnitCurtainStatus(mDriver.Polling.CurrentAddress, (byte) 0);
+            DataClasses.CurtainCtrl.Curtain curtain = sendGetUnitCurtainStatus(DEVICE_ADDRESS, mDriver.Polling.CurrentAddress);
             if (curtain != null) {
-                mDriver.Device[mDriver.Polling.CurrentAddress].crutain = curtain;
+                mDriver.Device[mDriver.Polling.CurrentAddress].curtain = curtain;
                 mDriver.Device[mDriver.Polling.CurrentAddress].info = new DataClasses.CurtainCtrl.Info();
                 mDriver.Device[mDriver.Polling.CurrentAddress].info.bInstall = true;
                 mDriver.Polling.SearchDeviceCount = (byte) (mDriver.Polling.CurrentAddress + 1);
@@ -284,7 +285,7 @@ public class CurtainV1_Controller extends DeviceManager {
             else {
                 DataClasses.CurtainCtrl.Curtain curtain = sendGetUnitCurtainStatus(DEVICE_ADDRESS, CurrentAddress);
                 if (curtain != null) {
-                    mDriver.Device[CurrentAddress].crutain = curtain;
+                    mDriver.Device[CurrentAddress].curtain = curtain;
                     mDriver.Device[CurrentAddress].info = new DataClasses.CurtainCtrl.Info();
                     mDriver.Device[CurrentAddress].info.bInstall = true;
                     AddDoCount(CurrentAddress, true);
@@ -380,11 +381,11 @@ public class CurtainV1_Controller extends DeviceManager {
                     }
 
                     // 2. Doing
-                    DataClasses.CurtainCtrl.Curtain circuit;
-                    circuit = sendGetUnitCurtainStatus(DEVICE_ADDRESS, Index);
+                    DataClasses.CurtainCtrl.Curtain curtain;
+                    curtain = sendGetUnitCurtainStatus(DEVICE_ADDRESS, Index);
 
-                    if (circuit != null) {
-                        updateVariables(Index, circuit, false);
+                    if (curtain != null) {
+                        updateVariables(Index, curtain, false);
                         SHMem.retVal = RefreshResult(Index);
                     }
                     else {
@@ -411,23 +412,23 @@ public class CurtainV1_Controller extends DeviceManager {
             else if (ctrDevFormat.CmdStr.equals("setUnitCurtainStatus")) {
                 try {
                     byte Index    = ctrDevFormat.param[0];
-                    byte hStatus = ctrDevFormat.param[1];
+                    byte hStatus  = ctrDevFormat.param[1];
 
                     // 1. 범위체크
                     //     1.1. Index
                     if (!DeviceIndexRangeCheck(Index)) {
-                        Log.w(TAG, "[do_ctrEmm -> setUnitCircuitClose] Param : Index - Out Of Range !!! (Index:" + Index + ")");
+                        Log.w(TAG, "[do_ctrEmm -> setUnitCurtainStatus] Param : Index - Out Of Range !!! (Index:" + Index + ")");
                         return SHMem.retVal = APIErrorCode.FAILSTR + ";" + APIErrorCode.INVALIDPARAMETER;
                     }
 
                     if (!mDriver.Device[Index].info.bInstall) {
-                        Log.w(TAG, "[do_ctrEmm -> setUnitCircuitClose] Device [" + Index + "]  No Install !!!");
+                        Log.w(TAG, "[do_ctrEmm -> setUnitCurtainStatus] Device [" + Index + "]  No Install !!!");
                         return SHMem.retVal = APIErrorCode.FAILSTR + ";" + APIErrorCode.DEVICEISNOTREADY;
                     }
 
                     // 3. Doing
                     DataClasses.CurtainCtrl.Curtain circuit;
-                    circuit = sendSetUnitCircuitStatus(Index, hStatus);
+                    circuit = sendSetUnitCurtainStatus(Index, hStatus);
 
                     if (circuit != null) {
                         updateVariables(Index, circuit, false);
@@ -506,7 +507,7 @@ public class CurtainV1_Controller extends DeviceManager {
             if (mDriver == null) return APIErrorCode.FAILSTR + ";" + APIErrorCode.DEVICEISNOTREADY;
             if (mDriver.Device == null) return APIErrorCode.FAILSTR + ";" + APIErrorCode.DEVICEISNOTREADY;
             if (mDriver.Device[Index].info == null) return APIErrorCode.FAILSTR + ";" + APIErrorCode.DEVICEISNOTREADY;
-            if (mDriver.Device[Index].crutain == null) return APIErrorCode.FAILSTR + ";" + APIErrorCode.DEVICEISNOTREADY;
+            if (mDriver.Device[Index].curtain == null) return APIErrorCode.FAILSTR + ";" + APIErrorCode.DEVICEISNOTREADY;
 
             /*
              * [Format]
@@ -530,9 +531,10 @@ public class CurtainV1_Controller extends DeviceManager {
             if (!Device.info.bInstall) return result;
 
             // 회로 정보
-            result += Device.crutain.getCurtainID() + ";";
-            result += Device.crutain.getCurtainStatus() + ";";
-            result += Device.crutain.getErrorStatus() + ";";
+            result += Device.curtain.getCurtainGroupID() + ";"; //그룹정보
+            result += Device.curtain.getCurtainID() + ";"; //아이디
+            result += Device.curtain.getCurtainStatus() + ";"; //상태
+            result += Device.curtain.getErrorStatus() + ";"; //에러
 
         } catch (RuntimeException re) {
             LogUtil.errorLogInfo("", TAG, re);
@@ -607,7 +609,7 @@ public class CurtainV1_Controller extends DeviceManager {
      * @param status - (byte) 요청할 회로 상태
      * @return (DataClasses.CurtainCtrl.Curtain) 기기상태 null - Error , Not null - OK
      */
-    private DataClasses.CurtainCtrl.Curtain sendSetUnitCircuitStatus(byte deviceIdx, byte status) {
+    private DataClasses.CurtainCtrl.Curtain sendSetUnitCurtainStatus(byte deviceIdx, byte status) {
         try {
             if ((deviceIdx < 0) || (deviceIdx >= MAX_DEVICE_CNT)) {
                 Log.w(TAG, "[sendSetUnitCircuitStatus] param [circuitId] Out of Range!!! " + deviceIdx);
@@ -703,9 +705,10 @@ public class CurtainV1_Controller extends DeviceManager {
             }
             // Data check OK!
 
-            index = 1;   // index 초기화
+            index = 1;   // index 초기화 (D1은 응답 성공만 체크
             DataClasses.CurtainCtrl.Curtain curtain = new DataClasses.CurtainCtrl.Curtain();
-            curtain.setCurtainGroupID(data);
+            curtain.setCurtainGroupID(GroupID);
+            curtain.setCurtainID(deviceIdx);
 
             //          - D2 : 제어기 제어 상태
             data = Reply[index++];
@@ -716,6 +719,7 @@ public class CurtainV1_Controller extends DeviceManager {
             data = Reply[index++];
             curtain.setGroupCount(data);
 
+            //          - D4 : reserve 데이터
             index++;
 
             //          - D5 : 제어기 이상 상태
@@ -773,11 +777,11 @@ public class CurtainV1_Controller extends DeviceManager {
         // 1. Param Range Check
         if (deviceIdx < 0) return false;
         if (deviceIdx >= mDriver.Polling.SearchDeviceCount) return false;
-        if (mDriver.Device[deviceIdx].crutain == null) return false;
+        if (mDriver.Device[deviceIdx].curtain == null) return false;
 
         // 2. Check
         boolean bChanged = false;
-        DataClasses.CurtainCtrl.Curtain OldCurtain = mDriver.Device[deviceIdx].crutain;
+        DataClasses.CurtainCtrl.Curtain OldCurtain = mDriver.Device[deviceIdx].curtain;
 
         while (true) {
 
@@ -792,11 +796,11 @@ public class CurtainV1_Controller extends DeviceManager {
         }
 
         if (bChanged || bNotify) {
-            mDriver.Device[deviceIdx].crutain = curtain;
+            mDriver.Device[deviceIdx].curtain = curtain;
             StatusChanged(deviceIdx);
 
             DeviceLog("updateVariables !!!! ***************************************");
-            DeviceLog(mDriver.Device[deviceIdx].crutain.ToDebugString(deviceIdx));
+            DeviceLog(mDriver.Device[deviceIdx].curtain.ToDebugString(deviceIdx));
             return true;
         }
         return false;