MainActivity.java 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891
  1. package kr.co.icontrols.wallpadenergyctrl;
  2. import java.util.ArrayList;
  3. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  4. import com.artncore.WallPadDataMgr.WallpadStatusData;
  5. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  6. import com.artncore.commons.API_Menu;
  7. import com.artncore.commons.API_Menu.MenuListDataClass;
  8. import com.artncore.commons.API_Menu.MenuListDataClass.ChildIDMapping;
  9. import com.artncore.commons.define;
  10. import com.artncore.wallpadapi.WallPadAPI;
  11. import android.annotation.SuppressLint;
  12. import android.content.BroadcastReceiver;
  13. import android.content.Context;
  14. import android.content.Intent;
  15. import android.content.IntentFilter;
  16. import android.graphics.Color;
  17. import android.os.Bundle;
  18. import android.os.CountDownTimer;
  19. import android.os.Handler;
  20. import android.os.Message;
  21. import android.util.Log;
  22. import android.view.Gravity;
  23. import android.view.KeyEvent;
  24. import android.view.MotionEvent;
  25. import android.view.View;
  26. import android.view.View.OnTouchListener;
  27. import android.view.WindowManager;
  28. import android.view.animation.AccelerateInterpolator;
  29. import android.view.animation.Animation;
  30. import android.view.animation.Animation.AnimationListener;
  31. import android.view.animation.TranslateAnimation;
  32. import android.widget.ExpandableListView;
  33. import android.widget.ExpandableListView.OnGroupClickListener;
  34. import android.widget.ExpandableListView.OnGroupCollapseListener;
  35. import android.widget.ExpandableListView.OnGroupExpandListener;
  36. import android.widget.Button;
  37. import android.widget.RelativeLayout;
  38. import kr.co.icontrols.wallpadenergyctrl.declare.Common;
  39. import kr.co.icontrols.wallpadenergyctrl.declare.ID;
  40. import kr.co.icontrols.wallpadenergyctrl.screen.*;
  41. import kr.co.icontrols.wallpadenergyctrl.screen.ienergy.EachRoomEnergyDetailScreen;
  42. import kr.co.icontrols.wallpadenergyctrl.screen.ienergy.EachRoomEnergyMainScreen;
  43. import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartConcentScreen;
  44. import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartDisPanelScreen;
  45. import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartDisPanelScreen_01;
  46. import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartDisPanelScreen_02;
  47. import kr.co.icontrols.wallpadenergyctrl.screen.smart_distribution.SmartLightScreen;
  48. import kr.co.icontrols.wallpadsupport.Version;
  49. import kr.co.icontrols.wallpadsupport.WpadActivity;
  50. import kr.co.icontrols.wallpadsupport.WpadImageView;
  51. import kr.co.icontrols.wallpadsupport.WpadScale;
  52. import kr.co.icontrols.wallpadsupport.WpadTextView;
  53. import kr.co.icontrols.wallpadsupport.WpadUtil;
  54. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  55. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  56. import com.util.LogUtil;
  57. /**
  58. * @description
  59. * 월패드 [에너지관리] 메인화면 이다.<br>
  60. * 상단의 Top 메뉴, [홈] [돌아가기]<br>
  61. * 좌측의 Tab 메뉴, [원격검침] [IEnergy] [실시간검침] ... 등 선택 메뉴<br>
  62. * 를 여기서 처리한다.
  63. */
  64. public class MainActivity extends WpadActivity {
  65. private final static String TAG = "MainActivity";
  66. private final boolean DEBUG_LOG_ON = true;
  67. private void DebugLogOutput(String s) { if(DEBUG_LOG_ON) Log.d(TAG, s); }
  68. // =================================================================================================
  69. // [[ Declaration ]] region
  70. // =================================================================================================
  71. protected Context mContext = null;
  72. public Context getContext() { return mContext; }
  73. private WallPadAPI wpapi = null;
  74. private WallpadStatusData wdb = null;
  75. private int OPERATION_MODE = Common.MODE;
  76. // Layout
  77. private RelativeLayout AllLayout; // 화면 전체
  78. private RelativeLayout TopLayout; // 상단 메뉴
  79. private RelativeLayout ScreenLayout; // 메인 화면
  80. private RelativeLayout MenuLayout; // 메뉴 화면
  81. // Top Menu
  82. private WpadImageView TopBackground;
  83. private WpadTextView TopTitle;
  84. private WpadImageView TopHomeBtn,TopBackBtn, TopMenuBtn, TopSetTargetBtn;
  85. private WpadImageView Hide1Btn, Hide2Btn;
  86. private TextButton EnergyResetBtn;
  87. private WpadTextView SampleModeTitle;
  88. private WpadImageView BackBtn_SmartDist;
  89. private WpadImageView TopManualBtn;
  90. // Tab Menu
  91. /* private int [][] TabBgDrawIdArray = new int [][]
  92. {
  93. { R.drawable.sub_menu_bgr_normal_1, R.drawable.sub_menu_bgr_pressed },
  94. { R.drawable.sub_menu_bgr_normal_2, R.drawable.sub_menu_bgr_pressed },
  95. { R.drawable.sub_menu_bgr_normal_3, R.drawable.sub_menu_bgr_pressed },
  96. { R.drawable.sub_menu_bgr_normal_4, R.drawable.sub_menu_bgr_pressed },
  97. { R.drawable.sub_menu_bgr_normal_5, R.drawable.sub_menu_bgr_pressed },
  98. { R.drawable.sub_menu_bgr_normal_6, R.drawable.sub_menu_bgr_pressed },
  99. { R.drawable.sub_menu_bgr_normal_7, R.drawable.sub_menu_bgr_pressed },
  100. };
  101. private WpadImageView TabBtn1, TabBtn2, TabBtn3, TabBtn4, TabBtn5, TabBtn6, TabBtn7;
  102. private WpadImageView [] TabBtn_Array = new WpadImageView [] {TabBtn1, TabBtn2, TabBtn3, TabBtn4, TabBtn5, TabBtn6, TabBtn7};*/
  103. // Main
  104. private WpadImageView ScreenBackground;
  105. // Menu
  106. private WpadImageView MenuBackground;
  107. private WpadImageView MenuClose;
  108. private WpadTextView MenuTitle;
  109. private static ExpandableListView mListView;
  110. private Menu_AdptMain adptMain;
  111. private MenuListDataClass menueListDataClass;
  112. private boolean MenuOpen = false;
  113. // PopupActivityRun
  114. private static boolean PopupActivityRun = false;
  115. public static boolean getPopupActivityRun() { return PopupActivityRun; }
  116. public static void setPopupActivityRun(boolean run) { PopupActivityRun = run; }
  117. // Menu & TabData
  118. private Menu mMenu = null;
  119. // private TabData mTabData = null;
  120. // CurrentScreenId
  121. private int mCurrentScreenId = -1;
  122. private int mTempCurrentScreenId = -1;
  123. public static int mCurrentManualScreenId = -1;
  124. // HideMenu
  125. private int mHideMenuEntryStatus = 0;
  126. private static boolean mHideMenuOn = false;
  127. public static boolean getHideMenuOn() { return mHideMenuOn; }
  128. private CountDownTimer mHideMenuTimer = null;
  129. // TextButton
  130. private class TextButton {
  131. public WpadImageView Bg; // 배경
  132. public WpadTextView Text; // 글씨
  133. public TextButton(RelativeLayout layout, boolean UseButton, int bgcolor, int w, int h, int id, int textcolor, int textsize, boolean textbold, int left, int top) {
  134. int TouchKind = TOUCH_KIND.NONE;
  135. if(UseButton) TouchKind = TOUCH_KIND.BUTTON_M;
  136. Bg = new WpadImageView(getContext(), TouchKind, w, h, 0, 0, id);
  137. Bg.setBackgroundColor(bgcolor);
  138. ViewRegistration(layout, Bg, left, top);
  139. Text = new WpadTextView(getContext(), false, w, h, Gravity.CENTER, textcolor, textsize, textbold, 0);
  140. ViewRegistration(layout, Text, left, top);
  141. }
  142. public void setText(String str)
  143. {
  144. if(Text != null) Text.setText(str);
  145. }
  146. public void setVisibility(int visibility) {
  147. Bg.setVisibility(visibility);
  148. Text.setVisibility(visibility);
  149. }
  150. }
  151. // Screen
  152. private RemoteMeterMainScreen remoteMeterMainScreen = null; //원격검침
  153. private IcEnergyMgrScreen icEnergyMgrScreen = null ;//HEMS
  154. //private RealTimeMeterMainScreen realTimeMeterMainScreen = null; //실시간검침
  155. private RemoteMeterCostTableScreen remoteMeterCostTableScreen = null; //요금테이블
  156. private EachRoomEnergyMainScreen eachRoomEnergyMainScreen; // I'Energy Main Screen (간편보기) -> 신규 사용안함..
  157. private EachRoomEnergyDetailScreen eachRoomEnergyDetailScreen; // I'Energy 상세보기 -> 신규 기본화면
  158. private SmartDisPanelScreen smartDisPanelScreen;
  159. private SmartDisPanelScreen_01 smartDisPanelScreen_01; // 신규 화면 (통합전력제어기: 전력측정(VE버전))
  160. private SmartDisPanelScreen_02 smartDisPanelScreen_02; // 신규 화면 (통합전력제어기: 직결)
  161. private SmartConcentScreen smartConcentScreen;
  162. private SmartLightScreen smartLightScreen;
  163. // 명칭 관련
  164. public static final int HEATING = 1;
  165. public static final int LIGHT = 2;
  166. private String [] mRoomNameList = null; //조명 방 명칭
  167. private String[] mRoomNameList_Light = null; //조명 방 명칭
  168. private String[] mRoomNameList_Heating = null; //난방 방 명칭
  169. private String [] mDefaultRoomNameList = new String []{ "거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  170. //난방 조명 방 명칭 분리 사용시 디폴트 값
  171. private String [] mDefaultRoomNameList_Light = new String [] { "거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  172. public WallpadStatusData GetDBObj()
  173. {
  174. return wdb;
  175. }
  176. // =================================================================================================
  177. // [[ Activity Life Cycle ]] region
  178. // =================================================================================================
  179. /**
  180. * Activity Constructors
  181. */
  182. @Override
  183. protected void onCreate(Bundle savedInstanceState) {
  184. Log.i(TAG, "-------------------------------------------------------------");
  185. Log.i(TAG, "------------------ [START - MainActivity] -------------------");
  186. Log.i(TAG, "-------------------------------------------------------------");
  187. super.onCreate(savedInstanceState);
  188. // @ AutoScale 설정
  189. WpadScale.setAutoScale(true);
  190. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  191. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
  192. // 1. 변수 초기화
  193. DebugLogOutput("[Create] - Step1 : Data Create");
  194. PopupActivityRun = false;
  195. mContext = this;
  196. mHideMenuOn = false;
  197. // 2. 자동 종료 셋팅
  198. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  199. // 2-1. 자동종료 타이머 셋팅
  200. if (Common.MODE == Common.MODE_PRODUCTION) {
  201. // LCD 항상 켜져 있게 하는 기능 추가
  202. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  203. // pm.userActivity(2, true);
  204. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  205. }
  206. else {
  207. if (Common.FINISH_TIME_ENABLE) super.setFinishTimerCreate(Common.FINISH_TIME_SEC); // 주석 해제해야 정상임
  208. }
  209. // 3. API 호출
  210. DebugLogOutput("[Create] - Step3 : API Call");
  211. if (Common.GetDeviceSampleMode(this)) OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  212. else OPERATION_MODE = Common.MODE_NOMAL;
  213. // 3.1. wpapi 생성
  214. if (OPERATION_MODE == Common.MODE_NOMAL) {
  215. Log.d(TAG, "OperationMode = MODE_NOMAL");
  216. try {
  217. wpapi = new WallPadAPI(this);
  218. } catch (RuntimeException re) {
  219. LogUtil.errorLogInfo("", TAG, re);
  220. }
  221. catch (Exception e) {
  222. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  223. //e.printStackTrace();
  224. LogUtil.errorLogInfo("", TAG, e);
  225. }
  226. }
  227. else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  228. Log.d(TAG, "OperationMode = MODE_BUSINESS_SAMPLE");
  229. }
  230. try { wdb = new WallpadStatusData(this); }
  231. catch (RuntimeException re) {
  232. LogUtil.errorLogInfo("", TAG, re);
  233. }
  234. catch (Exception e) { Log.e(TAG, "[ExceptionError] - onCreate->WallpadStatusData Create : " + e); }
  235. getIntegratedPowerCtrllerType();
  236. GetRoomName();
  237. // 4. Layout registration
  238. DebugLogOutput("[Create] - Step4 : Layout registration");
  239. // 4-1. mainLayout
  240. AllLayout = new RelativeLayout(this);
  241. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  242. AllLayout.setLayoutParams(params);
  243. AllLayout.setId(ID.main.layout.ALL);
  244. super.setAllLayoutRegistration(AllLayout);
  245. // 4-2. TopLayout
  246. TopLayout = new RelativeLayout(this);
  247. WpadUtil.LayoutRegistration(AllLayout, TopLayout, 1280, 110, 0, 0, ID.main.layout.TOP);
  248. // 4-4. ScreenLayout
  249. ScreenLayout = new RelativeLayout(this);
  250. WpadUtil.LayoutRegistration(AllLayout, ScreenLayout, 1280, 690, 0, 110, ID.main.layout.SCREEN);
  251. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  252. SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.WHITE, Common.fontsize._26_DEFAULT, true, 0);
  253. ViewRegistration(TopLayout, SampleModeTitle, 133, 15);
  254. SampleModeTitle.setText("[영업샘플모드]");
  255. }
  256. else if (Common.MODE == Common.MODE_PRODUCTION) {
  257. SampleModeTitle = new WpadTextView(this, false, 200, 72, Gravity.CENTER, Color.WHITE, Common.fontsize._26_DEFAULT, true, 0);
  258. ViewRegistration(TopLayout, SampleModeTitle, 316, 0);
  259. SampleModeTitle.setText("[생산 검수 모드]");
  260. 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);
  261. EnergyResetBtn.setText("RESET");
  262. EnergyResetBtn.setVisibility(View.INVISIBLE);
  263. }
  264. ScreenBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, R.drawable.bg_body, ID.main.image.SCREEN_BACKGROUND);
  265. ViewRegistration(ScreenLayout, ScreenBackground, 0, 0);
  266. // 5. Top Menu - ImageView registration
  267. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  268. TopBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 110, R.drawable.bg_topbar, R.drawable.bg_topbar, ID.main.image.TOP_BACKGROUND);
  269. ViewRegistration(TopLayout, TopBackground, 0, 0);
  270. TopTitle = new WpadTextView(this, false, 247+50, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE);
  271. ViewRegistration(TopLayout, TopTitle, 133, 15);
  272. 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);
  273. ViewRegistration(TopLayout, TopHomeBtn, 1145, 0);
  274. 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);
  275. ViewRegistration(TopLayout, TopBackBtn, 1019, 0);
  276. setTopBackBtnVisible(false);
  277. 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);
  278. setManualBtnVisible(getManualUse(), 1019);
  279. 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);
  280. ViewRegistration(TopLayout, BackBtn_SmartDist, 1020, 0);
  281. setBackBtnSmartDistVisible(false);
  282. 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);
  283. ViewRegistration(TopLayout, TopMenuBtn, 0, 0);
  284. // Hide1Btn = new WpadImageView(this, TOUCH_KIND.BUTTON_M, 70, 61, 0, 0, ID.main.button.HIDE1);
  285. // ViewRegistration(TopLayout, Hide1Btn, 0, 0);
  286. // Hide2Btn = new WpadImageView(this, TOUCH_KIND.BUTTON_M, 70, 61, 0, 0, ID.main.button.HIDE2);
  287. // ViewRegistration(TopLayout, Hide2Btn, 1024-70, 0);
  288. // 6. Menu Loading
  289. // 6-1. 메뉴 정보를 가져온다 (DB에서 가져온다)
  290. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  291. //test
  292. WallpadDBMGR.DeleteMenuList();
  293. ArrayList<ArrayList<Integer>> mGroupList = null;
  294. ArrayList<Integer> mChildList = null;
  295. mGroupList = new ArrayList<ArrayList<Integer>>();
  296. //b. 에너지관리
  297. mChildList = new ArrayList<Integer>();
  298. mChildList.add(API_Menu.SubMenuEnergy.EnergyMgr);
  299. mChildList.add(API_Menu.SubMenuEnergy.RemoteMeter);
  300. mChildList.add(API_Menu.SubMenuEnergy.EachRoomEnergy);
  301. //mChildList.add(API_Menu.SubMenuEnergy.CostTable);
  302. mGroupList.add(mChildList);
  303. WallpadDBMGR.SetMenuList(mGroupList);
  304. menueListDataClass = WallpadDBMGR.GetMenuList();
  305. WallpadDBMGR.closeDB();
  306. if (menueListDataClass == null) {
  307. Log.e(TAG, "menueListDataClass == null, Load Default List");
  308. menueListDataClass = LoadDefaultMenuList();
  309. }
  310. //WallPadMain에서 MenuList를 넣어주지 않아 아래 테스트 코드를 넣음
  311. menueListDataClass = LoadDefaultMenuList();
  312. // 6-2. 시작 화면을 main APP으로 부터 받아서 처리한다.
  313. mMenu = new Menu();
  314. mMenu = super.getIntentParsingMenu(getIntent());
  315. if(mMenu == null)
  316. {
  317. //setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false);
  318. Log.i(TAG, "mMenu = null");
  319. if (OPERATION_MODE == Common.MODE_NOMAL)
  320. {
  321. mTempCurrentScreenId =API_Menu.SubMenuEnergy.RemoteMeter;
  322. //SetTitleText(mTempCurrentScreenId);
  323. mWallPadApiCheckHandler.sendEmptyMessage(0);
  324. } else
  325. {
  326. setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false);
  327. }
  328. }
  329. else
  330. {
  331. /*boolean result = setChangeScreen(mMenu.getStartId(), false);
  332. if(result == false)
  333. {
  334. setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false);
  335. }*/
  336. Log.i(TAG, "mMenu != null");
  337. if (OPERATION_MODE == Common.MODE_NOMAL)
  338. {
  339. mTempCurrentScreenId = mMenu.getStartId();
  340. //setTitleName(mTempCurrentScreenId);
  341. mWallPadApiCheckHandler.sendEmptyMessage(0);
  342. } else
  343. {
  344. boolean result = setChangeScreen(mMenu.getStartId(), false);
  345. if (result == false)
  346. {
  347. setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false);
  348. }
  349. }
  350. }
  351. // 7. Draw
  352. DebugLogOutput("[Create] - Step7 : setContentView");
  353. setContentView(AllLayout);
  354. // 8. Window ReSize
  355. DebugLogOutput("[Create] - Step8 : Window ReSize");
  356. //super.WindowReSize(Common.SCREEN_SIZE_MAIN_W, Common.SCREEN_SIZE_MAIN_H, false);
  357. // 9. BR Receiver 등록(메뉴에서 다른 화면이 눌린 경우 BR처리)
  358. reg_Receiver();
  359. /*WallpadDeviceSet wd = new WallpadDeviceSet(getContext());
  360. if(wd.Get_SmartDistribution_Info() == 1)
  361. {
  362. Log.i(TAG, "스마트분전반 사용설정 ON");
  363. }
  364. else
  365. {
  366. Log.i(TAG, "스마트분전반 사용설정 OFF");
  367. }*/
  368. Log.i(TAG, "End onCreate -------------------------------------------------");
  369. }
  370. /* *
  371. * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며, <br>
  372. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  373. * 본 딜레이 코드를 임시로 적용한다.*/
  374. @SuppressLint("HandlerLeak")
  375. protected Handler mWallPadApiCheckHandler = new Handler()
  376. {
  377. @SuppressLint("HandlerLeak")
  378. @Override
  379. public void handleMessage(Message msg)
  380. {
  381. if(msg.what == 0)
  382. {
  383. if(wpapi != null)
  384. {
  385. if(wpapi.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  386. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  387. }
  388. }
  389. else if(msg.what == 1)
  390. {
  391. setChangeScreen(mTempCurrentScreenId, false);
  392. }
  393. }
  394. };
  395. /**
  396. * onDestroy
  397. */
  398. @Override
  399. protected void onDestroy()
  400. {
  401. if(Common.MODE == Common.MODE_PRODUCTION)
  402. {
  403. // LCD 를 Normal 상태로 변경하는 기능 추가
  404. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  405. // pm.userActivity(1, true);
  406. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  407. }
  408. setChangeScreen(mCurrentScreenId, true);
  409. if(wdb != null) wdb.closeDB();
  410. this.unregisterReceiver(mWallPadAlertBR);
  411. this.unregisterReceiver(mWallPadJogBR);
  412. if(getManualUse())
  413. {
  414. FinishManualActivity();
  415. }
  416. super.setFinishTimerDestroy();
  417. super.onDestroy();
  418. Log.i(TAG, "*************************************************************");
  419. Log.i(TAG, "****************** [END - MainActivity] *******************");
  420. Log.i(TAG, "*************************************************************");
  421. }
  422. /**
  423. * onResume
  424. */
  425. @Override
  426. protected void onResume() {
  427. super.onResume();
  428. if(wpapi != null) wpapi.Resume();
  429. DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@");
  430. }
  431. /**
  432. * onPause
  433. */
  434. @Override
  435. protected void onPause() {
  436. super.onPause();
  437. if(wpapi != null) wpapi.Pause();
  438. DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@");
  439. }
  440. /* ================================================================================================
  441. * [BroadcastReceiver] Section
  442. ================================================================================================ */
  443. /**
  444. * BroadcastReceiver.onReceive for [WpadActivity]
  445. */
  446. @Override
  447. protected void onBrReceive(Intent intent)
  448. {
  449. super.onBrReceive(intent);
  450. DebugLogOutput("Receive BR " + intent.getAction());
  451. }
  452. /* ================================================================================================
  453. * [Touch & Key Event] Section
  454. ================================================================================================ */
  455. /**
  456. * TouchEvent for [WpadActivity]
  457. */
  458. @Override
  459. protected void onTouchEvent(View v, MotionEvent event)
  460. {
  461. super.onTouchEvent(v, event);
  462. int TargetId = v.getId();
  463. int MoveEvent = event.getAction();
  464. //DebugLogOutput("onTouch - " + "id : " + v.getId() + " / Action : " + event.getAction());
  465. if(MoveEvent == MotionEvent.ACTION_UP)
  466. {
  467. if(TargetId == ID.main.button.HOME)
  468. {
  469. DebugLogOutput("onTouchEvent [HOME] BUTTON !!!");
  470. Sound().Play(SND.effect.TOUCH_LATCHED);
  471. Intent intent = new Intent();
  472. intent.putExtra("Finish_Kind", "HomeButton");
  473. setResult(RESULT_OK, intent);
  474. finish();
  475. }
  476. else if(TargetId == ID.main.button.BACK_SMARTDIST)
  477. {
  478. DebugLogOutput("onTouchEvent [BACK_SMARTDIST] BUTTON !!!");
  479. Sound().Play(SND.effect.TOUCH_LATCHED);
  480. setBackBtnSmartDistVisible(false);
  481. setChangeScreen(API_Menu.SubMenuEnergy.SmartPanel, false);
  482. }
  483. else if(TargetId == ID.main.button.BACK)
  484. {
  485. DebugLogOutput("onTouchEvent [BACK] BUTTON !!!");
  486. Sound().Play(SND.effect.TOUCH_LATCHED);
  487. /**
  488. *[수정필요]Back Button 필요한 화면은 아래 부분 추가 후 사용 필요
  489. * **/
  490. /*
  491. if(mCurrentScreenId == API_Menu.SubMenuConfig.SmartKey)
  492. {
  493. setChangeScreen(API_Menu.SubMenuConfig.Configuration, false);
  494. }
  495. */
  496. }
  497. else if(TargetId == ID.main.button.MENU)
  498. {
  499. DebugLogOutput("onTouchEvent [MENU] BUTTON !!!");
  500. if(MenuOpen == true)
  501. {
  502. return;
  503. }
  504. Sound().Play(SND.effect.TOUCH_LATCHED);
  505. OpenMenuLayout();
  506. }
  507. else if (TargetId == ID.main.button.MENUCLOSE)
  508. {
  509. if(MenuOpen == true)
  510. {
  511. Sound().Play(SND.effect.TOUCH_LATCHED);
  512. CloseMenuLayout();
  513. }
  514. }
  515. else if(TargetId == ID.main.button.ENERGY_RESET)
  516. {
  517. DebugLogOutput("onTouchEvent [ENERGY_RESET] BUTTON !!!");
  518. try
  519. {
  520. if(wpapi != null && wpapi.Get_IGW200dController()!=null)
  521. {
  522. int ret = wpapi.Get_IGW200dController().EnergyReset();
  523. if(ret >= 0)
  524. {
  525. Sound().Play(SND.effect.EFFECT1);
  526. }
  527. }
  528. }
  529. catch (RuntimeException re) {
  530. LogUtil.errorLogInfo("", TAG, re);
  531. }
  532. catch (Exception e)
  533. {
  534. Log.e(TAG, "[ExceptionError] - onTouchEvent->ENERGY_RESET wpapi.Get_IGW200dController().EnergyReset()");
  535. //e.printStackTrace();
  536. LogUtil.errorLogInfo("", TAG, e);
  537. }
  538. }
  539. else if (TargetId == ID.main.button.MANUAL)
  540. {
  541. Log.i(TAG, "onTouchEvent [MANUAL] BUTTON [mCurrentScreenId = " + mCurrentScreenId + "]");
  542. Sound().Play(SND.effect.TOUCH_LATCHED);
  543. try
  544. {
  545. if(mCurrentScreenId == API_Menu.SubMenuEnergy.RemoteMeter) { StartManual(ID.MANUAL.MANUAL_RemoteMeter); }
  546. else if(mCurrentScreenId == API_Menu.SubMenuEnergy.EnergyMgr) { StartManual(ID.MANUAL.MANUAL_HEMS); }
  547. else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartPanel) { StartManual(ID.MANUAL.MANUAL_SmartDist); }
  548. else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartLight) { StartManual(ID.MANUAL.MANUAL_SmartLight); }
  549. else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartOutlet) { StartManual(ID.MANUAL.MANUAL_SmartConcent); }
  550. }
  551. catch (RuntimeException re) {
  552. LogUtil.errorLogInfo("", TAG, re);
  553. }
  554. catch (Exception ex)
  555. {
  556. //ex.printStackTrace();
  557. LogUtil.errorLogInfo("", TAG, ex);
  558. }
  559. }
  560. }
  561. }
  562. /**
  563. * H/W Key Event
  564. */
  565. @Override
  566. public boolean onKeyDown(int keyCode, KeyEvent event)
  567. {
  568. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  569. return super.onKeyDown(keyCode, event);
  570. }
  571. /* ================================================================================================
  572. * [TOP - Back] Section
  573. ================================================================================================ */
  574. /**
  575. * TOP 돌아가기 버튼 활성화 & 비활성화
  576. *
  577. * @param Enabled - true : 활성화, false : 비활성화
  578. * @return (boolean) true : 성공, false : 실패
  579. */
  580. public boolean setTopBackBtnVisible(boolean Enabled)
  581. {
  582. if(Enabled == true)
  583. {
  584. if(TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE);
  585. TopBackBtn.bringToFront();
  586. }
  587. else
  588. {
  589. if(TopBackBtn.getVisibility() != View.INVISIBLE) TopBackBtn.setVisibility(View.INVISIBLE);
  590. }
  591. return true;
  592. }
  593. /**
  594. * 스마트분전반 돌아가기 버튼 활성화 & 비활성화
  595. *
  596. * @param Enabled - true : 활성화, false : 비활성화
  597. * @return (boolean) true : 성공, false : 실패
  598. */
  599. public boolean setBackBtnSmartDistVisible(boolean Enabled)
  600. {
  601. if(Enabled == true)
  602. {
  603. if(BackBtn_SmartDist.getVisibility() != View.VISIBLE) BackBtn_SmartDist.setVisibility(View.VISIBLE);
  604. BackBtn_SmartDist.bringToFront();
  605. if(TopManualBtn.getVisibility() == View.VISIBLE)
  606. {
  607. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  608. }
  609. }
  610. else
  611. {
  612. if(BackBtn_SmartDist.getVisibility() != View.INVISIBLE) BackBtn_SmartDist.setVisibility(View.INVISIBLE);
  613. if(TopManualBtn.getVisibility() == View.VISIBLE)
  614. {
  615. WpadUtil.ViewMove(TopManualBtn, 1019, 0);
  616. }
  617. }
  618. return true;
  619. }
  620. /**
  621. * TOP 에 목표량설정 아이콘 활성화 & 비활성화
  622. *
  623. * @param Enabled - true : 활성화, false : 비활성화
  624. * @return (boolean) true : 성공, false : 실패
  625. */
  626. public boolean setTopSetTargetBtnVisible(boolean Enabled)
  627. {
  628. if(Enabled == true)
  629. {
  630. if(TopSetTargetBtn.getVisibility() != View.VISIBLE)
  631. {
  632. WpadUtil.ViewMove(TopSetTargetBtn, 93, 132);
  633. if(TopSetTargetBtn!=null) TopSetTargetBtn.setVisibility(View.VISIBLE);
  634. }
  635. if(TopSetTargetBtn!=null) TopSetTargetBtn.bringToFront();
  636. }
  637. else
  638. {
  639. if(TopSetTargetBtn.getVisibility() != View.INVISIBLE && TopSetTargetBtn!=null) TopSetTargetBtn.setVisibility(View.INVISIBLE);
  640. }
  641. return true;
  642. }
  643. /**
  644. * TOP 에너지미터 리셋 버튼 활성화 & 비활성화
  645. *
  646. * @param Enabled - true : 활성화, false : 비활성화
  647. */
  648. public void setTopEnergyResetBtnVisible(boolean Enabled)
  649. {
  650. if(Enabled == true)
  651. EnergyResetBtn.setVisibility(View.VISIBLE);
  652. else
  653. EnergyResetBtn.setVisibility(View.INVISIBLE);
  654. }
  655. /* ================================================================================================
  656. * [Manual Activity] Section
  657. ================================================================================================ */
  658. public static ManualActivity mManualActivity;
  659. public void setManualBtnVisible(boolean bEnable, int marginLeft)
  660. {
  661. try
  662. {
  663. Log.d(TAG, "[setManualBtnVisible] bEnable [" + bEnable + "], marginLeft [" + marginLeft + "]");
  664. if (bEnable) TopManualBtn.setVisibility(View.VISIBLE);
  665. else TopManualBtn.setVisibility(View.INVISIBLE);
  666. ViewRegistration(TopLayout, TopManualBtn, marginLeft, 0);
  667. }
  668. catch (RuntimeException re) {
  669. LogUtil.errorLogInfo("", TAG, re);
  670. }
  671. catch (Exception e)
  672. {
  673. Log.e(TAG, "[Exception] setManualBtnVisible(boolean bEnable)");
  674. //e.printStackTrace();
  675. LogUtil.errorLogInfo("", TAG, e);
  676. }
  677. }
  678. /**
  679. * 매뉴얼 버튼 사용 유무
  680. * @return boolean 타입 - true: 사용, false: 미사용
  681. */
  682. public boolean getManualUse()
  683. {
  684. try
  685. {
  686. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  687. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  688. devSet.closeDB();
  689. if (DBinfo != null)
  690. {
  691. if (DBinfo[1].indexOf("사용함") > 0)
  692. {
  693. Log.d(TAG, "[getManualUse] Use Manual");
  694. return true;
  695. }
  696. else
  697. {
  698. // 미사용
  699. Log.d(TAG, "[getManualUse] Not Use Manual [1]");
  700. return false;
  701. }
  702. }
  703. else
  704. {
  705. // 미사용
  706. Log.d(TAG, "[getManualUse] Not Use Manual [2]");
  707. return false;
  708. }
  709. }
  710. catch (RuntimeException re) {
  711. LogUtil.errorLogInfo("", TAG, re);
  712. }
  713. catch (Exception ex)
  714. {
  715. Log.e(TAG, "[getManualUse] - Exception !!!");
  716. //ex.printStackTrace();
  717. LogUtil.errorLogInfo("", TAG, ex);
  718. }
  719. return false;
  720. }
  721. // ManualActivityRun
  722. private static boolean ManualActivityRun = false;
  723. public static boolean getManualActivityRun() {
  724. Log.d(TAG, "[getManualActivityRun] ManualActivityRun: " + ManualActivityRun);
  725. return ManualActivityRun;
  726. }
  727. public static void setManualActivityRun(boolean run)
  728. {
  729. ManualActivityRun = run;
  730. if (!ManualActivityRun) resetCurrentManualScreenID();
  731. }
  732. public boolean StartManual(int screenId)
  733. {
  734. Log.d(TAG, "[StartManual] ScreenId [" + screenId + "], mCurrentManualScreenId [" + mCurrentManualScreenId + "]");
  735. if (getManualActivityRun())
  736. {
  737. mCurrentManualScreenId = screenId;
  738. try
  739. {
  740. boolean ret = mManualActivity.ChangeScreen(screenId);
  741. Log.d(TAG, "[StartManual] - ret : " + ret);
  742. return ret;
  743. }
  744. catch (RuntimeException re) {
  745. LogUtil.errorLogInfo("", TAG, re);
  746. return false;
  747. }
  748. catch (Exception ex)
  749. {
  750. //ex.printStackTrace();
  751. LogUtil.errorLogInfo("", TAG, ex);
  752. return false;
  753. }
  754. }
  755. else
  756. {
  757. try
  758. {
  759. if (mCurrentManualScreenId == screenId) return false;
  760. mCurrentManualScreenId = screenId;
  761. setManualActivityRun(true);
  762. Intent intent = new Intent(mContext, ManualActivity.class);
  763. intent.putExtra("ScreenId", screenId);
  764. if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartLight)
  765. {
  766. intent.putExtra("SmartLightInfo", smartLightScreen.nAllEMCnt);
  767. }
  768. else if(mCurrentScreenId == API_Menu.SubMenuEnergy.SmartOutlet)
  769. {
  770. if(smartConcentScreen.concentRooms != null)
  771. {
  772. intent.putExtra("SmartConcentInfo", smartConcentScreen.concentRooms.length);
  773. }
  774. }
  775. overridePendingTransition(0, 0);
  776. startActivityForResult(intent, 0);
  777. return true;
  778. }
  779. catch (RuntimeException re) {
  780. LogUtil.errorLogInfo("", TAG, re);
  781. return false;
  782. }
  783. catch (Exception exc)
  784. {
  785. //exc.printStackTrace();
  786. LogUtil.errorLogInfo("", TAG, exc);
  787. return false;
  788. }
  789. }
  790. }
  791. public static void resetCurrentManualScreenID()
  792. {
  793. try
  794. {
  795. mCurrentManualScreenId = -1;
  796. } catch (RuntimeException re) {
  797. LogUtil.errorLogInfo("", TAG, re);
  798. }
  799. catch (Exception e)
  800. {
  801. Log.e(TAG, "[Exception] resetCurrentManualScreenID()");
  802. //e.printStackTrace();
  803. LogUtil.errorLogInfo("", TAG, e);
  804. }
  805. }
  806. public static void FinishManualActivity()
  807. {
  808. Log.i(TAG, "[FinishManualActivity]");
  809. try
  810. {
  811. if (mManualActivity != null)
  812. {
  813. mCurrentManualScreenId = -1;
  814. mManualActivity.finish();
  815. }
  816. }
  817. catch (RuntimeException re) {
  818. LogUtil.errorLogInfo("", TAG, re);
  819. }
  820. catch (Exception e)
  821. {
  822. Log.e(TAG, "[Exception] FinishManualActivity()");
  823. //e.printStackTrace();
  824. LogUtil.errorLogInfo("", TAG, e);
  825. }
  826. }
  827. /* ================================================================================================
  828. * [Popup Activity] Section
  829. ================================================================================================ */
  830. /**
  831. * Popup Activity 를 시작시킨다.
  832. *
  833. * @param ScreenId - 팝업시작시 Screen ID
  834. * @return (boolean) true : 성공, false : 실패
  835. */
  836. public boolean StartPopup(int ScreenId)
  837. {
  838. if(getPopupActivityRun() == true)
  839. {
  840. return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  841. }
  842. else
  843. {
  844. setPopupActivityRun(true);
  845. Intent intent = new Intent(mContext, PopupActivity.class);
  846. intent.putExtra("ScreenId", ScreenId);
  847. overridePendingTransition(0, 0);
  848. startActivityForResult(intent, 0);
  849. return true;
  850. }
  851. }
  852. /**
  853. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  854. *
  855. * @param ScreenId - 팝업시작시 Screen ID
  856. * @param data - 전달할 데이터
  857. * @return (boolean) true : 성공, false : 실패
  858. */
  859. public boolean StartPopup(int ScreenId, Intent data)
  860. {
  861. if(getPopupActivityRun() == true)
  862. {
  863. return false;
  864. }
  865. else
  866. {
  867. setPopupActivityRun(true);
  868. Intent intent = new Intent(mContext, PopupActivity.class);
  869. intent.putExtra("ScreenId", ScreenId);
  870. intent.putExtra("PopupScreenDataIntent", data);
  871. overridePendingTransition(0, 0);
  872. startActivityForResult(intent, 0);
  873. return true;
  874. }
  875. }
  876. /**
  877. * Activity Result Reception
  878. */
  879. @Override
  880. protected void onActivityResult(int requestCode, int resultCode, Intent data)
  881. {
  882. super.onActivityResult(requestCode, resultCode, data);
  883. Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@");
  884. if(resultCode == RESULT_OK)
  885. {
  886. try
  887. {
  888. // PopupActivity 에서 FinishTimer 로 인하여 종료가 되었을 경우
  889. // MainActivity 도 즉시 종료시킨다.
  890. String code = (String) data.getExtras().get("Finish_Kind");
  891. Log.d(TAG, "Finish_Kind : " + code);
  892. if(code.equals("FinishTimer") == true)
  893. {
  894. Log.d(TAG, "FinishTimer finish");
  895. finish();
  896. }
  897. }
  898. catch (RuntimeException re) {
  899. LogUtil.errorLogInfo("", TAG, re);
  900. }
  901. catch (Exception e)
  902. {
  903. Log.e(TAG, "[Exception Error] [onActivityResult] - data.getExtras().get");
  904. }
  905. }
  906. }
  907. /* ================================================================================================
  908. * [Screen] Section
  909. ================================================================================================ */
  910. /**
  911. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  912. * Override 사용하여 Screen 변경을 처리한다.<br>
  913. *
  914. * @param nScreenId - 변경할 Screen ID
  915. * @return (boolean) true : 성공, false : 실패
  916. */
  917. @Override
  918. protected boolean onChangeScreen(int nScreenId) {
  919. super.onChangeScreen(nScreenId);
  920. return setChangeScreen(nScreenId, false);
  921. }
  922. /**
  923. * Screen 등록자<br>
  924. * ScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  925. *
  926. * @param nScreenId - 변경할 Screen ID
  927. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  928. * @return (boolean) true : 성공, false : 실패
  929. */
  930. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove)
  931. {
  932. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId
  933. + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  934. // 1. 현재 Layout 삭제
  935. if(mCurrentScreenId > 0)
  936. {
  937. ScreenLayout.removeAllViews();
  938. super.setCurrentScreen(null);
  939. }
  940. if(OnlyRemove) return true;
  941. mCurrentScreenId = nScreenId;
  942. setTopBackBtnVisible(false);
  943. // 2. 새로운 Layout 표시
  944. try
  945. {
  946. switch(nScreenId)
  947. {
  948. /**
  949. * [수정필요]
  950. * Back Button 필요한 화면은 setTopBackBtnVisible(true) 호출 필요
  951. * 추가 또는 수정해야할 부분 1. - 스크린 별 layout 생성
  952. * **/
  953. case API_Menu.SubMenuEnergy.RemoteMeter:
  954. SetTitleText(API_Menu.SubMenuEnergy.Name_RemoteMeter);
  955. remoteMeterMainScreen = new RemoteMeterMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  956. super.setCurrentScreen(remoteMeterMainScreen);
  957. break;
  958. case API_Menu.SubMenuEnergy.EnergyMgr:
  959. SetTitleText(API_Menu.SubMenuEnergy.Name_EnergyMgr);
  960. icEnergyMgrScreen= new IcEnergyMgrScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  961. super.setCurrentScreen(icEnergyMgrScreen);
  962. break;
  963. case API_Menu.SubMenuEnergy.CostTable:
  964. SetTitleText(API_Menu.SubMenuEnergy.Name_CostTable);
  965. remoteMeterCostTableScreen= new RemoteMeterCostTableScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  966. super.setCurrentScreen(remoteMeterCostTableScreen);
  967. break;
  968. case API_Menu.SubMenuEnergy.EachRoomEnergy:
  969. SetTitleText(API_Menu.SubMenuEnergy.Name_EachRoomEnergy);
  970. eachRoomEnergyDetailScreen = new EachRoomEnergyDetailScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList);
  971. super.setCurrentScreen(eachRoomEnergyDetailScreen);
  972. break;
  973. case API_Menu.SubMenuEnergy.SmartPanel:
  974. if (nIntegratedPowerCtrller == WallpadDeviceSet.POWERCONTROLLER_TYPE_DEFAULT) {
  975. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution);
  976. smartDisPanelScreen = new SmartDisPanelScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  977. super.setCurrentScreen(smartDisPanelScreen);
  978. }
  979. else if (nIntegratedPowerCtrller == WallpadDeviceSet.POWERCONTROLLER_TYPE_MEASURE) {
  980. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution);
  981. smartDisPanelScreen_01 = new SmartDisPanelScreen_01(this, ScreenLayout, wpapi, OPERATION_MODE);
  982. super.setCurrentScreen(smartDisPanelScreen_01);
  983. }
  984. else if (nIntegratedPowerCtrller == WallpadDeviceSet.POWERCONTROLLER_TYPE_DIRECT) {
  985. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution);
  986. smartDisPanelScreen_02 = new SmartDisPanelScreen_02(this, ScreenLayout, wpapi, OPERATION_MODE);
  987. super.setCurrentScreen(smartDisPanelScreen_02);
  988. }
  989. else {
  990. // 설정값이 없는 경우에는 기본화면을 출력한다.
  991. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartDistribution);
  992. smartDisPanelScreen = new SmartDisPanelScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  993. super.setCurrentScreen(smartDisPanelScreen);
  994. Log.w(TAG, "[setChangeScreen] API_Menu.SubMenuEnergy.SmartPanel -> Not supported type : nIntegratedPowerCtrller -> " + nIntegratedPowerCtrller);
  995. }
  996. break;
  997. case API_Menu.SubMenuEnergy.SmartOutlet:
  998. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartConcent);
  999. smartConcentScreen = new SmartConcentScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light, false);
  1000. super.setCurrentScreen(smartConcentScreen);
  1001. break;
  1002. case API_Menu.SubMenuEnergy.SmartLight:
  1003. SetTitleText(API_Menu.SubMenuEnergy.Name_SmartLight);
  1004. smartLightScreen = new SmartLightScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light, false);
  1005. super.setCurrentScreen(smartLightScreen);
  1006. break;
  1007. default:
  1008. Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  1009. mCurrentScreenId = -1;
  1010. return false;
  1011. }
  1012. }
  1013. catch (RuntimeException re) {
  1014. LogUtil.errorLogInfo("", TAG, re);
  1015. return false;
  1016. }
  1017. catch (Exception e)
  1018. {
  1019. Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e);
  1020. //e.printStackTrace();
  1021. LogUtil.errorLogInfo("", TAG, e);
  1022. return false;
  1023. }
  1024. return true;
  1025. }
  1026. /**
  1027. * 상단 타이틀 텍스트 수정
  1028. * @param SetText 수정할 타이틀 이름
  1029. * **/
  1030. private void SetTitleText(String SetText)
  1031. {
  1032. if(SetText != null)
  1033. {
  1034. TopTitle.setText(SetText);
  1035. }
  1036. }
  1037. /* ================================================================================================
  1038. * [Menu Layout] Section
  1039. ================================================================================================ */
  1040. /**
  1041. * 메뉴 레이아웃 생성
  1042. * **/
  1043. private void OpenMenuLayout()
  1044. {
  1045. if(MenuOpen == true)
  1046. {
  1047. Log.d(TAG, "MenuOpen == true");
  1048. return;
  1049. }
  1050. if(menueListDataClass == null)
  1051. {
  1052. Log.d(TAG, "menueListDataClass = null");
  1053. return;
  1054. }
  1055. //0. 현재 ID 및 리스트 불러오기
  1056. String Title = API_Menu.GetGroupNameByID((mCurrentScreenId / 1000) * 1000);
  1057. //Log.i(TAG, "[OpenMenuLayout] - API_Menu title = " + Title);
  1058. String TempChildName = null;
  1059. int ChooseGroup = 0;
  1060. int ChooseChild = 0;
  1061. for(int i =0; i< menueListDataClass.arrayGroup.size(); i++)
  1062. {
  1063. if(menueListDataClass.arrayGroup.get(i).equals(Title))
  1064. {
  1065. //Log.i(TAG, "arrayGroup[" + i + "] = " + menueListDataClass.arrayGroup.get(i));
  1066. ChooseGroup = i;
  1067. break;
  1068. }
  1069. }
  1070. //Log.i(TAG, "[OpenMenuLayout] - ChooseGroup = " + ChooseGroup);
  1071. //Log.i(TAG, "mCurrentScreenId = " + mCurrentScreenId);
  1072. for(int i = 0; i< menueListDataClass.idMappingTable.length; i++)
  1073. {
  1074. //Log.i(TAG, "[OpenMenuLayout] - menueListDataClass.idMappingTable[i].Id = " + menueListDataClass.idMappingTable[i].Id);
  1075. if (menueListDataClass.idMappingTable[i].Id == mCurrentScreenId)
  1076. {
  1077. TempChildName = menueListDataClass.idMappingTable[i].Name;
  1078. //Log.i(TAG, "[OpenMenuLayout] - Same ChildName = " + TempChildName);
  1079. break;
  1080. }
  1081. }
  1082. if(TempChildName == null)
  1083. {
  1084. Log.i(TAG, "[OpenMenuLayout] - TempChildName == null");
  1085. return;
  1086. }
  1087. //Log.i(TAG, "[OpenMenuLayout] - TempChildName = " + TempChildName);
  1088. try
  1089. {
  1090. for(int i = 0; i< menueListDataClass.arrayChild.get(Title).size(); i++)
  1091. {
  1092. if(menueListDataClass.arrayChild.get(Title).get(i).equals(TempChildName) == true)
  1093. {
  1094. ChooseChild = i;
  1095. break;
  1096. }
  1097. }
  1098. }
  1099. catch (RuntimeException re) {
  1100. LogUtil.errorLogInfo("", TAG, re);
  1101. }
  1102. catch (Exception e)
  1103. {
  1104. //e.printStackTrace();
  1105. LogUtil.errorLogInfo("", TAG, e);
  1106. }
  1107. //Log.i(TAG, "[OpenMenuLayout] - ChooseChild = " + ChooseChild);
  1108. //1. 기존 화면 투명도 변경
  1109. TopLayout.setAlpha(0.5f);
  1110. ScreenLayout.setAlpha(0.5f);
  1111. //2. Layout 생성 및 처리 이벤트 등록
  1112. MenuLayout = new RelativeLayout(this);
  1113. WpadUtil.LayoutRegistration(AllLayout, MenuLayout, 1280, 800, 0, 0, ID.main.layout.MENU);
  1114. MenuLayout.setOnTouchListener(new Button.OnTouchListener()
  1115. {
  1116. @Override
  1117. public boolean onTouch(View v, MotionEvent event)
  1118. {
  1119. if (event.getAction() == MotionEvent.ACTION_UP)
  1120. {
  1121. setFinishTimerReset();
  1122. CloseMenuLayout();
  1123. }
  1124. return true;
  1125. }
  1126. });
  1127. //3. 배경 이미지 생성 및 에니메이션 등록
  1128. MenuBackground = new WpadImageView(this, TOUCH_KIND.BUTTON, 460, 800, R.drawable.bg_menu, R.drawable.bg_menu, ID.main.image.TAB_BACKGROUND);
  1129. TranslateAnimation anim = new TranslateAnimation(WpadScale.getWidth(-460), 0, 0, 0);
  1130. anim.setDuration(200);
  1131. anim.setInterpolator(new AccelerateInterpolator());
  1132. MenuLayout.setAnimation(anim);
  1133. ViewRegistration(MenuLayout, MenuBackground, 0, 0);
  1134. //4. 타이틀 등록
  1135. MenuTitle = new WpadTextView(this, false, 247, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE);
  1136. ViewRegistration(MenuLayout, MenuTitle, 133, 15);
  1137. MenuTitle.setText(Title);
  1138. //5. 종료 버튼 등록
  1139. 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);
  1140. MenuClose.setTouchDelayMs(1000);
  1141. ViewRegistration(MenuLayout, MenuClose, 380, 15);
  1142. //6. 리스트뷰 초기화 및 등록
  1143. mListView = new ExpandableListView(this);
  1144. ExpandableListView.LayoutParams params = new ExpandableListView.LayoutParams(WpadScale.getWidth(460), WpadScale.getHeight(690));
  1145. mListView.setLayoutParams(params);
  1146. mListView.setX(WpadScale.getWidth(0));
  1147. mListView.setY(WpadScale.getHeight(112));
  1148. mListView.setBackgroundColor(Color.BLACK);
  1149. mListView.setId(ID.main.liveview.lv);
  1150. mListView.setGroupIndicator(null);
  1151. mListView.setDividerHeight(0);
  1152. mListView.setDivider(null);
  1153. mListView.setFocusable(true);
  1154. mListView.setSmoothScrollbarEnabled(true);
  1155. mListView.setTranscriptMode(android.widget.AbsListView.TRANSCRIPT_MODE_DISABLED);
  1156. mListView.setScrollbarFadingEnabled(true);
  1157. MenuLayout.addView(mListView);
  1158. adptMain = new Menu_AdptMain(this, menueListDataClass.arrayGroup, menueListDataClass.arrayChild, ChooseGroup, ChooseChild);
  1159. mListView.setAdapter(adptMain);
  1160. //7. 선택된 그룹 열기
  1161. mListView.setSelectedGroup(ChooseGroup);
  1162. mListView.expandGroup(ChooseGroup);
  1163. // 8. 리스트뷰 터치 이벤트 등록
  1164. mListView.setOnTouchListener(new OnTouchListener(){
  1165. @Override
  1166. public boolean onTouch(View v, MotionEvent event)
  1167. {
  1168. if((event.getAction() == MotionEvent.ACTION_DOWN) ||
  1169. (event.getAction() == MotionEvent.ACTION_UP))
  1170. {
  1171. WpadActivity.setFinishTimerReset();
  1172. }
  1173. return false;
  1174. }});
  1175. // 9. 그룹 터치 이벤트 등록
  1176. mListView.setOnGroupClickListener(new OnGroupClickListener()
  1177. {
  1178. @Override
  1179. public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id)
  1180. {
  1181. DebugLogOutput("group click = " + groupPosition);
  1182. WpadActivity.setFinishTimerReset();
  1183. return false;
  1184. }
  1185. });
  1186. // 10. 차일드 터치 이벤트 등록
  1187. /*
  1188. mListView.setOnChildClickListener(new OnChildClickListener()
  1189. {
  1190. @Override
  1191. public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
  1192. {
  1193. DebugLogOutput("onChildClick");
  1194. DebugLogOutput("groupPosition = " + groupPosition);
  1195. DebugLogOutput("childPosition = " + childPosition);
  1196. WpadActivity.setFinishTimerReset();
  1197. return false;
  1198. }
  1199. });
  1200. */
  1201. // 11. 그룹 열리는 경우 이벤트
  1202. mListView.setOnGroupExpandListener(new OnGroupExpandListener()
  1203. {
  1204. @Override
  1205. public void onGroupExpand(int groupPosition)
  1206. {
  1207. DebugLogOutput("groupPosition Open Event = " + groupPosition);
  1208. Sound().Play(SND.effect.TOUCH_LATCHED);
  1209. WpadActivity.setFinishTimerReset();
  1210. }
  1211. });
  1212. // 12. 그룹 닫히는 경우 이벤트
  1213. mListView.setOnGroupCollapseListener(new OnGroupCollapseListener()
  1214. {
  1215. @Override
  1216. public void onGroupCollapse(int groupPosition)
  1217. {
  1218. DebugLogOutput("groupPosition Close Event = " + groupPosition);
  1219. Sound().Play(SND.effect.TOUCH_LATCHED);
  1220. WpadActivity.setFinishTimerReset();
  1221. }
  1222. });
  1223. // 13. MenuOpen True 설정
  1224. MenuOpen = true;
  1225. }
  1226. /**
  1227. * 메뉴 layout 닫힘 처리
  1228. * **/
  1229. private void CloseMenuLayout()
  1230. {
  1231. if(MenuOpen == false)
  1232. {
  1233. return;
  1234. }
  1235. TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0);
  1236. anim.setDuration(200);
  1237. anim.setInterpolator(new AccelerateInterpolator());
  1238. anim.setAnimationListener(new AnimationListener()
  1239. {
  1240. @Override
  1241. public void onAnimationStart(Animation animation)
  1242. {
  1243. MenuOpen = false;
  1244. }
  1245. @Override
  1246. public void onAnimationRepeat(Animation animation)
  1247. {
  1248. }
  1249. @Override
  1250. public void onAnimationEnd(Animation animation)
  1251. {
  1252. AllLayout.removeView(MenuLayout);
  1253. TopLayout.setAlpha(1.0f);
  1254. ScreenLayout.setAlpha(1.0f);
  1255. }
  1256. });
  1257. MenuLayout.startAnimation(anim);
  1258. }
  1259. /**
  1260. * 메뉴 그룹 터치시 처리 (Menu_AdptMain에서 호출)
  1261. * **/
  1262. public static void SetListViewGroupExpand_Collapse(int GroupID, boolean ExpandEnable)
  1263. {
  1264. if(ExpandEnable == true)
  1265. {
  1266. mListView.expandGroup(GroupID);
  1267. }
  1268. else
  1269. {
  1270. mListView.collapseGroup(GroupID);
  1271. }
  1272. }
  1273. /**
  1274. * Menu정보가 DB에 없을 경우 불러올 스크린 로딩
  1275. * @return MenuListDataClass 타입의 초기정보
  1276. * **/
  1277. private MenuListDataClass LoadDefaultMenuList()
  1278. {
  1279. MenuListDataClass Temp_menueListDataClass = new MenuListDataClass();
  1280. Temp_menueListDataClass.SetArrayGroup(API_Menu.SubMenuEnergy.Name);
  1281. ArrayList<String> arrayList = new ArrayList<String>();
  1282. int ChildCount = 0;
  1283. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  1284. int[] realUse = devset.Get_RealTimeMetor_Info();
  1285. boolean remoteMeterUse = devset.Get_RemoteMeter_Use();
  1286. int nDistributionPanelType = devset.Get_DistributionPannelType_Info();
  1287. devset.closeDB();
  1288. //[수정필요]
  1289. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작)
  1290. if(remoteMeterUse == true)
  1291. {
  1292. Log.i(TAG, "[LoadDefaultMenuList] - RemoteMeter Screen ADD ~~~");
  1293. arrayList.add(API_Menu.SubMenuEnergy.Name_RemoteMeter); ChildCount++;
  1294. if(Version.getModelType() != Version.MODEL_TYPE.IHN_1010GL_I_2443ALT)
  1295. {
  1296. arrayList.add(API_Menu.SubMenuEnergy.Name_EnergyMgr); ChildCount++;
  1297. }
  1298. }
  1299. /*if(realUse[0] == 1)
  1300. {
  1301. Log.i(TAG, "[LoadDefaultMenuList] - EnergyValue Screen ADD ~~~");
  1302. arrayList.add(API_Menu.SubMenuEnergy.Name_EnergyMgr); ChildCount++;
  1303. }*/
  1304. //arrayList.add(API_Menu.SubMenuEnergy.Name_CostTable); ChildCount++;
  1305. //arrayList.add(API_Menu.SubMenuEnergy.Name_EachRoomEnergy); ChildCount++;
  1306. //if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101)
  1307. if(nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST)
  1308. {
  1309. arrayList.add(API_Menu.SubMenuEnergy.Name_SmartDistribution); ChildCount++;
  1310. arrayList.add(API_Menu.SubMenuEnergy.Name_SmartConcent); ChildCount++;
  1311. arrayList.add(API_Menu.SubMenuEnergy.Name_SmartLight); ChildCount++;
  1312. }
  1313. Log.i(TAG, "[LoadDefaultMenuList] - ChildCount : " + ChildCount);
  1314. //Log.i(TAG, "[LoadDefaultMenuList] - childCount = " + ChildCount);
  1315. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝)
  1316. Temp_menueListDataClass.SetArrayChild(API_Menu.SubMenuEnergy.Name, arrayList);
  1317. Temp_menueListDataClass.idMappingTable = new ChildIDMapping[ChildCount];
  1318. for (int i = 0; i < ChildCount; i++)
  1319. {
  1320. Temp_menueListDataClass.idMappingTable[i] = new ChildIDMapping();
  1321. //[수정필요]
  1322. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 ID를 임의로 입력(시작)
  1323. if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_RemoteMeter) == true)
  1324. {
  1325. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.RemoteMeter;
  1326. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_RemoteMeter;
  1327. }
  1328. else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_EnergyMgr) == true)
  1329. {
  1330. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.EnergyMgr;
  1331. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_EnergyMgr;
  1332. }
  1333. else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_CostTable) == true)
  1334. {
  1335. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.CostTable;
  1336. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_CostTable;
  1337. }
  1338. else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_EachRoomEnergy) == true)
  1339. {
  1340. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.EachRoomEnergy;
  1341. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_EachRoomEnergy;
  1342. }
  1343. else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_SmartDistribution) == true)
  1344. {
  1345. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.SmartPanel;
  1346. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_SmartDistribution;
  1347. }
  1348. else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_SmartConcent) == true)
  1349. {
  1350. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.SmartOutlet;
  1351. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_SmartConcent;
  1352. }
  1353. else if(arrayList.get(i).equals(API_Menu.SubMenuEnergy.Name_SmartLight) == true)
  1354. {
  1355. Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuEnergy.SmartLight;
  1356. Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuEnergy.Name_SmartLight;
  1357. }
  1358. //Log.i(TAG, "[LoadDefaultMenuList] - idMappingTable.id[" + i + "] = " + Temp_menueListDataClass.idMappingTable[i].Id);
  1359. //Log.i(TAG, "[LoadDefaultMenuList] - idMappingTable.Name[" + i + "] = " + Temp_menueListDataClass.idMappingTable[i].Name);
  1360. }
  1361. return Temp_menueListDataClass;
  1362. }
  1363. /**
  1364. * DB 에서 룸이름 정보를 가져온다.
  1365. *
  1366. * @return (String []) null - 실패, not null
  1367. */
  1368. private String[] getRoomNamefromDB() {
  1369. try {
  1370. WallpadStatusData wallpadStatusData = new WallpadStatusData(getContext().getApplicationContext());
  1371. String[] RoomNameList = wallpadStatusData.GetDevRoomName();
  1372. wallpadStatusData.closeDB();
  1373. if (RoomNameList == null) {
  1374. Log.e(TAG, "[getRoomNamefromDB] - RoomNameList is null !!!");
  1375. return null;
  1376. }
  1377. if (RoomNameList.length != 6) {
  1378. Log.e(TAG, "[getRoomNamefromDB] - RoomNameList.length Not Match (" + RoomNameList.length + ")");
  1379. return null;
  1380. }
  1381. if (DEBUG_LOG_ON) {
  1382. for (int i = 0; i < RoomNameList.length; i++) DebugLogOutput("[getRoomNamefromDB] RoomNameList[" + i + "] = " + RoomNameList[i]);
  1383. }
  1384. //{ "거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  1385. //RoomNameList += {"방5", "방6", "방7", "방8"};
  1386. String[] retRoomNameList = new String[10];
  1387. for (int i = 0; i < retRoomNameList.length; i++) {
  1388. if (i < 6) {
  1389. if (i < 1) retRoomNameList[i] = RoomNameList[i];
  1390. else if (i == 1) retRoomNameList[i] = "주방"; // 난방 기준의 방명칭 설정을 조명/콘센트에 적용시에는 두번째에 주방을 추가한다. 이는 추후 방명칭 입력단계부터 개선해야 함
  1391. else retRoomNameList[i] = RoomNameList[i - 1];
  1392. }
  1393. else {
  1394. retRoomNameList[i] = mDefaultRoomNameList[i];
  1395. }
  1396. }
  1397. for (int i = 0; i < retRoomNameList.length; i++) DebugLogOutput("[getRoomNamefromDB] retRoomNameList[" + i + "] = " + retRoomNameList[i]);
  1398. return retRoomNameList;
  1399. } catch (RuntimeException re) {
  1400. LogUtil.errorLogInfo("", TAG, re);
  1401. }
  1402. catch (Exception e) {
  1403. Log.e(TAG, "[Exception] getRoomNamefromDB()");
  1404. //e.printStackTrace();
  1405. LogUtil.errorLogInfo("", TAG, e);
  1406. }
  1407. return null;
  1408. }
  1409. /**
  1410. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  1411. *
  1412. * @param Device - int
  1413. * @return (String []) null - 실패, not null
  1414. */
  1415. private String[] getRoomNamefromDB(int Device)
  1416. {
  1417. try
  1418. {
  1419. String[] RoomNameList = null;
  1420. WallpadStatusData wallpadStatusData = new WallpadStatusData(getContext().getApplicationContext());
  1421. if (Device == HEATING)
  1422. {
  1423. RoomNameList = wallpadStatusData.GetDevRoomName("heating");
  1424. } else
  1425. {
  1426. RoomNameList = wallpadStatusData.GetDevRoomName("light");
  1427. }
  1428. wallpadStatusData.closeDB();
  1429. if (RoomNameList == null)
  1430. {
  1431. Log.e(TAG, "[DB_GetRoomName] - RoomNameList is null !!!");
  1432. return null;
  1433. }
  1434. if (RoomNameList.length != 6)
  1435. {
  1436. Log.e(TAG, "[DB_GetRoomName] - RoomNameList.length Not Match (" + RoomNameList.length + ")");
  1437. return null;
  1438. }
  1439. if (DEBUG_LOG_ON)
  1440. {
  1441. for (int i = 0; i < RoomNameList.length; i++)
  1442. DebugLogOutput("RoomNameList[" + i + "] " + RoomNameList[i]);
  1443. }
  1444. return RoomNameList;
  1445. } catch (RuntimeException re) {
  1446. LogUtil.errorLogInfo("", TAG, re);
  1447. }
  1448. catch (Exception e)
  1449. {
  1450. Log.e(TAG, "[DB_GetRoomName] [ExceptionError] : " + e);
  1451. //e.printStackTrace();
  1452. LogUtil.errorLogInfo("", TAG, e);
  1453. }
  1454. return null;
  1455. }
  1456. /**
  1457. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  1458. **/
  1459. private void GetRoomName() {
  1460. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getContext().getApplicationContext());
  1461. boolean UseEachRoomName = wallpadDeviceSet.GetEachRoomNameInfo();
  1462. wallpadDeviceSet.closeDB();
  1463. Log.i(TAG, "[GetRoomName] UseEachRoomName [" + UseEachRoomName + "]");
  1464. if (UseEachRoomName == false) {
  1465. // 명칭 통합사용
  1466. mRoomNameList_Light = getRoomNamefromDB();
  1467. if (mRoomNameList_Light == null) {
  1468. mRoomNameList_Light = mDefaultRoomNameList;
  1469. }
  1470. }
  1471. else {
  1472. // 명칭 난방, 조명 분리 사용
  1473. mRoomNameList_Light = getRoomNamefromDB(LIGHT);
  1474. if (mRoomNameList_Light == null) {
  1475. mRoomNameList_Light = mDefaultRoomNameList_Light;
  1476. }
  1477. }
  1478. }
  1479. /**
  1480. * Menu Event intent filter 등록
  1481. **/
  1482. private void reg_Receiver()
  1483. {
  1484. try
  1485. {
  1486. IntentFilter filter = new IntentFilter();
  1487. filter.addAction("MENU_EVENT");
  1488. registerReceiver(mWallPadAlertBR, filter);
  1489. filter = new IntentFilter();
  1490. filter.addAction(define.NOTIFY_DAIL);
  1491. filter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH");
  1492. registerReceiver(mWallPadJogBR, filter);
  1493. }
  1494. catch (RuntimeException re) {
  1495. LogUtil.errorLogInfo("", TAG, re);
  1496. }
  1497. catch (Exception e)
  1498. {
  1499. //e.printStackTrace();
  1500. LogUtil.errorLogInfo("", TAG, e);
  1501. }
  1502. }
  1503. /**
  1504. * 조그버튼 입력 받을 시 처리
  1505. **/
  1506. BroadcastReceiver mWallPadJogBR = new BroadcastReceiver()
  1507. {
  1508. @Override
  1509. public void onReceive(Context context, Intent intent)
  1510. {
  1511. WpadActivity.setFinishTimerReset();
  1512. }
  1513. };
  1514. /**
  1515. * 메뉴에서 버튼 터치 처리
  1516. * **/
  1517. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver()
  1518. {
  1519. @Override
  1520. public void onReceive(Context context, Intent intent)
  1521. {
  1522. int groupPosition = intent.getIntExtra("groupPosition", -1);
  1523. int childPosition = intent.getIntExtra("childPosition", -1);
  1524. Log.i(TAG, "groupPosition :" +groupPosition + ", childPosition :" + childPosition);
  1525. if((groupPosition >= 0) && (childPosition >= 0))
  1526. {
  1527. if(MenuOpen == true)
  1528. {
  1529. Sound().Play(SND.effect.TOUCH_LATCHED);
  1530. CloseMenuLayout();
  1531. if(menueListDataClass == null)
  1532. {
  1533. return;
  1534. }
  1535. String childName = menueListDataClass.arrayChild.get(menueListDataClass.arrayGroup.get(groupPosition)).get(childPosition);
  1536. for (int i = 0; i < menueListDataClass.idMappingTable.length; i++)
  1537. {
  1538. if(menueListDataClass.idMappingTable[i].Name.equals(childName) == true)
  1539. {
  1540. API_Menu api_Menu = new API_Menu();
  1541. int TempID = api_Menu.GetMyGroupID(getApplicationContext().getPackageName());
  1542. int ChildID = menueListDataClass.idMappingTable[i].Id;
  1543. int ChildGroupID = (ChildID / 1000) * 1000;
  1544. Log.i(TAG, "Child ID :" + ChildID);
  1545. if(TempID == 0)
  1546. {
  1547. return;
  1548. }
  1549. if(ChildGroupID == TempID)
  1550. {
  1551. //해당 APP내에서 스크린 전환 필요
  1552. //[수정필요]
  1553. boolean result = setChangeScreen(ChildID, false);
  1554. setBackBtnSmartDistVisible(false);
  1555. if(result == false)
  1556. {
  1557. setChangeScreen(API_Menu.SubMenuEnergy.RemoteMeter, false);
  1558. }
  1559. WpadActivity.setFinishTimerReset();
  1560. }
  1561. else
  1562. {
  1563. //외부 앱 호출 후, 본 APP Finish 필요
  1564. api_Menu.startSubScreenActivity(getApplicationContext(),
  1565. menueListDataClass.idMappingTable[i].Id, API_Menu.MENU_START_OPTION_1, api_Menu.GetAPK_Name_ByID(ChildGroupID));
  1566. Intent mIntent = new Intent();
  1567. mIntent.putExtra("Finish_Kind", "HomeButton");
  1568. MainActivity.this.setResult(RESULT_OK, mIntent);
  1569. finish();
  1570. }
  1571. break;
  1572. }
  1573. }
  1574. }
  1575. }
  1576. }
  1577. };
  1578. /**
  1579. * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
  1580. *
  1581. * @param code - (int) 송신할 keycode
  1582. * @return (int) - >=0 : 성공, <0 : 실패
  1583. */
  1584. private int setSendEventBR(int code)
  1585. {
  1586. try
  1587. {
  1588. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code);
  1589. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  1590. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  1591. intent.putExtra("keycode",code);
  1592. getContext().sendBroadcast(intent);
  1593. }
  1594. catch (RuntimeException re) {
  1595. LogUtil.errorLogInfo("", TAG, re);
  1596. return -100;
  1597. }
  1598. catch (Exception e)
  1599. {
  1600. Log.e(TAG, "[setSendEventBR] - [Exception Error] code:" + code);
  1601. //e.printStackTrace();
  1602. LogUtil.errorLogInfo("", TAG, e);
  1603. return -100;
  1604. }
  1605. return 0;
  1606. }
  1607. /**
  1608. * 간편모드 UX 사용여부를 반환한다.
  1609. * @return TRUE일 경우 간편모드 UX 사용
  1610. */
  1611. public boolean GetEasyModeUXUse() {
  1612. try {
  1613. WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext);
  1614. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  1615. deviceSet.closeDB();
  1616. WallpadStatusData data = new WallpadStatusData(mContext);
  1617. boolean bUse = data.GetEasyModeUxUse();
  1618. data.closeDB();
  1619. Log.d(TAG, "[GetEasyModeUXUse] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  1620. return bSupport & bUse;
  1621. } catch (RuntimeException re) {
  1622. LogUtil.errorLogInfo("", TAG, re);
  1623. }
  1624. catch (Exception e) {
  1625. Log.e(TAG, "[Exception] GetEasyModeUXUse()");
  1626. //e.printStackTrace();
  1627. LogUtil.errorLogInfo("", TAG, e);
  1628. }
  1629. return false;
  1630. }
  1631. /**
  1632. * 통합전력제어기 종류를 확인한다.
  1633. * POWERCONTROLLER_TYPE_NONE = 110; // 사용안함
  1634. * POWERCONTROLLER_TYPE_DEFAULT = 111; // 기본
  1635. * POWERCONTROLLER_TYPE_DIRECT = 112 // 직결보드
  1636. * POWERCONTROLLER_TYPE_MEASURE = 113 // 전력측정직결보드
  1637. */
  1638. int nIntegratedPowerCtrller = WallpadDeviceSet.POWERCONTROLLER_TYPE_NONE;
  1639. public int getIntegratedPowerCtrllerType() {
  1640. try {
  1641. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  1642. nIntegratedPowerCtrller = mWallpadDeviceSet.Get_PowerControllerType_Info();
  1643. mWallpadDeviceSet.closeDB();
  1644. Log.d(TAG, "[getIntegratedPowerCtrllerType] nIntegratedPowerCtrller [" + nIntegratedPowerCtrller + "]");
  1645. return nIntegratedPowerCtrller;
  1646. } catch (RuntimeException re) {
  1647. LogUtil.errorLogInfo("", TAG, re);
  1648. return WallpadDeviceSet.POWERCONTROLLER_TYPE_NONE;
  1649. }
  1650. catch (Exception e) {
  1651. Log.e(TAG, "[Exception] getIntegratedPowerCtrllerType()");
  1652. //e.printStackTrace();
  1653. LogUtil.errorLogInfo("", TAG, e);
  1654. return WallpadDeviceSet.POWERCONTROLLER_TYPE_NONE;
  1655. }
  1656. }
  1657. }