|
|
@@ -16,6 +16,8 @@ import com.artncore.commons.define;
|
|
|
import com.artncore.wallpadapi.LightAPI;
|
|
|
import com.artncore.wallpadapi.WallPadAPI;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
import kr.co.icontrols.wallpadhomectrl.MainActivity;
|
|
|
import kr.co.icontrols.wallpadhomectrl.R;
|
|
|
import kr.co.icontrols.wallpadhomectrl.declare.Common;
|
|
|
@@ -42,6 +44,7 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
|
|
|
private final boolean DEBUG_LOG_ON = true;
|
|
|
private void DebugLogOutput(String s) { if(DEBUG_LOG_ON) Log.d(TAG, s); }
|
|
|
+ private Context mContext;
|
|
|
|
|
|
// =================================================================================================
|
|
|
// [[ Declaration ]] region
|
|
|
@@ -124,10 +127,11 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* @param wpapi - 상속받은 WallPadAPI
|
|
|
* @param operationMode - 동작모드
|
|
|
*/
|
|
|
- public LightEtcLivMainScreen(Context context, RelativeLayout layout, WallPadAPI wpapi, int operationMode)
|
|
|
- {
|
|
|
+ public LightEtcLivMainScreen(Context context, RelativeLayout layout, WallPadAPI wpapi, int operationMode) {
|
|
|
super(context, layout);
|
|
|
Log.i(TAG, "[START - Screen] --------------------------------------------");
|
|
|
+ mContext = context;
|
|
|
+ init();
|
|
|
|
|
|
// 1. Data Create
|
|
|
DebugLogOutput("[Create] - Step1 : Data Create");
|
|
|
@@ -136,22 +140,18 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
|
|
|
// 2. Device API Load & Update
|
|
|
DebugLogOutput("[Create] - Step2 : Device API Load & Update");
|
|
|
- if(OPERATION_MODE == Common.MODE_NOMAL)
|
|
|
- {
|
|
|
+ if (OPERATION_MODE == Common.MODE_NOMAL) {
|
|
|
mWpapi = wpapi;
|
|
|
DebugLogOutput("OPERATION_MODE = MODE_NOMAL");
|
|
|
- if(Device_ApiLoad(wpapi) >= 0) Device_Update(false);
|
|
|
+ if (Device_ApiLoad(wpapi) >= 0) Device_Update(false);
|
|
|
}
|
|
|
- else if(OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
|
|
|
- {
|
|
|
+ else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
|
|
|
int LightCount = DB_GetLightCount();
|
|
|
- if(LightCount > 0) mData.Light.LightCount = LightCount;
|
|
|
+ if (LightCount > 0) mData.Light.LightCount = LightCount;
|
|
|
else mData.Light.LightCount = 6;
|
|
|
-
|
|
|
DebugLogOutput("OPERATION_MODE = MODE_BUSINESS_SAMPLE");
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
DebugLogOutput("OPERATION_MODE = Other (" + OPERATION_MODE + " ... Change Mode -> MODE_NOMAL");
|
|
|
OPERATION_MODE = Common.MODE_NOMAL;
|
|
|
}
|
|
|
@@ -165,56 +165,51 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
DebugLogOutput("[Create] - Step4 : Button Create");
|
|
|
|
|
|
int LightCount = mData.Light.LightCount;
|
|
|
- if((LightCount > 0) && (LightCount <= 8))
|
|
|
- {
|
|
|
+ if ((LightCount > 0) && (LightCount <= 8)) {
|
|
|
lightView = new LightView[LightCount];
|
|
|
|
|
|
int left = 0;
|
|
|
int top = 0;
|
|
|
- for(int i=0 ; i<mData.Light.LightCount ; i++)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ for (int i = 0; i < mData.Light.LightCount; i++) {
|
|
|
+ try {
|
|
|
left = Common.ImgPosion.GetX(mPos[LightCount-1][i][0]);
|
|
|
top = Common.ImgPosion.GetY(mPos[LightCount-1][i][1]);
|
|
|
lightView[i] = new LightView(left, top, i);
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, "[Exception Error] - [Create] LightView new");
|
|
|
e.printStackTrace();
|
|
|
lightView[i] = null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
Log.e(TAG, "LightCount Out of range!!! (" + LightCount + ")");
|
|
|
}
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
- if((mData.Light.LightCount > 0) && (mData.Light.LightCount <= 6))
|
|
|
- {
|
|
|
- BatchOff_Enable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_en_normal, R.drawable.control_multisw_batch_en_pressed, ID.lightEtcLivMain.button.BATCHOFF_ENABLE);
|
|
|
- ViewRegistration(layout, BatchOff_Enable, Common.ImgPosion.GetX(908), Common.ImgPosion.GetY(168));
|
|
|
- BatchOff_Enable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
- BatchOff_Disable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_dis_normal, R.drawable.control_multisw_batch_dis_pressed, ID.lightEtcLivMain.button.BATCHOFF_DISABLE);
|
|
|
- ViewRegistration(layout, BatchOff_Disable, Common.ImgPosion.GetX(908), Common.ImgPosion.GetY(440));
|
|
|
- BatchOff_Disable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
+ try {
|
|
|
+ if ((mData.Light.LightCount > 0) && (mData.Light.LightCount <= 6)) {
|
|
|
+ if (naAllLightOffEnable != null && naAllLightOffEnable[0] == WallpadDeviceSet.DO_USE) {
|
|
|
+ BatchOff_Enable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_en_normal, R.drawable.control_multisw_batch_en_pressed, ID.lightEtcLivMain.button.BATCHOFF_ENABLE);
|
|
|
+ ViewRegistration(layout, BatchOff_Enable, Common.ImgPosion.GetX(908), Common.ImgPosion.GetY(168));
|
|
|
+ BatchOff_Enable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
+
|
|
|
+ BatchOff_Disable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_dis_normal, R.drawable.control_multisw_batch_dis_pressed, ID.lightEtcLivMain.button.BATCHOFF_DISABLE);
|
|
|
+ ViewRegistration(layout, BatchOff_Disable, Common.ImgPosion.GetX(908), Common.ImgPosion.GetY(440));
|
|
|
+ BatchOff_Disable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
+ }
|
|
|
}
|
|
|
- else if((mData.Light.LightCount >= 7) && (mData.Light.LightCount <= 8))
|
|
|
- {
|
|
|
- BatchOff_Enable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_en_normal, R.drawable.control_multisw_batch_en_pressed, ID.lightEtcLivMain.button.BATCHOFF_ENABLE);
|
|
|
- ViewRegistration(layout, BatchOff_Enable, Common.ImgPosion.GetX(980), Common.ImgPosion.GetY(168));
|
|
|
- BatchOff_Enable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
- BatchOff_Disable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_dis_normal, R.drawable.control_multisw_batch_dis_pressed, ID.lightEtcLivMain.button.BATCHOFF_DISABLE);
|
|
|
- ViewRegistration(layout, BatchOff_Disable, Common.ImgPosion.GetX(980), Common.ImgPosion.GetY(440));
|
|
|
- BatchOff_Disable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
+ else if ((mData.Light.LightCount >= 7) && (mData.Light.LightCount <= 8)) {
|
|
|
+ if (naAllLightOffEnable != null && naAllLightOffEnable[0] == WallpadDeviceSet.DO_USE) {
|
|
|
+ BatchOff_Enable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_en_normal, R.drawable.control_multisw_batch_en_pressed, ID.lightEtcLivMain.button.BATCHOFF_ENABLE);
|
|
|
+ ViewRegistration(layout, BatchOff_Enable, Common.ImgPosion.GetX(980), Common.ImgPosion.GetY(168));
|
|
|
+ BatchOff_Enable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
+
|
|
|
+ BatchOff_Disable = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 272, R.drawable.control_multisw_batch_dis_normal, R.drawable.control_multisw_batch_dis_pressed, ID.lightEtcLivMain.button.BATCHOFF_DISABLE);
|
|
|
+ ViewRegistration(layout, BatchOff_Disable, Common.ImgPosion.GetX(980), Common.ImgPosion.GetY(440));
|
|
|
+ BatchOff_Disable.setTouchDelayMs(Common.BTN_DELAY_DEVCTRL);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch(Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
@@ -223,8 +218,7 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
Draw_Update();
|
|
|
|
|
|
|
|
|
- if(OPERATION_MODE == Common.MODE_NOMAL)
|
|
|
- {
|
|
|
+ if (OPERATION_MODE == Common.MODE_NOMAL) {
|
|
|
int BatchSwitchStatus = wpapi.GetBatchSwitchStatus();
|
|
|
//del KSJ
|
|
|
//switch(BatchSwitchStatus)
|
|
|
@@ -236,32 +230,46 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
|
|
|
Device_BrRegistration(true);
|
|
|
|
|
|
- if(MainActivity.getHideMenuOn())
|
|
|
- {
|
|
|
+ if (MainActivity.getHideMenuOn()) {
|
|
|
APIList mAPIList = new APIList();
|
|
|
mAPIList.Add(lightApi, 0, "거실조명");
|
|
|
|
|
|
transactionDisplay = new TransactionDisplay(mAPIList, (WpadScreen) this);
|
|
|
}
|
|
|
}
|
|
|
- else if(OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
|
|
|
- {
|
|
|
+ else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
|
|
|
Draw_AllLight(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ int[] naAllLightOffEnable = null; // 일괄소등
|
|
|
+ private void init() {
|
|
|
+ WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
|
|
|
+ try {
|
|
|
+ Log.i(TAG, "[init] START");
|
|
|
+ naAllLightOffEnable = mWallpadDeviceSet.Get_BatchSW_Info(); // 일괄소등
|
|
|
+ mWallpadDeviceSet.closeDB();
|
|
|
+ if (naAllLightOffEnable == null) Log.w(TAG, "[init] naAllLightOffEnable is null!!");
|
|
|
+ else Log.i(TAG, "[init] naAllLightOffEnable : " + Arrays.toString(naAllLightOffEnable));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 본 스크린 종료시 호출됨
|
|
|
*/
|
|
|
@Override
|
|
|
- protected void onClose()
|
|
|
- {
|
|
|
+ protected void onClose() {
|
|
|
super.onClose();
|
|
|
|
|
|
// 등록된 BR 을 해제 한다.
|
|
|
- if(lightApi != null) Device_BrRegistration(false);
|
|
|
+ if (lightApi != null) Device_BrRegistration(false);
|
|
|
|
|
|
- if(MainActivity.getHideMenuOn()) { if(transactionDisplay != null) transactionDisplay.Close(); }
|
|
|
+ if (MainActivity.getHideMenuOn()) {
|
|
|
+ if (transactionDisplay != null) transactionDisplay.Close();
|
|
|
+ }
|
|
|
|
|
|
Log.i(TAG, "[END - Screen] ********************************************");
|
|
|
}
|
|
|
@@ -274,31 +282,28 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* 부모 Activity 에서 BroadcastReceiver 을 수신받을시 호출됨
|
|
|
*/
|
|
|
@Override
|
|
|
- protected void onBrReceive(Intent intent)
|
|
|
- {
|
|
|
+ protected void onBrReceive(Intent intent) {
|
|
|
super.onBrReceive(intent);
|
|
|
|
|
|
String ActionName = intent.getAction();
|
|
|
|
|
|
DebugLogOutput("[[[[ onBrReceive ]]]] ActionName = " + ActionName);
|
|
|
|
|
|
- if(ActionName.equals(ID.lightEtcLivMain.BR_LIGHT))
|
|
|
- {
|
|
|
+ if (ActionName.equals(ID.lightEtcLivMain.BR_LIGHT)) {
|
|
|
DebugLogOutput("onBrReceive - BR_LIGHT");
|
|
|
Device_Update(false);
|
|
|
Draw_Update();
|
|
|
}
|
|
|
- else if(ActionName.equals(define.NOTIFY_ACNAME))
|
|
|
- {
|
|
|
+ else if (ActionName.equals(define.NOTIFY_ACNAME)) {
|
|
|
int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
|
|
|
DebugLogOutput("Receive Notify BR "+ define.NOTIFY_ACNAME + " : " + kind);
|
|
|
|
|
|
- switch (kind)
|
|
|
- {
|
|
|
+ switch (kind) {
|
|
|
case define.NOTIFY_ALL_LIGHT_OFF:
|
|
|
// 일괄소등 설정 (조명 OFF)
|
|
|
Draw_AllLight(false);
|
|
|
break;
|
|
|
+
|
|
|
case define.NOTIFY_ALL_LIGHT_ON:
|
|
|
// 일괄소등 해제 (조명 ON)
|
|
|
Draw_AllLight(true);
|
|
|
@@ -315,67 +320,56 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* 본 클래스에서 등록한 [WpadImageView] [WpadTextView] 의 TouchEvent 가 있을시 호출됨
|
|
|
*/
|
|
|
@Override
|
|
|
- protected void onTouchEvent(View v, MotionEvent event)
|
|
|
- {
|
|
|
+ protected void onTouchEvent(View v, MotionEvent event) {
|
|
|
super.onTouchEvent(v, event);
|
|
|
|
|
|
int TargetId = v.getId();
|
|
|
int MoveEvent = event.getAction();
|
|
|
|
|
|
- if(MoveEvent == MotionEvent.ACTION_UP)
|
|
|
- {
|
|
|
- if( (TargetId >= ID.lightEtcLivMain.button.LIGHT_1) && (TargetId <= ID.lightEtcLivMain.button.LIGHT_8) )
|
|
|
- {
|
|
|
+ if (MoveEvent == MotionEvent.ACTION_UP) {
|
|
|
+ if ((TargetId >= ID.lightEtcLivMain.button.LIGHT_1) && (TargetId <= ID.lightEtcLivMain.button.LIGHT_8)) {
|
|
|
// 개별 조명 제어
|
|
|
int index = TargetId - ID.lightEtcLivMain.button.LIGHT_1;
|
|
|
DebugLogOutput("onTouchEvent [LIGHT_" + (index + 1) + "] BUTTON !!!");
|
|
|
|
|
|
boolean OnOff;
|
|
|
- if(mData.Light.OnOff[index]) OnOff = false;
|
|
|
+ if (mData.Light.OnOff[index]) OnOff = false;
|
|
|
else OnOff = true;
|
|
|
- if(OPERATION_MODE == Common.MODE_NOMAL)
|
|
|
- {
|
|
|
+ if (OPERATION_MODE == Common.MODE_NOMAL) {
|
|
|
int ret = Device_LightOnOff( (byte)(index + 1), OnOff);
|
|
|
- if(ret >= 0) Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
+ if (ret >= 0) Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
else Sound().Play(SND.effect.TOUCH_UNLATCHED);
|
|
|
}
|
|
|
- else if(OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
|
|
|
- {
|
|
|
+ else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
|
|
|
Sample_LightOnOff( index + 1, OnOff);
|
|
|
Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
}
|
|
|
}
|
|
|
- else if(TargetId == ID.lightEtcLivMain.button.BATCHOFF_ENABLE)
|
|
|
- {
|
|
|
+ else if (TargetId == ID.lightEtcLivMain.button.BATCHOFF_ENABLE) {
|
|
|
// 일괄소등 실행
|
|
|
DebugLogOutput("onTouchEvent [BATCHOFF_ENABLE] BUTTON !!!");
|
|
|
|
|
|
- if(OPERATION_MODE == Common.MODE_NOMAL)
|
|
|
- {
|
|
|
+ if (OPERATION_MODE == Common.MODE_NOMAL) {
|
|
|
int ret = Device_AllLightOnOff(false);
|
|
|
- if(ret >= 0) Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
+ if (ret >= 0) Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
else Sound().Play(SND.effect.TOUCH_UNLATCHED);
|
|
|
}
|
|
|
- else if(OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
|
|
|
- {
|
|
|
+ else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
|
|
|
Sample_LightOnOff(0, false);
|
|
|
Draw_AllLight(false);
|
|
|
Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
}
|
|
|
}
|
|
|
- else if(TargetId == ID.lightEtcLivMain.button.BATCHOFF_DISABLE)
|
|
|
- {
|
|
|
+ else if (TargetId == ID.lightEtcLivMain.button.BATCHOFF_DISABLE) {
|
|
|
// 일괄소등 해제
|
|
|
DebugLogOutput("onTouchEvent [BATCHOFF_DISABLE] BUTTON !!!");
|
|
|
|
|
|
- if(OPERATION_MODE == Common.MODE_NOMAL)
|
|
|
- {
|
|
|
+ if (OPERATION_MODE == Common.MODE_NOMAL) {
|
|
|
int ret = Device_AllLightOnOff(true);
|
|
|
if(ret >= 0) Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
else Sound().Play(SND.effect.TOUCH_UNLATCHED);
|
|
|
}
|
|
|
- else if(OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
|
|
|
- {
|
|
|
+ else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
|
|
|
Draw_AllLight(true);
|
|
|
Sound().Play(SND.effect.TOUCH_LATCHED);
|
|
|
}
|
|
|
@@ -390,15 +384,13 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
/**
|
|
|
* 변경되는 이미지를 다시 그린다.
|
|
|
*/
|
|
|
- private void Draw_Update()
|
|
|
- {
|
|
|
- if(mData == null) return;
|
|
|
- if(mData.Light.OnOff == null) return;
|
|
|
+ private void Draw_Update() {
|
|
|
+ if (mData == null) return;
|
|
|
+ if (mData.Light.OnOff == null) return;
|
|
|
|
|
|
- for(int i=0 ; i<mData.Light.LightCount ; i++)
|
|
|
- {
|
|
|
- if(mData.Light.OnOff[i]) Draw_LightStatusChange(i+1, true);
|
|
|
- else Draw_LightStatusChange(i+1, false);
|
|
|
+ for (int i = 0; i < mData.Light.LightCount; i++) {
|
|
|
+ if (mData.Light.OnOff[i]) Draw_LightStatusChange(i+1, true);
|
|
|
+ else Draw_LightStatusChange(i+1, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -407,29 +399,26 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
*
|
|
|
* @param OnOff - (boolean) 변경할 상태 (true:일괄소등해제 , false:일괄소등)
|
|
|
*/
|
|
|
- private void Draw_AllLight(boolean OnOff)
|
|
|
- {
|
|
|
- if(OnOff)
|
|
|
- {
|
|
|
+ private void Draw_AllLight(boolean OnOff) {
|
|
|
+ if (OnOff) {
|
|
|
///////////////////////////////
|
|
|
// 일괄소등 해제
|
|
|
///////////////////////////////
|
|
|
// 일괄소등 버튼 - 활성화
|
|
|
// 일괄소등 해제 버튼 - 비활성화
|
|
|
|
|
|
- BatchOff_Enable.setButtonEventOffDisable();
|
|
|
- BatchOff_Disable.setButtonEventOffEnable(R.drawable.control_multisw_batch_dis_disable);
|
|
|
+ if (BatchOff_Enable != null) BatchOff_Enable.setButtonEventOffDisable();
|
|
|
+ if (BatchOff_Disable != null) BatchOff_Disable.setButtonEventOffEnable(R.drawable.control_multisw_batch_dis_disable);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
///////////////////////////////
|
|
|
// 일괄소등
|
|
|
///////////////////////////////
|
|
|
// 일괄소등 버튼 - 활성화
|
|
|
// 일괄소등 해제 버튼 - 비활성화
|
|
|
|
|
|
- BatchOff_Enable.setButtonEventOffEnable(R.drawable.control_multisw_batch_en_disable);
|
|
|
- BatchOff_Disable.setButtonEventOffDisable();
|
|
|
+ if (BatchOff_Enable != null) BatchOff_Enable.setButtonEventOffEnable(R.drawable.control_multisw_batch_en_disable);
|
|
|
+ if (BatchOff_Disable != null) BatchOff_Disable.setButtonEventOffDisable();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -439,21 +428,18 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* @param LightNumber - 변경할 조명 번호 (1~8 각조명 [조명개수를 초과할 경우 변경되지않는다])
|
|
|
* @param OnOff - true : ON / false : OFF
|
|
|
*/
|
|
|
- private void Draw_LightStatusChange(int LightNumber, boolean OnOff)
|
|
|
- {
|
|
|
- if(LightNumber < 0) return;
|
|
|
- if(lightView == null) return;
|
|
|
- if(LightNumber > lightView.length) return;
|
|
|
+ private void Draw_LightStatusChange(int LightNumber, boolean OnOff) {
|
|
|
+ if (LightNumber < 0) return;
|
|
|
+ if (lightView == null) return;
|
|
|
+ if (LightNumber > lightView.length) return;
|
|
|
|
|
|
int index = LightNumber - 1;
|
|
|
- if(lightView[index] == null) return;
|
|
|
- if(OnOff)
|
|
|
- {
|
|
|
+ if (lightView[index] == null) return;
|
|
|
+ if (OnOff) {
|
|
|
//lightView[index].BgBtn.setButtonPressedImageID();
|
|
|
lightView[index].OnOffBtn.setButtonRearImage();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
//lightView[index].BgBtn.setButtonDefaultImageID();
|
|
|
lightView[index].OnOffBtn.setButtonFrontImage();
|
|
|
}
|
|
|
@@ -469,16 +455,14 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* @param wpapi - 생성시 전달받은 WallPadAPI
|
|
|
* @return (int) - >=0 : 성공, <0 : 실패
|
|
|
*/
|
|
|
- private int Device_ApiLoad(WallPadAPI wpapi)
|
|
|
- {
|
|
|
+ private int Device_ApiLoad(WallPadAPI wpapi) {
|
|
|
// 1. Mode Check
|
|
|
- if(OPERATION_MODE != Common.MODE_NOMAL) return -1;
|
|
|
+ if (OPERATION_MODE != Common.MODE_NOMAL) return -1;
|
|
|
|
|
|
DebugLogOutput("[Device_ApiLoad] - Start");
|
|
|
|
|
|
// 2. wpapi Check
|
|
|
- if(wpapi == null)
|
|
|
- {
|
|
|
+ if (wpapi == null) {
|
|
|
Log.e(TAG, "[Device_ApiLoad] - wpapi is null");
|
|
|
return -2;
|
|
|
}
|
|
|
@@ -489,19 +473,16 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
|
|
|
// 3. Load API (Light)
|
|
|
DebugLogOutput("[Device_ApiLoad] - Step1 : Light API Load...");
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
lightApi = wpapi.Get_LightController();
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch(Exception e) {
|
|
|
Log.e(TAG, "[Device_ApiLoad] - [Exception Error] wpapi.Get_LightController");
|
|
|
Log.e(TAG, "[Device_ApiLoad] - " + e.toString());
|
|
|
e.printStackTrace();
|
|
|
return -100;
|
|
|
}
|
|
|
- if(lightApi == null)
|
|
|
- {
|
|
|
+
|
|
|
+ if (lightApi == null) {
|
|
|
Log.e(TAG, "[Device_ApiLoad] - lightApi is null");
|
|
|
return -4;
|
|
|
}
|
|
|
@@ -516,29 +497,23 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
*
|
|
|
* @return (int) - >=0 : 성공, <0 : 실패
|
|
|
*/
|
|
|
- private int Device_BrRegistration(boolean OnOff)
|
|
|
- {
|
|
|
+ private int Device_BrRegistration(boolean OnOff) {
|
|
|
DebugLogOutput("[Device_BrRegistration] - Start (OnOff:" + OnOff + ")");
|
|
|
|
|
|
String BR_NAME = ID.lightEtcLivMain.BR_LIGHT;
|
|
|
|
|
|
// 1. Api Load Check
|
|
|
- if(lightApi == null)
|
|
|
- {
|
|
|
+ if (lightApi == null) {
|
|
|
Log.e(TAG, "[Device_BrRegistration] - lightApi unload !!!");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- if(OnOff)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ if (OnOff) {
|
|
|
+ try {
|
|
|
//DebugLogOutput("[Device_BrRegistration] - regChangedBR START");
|
|
|
lightApi.regChangedBR(BR_NAME);
|
|
|
//DebugLogOutput("[Device_BrRegistration] - regChangedBR END");
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, "[Device_BrRegistration] - [Exception Error] lightApi.regChangedBR");
|
|
|
Log.e(TAG, "[Device_BrRegistration] - " + e.toString());
|
|
|
e.printStackTrace();
|
|
|
@@ -548,16 +523,12 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
|
|
|
super.addBrActionFilter(define.NOTIFY_ACNAME);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ else {
|
|
|
+ try {
|
|
|
//DebugLogOutput("[Device_BrRegistration] - unregChangedBR START");
|
|
|
lightApi.unregChangedBR(BR_NAME);
|
|
|
//DebugLogOutput("[Device_BrRegistration] - unregChangedBR END");
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, "[Device_BrRegistration] - [Exception Error] lightApi.unregChangedBR");
|
|
|
Log.e(TAG, "[Device_BrRegistration] - " + e.toString());
|
|
|
e.printStackTrace();
|
|
|
@@ -578,29 +549,23 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
*
|
|
|
* @return (int) - >=0 : 성공, <0 : 실패
|
|
|
*/
|
|
|
- private int Device_Update(boolean real)
|
|
|
- {
|
|
|
+ private int Device_Update(boolean real) {
|
|
|
DebugLogOutput("[Device_Update] - Start (real : " + real + ")");
|
|
|
|
|
|
// 1. Api Load Check
|
|
|
- if(lightApi == null)
|
|
|
- {
|
|
|
+ if (lightApi == null) {
|
|
|
Log.e(TAG, "[Device_Update] lightApi unload !!!");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
// 2. Refresh
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
int ret = lightApi.Refresh(real);
|
|
|
- if(ret < 0)
|
|
|
- {
|
|
|
+ if (ret < 0) {
|
|
|
Log.e(TAG, "[Device_Update] Refresh(" + real + ") ret (" + ret + ") ErrorCode = " + lightApi.ErrorCode.ErrStr());
|
|
|
return -2;
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch(Exception e) {
|
|
|
Log.e(TAG, "[Device_Update] - [Exception Error] lightApi.Refresh(" + real + ")");
|
|
|
e.printStackTrace();
|
|
|
return -100;
|
|
|
@@ -625,37 +590,29 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
*
|
|
|
* @return (int) - >=0 : 성공, <0 : 실패
|
|
|
*/
|
|
|
- private int Device_LightOnOff(byte LightNumber, boolean OnOff)
|
|
|
- {
|
|
|
+ private int Device_LightOnOff(byte LightNumber, boolean OnOff) {
|
|
|
DebugLogOutput("[Device_LightOnOff] - Start (LightNumber : " + LightNumber + " / OnOff : " + OnOff + ")");
|
|
|
|
|
|
// 1. Api Load Check
|
|
|
- if(lightApi == null)
|
|
|
- {
|
|
|
+ if (lightApi == null) {
|
|
|
Log.e(TAG, "[Device_LightOnOff] lightApi unload !!!");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
// 2. Param Range Check
|
|
|
- if( (LightNumber > mData.Light.LightCount) &&
|
|
|
- (LightNumber != (byte)define.DEVICE_ALL_OR_NOTHING) )
|
|
|
- {
|
|
|
+ if ((LightNumber > mData.Light.LightCount) && (LightNumber != (byte)define.DEVICE_ALL_OR_NOTHING)) {
|
|
|
Log.w(TAG, "[Device_LightOnOff] Param Out Of Range (LightNumber:" + LightNumber + " , " + "LightCount:" + mData.Light.LightCount + ")");
|
|
|
return -2;
|
|
|
}
|
|
|
|
|
|
// 4. Light Control
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
int ret = lightApi.SetLightOnOff(LightNumber, OnOff);
|
|
|
- if(ret < 0)
|
|
|
- {
|
|
|
+ if (ret < 0) {
|
|
|
Log.e(TAG, "[Device_LightOnOff] SetLightOnOff Error (" + ret + ") ErrorCode = " + lightApi.ErrorCode.ErrStr());
|
|
|
return -6;
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch(Exception e) {
|
|
|
Log.e(TAG, "[Device_LightOnOff] - [Exception Error] lightApi.SetLightOnOff()");
|
|
|
e.printStackTrace();
|
|
|
return -100;
|
|
|
@@ -672,29 +629,23 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* @param OnOff - true : ON / false : OFF
|
|
|
* @return (int) - >=0 : 성공, <0 : 실패
|
|
|
*/
|
|
|
- private int Device_AllLightOnOff(boolean OnOff)
|
|
|
- {
|
|
|
+ private int Device_AllLightOnOff(boolean OnOff) {
|
|
|
DebugLogOutput("[Device_AllLightOnOff] - Start (OnOff : " + OnOff + ")");
|
|
|
|
|
|
// 1. Api Load Check
|
|
|
- if(mWpapi == null)
|
|
|
- {
|
|
|
+ if (mWpapi == null) {
|
|
|
Log.e(TAG, "[Device_AllLightOnOff] mWpapi unload !!!");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
// 2. Light Control
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
int ret = mWpapi.SetBatchSwitchStatus(OnOff);
|
|
|
- if(ret < 0)
|
|
|
- {
|
|
|
+ if (ret < 0) {
|
|
|
Log.e(TAG, "[Device_AllLightOnOff] SetBatchSwitchStatus Error (" + ret + ")");
|
|
|
return -6;
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, "[Device_AllLightOnOff] - [Exception Error] mWpapi.SetBatchSwitchStatus(" + OnOff + ")");
|
|
|
e.printStackTrace();
|
|
|
return -100;
|
|
|
@@ -715,17 +666,14 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
* @param LightNumber - 제어할 조명 번호 (1~8 각조명 [조명개수를 초과할 경우 제어되지않는다] , 0 전체조명
|
|
|
* @param OnOff - true - ON / false - OFF
|
|
|
*/
|
|
|
- private void Sample_LightOnOff(int LightNumber, boolean OnOff)
|
|
|
- {
|
|
|
- if(LightNumber != 0)
|
|
|
- {
|
|
|
+ private void Sample_LightOnOff(int LightNumber, boolean OnOff) {
|
|
|
+ if (LightNumber != 0) {
|
|
|
int index = LightNumber - 1;
|
|
|
mData.Light.OnOff[index] = OnOff;
|
|
|
Draw_LightStatusChange(LightNumber, OnOff);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- for(int i=0 ; i<mData.Light.LightCount ; i++) mData.Light.OnOff[i] = OnOff;
|
|
|
+ else {
|
|
|
+ for (int i = 0; i < mData.Light.LightCount; i++) mData.Light.OnOff[i] = OnOff;
|
|
|
|
|
|
Draw_Update();
|
|
|
}
|
|
|
@@ -740,29 +688,24 @@ public class LightEtcLivMainScreen extends WpadScreen
|
|
|
*
|
|
|
* @return (int) - >=0 : 성공, <0 : 실패
|
|
|
*/
|
|
|
- private int DB_GetLightCount()
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ private int DB_GetLightCount() {
|
|
|
+ try {
|
|
|
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getContext());
|
|
|
int [] Get_Light_info = wallpadDeviceSet.Get_Light_info();
|
|
|
wallpadDeviceSet.closeDB();
|
|
|
- if(Get_Light_info == null)
|
|
|
- {
|
|
|
+ if (Get_Light_info == null) {
|
|
|
Log.w(TAG, "[DB_GetLightCount] Get_Light_info return value is null !!!");
|
|
|
return -1;
|
|
|
}
|
|
|
- if(Get_Light_info.length < 3)
|
|
|
- {
|
|
|
+
|
|
|
+ if (Get_Light_info.length < 3) {
|
|
|
Log.w(TAG, "[DB_GetLightCount] Get_Light_info return Length 3 under !!! (len:" + Get_Light_info.length + ")");
|
|
|
return -2;
|
|
|
}
|
|
|
int LightCount = Get_Light_info[2];
|
|
|
|
|
|
return LightCount;
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, "[DB_GetLightCount] Exception Error");
|
|
|
e.printStackTrace();
|
|
|
return -100;
|