package kr.co.icontrols.wallpadenergyctrl; import java.util.ArrayList; import com.artncore.WallPadDataMgr.WallpadDeviceSet; import com.artncore.WallPadDataMgr.WallpadStatusData; import com.artncore.WallPadDataMgr.wallpaddbmgr; import com.artncore.commons.API_Menu; import com.artncore.commons.API_Menu.MenuListDataClass; import com.artncore.commons.API_Menu.MenuListDataClass.ChildIDMapping; import com.artncore.commons.define; import com.artncore.wallpadapi.WallPadAPI; import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Color; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.WindowManager; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.TranslateAnimation; import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnGroupClickListener; import android.widget.ExpandableListView.OnGroupCollapseListener; import android.widget.ExpandableListView.OnGroupExpandListener; import android.widget.Button; import android.widget.RelativeLayout; import kr.co.icontrols.wallpadenergyctrl.declare.Common; import kr.co.icontrols.wallpadenergyctrl.declare.ID; import kr.co.icontrols.wallpadenergyctrl.screen.*; import kr.co.icontrols.wallpadenergyctrl.screen.ienergy.EachRoomEnergyDetailScreen; import kr.co.icontrols.wallpadenergyctrl.screen.ienergy.EachRoomEnergyMainScreen; import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartConcentScreen; import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartDisPanelScreen; import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartDisPanelScreen_01; import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartDisPanelScreen_02; import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartLightScreen; import kr.co.icontrols.wallpadsupport.Version; import kr.co.icontrols.wallpadsupport.WpadActivity; import kr.co.icontrols.wallpadsupport.WpadImageView; import kr.co.icontrols.wallpadsupport.WpadScale; import kr.co.icontrols.wallpadsupport.WpadTextView; import kr.co.icontrols.wallpadsupport.WpadUtil; import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND; import kr.co.icontrols.wallpadsupport.WpadSound.SND; import com.util.LogUtil; /** * @description * 월패드 [에너지관리] 메인화면 이다.
* 상단의 Top 메뉴, [홈] [돌아가기]
* 좌측의 Tab 메뉴, [원격검침] [IEnergy] [실시간검침] ... 등 선택 메뉴
* 를 여기서 처리한다. */ public class MainActivity extends WpadActivity { private final static String TAG = "MainActivity"; private final boolean DEBUG_LOG_ON = true; private void DebugLogOutput(String s) { if(DEBUG_LOG_ON) Log.d(TAG, s); } // ================================================================================================= // [[ Declaration ]] region // ================================================================================================= protected Context mContext = null; public Context getContext() { return mContext; } private WallPadAPI wpapi = null; private WallpadStatusData wdb = null; private int OPERATION_MODE = Common.MODE; // Layout private RelativeLayout AllLayout; // 화면 전체 private RelativeLayout TopLayout; // 상단 메뉴 private RelativeLayout ScreenLayout; // 메인 화면 private RelativeLayout MenuLayout; // 메뉴 화면 // Top Menu private WpadImageView TopBackground; private WpadTextView TopTitle; private WpadImageView TopHomeBtn,TopBackBtn, TopMenuBtn, TopSetTargetBtn; private WpadImageView Hide1Btn, Hide2Btn; private TextButton EnergyResetBtn; private WpadTextView SampleModeTitle; private WpadImageView BackBtn_SmartDist; private WpadImageView TopManualBtn; // Tab Menu /* private int [][] TabBgDrawIdArray = new int [][] { { R.drawable.sub_menu_bgr_normal_1, R.drawable.sub_menu_bgr_pressed }, { R.drawable.sub_menu_bgr_normal_2, R.drawable.sub_menu_bgr_pressed }, { R.drawable.sub_menu_bgr_normal_3, R.drawable.sub_menu_bgr_pressed }, { R.drawable.sub_menu_bgr_normal_4, R.drawable.sub_menu_bgr_pressed }, { R.drawable.sub_menu_bgr_normal_5, R.drawable.sub_menu_bgr_pressed }, { R.drawable.sub_menu_bgr_normal_6, R.drawable.sub_menu_bgr_pressed }, { R.drawable.sub_menu_bgr_normal_7, R.drawable.sub_menu_bgr_pressed }, }; private WpadImageView TabBtn1, TabBtn2, TabBtn3, TabBtn4, TabBtn5, TabBtn6, TabBtn7; private WpadImageView [] TabBtn_Array = new WpadImageView [] {TabBtn1, TabBtn2, TabBtn3, TabBtn4, TabBtn5, TabBtn6, TabBtn7};*/ // Main private WpadImageView ScreenBackground; // Menu private WpadImageView MenuBackground; private WpadImageView MenuClose; private WpadTextView MenuTitle; private static ExpandableListView mListView; private Menu_AdptMain adptMain; private MenuListDataClass menueListDataClass; private boolean MenuOpen = false; // PopupActivityRun private static boolean PopupActivityRun = false; public static boolean getPopupActivityRun() { return PopupActivityRun; } public static void setPopupActivityRun(boolean run) { PopupActivityRun = run; } // Menu & TabData private Menu mMenu = null; // private TabData mTabData = null; // CurrentScreenId private int mCurrentScreenId = -1; private int mTempCurrentScreenId = -1; public static int mCurrentManualScreenId = -1; // HideMenu private int mHideMenuEntryStatus = 0; private static boolean mHideMenuOn = false; public static boolean getHideMenuOn() { return mHideMenuOn; } private CountDownTimer mHideMenuTimer = null; // TextButton private class TextButton { public WpadImageView Bg; // 배경 public WpadTextView Text; // 글씨 public TextButton(RelativeLayout layout, boolean UseButton, int bgcolor, int w, int h, int id, int textcolor, int textsize, boolean textbold, int left, int top) { int TouchKind = TOUCH_KIND.NONE; if(UseButton) TouchKind = TOUCH_KIND.BUTTON_M; Bg = new WpadImageView(getContext(), TouchKind, w, h, 0, 0, id); Bg.setBackgroundColor(bgcolor); ViewRegistration(layout, Bg, left, top); Text = new WpadTextView(getContext(), false, w, h, Gravity.CENTER, textcolor, textsize, textbold, 0); ViewRegistration(layout, Text, left, top); } public void setText(String str) { if(Text != null) Text.setText(str); } public void setVisibility(int visibility) { Bg.setVisibility(visibility); Text.setVisibility(visibility); } } // Screen private RemoteMeterMainScreen remoteMeterMainScreen = null; //원격검침 private IcEnergyMgrScreen icEnergyMgrScreen = null ;//HEMS //private RealTimeMeterMainScreen realTimeMeterMainScreen = null; //실시간검침 private RemoteMeterCostTableScreen remoteMeterCostTableScreen = null; //요금테이블 private EachRoomEnergyMainScreen eachRoomEnergyMainScreen; // I'Energy Main Screen (간편보기) -> 신규 사용안함.. private EachRoomEnergyDetailScreen eachRoomEnergyDetailScreen; // I'Energy 상세보기 -> 신규 기본화면 private SmartDisPanelScreen smartDisPanelScreen; private SmartDisPanelScreen_01 smartDisPanelScreen_01; // 신규 화면 (통합전력제어기: 전력측정(VE버전)) private SmartDisPanelScreen_02 smartDisPanelScreen_02; // 신규 화면 (통합전력제어기: 직결) private SmartConcentScreen smartConcentScreen; private SmartLightScreen smartLightScreen; // 명칭 관련 public static final int HEATING = 1; public static final int LIGHT = 2; private String [] mRoomNameList = null; //조명 방 명칭 private String[] mRoomNameList_Light = null; //조명 방 명칭 private String[] mRoomNameList_Heating = null; //난방 방 명칭 private String [] mDefaultRoomNameList = new String []{ "거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"}; //난방 조명 방 명칭 분리 사용시 디폴트 값 private String [] mDefaultRoomNameList_Light = new String [] { "거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"}; public WallpadStatusData GetDBObj() { return wdb; } // ================================================================================================= // [[ Activity Life Cycle ]] region // ================================================================================================= /** * Activity Constructors */ @Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "-------------------------------------------------------------"); Log.i(TAG, "------------------ [START - MainActivity] -------------------"); Log.i(TAG, "-------------------------------------------------------------"); super.onCreate(savedInstanceState); // @ AutoScale 설정 WpadScale.setAutoScale(true); super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>"); // 1. 변수 초기화 DebugLogOutput("[Create] - Step1 : Data Create"); PopupActivityRun = false; mContext = this; mHideMenuOn = false; // 2. 자동 종료 셋팅 DebugLogOutput("[Create] - Step2 : Auto Finish Setting"); // 2-1. 자동종료 타이머 셋팅 if (Common.MODE == Common.MODE_PRODUCTION) { // LCD 항상 켜져 있게 하는 기능 추가 // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); // pm.userActivity(2, true); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { if (Common.FINISH_TIME_ENABLE) super.setFinishTimerCreate(Common.FINISH_TIME_SEC); // 주석 해제해야 정상임 } // 3. API 호출 DebugLogOutput("[Create] - Step3 : API Call"); if (Common.GetDeviceSampleMode(this)) OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE; else OPERATION_MODE = Common.MODE_NOMAL; // 3.1. wpapi 생성 if (OPERATION_MODE == Common.MODE_NOMAL) { Log.d(TAG, "OperationMode = MODE_NOMAL"); try { wpapi = new WallPadAPI(this); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) { Log.d(TAG, "OperationMode = MODE_BUSINESS_SAMPLE"); } try { wdb = new WallpadStatusData(this); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[ExceptionError] - onCreate->WallpadStatusData Create : " + e); } getIntegratedPowerCtrllerType(); GetRoomName(); // 4. Layout registration DebugLogOutput("[Create] - Step4 : Layout registration"); // 4-1. mainLayout AllLayout = new RelativeLayout(this); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels()); AllLayout.setLayoutParams(params); AllLayout.setId(ID.main.layout.ALL); super.setAllLayoutRegistration(AllLayout); // 4-2. TopLayout TopLayout = new RelativeLayout(this); WpadUtil.LayoutRegistration(AllLayout, TopLayout, 1280, 110, 0, 0, ID.main.layout.TOP); // 4-4. ScreenLayout ScreenLayout = new RelativeLayout(this); WpadUtil.LayoutRegistration(AllLayout, ScreenLayout, 1280, 690, 0, 110, ID.main.layout.SCREEN); if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) { SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.WHITE, Common.fontsize._26_DEFAULT, true, 0); ViewRegistration(TopLayout, SampleModeTitle, 133, 15); SampleModeTitle.setText("[영업샘플모드]"); } else if (Common.MODE == Common.MODE_PRODUCTION) { SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.WHITE, Common.fontsize._26_DEFAULT, true, 0); ViewRegistration(TopLayout, SampleModeTitle, 316, 0); SampleModeTitle.setText("[생산 검수 모드]"); EnergyResetBtn = new TextButton(TopLayout, true, Color.WHITE, 200, 72, ID.main.button.ENERGY_RESET, Color.BLACK, Common.fontsize._32_POPUP_TITLE, true, 316+200+100, 0); EnergyResetBtn.setText("RESET"); EnergyResetBtn.setVisibility(View.INVISIBLE); } ScreenBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, R.drawable.bg_body, ID.main.image.SCREEN_BACKGROUND); ViewRegistration(ScreenLayout, ScreenBackground, 0, 0); // 5. Top Menu - ImageView registration DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration"); TopBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 110, R.drawable.bg_topbar, R.drawable.bg_topbar, ID.main.image.TOP_BACKGROUND); ViewRegistration(TopLayout, TopBackground, 0, 0); TopTitle = new WpadTextView(this, false, 247+50, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE); ViewRegistration(TopLayout, TopTitle, 133, 15); TopHomeBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_home_normal, R.drawable.topbar_icon_home_pressed, ID.main.button.HOME); ViewRegistration(TopLayout, TopHomeBtn, 1145, 0); TopBackBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.main.button.BACK); ViewRegistration(TopLayout, TopBackBtn, 1019, 0); setTopBackBtnVisible(false); TopManualBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_manual_normal, R.drawable.topbar_icon_manual_pressed, ID.main.button.MANUAL); setManualBtnVisible(getManualUse(), 1019); BackBtn_SmartDist = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.main.button.BACK_SMARTDIST); ViewRegistration(TopLayout, BackBtn_SmartDist, 1020, 0); setBackBtnSmartDistVisible(false); TopMenuBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_menu_normal, R.drawable.topbar_icon_menu_pressed, ID.main.button.MENU); ViewRegistration(TopLayout, TopMenuBtn, 0, 0); // Hide1Btn = new WpadImageView(this, TOUCH_KIND.BUTTON_M, 70, 61, 0, 0, ID.main.button.HIDE1); // ViewRegistration(TopLayout, Hide1Btn, 0, 0); // Hide2Btn = new WpadImageView(this, TOUCH_KIND.BUTTON_M, 70, 61, 0, 0, ID.main.button.HIDE2); // ViewRegistration(TopLayout, Hide2Btn, 1024-70, 0); // 6. Menu Loading // 6-1. 메뉴 정보를 가져온다 (DB에서 가져온다) wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext()); //test WallpadDBMGR.DeleteMenuList(); ArrayList> mGroupList = null; ArrayList mChildList = null; mGroupList = new ArrayList>(); //b. 에너지관리 mChildList = new ArrayList(); mChildList.add(API_Menu.SubMenuEnergy.EnergyMgr); mChildList.add(API_Menu.SubMenuEnergy.RemoteMeter); mChildList.add(API_Menu.SubMenuEnergy.EachRoomEnergy); //mChildList.add(API_Menu.SubMenuEnergy.CostTable); mGroupList.add(mChildList); WallpadDBMGR.SetMenuList(mGroupList); menueListDataClass = WallpadDBMGR.GetMenuList(); WallpadDBMGR.closeDB(); if (menueListDataClass == null) { Log.e(TAG, "menueListDataClass == null, Load Default List"); menueListDataClass = LoadDefaultMenuList(); } //WallPadMain에서 MenuList를 넣어주지 않아 아래 테스트 코드를 넣음 menueListDataClass = LoadDefaultMenuList(); // 6-2. 시작 화면을 main APP으로 부터 받아서 처리한다. mMenu = new Menu(); mMenu = super.getIntentParsingMenu(getIntent()); if(mMenu == null) { //setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false); Log.i(TAG, "mMenu = null"); if (OPERATION_MODE == Common.MODE_NOMAL) { mTempCurrentScreenId =API_Menu.SubMenuEnergy.RemoteMeter; //SetTitleText(mTempCurrentScreenId); mWallPadApiCheckHandler.sendEmptyMessage(0); } else { setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false); } } else { /*boolean result = setChangeScreen(mMenu.getStartId(), false); if(result == false) { setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false); }*/ Log.i(TAG, "mMenu != null"); if (OPERATION_MODE == Common.MODE_NOMAL) { mTempCurrentScreenId = mMenu.getStartId(); //setTitleName(mTempCurrentScreenId); mWallPadApiCheckHandler.sendEmptyMessage(0); } else { boolean result = setChangeScreen(mMenu.getStartId(), false); if (result == false) { setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false); } } } // 7. Draw DebugLogOutput("[Create] - Step7 : setContentView"); setContentView(AllLayout); // 8. Window ReSize DebugLogOutput("[Create] - Step8 : Window ReSize"); //super.WindowReSize(Common.SCREEN_SIZE_MAIN_W, Common.SCREEN_SIZE_MAIN_H, false); // 9. BR Receiver 등록(메뉴에서 다른 화면이 눌린 경우 BR처리) reg_Receiver(); /*WallpadDeviceSet wd = new WallpadDeviceSet(getContext()); if(wd.Get_SmartDistribution_Info() == 1) { Log.i(TAG, "스마트분전반 사용설정 ON"); } else { Log.i(TAG, "스마트분전반 사용설정 OFF"); }*/ Log.i(TAG, "End onCreate -------------------------------------------------"); } /* * * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며,
* WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에,
* 본 딜레이 코드를 임시로 적용한다.*/ @SuppressLint("HandlerLeak") protected Handler mWallPadApiCheckHandler = new Handler() { @SuppressLint("HandlerLeak") @Override public void handleMessage(Message msg) { if(msg.what == 0) { if(wpapi != null) { if(wpapi.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10); else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10); } } else if(msg.what == 1) { setChangeScreen(mTempCurrentScreenId, false); } } }; /** * onDestroy */ @Override protected void onDestroy() { if(Common.MODE == Common.MODE_PRODUCTION) { // LCD 를 Normal 상태로 변경하는 기능 추가 // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); // pm.userActivity(1, true); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } setChangeScreen(mCurrentScreenId, true); if(wdb != null) wdb.closeDB(); this.unregisterReceiver(mWallPadAlertBR); this.unregisterReceiver(mWallPadJogBR); if(getManualUse()) { FinishManualActivity(); } super.setFinishTimerDestroy(); super.onDestroy(); Log.i(TAG, "*************************************************************"); Log.i(TAG, "****************** [END - MainActivity] *******************"); Log.i(TAG, "*************************************************************"); } /** * onResume */ @Override protected void onResume() { super.onResume(); if(wpapi != null) wpapi.Resume(); DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@"); } /** * onPause */ @Override protected void onPause() { super.onPause(); if(wpapi != null) wpapi.Pause(); DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@"); } /* ================================================================================================ * [BroadcastReceiver] Section ================================================================================================ */ /** * BroadcastReceiver.onReceive for [WpadActivity] */ @Override protected void onBrReceive(Intent intent) { super.onBrReceive(intent); DebugLogOutput("Receive BR " + intent.getAction()); } /* ================================================================================================ * [Touch & Key Event] Section ================================================================================================ */ /** * TouchEvent for [WpadActivity] */ @Override protected void onTouchEvent(View v, MotionEvent event) { super.onTouchEvent(v, event); int TargetId = v.getId(); int MoveEvent = event.getAction(); //DebugLogOutput("onTouch - " + "id : " + v.getId() + " / Action : " + event.getAction()); if(MoveEvent == MotionEvent.ACTION_UP) { if(TargetId == ID.main.button.HOME) { DebugLogOutput("onTouchEvent [HOME] BUTTON !!!"); Sound().Play(SND.effect.TOUCH_LATCHED); Intent intent = new Intent(); intent.putExtra("Finish_Kind", "HomeButton"); setResult(RESULT_OK, intent); finish(); } else if(TargetId == ID.main.button.BACK_SMARTDIST) { DebugLogOutput("onTouchEvent [BACK_SMARTDIST] BUTTON !!!"); Sound().Play(SND.effect.TOUCH_LATCHED); setBackBtnSmartDistVisible(false); setChangeScreen(API_Menu.SubMenuEnergy.SmartPanel, false); } else if(TargetId == ID.main.button.BACK) { DebugLogOutput("onTouchEvent [BACK] BUTTON !!!"); Sound().Play(SND.effect.TOUCH_LATCHED); /** *[수정필요]Back Button 필요한 화면은 아래 부분 추가 후 사용 필요 * **/ /* if(mCurrentScreenId == API_Menu.SubMenuConfig.SmartKey) { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); } */ } else if(TargetId == ID.main.button.MENU) { DebugLogOutput("onTouchEvent [MENU] BUTTON !!!"); if(MenuOpen == true) { return; } Sound().Play(SND.effect.TOUCH_LATCHED); OpenMenuLayout(); } else if (TargetId == ID.main.button.MENUCLOSE) { if(MenuOpen == true) { Sound().Play(SND.effect.TOUCH_LATCHED); CloseMenuLayout(); } } else if(TargetId == ID.main.button.ENERGY_RESET) { DebugLogOutput("onTouchEvent [ENERGY_RESET] BUTTON !!!"); try { if(wpapi != null && wpapi.Get_IGW200dController()!=null) { int ret = wpapi.Get_IGW200dController().EnergyReset(); if(ret >= 0) { Sound().Play(SND.effect.EFFECT1); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[ExceptionError] - onTouchEvent->ENERGY_RESET wpapi.Get_IGW200dController().EnergyReset()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } else if (TargetId == ID.main.button.MANUAL) { Log.i(TAG, "onTouchEvent [MANUAL] BUTTON [mCurrentScreenId = " + mCurrentScreenId + "]"); Sound().Play(SND.effect.TOUCH_LATCHED); try { if(mCurrentScreenId == API_Menu.SubMenuEnergy.RemoteMeter) { StartManual(ID.MANUAL.MANUAL_RemoteMeter); } else if(mCurrentScreenId == API_Menu.SubMenuEnergy.EnergyMgr) { StartManual(ID.MANUAL.MANUAL_HEMS); } else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartPanel) { StartManual(ID.MANUAL.MANUAL_SmartDist); } else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartLight) { StartManual(ID.MANUAL.MANUAL_SmartLight); } else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartOutlet) { StartManual(ID.MANUAL.MANUAL_SmartConcent); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception ex) { //ex.printStackTrace(); LogUtil.errorLogInfo("", TAG, ex); } } } } /** * H/W Key Event */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction()); return super.onKeyDown(keyCode, event); } /* ================================================================================================ * [TOP - Back] Section ================================================================================================ */ /** * TOP 돌아가기 버튼 활성화 & 비활성화 * * @param Enabled - true : 활성화, false : 비활성화 * @return (boolean) true : 성공, false : 실패 */ public boolean setTopBackBtnVisible(boolean Enabled) { if(Enabled == true) { if(TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE); TopBackBtn.bringToFront(); } else { if(TopBackBtn.getVisibility() != View.INVISIBLE) TopBackBtn.setVisibility(View.INVISIBLE); } return true; } /** * 스마트분전반 돌아가기 버튼 활성화 & 비활성화 * * @param Enabled - true : 활성화, false : 비활성화 * @return (boolean) true : 성공, false : 실패 */ public boolean setBackBtnSmartDistVisible(boolean Enabled) { if(Enabled == true) { if(BackBtn_SmartDist.getVisibility() != View.VISIBLE) BackBtn_SmartDist.setVisibility(View.VISIBLE); BackBtn_SmartDist.bringToFront(); if(TopManualBtn.getVisibility() == View.VISIBLE) { WpadUtil.ViewMove(TopManualBtn, 893, 0); } } else { if(BackBtn_SmartDist.getVisibility() != View.INVISIBLE) BackBtn_SmartDist.setVisibility(View.INVISIBLE); if(TopManualBtn.getVisibility() == View.VISIBLE) { WpadUtil.ViewMove(TopManualBtn, 1019, 0); } } return true; } /** * TOP 에 목표량설정 아이콘 활성화 & 비활성화 * * @param Enabled - true : 활성화, false : 비활성화 * @return (boolean) true : 성공, false : 실패 */ public boolean setTopSetTargetBtnVisible(boolean Enabled) { if(Enabled == true) { if(TopSetTargetBtn.getVisibility() != View.VISIBLE) { WpadUtil.ViewMove(TopSetTargetBtn, 93, 132); if(TopSetTargetBtn!=null) TopSetTargetBtn.setVisibility(View.VISIBLE); } if(TopSetTargetBtn!=null) TopSetTargetBtn.bringToFront(); } else { if(TopSetTargetBtn.getVisibility() != View.INVISIBLE && TopSetTargetBtn!=null) TopSetTargetBtn.setVisibility(View.INVISIBLE); } return true; } /** * TOP 에너지미터 리셋 버튼 활성화 & 비활성화 * * @param Enabled - true : 활성화, false : 비활성화 */ public void setTopEnergyResetBtnVisible(boolean Enabled) { if(Enabled == true) EnergyResetBtn.setVisibility(View.VISIBLE); else EnergyResetBtn.setVisibility(View.INVISIBLE); } /* ================================================================================================ * [Manual Activity] Section ================================================================================================ */ public static ManualActivity mManualActivity; public void setManualBtnVisible(boolean bEnable, int marginLeft) { try { Log.d(TAG, "[setManualBtnVisible] bEnable [" + bEnable + "], marginLeft [" + marginLeft + "]"); if (bEnable) TopManualBtn.setVisibility(View.VISIBLE); else TopManualBtn.setVisibility(View.INVISIBLE); ViewRegistration(TopLayout, TopManualBtn, marginLeft, 0); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setManualBtnVisible(boolean bEnable)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 매뉴얼 버튼 사용 유무 * @return boolean 타입 - true: 사용, false: 미사용 */ public boolean getManualUse() { try { WallpadDeviceSet devSet = new WallpadDeviceSet(mContext); String[] DBinfo = devSet.GetSettingData("매뉴얼"); devSet.closeDB(); if (DBinfo != null) { if (DBinfo[1].indexOf("사용함") > 0) { Log.d(TAG, "[getManualUse] Use Manual"); return true; } else { // 미사용 Log.d(TAG, "[getManualUse] Not Use Manual [1]"); return false; } } else { // 미사용 Log.d(TAG, "[getManualUse] Not Use Manual [2]"); return false; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception ex) { Log.e(TAG, "[getManualUse] - Exception !!!"); //ex.printStackTrace(); LogUtil.errorLogInfo("", TAG, ex); } return false; } // ManualActivityRun private static boolean ManualActivityRun = false; public static boolean getManualActivityRun() { Log.d(TAG, "[getManualActivityRun] ManualActivityRun: " + ManualActivityRun); return ManualActivityRun; } public static void setManualActivityRun(boolean run) { ManualActivityRun = run; if (!ManualActivityRun) resetCurrentManualScreenID(); } public boolean StartManual(int screenId) { Log.d(TAG, "[StartManual] ScreenId [" + screenId + "], mCurrentManualScreenId [" + mCurrentManualScreenId + "]"); if (getManualActivityRun()) { mCurrentManualScreenId = screenId; try { boolean ret = mManualActivity.ChangeScreen(screenId); Log.d(TAG, "[StartManual] - ret : " + ret); return ret; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return false; } catch (Exception ex) { //ex.printStackTrace(); LogUtil.errorLogInfo("", TAG, ex); return false; } } else { try { if (mCurrentManualScreenId == screenId) return false; mCurrentManualScreenId = screenId; setManualActivityRun(true); Intent intent = new Intent(mContext, ManualActivity.class); intent.putExtra("ScreenId", screenId); if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartLight) { intent.putExtra("SmartLightInfo", smartLightScreen.nAllEMCnt); } else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartOutlet) { if(smartConcentScreen.concentRooms != null) { intent.putExtra("SmartConcentInfo", smartConcentScreen.concentRooms.length); } } overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return false; } catch (Exception exc) { //exc.printStackTrace(); LogUtil.errorLogInfo("", TAG, exc); return false; } } } public static void resetCurrentManualScreenID() { try { mCurrentManualScreenId = -1; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] resetCurrentManualScreenID()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public static void FinishManualActivity() { Log.i(TAG, "[FinishManualActivity]"); try { if (mManualActivity != null) { mCurrentManualScreenId = -1; mManualActivity.finish(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] FinishManualActivity()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /* ================================================================================================ * [Popup Activity] Section ================================================================================================ */ /** * Popup Activity 를 시작시킨다. * * @param ScreenId - 팝업시작시 Screen ID * @return (boolean) true : 성공, false : 실패 */ public boolean StartPopup(int ScreenId) { if(getPopupActivityRun() == true) { return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId); } else { setPopupActivityRun(true); Intent intent = new Intent(mContext, PopupActivity.class); intent.putExtra("ScreenId", ScreenId); overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } /** * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다) * * @param ScreenId - 팝업시작시 Screen ID * @param data - 전달할 데이터 * @return (boolean) true : 성공, false : 실패 */ public boolean StartPopup(int ScreenId, Intent data) { if(getPopupActivityRun() == true) { return false; } else { setPopupActivityRun(true); Intent intent = new Intent(mContext, PopupActivity.class); intent.putExtra("ScreenId", ScreenId); intent.putExtra("PopupScreenDataIntent", data); overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } /** * Activity Result Reception */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@"); if(resultCode == RESULT_OK) { try { // PopupActivity 에서 FinishTimer 로 인하여 종료가 되었을 경우 // MainActivity 도 즉시 종료시킨다. String code = (String) data.getExtras().get("Finish_Kind"); Log.d(TAG, "Finish_Kind : " + code); if(code.equals("FinishTimer") == true) { Log.d(TAG, "FinishTimer finish"); finish(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception Error] [onActivityResult] - data.getExtras().get"); } } } /* ================================================================================================ * [Screen] Section ================================================================================================ */ /** * Screen 에서 Screen 변경을 요청할 경우 호출된다.
* Override 사용하여 Screen 변경을 처리한다.
* * @param nScreenId - 변경할 Screen ID * @return (boolean) true : 성공, false : 실패 */ @Override protected boolean onChangeScreen(int nScreenId) { super.onChangeScreen(nScreenId); return setChangeScreen(nScreenId, false); } /** * Screen 등록자
* ScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다. * * @param nScreenId - 변경할 Screen ID * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용) * @return (boolean) true : 성공, false : 실패 */ private boolean setChangeScreen(int nScreenId, boolean OnlyRemove) { DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove); // 1. 현재 Layout 삭제 if(mCurrentScreenId > 0) { ScreenLayout.removeAllViews(); super.setCurrentScreen(null); } if(OnlyRemove) return true; mCurrentScreenId = nScreenId; setTopBackBtnVisible(false); // 2. 새로운 Layout 표시 try { switch(nScreenId) { /** * [수정필요] * Back Button 필요한 화면은 setTopBackBtnVisible(true) 호출 필요 * 추가 또는 수정해야할 부분 1. - 스크린 별 layout 생성 * **/ case API_Menu.SubMenuEnergy.RemoteMeter: SetTitleText(API_Menu.SubMenuEnergy.Name_RemoteMeter); remoteMeterMainScreen = new RemoteMeterMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(remoteMeterMainScreen); break; case API_Menu.SubMenuEnergy.EnergyMgr: SetTitleText(API_Menu.SubMenuEnergy.Name_EnergyMgr); icEnergyMgrScreen= new IcEnergyMgrScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(icEnergyMgrScreen); break; case API_Menu.SubMenuEnergy.CostTable: SetTitleText(API_Menu.SubMenuEnergy.Name_CostTable); remoteMeterCostTableScreen= new RemoteMeterCostTableScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(remoteMeterCostTableScreen); break; case API_Menu.SubMenuEnergy.EachRoomEnergy: SetTitleText(API_Menu.SubMenuEnergy.Name_EachRoomEnergy); eachRoomEnergyDetailScreen = new EachRoomEnergyDetailScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList); super.setCurrentScreen(eachRoomEnergyDetailScreen); break; case API_Menu.SubMenuEnergy.SmartPanel: if (nIntegratedPowerCtrller == WallpadDeviceSet.POWERCONTROLLER_TYPE_DEFAULT) { SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution); smartDisPanelScreen = new SmartDisPanelScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(smartDisPanelScreen); } else if (nIntegratedPowerCtrller == WallpadDeviceSet.POWERCONTROLLER_TYPE_MEASURE) { SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution); smartDisPanelScreen_01 = new SmartDisPanelScreen_01(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(smartDisPanelScreen_01); } else if (nIntegratedPowerCtrller == WallpadDeviceSet.POWERCONTROLLER_TYPE_DIRECT) { SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution); smartDisPanelScreen_02 = new SmartDisPanelScreen_02(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(smartDisPanelScreen_02); } else { // 설정값이 없는 경우에는 기본화면을 출력한다. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution); smartDisPanelScreen = new SmartDisPanelScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(smartDisPanelScreen); Log.w(TAG, "[setChangeScreen] API_Menu.SubMenuEnergy.SmartPanel -> Not supported type : nIntegratedPowerCtrller -> " + nIntegratedPowerCtrller); } break; case API_Menu.SubMenuEnergy.SmartOutlet: SetTitleText(API_Menu.SubMenuEnergy.Name_SmartConcent); smartConcentScreen = new SmartConcentScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light, false); super.setCurrentScreen(smartConcentScreen); break; case API_Menu.SubMenuEnergy.SmartLight: SetTitleText(API_Menu.SubMenuEnergy.Name_SmartLight); smartLightScreen = new SmartLightScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light, false); super.setCurrentScreen(smartLightScreen); break; default: Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")"); mCurrentScreenId = -1; return false; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return false; } catch (Exception e) { Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return false; } return true; } /** * 상단 타이틀 텍스트 수정 * @param SetText 수정할 타이틀 이름 * **/ private void SetTitleText(String SetText) { if(SetText != null) { TopTitle.setText(SetText); } } /* ================================================================================================ * [Menu Layout] Section ================================================================================================ */ /** * 메뉴 레이아웃 생성 * **/ private void OpenMenuLayout() { if(MenuOpen == true) { Log.d(TAG, "MenuOpen == true"); return; } if(menueListDataClass == null) { Log.d(TAG, "menueListDataClass = null"); return; } //0. 현재 ID 및 리스트 불러오기 String Title = API_Menu.GetGroupNameByID((mCurrentScreenId / 1000) * 1000); //Log.i(TAG, "[OpenMenuLayout] - API_Menu title = " + Title); String TempChildName = null; int ChooseGroup = 0; int ChooseChild = 0; for(int i =0; i< menueListDataClass.arrayGroup.size(); i++) { if(menueListDataClass.arrayGroup.get(i).equals(Title)) { //Log.i(TAG, "arrayGroup[" + i + "] = " + menueListDataClass.arrayGroup.get(i)); ChooseGroup = i; break; } } //Log.i(TAG, "[OpenMenuLayout] - ChooseGroup = " + ChooseGroup); //Log.i(TAG, "mCurrentScreenId = " + mCurrentScreenId); for(int i = 0; i< menueListDataClass.idMappingTable.length; i++) { //Log.i(TAG, "[OpenMenuLayout] - menueListDataClass.idMappingTable[i].Id = " + menueListDataClass.idMappingTable[i].Id); if (menueListDataClass.idMappingTable[i].Id == mCurrentScreenId) { TempChildName = menueListDataClass.idMappingTable[i].Name; //Log.i(TAG, "[OpenMenuLayout] - Same ChildName = " + TempChildName); break; } } if(TempChildName == null) { Log.i(TAG, "[OpenMenuLayout] - TempChildName == null"); return; } //Log.i(TAG, "[OpenMenuLayout] - TempChildName = " + TempChildName); try { for(int i = 0; i< menueListDataClass.arrayChild.get(Title).size(); i++) { if(menueListDataClass.arrayChild.get(Title).get(i).equals(TempChildName) == true) { ChooseChild = i; break; } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } //Log.i(TAG, "[OpenMenuLayout] - ChooseChild = " + ChooseChild); //1. 기존 화면 투명도 변경 TopLayout.setAlpha(0.5f); ScreenLayout.setAlpha(0.5f); //2. Layout 생성 및 처리 이벤트 등록 MenuLayout = new RelativeLayout(this); WpadUtil.LayoutRegistration(AllLayout, MenuLayout, 1280, 800, 0, 0, ID.main.layout.MENU); MenuLayout.setOnTouchListener(new Button.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { setFinishTimerReset(); CloseMenuLayout(); } return true; } }); //3. 배경 이미지 생성 및 에니메이션 등록 MenuBackground = new WpadImageView(this, TOUCH_KIND.BUTTON, 460, 800, R.drawable.bg_menu, R.drawable.bg_menu, ID.main.image.TAB_BACKGROUND); TranslateAnimation anim = new TranslateAnimation(WpadScale.getWidth(-460), 0, 0, 0); anim.setDuration(200); anim.setInterpolator(new AccelerateInterpolator()); MenuLayout.setAnimation(anim); ViewRegistration(MenuLayout, MenuBackground, 0, 0); //4. 타이틀 등록 MenuTitle = new WpadTextView(this, false, 247, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE); ViewRegistration(MenuLayout, MenuTitle, 133, 15); MenuTitle.setText(Title); //5. 종료 버튼 등록 MenuClose = new WpadImageView(this, TOUCH_KIND.BUTTON, 80, 80, R.drawable.topbar_icon_close_normal, R.drawable.topbar_icon_close_pressed, ID.main.button.MENUCLOSE); MenuClose.setTouchDelayMs(1000); ViewRegistration(MenuLayout, MenuClose, 380, 15); //6. 리스트뷰 초기화 및 등록 mListView = new ExpandableListView(this); ExpandableListView.LayoutParams params = new ExpandableListView.LayoutParams(WpadScale.getWidth(460), WpadScale.getHeight(690)); mListView.setLayoutParams(params); mListView.setX(WpadScale.getWidth(0)); mListView.setY(WpadScale.getHeight(112)); mListView.setBackgroundColor(Color.BLACK); mListView.setId(ID.main.liveview.lv); mListView.setGroupIndicator(null); mListView.setDividerHeight(0); mListView.setDivider(null); mListView.setFocusable(true); mListView.setSmoothScrollbarEnabled(true); mListView.setTranscriptMode(android.widget.AbsListView.TRANSCRIPT_MODE_DISABLED); mListView.setScrollbarFadingEnabled(true); MenuLayout.addView(mListView); adptMain = new Menu_AdptMain(this, menueListDataClass.arrayGroup, menueListDataClass.arrayChild, ChooseGroup, ChooseChild); mListView.setAdapter(adptMain); //7. 선택된 그룹 열기 mListView.setSelectedGroup(ChooseGroup); mListView.expandGroup(ChooseGroup); // 8. 리스트뷰 터치 이벤트 등록 mListView.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { if((event.getAction() == MotionEvent.ACTION_DOWN) || (event.getAction() == MotionEvent.ACTION_UP)) { WpadActivity.setFinishTimerReset(); } return false; }}); // 9. 그룹 터치 이벤트 등록 mListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { DebugLogOutput("group click = " + groupPosition); WpadActivity.setFinishTimerReset(); return false; } }); // 10. 차일드 터치 이벤트 등록 /* mListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { DebugLogOutput("onChildClick"); DebugLogOutput("groupPosition = " + groupPosition); DebugLogOutput("childPosition = " + childPosition); WpadActivity.setFinishTimerReset(); return false; } }); */ // 11. 그룹 열리는 경우 이벤트 mListView.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { DebugLogOutput("groupPosition Open Event = " + groupPosition); Sound().Play(SND.effect.TOUCH_LATCHED); WpadActivity.setFinishTimerReset(); } }); // 12. 그룹 닫히는 경우 이벤트 mListView.setOnGroupCollapseListener(new OnGroupCollapseListener() { @Override public void onGroupCollapse(int groupPosition) { DebugLogOutput("groupPosition Close Event = " + groupPosition); Sound().Play(SND.effect.TOUCH_LATCHED); WpadActivity.setFinishTimerReset(); } }); // 13. MenuOpen True 설정 MenuOpen = true; } /** * 메뉴 layout 닫힘 처리 * **/ private void CloseMenuLayout() { if(MenuOpen == false) { return; } TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0); anim.setDuration(200); anim.setInterpolator(new AccelerateInterpolator()); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { MenuOpen = false; } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { AllLayout.removeView(MenuLayout); TopLayout.setAlpha(1.0f); ScreenLayout.setAlpha(1.0f); } }); MenuLayout.startAnimation(anim); } /** * 메뉴 그룹 터치시 처리 (Menu_AdptMain에서 호출) * **/ public static void SetListViewGroupExpand_Collapse(int GroupID, boolean ExpandEnable) { if(ExpandEnable == true) { mListView.expandGroup(GroupID); } else { mListView.collapseGroup(GroupID); } } /** * Menu정보가 DB에 없을 경우 불러올 스크린 로딩 * @return MenuListDataClass 타입의 초기정보 * **/ private MenuListDataClass LoadDefaultMenuList() { MenuListDataClass Temp_menueListDataClass = new MenuListDataClass(); Temp_menueListDataClass.SetArrayGroup(API_Menu.SubMenuEnergy.Name); ArrayList arrayList = new ArrayList(); int ChildCount = 0; WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext()); int[] realUse = devset.Get_RealTimeMetor_Info(); boolean remoteMeterUse = devset.Get_RemoteMeter_Use(); int nDistributionPanelType = devset.Get_DistributionPannelType_Info(); devset.closeDB(); //[수정필요] //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작) if(remoteMeterUse == true) { Log.i(TAG, "[LoadDefaultMenuList] - RemoteMeter Screen ADD ~~~"); arrayList.add(API_Menu.SubMenuEnergy.Name_RemoteMeter); ChildCount++; if(Version.getModelType() != Version.MODEL_TYPE.IHN_1010GL_I_2443ALT) { arrayList.add(API_Menu.SubMenuEnergy.Name_EnergyMgr); ChildCount++; } } /*if(realUse[0] == 1) { Log.i(TAG, "[LoadDefaultMenuList] - EnergyValue Screen ADD ~~~"); arrayList.add(API_Menu.SubMenuEnergy.Name_EnergyMgr); ChildCount++; }*/ //arrayList.add(API_Menu.SubMenuEnergy.Name_CostTable); ChildCount++; //arrayList.add(API_Menu.SubMenuEnergy.Name_EachRoomEnergy); ChildCount++; //if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101) if(nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) { arrayList.add(API_Menu.SubMenuEnergy.Name_SmartDistribution); ChildCount++; arrayList.add(API_Menu.SubMenuEnergy.Name_SmartConcent); ChildCount++; arrayList.add(API_Menu.SubMenuEnergy.Name_SmartLight); ChildCount++; } Log.i(TAG, "[LoadDefaultMenuList] - ChildCount : " + ChildCount); //Log.i(TAG, "[LoadDefaultMenuList] - childCount = " + ChildCount); //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝) Temp_menueListDataClass.SetArrayChild(API_Menu.SubMenuEnergy.Name, arrayList); Temp_menueListDataClass.idMappingTable = new ChildIDMapping[ChildCount]; for (int i = 0; i < ChildCount; i++) { Temp_menueListDataClass.idMappingTable[i] = new ChildIDMapping(); //[수정필요] //추가 또는 수정해야할 부분 2. - 불러올 스크린의 ID를 임의로 입력(시작) if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_RemoteMeter) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.RemoteMeter; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_RemoteMeter; } else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_EnergyMgr) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.EnergyMgr; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_EnergyMgr; } else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_CostTable) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.CostTable; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_CostTable; } else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_EachRoomEnergy) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.EachRoomEnergy; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_EachRoomEnergy; } else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_SmartDistribution) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.SmartPanel; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_SmartDistribution; } else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_SmartConcent) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.SmartOutlet; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_SmartConcent; } else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_SmartLight) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.SmartLight; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_SmartLight; } //Log.i(TAG, "[LoadDefaultMenuList] - idMappingTable.id[" + i + "] = " + Temp_menueListDataClass.idMappingTable[i].Id); //Log.i(TAG, "[LoadDefaultMenuList] - idMappingTable.Name[" + i + "] = " + Temp_menueListDataClass.idMappingTable[i].Name); } return Temp_menueListDataClass; } /** * DB 에서 룸이름 정보를 가져온다. * * @return (String []) null - 실패, not null */ private String[] getRoomNamefromDB() { try { WallpadStatusData wallpadStatusData = new WallpadStatusData(getContext().getApplicationContext()); String[] RoomNameList = wallpadStatusData.GetDevRoomName(); wallpadStatusData.closeDB(); if (RoomNameList == null) { Log.e(TAG, "[getRoomNamefromDB] - RoomNameList is null !!!"); return null; } if (RoomNameList.length != 6) { Log.e(TAG, "[getRoomNamefromDB] - RoomNameList.length Not Match (" + RoomNameList.length + ")"); return null; } if (DEBUG_LOG_ON) { for (int i = 0; i < RoomNameList.length; i++) DebugLogOutput("[getRoomNamefromDB] RoomNameList[" + i + "] = " + RoomNameList[i]); } //{ "거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"}; //RoomNameList += {"방5", "방6", "방7", "방8"}; String[] retRoomNameList = new String[10]; for (int i = 0; i < retRoomNameList.length; i++) { if (i < 6) { if (i < 1) retRoomNameList[i] = RoomNameList[i]; else if (i == 1) retRoomNameList[i] = "주방"; // 난방 기준의 방명칭 설정을 조명/콘센트에 적용시에는 두번째에 주방을 추가한다. 이는 추후 방명칭 입력단계부터 개선해야 함 else retRoomNameList[i] = RoomNameList[i - 1]; } else { retRoomNameList[i] = mDefaultRoomNameList[i]; } } for (int i = 0; i < retRoomNameList.length; i++) DebugLogOutput("[getRoomNamefromDB] retRoomNameList[" + i + "] = " + retRoomNameList[i]); return retRoomNameList; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getRoomNamefromDB()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return null; } /** * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기 * * @param Device - int * @return (String []) null - 실패, not null */ private String[] getRoomNamefromDB(int Device) { try { String[] RoomNameList = null; WallpadStatusData wallpadStatusData = new WallpadStatusData(getContext().getApplicationContext()); if (Device == HEATING) { RoomNameList = wallpadStatusData.GetDevRoomName("heating"); } else { RoomNameList = wallpadStatusData.GetDevRoomName("light"); } wallpadStatusData.closeDB(); if (RoomNameList == null) { Log.e(TAG, "[DB_GetRoomName] - RoomNameList is null !!!"); return null; } if (RoomNameList.length != 6) { Log.e(TAG, "[DB_GetRoomName] - RoomNameList.length Not Match (" + RoomNameList.length + ")"); return null; } if (DEBUG_LOG_ON) { for (int i = 0; i < RoomNameList.length; i++) DebugLogOutput("RoomNameList[" + i + "] " + RoomNameList[i]); } return RoomNameList; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[DB_GetRoomName] [ExceptionError] : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return null; } /** * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다. **/ private void GetRoomName() { WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getContext().getApplicationContext()); boolean UseEachRoomName = wallpadDeviceSet.GetEachRoomNameInfo(); wallpadDeviceSet.closeDB(); Log.i(TAG, "[GetRoomName] UseEachRoomName [" + UseEachRoomName + "]"); if (UseEachRoomName == false) { // 명칭 통합사용 mRoomNameList_Light = getRoomNamefromDB(); if (mRoomNameList_Light == null) { mRoomNameList_Light = mDefaultRoomNameList; } } else { // 명칭 난방, 조명 분리 사용 mRoomNameList_Light = getRoomNamefromDB(LIGHT); if (mRoomNameList_Light == null) { mRoomNameList_Light = mDefaultRoomNameList_Light; } } } /** * Menu Event intent filter 등록 **/ private void reg_Receiver() { try { IntentFilter filter = new IntentFilter(); filter.addAction("MENU_EVENT"); registerReceiver(mWallPadAlertBR, filter); filter = new IntentFilter(); filter.addAction(define.NOTIFY_DAIL); filter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH"); registerReceiver(mWallPadJogBR, filter); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 조그버튼 입력 받을 시 처리 **/ BroadcastReceiver mWallPadJogBR = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { WpadActivity.setFinishTimerReset(); } }; /** * 메뉴에서 버튼 터치 처리 * **/ BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int groupPosition = intent.getIntExtra("groupPosition", -1); int childPosition = intent.getIntExtra("childPosition", -1); Log.i(TAG, "groupPosition :" +groupPosition + ", childPosition :" + childPosition); if((groupPosition >= 0) && (childPosition >= 0)) { if(MenuOpen == true) { Sound().Play(SND.effect.TOUCH_LATCHED); CloseMenuLayout(); if(menueListDataClass == null) { return; } String childName = menueListDataClass.arrayChild.get(menueListDataClass.arrayGroup.get(groupPosition)).get(childPosition); for (int i = 0; i < menueListDataClass.idMappingTable.length; i++) { if(menueListDataClass.idMappingTable[i].Name.equals(childName) == true) { API_Menu api_Menu = new API_Menu(); int TempID = api_Menu.GetMyGroupID(getApplicationContext().getPackageName()); int ChildID = menueListDataClass.idMappingTable[i].Id; int ChildGroupID = (ChildID / 1000) * 1000; Log.i(TAG, "Child ID :" + ChildID); if(TempID == 0) { return; } if(ChildGroupID == TempID) { //해당 APP내에서 스크린 전환 필요 //[수정필요] boolean result = setChangeScreen(ChildID, false); setBackBtnSmartDistVisible(false); if(result == false) { setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false); } WpadActivity.setFinishTimerReset(); } else { //외부 앱 호출 후, 본 APP Finish 필요 api_Menu.startSubScreenActivity(getApplicationContext(), menueListDataClass.idMappingTable[i].Id, API_Menu.MENU_START_OPTION_1, api_Menu.GetAPK_Name_ByID(ChildGroupID)); Intent mIntent = new Intent(); mIntent.putExtra("Finish_Kind", "HomeButton"); MainActivity.this.setResult(RESULT_OK, mIntent); finish(); } break; } } } } } }; /** * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다. * * @param code - (int) 송신할 keycode * @return (int) - >=0 : 성공, <0 : 실패 */ private int setSendEventBR(int code) { try { KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code); Intent intent = new Intent("EVENT_DEVICE_CONTROL", null); intent.putExtra(Intent.EXTRA_KEY_EVENT, event); intent.putExtra("keycode",code); getContext().sendBroadcast(intent); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return -100; } catch (Exception e) { Log.e(TAG, "[setSendEventBR] - [Exception Error] code:" + code); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return -100; } return 0; } /** * 간편모드 UX 사용여부를 반환한다. * @return TRUE일 경우 간편모드 UX 사용 */ public boolean GetEasyModeUXUse() { try { WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext); boolean bSupport = deviceSet.Get_EasyModeUX_Support(); deviceSet.closeDB(); WallpadStatusData data = new WallpadStatusData(mContext); boolean bUse = data.GetEasyModeUxUse(); data.closeDB(); Log.d(TAG, "[GetEasyModeUXUse] bSupport [" + bSupport + "], bUse [" + bUse + "]"); return bSupport & bUse; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] GetEasyModeUXUse()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return false; } /** * 통합전력제어기 종류를 확인한다. * POWERCONTROLLER_TYPE_NONE = 110; // 사용안함 * POWERCONTROLLER_TYPE_DEFAULT = 111; // 기본 * POWERCONTROLLER_TYPE_DIRECT = 112 // 직결보드 * POWERCONTROLLER_TYPE_MEASURE = 113 // 전력측정직결보드 */ int nIntegratedPowerCtrller = WallpadDeviceSet.POWERCONTROLLER_TYPE_NONE; public int getIntegratedPowerCtrllerType() { try { WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext); nIntegratedPowerCtrller = mWallpadDeviceSet.Get_PowerControllerType_Info(); mWallpadDeviceSet.closeDB(); Log.d(TAG, "[getIntegratedPowerCtrllerType] nIntegratedPowerCtrller [" + nIntegratedPowerCtrller + "]"); return nIntegratedPowerCtrller; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return WallpadDeviceSet.POWERCONTROLLER_TYPE_NONE; } catch (Exception e) { Log.e(TAG, "[Exception] getIntegratedPowerCtrllerType()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return WallpadDeviceSet.POWERCONTROLLER_TYPE_NONE; } } }