MainActivity.java 131 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585
  1. package kr.co.icontrols.wallpadhomectrl;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.graphics.Color;
  9. import android.os.Bundle;
  10. import android.os.CountDownTimer;
  11. import android.os.Handler;
  12. import android.os.Message;
  13. import android.os.PowerManager;
  14. import android.util.Log;
  15. import android.view.Gravity;
  16. import android.view.KeyEvent;
  17. import android.view.MotionEvent;
  18. import android.view.View;
  19. import android.view.View.OnTouchListener;
  20. import android.view.animation.AccelerateInterpolator;
  21. import android.view.animation.Animation;
  22. import android.view.animation.Animation.AnimationListener;
  23. import android.view.animation.TranslateAnimation;
  24. import android.widget.ExpandableListView;
  25. import android.widget.ExpandableListView.OnGroupClickListener;
  26. import android.widget.ExpandableListView.OnGroupCollapseListener;
  27. import android.widget.ExpandableListView.OnGroupExpandListener;
  28. import android.widget.RelativeLayout;
  29. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  30. import com.artncore.WallPadDataMgr.WallpadStatusData;
  31. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  32. import com.artncore.commons.API_Menu;
  33. import com.artncore.commons.API_Menu.MenuListDataClass;
  34. import com.artncore.commons.API_Menu.MenuListDataClass.ChildIDMapping;
  35. import com.artncore.commons.DataClasses;
  36. import com.artncore.commons.define;
  37. import com.artncore.wallpadapi.KnxVentiAPI;
  38. import com.artncore.wallpadapi.LedDimmingKCC_API;
  39. import com.artncore.wallpadapi.MultiSwitchAPI;
  40. import com.artncore.wallpadapi.VentiAPI;
  41. import com.artncore.wallpadapi.WallPadAPI;
  42. import com.util.LogUtil;
  43. import org.json.JSONException;
  44. import org.json.JSONObject;
  45. import java.io.ObjectInputStream;
  46. import java.io.ObjectOutputStream;
  47. import java.net.InetSocketAddress;
  48. import java.net.Socket;
  49. import java.sql.Timestamp;
  50. import java.text.SimpleDateFormat;
  51. import java.util.ArrayList;
  52. import java.util.List;
  53. import kr.co.icontrols.v40ioctl.V40IF;
  54. import kr.co.icontrols.wallpadhomectrl.declare.Common;
  55. import kr.co.icontrols.wallpadhomectrl.declare.ID;
  56. import kr.co.icontrols.wallpadhomectrl.screen.screen_aircon.SystemAirconMainScreen;
  57. import kr.co.icontrols.wallpadhomectrl.screen.screen_multi.HeatingV2TestScreen;
  58. import kr.co.icontrols.wallpadhomectrl.screen.screen_multi.HybridCookTopTestScreen;
  59. import kr.co.icontrols.wallpadhomectrl.screen.screen_multi.LightKnxMainTestScreen;
  60. import kr.co.icontrols.wallpadhomectrl.screen.screen_multi.ParkingDoorMainScreen;
  61. import kr.co.icontrols.wallpadhomectrl.screen.screen_multi.SystemAirconTestScreen;
  62. import kr.co.icontrols.wallpadhomectrl.screen.screen_airquality.AirQualityMainScreen;
  63. import kr.co.icontrols.wallpadhomectrl.screen.screen_airquality.DustInfoScreen;
  64. import kr.co.icontrols.wallpadhomectrl.screen.screen_concent.ConcentHdcNEachMainScreen;
  65. import kr.co.icontrols.wallpadhomectrl.screen.screen_concent.ConcentKnxMainScreen;
  66. import kr.co.icontrols.wallpadhomectrl.screen.screen_concent.ConcentMainScreen;
  67. import kr.co.icontrols.wallpadhomectrl.screen.screen_doorlock.DoorLockMainScreen;
  68. import kr.co.icontrols.wallpadhomectrl.screen.screen_elecrange.ElectricRangeMainScreen;
  69. import kr.co.icontrols.wallpadhomectrl.screen.screen_gas.CookTopConcentMainScreen;
  70. import kr.co.icontrols.wallpadhomectrl.screen.screen_gas.GasMainScreen;
  71. import kr.co.icontrols.wallpadhomectrl.screen.screen_gas.HybridCookTopMainScreen;
  72. import kr.co.icontrols.wallpadhomectrl.screen.screen_heating.HeatingV1MainScreen;
  73. import kr.co.icontrols.wallpadhomectrl.screen.screen_heating.HeatingV2MainScreen;
  74. import kr.co.icontrols.wallpadhomectrl.screen.screen_knx_venti.KnxVentiEasymodeScreen;
  75. import kr.co.icontrols.wallpadhomectrl.screen.screen_knx_venti.KnxVentiMainScreen;
  76. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightEtcEachMainScreen;
  77. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightEtcLivMainScreen;
  78. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightHdcLivConifgScreen;
  79. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightHdcLivKnxMainScreen;
  80. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightHdcLivMainScreen;
  81. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightHdcNEachMainScreen;
  82. import kr.co.icontrols.wallpadhomectrl.screen.screen_light.LightKnxMainScreen;
  83. import kr.co.icontrols.wallpadhomectrl.screen.screen_multi.VentilationMainTestScreen;
  84. import kr.co.icontrols.wallpadhomectrl.screen.screen_purity.PurityMainScreen;
  85. import kr.co.icontrols.wallpadhomectrl.screen.screen_venti.VentiEasymodeScreen;
  86. import kr.co.icontrols.wallpadhomectrl.screen.screen_venti.VentiMainScreen;
  87. import kr.co.icontrols.wallpadhomectrl.screen.screen_venti.VentilationMainScreen;
  88. import kr.co.icontrols.wallpadhomectrl.screen.screen_venti.VentilationModelMainScreen;
  89. import kr.co.icontrols.wallpadsupport.Version;
  90. import kr.co.icontrols.wallpadsupport.WpadActivity;
  91. import kr.co.icontrols.wallpadsupport.WpadImageView;
  92. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  93. import kr.co.icontrols.wallpadsupport.WpadScale;
  94. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  95. import kr.co.icontrols.wallpadsupport.WpadTextView;
  96. import kr.co.icontrols.wallpadsupport.WpadUtil;
  97. import static com.artncore.WallPadDataMgr.WallpadDeviceSet.DOORLOCK_TYPE_FINGERPRINT;
  98. import static com.artncore.WallPadDataMgr.WallpadDeviceSet.DOORLOCK_TYPE_NORMAL;
  99. import static com.artncore.WallPadDataMgr.WallpadDeviceSet.DOORLOCK_TYPE_RF;
  100. /**
  101. * @description 월패드 [설정기능] 메인화면 이다.<br>
  102. * 상단의 Top 메뉴, [홈] [돌아가기]<br>
  103. * 좌측의 Tab 메뉴, [환경설정] [화면청소] [비밀번호변경] ... 등 선택 메뉴<br>
  104. * 를 여기서 처리한다.
  105. */
  106. public class MainActivity extends WpadActivity {
  107. private final static String TAG = "MainActivity";
  108. private final boolean DEBUG_LOG_ON = true;
  109. private void DebugLogOutput(String s)
  110. {
  111. if (DEBUG_LOG_ON) Log.d(TAG, s);
  112. }
  113. // =================================================================================================
  114. // [[ Declaration ]] region
  115. // =================================================================================================
  116. protected Context mContext = null;
  117. public Context getContext()
  118. {
  119. return mContext;
  120. }
  121. private WallPadAPI wpapi = null;
  122. private int OPERATION_MODE = Common.MODE;
  123. private WallpadStatusData wdb = null;
  124. // Layout
  125. private RelativeLayout AllLayout; // 화면 전체
  126. private RelativeLayout TopLayout; // 상단 메뉴
  127. private RelativeLayout ScreenLayout; // 메인 화면
  128. private RelativeLayout MenuLayout; // 메뉴 화면
  129. // Top Menu
  130. private WpadImageView TopBackground;
  131. private WpadTextView TopTitle;
  132. private WpadImageView TopHomeBtn, TopBackBtn, TopMenuBtn, TopBoilerBtn;
  133. private WpadImageView MultiBtn[];
  134. private WpadImageView TopAirBackBtn, BTN_TOP_BACK_VENTIL;
  135. private WpadImageView TopDimmingBtn[];
  136. public static WpadImageView TopManualBtn;
  137. private WpadImageView Hide1Btn, Hide2Btn;
  138. // Main
  139. private WpadImageView ScreenBackground;
  140. // Menu
  141. private WpadImageView MenuBackground;
  142. private WpadImageView MenuClose;
  143. private WpadTextView MenuTitle;
  144. private static ExpandableListView mListView;
  145. private Menu_AdptMain adptMain;
  146. private MenuListDataClass menueListDataClass;
  147. private Menu mMenu = null; //WPadAPI의 Menu class
  148. private boolean MenuOpen = false;
  149. // HideMenu
  150. private int mHideMenuEntryStatus = 0;
  151. private static boolean mHideMenuOn = false;
  152. public static boolean getHideMenuOn() { return mHideMenuOn; }
  153. private CountDownTimer mHideMenuTimer = null;
  154. // PopupActivityRun
  155. private static boolean PopupActivityRun = false;
  156. public static boolean getPopupActivityRun()
  157. {
  158. return PopupActivityRun;
  159. }
  160. public static void setPopupActivityRun(boolean run)
  161. {
  162. PopupActivityRun = run;
  163. }
  164. // CurrentScreenId
  165. private int mCurrentScreenId = -1;
  166. private int mTempCurrentScreenId = -1;
  167. public static int mCurrentManualScreenId = -1;
  168. public static int mCurrentMultiScreenId = -1;
  169. // Screen
  170. private LightHdcLivMainScreen lightHdcLivMainScreen = null;
  171. private LightHdcLivKnxMainScreen lightHdcLivKnxMainScreen = null;
  172. private LightKnxMainScreen lightKnxMainScreen = null;
  173. private KnxVentiMainScreen KnxVentiMainScreen = null;
  174. private VentiMainScreen ventiMainScreen = null;
  175. private VentilationMainScreen ventilationMainScreen = null;
  176. private kr.co.icontrols.wallpadhomectrl.screen.screen_venti.VentilationModelMainScreen ventilationModelMainScreen = null;
  177. private KnxVentiMainScreen knxVentiMainScreen = null;
  178. private KnxVentiEasymodeScreen knxVentiEasymodeScreen= null;
  179. private VentiEasymodeScreen ventiEasymodeScreen= null;
  180. private GasMainScreen gasMainScreen = null;
  181. private DoorLockMainScreen doorLockMainScreen = null;
  182. private HeatingV2MainScreen heatingV2MainScreen = null;
  183. private HeatingV1MainScreen heatingV1MainScreen = null;
  184. private LightHdcLivConifgScreen lightHdcLivConifgScreen = null;
  185. private LightEtcEachMainScreen lightEtcEachMainScreen = null;
  186. private LightEtcLivMainScreen lightEtcLivMainScreen = null;
  187. private LightHdcNEachMainScreen lightHdcNEachMainScreen = null;
  188. private AirQualityMainScreen airQualityMainScreen = null;
  189. private DustInfoScreen dustInfoScreen = null;
  190. private ConcentMainScreen concentMainScreen = null;
  191. private ConcentKnxMainScreen concentKnxMainScreen = null;
  192. private HybridCookTopMainScreen hybridCookTopMainScreen = null;
  193. private ConcentHdcNEachMainScreen concentHdcNEachMainScreen = null;
  194. private ElectricRangeMainScreen electricRangeMainScreen = null;
  195. private CookTopConcentMainScreen cookTopConcentMainScreen = null;
  196. private SystemAirconMainScreen systemAirconMainScreen = null;
  197. private PurityMainScreen purityMainScreen = null;
  198. private ParkingDoorMainScreen parkingDoorMainScreen = null;
  199. //API
  200. public WallpadStatusData GetDBObj() {
  201. return wdb;
  202. }
  203. // 명칭 관련
  204. public static final int HEATING = 1;
  205. public static final int LIGHT = 2;
  206. private String[] mRoomNameList_Light = null; //조명 방 명칭
  207. private String[] mRoomNameList_Heating = null; //난방 방 명칭
  208. private String[] mDefaultRoomNameList = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  209. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  210. private String[] mDefaultRoomNameList_Light_SK = new String[]{"거실", "주방", "안방", "침실1", "침실2", "침실3", "침실4", "침실5", "침실6", "침실7", "침실8"};
  211. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  212. private String[] mDefaultRoomNameList_Heating_SK = new String[]{"거실", "안방", "침실1", "침실2", "침실3", "침실4", "침실5", "침실6", "침실7", "침실8"};
  213. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  214. private int[][] KCC_DimmBtnOffArray =
  215. {
  216. {R.drawable.btn_top_dimm_normal_off, R.drawable.btn_top_dimm_normal_pressed},
  217. {R.drawable.btn_top_dimm_study_off, R.drawable.btn_top_dimm_study_pressed},
  218. {R.drawable.btn_top_dimm_sensi_off, R.drawable.btn_top_dimm_sensi_pressed},
  219. {R.drawable.btn_top_dimm_rest_off, R.drawable.btn_top_dimm_rest_pressed}
  220. };
  221. private int[][] KCC_DimmBtnOnArray =
  222. {
  223. {R.drawable.btn_top_dimm_normal_selected, R.drawable.btn_top_dimm_normal_pressed},
  224. {R.drawable.btn_top_dimm_study_selected, R.drawable.btn_top_dimm_study_pressed},
  225. {R.drawable.btn_top_dimm_sensi_selected, R.drawable.btn_top_dimm_sensi_pressed},
  226. {R.drawable.btn_top_dimm_rest_selected, R.drawable.btn_top_dimm_rest_pressed},
  227. };
  228. private int[][] MultiBtnArray =
  229. {
  230. {R.drawable.tab_floor_1_normal, R.drawable.tab_floor_1_pressed},
  231. {R.drawable.tab_floor_2_normal, R.drawable.tab_floor_2_pressed},
  232. {R.drawable.tab_floor_3_normal, R.drawable.tab_floor_3_pressed}
  233. };
  234. private int[][] MultiSelectedBtnArray =
  235. {
  236. {R.drawable.tab_floor_1_selected, R.drawable.tab_floor_1_selected},
  237. {R.drawable.tab_floor_2_selected, R.drawable.tab_floor_2_selected},
  238. {R.drawable.tab_floor_3_selected, R.drawable.tab_floor_3_selected}
  239. };
  240. private LedDimmingKCC_API ledDimmingAPI = null;
  241. private class DimData {
  242. LedDimmingKCC_API.Data DimData;
  243. public DimData()
  244. {
  245. DimData = null;
  246. }
  247. }
  248. private DimData mDimData = null;
  249. private byte [] mLevelArray = { 100, 70, 50, 20 };
  250. private boolean bMultiConcentExist = false;
  251. boolean bKitchenLightonLivingEM = false; // 거실EM에 주방등 연결 여부
  252. public static PowerManager mPowerManager;
  253. public static V40IF mV40IF;
  254. //Value
  255. String myIP = "NONE";
  256. String myDong = "NONE";
  257. String myHo = "NONE";
  258. int ho;
  259. int mMultiAddress;
  260. public int KccDimUse = 0;
  261. // int SmartDistUse = -1;
  262. // boolean KnxDistUse = false;
  263. public static int nDistributionPanelType = Version.DISTRIBUTION_MODEL.OTHER;
  264. private VentiAPI mVentilAPI = null;
  265. private KnxVentiAPI mKnxVentilAPI = null;
  266. DataClasses.Venti VentilStatus;
  267. /**
  268. * 모델하우스 전용 환기 버전2 사용 여부 체크
  269. * UI만 동작함
  270. */
  271. private boolean isUseModelHouse_Venti = false;
  272. // =================================================================================================
  273. // [[ Activity Life Cycle ]] region
  274. // =================================================================================================
  275. /**
  276. * Activity Constructors
  277. */
  278. @Override
  279. protected void onCreate(Bundle savedInstanceState) {
  280. Log.i(TAG, "[onCreate] -------------------------------------------------------------");
  281. Log.i(TAG, "[onCreate] ------------------ [START - MainActivity] -------------------");
  282. Log.i(TAG, "[onCreate] -------------------------------------------------------------");
  283. super.onCreate(savedInstanceState);
  284. // @ AutoScale 설정
  285. WpadScale.setAutoScale(true);
  286. if (Common.CHECK_DEV_SERVICE) StartDevService();
  287. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  288. Log.i("[onCreate] Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
  289. // 1. 변수 초기화
  290. DebugLogOutput("[Create] - Step1 : Data Create");
  291. PopupActivityRun = false;
  292. ManualActivityRun = false;
  293. mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  294. mV40IF = new V40IF();
  295. mContext = this;
  296. mDimData = new DimData();
  297. mHideMenuOn = false;
  298. // 2. 자동 종료 셋팅
  299. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  300. // 2-1. 자동종료 타이머 셋팅
  301. //if (Common.FINISH_TIME_ENABLE) super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
  302. //Common.ctrlLCDOnOff(true);
  303. // 3. API 호출
  304. DebugLogOutput("[Create] - Step3 : API Call");
  305. if (Common.GetDeviceSampleMode(this)) OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  306. else OPERATION_MODE = Common.MODE_NOMAL;
  307. //for test
  308. //OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  309. // 3.1. wpapi 생성
  310. if (OPERATION_MODE == Common.MODE_NOMAL) {
  311. Log.d(TAG, "[onCreate] OperationMode = MODE_NOMAL");
  312. try {
  313. wpapi = new WallPadAPI(this);
  314. } catch (RuntimeException re) {
  315. LogUtil.errorLogInfo("", TAG, re);
  316. }
  317. catch (Exception e) {
  318. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  319. }
  320. }
  321. else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  322. Log.d(TAG, "[onCreate] OperationMode = MODE_BUSINESS_SAMPLE");
  323. try {
  324. wpapi = new WallPadAPI(this);
  325. } catch (RuntimeException re) {
  326. LogUtil.errorLogInfo("", TAG, re);
  327. }
  328. catch (Exception e) {
  329. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  330. }
  331. }
  332. try {
  333. wdb = new WallpadStatusData(this);
  334. wallpaddbmgr.AddressSet addc = wdb.getAddressMGR(); //DB에서 동호 정보 받아옴
  335. //동, 호, ip 정보 저장
  336. myIP = addc.IPAddress;
  337. myDong = addc.Dong;
  338. myHo = addc.Ho;
  339. ho = Integer.valueOf(myIP.substring(myIP.length()-1, myIP.length()));
  340. } catch (RuntimeException re) {
  341. LogUtil.errorLogInfo("", TAG, re);
  342. }
  343. catch (Exception e) {
  344. Log.e(TAG, "[ExceptionError] - onCreate->WallpadStatusData Create : " + e);
  345. }
  346. getConstructionFunction();
  347. GetRoomName();
  348. //mMultiConentCheckHandler.sendEmptyMessage(0); // 멀티스위치 콘센트 유무 확인
  349. // 4. Layout registration
  350. DebugLogOutput("[Create] - Step4 : Layout registration");
  351. // 4-1. mainLayout
  352. AllLayout = new RelativeLayout(this);
  353. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  354. AllLayout.setLayoutParams(params);
  355. AllLayout.setId(ID.main.layout.ALL);
  356. super.setAllLayoutRegistration(AllLayout);
  357. // 4-2. TopLayout
  358. TopLayout = new RelativeLayout(this);
  359. WpadUtil.LayoutRegistration(AllLayout, TopLayout, 1280, 110, 0, 0, ID.main.layout.TOP);
  360. // 4-4. ScreenLayout
  361. ScreenLayout = new RelativeLayout(this);
  362. WpadUtil.LayoutRegistration(AllLayout, ScreenLayout, 1280, 690, 0, 110, ID.main.layout.SCREEN);
  363. ScreenBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, R.drawable.bg_body, ID.main.image.SCREEN_BACKGROUND);
  364. ViewRegistration(ScreenLayout, ScreenBackground, 0, 0);
  365. // 5. Top Menu - ImageView registration
  366. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  367. TopBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 110, R.drawable.bg_topbar, R.drawable.bg_topbar, ID.main.image.TOP_BACKGROUND);
  368. ViewRegistration(TopLayout, TopBackground, 0, 0);
  369. TopTitle = new WpadTextView(this, false, 247 + 600, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE);
  370. ViewRegistration(TopLayout, TopTitle, 133, 15);
  371. 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);
  372. ViewRegistration(TopLayout, TopHomeBtn, 1145, 0);
  373. 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);
  374. ViewRegistration(TopLayout, TopMenuBtn, 0, 0);
  375. 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);
  376. setManualBtnVisible(getManualUse(), 1019);
  377. 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);
  378. ViewRegistration(TopLayout, TopBackBtn, 1019, 0);
  379. setTopBackBtnVisible(false);
  380. TopBoilerBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.top_but_boiler_normal, R.drawable.top_but_boiler_pressed, ID.main.button.BOILER);
  381. ViewRegistration(TopLayout, TopBoilerBtn, 1019, 0);
  382. setTopBoilerBtnVisible(false);
  383. TopAirBackBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.main.button.AIRQBACK);
  384. ViewRegistration(TopLayout, TopAirBackBtn, 1019, 0);
  385. setAIRBackBtnVisible(false);
  386. BTN_TOP_BACK_VENTIL = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.main.button.VENTILBACK);
  387. ViewRegistration(TopLayout, BTN_TOP_BACK_VENTIL, 1019, 0);
  388. setVentilBackBtnVisible(false);
  389. Hide1Btn = new WpadImageView(this, TOUCH_KIND.BUTTON_M, 100, 110, 0, 0, ID.main.button.HIDE1);
  390. ViewRegistration(TopLayout, Hide1Btn, 530, 0);
  391. Hide2Btn = new WpadImageView(this, TOUCH_KIND.BUTTON_M, 100, 110, 0, 0, ID.main.button.HIDE2);
  392. ViewRegistration(TopLayout, Hide2Btn, 650, 0);
  393. TopDimmingBtn = new WpadImageView[4];
  394. for (int i = 0; i < TopDimmingBtn.length; i++) {
  395. TopDimmingBtn[i] = new WpadImageView(this, TOUCH_KIND.BUTTON, 76, 76, KCC_DimmBtnOffArray[i], KCC_DimmBtnOnArray[i], ID.main.button.DIMM_NORMAL + i);
  396. ViewRegistration(TopLayout, TopDimmingBtn[i], 445 + (i*100), 17);
  397. }
  398. setKccDimmBtnVisible(false);
  399. MultiBtn = new WpadImageView[3];
  400. for (int i = 0; i < MultiBtn.length; i++) {
  401. MultiBtn[i] = new WpadImageView(this, TOUCH_KIND.BUTTON, 156, 50,
  402. MultiBtnArray[i],
  403. MultiSelectedBtnArray[i],
  404. ID.main.button.MULTI1 + i);
  405. ViewRegistration(TopLayout, MultiBtn[i], 464 + (i*160), 30);
  406. }
  407. setMultiBtnVisible(false);
  408. WallpadDeviceSet wpdds = new WallpadDeviceSet(getContext());
  409. bKitchenLightonLivingEM = wpdds.Get_LivingEm_KitchenLight_Use();
  410. wpdds.closeDB();
  411. // 6. Menu Loading
  412. // 6-1. 메뉴 정보를 가져온다 (DB에서 가져온다)
  413. DebugLogOutput("[Create] - Step6 : Side Menu - Insert Menu List");
  414. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  415. menueListDataClass = WallpadDBMGR.GetMenuList();
  416. WallpadDBMGR.closeDB();
  417. //WallPadMain에서 MenuList를 넣어주지 않아 아래 테스트 코드를 넣음
  418. menueListDataClass = null;
  419. if (menueListDataClass == null) {
  420. Log.e(TAG, "[onCreate] menueListDataClass == null, Load Default List");
  421. menueListDataClass = loadDefaultMenuList();
  422. }
  423. else {
  424. for (int i = 0; i < menueListDataClass.idMappingTable.length; i++) {
  425. Log.d(TAG, "[onCreate] i [" + i + "], ID [" + menueListDataClass.idMappingTable[i].Id + ", NAME [" + menueListDataClass.idMappingTable[i].Name + "]");
  426. }
  427. }
  428. // 6-2. 시작 화면을 main APP으로 부터 받아서 처리한다.
  429. VentilStatus = new DataClasses.Venti();
  430. mMenu = new Menu();
  431. mMenu = super.getIntentParsingMenu(getIntent());
  432. if (mMenu == null) {
  433. Log.i(TAG, "[onCreate] mMenu = null");
  434. if (OPERATION_MODE == Common.MODE_NOMAL) {
  435. mTempCurrentScreenId = API_Menu.SubMenuCtrl.HDC_LivingLamp;
  436. setTitleName(mTempCurrentScreenId);
  437. mWallPadApiCheckHandler.sendEmptyMessage(0);
  438. }
  439. else {
  440. setChangeScreen(API_Menu.SubMenuCtrl.HDC_LivingLamp, false);
  441. }
  442. }
  443. else {
  444. Log.i(TAG, "[onCreate] mMenu != null");
  445. if (OPERATION_MODE == Common.MODE_NOMAL) {
  446. mTempCurrentScreenId = mMenu.getStartId();
  447. setTitleName(mTempCurrentScreenId);
  448. mWallPadApiCheckHandler.sendEmptyMessage(0);
  449. }
  450. else {
  451. mTempCurrentScreenId = mMenu.getStartId();
  452. setTitleName(mTempCurrentScreenId);
  453. mWallPadApiCheckHandler.sendEmptyMessage(0);
  454. /*boolean result = setChangeScreen(mMenu.getStartId(), false);
  455. Log.i(TAG, "Menu Sample result = " + result);
  456. if (result == false)
  457. {
  458. setChangeScreen(API_Menu.SubMenuCtrl.HDC_LivingLamp, false);
  459. }*/
  460. }
  461. }
  462. // 7. Draw
  463. DebugLogOutput("[Create] - Step7 : setContentView");
  464. setContentView(AllLayout);
  465. // 8. Window ReSize
  466. DebugLogOutput("[Create] - Step8 : Window ReSize");
  467. //super.WindowReSize(Common.SCREEN_SIZE_MAIN_W, Common.SCREEN_SIZE_MAIN_H, false);
  468. // 9. BR Receiver 등록(메뉴에서 다른 화면이 눌린 경우 BR처리)
  469. reg_Receiver();
  470. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  471. int gateway = wds.GetGatewayModelKindInfo();
  472. nDistributionPanelType = wds.Get_DistributionPannelType_Info();
  473. wds.closeDB();
  474. //for test
  475. nDistributionPanelType = Version.DISTRIBUTION_MODEL.KNX_DIST;
  476. if (gateway == Version.GATEWAY_MODEL.IGW_200) {
  477. Log.i(TAG, "[onCreate] IGW_200 SET @@@@@@@@@@@@@@@@@@@@");
  478. }
  479. else if (gateway == Version.GATEWAY_MODEL.IGW_300) {
  480. Log.i(TAG, "[onCreate] IGW_300 SET @@@@@@@@@@@@@@@@@@@@");
  481. }
  482. else {
  483. Log.i(TAG, "[onCreate] GATEWAY OTHER @@@@@@@@@@@@@@@@@@@@");
  484. }
  485. /*if( (SmartDistUse == 1) && (KnxDistUse == false) ) // 스마트분전반 O / KNX 분전반 X
  486. {
  487. SdbAPI sdbAPI = Get_SdbController();
  488. if(sdbAPI == null) return -1;
  489. ret = sdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_CONT, define.DEVICE_ALL_OR_NOTHING);
  490. if(ret < 0) return -2;
  491. if(sdbAPI.data.EnergyController.Data.BatchOffStatus == Sdb_DataClasses.BATCHOFF_STATUS.SET) return 0;
  492. else return 1;
  493. }
  494. else if( (SmartDistUse == 0) && (KnxDistUse == true) ) // 스마트분전반 X / KNX 분전반 O
  495. {
  496. KnxAPI knxAPI = Get_KnxController();
  497. if(knxAPI == null) return -1;
  498. ret = knxAPI.Refresh(KnxAPI.DEVICE_INDEX.MASTER_CONT, define.DEVICE_ALL_OR_NOTHING);
  499. if(ret < 0) return -2;
  500. if(knxAPI.data.MasterController.Data.BatchOffStatus == KNX_DataClasses.BATCHOFF_STATUS.SET) return 0;
  501. else return 1;
  502. }
  503. else // 그밖의 경우, 스마트분전반을 기본으로 로딩.
  504. {
  505. SdbAPI sdbAPI = Get_SdbController();
  506. if(sdbAPI == null) return -1;
  507. ret = sdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_CONT, define.DEVICE_ALL_OR_NOTHING);
  508. if(ret < 0) return -2;
  509. if(sdbAPI.data.EnergyController.Data.BatchOffStatus == Sdb_DataClasses.BATCHOFF_STATUS.SET) return 0;
  510. else return 1;
  511. }*/
  512. // 거주자 안전확인 서비스 사용여부 확인하고, 화면 WallPadSupport Lib.에 관련 설정을 한다.
  513. getResidentSafetyCheckSetting();
  514. Log.i(TAG, "[onCreate] End onCreate -------------------------------------------------");
  515. }
  516. /**
  517. * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며, <br>
  518. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  519. * 본 딜레이 코드를 임시로 적용한다.
  520. */
  521. @SuppressLint("HandlerLeak")
  522. protected Handler mWallPadApiCheckHandler = new Handler() {
  523. @SuppressLint("HandlerLeak")
  524. @Override
  525. public void handleMessage(Message msg) {
  526. try {
  527. if (msg.what == 0) {
  528. if (wpapi != null) {
  529. //Log.d(TAG, "Handler go");
  530. if (wpapi.Check_Connect()) {
  531. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  532. mKnxVentilAPI = wpapi.Get_KnxVentiController();
  533. // KNX 환기
  534. if (mKnxVentilAPI != null) {
  535. Log.e(TAG, "[mWallPadApiCheckHandler] mKnxVentilAPI is not null!!");
  536. updateKnxVentilatorData(false);
  537. }
  538. else {
  539. Log.e(TAG, "[mWallPadApiCheckHandler] mKnxVentilAPI is null!!");
  540. mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  541. }
  542. mVentilAPI = wpapi.Get_VentiController();
  543. if (mVentilAPI != null) {
  544. Log.e(TAG, "[mWallPadApiCheckHandler] mVentilAPI is not null!!");
  545. updateVentilatorData(false);
  546. }
  547. else {
  548. Log.e(TAG, "[mWallPadApiCheckHandler] mVentilAPI is null!!");
  549. mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  550. }
  551. }
  552. else {
  553. // 일반 환기
  554. mVentilAPI = wpapi.Get_VentiController();
  555. if (mVentilAPI != null) {
  556. Log.e(TAG, "[mWallPadApiCheckHandler] mVentilAPI is not null!!");
  557. updateVentilatorData(false);
  558. }
  559. else {
  560. Log.e(TAG, "[mWallPadApiCheckHandler] mVentilAPI is null!!");
  561. mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  562. }
  563. }
  564. // KCC 디밍제어기 사용여부 확인
  565. WallpadDeviceSet wdst = new WallpadDeviceSet(getContext());
  566. int nKCCDimmingUsage = wdst.GetDeviceSetted("KCC디밍제어기"); // 1: 사용안함 / 2: 사용함
  567. int[] nLightType = wdst.Get_Light_info();
  568. wdst.closeDB();
  569. if (nKCCDimmingUsage == WallpadDeviceSet.DEV_DATA_ENABLE) {
  570. ledDimmingAPI = wpapi.Get_KCCDimmingController();
  571. if (ledDimmingAPI != null) {
  572. ledDimmingAPI.regChangedBR(ID.main.BR_KCC_DIM);
  573. if (ledDimmingAPI.Refresh((byte)0, false) >= 0) {
  574. mDimData.DimData = ledDimmingAPI.data;
  575. }
  576. Draw_Update_DimmBtn();
  577. }
  578. else {
  579. Log.w(TAG, "[mWallPadApiCheckHandler] ledDimmingAPI is null!!");
  580. //mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  581. }
  582. }
  583. if (nLightType[0] == WallpadDeviceSet.DO_USE) {
  584. if (nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_ROOM || nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  585. // 조명 : 멀티스위치인 경우
  586. try {
  587. MultiSwitchAPI mMultiSwitchAPI = wpapi.Get_MultiSwitchController();
  588. if (mMultiSwitchAPI.Refresh((byte) 0xFF, false) >= 0) {
  589. Log.i(TAG, "[mWallPadApiCheckHandler] Multi Refresh ----> true @@@@@@@@@@@@@");
  590. if (mMultiSwitchAPI.isExist_ConcentDevice()) {
  591. Log.i(TAG, "[mWallPadApiCheckHandler] Multi concent ----> true @@@@@@@@@@@@@");
  592. bMultiConcentExist = true; // 콘센트 있는지 확인
  593. }
  594. }
  595. } catch (RuntimeException re) {
  596. LogUtil.errorLogInfo("", TAG, re);
  597. }
  598. catch (Exception e) {
  599. Log.e(TAG, e.toString());
  600. }
  601. }
  602. }
  603. mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  604. }
  605. else {
  606. mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  607. }
  608. }
  609. else {
  610. Log.w(TAG, "[mWallPadApiCheckHandler] wpapi is null!!");
  611. }
  612. }
  613. else if (msg.what == 1) {
  614. Log.d(TAG, "Handler finish");
  615. menueListDataClass = loadDefaultMenuList(); // 다시 메뉴를 만들어 질까? ??????
  616. boolean result = setChangeScreen(mTempCurrentScreenId, false);
  617. if (result == false) {
  618. setChangeScreen(API_Menu.SubMenuCtrl.HDC_LivingLamp, false);
  619. }
  620. }
  621. } catch (RuntimeException re) {
  622. LogUtil.errorLogInfo("", TAG, re);
  623. }
  624. catch (Exception e) {
  625. Log.e(TAG, "[Exception] mWallPadApiCheckHandler.handleMessage(Message msg)");
  626. //e.printStackTrace();
  627. LogUtil.errorLogInfo("", TAG, e);
  628. }
  629. }
  630. };
  631. boolean multiConcentFindRoutine = false;
  632. @SuppressLint("HandlerLeak")
  633. protected Handler mMultiConentCheckHandler = new Handler()
  634. {
  635. @SuppressLint("HandlerLeak")
  636. @Override
  637. public void handleMessage(Message msg) {
  638. if (msg.what == 0) {
  639. if (wpapi != null) {
  640. //Log.d(TAG, "Handler go");
  641. if (wpapi.Check_Connect()) {
  642. WallpadDeviceSet wdst = new WallpadDeviceSet(getContext());
  643. int[] lightType = wdst.Get_Light_info();
  644. wdst.closeDB();
  645. if (lightType[0] == WallpadDeviceSet.DO_USE) {
  646. if (lightType[1] == WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  647. // 조명 : 멀티스위치인 경우,
  648. try {
  649. MultiSwitchAPI MSAPI = wpapi.Get_MultiSwitchController();
  650. if (MSAPI.Refresh((byte) 0xFF, false) >= 0) {
  651. Log.i(TAG, "Multi Refresh ----> true @@@@@@@@@@@@@");
  652. if (MSAPI.isExist_ConcentDevice()) {
  653. Log.i(TAG, "Multi concent ----> true @@@@@@@@@@@@@");
  654. bMultiConcentExist = true; // 콘센트 있는지 확인
  655. }
  656. }
  657. } catch (RuntimeException re) {
  658. LogUtil.errorLogInfo("", TAG, re);
  659. }
  660. catch (Exception e) {
  661. Log.e(TAG, e.toString());
  662. }
  663. }
  664. else {
  665. mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  666. }
  667. }
  668. mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  669. }
  670. else {
  671. mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  672. }
  673. }
  674. }
  675. else if (msg.what == 1) {
  676. Log.d(TAG, "Handler finish");
  677. multiConcentFindRoutine = true;
  678. menueListDataClass = loadDefaultMenuList(); // 다시 메뉴를 만들어 질까? ??????
  679. }
  680. }
  681. };
  682. /* ================================================================================================
  683. * [Manual Activity] Section
  684. ================================================================================================ */
  685. public static ManualActivity mManualActivity;
  686. public void setManualBtnVisible(boolean bEnable, int marginLeft) {
  687. try {
  688. Log.d(TAG, "[setManualBtnVisible] bEnable [" + bEnable + "], marginLeft [" + marginLeft + "]");
  689. if (bEnable) {
  690. TopManualBtn.setVisibility(View.VISIBLE);
  691. ViewRegistration(TopLayout, TopManualBtn, marginLeft, 0);
  692. }
  693. else {
  694. TopManualBtn.setVisibility(View.INVISIBLE);
  695. }
  696. } catch (RuntimeException re) {
  697. LogUtil.errorLogInfo("", TAG, re);
  698. }
  699. catch (Exception e) {
  700. Log.e(TAG, "[Exception] setManualBtnVisible(boolean bEnable, int marginLeft)");
  701. //e.printStackTrace();
  702. LogUtil.errorLogInfo("", TAG, e);
  703. }
  704. }
  705. /**
  706. * 매뉴얼 버튼 사용 유무
  707. * @return boolean 타입 - true: 사용, false: 미사용
  708. */
  709. public boolean getManualUse() {
  710. try {
  711. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  712. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  713. devSet.closeDB();
  714. if (DBinfo != null) {
  715. if (DBinfo[1].indexOf("사용함") > 0) {
  716. Log.d(TAG, "[getManualUse] Use Manual");
  717. return true;
  718. }
  719. else {
  720. // 미사용
  721. Log.d(TAG, "[getManualUse] Not Use Manual [1]");
  722. return false;
  723. }
  724. }
  725. else {
  726. // 미사용
  727. Log.d(TAG, "[getManualUse] Not Use Manual [2]");
  728. return false;
  729. }
  730. } catch (RuntimeException re) {
  731. LogUtil.errorLogInfo("", TAG, re);
  732. }
  733. catch (Exception e) {
  734. Log.e(TAG, "[Exception] getManualUse()");
  735. //e.printStackTrace();
  736. LogUtil.errorLogInfo("", TAG, e);
  737. }
  738. return false;
  739. }
  740. // ManualActivityRun
  741. private static boolean ManualActivityRun = false;
  742. public static boolean getManualActivityRun() {
  743. Log.d(TAG, "[getManualActivityRun] ManualActivityRun: " + ManualActivityRun);
  744. return ManualActivityRun;
  745. }
  746. public static void setManualActivityRun(boolean run) {
  747. ManualActivityRun = run;
  748. if (!ManualActivityRun) resetCurrentManualScreenID();
  749. }
  750. public boolean StartManual(int screenId) {
  751. try {
  752. Log.d(TAG, "[StartManual] ScreenId [" + screenId + "], mCurrentManualScreenId [" + mCurrentManualScreenId + "]");
  753. if (getManualActivityRun()) {
  754. mCurrentManualScreenId = screenId;
  755. return ((WpadActivity) (ManualActivity.getContext())).ChangeScreen(screenId);
  756. }
  757. else {
  758. if (mCurrentManualScreenId == screenId) return false;
  759. mCurrentManualScreenId = screenId;
  760. setManualActivityRun(true);
  761. Intent intent = new Intent(mContext, ManualActivity.class);
  762. intent.putExtra("ScreenId", screenId);
  763. if (mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V2) {
  764. intent.putExtra("HeatInfo", heatingV2MainScreen.Heating_Manual_Str);
  765. }
  766. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.OutSide_EachLamp) {
  767. intent.putExtra("EtcMultiInfo", "RoomCount:"+lightEtcEachMainScreen.TotalRoomCount + "/" + "KccDim:" + KccDimUse );
  768. }
  769. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Concent) {
  770. intent.putExtra("ConcentInfo", "ConcentCount:"+concentMainScreen.mConDeviceCount );
  771. }
  772. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.ChangAir_Normal) {
  773. if (GetEasyModeUXUse() == true) {
  774. intent.putExtra("VentiInfo", ventiEasymodeScreen.VentiManual_Str);
  775. }
  776. else {
  777. if (ventiMainScreen != null) intent.putExtra("VentiInfo", ventiMainScreen.VentiManual_Str);
  778. }
  779. }
  780. overridePendingTransition(0, 0);
  781. startActivityForResult(intent, 0);
  782. return true;
  783. }
  784. } catch (RuntimeException re) {
  785. LogUtil.errorLogInfo("", TAG, re);
  786. return false;
  787. }
  788. catch (Exception e) {
  789. Log.e(TAG, "[Exception] StartManual(int screenId)");
  790. //e.printStackTrace();
  791. LogUtil.errorLogInfo("", TAG, e);
  792. return false;
  793. }
  794. }
  795. public boolean StartMultiControl(int screenId, int ho) {
  796. try {
  797. Log.d(TAG, "[StartMultiControl] ScreenId [" + screenId + "], mCurrentScreenId [" + mCurrentScreenId + "]");
  798. if (mCurrentScreenId == screenId) return false;
  799. if(setMultiScreen(screenId, ho)){
  800. return true;
  801. }
  802. return false;
  803. } catch (RuntimeException re) {
  804. LogUtil.errorLogInfo("", TAG, re);
  805. return false;
  806. }
  807. catch (Exception e) {
  808. Log.e(TAG, "[Exception] StartMultiControl(int screenId)");
  809. //e.printStackTrace();
  810. LogUtil.errorLogInfo("", TAG, e);
  811. return false;
  812. }
  813. }
  814. public static void resetCurrentManualScreenID() {
  815. try {
  816. mCurrentManualScreenId = -1;
  817. } catch (RuntimeException re) {
  818. LogUtil.errorLogInfo("", TAG, re);
  819. }
  820. catch (Exception e) {
  821. Log.e(TAG, "[Exception] resetCurrentManualScreenID()");
  822. //e.printStackTrace();
  823. LogUtil.errorLogInfo("", TAG, e);
  824. }
  825. }
  826. public static void FinishManualActivity() {
  827. Log.i(TAG, "[FinishManualActivity]");
  828. try {
  829. if (mManualActivity != null) {
  830. mCurrentManualScreenId = -1;
  831. mManualActivity.finish();
  832. }
  833. } catch (RuntimeException re) {
  834. LogUtil.errorLogInfo("", TAG, re);
  835. }
  836. catch (Exception e) {
  837. Log.e(TAG, "[Exception] FinishManualActivity()");
  838. //e.printStackTrace();
  839. LogUtil.errorLogInfo("", TAG, e);
  840. }
  841. }
  842. /**
  843. * onDestroy
  844. */
  845. @Override
  846. protected void onDestroy() {
  847. try {
  848. setChangeScreen(mCurrentScreenId, true);
  849. if (wdb != null) wdb.closeDB();
  850. if (mWallPadApiCheckHandler != null) {
  851. mWallPadApiCheckHandler.removeMessages(0);
  852. }
  853. this.unregisterReceiver(mWallPadAlertBR);
  854. this.unregisterReceiver(mWallPadJogBR);
  855. this.unregisterReceiver(mKccDimmBR);
  856. if (ledDimmingAPI != null) {
  857. ledDimmingAPI.unregChangedBR(ID.main.BR_KCC_DIM);
  858. super.removeBrActionFilter(ID.main.BR_KCC_DIM);
  859. }
  860. if (getManualUse()) {
  861. FinishManualActivity();
  862. }
  863. super.setFinishTimerDestroy();
  864. super.onDestroy();
  865. Log.i(TAG, "*************************************************************");
  866. Log.i(TAG, "****************** [END - MainActivity] *******************");
  867. Log.i(TAG, "*************************************************************");
  868. } catch (RuntimeException re) {
  869. LogUtil.errorLogInfo("", TAG, re);
  870. }
  871. catch (Exception e) {
  872. Log.e(TAG, "[Exception] onDestroy()");
  873. //e.printStackTrace();
  874. LogUtil.errorLogInfo("", TAG, e);
  875. }
  876. }
  877. /**
  878. * onResume
  879. */
  880. @Override
  881. protected void onResume() {
  882. super.onResume();
  883. if (wpapi != null) wpapi.Resume();
  884. DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@");
  885. }
  886. /**
  887. * onPause
  888. */
  889. @Override
  890. protected void onPause() {
  891. super.onPause();
  892. if (wpapi != null) wpapi.Pause();
  893. DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@");
  894. }
  895. /* ================================================================================================
  896. * [BroadcastReceiver] Section
  897. ================================================================================================ */
  898. /**
  899. * BroadcastReceiver.onReceive for [WpadActivity]
  900. */
  901. @Override
  902. protected void onBrReceive(Intent intent) {
  903. super.onBrReceive(intent);
  904. String strActionName = intent.getAction();
  905. DebugLogOutput("[onBrReceive] strActionName [" + intent.getAction() + "]");
  906. if (strActionName.equals(ID.main.BR_KCC_DIM)) {
  907. DebugLogOutput("[onBrReceive] ID.main.BR_KCC_DIM");
  908. Device_Update_Dimming(false, (byte)0);
  909. Draw_Update_DimmBtn();
  910. }
  911. }
  912. /* ================================================================================================
  913. * [Touch & Key Event] Section
  914. ================================================================================================ */
  915. /**
  916. * TouchEvent for [WpadActivity]
  917. */
  918. @Override
  919. protected void onTouchEvent(View v, MotionEvent event) {
  920. super.onTouchEvent(v, event);
  921. try {
  922. int TargetId = v.getId();
  923. int MoveEvent = event.getAction();
  924. //DebugLogOutput("onTouch - " + "id : " + v.getId() + " / Action : " + event.getAction());
  925. if (MoveEvent == MotionEvent.ACTION_UP) {
  926. if (TargetId == ID.main.button.HOME) {
  927. DebugLogOutput("onTouchEvent [HOME] BUTTON !!!");
  928. Sound().Play(SND.effect.TOUCH_LATCHED);
  929. Intent intent = new Intent();
  930. intent.putExtra("Finish_Kind", "HomeButton");
  931. setResult(RESULT_OK, intent);
  932. finish();
  933. }
  934. else if (TargetId == ID.main.button.BACK) {
  935. DebugLogOutput("onTouchEvent [BACK] BUTTON !!!");
  936. Sound().Play(SND.effect.TOUCH_LATCHED);
  937. /**
  938. *[수정필요]Back Button 필요한 화면은 아래 부분 추가 후 사용 필요
  939. * **/
  940. /*
  941. if(mCurrentScreenId == API_Menu.SubMenuConfig.SmartKey)
  942. {
  943. setChangeScreen(API_Menu.SubMenuConfig.Configuration, false);
  944. }
  945. */
  946. }
  947. else if (TargetId == ID.main.button.MENU) {
  948. DebugLogOutput("onTouchEvent [MENU] BUTTON !!!");
  949. Log.i(TAG, "MenuOpen = " + MenuOpen);
  950. Sound().Play(SND.effect.TOUCH_LATCHED);
  951. if (MenuOpen == true) {
  952. return;
  953. }
  954. OpenMenuLayout();
  955. }
  956. else if (TargetId == ID.main.button.MENUCLOSE) {
  957. Sound().Play(SND.effect.TOUCH_LATCHED);
  958. CloseMenuLayout();
  959. }
  960. else if (TargetId == ID.main.button.BOILER) {
  961. DebugLogOutput("onTouchEvent [BOILER] BUTTON !!!");
  962. if (mCurrentMultiScreenId == ID.screen.HeatingV2TestScreen) {
  963. if(StartPopup(ID.screen.HeatingV2PopupBoilerTestScreen)) {
  964. Sound().Play(SND.effect.TOUCH_LATCHED);
  965. }
  966. }
  967. else {
  968. if(StartPopup(ID.screen.HeatingV2PopupBoilerScreen)) {
  969. Sound().Play(SND.effect.TOUCH_LATCHED);
  970. }
  971. }
  972. }
  973. else if (TargetId == ID.main.button.HIDE1 || TargetId == ID.main.button.HIDE2) {
  974. HideMenuEntryProc(TargetId);
  975. }
  976. else if (TargetId == ID.main.button.AIRQBACK) {
  977. DebugLogOutput("onTouchEvent [AIRQBACK] BUTTON !!!");
  978. Sound().Play(SND.effect.TOUCH_LATCHED);
  979. setAIRBackBtnVisible(false);
  980. setChangeScreen(API_Menu.SubMenuCtrl.Inner_AirQuality, false);
  981. }
  982. else if (TargetId == ID.main.button.VENTILBACK) {
  983. DebugLogOutput("onTouchEvent [AIRQBACK] BUTTON !!!");
  984. Sound().Play(SND.effect.TOUCH_LATCHED);
  985. setVentilBackBtnVisible(false);
  986. setChangeScreen(API_Menu.SubMenuCtrl.ChangAir_Normal, false);
  987. }
  988. else if (TargetId >= ID.main.button.DIMM_NORMAL && TargetId <= ID.main.button.DIMM_REST) {
  989. DebugLogOutput("onTouchEvent [DIMM_NORMAL] BUTTON !!!");
  990. try {
  991. // 디밍제어
  992. int index = TargetId - ID.main.button.DIMM_NORMAL;
  993. DebugLogOutput("onTouchEvent [DIM_LEV" + (index + 1) + "] BUTTON !!!");
  994. if (mDimData.DimData.Device[0] == null) {
  995. DebugLogOutput("null event");
  996. }
  997. if(mDimData.DimData.Device[0]!=null && mLevelArray!=null)
  998. {
  999. byte NowLevel = mDimData.DimData.Device[0].device.Level;
  1000. DebugLogOutput("NowLevel :" + NowLevel);
  1001. byte CtrlLevel = mLevelArray[index];
  1002. DebugLogOutput("CtrlLevel :" + CtrlLevel);
  1003. if (NowLevel == CtrlLevel) {
  1004. TopDimmingBtn[index].setButtonRearImage(); // 켜진 상태 그대로 유지
  1005. }
  1006. else if (NowLevel != CtrlLevel) {
  1007. int ret = Device_SetDimmingLevel(CtrlLevel);
  1008. if (ret >= 0) Sound().Play(SND.effect.TOUCH_LATCHED);
  1009. else Sound().Play(SND.effect.TOUCH_UNLATCHED);
  1010. }
  1011. }
  1012. } catch (RuntimeException re) {
  1013. Sound().Play(SND.effect.TOUCH_UNLATCHED);
  1014. LogUtil.errorLogInfo("", TAG, re);
  1015. }
  1016. catch (Exception ex) {
  1017. Sound().Play(SND.effect.TOUCH_UNLATCHED);
  1018. //ex.printStackTrace();
  1019. LogUtil.errorLogInfo("", TAG, ex);
  1020. }
  1021. }
  1022. else if (TargetId == ID.main.button.MANUAL) {
  1023. Log.i(TAG, "onTouchEvent [MANUAL] BUTTON [mCurrentScreenId = " + mCurrentScreenId + "]");
  1024. Sound().Play(SND.effect.TOUCH_LATCHED);
  1025. if (mCurrentScreenId == API_Menu.SubMenuCtrl.HDC_LivingLamp) { StartManual(ID.MANUAL.MANUAL_HdcLivingLight); }
  1026. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.LivingLightConfig) { StartManual(ID.MANUAL.MANUAL_HdcLivingGroup); }
  1027. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.OutSide_livingLamp) { StartManual(ID.MANUAL.MANUAL_EtcLivingLight); }
  1028. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.HDCLivingNEach_Lamp) {}
  1029. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.OutSide_EachLamp) { StartManual(ID.MANUAL.MANUAL_EtcMultiLight); }
  1030. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V2 || mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V1) { StartManual(ID.MANUAL.MANUAL_Heating); }
  1031. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Gas) { StartManual(ID.MANUAL.MANUAL_Gas); }
  1032. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Cooktop_Concent) { StartManual(ID.MANUAL.MANUAL_CookTopConcent); }
  1033. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.DoorLockWL) { StartManual(ID.MANUAL.MANUAL_Doorlock); }
  1034. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.DoorLock485) { StartManual(ID.MANUAL.MANUAL_Doorlock); }
  1035. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Concent) { StartManual(ID.MANUAL.MANUAL_Concent); }
  1036. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.ChangAir_Normal) {
  1037. if (getAirSensorAPUsage() && VentilStatus.Support.InnerCycle && VentilStatus.Support.OutAirClean) {
  1038. if (nDistributionPanelType != Version.DISTRIBUTION_MODEL.KNX_DIST) StartManual(ID.MANUAL.MANUAL_Ventilation);
  1039. }
  1040. else {
  1041. if (GetEasyModeUXUse()) StartManual(ID.MANUAL.MANUAL_Easymode_Venti);
  1042. else {
  1043. if (VentilStatus.Support2.WindowVenti) StartManual(ID.MANUAL.MANUAL_Venti);
  1044. else StartManual(ID.MANUAL.MANUAL_Ventilation);
  1045. }
  1046. }
  1047. }
  1048. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Inner_AirQuality) { StartManual(ID.MANUAL.MANUAL_InAirQual); }
  1049. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Inner_AirInfo) { /*StartManual(ID.MANUAL.MANUAL_AirInfo);*/ }
  1050. else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Electric_Range) { StartManual(ID.MANUAL.MANUAL_ElecRange); }
  1051. }
  1052. else if (TargetId >= ID.main.button.MULTI1 && TargetId <= ID.main.button.MULTI3) {
  1053. Log.i(TAG, "onTouchEvent [TEST1] BUTTON [mCurrentScreenId = " + mCurrentScreenId + "]");
  1054. Sound().Play(SND.effect.TOUCH_LATCHED);
  1055. int index = TargetId - ID.main.button.MULTI1;
  1056. for(int i = 0; i< MultiBtn.length; i++){
  1057. MultiBtn[i].setButtonFrontImage();
  1058. }
  1059. MultiBtn[index].setButtonRearImage();
  1060. //해당층
  1061. if(ho==(index+1)){
  1062. if (mCurrentScreenId == API_Menu.SubMenuCtrl.HDC_LivingLamp) {
  1063. setChangeScreen(API_Menu.SubMenuCtrl.HDC_LivingLamp, false);
  1064. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V2 || mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V1) {
  1065. setChangeScreen(API_Menu.SubMenuCtrl.Heating_V2, false);
  1066. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Gas) {
  1067. setChangeScreen(API_Menu.SubMenuCtrl.Gas, false);
  1068. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.SystemAircon) {
  1069. setChangeScreen(API_Menu.SubMenuCtrl.SystemAircon, false);
  1070. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.ChangAir_Normal) {
  1071. setChangeScreen(API_Menu.SubMenuCtrl.ChangAir_Normal, false);
  1072. }
  1073. }else {
  1074. //다른층
  1075. if (mCurrentScreenId == API_Menu.SubMenuCtrl.HDC_LivingLamp) {
  1076. StartMultiControl(ID.screen.LightKnxMainTestScreen, index+1);
  1077. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.LivingLightConfig) {
  1078. StartMultiControl(API_Menu.SubMenuCtrl.Gas, index+1);
  1079. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V2 || mCurrentScreenId == API_Menu.SubMenuCtrl.Heating_V1) {
  1080. StartMultiControl(ID.screen.HeatingV2TestScreen, index+1);
  1081. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.Gas) {
  1082. StartMultiControl(ID.screen.GasTestScreen, index+1);
  1083. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.SystemAircon) {
  1084. StartMultiControl(ID.screen.SystemAirconTest1Screen, index+1);
  1085. } else if (mCurrentScreenId == API_Menu.SubMenuCtrl.ChangAir_Normal) {
  1086. StartMultiControl(ID.screen.VentiMainTestScreen, index+1);
  1087. }
  1088. }
  1089. }
  1090. }
  1091. } catch (RuntimeException re) {
  1092. LogUtil.errorLogInfo("", TAG, re);
  1093. }
  1094. catch (Exception e) {
  1095. Log.e(TAG, "[Exception] onTouchEvent(View v, MotionEvent event)");
  1096. //e.printStackTrace();
  1097. LogUtil.errorLogInfo("", TAG, e);
  1098. }
  1099. }
  1100. /**
  1101. * H/W Key Event
  1102. */
  1103. @Override
  1104. public boolean onKeyDown(int keyCode, KeyEvent event) {
  1105. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  1106. return super.onKeyDown(keyCode, event);
  1107. }
  1108. /* ================================================================================================
  1109. * [TOP - Back] Section
  1110. ================================================================================================ */
  1111. /**
  1112. * TOP 돌아가기 버튼 활성화 & 비활성화
  1113. *
  1114. * @param Enabled - true : 활성화, false : 비활성화
  1115. * @return (boolean) true : 성공, false : 실패
  1116. */
  1117. public boolean setTopBackBtnVisible(boolean Enabled) {
  1118. try {
  1119. if (Enabled == true) {
  1120. if (TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE);
  1121. TopBackBtn.bringToFront();
  1122. }
  1123. else {
  1124. if (TopBackBtn.getVisibility() != View.INVISIBLE) TopBackBtn.setVisibility(View.INVISIBLE);
  1125. }
  1126. return true;
  1127. } catch (RuntimeException re) {
  1128. LogUtil.errorLogInfo("", TAG, re);
  1129. return false;
  1130. }
  1131. catch (Exception e) {
  1132. Log.e(TAG, "[Exception] setTopBackBtnVisible(boolean Enabled)");
  1133. //e.printStackTrace();
  1134. LogUtil.errorLogInfo("", TAG, e);
  1135. return false;
  1136. }
  1137. }
  1138. /* ================================================================================================
  1139. * [Popup Activity] Section
  1140. ================================================================================================ */
  1141. /**
  1142. * Popup Activity 를 시작시킨다.
  1143. *
  1144. * @param ScreenId - 팝업시작시 Screen ID
  1145. * @return (boolean) true : 성공, false : 실패
  1146. */
  1147. public boolean StartPopup(int ScreenId) {
  1148. if (getPopupActivityRun() == true) {
  1149. return ((WpadActivity) (PopupActivity.getContext())).ChangeScreen(ScreenId);
  1150. }
  1151. else {
  1152. setPopupActivityRun(true);
  1153. Intent intent = new Intent(mContext, PopupActivity.class);
  1154. intent.putExtra("ScreenId", ScreenId);
  1155. overridePendingTransition(0, 0);
  1156. startActivityForResult(intent, 0);
  1157. return true;
  1158. }
  1159. }
  1160. /**
  1161. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  1162. *
  1163. * @param ScreenId - 팝업시작시 Screen ID
  1164. * @param data - 전달할 데이터
  1165. * @return (boolean) true : 성공, false : 실패
  1166. */
  1167. public boolean StartPopup(int ScreenId, Intent data) {
  1168. if (getPopupActivityRun() == true) {
  1169. return false;
  1170. }
  1171. else {
  1172. setPopupActivityRun(true);
  1173. Intent intent = new Intent(mContext, PopupActivity.class);
  1174. intent.putExtra("ScreenId", ScreenId);
  1175. intent.putExtra("PopupScreenDataIntent", data);
  1176. overridePendingTransition(0, 0);
  1177. startActivityForResult(intent, 0);
  1178. return true;
  1179. }
  1180. }
  1181. /**
  1182. * Activity Result Reception
  1183. */
  1184. @Override
  1185. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  1186. super.onActivityResult(requestCode, resultCode, data);
  1187. try {
  1188. Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@");
  1189. if (resultCode == RESULT_OK) {
  1190. // PopupActivity 에서 FinishTimer 로 인하여 종료가 되었을 경우
  1191. // MainActivity 도 즉시 종료시킨다.
  1192. String code = (String) data.getExtras().get("Finish_Kind");
  1193. Log.d(TAG, "[onActivityResult] Finish_Kind : " + code);
  1194. if (code != null) {
  1195. if (code.equals("FinishTimer")) {
  1196. Log.d(TAG, "FinishTimer finish");
  1197. finish();
  1198. }
  1199. }
  1200. }
  1201. } catch (RuntimeException re) {
  1202. LogUtil.errorLogInfo("", TAG, re);
  1203. }
  1204. catch (Exception e) {
  1205. Log.e(TAG, "[Exception] onActivityResult(int requestCode, int resultCode, Intent data)");
  1206. //e.printStackTrace();
  1207. LogUtil.errorLogInfo("", TAG, e);
  1208. }
  1209. }
  1210. /* ================================================================================================
  1211. * [Screen] Section
  1212. ================================================================================================ */
  1213. /**
  1214. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  1215. * Override 사용하여 Screen 변경을 처리한다.<br>
  1216. *
  1217. * @param nScreenId - 변경할 Screen ID
  1218. * @return (boolean) true : 성공, false : 실패
  1219. */
  1220. @Override
  1221. protected boolean onChangeScreen(int nScreenId) {
  1222. super.onChangeScreen(nScreenId);
  1223. return setChangeScreen(nScreenId, false);
  1224. }
  1225. /**
  1226. * @param nScreenId - 변경할 Screen ID
  1227. * @return (boolean) true : 성공, false : 실패
  1228. **/
  1229. private boolean setTitleName(int nScreenId) {
  1230. boolean ret = false;
  1231. try {
  1232. Log.d(TAG, "[setTitleName] nScreenId [" + nScreenId + "]");
  1233. switch (nScreenId) {
  1234. case API_Menu.SubMenuCtrl.HDC_LivingLamp:
  1235. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1236. ret = true;
  1237. break;
  1238. case API_Menu.SubMenuCtrl.HDC_EachLamp:
  1239. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1240. ret = true;
  1241. break;
  1242. case API_Menu.SubMenuCtrl.LivingLightConfig:
  1243. SetTitleText(API_Menu.SubMenuCtrl.Name_LivingLightConfig);
  1244. ret = true;
  1245. break;
  1246. case API_Menu.SubMenuCtrl.OutSide_livingLamp:
  1247. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1248. ret = true;
  1249. break;
  1250. case API_Menu.SubMenuCtrl.OutSide_EachLamp:
  1251. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1252. ret = true;
  1253. break;
  1254. case API_Menu.SubMenuCtrl.HDCLivingNEach_Lamp:
  1255. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1256. ret = true;
  1257. break;
  1258. case API_Menu.SubMenuCtrl.Heating_V2:
  1259. case ID.screen.HeatingV2TestScreen:
  1260. SetTitleText(API_Menu.SubMenuCtrl.Name_Heating);
  1261. ret = true;
  1262. break;
  1263. case API_Menu.SubMenuCtrl.Gas:
  1264. SetTitleText(API_Menu.SubMenuCtrl.Name_Gas);
  1265. ret = true;
  1266. break;
  1267. case API_Menu.SubMenuCtrl.DoorLock485:
  1268. SetTitleText(API_Menu.SubMenuCtrl.Name_DoorLock);
  1269. ret = true;
  1270. break;
  1271. case API_Menu.SubMenuCtrl.DoorLockWL:
  1272. SetTitleText(API_Menu.SubMenuCtrl.Name_DoorLock);
  1273. ret = true;
  1274. break;
  1275. case API_Menu.SubMenuCtrl.ChangAir_Normal:
  1276. case API_Menu.SubMenuCtrl.ChangAir_LH:
  1277. case API_Menu.SubMenuCtrl.ChangAir_Hood:
  1278. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1279. ret = true;
  1280. break;
  1281. case API_Menu.SubMenuCtrl.Inner_AirQuality:
  1282. SetTitleText(API_Menu.SubMenuCtrl.Name_InnerAirQuality);
  1283. ret = true;
  1284. break;
  1285. case API_Menu.SubMenuCtrl.Inner_AirInfo:
  1286. SetTitleText(API_Menu.SubMenuCtrl.Name_InnerAirInfo);
  1287. ret = true;
  1288. break;
  1289. case API_Menu.SubMenuCtrl.Concent:
  1290. case API_Menu.SubMenuCtrl.HDCLivingNEach_Concent:
  1291. SetTitleText(API_Menu.SubMenuCtrl.Name_Concent);
  1292. ret = true;
  1293. break;
  1294. case API_Menu.SubMenuCtrl.SystemAircon:
  1295. case ID.screen.SystemAirconTest1Screen:
  1296. SetTitleText(API_Menu.SubMenuCtrl.Name_SystemAircon);
  1297. ret = true;
  1298. break;
  1299. case API_Menu.SubMenuCtrl.Purity:
  1300. SetTitleText(API_Menu.SubMenuCtrl.Name_Purity);
  1301. ret = true;
  1302. break;
  1303. default:
  1304. Log.e(TAG, "[Error] setTitleName - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  1305. //mCurrentScreenId = -1;
  1306. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1307. ret = false;
  1308. break;
  1309. }
  1310. } catch (RuntimeException re) {
  1311. LogUtil.errorLogInfo("", TAG, re);
  1312. }
  1313. catch (Exception e) {
  1314. Log.e(TAG, "[Exception] setTitleName(int nScreenId)");
  1315. //e.printStackTrace();
  1316. LogUtil.errorLogInfo("", TAG, e);
  1317. }
  1318. return ret;
  1319. }
  1320. /**
  1321. * Screen 등록자<br>
  1322. * ScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  1323. *
  1324. * @param nScreenId - 변경할 Screen ID
  1325. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  1326. * @return (boolean) true : 성공, false : 실패
  1327. */
  1328. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove) {
  1329. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  1330. // 1. 현재 Layout 삭제
  1331. if (mCurrentScreenId > 0) {
  1332. ScreenLayout.removeAllViews();
  1333. super.setCurrentScreen(null);
  1334. }
  1335. if (OnlyRemove) return true;
  1336. mCurrentScreenId = nScreenId;
  1337. mCurrentMultiScreenId = 0;
  1338. setTopBackBtnVisible(false);
  1339. setMultiBtnVisible(false);
  1340. boolean result = false;
  1341. // 2. 새로운 Layout 표시
  1342. try {
  1343. setTitleName(nScreenId);
  1344. //super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
  1345. switch (nScreenId) {
  1346. /**
  1347. * [수정필요]
  1348. * Back Button 필요한 화면은 setTopBackBtnVisible(true) 호출 필요
  1349. * 추가 또는 수정해야할 부분 1. - 스크린 별 layout 생성
  1350. * **/
  1351. //추가 또는 수정해야할 부분 1. - 스크린 별 layout 생성
  1352. case API_Menu.SubMenuCtrl.HDC_LivingLamp: {
  1353. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  1354. // 스마트 분전반
  1355. lightHdcLivMainScreen = new LightHdcLivMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1356. super.setCurrentScreen(lightHdcLivMainScreen);
  1357. setTopBoilerBtnVisible(false);
  1358. setAIRBackBtnVisible(false);
  1359. setKccDimmBtnVisible(false);
  1360. setVentilBackBtnVisible(false);
  1361. result = true;
  1362. break;
  1363. }
  1364. else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  1365. // KNX 분전반
  1366. // madeinlab 새로 만든 스크린으로 적용한다.
  1367. lightKnxMainScreen = new LightKnxMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1368. super.setCurrentScreen(lightKnxMainScreen);
  1369. setTopBoilerBtnVisible(false);
  1370. setAIRBackBtnVisible(false);
  1371. setKccDimmBtnVisible(false);
  1372. setVentilBackBtnVisible(false);
  1373. setManualBtnVisible(false, 1019);
  1374. setMultiBtnVisible(true);
  1375. result = true;
  1376. break;
  1377. }
  1378. }
  1379. /*case API_Menu.SubMenuCtrl.HDC_EachLamp:
  1380. {
  1381. if( (SmartDistUse == 1) && (KnxDistUse == false) ) // 스마트분전반 O / KNX 분전반 X
  1382. {
  1383. lightHdcLivMainScreen = new LightHdcLivMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1384. super.setCurrentScreen(lightHdcLivMainScreen);
  1385. setTopBoilerBtnVisible(false);
  1386. setAIRBackBtnVisible(false);
  1387. setKccDimmBtnVisible(false);
  1388. result = true;
  1389. break;
  1390. }
  1391. else if( (SmartDistUse == 0) && (KnxDistUse == true) ) // 스마트분전반 X / KNX 분전반 O
  1392. {
  1393. lightHdcLivKnxMainScreen = new LightHdcLivKnxMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1394. super.setCurrentScreen(lightHdcLivKnxMainScreen);
  1395. setTopBoilerBtnVisible(false);
  1396. setAIRBackBtnVisible(false);
  1397. setKccDimmBtnVisible(false);
  1398. result = true;
  1399. break;
  1400. }
  1401. }*/
  1402. case API_Menu.SubMenuCtrl.LivingLightConfig:
  1403. lightHdcLivConifgScreen = new LightHdcLivConifgScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1404. super.setCurrentScreen(lightHdcLivConifgScreen);
  1405. setTopBoilerBtnVisible(false);
  1406. setAIRBackBtnVisible(false);
  1407. setKccDimmBtnVisible(false);
  1408. setVentilBackBtnVisible(false);
  1409. result = true;
  1410. break;
  1411. //OutSide_EachLamp
  1412. case API_Menu.SubMenuCtrl.OutSide_EachLamp:
  1413. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1414. lightEtcEachMainScreen = new LightEtcEachMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1415. super.setCurrentScreen(lightEtcEachMainScreen);
  1416. setTopBoilerBtnVisible(false);
  1417. setAIRBackBtnVisible(false);
  1418. setKccDimmBtnVisible(true);
  1419. setVentilBackBtnVisible(false);
  1420. result = true;
  1421. break;
  1422. case API_Menu.SubMenuCtrl.OutSide_livingLamp:
  1423. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1424. lightEtcLivMainScreen = new LightEtcLivMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1425. super.setCurrentScreen(lightEtcLivMainScreen);
  1426. setTopBoilerBtnVisible(false);
  1427. setAIRBackBtnVisible(false);
  1428. setKccDimmBtnVisible(true);
  1429. setVentilBackBtnVisible(false);
  1430. result = true;
  1431. break;
  1432. case API_Menu.SubMenuCtrl.HDCLivingNEach_Lamp:
  1433. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1434. lightHdcNEachMainScreen = new LightHdcNEachMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1435. super.setCurrentScreen(lightHdcNEachMainScreen);
  1436. setTopBoilerBtnVisible(false);
  1437. setAIRBackBtnVisible(false);
  1438. setKccDimmBtnVisible(true);
  1439. setVentilBackBtnVisible(false);
  1440. result = true;
  1441. break;
  1442. case API_Menu.SubMenuCtrl.Heating_V1:
  1443. case API_Menu.SubMenuCtrl.Heating_V2:
  1444. SetTitleText(API_Menu.SubMenuCtrl.Name_Heating);
  1445. try {
  1446. if(wpapi.GetHeatingKind() == 1)
  1447. {
  1448. heatingV1MainScreen = new HeatingV1MainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Heating);
  1449. super.setCurrentScreen(heatingV1MainScreen);
  1450. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  1451. //setTopBoilerBtnVisible(true); // 임시 강제 생성코드
  1452. }
  1453. }
  1454. else
  1455. {
  1456. heatingV2MainScreen = new HeatingV2MainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Heating);
  1457. super.setCurrentScreen(heatingV2MainScreen);
  1458. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  1459. //setTopBoilerBtnVisible(true); // 임시 강제 생성코드
  1460. }
  1461. }
  1462. }
  1463. catch (Exception e)
  1464. {
  1465. heatingV2MainScreen = new HeatingV2MainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Heating);
  1466. super.setCurrentScreen(heatingV2MainScreen);
  1467. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  1468. //setTopBoilerBtnVisible(true); // 임시 강제 생성코드
  1469. }
  1470. }
  1471. setAIRBackBtnVisible(false);
  1472. setKccDimmBtnVisible(false);
  1473. setVentilBackBtnVisible(false);
  1474. setMultiBtnVisible(true);
  1475. result = true;
  1476. break;
  1477. case API_Menu.SubMenuCtrl.Gas:
  1478. try {
  1479. if(wpapi.GetGasKind() == 1)
  1480. {
  1481. SetTitleText(API_Menu.SubMenuCtrl.Name_Gas);
  1482. gasMainScreen = new GasMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1483. super.setCurrentScreen(gasMainScreen);
  1484. }
  1485. else if(wpapi.GetGasKind() == 2)
  1486. {
  1487. SetTitleText(API_Menu.SubMenuCtrl.Name_Gas);
  1488. hybridCookTopMainScreen = new HybridCookTopMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1489. super.setCurrentScreen(hybridCookTopMainScreen);
  1490. }
  1491. else
  1492. {
  1493. SetTitleText(API_Menu.SubMenuCtrl.Name_Gas);
  1494. gasMainScreen = new GasMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1495. super.setCurrentScreen(gasMainScreen);
  1496. }
  1497. }
  1498. catch (Exception e)
  1499. {
  1500. // SetTitleText(API_Menu.SubMenuCtrl.Name_Gas);
  1501. // gasMainScreen = new GasMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1502. // super.setCurrentScreen(gasMainScreen);
  1503. }
  1504. // SetTitleText(API_Menu.SubMenuCtrl.Name_Gas);
  1505. // gasMainScreen = new GasMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1506. // super.setCurrentScreen(gasMainScreen);
  1507. setTopBoilerBtnVisible(false);
  1508. setAIRBackBtnVisible(false);
  1509. setKccDimmBtnVisible(false);
  1510. setVentilBackBtnVisible(false);
  1511. setMultiBtnVisible(true);
  1512. result = true;
  1513. break;
  1514. case API_Menu.SubMenuCtrl.DoorLock485:
  1515. SetTitleText(API_Menu.SubMenuCtrl.Name_DoorLock);
  1516. doorLockMainScreen = new DoorLockMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, API_Menu.SubMenuCtrl.DoorLock485);
  1517. super.setCurrentScreen(doorLockMainScreen);
  1518. setTopBoilerBtnVisible(false);
  1519. setAIRBackBtnVisible(false);
  1520. setKccDimmBtnVisible(false);
  1521. result = true;
  1522. break;
  1523. case API_Menu.SubMenuCtrl.DoorLockWL:
  1524. SetTitleText(API_Menu.SubMenuCtrl.Name_DoorLock);
  1525. doorLockMainScreen = new DoorLockMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, API_Menu.SubMenuCtrl.DoorLockWL);
  1526. super.setCurrentScreen(doorLockMainScreen);
  1527. setTopBoilerBtnVisible(false);
  1528. setAIRBackBtnVisible(false);
  1529. setKccDimmBtnVisible(false);
  1530. result = true;
  1531. break;
  1532. case API_Menu.SubMenuCtrl.ChangAir_Normal:
  1533. case API_Menu.SubMenuCtrl.ChangAir_LH:
  1534. case API_Menu.SubMenuCtrl.ChangAir_Hood:
  1535. if(isUseModelHouse_Venti)
  1536. {
  1537. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1538. ventilationModelMainScreen = new VentilationModelMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1539. super.setFinishTimerDestroy();
  1540. super.setCurrentScreen(ventilationModelMainScreen);
  1541. setTopBoilerBtnVisible(false);
  1542. setAIRBackBtnVisible(false);
  1543. setKccDimmBtnVisible(false);
  1544. setVentilBackBtnVisible(false);
  1545. result = true;
  1546. }
  1547. else
  1548. {
  1549. Log.e(TAG, "[setChangeScreen] getAirSensorAPUsage [" + getAirSensorAPUsage() + "], Support.InnerCycle [" + VentilStatus.Support.InnerCycle + "], Support.OutAirClean [" + VentilStatus.Support.OutAirClean + "]");
  1550. if (getAirSensorAPUsage() && VentilStatus.Support.InnerCycle && VentilStatus.Support.OutAirClean) {
  1551. if(isUseModelHouse_Venti)
  1552. {
  1553. ventilationModelMainScreen = new VentilationModelMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1554. super.setCurrentScreen(ventilationModelMainScreen);
  1555. super.setFinishTimerDestroy();
  1556. }
  1557. else
  1558. {
  1559. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  1560. //고급향은 환기가 3개임. KNX 쪽으로 우선 분기를 태움.
  1561. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1562. //고급향 환기 테스트 때문에 임시로 바꿈.
  1563. //knxVentiMainScreen = new KnxVentiMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1564. //super.setCurrentScreen(knxVentiMainScreen);
  1565. ventilationMainScreen = new VentilationMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1566. super.setCurrentScreen(ventilationMainScreen);
  1567. }
  1568. else {
  1569. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1570. ventilationMainScreen = new VentilationMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1571. super.setCurrentScreen(ventilationMainScreen);
  1572. }
  1573. }
  1574. setTopBoilerBtnVisible(false);
  1575. setAIRBackBtnVisible(false);
  1576. setKccDimmBtnVisible(false);
  1577. setVentilBackBtnVisible(false);
  1578. setMultiBtnVisible(true);
  1579. result = true;
  1580. }
  1581. else {
  1582. if (GetEasyModeUXUse() == true) {
  1583. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1584. ventiEasymodeScreen = new VentiEasymodeScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1585. super.setCurrentScreen(ventiEasymodeScreen);;
  1586. setTopBoilerBtnVisible(false);
  1587. setAIRBackBtnVisible(false);
  1588. setKccDimmBtnVisible(false);
  1589. setVentilBackBtnVisible(false);
  1590. result = true;
  1591. }
  1592. else {
  1593. if (VentilStatus.Support2.WindowVenti) {
  1594. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1595. ventiMainScreen = new VentiMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1596. super.setCurrentScreen(ventiMainScreen);
  1597. }
  1598. else {
  1599. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  1600. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1601. //테스트 때문에 바꿈
  1602. //knxVentiMainScreen = new KnxVentiMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1603. //super.setCurrentScreen(knxVentiMainScreen);
  1604. ventilationMainScreen = new VentilationMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1605. super.setCurrentScreen(ventilationMainScreen);
  1606. setManualBtnVisible(false, 1019);
  1607. }
  1608. else {
  1609. SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1610. ventilationMainScreen = new VentilationMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1611. super.setCurrentScreen(ventilationMainScreen);
  1612. // SetTitleText(API_Menu.SubMenuCtrl.Name_Venti);
  1613. // ventiMainScreen = new VentiMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, API_Menu.SubMenuCtrl.ChangAir_Normal);
  1614. // super.setCurrentScreen(ventiMainScreen);
  1615. }
  1616. }
  1617. setTopBoilerBtnVisible(false);
  1618. setAIRBackBtnVisible(false);
  1619. setKccDimmBtnVisible(false);
  1620. setVentilBackBtnVisible(false);
  1621. setMultiBtnVisible(true);
  1622. result = true;
  1623. }
  1624. }
  1625. }
  1626. break;
  1627. case API_Menu.SubMenuCtrl.Inner_AirQuality:
  1628. SetTitleText(API_Menu.SubMenuCtrl.Name_InnerAirQuality);
  1629. airQualityMainScreen = new AirQualityMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1630. super.setCurrentScreen(airQualityMainScreen);
  1631. setTopBoilerBtnVisible(false);
  1632. setAIRBackBtnVisible(false);
  1633. setKccDimmBtnVisible(false);
  1634. setVentilBackBtnVisible(false);
  1635. result = true;
  1636. break;
  1637. case API_Menu.SubMenuCtrl.Inner_AirInfo:
  1638. SetTitleText(API_Menu.SubMenuCtrl.Name_InnerAirInfo);
  1639. dustInfoScreen = new DustInfoScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1640. super.setCurrentScreen(dustInfoScreen);
  1641. setTopBoilerBtnVisible(false);
  1642. setAIRBackBtnVisible(false);
  1643. setKccDimmBtnVisible(false);
  1644. setVentilBackBtnVisible(false);
  1645. result = true;
  1646. break;
  1647. case API_Menu.SubMenuCtrl.Concent:
  1648. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  1649. SetTitleText(API_Menu.SubMenuCtrl.Name_Concent);
  1650. concentKnxMainScreen = new ConcentKnxMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1651. super.setCurrentScreen(concentKnxMainScreen);
  1652. setManualBtnVisible(false, 1019);
  1653. }
  1654. else {
  1655. SetTitleText(API_Menu.SubMenuCtrl.Name_Concent);
  1656. concentMainScreen = new ConcentMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mDefaultRoomNameList_Light);
  1657. super.setCurrentScreen(concentMainScreen);
  1658. setManualBtnVisible(getManualUse(), 1019);
  1659. }
  1660. setTopBoilerBtnVisible(false);
  1661. setAIRBackBtnVisible(false);
  1662. setKccDimmBtnVisible(false);
  1663. setVentilBackBtnVisible(false);
  1664. result = true;
  1665. break;
  1666. case API_Menu.SubMenuCtrl.HDCLivingNEach_Concent:
  1667. SetTitleText(API_Menu.SubMenuCtrl.Name_Concent);
  1668. concentHdcNEachMainScreen = new ConcentHdcNEachMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1669. super.setCurrentScreen(concentHdcNEachMainScreen);
  1670. setTopBoilerBtnVisible(false);
  1671. setAIRBackBtnVisible(false);
  1672. setKccDimmBtnVisible(false);
  1673. setVentilBackBtnVisible(false);
  1674. setManualBtnVisible(false, 1019);
  1675. result = true;
  1676. break;
  1677. case API_Menu.SubMenuCtrl.Electric_Range:
  1678. SetTitleText(API_Menu.SubMenuCtrl.Name_ElectricRange);
  1679. electricRangeMainScreen = new ElectricRangeMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1680. super.setCurrentScreen(electricRangeMainScreen);
  1681. setTopBoilerBtnVisible(false);
  1682. setAIRBackBtnVisible(false);
  1683. setKccDimmBtnVisible(false);
  1684. setVentilBackBtnVisible(false);
  1685. result = true;
  1686. break;
  1687. case API_Menu.SubMenuCtrl.Cooktop_Concent:
  1688. SetTitleText(API_Menu.SubMenuCtrl.Name_CooktopConcent);
  1689. cookTopConcentMainScreen = new CookTopConcentMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1690. super.setCurrentScreen(cookTopConcentMainScreen);
  1691. setTopBoilerBtnVisible(false);
  1692. setAIRBackBtnVisible(false);
  1693. setKccDimmBtnVisible(false);
  1694. setVentilBackBtnVisible(false);
  1695. result = true;
  1696. break;
  1697. case API_Menu.SubMenuCtrl.SystemAircon:
  1698. SetTitleText(API_Menu.SubMenuCtrl.Name_SystemAircon);
  1699. systemAirconMainScreen = new SystemAirconMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mDefaultRoomNameList);
  1700. super.setCurrentScreen(systemAirconMainScreen);
  1701. setTopBoilerBtnVisible(false);
  1702. setAIRBackBtnVisible(false);
  1703. setKccDimmBtnVisible(false);
  1704. setVentilBackBtnVisible(false);
  1705. setManualBtnVisible(false, 1019);
  1706. setMultiBtnVisible(true);
  1707. result = true;
  1708. break;
  1709. case API_Menu.SubMenuCtrl.Purity:
  1710. SetTitleText(API_Menu.SubMenuCtrl.Name_Purity);
  1711. purityMainScreen = new PurityMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mDefaultRoomNameList);
  1712. super.setCurrentScreen(purityMainScreen);
  1713. setTopBoilerBtnVisible(false);
  1714. setAIRBackBtnVisible(false);
  1715. setKccDimmBtnVisible(false);
  1716. setVentilBackBtnVisible(false);
  1717. result = true;
  1718. break;
  1719. case API_Menu.SubMenuCtrl.ParkingDoor:
  1720. SetTitleText(API_Menu.SubMenuCtrl.Name_ParkingDoor);
  1721. parkingDoorMainScreen = new ParkingDoorMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, API_Menu.SubMenuCtrl.ParkingDoor);
  1722. super.setCurrentScreen(parkingDoorMainScreen);
  1723. setTopBoilerBtnVisible(false);
  1724. setAIRBackBtnVisible(false);
  1725. setKccDimmBtnVisible(false);
  1726. result = true;
  1727. break;
  1728. default:
  1729. Log.i(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  1730. if (Version.getGatewayUsage()) {
  1731. // 게이트웨이 사용
  1732. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1733. lightHdcLivMainScreen = new LightHdcLivMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1734. super.setCurrentScreen(lightHdcLivMainScreen);
  1735. setTopBoilerBtnVisible(false);
  1736. setAIRBackBtnVisible(false);
  1737. setKccDimmBtnVisible(false);
  1738. setVentilBackBtnVisible(false);
  1739. }
  1740. else {
  1741. // 게이트웨이 미사용
  1742. SetTitleText(API_Menu.SubMenuCtrl.Name_Lamp);
  1743. lightEtcEachMainScreen = new LightEtcEachMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1744. super.setCurrentScreen(lightEtcEachMainScreen);
  1745. setTopBoilerBtnVisible(false);
  1746. setAIRBackBtnVisible(false);
  1747. setKccDimmBtnVisible(true);
  1748. setVentilBackBtnVisible(false);
  1749. }
  1750. result = false;
  1751. break;
  1752. //mCurrentScreenId = -1;
  1753. //return false;
  1754. }
  1755. } catch (RuntimeException re) {
  1756. LogUtil.errorLogInfo("", TAG, re);
  1757. return false;
  1758. }
  1759. catch (Exception e) {
  1760. Log.e(TAG, "[Exception] setChangeScreen(int nScreenId, boolean OnlyRemove)");
  1761. //e.printStackTrace();
  1762. LogUtil.errorLogInfo("", TAG, e);
  1763. return false;
  1764. }
  1765. return result;
  1766. }
  1767. /**
  1768. * Screen 등록자<br>
  1769. * ScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  1770. *
  1771. * @param nScreenId - 변경할 Screen ID
  1772. * @param ho - 멀티제어하려논 호
  1773. * @return (boolean) true : 성공, false : 실패
  1774. */
  1775. private boolean setMultiScreen(int nScreenId, int ho) {
  1776. // 1. 현재 Layout 삭제
  1777. if (mCurrentScreenId > 0) {
  1778. ScreenLayout.removeAllViews();
  1779. super.setCurrentScreen(null);
  1780. }
  1781. mMultiAddress = ho;
  1782. setTopBackBtnVisible(false);
  1783. boolean result = false;
  1784. // 2. 새로운 Layout 표시
  1785. try {
  1786. setTitleName(nScreenId);
  1787. //super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
  1788. switch (nScreenId) {
  1789. case ID.screen.SystemAirconTest1Screen: // sub - 공지사항 내용
  1790. SystemAirconTestScreen systemAirconTest1Screen = new SystemAirconTestScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mDefaultRoomNameList);
  1791. super.setCurrentScreen(systemAirconTest1Screen);
  1792. result = true;
  1793. break;
  1794. case ID.screen.LightKnxMainTestScreen: // sub - 공지사항 내용
  1795. LightKnxMainTestScreen lightKnxMainTestScreen = new LightKnxMainTestScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Light);
  1796. super.setCurrentScreen(lightKnxMainTestScreen);
  1797. result = true;
  1798. break;
  1799. case ID.screen.HeatingV2TestScreen: // sub - 공지사항 내용
  1800. HeatingV2TestScreen heatingV2TestScreen = new HeatingV2TestScreen(this, ScreenLayout, wpapi, OPERATION_MODE, mRoomNameList_Heating);
  1801. super.setCurrentScreen(heatingV2TestScreen);
  1802. mCurrentMultiScreenId = ID.screen.HeatingV2TestScreen;
  1803. result = true;
  1804. break;
  1805. case ID.screen.GasTestScreen: // 가스
  1806. HybridCookTopTestScreen hybridCookTopTestScreen = new HybridCookTopTestScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  1807. super.setCurrentScreen(hybridCookTopTestScreen);
  1808. result = true;
  1809. break;
  1810. case ID.screen.VentiMainTestScreen: // 환기
  1811. VentilationMainTestScreen ventilationMainTestScreen = new VentilationMainTestScreen(this, ScreenLayout, wpapi, OPERATION_MODE, nScreenId);
  1812. super.setCurrentScreen(ventilationMainTestScreen);
  1813. result = true;
  1814. break;
  1815. default:
  1816. result = false;
  1817. break;
  1818. }
  1819. } catch (RuntimeException re) {
  1820. LogUtil.errorLogInfo("", TAG, re);
  1821. return false;
  1822. }
  1823. catch (Exception e) {
  1824. LogUtil.errorLogInfo("", TAG, e);
  1825. return false;
  1826. }
  1827. return result;
  1828. }
  1829. /**
  1830. * 상단 타이틀 텍스트 수정
  1831. *
  1832. * @param SetText (String) 수정할 타이틀 이름
  1833. **/
  1834. private void SetTitleText(String SetText) {
  1835. if (SetText != null) {
  1836. TopTitle.setText(SetText);
  1837. }
  1838. }
  1839. /* ================================================================================================
  1840. * [Menu Layout] Section
  1841. ================================================================================================ */
  1842. /**
  1843. * 메뉴 레이아웃 생성
  1844. **/
  1845. private void OpenMenuLayout() {
  1846. Log.i(TAG, "Enter OpenMenuLayout !!!");
  1847. if (MenuOpen == true) {
  1848. Log.e(TAG, "[OpenMenuLayout] MenuOpen");
  1849. return;
  1850. }
  1851. if (menueListDataClass == null) {
  1852. Log.e(TAG, "[OpenMenuLayout] menueListDataClass is null");
  1853. return;
  1854. }
  1855. //0. 현재 ID 및 리스트 불러오기
  1856. String Title = API_Menu.GetGroupNameByID((mCurrentScreenId / 1000) * 1000);
  1857. String TempChildName = null;
  1858. int ChooseGroup = 0;
  1859. int ChooseChild = 0;
  1860. for (int i = 0; i < menueListDataClass.arrayGroup.size(); i++) {
  1861. if (menueListDataClass.arrayGroup.get(i).equals(Title)) {
  1862. ChooseGroup = i;
  1863. break;
  1864. }
  1865. }
  1866. Log.i(TAG, "[OpenMenuLayout] - ChooseGroup = " + ChooseGroup);
  1867. for (int i = 0; i < menueListDataClass.idMappingTable.length; i++) {
  1868. if (menueListDataClass.idMappingTable[i].Id == mCurrentScreenId) {
  1869. TempChildName = menueListDataClass.idMappingTable[i].Name;
  1870. break;
  1871. }
  1872. }
  1873. Log.i(TAG, "[OpenMenuLayout] - TempChildName = " + TempChildName);
  1874. if (TempChildName == null) {
  1875. Log.e(TAG, "TempChildName is null");
  1876. return;
  1877. }
  1878. for (int i = 0; i < menueListDataClass.arrayChild.get(Title).size(); i++) {
  1879. if (menueListDataClass.arrayChild.get(Title).get(i).equals(TempChildName) == true) {
  1880. ChooseChild = i;
  1881. break;
  1882. }
  1883. }
  1884. //1. 기존 화면 투명도 변경
  1885. TopLayout.setAlpha(0.5f);
  1886. ScreenLayout.setAlpha(0.5f);
  1887. //2. Layout 생성 및 처리 이벤트 등록
  1888. MenuLayout = new RelativeLayout(this);
  1889. WpadUtil.LayoutRegistration(AllLayout, MenuLayout, 1280, 800, 0, 0, ID.main.layout.MENU);
  1890. MenuLayout.setOnTouchListener(new OnTouchListener() {
  1891. @Override
  1892. public boolean onTouch(View v, MotionEvent event) {
  1893. if (event.getAction() == MotionEvent.ACTION_UP) {
  1894. setFinishTimerReset();
  1895. CloseMenuLayout();
  1896. }
  1897. return true;
  1898. }
  1899. });
  1900. //3. 배경 이미지 생성 및 에니메이션 등록
  1901. MenuBackground = new WpadImageView(this, TOUCH_KIND.BUTTON, 460, 800, R.drawable.bg_menu, R.drawable.bg_menu, ID.main.image.TAB_BACKGROUND);
  1902. TranslateAnimation anim = new TranslateAnimation(WpadScale.getWidth(-460), 0, 0, 0);
  1903. anim.setDuration(200);
  1904. anim.setInterpolator(new AccelerateInterpolator());
  1905. MenuLayout.setAnimation(anim);
  1906. ViewRegistration(MenuLayout, MenuBackground, 0, 0);
  1907. //4. 타이틀 등록
  1908. MenuTitle = new WpadTextView(this, false, 247, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE);
  1909. ViewRegistration(MenuLayout, MenuTitle, 133, 15);
  1910. MenuTitle.setText(Title);
  1911. //5. 종료 버튼 등록
  1912. 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);
  1913. MenuClose.setTouchDelayMs(1000);
  1914. ViewRegistration(MenuLayout, MenuClose, 380, 15);
  1915. //6. 리스트뷰 초기화 및 등록
  1916. mListView = new ExpandableListView(this);
  1917. ExpandableListView.LayoutParams params = new ExpandableListView.LayoutParams(WpadScale.getWidth(460), WpadScale.getHeight(690));
  1918. mListView.setLayoutParams(params);
  1919. mListView.setX(WpadScale.getWidth(0));
  1920. mListView.setY(WpadScale.getHeight(112));
  1921. mListView.setBackgroundColor(Color.BLACK);
  1922. mListView.setId(ID.main.liveview.lv);
  1923. mListView.setGroupIndicator(null);
  1924. mListView.setDividerHeight(0);
  1925. mListView.setDivider(null);
  1926. mListView.setFocusable(true);
  1927. mListView.setSmoothScrollbarEnabled(true);
  1928. mListView.setTranscriptMode(android.widget.AbsListView.TRANSCRIPT_MODE_DISABLED);
  1929. mListView.setScrollbarFadingEnabled(true);
  1930. MenuLayout.addView(mListView);
  1931. adptMain = new Menu_AdptMain(this, menueListDataClass.arrayGroup, menueListDataClass.arrayChild, ChooseGroup, ChooseChild);
  1932. mListView.setAdapter(adptMain);
  1933. //7. 선택된 그룹 열기
  1934. mListView.setSelectedGroup(ChooseGroup);
  1935. mListView.expandGroup(ChooseGroup);
  1936. // 8. 리스트뷰 터치 이벤트 등록
  1937. mListView.setOnTouchListener(new OnTouchListener() {
  1938. @Override
  1939. public boolean onTouch(View v, MotionEvent event) {
  1940. if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
  1941. (event.getAction() == MotionEvent.ACTION_UP)) {
  1942. WpadActivity.setFinishTimerReset();
  1943. }
  1944. return false;
  1945. }
  1946. });
  1947. // 9. 그룹 터치 이벤트 등록
  1948. mListView.setOnGroupClickListener(new OnGroupClickListener() {
  1949. @Override
  1950. public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
  1951. DebugLogOutput("group click = " + groupPosition);
  1952. WpadActivity.setFinishTimerReset();
  1953. return false;
  1954. }
  1955. });
  1956. // 10. 차일드 터치 이벤트 등록
  1957. /*
  1958. mListView.setOnChildClickListener(new OnChildClickListener()
  1959. {
  1960. @Override
  1961. public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
  1962. {
  1963. DebugLogOutput("onChildClick");
  1964. DebugLogOutput("groupPosition = " + groupPosition);
  1965. DebugLogOutput("childPosition = " + childPosition);
  1966. WpadActivity.setFinishTimerReset();
  1967. return false;
  1968. }
  1969. });
  1970. */
  1971. // 11. 그룹 열리는 경우 이벤트
  1972. mListView.setOnGroupExpandListener(new OnGroupExpandListener() {
  1973. @Override
  1974. public void onGroupExpand(int groupPosition) {
  1975. DebugLogOutput("groupPosition Open Event = " + groupPosition);
  1976. Sound().Play(SND.effect.TOUCH_LATCHED);
  1977. WpadActivity.setFinishTimerReset();
  1978. }
  1979. });
  1980. // 12. 그룹 닫히는 경우 이벤트
  1981. mListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {
  1982. @Override
  1983. public void onGroupCollapse(int groupPosition) {
  1984. DebugLogOutput("groupPosition Close Event = " + groupPosition);
  1985. Sound().Play(SND.effect.TOUCH_LATCHED);
  1986. WpadActivity.setFinishTimerReset();
  1987. }
  1988. });
  1989. // 13. MenuOpen True 설정
  1990. MenuOpen = true;
  1991. }
  1992. /**
  1993. * 메뉴 layout 닫힘 처리
  1994. **/
  1995. private void CloseMenuLayout() {
  1996. if (MenuOpen == false) {
  1997. return;
  1998. }
  1999. TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0);
  2000. anim.setDuration(200);
  2001. anim.setInterpolator(new AccelerateInterpolator());
  2002. anim.setAnimationListener(new AnimationListener() {
  2003. @Override
  2004. public void onAnimationStart(Animation animation) {
  2005. MenuOpen = false;
  2006. }
  2007. @Override
  2008. public void onAnimationRepeat(Animation animation) {
  2009. }
  2010. @Override
  2011. public void onAnimationEnd(Animation animation) {
  2012. AllLayout.removeView(MenuLayout);
  2013. TopLayout.setAlpha(1.0f);
  2014. ScreenLayout.setAlpha(1.0f);
  2015. }
  2016. });
  2017. MenuLayout.startAnimation(anim);
  2018. }
  2019. /**
  2020. * 메뉴 그룹 터치시 처리 (Menu_AdptMain에서 호출)
  2021. **/
  2022. public static void SetListViewGroupExpand_Collapse(int GroupID, boolean ExpandEnable) {
  2023. if (ExpandEnable) {
  2024. mListView.expandGroup(GroupID);
  2025. }
  2026. else {
  2027. mListView.collapseGroup(GroupID);
  2028. }
  2029. }
  2030. /**
  2031. * Menu정보가 DB에 없을 경우 불러올 스크린 로딩
  2032. *
  2033. * @return MenuListDataClass 타입의 초기정보
  2034. **/
  2035. private MenuListDataClass loadDefaultMenuList() {
  2036. try {
  2037. MenuListDataClass tempMenuListDataClass = new MenuListDataClass();
  2038. tempMenuListDataClass.SetArrayGroup(API_Menu.SubMenuCtrl.Name);
  2039. ArrayList<String> arrayList = new ArrayList<String>();
  2040. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2041. int nAirQualitySensorUsage = mWallpadDeviceSet.GetDeviceSetted("센서AP");
  2042. int[] nLightType = mWallpadDeviceSet.Get_Light_info();
  2043. int[] nDoorlockType = mWallpadDeviceSet.Get_DoorLock_Info();
  2044. int[] nVentilType = mWallpadDeviceSet.Get_Ventil_Info();
  2045. int nHeatingUsage = mWallpadDeviceSet.Get_Temper_Info();
  2046. int nGasValveUsage = mWallpadDeviceSet.Get_GAS_Info();
  2047. boolean bElecCooktopUsage = mWallpadDeviceSet.Get_ElectricRange_Use();
  2048. boolean bCooktopOutletUsage = mWallpadDeviceSet.Get_CookTopConcent_Use();
  2049. int nSystemAirconUsage = mWallpadDeviceSet.Get_AirCON_Info();
  2050. int nPurityUsage = mWallpadDeviceSet.Get_Purity_Info();
  2051. mWallpadDeviceSet.closeDB();
  2052. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getContext());
  2053. boolean bElecOutletUsage = mWallpadStatusData.Get_MultiSwitch_Concent_Use();
  2054. mWallpadStatusData.closeDB();
  2055. int nChildCnt = 0;
  2056. //[수정필요]
  2057. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작)
  2058. if (nLightType[0] == WallpadDeviceSet.DO_USE) {
  2059. arrayList.add(API_Menu.SubMenuCtrl.Name_Lamp);
  2060. nChildCnt++;
  2061. }
  2062. if (nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_ROOM || nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  2063. Log.i(TAG, "[loadDefaultMenuList] bElecOutletUsage = " + bElecOutletUsage + " @@@@@@@@@@@@@@@@");
  2064. Log.i(TAG, "[loadDefaultMenuList] MultiConcentExist = " + bMultiConcentExist + " @@@@@@@@@@@@@@@@");
  2065. if ((OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) || (nLightType[0] == 1 && bElecOutletUsage && bMultiConcentExist)) {
  2066. // Log.i(TAG, "[loadDefaultMenuList] Add Concent @@@@@@@@@@@@@@@@");
  2067. arrayList.add(API_Menu.SubMenuCtrl.Name_Concent);
  2068. nChildCnt++;
  2069. }
  2070. }
  2071. if (nHeatingUsage == WallpadDeviceSet.DO_USE) {
  2072. arrayList.add(API_Menu.SubMenuCtrl.Name_Heating);
  2073. nChildCnt++;
  2074. }
  2075. if (nGasValveUsage == WallpadDeviceSet.DO_USE) {
  2076. arrayList.add(API_Menu.SubMenuCtrl.Name_Gas);
  2077. nChildCnt++;
  2078. }
  2079. if (bCooktopOutletUsage) {
  2080. // 쿡탑콘센트
  2081. arrayList.add(API_Menu.SubMenuCtrl.Name_CooktopConcent);
  2082. nChildCnt++;
  2083. Log.i(TAG, "cooktopConcentUse = " + bCooktopOutletUsage + " @@@@@@@@@@@@@@@@");
  2084. Log.i(TAG, "Name_CooktopConcent Added ~~~ " + " @@@@@@@@@@@@@@@@");
  2085. }
  2086. if (bElecCooktopUsage) {
  2087. arrayList.add(API_Menu.SubMenuCtrl.Name_ElectricRange);
  2088. nChildCnt++;
  2089. }
  2090. if (nDoorlockType[0] == WallpadDeviceSet.DO_USE) {
  2091. arrayList.add(API_Menu.SubMenuCtrl.Name_DoorLock);
  2092. nChildCnt++;
  2093. }
  2094. if (nVentilType[0] == WallpadDeviceSet.DO_USE) {
  2095. arrayList.add(API_Menu.SubMenuCtrl.Name_Venti);
  2096. nChildCnt++;
  2097. }
  2098. if (nSystemAirconUsage != WallpadDeviceSet.SYSTEMAIRCON_NONE) {
  2099. arrayList.add(API_Menu.SubMenuCtrl.Name_SystemAircon);
  2100. nChildCnt++;
  2101. }
  2102. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2103. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2104. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF)
  2105. {
  2106. if (!bKitchenLightonLivingEM &&(nDistributionPanelType != Version.DISTRIBUTION_MODEL.KNX_DIST)) {
  2107. // knx분전반은 거실조명 그룹설정 메뉴에서 빠짐
  2108. arrayList.add(API_Menu.SubMenuCtrl.Name_LivingLightConfig);
  2109. nChildCnt++;
  2110. }
  2111. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  2112. arrayList.add(API_Menu.SubMenuCtrl.Name_Concent);
  2113. nChildCnt++;
  2114. }
  2115. if (nPurityUsage == WallpadDeviceSet.DO_USE) {
  2116. arrayList.add(API_Menu.SubMenuCtrl.Name_Purity);
  2117. nChildCnt++;
  2118. }
  2119. }
  2120. if (nAirQualitySensorUsage == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2121. arrayList.add(API_Menu.SubMenuCtrl.Name_InnerAirQuality);
  2122. nChildCnt++;
  2123. arrayList.add(API_Menu.SubMenuCtrl.Name_InnerAirInfo);
  2124. nChildCnt++;
  2125. }
  2126. //for test
  2127. arrayList.add(API_Menu.SubMenuCtrl.Name_ParkingDoor);
  2128. nChildCnt++;
  2129. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝)
  2130. Log.i(TAG, "[loadDefaultMenuList] childCount = " + nChildCnt);
  2131. tempMenuListDataClass.SetArrayChild(API_Menu.SubMenuCtrl.Name, arrayList);
  2132. tempMenuListDataClass.idMappingTable = new ChildIDMapping[nChildCnt];
  2133. for (int i = 0; i < nChildCnt; i++) {
  2134. tempMenuListDataClass.idMappingTable[i] = new ChildIDMapping();
  2135. //[수정필요]
  2136. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 ID를 임의로 입력(시작)
  2137. // Log.d(TAG, "[loadDefaultMenuList] arrayList.get(" + i + ") = " + arrayList.get(i));
  2138. if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_Lamp)) {
  2139. if (Version.getGatewayUsage()) {
  2140. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I
  2141. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  2142. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.HDCLivingNEach_Lamp;
  2143. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Lamp;
  2144. }
  2145. else {
  2146. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  2147. // 스마트 분전반
  2148. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.HDC_LivingLamp;
  2149. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Lamp;
  2150. }
  2151. else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  2152. // KNX 분전반
  2153. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.HDC_LivingLamp;
  2154. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Lamp;
  2155. }
  2156. else {
  2157. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.HDC_LivingLamp;
  2158. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Lamp;
  2159. }
  2160. }
  2161. }
  2162. else {
  2163. if (nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  2164. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.OutSide_livingLamp;
  2165. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Lamp;
  2166. }
  2167. else if (nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  2168. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.OutSide_EachLamp;
  2169. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Lamp;
  2170. }
  2171. }
  2172. }
  2173. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_Concent)) {
  2174. if (nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  2175. if ((OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) || (bElecOutletUsage && bMultiConcentExist)) {
  2176. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Concent;
  2177. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Concent;
  2178. }
  2179. }
  2180. else if (nLightType[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  2181. if ((OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) || (bElecOutletUsage && bMultiConcentExist)) {
  2182. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.HDCLivingNEach_Concent;
  2183. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Concent;
  2184. }
  2185. }
  2186. else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  2187. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Concent;
  2188. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Concent;
  2189. }
  2190. }
  2191. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_Gas)) {
  2192. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Gas;
  2193. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Gas;
  2194. }
  2195. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_CooktopConcent)) {
  2196. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Cooktop_Concent;
  2197. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_CooktopConcent;
  2198. }
  2199. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_DoorLock)) {
  2200. if (nDoorlockType[1] == DOORLOCK_TYPE_NORMAL) {
  2201. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.DoorLock485;
  2202. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_DoorLock;
  2203. }
  2204. else if (nDoorlockType[1] == DOORLOCK_TYPE_RF) {
  2205. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.DoorLockWL;
  2206. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_DoorLock;
  2207. }
  2208. else if (nDoorlockType[1] == DOORLOCK_TYPE_FINGERPRINT) {
  2209. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.DoorLockWL;
  2210. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_DoorLock;
  2211. }
  2212. }
  2213. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_Venti)) {
  2214. Log.d(TAG, "[loadDefaultMenuList] nVentilType[1] = " + nVentilType[1]);
  2215. if (nVentilType[1] == WallpadDeviceSet.VENTIL_TYPE_NORMAL) {
  2216. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.ChangAir_Normal;
  2217. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Venti;
  2218. }
  2219. else if (nVentilType[1] == WallpadDeviceSet.VENTIL_TYPE_LH) {
  2220. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.ChangAir_LH;
  2221. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Venti;
  2222. }
  2223. else if (nVentilType[1] == WallpadDeviceSet.VENTIL_TYPE_HOOD) {
  2224. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.ChangAir_Hood;
  2225. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Venti;
  2226. }
  2227. }
  2228. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_Heating)) {
  2229. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Heating_V2;
  2230. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Heating;
  2231. }
  2232. /*
  2233. //확인 필요
  2234. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_Heating)) {
  2235. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Heating_V1;
  2236. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_Heating;
  2237. }
  2238. */
  2239. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_InnerAirQuality)) {
  2240. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Inner_AirQuality;
  2241. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_InnerAirQuality;
  2242. }
  2243. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_InnerAirInfo)) {
  2244. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Inner_AirInfo;
  2245. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_InnerAirInfo;
  2246. }
  2247. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_ElectricRange)) {
  2248. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.Electric_Range;
  2249. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_ElectricRange;
  2250. }
  2251. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_SystemAircon)) {
  2252. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.SystemAircon;
  2253. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_SystemAircon;
  2254. }
  2255. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_LivingLightConfig)) {
  2256. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.LivingLightConfig;
  2257. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_LivingLightConfig;
  2258. }
  2259. else if (arrayList.get(i).equals(API_Menu.SubMenuCtrl.Name_ParkingDoor)) {
  2260. tempMenuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuCtrl.ParkingDoor;
  2261. tempMenuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuCtrl.Name_ParkingDoor;
  2262. }
  2263. else {
  2264. Log.w(TAG, "[loadDefaultMenuList] arrayList.get(" + i + ") is not supported menu!!");
  2265. }
  2266. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 ID를 임의로 입력(끝)
  2267. }
  2268. // for (int j = 0; j < tempMenuListDataClass.idMappingTable.length; j++) {
  2269. // Log.d(TAG, "[loadDefaultMenuList] tempMenuListDataClass.idMappingTable[" + j + "].Name = " + tempMenuListDataClass.idMappingTable[j].Name);
  2270. // Log.d(TAG, "[loadDefaultMenuList] tempMenuListDataClass.idMappingTable[" + j + "].Id = " + tempMenuListDataClass.idMappingTable[j].Id);
  2271. // }
  2272. return tempMenuListDataClass;
  2273. } catch (RuntimeException re) {
  2274. LogUtil.errorLogInfo("", TAG, re);
  2275. return null;
  2276. }
  2277. catch (Exception e) {
  2278. Log.e(TAG, "[Exception] loadDefaultMenuList()");
  2279. //e.printStackTrace();
  2280. LogUtil.errorLogInfo("", TAG, e);
  2281. return null;
  2282. }
  2283. }
  2284. /**
  2285. * Menu Event intent filter 등록
  2286. **/
  2287. private void reg_Receiver() {
  2288. try {
  2289. IntentFilter filter = new IntentFilter();
  2290. filter.addAction("MENU_EVENT");
  2291. registerReceiver(mWallPadAlertBR, filter);
  2292. filter = new IntentFilter();
  2293. filter.addAction(define.NOTIFY_DAIL);
  2294. filter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH");
  2295. registerReceiver(mWallPadJogBR, filter);
  2296. filter = new IntentFilter();
  2297. filter.addAction(ID.main.BR_KCC_DIM);
  2298. registerReceiver(mKccDimmBR, filter);
  2299. } catch (RuntimeException re) {
  2300. LogUtil.errorLogInfo("", TAG, re);
  2301. }
  2302. catch (Exception e) {
  2303. Log.e(TAG, "[Exception] reg_Receiver()");
  2304. //e.printStackTrace();
  2305. LogUtil.errorLogInfo("", TAG, e);
  2306. }
  2307. }
  2308. /**
  2309. * 조그버튼 입력 받을 시 처리
  2310. **/
  2311. BroadcastReceiver mWallPadJogBR = new BroadcastReceiver() {
  2312. @Override
  2313. public void onReceive(Context context, Intent intent) {
  2314. WpadActivity.setFinishTimerReset();
  2315. }
  2316. };
  2317. /**
  2318. * KCC디밍조절기 BR 등록
  2319. **/
  2320. BroadcastReceiver mKccDimmBR = new BroadcastReceiver() {
  2321. @Override
  2322. public void onReceive(Context context, Intent intent) {
  2323. WpadActivity.setFinishTimerReset();
  2324. DebugLogOutput("[mKccDimmBR] - onReceive - mKccDimmBR");
  2325. Device_Update_Dimming(false, (byte)0);
  2326. Draw_Update_DimmBtn();
  2327. }
  2328. };
  2329. /**
  2330. * 메뉴에서 버튼 터치 처리
  2331. **/
  2332. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  2333. @Override
  2334. public void onReceive(Context context, Intent intent) {
  2335. int groupPosition = intent.getIntExtra("groupPosition", -1);
  2336. int childPosition = intent.getIntExtra("childPosition", -1);
  2337. Log.i(TAG, "[mWallPadAlertBR] groupPosition :" + groupPosition + ", childPosition :" + childPosition);
  2338. if ((groupPosition >= 0) && (childPosition >= 0)) {
  2339. if (MenuOpen == true) {
  2340. Sound().Play(SND.effect.TOUCH_LATCHED);
  2341. CloseMenuLayout();
  2342. if (menueListDataClass == null) {
  2343. return;
  2344. }
  2345. String childName = menueListDataClass.arrayChild.get(menueListDataClass.arrayGroup.get(groupPosition)).get(childPosition);
  2346. for (int i = 0; i < menueListDataClass.idMappingTable.length; i++) {
  2347. if (menueListDataClass.idMappingTable[i].Name.equals(childName)) {
  2348. API_Menu api_Menu = new API_Menu();
  2349. int TempID = api_Menu.GetMyGroupID(getApplicationContext().getPackageName());
  2350. int ChildID = menueListDataClass.idMappingTable[i].Id;
  2351. int ChildGroupID = (ChildID / 1000) * 1000;
  2352. Log.i(TAG, "[mWallPadAlertBR] Child ID :" + ChildID);
  2353. if (TempID == 0) {
  2354. return;
  2355. }
  2356. if (ChildGroupID == TempID) {
  2357. //해당 APP내에서 스크린 전환 필요
  2358. //[수정필요]
  2359. if (OPERATION_MODE == Common.MODE_NOMAL) {
  2360. mTempCurrentScreenId = ChildID;
  2361. mWallPadApiCheckHandler.sendEmptyMessage(0);
  2362. }
  2363. else {
  2364. boolean result = setChangeScreen(ChildID, false);
  2365. if (result == false) {
  2366. setChangeScreen(API_Menu.SubMenuCtrl.HDC_LivingLamp, false);
  2367. }
  2368. }
  2369. WpadActivity.setFinishTimerReset();
  2370. }
  2371. else {
  2372. //외부 앱 호출 후, 본 APP Finish 필요
  2373. api_Menu.startSubScreenActivity(getApplicationContext(), menueListDataClass.idMappingTable[i].Id, API_Menu.MENU_START_OPTION_1, api_Menu.GetAPK_Name_ByID(ChildGroupID));
  2374. Intent mIntent = new Intent();
  2375. mIntent.putExtra("Finish_Kind", "HomeButton");
  2376. MainActivity.this.setResult(RESULT_OK, mIntent);
  2377. finish();
  2378. }
  2379. break;
  2380. }
  2381. }
  2382. }
  2383. }
  2384. }
  2385. };
  2386. /**
  2387. * 디바이스 서비스 APP 을 체크하여 실행되어있지 않을시 실행시킨다.
  2388. */
  2389. private void StartDevService() {
  2390. try {
  2391. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2392. List<ActivityManager.RunningAppProcessInfo> appList = am.getRunningAppProcesses();
  2393. boolean DevServiceExist = false;
  2394. for (int i = 0; i < appList.size(); i++) {
  2395. ActivityManager.RunningAppProcessInfo rapi = appList.get(i);
  2396. Log.i(TAG, "App List i = " + i + " / name = " + rapi.getClass().getName());
  2397. if (rapi.processName.equals("com.artncore.deviceservice")) {
  2398. Log.d(TAG, "Filter 1 : Service already running");
  2399. DevServiceExist = true;
  2400. break;
  2401. }
  2402. }
  2403. ActivityManager am2 = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2404. List<ActivityManager.RunningServiceInfo> rs = am2.getRunningServices(1000);
  2405. for (int i = 0; i < rs.size(); i++) {
  2406. ActivityManager.RunningServiceInfo rsi = rs.get(i);
  2407. //Log.d("run service","Package Name " + i + " = " + rsi.service.getPackageName());
  2408. //Log.d("run service","Class Name : " + i + " = " + rsi.service.getClassName());
  2409. if (rsi.service.getPackageName().equals("com.artncore.deviceservice")) {
  2410. Log.d(TAG, "Filter 2 : Service already running");
  2411. DevServiceExist = true;
  2412. break;
  2413. }
  2414. }
  2415. if (!DevServiceExist) {
  2416. Log.d(TAG, "Call Service Start");
  2417. Intent intent = new Intent("wallpaddevservice.ServiceMain");
  2418. startService(intent);
  2419. try {
  2420. Thread.sleep(3000);
  2421. } catch (RuntimeException re) {
  2422. LogUtil.errorLogInfo("", TAG, re);
  2423. }
  2424. catch (Exception e) {
  2425. Log.e(TAG, "[Exception] StartDevService().sleep(...)");
  2426. }
  2427. }
  2428. } catch (RuntimeException re) {
  2429. LogUtil.errorLogInfo("", TAG, re);
  2430. }
  2431. catch (Exception e) {
  2432. Log.w(TAG, "[Exception] StartDevService()");
  2433. //e.printStackTrace();
  2434. LogUtil.errorLogInfo("", TAG, e);
  2435. }
  2436. }
  2437. /**
  2438. * DB 에서 룸이름 정보를 가져온다.
  2439. *
  2440. * @return (String []) null - 실패, not null
  2441. */
  2442. private String[] getRoomNameFromDB() {
  2443. try {
  2444. WallpadStatusData wallpadStatusData = new WallpadStatusData(getContext().getApplicationContext());
  2445. String[] RoomNameList = wallpadStatusData.GetDevRoomName();
  2446. wallpadStatusData.closeDB();
  2447. if (RoomNameList == null) {
  2448. Log.e(TAG, "[getRoomNameFromDB] - RoomNameList is null !!!");
  2449. return null;
  2450. }
  2451. if (RoomNameList.length != 6) {
  2452. Log.e(TAG, "[getRoomNameFromDB.length Not Match (" + RoomNameList.length + ")");
  2453. return null;
  2454. }
  2455. if (DEBUG_LOG_ON) {
  2456. for (int i = 0; i < RoomNameList.length; i++)
  2457. DebugLogOutput("[getRoomNameFromDB] RoomNameList[" + i + "] " + RoomNameList[i]);
  2458. }
  2459. return RoomNameList;
  2460. } catch (RuntimeException re) {
  2461. LogUtil.errorLogInfo("", TAG, re);
  2462. }
  2463. catch (Exception e) {
  2464. Log.e(TAG, "[Exception] getRoomNameFromDB()");
  2465. //e.printStackTrace();
  2466. LogUtil.errorLogInfo("", TAG, e);
  2467. }
  2468. return null;
  2469. }
  2470. /**
  2471. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  2472. *
  2473. * @param Device - int
  2474. * @return (String []) null - 실패, not null
  2475. */
  2476. private String[] getRoomNameFromDB(int Device) {
  2477. try {
  2478. String[] RoomNameList = null;
  2479. WallpadStatusData wallpadStatusData = new WallpadStatusData(getContext().getApplicationContext());
  2480. if (Device == HEATING) {
  2481. RoomNameList = wallpadStatusData.GetDevRoomName("heating");
  2482. }
  2483. else {
  2484. RoomNameList = wallpadStatusData.GetDevRoomName("light");
  2485. }
  2486. wallpadStatusData.closeDB();
  2487. if (RoomNameList == null) {
  2488. Log.e(TAG, "[DB_GetRoomName] - RoomNameList is null !!!");
  2489. return null;
  2490. }
  2491. if (RoomNameList.length != 6) {
  2492. Log.e(TAG, "[DB_GetRoomName] - RoomNameList.length Not Match (" + RoomNameList.length + ")");
  2493. return null;
  2494. }
  2495. if (DEBUG_LOG_ON) {
  2496. for (int i = 0; i < RoomNameList.length; i++)
  2497. DebugLogOutput("RoomNameList[" + i + "] " + RoomNameList[i]);
  2498. }
  2499. return RoomNameList;
  2500. } catch (RuntimeException re) {
  2501. LogUtil.errorLogInfo("", TAG, re);
  2502. }
  2503. catch (Exception e) {
  2504. Log.e(TAG, "[Exception] DB_GetRoomName(int Device)");
  2505. //e.printStackTrace();
  2506. LogUtil.errorLogInfo("", TAG, e);
  2507. }
  2508. return null;
  2509. }
  2510. /**
  2511. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  2512. **/
  2513. private void GetRoomName() {
  2514. try {
  2515. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getContext().getApplicationContext());
  2516. boolean UseEachRoomName = wallpadDeviceSet.GetEachRoomNameInfo();
  2517. wallpadDeviceSet.closeDB();
  2518. Log.e(TAG, "[GetRoomName] UseEachRoomName = " + UseEachRoomName);
  2519. if (UseEachRoomName == false) {
  2520. // 명칭 통합사용
  2521. if (nConstructionFunction == WallpadDeviceSet.CONSTRUCTION_SPECIAL_FUNCTION_SK) {
  2522. // SK건설
  2523. mRoomNameList_Light = mDefaultRoomNameList_Light_SK;
  2524. mRoomNameList_Heating = mDefaultRoomNameList_Heating_SK;
  2525. }
  2526. else {
  2527. mRoomNameList_Light = getRoomNameFromDB();
  2528. if (mRoomNameList_Light == null) {
  2529. mRoomNameList_Light = mDefaultRoomNameList;
  2530. }
  2531. if (GetEasyModeUXUse()) {
  2532. mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  2533. }
  2534. else {
  2535. mRoomNameList_Heating = getRoomNameFromDB();
  2536. if (mRoomNameList_Heating == null) {
  2537. mRoomNameList_Heating = mDefaultRoomNameList;
  2538. }
  2539. }
  2540. }
  2541. }
  2542. else {
  2543. // 명칭 난방, 조명 분리 사용
  2544. mRoomNameList_Light = getRoomNameFromDB(LIGHT);
  2545. if (mRoomNameList_Light == null) {
  2546. mRoomNameList_Light = mDefaultRoomNameList_Light;
  2547. }
  2548. if (GetEasyModeUXUse()) {
  2549. mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  2550. }
  2551. else {
  2552. mRoomNameList_Heating = getRoomNameFromDB(HEATING);
  2553. if (mRoomNameList_Heating == null) {
  2554. mRoomNameList_Heating = mDefaultRoomNameList_Heating;
  2555. }
  2556. }
  2557. }
  2558. } catch (RuntimeException re) {
  2559. LogUtil.errorLogInfo("", TAG, re);
  2560. }
  2561. catch (Exception e) {
  2562. Log.e(TAG, "[Exception] GetRoomName()");
  2563. //e.printStackTrace();
  2564. LogUtil.errorLogInfo("", TAG, e);
  2565. }
  2566. }
  2567. /**
  2568. * TOP 에 보일러 아이콘 활성화 & 비활성화
  2569. *
  2570. * @param Enabled - true : 활성화, false : 비활성화
  2571. * @return (boolean) true : 성공, false : 실패
  2572. */
  2573. public boolean setTopBoilerBtnVisible(boolean Enabled) {
  2574. try {
  2575. if (Enabled == true) {
  2576. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 0");
  2577. if (TopBoilerBtn.getVisibility() != View.VISIBLE) {
  2578. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 1");
  2579. if (TopBackBtn.getVisibility() == View.VISIBLE) {
  2580. // 1019
  2581. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 2");
  2582. WpadUtil.ViewMove(TopBoilerBtn, 893, 0);
  2583. WpadUtil.ViewMove(TopManualBtn, 767, 0);
  2584. }
  2585. else {
  2586. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 3-1");
  2587. WpadUtil.ViewMove(TopBoilerBtn, 1019, 0);
  2588. }
  2589. if(TopBoilerBtn!=null) TopBoilerBtn.setVisibility(View.VISIBLE);
  2590. if(TopBoilerBtn!=null) TopBoilerBtn.bringToFront();
  2591. if (TopBoilerBtn!=null && TopBoilerBtn.getVisibility() == View.VISIBLE) {
  2592. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 3-2");
  2593. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  2594. // TopManualBtn.bringToFront();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 4");
  2600. if (TopBoilerBtn.getVisibility() != View.INVISIBLE) {
  2601. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 5");
  2602. TopBoilerBtn.setVisibility(View.INVISIBLE);
  2603. if (TopBackBtn.getVisibility() == View.VISIBLE) {
  2604. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 6");
  2605. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  2606. }
  2607. else {
  2608. Log.i(TAG, "[setTopBoilerBtnVisible] ENTER 7");
  2609. WpadUtil.ViewMove(TopManualBtn, 1019, 0);
  2610. }
  2611. }
  2612. }
  2613. } catch (RuntimeException re) {
  2614. LogUtil.errorLogInfo("", TAG, re);
  2615. return false;
  2616. }
  2617. catch (Exception ex) {
  2618. Log.e(TAG, "[Exception] setTopBoilerBtnVisible(boolean Enabled)");
  2619. //ex.printStackTrace();
  2620. LogUtil.errorLogInfo("", TAG, ex);
  2621. return false;
  2622. }
  2623. return true;
  2624. }
  2625. /**
  2626. * 실내공기질 돌아가기 버튼 활성화 & 비활성화
  2627. *
  2628. * @param Enabled - true : 활성화, false : 비활성화
  2629. * @return (boolean) true : 성공, false : 실패
  2630. */
  2631. public boolean setAIRBackBtnVisible(boolean Enabled) {
  2632. if (Enabled == true) {
  2633. if (TopAirBackBtn.getVisibility() != View.VISIBLE) TopAirBackBtn.setVisibility(View.VISIBLE);
  2634. TopAirBackBtn.bringToFront();
  2635. if (TopAirBackBtn.getVisibility() == View.VISIBLE) {
  2636. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  2637. }
  2638. if(TopManualBtn!=null) TopManualBtn.setVisibility(View.INVISIBLE);
  2639. }
  2640. else {
  2641. if (TopAirBackBtn.getVisibility() != View.INVISIBLE) TopAirBackBtn.setVisibility(View.INVISIBLE);
  2642. if (TopAirBackBtn.getVisibility() == View.INVISIBLE) {
  2643. WpadUtil.ViewMove(TopManualBtn, 1019, 0);
  2644. }
  2645. }
  2646. return true;
  2647. }
  2648. /**
  2649. * 환기제어 돌아가기 버튼 활성화 & 비활성화
  2650. *
  2651. * @param Enabled - true : 활성화, false : 비활성화
  2652. * @return (boolean) true : 성공, false : 실패
  2653. */
  2654. public boolean setVentilBackBtnVisible(boolean Enabled) {
  2655. if (Enabled == true) {
  2656. if (BTN_TOP_BACK_VENTIL.getVisibility() != View.VISIBLE) BTN_TOP_BACK_VENTIL.setVisibility(View.VISIBLE);
  2657. BTN_TOP_BACK_VENTIL.bringToFront();
  2658. if (BTN_TOP_BACK_VENTIL.getVisibility() == View.VISIBLE) {
  2659. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  2660. }
  2661. if(TopManualBtn!=null) TopManualBtn.setVisibility(View.INVISIBLE);
  2662. }
  2663. else {
  2664. if (BTN_TOP_BACK_VENTIL.getVisibility() != View.INVISIBLE) BTN_TOP_BACK_VENTIL.setVisibility(View.INVISIBLE);
  2665. if (BTN_TOP_BACK_VENTIL.getVisibility() == View.INVISIBLE) {
  2666. if (TopBoilerBtn != null && TopBoilerBtn.getVisibility() == View.VISIBLE) {
  2667. WpadUtil.ViewMove(TopManualBtn, 893, 0);
  2668. }
  2669. else {
  2670. WpadUtil.ViewMove(TopManualBtn, 1019, 0);
  2671. }
  2672. }
  2673. }
  2674. return true;
  2675. }
  2676. /**
  2677. * 상단 KCC디밍조절 버튼 활성화 & 비활성화
  2678. *
  2679. * @param Enabled - true : 활성화, false : 비활성화
  2680. * @return (boolean) true : 성공, false : 실패
  2681. */
  2682. public void setMultiBtnVisible(boolean Enabled) {
  2683. for (int i = 0; i < MultiBtn.length; i++) {
  2684. if (Enabled == true) {
  2685. if (MultiBtn[i].getVisibility() != View.VISIBLE)
  2686. MultiBtn[i].setVisibility(View.VISIBLE);
  2687. MultiBtn[i].bringToFront();
  2688. MultiBtn[i].setButtonFrontImage();
  2689. } else {
  2690. if (MultiBtn[i].getVisibility() != View.INVISIBLE)
  2691. MultiBtn[i].setVisibility(View.INVISIBLE);
  2692. }
  2693. }
  2694. if (myIP.equals("10.1.1.2")) {
  2695. MultiBtn[1].setButtonRearImage();
  2696. } else if (myIP.equals("10.1.1.1")) {
  2697. MultiBtn[0].setButtonRearImage();
  2698. } else if (myIP.equals("10.1.1.3")) {
  2699. MultiBtn[2].setButtonRearImage();
  2700. }
  2701. }
  2702. /**
  2703. * 멀티 제어 층 버튼 활성화 & 비활성화
  2704. *
  2705. * @param Enabled - true : 활성화, false : 비활성화
  2706. * @return (boolean) true : 성공, false : 실패
  2707. */
  2708. public void setKccDimmBtnVisible(boolean Enabled) {
  2709. WallpadDeviceSet wdst = new WallpadDeviceSet(getContext());
  2710. int dimmUse = wdst.GetDeviceSetted("KCC디밍제어기"); // 1: 사용안함 / 2: 사용함
  2711. wdst.closeDB();
  2712. Log.i(TAG, "[setKccDimmBtnVisible] - KCC Dimm : " + dimmUse);
  2713. // null, 사용안함 이면 안나오도록 한다.
  2714. if (dimmUse == 0 || dimmUse == 1) {
  2715. Log.w(TAG, "[setKccDimmBtnVisible] - KCC Dimm NOT USE !!!");
  2716. Enabled = false;
  2717. KccDimUse = 0;
  2718. }
  2719. else {
  2720. KccDimUse = 1;
  2721. }
  2722. for (int i = 0; i < TopDimmingBtn.length; i++) {
  2723. if (Enabled == true) {
  2724. if (TopDimmingBtn[i].getVisibility() != View.VISIBLE)
  2725. TopDimmingBtn[i].setVisibility(View.VISIBLE);
  2726. TopDimmingBtn[i].bringToFront();
  2727. }
  2728. else {
  2729. if (TopDimmingBtn[i].getVisibility() != View.INVISIBLE)
  2730. TopDimmingBtn[i].setVisibility(View.INVISIBLE);
  2731. }
  2732. }
  2733. }
  2734. /**
  2735. * 조명제어기의 디밍 레벨을 조절한다.
  2736. *
  2737. * @param Level - 디밍레벨
  2738. * @return (int) - >=0 : 성공, <0 : 실패
  2739. */
  2740. private int Device_SetDimmingLevel(byte Level) {
  2741. DebugLogOutput("[Device_SetAllDimmingLevel] - Start (Level : " + Level + ")");
  2742. // 1. Api Load Check
  2743. if (ledDimmingAPI == null) {
  2744. Log.e(TAG, "[Device_SetAllDimmingLevel] ledDimmingAPI unload !!!");
  2745. return -1;
  2746. }
  2747. // 2. Param Range Check
  2748. if (mDimData.DimData.DeviceCnt == 0) {
  2749. Log.w(TAG, "[Device_SetAllDimmingLevel] mData.DeviceCnt == 0");
  2750. return -2;
  2751. }
  2752. // 3. Light Control
  2753. try {
  2754. int ret = ledDimmingAPI.SetDimmingLevel(0, Level);
  2755. if (ret < 0) {
  2756. Log.e(TAG, "[Device_SetAllDimmingLevel] SetAllDimmingLevel Error (" + ret + ") ErrorCode = " + ledDimmingAPI.ErrorCode.ErrStr());
  2757. return -6;
  2758. }
  2759. } catch (RuntimeException re) {
  2760. LogUtil.errorLogInfo("", TAG, re);
  2761. return -100;
  2762. }
  2763. catch (Exception e) {
  2764. Log.e(TAG, "[Device_SetAllDimmingLevel] - [Exception Error] ledDimmingAPI.SetAllDimmingLevel()");
  2765. //e.printStackTrace();
  2766. LogUtil.errorLogInfo("", TAG, e);
  2767. return -100;
  2768. }
  2769. DebugLogOutput("[Device_SetAllDimmingLevel] - OK");
  2770. return 0;
  2771. }
  2772. private void Draw_Update_DimmBtn() {
  2773. // 디밍 표시
  2774. Log.i(TAG, "[Draw_Update_DimmBtn] - Dimming Draw Start");
  2775. if (mDimData.DimData == null) {
  2776. Log.w(TAG, "[Draw_Update_DimmBtn] - mDimData.DimData null");
  2777. return;
  2778. }
  2779. else {
  2780. Log.i(TAG, "[Draw_Update_DimmBtn] - mDimData.DimData normal");
  2781. }
  2782. byte Level = mDimData.DimData.Device[0].device.Level;
  2783. Log.i(TAG, "[Draw_Update_DimmBtn] - Level =" + Level);
  2784. for (int i = 0; i < 4; i++) {
  2785. if (Level == mLevelArray[i]) {
  2786. Log.i(TAG, "[Draw_Update_DimmBtn] - Same Level Button i = " + i);
  2787. TopDimmingBtn[i].setButtonRearImage();
  2788. }
  2789. else {
  2790. Log.i(TAG, "[Draw_Update_DimmBtn] - Diff Level Button i = " + i);
  2791. TopDimmingBtn[i].setButtonFrontImage();
  2792. }
  2793. }
  2794. Log.i(TAG, "[Draw_Update_DimmBtn] - Dimming Draw End");
  2795. }
  2796. /**
  2797. * KCC 디밍제어기의 상태를 갱신한다.
  2798. *
  2799. * @param real - (boolean) true : 실시간 , false : 가장최근
  2800. * @param index - (byte) 방 인덱스 (0~5개별방, Common.INDEX_ALL 전체)
  2801. * @return (int) - >=0 : 성공, <0 : 실패
  2802. */
  2803. private int Device_Update_Dimming(boolean real, byte index) {
  2804. DebugLogOutput("[Device_Update_Dimming] - Start (real : " + real + ", index:" + index + ")");
  2805. // 1. Api Load Check
  2806. if (ledDimmingAPI == null) {
  2807. Log.e(TAG, "[Device_Update_Dimming] ledDimmingAPI unload !!!");
  2808. return -1;
  2809. }
  2810. // 2. refresh
  2811. try {
  2812. int ret = ledDimmingAPI.Refresh(index, real);
  2813. if (ret < 0) {
  2814. Log.e(TAG, "[Device_Update_Dimming] Refresh(" + index + ", " + real + ") ret = " + ret + " / ErrorCode = " + ledDimmingAPI.ErrorCode.ErrStr());
  2815. return -2;
  2816. }
  2817. } catch (RuntimeException re) {
  2818. LogUtil.errorLogInfo("", TAG, re);
  2819. return -100;
  2820. }
  2821. catch (Exception e) {
  2822. Log.e(TAG, "[Device_Update_Dimming] - [Exception Error] ledDimmingAPI.Refresh(index:" + index + ", real:" + real + ")");
  2823. //e.printStackTrace();
  2824. LogUtil.errorLogInfo("", TAG, e);
  2825. return -100;
  2826. }
  2827. // 3. Range Check
  2828. if (ledDimmingAPI.data.DeviceCnt <= 0) {
  2829. Log.e(TAG, "[Device_Update_Dimming] - DeviceCnt Out of range !!! (DeviceCnt:" + ledDimmingAPI.data.DeviceCnt + ")");
  2830. return -10;
  2831. }
  2832. // 4. Data Copy
  2833. mDimData.DimData = ledDimmingAPI.data;
  2834. // 5. Debug Msg
  2835. DebugLogOutput("---------------------------------------");
  2836. DebugLogOutput("[Device_Update_Dimming]");
  2837. DebugLogOutput("---------------------------------------");
  2838. DebugLogOutput("DeviceCnt = " + ledDimmingAPI.data.DeviceCnt);
  2839. byte DeviceCnt = ledDimmingAPI.data.DeviceCnt;
  2840. if (index == define.DEVICE_ALL_OR_NOTHING) {
  2841. for (byte i = 0; i < DeviceCnt; i++) {
  2842. DebugLogOutput(ledDimmingAPI.data.Device[i].info.ToDebugString(i));
  2843. DebugLogOutput(ledDimmingAPI.data.Device[i].device.ToDebugString(i));
  2844. }
  2845. }
  2846. else {
  2847. DebugLogOutput(ledDimmingAPI.data.Device[index].device.ToDebugString(index));
  2848. }
  2849. DebugLogOutput("---------------------------------------");
  2850. DebugLogOutput("[Device_Update_Dimming] - OK");
  2851. return 0;
  2852. }
  2853. /**
  2854. * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
  2855. *
  2856. * @param code - (int) 송신할 keycode
  2857. * @return (int) - >=0 : 성공, <0 : 실패
  2858. */
  2859. private int setSendEventBR(int code) {
  2860. try {
  2861. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code);
  2862. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  2863. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  2864. intent.putExtra("keycode",code);
  2865. getContext().sendBroadcast(intent);
  2866. } catch (RuntimeException re) {
  2867. LogUtil.errorLogInfo("", TAG, re);
  2868. return -100;
  2869. }
  2870. catch (Exception e) {
  2871. Log.e(TAG, "[setSendEventBR] - [Exception Error] code:" + code);
  2872. //e.printStackTrace();
  2873. LogUtil.errorLogInfo("", TAG, e);
  2874. return -100;
  2875. }
  2876. return 0;
  2877. }
  2878. /**
  2879. * 히든메뉴의 버튼 타임아웃을 설정한다.
  2880. */
  2881. private void HideMenu_setTimeOut() {
  2882. if (mHideMenuTimer != null) mHideMenuTimer.cancel();
  2883. mHideMenuTimer = new CountDownTimer( 1 * 1000, 1000) {
  2884. @Override
  2885. public void onFinish() {
  2886. Log.d(TAG, "mHideMenuTimer - onFinish !!!");
  2887. mHideMenuEntryStatus = 0;
  2888. }
  2889. @Override
  2890. public void onTick(long millisUntilFinished) {
  2891. }
  2892. };
  2893. mHideMenuTimer.cancel();
  2894. mHideMenuTimer.start();
  2895. }
  2896. /**
  2897. * 히든메뉴 진입용 프로세스
  2898. *
  2899. * @param TargetId - 히든메뉴용 버튼 ID
  2900. */
  2901. private void HideMenuEntryProc(int TargetId) {
  2902. if (OPERATION_MODE != Common.MODE_NOMAL) return;
  2903. if (mHideMenuOn) return;
  2904. if (TargetId == ID.main.button.HIDE1) {
  2905. if (mHideMenuEntryStatus == 0) { mHideMenuEntryStatus = 1; HideMenu_setTimeOut(); }
  2906. else if (mHideMenuEntryStatus == 2) { mHideMenuEntryStatus = 3; HideMenu_setTimeOut(); }
  2907. else if (mHideMenuEntryStatus == 4) { mHideMenuEntryStatus = 5; HideMenu_setTimeOut(); }
  2908. }
  2909. else if (TargetId == ID.main.button.HIDE2) {
  2910. if (mHideMenuEntryStatus == 1) { mHideMenuEntryStatus = 2; HideMenu_setTimeOut(); }
  2911. else if (mHideMenuEntryStatus == 3) { mHideMenuEntryStatus = 4; HideMenu_setTimeOut(); }
  2912. else if (mHideMenuEntryStatus == 5) {
  2913. mHideMenuEntryStatus = 6;
  2914. mHideMenuOn = true;
  2915. if (mHideMenuTimer != null) {
  2916. mHideMenuTimer.cancel();
  2917. mHideMenuTimer = null;
  2918. TopBackground.setImageResource(0);
  2919. TopBackground.setBackgroundColor(Color.RED);
  2920. Sound().Play(SND.call.CALLSTART);
  2921. super.setFinishTimerDestroy();
  2922. Log.i(TAG, "================================");
  2923. Log.i(TAG, "[HideMenu] START !!!!!");
  2924. Log.i(TAG, "================================");
  2925. }
  2926. }
  2927. }
  2928. }
  2929. public boolean GetEasyModeUXUse() {
  2930. try {
  2931. WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext);
  2932. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  2933. deviceSet.closeDB();
  2934. WallpadStatusData data = new WallpadStatusData(mContext);
  2935. boolean bUse = data.GetEasyModeUxUse();
  2936. data.closeDB();
  2937. Log.d(TAG, "[GetEasyModeUXUse] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  2938. return bSupport & bUse;
  2939. } catch (RuntimeException re) {
  2940. LogUtil.errorLogInfo("", TAG, re);
  2941. }
  2942. catch (Exception e) {
  2943. Log.e(TAG, "[Exception] GetEasyModeUXUse()");
  2944. //e.printStackTrace();
  2945. LogUtil.errorLogInfo("", TAG, e);
  2946. }
  2947. return false;
  2948. }
  2949. public boolean getAirSensorAPUsage() {
  2950. try {
  2951. boolean bUsage = false;
  2952. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2953. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP");
  2954. mWallpadDeviceSet.closeDB();
  2955. if(nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) bUsage = true;
  2956. Log.d(TAG, "[getAirSensorAPUsage] bUsage [" + bUsage + "]");
  2957. return bUsage;
  2958. } catch (RuntimeException re) {
  2959. LogUtil.errorLogInfo("", TAG, re);
  2960. }
  2961. catch (Exception e) {
  2962. Log.e(TAG, "[Exception] getAirSensorAPUsage()");
  2963. //e.printStackTrace();
  2964. LogUtil.errorLogInfo("", TAG, e);
  2965. }
  2966. return false;
  2967. }
  2968. /**
  2969. * 제어기 상태를 가져온다.
  2970. *
  2971. * @param bReal - (boolean) true : 실시간 , false : 가장최근
  2972. * @return (int) - >=0 : 성공, <0 : 실패
  2973. */
  2974. private int updateVentilatorData(boolean bReal) {
  2975. Log.i(TAG, "[updateVentilatorData] - Start (bReal : " + bReal + ")");
  2976. // 1. Api Load Check
  2977. if (mVentilAPI == null) {
  2978. Log.e(TAG, "[updateVentilatorData] - mVentilAPI unload !!!");
  2979. return -1;
  2980. }
  2981. // 2. reflash
  2982. try {
  2983. int ret = mVentilAPI.Refresh(bReal);
  2984. if (ret < 0) {
  2985. Log.e(TAG, "[updateVentilatorData] Refresh - ret (" + ret + ") ErrorCode = " + mVentilAPI.ErrorCode.ErrStr());
  2986. return -2;
  2987. }
  2988. } catch (RuntimeException re) {
  2989. LogUtil.errorLogInfo("", TAG, re);
  2990. return -100;
  2991. }
  2992. catch (Exception e) {
  2993. Log.e(TAG, "[updateVentilatorData] - [Exception Error] mVentilAPI.Refresh(" + bReal + ")");
  2994. //e.printStackTrace();
  2995. LogUtil.errorLogInfo("", TAG, e);
  2996. return -100;
  2997. }
  2998. // 3. Data Copy
  2999. VentilStatus = mVentilAPI.data;
  3000. // 4. Debug Msg
  3001. Log.i(TAG, VentilStatus.ToDebugString());
  3002. Log.i(TAG, VentilStatus.ToFaultString());
  3003. Log.i(TAG, "[updateVentilatorData] - OK");
  3004. return 0;
  3005. }
  3006. /**
  3007. * Knx 환기 제어기 상태를 가져온다.
  3008. *
  3009. * @param bReal - (boolean) true : 실시간 , false : 가장최근
  3010. * @return (int) - >=0 : 성공, <0 : 실패
  3011. */
  3012. private int updateKnxVentilatorData(boolean bReal) {
  3013. Log.i(TAG, "[updateKnxVentilatorData] - Start (bReal : " + bReal + ")");
  3014. // 1. Api Load Check
  3015. if (mKnxVentilAPI == null) {
  3016. Log.e(TAG, "[updateKnxVentilatorData] - mVentilAPI unload !!!");
  3017. return -1;
  3018. }
  3019. // 2. reflash
  3020. try {
  3021. int ret = mKnxVentilAPI.Refresh(Common.INDEX_ALL, bReal);
  3022. if (ret < 0) {
  3023. Log.e(TAG, "[updateKnxVentilatorData] Refresh - ret (" + ret + ") ErrorCode = " + mKnxVentilAPI.ErrorCode.ErrStr());
  3024. return -2;
  3025. }
  3026. } catch (RuntimeException re) {
  3027. LogUtil.errorLogInfo("", TAG, re);
  3028. return -100;
  3029. }
  3030. catch (Exception e) {
  3031. Log.e(TAG, "[updateKnxVentilatorData] - [Exception Error] mKnxVentilAPI.Refresh(" + bReal + ")");
  3032. //e.printStackTrace();
  3033. LogUtil.errorLogInfo("", TAG, e);
  3034. return -100;
  3035. }
  3036. // 3. Data Copy
  3037. VentilStatus = mKnxVentilAPI.data.Device[0];
  3038. // 4. Debug Msg
  3039. Log.i(TAG, VentilStatus.ToDebugString());
  3040. Log.i(TAG, VentilStatus.ToFaultString());
  3041. Log.i(TAG, "[updateVentilatorData] - OK");
  3042. return 0;
  3043. }
  3044. public static int nConstructionFunction = WallpadDeviceSet.CONSTRUCTION_SPECIAL_FUNCTION_NONE;
  3045. private void getConstructionFunction() {
  3046. try {
  3047. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3048. nConstructionFunction = mWallpadDeviceSet.Get_Construction_SpecialFunc();
  3049. mWallpadDeviceSet.closeDB();
  3050. } catch (Exception e) {
  3051. Log.e(TAG, "[Exception] getConstructionFunction()");
  3052. e.printStackTrace();
  3053. }
  3054. }
  3055. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  3056. private void getResidentSafetyCheckSetting() {
  3057. try {
  3058. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3059. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  3060. mWallpadDeviceSet.closeDB();
  3061. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  3062. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE) Version.setResidentSafety();
  3063. else Version.unsetResidentSafety();
  3064. } catch (RuntimeException re) {
  3065. LogUtil.errorLogInfo("", TAG, re);
  3066. } catch (Exception e) {
  3067. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  3068. //e.printStackTrace();
  3069. LogUtil.errorLogInfo("", TAG, e);
  3070. }
  3071. }
  3072. /**
  3073. * 멀티제어 관련.
  3074. *
  3075. * */
  3076. public String millToDate(long mills) {
  3077. String pattern = "yyyy-MM-dd'T'HH:mm:ss";
  3078. SimpleDateFormat formatter = new SimpleDateFormat(pattern);
  3079. String date = (String) formatter.format(new Timestamp(mills));
  3080. return date;
  3081. }
  3082. class ClientThread extends Thread {
  3083. private Handler handler;
  3084. private String category;
  3085. private int menu, kind, reason, state, position;
  3086. private int roomNumber;
  3087. public ClientThread(Handler handler, int menu, int kind, int reason, int position, String category, int roomNumber, int state) {
  3088. this.handler = handler;
  3089. this.menu = menu;
  3090. this.kind = kind;
  3091. this.reason = reason;
  3092. this.position = position;
  3093. this.category = category;
  3094. this.roomNumber = roomNumber;
  3095. this.state = state;
  3096. }
  3097. public ClientThread(Handler handler, int menu, int kind, int reason, int position) {
  3098. this.handler = handler;
  3099. this.menu = menu;
  3100. this.kind = kind;
  3101. this.reason = reason;
  3102. this.position = position;
  3103. }
  3104. public void run() {
  3105. //String host = "10.1.1.1";
  3106. //String host = "10.1.1.2";
  3107. String host = "10.1.1." + mMultiAddress;
  3108. int port = 9998;
  3109. String json = "";
  3110. // build jsonObject
  3111. JSONObject jsonObject = new JSONObject();
  3112. JSONObject dataJsonObject = new JSONObject();
  3113. try {
  3114. jsonObject.accumulate("type", "request");
  3115. jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis()));
  3116. jsonObject.accumulate("wallpadip", myIP);
  3117. jsonObject.accumulate("menu", menu);
  3118. jsonObject.accumulate("kind", kind);
  3119. jsonObject.accumulate("reason", reason);
  3120. jsonObject.accumulate("position", position);
  3121. //제어
  3122. if (reason == Common.JSON.REASON.Control) {
  3123. dataJsonObject.accumulate("category", category);
  3124. dataJsonObject.accumulate("number", roomNumber);
  3125. dataJsonObject.accumulate("state", state);
  3126. }
  3127. jsonObject.accumulate("data", dataJsonObject);
  3128. } catch (JSONException e) {
  3129. e.printStackTrace();
  3130. }
  3131. // convert JSONObject to JSON to String
  3132. json = jsonObject.toString();
  3133. try {
  3134. Socket socket = new Socket();
  3135. InetSocketAddress ipep = new InetSocketAddress(host, port); // 방법 2
  3136. socket.connect(ipep);
  3137. ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
  3138. outputStream.writeObject(json);
  3139. Log.d("ClientThread", "서버로 보냄.");
  3140. ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());
  3141. StringBuffer stb = new StringBuffer();
  3142. String data;
  3143. while (true) {
  3144. try {
  3145. socket.setSoTimeout(5000);
  3146. data = (String) inputStream.readObject();
  3147. if (data == null) {
  3148. break;
  3149. }
  3150. stb.append(data);
  3151. } catch (Exception e) {
  3152. if (socket != null) {
  3153. socket.close();
  3154. }
  3155. if (inputStream != null) {
  3156. inputStream.close();
  3157. }
  3158. if (outputStream != null) {
  3159. outputStream.close();
  3160. }
  3161. break;
  3162. }
  3163. }
  3164. if (socket != null) {
  3165. socket.close();
  3166. }
  3167. if (inputStream != null) {
  3168. inputStream.close();
  3169. }
  3170. if (outputStream != null) {
  3171. outputStream.close();
  3172. }
  3173. final String response = String.valueOf(stb);
  3174. Log.d("ClientThread", "response=" + response);
  3175. final String finalResponse = response;
  3176. Message message = handler.obtainMessage();
  3177. message.what = 1000;
  3178. Bundle bundle = new Bundle();
  3179. bundle.putString("response", finalResponse);
  3180. message.setData(bundle);
  3181. handler.sendMessage(message);
  3182. } catch (Exception e) {
  3183. e.printStackTrace();
  3184. }
  3185. }
  3186. }
  3187. public void requestMultiControl(Handler handler, int menu, int kind, int reason, int position, String category, int number, int state) {
  3188. ClientThread thread = new ClientThread(handler, menu, kind, reason, position, category, number, state);
  3189. thread.start();
  3190. }
  3191. public void requestMultiStatus(Handler handler, int menu, int kind, int reason, int position) {
  3192. ClientThread thread = new ClientThread(handler, menu, kind, reason, position);
  3193. thread.start();
  3194. }
  3195. }