iMapServer.java 648 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064
  1. package kr.co.icontrols.wallpadmain.util;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningTaskInfo;
  5. import android.app.Service;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.media.AudioManager;
  15. import android.os.Build;
  16. import android.os.Bundle;
  17. import android.os.CountDownTimer;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Looper;
  21. import android.os.Message;
  22. import android.os.PowerManager;
  23. import android.util.Log;
  24. import android.view.KeyEvent;
  25. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  26. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  27. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  28. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  29. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  30. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  31. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  32. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  33. import com.artncore.WallPadDataMgr.WallpadStatusData;
  34. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  35. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  36. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  37. import com.artncore.WallPadKNXSystem.WallPadKNX;
  38. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  39. import com.artncore.commons.APIErrorCode;
  40. import com.artncore.commons.API_Menu;
  41. import com.artncore.commons.DataClasses;
  42. import com.artncore.commons.DataClasses.HeatingV1;
  43. import com.artncore.commons.DataClasses.HeatingV2;
  44. import com.artncore.commons.DataClasses.MultiSwitch;
  45. import com.artncore.commons.define;
  46. import com.artncore.deviceinterface.WallPadInterface;
  47. import com.artncore.wallpadapi.DLockAPI;
  48. import com.artncore.wallpadapi.EnergyMeterAPI;
  49. import com.artncore.wallpadapi.GasAPI;
  50. import com.artncore.wallpadapi.HeatingV1API;
  51. import com.artncore.wallpadapi.HeatingV2API;
  52. import com.artncore.wallpadapi.IGW200dAPI;
  53. import com.artncore.wallpadapi.IGW300API;
  54. import com.artncore.wallpadapi.IntLightAPI;
  55. import com.artncore.wallpadapi.KnxAPI;
  56. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  57. import com.artncore.wallpadapi.LightAPI;
  58. import com.artncore.wallpadapi.MultiSwitchAPI;
  59. import com.artncore.wallpadapi.PhonNRemocon;
  60. import com.artncore.wallpadapi.RealTimeMeterAPI;
  61. import com.artncore.wallpadapi.SdbAPI;
  62. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  63. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  64. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  65. import com.artncore.wallpadapi.VentiAPI;
  66. import com.artncore.wallpadapi.WallPadAPI;
  67. import com.artncore.wallpadimap.RetProci;
  68. import com.artncore.wallpadimap.WallPadFTPUploader;
  69. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  70. import com.artncore.wallpadimap.WallpadiCMDParser;
  71. import org.apache.commons.net.ftp.FTP;
  72. import org.w3c.dom.Document;
  73. import org.w3c.dom.Element;
  74. import org.w3c.dom.NamedNodeMap;
  75. import org.w3c.dom.Node;
  76. import org.w3c.dom.NodeList;
  77. import java.io.BufferedReader;
  78. import java.io.ByteArrayInputStream;
  79. import java.io.DataOutputStream;
  80. import java.io.File;
  81. import java.io.FilenameFilter;
  82. import java.io.IOException;
  83. import java.io.InputStream;
  84. import java.io.InputStreamReader;
  85. import java.net.ServerSocket;
  86. import java.net.Socket;
  87. import java.text.SimpleDateFormat;
  88. import java.util.ArrayList;
  89. import java.util.Calendar;
  90. import java.util.Date;
  91. import java.util.GregorianCalendar;
  92. import java.util.LinkedList;
  93. import java.util.List;
  94. import java.util.Queue;
  95. import javax.net.ssl.SSLServerSocket;
  96. import javax.xml.parsers.DocumentBuilder;
  97. import javax.xml.parsers.DocumentBuilderFactory;
  98. import kr.co.icontrols.gledeviceinterface.jni;
  99. import kr.co.icontrols.hdcftp.HDCFTPManager;
  100. import kr.co.icontrols.sslapi.SSLClient;
  101. import kr.co.icontrols.sslapi.SSLServer;
  102. import kr.co.icontrols.wallpadmain.IOInterface;
  103. import kr.co.icontrols.wallpadmain.MainActivity;
  104. import kr.co.icontrols.wallpadmain.R;
  105. import kr.co.icontrols.wallpadmain.declare.Common;
  106. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  107. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  108. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  109. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  110. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  111. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  112. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  113. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  114. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  115. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  116. import kr.co.icontrols.wallpadsupport.Version;
  117. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  118. import kr.co.icontrols.wallpadsupport.WpadSound;
  119. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  120. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  121. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  122. public class iMapServer extends Service {
  123. private String TAG = "iMapServer";
  124. static final int EVENTTIMELIMITE = 2000;
  125. iMapSverSocket SvrSock;
  126. int port =10000;
  127. String StrAddr ="";
  128. String IPaddr;
  129. String AddrDong;
  130. String AddrHo;
  131. boolean log_sw = true;
  132. String SVRIP = "";
  133. static WallPadAPI mWallPadAPI;
  134. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  135. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  136. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  137. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  138. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  139. private IGW200 mIGW200;
  140. private IGW300 mIGW300;
  141. PhonNRemocon PnRCtr;
  142. boolean CallConnected = false;
  143. long ALERTTIME = 0;
  144. long CALLTIME = 0;
  145. long OPENDOORTIME = 0;
  146. long currentTime = 0;
  147. long DoorDelayTime = 0;
  148. static Handler ScheDulerHandler;
  149. static final boolean iMAPDOORCTR = true;
  150. private jni mGleInterface = null;
  151. IOInterface mIOInterface = null;
  152. private boolean ResetFlag = false;
  153. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  154. private int ResetCount = 0;
  155. private boolean NowMainStatus = false;
  156. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  157. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  158. public iMapServer() {
  159. Log.i(TAG, "[iMapServer] ========== START ==========");
  160. }
  161. public static final int SENSOR_MAG = 0x01;
  162. public static final int SENSOR_IN = 0x02;
  163. public static final int SENSOR_OUT = 0x04;
  164. static int PORT_NUM_iMAP = 10000;
  165. static int SOCKET_WAIT_TIME = 40;
  166. static long lSocketConnectionPeriod = 0;
  167. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  168. static int SOCKET_BUFFER_SIZE_READ = 50;
  169. public static final String ITEM_MENU_TYPE = "call_menu";
  170. static final int DOOR_DELAY_TIME = 3000;
  171. static final String MULTISW_CTR = "remote_access_electric";
  172. String XMLHeader;
  173. SchedulerThread ScheServer;
  174. int OutGoingSensorWaiting = 0;
  175. private int ModelType = Version.getModelType();
  176. private WpadSound mSound;
  177. private WpadSound Sound() {
  178. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  179. return mSound;
  180. }
  181. /** 신형 단지서버 사용 유무*/
  182. private boolean mNewDanjiServer = false;
  183. /**
  184. * JEFF, 2019.12.31
  185. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  186. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  187. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  188. * 통화앱 종료 BR을 삭제하면 안됨
  189. */
  190. // 통화어플이 종료중인 경우에는 호출 무시
  191. // private boolean bBlockCallEvent = false;
  192. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  193. // true : smartlight 제어
  194. // false: 기존 livinglight/light로 smartlight 제어
  195. private boolean bSmartLightAsNormalLight = true;
  196. ////////////////////////////////////////////////////////////////////////////////
  197. // 엘리베이터관련
  198. ////////////////////////////////////////////////////////////////////////////////
  199. /**
  200. * 엘리베이터 호출관련 class
  201. *
  202. * shkang
  203. */
  204. private class ElevatorClass {
  205. /** 엘리베이터 호출 타임아웃 (단위:초) */
  206. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int)(5 * 60); // 5분
  207. /** 상향/하향 플레그 true:상향UP, false:하향DN */
  208. private boolean mUpDn = false;
  209. /** 엘리베이터 호출중 */
  210. private boolean mCallElevator = false;
  211. /** 엘리베이터 호출 API */
  212. private WallPadiMAPNotifyAPI mElevatorAPI;
  213. /** 엘리베이터 호출 타이머 */
  214. private CountDownTimer mElevatorTimer;
  215. /** 엘리베이터 호출중 상태 가져오기 */
  216. public boolean getElevatorCalling()
  217. {
  218. return mCallElevator;
  219. }
  220. /** 엘리베이터 호출 상태 클리어 */
  221. public void ClearElevator()
  222. {
  223. mCallElevator = false;
  224. }
  225. /**
  226. * 생성자
  227. *
  228. * @param Up - (boolean) true:상향, false:하향
  229. */
  230. private ElevatorClass(boolean Up) {
  231. try {
  232. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true?"UP" : "DOWN") + ")");
  233. // 1. Input Param
  234. mUpDn = Up;
  235. mCallElevator = false;
  236. // 2. Create API
  237. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  238. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  239. @Override
  240. public void ProcDoing() {
  241. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  242. }
  243. @Override
  244. public void ProcError() {
  245. Log.i(TAG, "[ElevatorClass] ProcError()");
  246. mCallElevator = false;
  247. // 엘리베이터 호출 에러 알림
  248. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  249. }
  250. @Override
  251. public void ProcSuccess() {
  252. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  253. mCallElevator = true;
  254. // 엘리베이터 호출 성공 알림
  255. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  256. // "엘리베이터를 호출하였습니다" 멘트출력
  257. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  258. if (!MainActivity.bKakaoiEnable) Sound().PlayMent(WpadSound.SND.elevator.CALL);
  259. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  260. // 타임아웃 시작
  261. TimeOutStart();
  262. }
  263. });
  264. // 3. Create Timer
  265. mElevatorTimer = new CountDownTimer( (long)(ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  266. @Override
  267. public void onFinish() {
  268. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  269. mCallElevator = false;
  270. // 호출 타임아웃 알림
  271. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  272. }
  273. @Override
  274. public void onTick(long arg0) {
  275. int RemainingTime = (int) (arg0 / 1000);
  276. if (RemainingTime <= 10) {
  277. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  278. }
  279. }
  280. };
  281. } catch (Exception e) {
  282. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  283. e.printStackTrace();
  284. }
  285. }
  286. /**
  287. * 엘리베이터 호출을 한다.
  288. */
  289. public void CallElevator() {
  290. try {
  291. if (mElevatorAPI == null) return;
  292. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  293. mCallElevator = true;
  294. } catch (Exception e) {
  295. Log.e(TAG, "[Exception] CallElevator()");
  296. e.printStackTrace();
  297. }
  298. }
  299. /**
  300. * 엘리베이터 상향호출 타임아웃을 취소한다.
  301. */
  302. public void TimeOutCancel() {
  303. try {
  304. if (mElevatorTimer == null) return;
  305. mElevatorTimer.cancel();
  306. } catch (Exception e) {
  307. Log.e(TAG, "[Exception] TimeOutCancel()");
  308. e.printStackTrace();
  309. }
  310. }
  311. /**
  312. * 엘리베이터 상향호출 타임아웃을 시작한다.
  313. */
  314. private void TimeOutStart() {
  315. try {
  316. if (mElevatorTimer == null) return;
  317. mElevatorTimer.cancel();
  318. mElevatorTimer.start();
  319. } catch (Exception e) {
  320. Log.e(TAG, "[Exception] TimeOutStart()");
  321. e.printStackTrace();
  322. }
  323. }
  324. /**
  325. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  326. *
  327. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  328. */
  329. private void SendNotifyKindBR(int kind) {
  330. try {
  331. Intent notiIntent = new Intent();
  332. notiIntent.setAction(define.NOTIFY_ACNAME);
  333. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  334. getApplicationContext().sendBroadcast(notiIntent);
  335. } catch (Exception e) {
  336. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  337. e.printStackTrace();
  338. }
  339. }
  340. }
  341. /** 엘리베이터 상향호출 Class */
  342. private ElevatorClass ElevatorUp;
  343. /** 엘리베이터 하향호출 Class */
  344. private ElevatorClass ElevatorDown;
  345. /**
  346. * 엘리베이터 호출한다.
  347. *
  348. * @param Up (boolean) true : 상향, false : 하향
  349. */
  350. private void CallElevatorBtn(boolean Up) {
  351. try {
  352. Log.i(TAG, "[CallElevatorBtn] Up [" + Up +"]");
  353. if (Up) {
  354. // 상향호출
  355. if (ElevatorUp == null) {
  356. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  357. return;
  358. }
  359. ElevatorUp.CallElevator();
  360. }
  361. else {
  362. // 하향호출
  363. if (ElevatorDown == null) {
  364. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  365. return;
  366. }
  367. ElevatorDown.CallElevator();
  368. }
  369. } catch (Exception e) {
  370. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  371. e.printStackTrace();
  372. }
  373. }
  374. ////////////////////////////////////////////////////////////////////////////////
  375. ////////////////////////////////////////////////////////////////////////////////
  376. @Override
  377. public void onCreate() {
  378. try {
  379. super.onCreate();
  380. Log.i(TAG, "[onCreate] ========== START ==========");
  381. setGlobalScreenAppRunningStatus(false);
  382. ModelType = Version.getModelType();
  383. mSound = new WpadSound(getApplicationContext());
  384. ElevatorUp = new ElevatorClass(true);
  385. ElevatorDown = new ElevatorClass(false);
  386. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  387. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  388. bSmartLightAsNormalLight = true;
  389. }
  390. else bSmartLightAsNormalLight = false;
  391. } catch (Exception e) {
  392. Log.e(TAG, "[Exception] onCreate()");
  393. e.printStackTrace();
  394. }
  395. }
  396. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  397. try {
  398. Intent notiIntent = new Intent();
  399. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  400. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  401. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  402. getApplicationContext().sendBroadcast(notiIntent);
  403. } catch (Exception e) {
  404. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  405. e.printStackTrace();
  406. }
  407. }
  408. protected String GetForegroundAPP() {
  409. try {
  410. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  411. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  412. ComponentName topActivity=taskInfo.get(0).topActivity;
  413. String str=topActivity.getPackageName();
  414. return str;
  415. } catch(Exception e) {
  416. Log.e(TAG, "[Exception] GetForegroundAPP()");
  417. e.printStackTrace();
  418. return " ";
  419. }
  420. }
  421. long lSavedTimestamp = 0;
  422. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  423. public void onReceive(Context context, Intent intent) {
  424. try {
  425. String strActionName = intent.getAction();
  426. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName+ "]");
  427. if (strActionName.equals(define.NOTIFY_DAIL)) {
  428. long lTimestamp = System.currentTimeMillis();
  429. long lInterval = lTimestamp - lSavedTimestamp;
  430. if (lInterval <1000) return;
  431. else Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval+ "]");
  432. lSavedTimestamp = lTimestamp;
  433. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  434. if (mSdb_LivingRoomLightAPI == null) {
  435. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  436. return;
  437. }
  438. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  439. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  440. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  441. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  442. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  443. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  444. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  445. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  446. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  447. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  448. mSdb_LivingRoomLightAPI.SetControlMode(false);
  449. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  450. }
  451. return;
  452. }
  453. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  454. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  455. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  456. return;
  457. }
  458. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  459. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  460. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  461. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  462. }
  463. else {
  464. setGlobalScreenAppRunningStatus(false);
  465. }
  466. }
  467. else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  468. if (mKnx_LivingRoomLightAPI == null) {
  469. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  470. return;
  471. }
  472. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  473. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  474. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  475. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  476. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  477. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  478. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  479. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  480. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  481. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  482. mKnx_LivingRoomLightAPI.SetControlMode(false);
  483. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  484. }
  485. return;
  486. }
  487. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  488. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  489. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  490. return;
  491. }
  492. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  493. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] LIV_Lights[" + i + "] -> OnOff [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.OnOff + "], Dimming [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.Dimming + "], Color [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.Color + "]");
  494. }
  495. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  496. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  497. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  498. }
  499. else {
  500. setGlobalScreenAppRunningStatus(false);
  501. }
  502. }
  503. else {
  504. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  505. }
  506. }
  507. else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  508. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  509. }
  510. else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  511. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  512. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind+ "]");
  513. switch (kind) {
  514. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  515. procUploadMissedVisitorPic(intent);
  516. break;
  517. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  518. // bBlockCallEvent = true;
  519. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  520. break;
  521. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  522. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  523. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  524. break;
  525. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE :
  526. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  527. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  528. break;
  529. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK :
  530. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  531. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  532. break;
  533. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  534. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  535. CallElevatorBtn(false);
  536. break;
  537. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  538. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  539. CallElevatorBtn(true);
  540. break;
  541. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING :
  542. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  543. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  544. int CalledWallPadUI = intent.getIntExtra("Called",0);
  545. if (CalledWallPadUI == 1) {
  546. ModeRunCtrlWorking(true , false);
  547. }
  548. else {
  549. ModeRunCtrlWorking(false, false);
  550. }
  551. break;
  552. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING :
  553. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  554. ModeReleaseCtrlWorking(false);
  555. break;
  556. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK :
  557. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  558. CheckMainStatus();
  559. break;
  560. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING :
  561. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  562. ModeRunCtrlWorking(false, false);
  563. break;
  564. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING :
  565. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  566. ModeReleaseCtrlWorking(false);
  567. break;
  568. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE :
  569. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  570. if (ElevatorUp != null && ElevatorDown != null) {
  571. boolean UpCalling = ElevatorUp.getElevatorCalling();
  572. boolean DownCalling = ElevatorDown.getElevatorCalling();
  573. Log.d( TAG , "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling );
  574. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  575. if (UpCalling && DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  576. else if (UpCalling && !DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  577. else if (!UpCalling && DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  578. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  579. Log.d(TAG , " ElvCallState : " + ElvCallState );
  580. SendBRElevatorCallState(ElvCallState);
  581. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  582. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  583. // sendIntent.putExtra("ELV", ElvCallState);
  584. // getApplicationContext().sendBroadcast(sendIntent);
  585. }
  586. break;
  587. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  588. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  589. try {
  590. if (ScheServer != null) {
  591. ScheServer.SetLive();
  592. }
  593. } catch (Exception e) {
  594. e.printStackTrace();
  595. }
  596. break;
  597. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  598. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  599. stopIGW300RingGenerator();
  600. break;
  601. }
  602. }
  603. else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  604. int kind = intent.getIntExtra("KIND",0);
  605. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind+ "]");
  606. switch (kind) {
  607. case define.NOTIFY_SERVER_VERSION:
  608. try {
  609. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  610. iMapSverReload tSock = new iMapSverReload();
  611. tSock.start();
  612. } catch (IOException e) {
  613. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  614. e.printStackTrace();
  615. }
  616. break;
  617. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  618. // 제어기기 엘리베이터 상향 호출 요청
  619. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  620. CallElevatorBtn(true);
  621. break;
  622. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  623. // 제어기기에서 엘리베이터 하향 호출 요청
  624. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  625. CallElevatorBtn(false);
  626. break;
  627. case define.NOTIFY_SUBDEVCALLBUSY:
  628. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  629. CallConnected = true;
  630. break;
  631. case define.NOTIFY_SUBDEVCALLEND:
  632. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  633. CallConnected = false;
  634. break;
  635. case define.NOTIFY_STARTHEARTBEAT:
  636. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  637. {
  638. Message msg = ScheDulerHandler.obtainMessage();
  639. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  640. ScheDulerHandler.sendMessage(msg);
  641. }
  642. break;
  643. case define.NOTIFY_STARTSTATUSBEAT:
  644. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  645. {
  646. Message msg = ScheDulerHandler.obtainMessage();
  647. msg.what = SCHEDULE_START_STATUSBEAT;
  648. ScheDulerHandler.sendMessage(msg);
  649. }
  650. break;
  651. case define.NOTIFY_OUTGOINGSETTED:
  652. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  653. OutGoingSensorWaiting = 0;
  654. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  655. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  656. sdata.closeDB();
  657. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  658. WallPadInterface wpifc = new WallPadInterface();
  659. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0 )
  660. OutGoingSensorWaiting |= SENSOR_MAG;
  661. int[] SensorInfoDB;
  662. int sensorIn = 0;
  663. int sensorOut = 0;
  664. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  665. if (SensorInfoDB[0] == 1) {
  666. // 내부동체가 사용함이면 상태 검사
  667. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  668. }
  669. if (SensorInfoDB[1] == 1) {
  670. // 외부동체가 사용함이면 상태 검사
  671. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  672. }
  673. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  674. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  675. if (OutGoingSensorWaiting > 0) {
  676. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  677. SensorThread.start();
  678. }
  679. break;
  680. case define.NOTIFY_DOOR_SET_DELAY:
  681. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  682. DoorDelayTime = System.currentTimeMillis();
  683. imapsvrlog("Receive "+define.NOTIFY_DOOR_SET_DELAY+" Set : " +DoorDelayTime);
  684. break;
  685. case define.NOTIFY_DEVICE_INIT_COMPLETION :
  686. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  687. Common.setDeviceServeiceLoadComplite();
  688. startRealtimemeterInfo(); // 실시간 검침기 확인
  689. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  690. startDistributionPanel(); // 분전반 확인
  691. getRoomName();
  692. break;
  693. case define.NOTIFY_DLOCK_SET_OUTING:
  694. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  695. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  696. try {
  697. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  698. int AlarmStatus = DBMGR.GetAlarmStatus();
  699. DBMGR.closeDB();
  700. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  701. // 센서 체크하고
  702. // 현관폰으로 사운드 출력하고
  703. boolean bSensorOk = false;
  704. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  705. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I) {
  706. bSensorOk = mIGW300.checkSensorforOutmode();
  707. }
  708. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  709. bSensorOk = mIGW200.checkSensorforOutmode();
  710. }
  711. else {
  712. bSensorOk = checkSensorforOutmode();
  713. }
  714. if (bSensorOk) {
  715. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  716. CallOutModeRunActivity();
  717. }
  718. else {
  719. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  720. }
  721. }
  722. } catch (Exception e) {
  723. e.printStackTrace();
  724. }
  725. break;
  726. case define.NOTIFY_DLOCK_FREE_OUTING:
  727. // 도어락 외출모드 해제
  728. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  729. try {
  730. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  731. int AlarmStatus = DBMGR.GetAlarmStatus();
  732. DBMGR.closeDB();
  733. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  734. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK );
  735. Common.SendAppFinishReqBR(getApplicationContext());
  736. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  737. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  738. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  739. devDB.closeDB();
  740. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  741. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  742. }
  743. }
  744. } catch (Exception e) {
  745. e.printStackTrace();
  746. }
  747. break;
  748. case define.NOTIFY_SMARTSW_SET_OUTING:
  749. // 485 대외향 스마트스위치 외출모드
  750. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  751. setUnoccupiedModeByNotHDCSmartSwitch();
  752. break;
  753. case define.NOTIFY_SMARTSW_FREE_OUTING:
  754. //대외향 485 스마트스위치 외출모드 해제
  755. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  756. releaseUnoccupiedModeByNotHDCSmartSwitch();
  757. break;
  758. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  759. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  760. String Type = intent.getStringExtra("TYPE");
  761. String Device = intent.getStringExtra("DEVICE");
  762. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  763. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  764. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  765. iMAPSmartLightEvent imapSmartLightEvent;
  766. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  767. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  768. imapSmartLightEvent.SetRetCtr(new RetProci() {
  769. @Override
  770. public void ProcSuccess() {
  771. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  772. }
  773. @Override
  774. public void ProcError() {
  775. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  776. }
  777. @Override
  778. public void ProcDoing() {
  779. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  780. }
  781. });
  782. break;
  783. case define.NOTIFY_KNX_DEVICE_EVENT:
  784. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  785. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  786. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  787. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  788. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  789. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  790. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  791. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  792. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  793. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  794. @Override
  795. public void ProcSuccess() {
  796. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  797. }
  798. @Override
  799. public void ProcError() {
  800. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  801. }
  802. @Override
  803. public void ProcDoing() {
  804. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  805. }
  806. });
  807. break;
  808. case define.NOTIFY_SMART_DCAM_DETECT:
  809. // 스마트현관카메라 거동수상자 발생
  810. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  811. if (!bWallPadCallLive && !bBlockFrontCall) {
  812. if (getStrangerRecordingManagerSetting()) {
  813. if (getStrangerRecordingUserSetting()) {
  814. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  815. Intent Newintent = new Intent();
  816. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  817. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  818. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  819. getApplicationContext().sendBroadcast(Newintent);
  820. }
  821. else {
  822. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  823. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  824. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  825. }
  826. }
  827. else {
  828. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  829. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  830. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  831. }
  832. }
  833. else {
  834. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  835. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  836. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  837. }
  838. break;
  839. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  840. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  841. if (getStrangerRecordingManagerSetting()) {
  842. if (getStrangerRecordingUserSetting()) {
  843. // 알람 상태 확인
  844. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  845. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  846. mWallpadStatusData.closeDB();
  847. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  848. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  849. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  850. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  851. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  852. }
  853. else {
  854. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  855. Intent Newintent = new Intent();
  856. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  857. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  858. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  859. getApplicationContext().sendBroadcast(Newintent);
  860. }
  861. }
  862. else {
  863. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  864. }
  865. }
  866. else {
  867. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  868. }
  869. break;
  870. case define.NOTIFY_ACCEPT_TAKEPIC_STRANGER:
  871. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_TAKEPIC_STRANGER");
  872. if (getUseSmartDoorCam()) {
  873. if (getStrangerTakePic()) {
  874. // 알람 상태 확인
  875. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  876. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  877. mWallpadStatusData.closeDB();
  878. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  879. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  880. // 외출 대기중 (설정진행중)일 경우 촬영안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  881. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  882. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  883. } else {
  884. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_TAKEPIC");
  885. Intent Newintent = new Intent();
  886. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  887. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_TAKEPIC);
  888. getApplicationContext().sendBroadcast(Newintent);
  889. }
  890. }
  891. }
  892. break;
  893. case define.NOTIFY_REJECT_RECORD_STRANGER:
  894. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  895. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  896. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  897. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  898. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  899. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  900. }
  901. break;
  902. case define.NOTIFY_ROOMNAME_CHANGED:
  903. getRoomName();
  904. break;
  905. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  906. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  907. break;
  908. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  909. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  910. break;
  911. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  912. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  913. break;
  914. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  915. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  916. break;
  917. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  918. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  919. break;
  920. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  921. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  922. break;
  923. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  924. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  925. break;
  926. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  927. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  928. break;
  929. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  930. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  931. break;
  932. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  933. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  934. break;
  935. default:
  936. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  937. break;
  938. }
  939. }
  940. } catch (Exception e) {
  941. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  942. e.printStackTrace();
  943. }
  944. }
  945. };
  946. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  947. try {
  948. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  949. // 485 대외향 스마트스위치 외출모드
  950. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  951. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  952. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  953. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  954. mWallpadStatusData.closeDB();
  955. if (UseGuardSensorCheck == false) {
  956. // 그냥 외출모드 처리 .. 기기 연동 처리만
  957. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  958. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  959. mWallpadStatusData.SetAlarmStatus (WallpadStatusData.OUT_MODE);
  960. mWallpadStatusData.closeDB();
  961. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  962. //메인화면 업데이트
  963. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  964. getApplicationContext().sendBroadcast(newIntent);
  965. ModeRunCtrlWorking(false , false);
  966. }
  967. }
  968. else {
  969. // 실제 외출 방범 모드를 설정하도록 한다.
  970. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  971. // 센서 체크하고
  972. // 센서 체크하는 부분이 들어가야 함
  973. Common.SendAppFinishReqBR(getApplicationContext());
  974. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  975. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  976. if (mIGW300.checkSensorforOutmode()) {
  977. CallOutModeWaitingActivity();
  978. }
  979. else {
  980. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  981. }
  982. }
  983. else {
  984. if (checkSensorforOutmode()) {
  985. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  986. CallOutModeWaitingActivity();
  987. }
  988. else {
  989. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  990. }
  991. }
  992. }
  993. }
  994. } catch (Exception e) {
  995. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  996. e.printStackTrace();
  997. }
  998. }
  999. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1000. try {
  1001. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1002. //대외향 485 스마트스위치 외출모드 해제
  1003. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1004. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1005. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1006. mWallpadStatusData.closeDB();
  1007. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease +"]");
  1008. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1009. if (OutModePwRelease) {
  1010. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1011. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1012. // 요청하여도 해제 되지 않으며
  1013. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1014. Intent notiIntent = new Intent();
  1015. notiIntent.setAction(define.NOTIFY_ACNAME);
  1016. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1017. getApplicationContext().sendBroadcast(notiIntent);
  1018. }
  1019. else {
  1020. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1021. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1022. // 처리하고.
  1023. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1024. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1025. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1026. mWallpadStatusData.closeDB();
  1027. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1028. Common.SendAppFinishReqBR(getApplicationContext());
  1029. }
  1030. }
  1031. else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1032. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1033. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1034. ModeReleaseCtrlWorking(false);
  1035. bSmartSwitch485ComebackMode = true;
  1036. Intent notiIntent = new Intent();
  1037. notiIntent.setAction(define.NOTIFY_ACNAME);
  1038. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1039. getApplicationContext().sendBroadcast(notiIntent);
  1040. }
  1041. else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1042. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1043. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1044. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1045. mWallpadStatusData.SetAlarmStatus (WallpadStatusData.ALARM_NONE);
  1046. mWallpadStatusData.closeDB();
  1047. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK );
  1048. //메인화면 업데이트
  1049. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1050. getApplicationContext().sendBroadcast(newIntent);
  1051. ModeReleaseCtrlWorking(false);
  1052. }
  1053. } catch (Exception e) {
  1054. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1055. e.printStackTrace();
  1056. }
  1057. }
  1058. /**
  1059. * 스마트현관카메라 녹화 여부 판별
  1060. * 사용자 화면에서 설정
  1061. */
  1062. private boolean getStrangerRecordingUserSetting() {
  1063. boolean bResult = false;
  1064. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1065. try {
  1066. bResult = DBMGR.GetStrangerRecordingOnOff();
  1067. DBMGR.closeDB();
  1068. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1069. } catch (Exception e) {
  1070. DBMGR.closeDB();
  1071. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1072. e.printStackTrace();
  1073. bResult = false;
  1074. }
  1075. return bResult;
  1076. }
  1077. private boolean getStrangerTakePic() {
  1078. try {
  1079. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1080. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1081. DBMGR.closeDB();
  1082. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1083. return bResult;
  1084. } catch (Exception e) {
  1085. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1086. e.printStackTrace();
  1087. return false;
  1088. }
  1089. }
  1090. // 관리자 설정 항목에 있음
  1091. private boolean getStrangerRecordUsage() {
  1092. try {
  1093. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1094. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1095. mWallpadDeviceSet .closeDB();
  1096. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1097. return bResult;
  1098. } catch (Exception e) {
  1099. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1100. e.printStackTrace();
  1101. return false;
  1102. }
  1103. }
  1104. private boolean checkSensorforOutmode() {
  1105. try {
  1106. WallPadInterface wallPadInterface = new WallPadInterface();
  1107. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1108. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1109. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1110. int[] SensorInfoDB;
  1111. int sensorIn = 0;
  1112. int sensorOut = 0;
  1113. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1114. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1115. if (SensorInfoDB[0] == 1) {
  1116. // 내부동체가 사용함이면 상태 검사
  1117. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1118. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1119. }
  1120. if (SensorInfoDB[1] == 1) {
  1121. // 외부동체가 사용함이면 상태 검사
  1122. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1123. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1124. }
  1125. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1126. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1127. // 동체 사용 설정 체크..
  1128. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1129. int sensor = devSet.Get_Sensor_Set();
  1130. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1131. devSet.closeDB();
  1132. int OtherInSensor = 0;
  1133. // 내부동체 사용안함 이면
  1134. if ((sensor&WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1135. // 외부동체 사용안함 이면
  1136. if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1137. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1138. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1139. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1140. return true;
  1141. }
  1142. else {
  1143. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1144. return false;
  1145. }
  1146. } catch (Exception e) {
  1147. e.printStackTrace();
  1148. return false;
  1149. }
  1150. }
  1151. private boolean checkSensorforInmode() {
  1152. try {
  1153. WallPadInterface wallPadInterface = new WallPadInterface();
  1154. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1155. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1156. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1157. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1158. if (sensorMag == 0) {
  1159. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1160. return true;
  1161. }
  1162. else {
  1163. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1164. return false;
  1165. }
  1166. } catch (Exception e) {
  1167. Log.e(TAG, e.toString());
  1168. e.printStackTrace();
  1169. return false;
  1170. }
  1171. }
  1172. /////////////////////
  1173. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1174. //////////////
  1175. /////////////////////
  1176. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1177. //////////////
  1178. public void playSoundthroughDoorphone(int SoundIdx) {
  1179. try
  1180. {
  1181. WallPadInterface Wiface = new WallPadInterface();
  1182. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1183. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1184. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  1185. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1186. if (getUseSmartDoorCam()) {
  1187. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1188. }
  1189. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1190. /*
  1191. JEFF (2019.01.14)
  1192. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1193. 강신구입니다.
  1194. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1195. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1196. 내용 공유합니다.
  1197. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1198. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1199. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1200. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1201. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1202. 문제 없습니다.
  1203. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1204. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1205. 문의사항은 하기 연락바랍니다.
  1206. 감사합니다.
  1207. */
  1208. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1209. }
  1210. else {
  1211. // 대외향 모델 처리
  1212. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1213. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1214. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1215. }
  1216. try{Thread.sleep(100);}catch(Exception e){e.printStackTrace();}
  1217. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1218. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1219. try{Thread.sleep(1500);}catch(Exception e){e.printStackTrace();}
  1220. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1221. int SLevel = Wdb.GetDoorSoundLevel();
  1222. Wdb.closeDB();
  1223. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1224. if (SLevel != -1) {
  1225. /**
  1226. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1227. * **/
  1228. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1229. }
  1230. else {
  1231. // 사용안함이면
  1232. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1233. }
  1234. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1235. int time = Sound().PlayMent(SoundIdx);
  1236. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1237. if (0 > time) {
  1238. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1239. time = 1000;
  1240. }
  1241. try{Thread.sleep(time + 1000);}catch(Exception e){e.printStackTrace();}
  1242. amanager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1243. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1244. try{Thread.sleep(100);}catch(Exception e){e.printStackTrace();}
  1245. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1246. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  1247. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1248. if (getUseSmartDoorCam()) {
  1249. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1250. }
  1251. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1252. /*
  1253. JEFF (2019.01.14)
  1254. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1255. 강신구입니다.
  1256. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1257. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1258. 내용 공유합니다.
  1259. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1260. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1261. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1262. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1263. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1264. 문제 없습니다.
  1265. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1266. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1267. 문의사항은 하기 연락바랍니다.
  1268. 감사합니다.
  1269. */
  1270. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1271. }
  1272. else {
  1273. // 대외향 모델 처리
  1274. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1275. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1276. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1277. }
  1278. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1279. } catch (Exception e) {
  1280. e.printStackTrace();
  1281. }
  1282. }
  1283. public void CallOutModeRunActivity() {
  1284. int base = 8000;
  1285. int [] Menu_Id_List = { base + 11 };
  1286. int Menu_StartId = base + 11;
  1287. int Menu_Option = -1;
  1288. Intent intent = new Intent(Intent.ACTION_MAIN);
  1289. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1290. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1291. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1292. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1293. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1294. startActivity(intent);
  1295. }
  1296. public void CallOutModeWaitingActivity() {
  1297. int base = 4000;
  1298. int [] Menu_Id_List = { base + 11 , base + 21};
  1299. int Menu_StartId = base + 11;
  1300. int Menu_Option = 1000;
  1301. Intent intent = new Intent(Intent.ACTION_MAIN);
  1302. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1303. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1304. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1305. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity","kr.co.icontrols.wallpadsecurity.MainActivity"));
  1306. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1307. startActivity(intent);
  1308. }
  1309. private boolean getGlobalScreenAppRunningStatus() {
  1310. boolean bRunning = false;
  1311. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1312. try {
  1313. bRunning = DBMGR.getGlobalScreenAPKRun();
  1314. DBMGR.closeDB();
  1315. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1316. return bRunning;
  1317. } catch (Exception e) {
  1318. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1319. e.printStackTrace();
  1320. DBMGR.closeDB();
  1321. }
  1322. return bRunning;
  1323. }
  1324. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1325. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1326. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1327. try {
  1328. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1329. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1330. DBMGR.closeDB();
  1331. } catch (Exception e) {
  1332. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1333. e.printStackTrace();
  1334. DBMGR.closeDB();
  1335. }
  1336. }
  1337. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1338. boolean bGlobalScreenRun = false;
  1339. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1340. try {
  1341. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel +"], hColor [" + hColor +"], hControl [" + hControl +"]");
  1342. wakeupLCD();
  1343. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1344. setGlobalScreenAppRunningStatus(true);
  1345. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1346. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1347. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1348. mIntent.putExtra("ONOFF", hOnOff);
  1349. mIntent.putExtra("DIAL", hDial);
  1350. mIntent.putExtra("LEVEL", hLevel);
  1351. mIntent.putExtra("COLOR", hColor);
  1352. mIntent.putExtra("CONTROL", hControl);
  1353. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1354. mIntent.setComponent(mComponentName);
  1355. startActivity(mIntent);
  1356. }
  1357. else {
  1358. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1359. }
  1360. } catch (Exception e) {
  1361. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1362. e.printStackTrace();
  1363. }
  1364. }
  1365. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1366. try {
  1367. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel +"], hColor [" + hColor +"], hControl [" + hControl +"]");
  1368. wakeupLCD();
  1369. if (!getGlobalScreenAppRunningStatus()) {
  1370. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1371. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1372. return;
  1373. }
  1374. setGlobalScreenAppRunningStatus(true);
  1375. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1376. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1377. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1378. mIntent.putExtra("SCREENID", nScreenID);
  1379. mIntent.putExtra("ONOFF", hOnOff);
  1380. mIntent.putExtra("DIAL", hDial);
  1381. mIntent.putExtra("LEVEL", hLevel);
  1382. mIntent.putExtra("COLOR", hColor);
  1383. mIntent.putExtra("CONTROL", hControl);
  1384. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1385. mIntent.setComponent(mComponentName);
  1386. startActivity(mIntent);
  1387. }
  1388. else {
  1389. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1390. }
  1391. } catch (Exception e) {
  1392. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1393. e.printStackTrace();
  1394. }
  1395. }
  1396. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1397. public void sendBlackoutReleasedBR() {
  1398. try {
  1399. Intent notiIntent = new Intent();
  1400. notiIntent.setAction(strBLACKOUT_RELEASED);
  1401. getApplicationContext().sendBroadcast(notiIntent);
  1402. } catch (Exception e) {
  1403. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1404. e.printStackTrace();
  1405. }
  1406. }
  1407. private int getCurrentScreen() {
  1408. int nScreenID = 0;
  1409. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1410. try {
  1411. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1412. DBMGR.closeDB();
  1413. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1414. return nScreenID;
  1415. } catch (Exception e) {
  1416. Log.e(TAG, "[Exception] getCurrentScreen()");
  1417. e.printStackTrace();
  1418. DBMGR.closeDB();
  1419. }
  1420. return nScreenID;
  1421. }
  1422. private void setCurrentScreen(int nScreenID) {
  1423. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1424. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1425. try {
  1426. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1427. DBMGR.closeDB();
  1428. } catch (Exception e) {
  1429. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1430. e.printStackTrace();
  1431. DBMGR.closeDB();
  1432. }
  1433. }
  1434. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1435. private void procUploadMissedVisitorPic(Intent intent) {
  1436. try {
  1437. String strDong = intent.getStringExtra("DONG");
  1438. String strHo = intent.getStringExtra("HO");
  1439. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1440. int nCnt = intent.getIntExtra("CNT", 0);
  1441. String[] strMissedPicURI = new String[nCnt];
  1442. strArrayMissedPicURI.clear();
  1443. for (int i = 0; i < nCnt; i++) {
  1444. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1445. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1446. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1447. }
  1448. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1449. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1450. }
  1451. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1452. } catch (Exception e) {
  1453. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1454. e.printStackTrace();
  1455. }
  1456. }
  1457. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1458. try {
  1459. String strURI = "", strFileName = "", strTime = "", strType = "";
  1460. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1461. // strURI = strArrayMissedPicURI.get(i).toString();
  1462. // strFileName = extractFileName(strURI);
  1463. // strTime = extractFileTime(strURI);
  1464. // strType = extractCallType(strFileName);
  1465. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1466. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1467. // }
  1468. if (strArrayMissedPicURI.size() > 0) {
  1469. strURI = strArrayMissedPicURI.get(0).toString();
  1470. strFileName = extractFileName(strURI);
  1471. strTime = extractFileTime(strFileName);
  1472. strType = extractCallType(strFileName);
  1473. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1474. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1475. }
  1476. else {
  1477. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1478. }
  1479. } catch (Exception e) {
  1480. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1481. e.printStackTrace();
  1482. }
  1483. }
  1484. public class uploadVisitorPicture extends Thread {
  1485. HDCFTPManager mFTPManager;
  1486. boolean bMainServer2dot0 = false;
  1487. String strRemoteIP = "10.0.1.1";
  1488. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1489. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1490. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1491. try {
  1492. strDong = dong;
  1493. strHo = ho;
  1494. strType = type;
  1495. strTime = time;
  1496. strFileName = filename;
  1497. strUploadFile = uploadfile;
  1498. bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1499. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1500. wallpadDeviceSet.closeDB();
  1501. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile +"], strFileName [" + strFileName +"], strTime [" + strTime +"]");
  1502. } catch (Exception e) {
  1503. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1504. e.printStackTrace();
  1505. }
  1506. }
  1507. public void run() {
  1508. try {
  1509. mFTPManager = new HDCFTPManager();
  1510. if (!mFTPManager.isFTPConnected()) {
  1511. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1512. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1513. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1514. return;
  1515. }
  1516. }
  1517. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1518. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1519. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1520. return;
  1521. }
  1522. if (!bMainServer2dot0) {
  1523. if (!mFTPManager.setPassiveMode()) {
  1524. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1525. disconnectFTP();
  1526. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1527. return;
  1528. }
  1529. }
  1530. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1531. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1532. disconnectFTP();
  1533. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1534. return;
  1535. }
  1536. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1537. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1538. disconnectFTP();
  1539. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1540. return;
  1541. }
  1542. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1543. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1544. disconnectFTP();
  1545. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1546. return;
  1547. }
  1548. disconnectFTP();
  1549. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1550. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1551. sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1552. } catch (Exception e) {
  1553. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1554. e.printStackTrace();
  1555. }
  1556. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1557. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1558. }
  1559. public boolean disconnectFTP() {
  1560. try {
  1561. if (mFTPManager.logoutFTP()) {
  1562. if (mFTPManager.disconnectFTP()) {
  1563. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1564. return true;
  1565. }
  1566. }
  1567. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1568. return false;
  1569. } catch (Exception e) {
  1570. Log.e(TAG, "[Exception] disconnectFTP()");
  1571. e.printStackTrace();
  1572. return false;
  1573. }
  1574. }
  1575. }
  1576. private String extractCallType(String strFileName) {
  1577. try {
  1578. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1579. String[] strParse_01 = strFileName.split("_");
  1580. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1581. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1582. else return "none";
  1583. } catch (Exception e) {
  1584. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1585. e.printStackTrace();
  1586. return null;
  1587. }
  1588. }
  1589. private String extractFileName(String strTargetFile) {
  1590. try {
  1591. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1592. String[] strParse_01 = strTargetFile.split("/");
  1593. return strParse_01[strParse_01.length - 1];
  1594. } catch (Exception e) {
  1595. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1596. e.printStackTrace();
  1597. return null;
  1598. }
  1599. }
  1600. private String extractFileTime(String strFileName) {
  1601. try {
  1602. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1603. String[] strParse_01 = strFileName.split("\\.");
  1604. String[] strParse_02 = strParse_01[0].split("_");
  1605. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1606. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1607. // strTime = strParse_03[5].substring(0, 4) + "." + strParse_03[5].substring(4, 6) + "." + strParse_03[5].substring(6) + "." + strParse_03[6].substring(0, 2) + "." + strParse_03[6].substring(2, 4) + "." + strParse_03[6].substring(4);
  1608. return strParse_02[5] + "_" + strParse_02[6];
  1609. } catch (Exception e) {
  1610. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1611. e.printStackTrace();
  1612. return null;
  1613. }
  1614. }
  1615. String strRemoteURI, strUserID, strPW, strPath;
  1616. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1617. public boolean send_visitor_access_info_request(final String strDong, final String strHo, final String strType, final String strTime, final String strFileName, String strMessage, final String strFilePath) {
  1618. try {
  1619. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1620. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1621. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1622. visitor_access_info.setResultCtrl(new RetProci() {
  1623. @Override
  1624. public void ProcSuccess() {
  1625. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1626. visitor_access_info.SetItem("ftp_info");
  1627. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1628. strReply_PW = visitor_access_info.GetAttributeVal(0, "passwd");
  1629. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1630. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1631. strUserID = strReply_User;
  1632. strPW = strReply_PW;
  1633. strPath = strReply_Path;
  1634. strRemoteURI = strPath + "/" + strFileName;
  1635. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1636. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1637. mUploadVisitorPicture.start();
  1638. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1639. // mUploadVisitorPicture.start();
  1640. }
  1641. @Override
  1642. public void ProcError() {
  1643. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1644. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1645. sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1646. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1647. }
  1648. @Override
  1649. public void ProcDoing() {
  1650. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1651. }
  1652. });
  1653. return true;
  1654. }
  1655. } catch (Exception e) {
  1656. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1657. e.printStackTrace();
  1658. }
  1659. return false;
  1660. }
  1661. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1662. try {
  1663. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1664. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1665. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1666. visitor_upload_complete.setResultCtrl(new RetProci() {
  1667. @Override
  1668. public void ProcSuccess() {
  1669. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1670. }
  1671. @Override
  1672. public void ProcError() {
  1673. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1674. }
  1675. @Override
  1676. public void ProcDoing() {
  1677. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1678. }
  1679. });
  1680. return true;
  1681. }
  1682. } catch (Exception e) {
  1683. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1684. e.printStackTrace();
  1685. }
  1686. return false;
  1687. }
  1688. /**
  1689. * 이통사 연동 서비스를 위한 BR
  1690. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1691. * @param kind (String) "lobby" or "home"
  1692. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1693. */
  1694. public void sendVisitorEventBRtoMobileVendorSKT(String kind , String datetime) {
  1695. try {
  1696. Log.i(TAG, "[sendVisitorEventBRtoMobileVendorSKT] kind [" + kind + "], datetime [" + datetime + "]");
  1697. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1698. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1699. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1700. Intent mIntent = new Intent();
  1701. mIntent.setAction(BR_VISITOR_EVENT);
  1702. mIntent.putExtra("KIND", kind);
  1703. mIntent.putExtra("TIME", datetime);
  1704. getApplicationContext().sendBroadcast(mIntent);
  1705. } catch (Exception e) {
  1706. Log.e(TAG, "[Exception] sendVisitorEventBRtoMobileVendorSKT(String kind , String datetime)");
  1707. e.printStackTrace();
  1708. }
  1709. }
  1710. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1711. public void onReceive(Context context, Intent intent) {
  1712. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1713. Bundle bundle;
  1714. WallpadDeviceSet devset;
  1715. Intent newintent;
  1716. boolean CallAppRun = false;
  1717. boolean MgrAppRun = false;
  1718. final String packageName = "com.artncore.apps.ic_wallpad";
  1719. final String packageNameMgr = "com.artncore.managersetting";
  1720. //CallAppRun = getForegroundAPK().equals(packageName);
  1721. // CallAppRun = getCallAppRunning();
  1722. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1723. int base = 7000;
  1724. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  1725. int Menu_Start_Option = 1;
  1726. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1727. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1728. int keyevt = ReceiveEvt.getKeyCode();
  1729. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY -1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1730. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1731. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1732. sdata.closeDB();
  1733. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1734. return;
  1735. }
  1736. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1737. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1738. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1739. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1740. mWallpadStatusData.closeDB();
  1741. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1742. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1743. sdata.closeDB();
  1744. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1745. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1746. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1747. int nModelType = Version.getModelType();
  1748. switch (ReceiveEvt.getKeyCode()) {
  1749. case 251: // 현산향 비상버튼 다운 업 처리
  1750. try {
  1751. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1752. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1753. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1754. }
  1755. else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1756. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1757. }
  1758. }
  1759. } catch(Exception e) {
  1760. e.printStackTrace();
  1761. }
  1762. break;
  1763. case WallPadInterface.EVT_RING:
  1764. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1765. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1766. // 전화 수신 링 수신
  1767. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1768. if (Version.getGatewayUsage()) {
  1769. // 국선 시작만 올라온다.
  1770. startIGW300RingGenerator();
  1771. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1772. }
  1773. else {
  1774. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1775. }
  1776. break;
  1777. case WallPadInterface.EVT_END_RING:
  1778. // 전화 수신 링 종료
  1779. // Jeff added below codes for call app (2018.01.25)
  1780. // This event is managed by WallPadCall
  1781. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  1782. if (Version.getGatewayUsage()) {
  1783. stopIGW300RingGenerator();
  1784. }
  1785. break;
  1786. case WallPadInterface.BTN_EMR:
  1787. case WallPadInterface.BTN_EMR_IHN1010:
  1788. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  1789. // 월패드 비상버튼 입력 SA 와 GLE 공통
  1790. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  1791. if (MgrAppRun) return;
  1792. if (Common.DIAGNOSTIC_MODE) return;
  1793. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  1794. //currentTime = System.currentTimeMillis();
  1795. //if (ALERTTIME > currentTime) break;
  1796. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  1797. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  1798. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  1799. devset = new WallpadDeviceSet(getApplicationContext());
  1800. int StatusVal = devset.GetDeviceSetted("알람발생");
  1801. devset.closeDB();
  1802. Log.d("imap", "StatusVal : " + StatusVal);
  1803. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  1804. // 보안 처리가 필요함..
  1805. // 지속적으로 이벤트가 들어올 경우 대비
  1806. Common.SendAppFinishReqBR(getApplicationContext());
  1807. newintent = new Intent(Intent.ACTION_MAIN);
  1808. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1809. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  1810. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  1811. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  1812. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  1813. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1814. iMAPstartActivity(newintent);
  1815. }
  1816. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  1817. if (getIsSubWallpad()) {
  1818. Intent notiIntent = new Intent();
  1819. notiIntent.setAction(define.NOTIFY_ACNAME);
  1820. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  1821. getApplicationContext().sendBroadcast(notiIntent);
  1822. }
  1823. break;
  1824. case WallPadInterface.BTN_CALL:
  1825. case WallPadInterface.BTN_CALL_IHN1010:
  1826. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  1827. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  1828. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  1829. // Jeff added below codes for call app (2018.01.25)
  1830. try {
  1831. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  1832. if (getIsSubWallpad()) {
  1833. // 서브월패드
  1834. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  1835. }
  1836. else {
  1837. // 메인월패드
  1838. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  1839. }
  1840. } catch (Exception e) {
  1841. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  1842. e.printStackTrace();
  1843. }
  1844. break;
  1845. case WallPadInterface.BTN_OPEN:
  1846. // 월패드 문여림 버튼 입력 상태 SA
  1847. break;
  1848. case WallPadInterface.BTN_DOOR:
  1849. case WallPadInterface.BTN_DOOR_IHN1010:
  1850. // 현관 도어폰 벨 눌림 입력 상태
  1851. // Jeff added below codes for call app (2018.01.25)
  1852. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  1853. if (!bWallPadCallLive && !bBlockFrontCall) {
  1854. bBlockFrontCall = true;
  1855. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  1856. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  1857. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1858. try {
  1859. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  1860. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  1861. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  1862. }
  1863. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1864. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  1865. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1866. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  1867. }
  1868. if (!Version.getGatewayUsage()) {
  1869. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  1870. }
  1871. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  1872. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  1873. } catch (Exception e) {
  1874. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  1875. e.printStackTrace();
  1876. }
  1877. }
  1878. else {
  1879. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  1880. }
  1881. break;
  1882. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  1883. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010:
  1884. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  1885. if (!getEmergencyIOUsage()) {
  1886. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  1887. return;
  1888. }
  1889. if (MgrAppRun) {
  1890. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  1891. return;
  1892. }
  1893. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  1894. devset = new WallpadDeviceSet(getApplicationContext());
  1895. StatusVal = devset.GetDeviceSetted("알람발생");
  1896. devset.closeDB();
  1897. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  1898. Common.SendAppFinishReqBR(getApplicationContext());
  1899. newintent = new Intent(Intent.ACTION_MAIN);
  1900. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1901. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  1902. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  1903. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  1904. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  1905. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1906. iMAPstartActivity(newintent);
  1907. }
  1908. break;
  1909. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  1910. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  1911. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  1912. if (MgrAppRun) return;
  1913. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_ALT) {
  1914. WallPadInterface mWallPadInterface = new WallPadInterface();
  1915. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1916. if (sensorMag == 0) return;
  1917. }
  1918. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  1919. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT ) break;
  1920. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1921. if (OutGoingSensorWaiting == 0) {
  1922. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  1923. SensorThread.start();
  1924. }
  1925. OutGoingSensorWaiting |= SENSOR_MAG;
  1926. }
  1927. else {
  1928. Common.SendAppFinishReqBR(getApplicationContext());
  1929. newintent = new Intent(Intent.ACTION_MAIN);
  1930. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1931. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  1932. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  1933. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  1934. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  1935. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1936. iMAPstartActivity(newintent);
  1937. }
  1938. break;
  1939. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  1940. saveBlackoutStatus(true);
  1941. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  1942. break;
  1943. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  1944. saveBlackoutStatus(false);
  1945. sendBlackoutReleasedBR();
  1946. break;
  1947. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  1948. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  1949. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  1950. if (MgrAppRun) return;
  1951. if (AlarmStatus == WallpadStatusData.ALARM_ARISE ||AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  1952. devset = new WallpadDeviceSet(getApplicationContext());
  1953. StatusVal = devset.GetDeviceSetted("피난사다리");
  1954. devset.closeDB();
  1955. Log.d(TAG, "ladder======> " + StatusVal);
  1956. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  1957. Common.SendAppFinishReqBR(getApplicationContext());
  1958. newintent = new Intent(Intent.ACTION_MAIN);
  1959. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1960. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  1961. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  1962. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  1963. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  1964. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1965. iMAPstartActivity(newintent);
  1966. }
  1967. break;
  1968. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  1969. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  1970. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  1971. {
  1972. // 내부동체가 상태가 변경된 경우
  1973. int[] SensorInfoDB;
  1974. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1975. if (SensorInfoDB[0] != 1) {
  1976. //내부동체가 사용함이면 상태 검사
  1977. return;
  1978. }
  1979. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_ALT) {
  1980. WallPadInterface mWallPadInterface = new WallPadInterface();
  1981. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1982. if (sensorMag == 0) return;
  1983. }
  1984. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1985. int sensor = devSet.Get_Sensor_Set();
  1986. devSet.closeDB();
  1987. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  1988. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  1989. break;
  1990. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  1991. if (OutGoingSensorWaiting == 0) {
  1992. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  1993. SensorThread.start();
  1994. }
  1995. OutGoingSensorWaiting |= SENSOR_IN;
  1996. }
  1997. break;
  1998. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  1999. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2000. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2001. {
  2002. // 외부동체가 상태가 변경된 경우
  2003. int[] SensorInfoDB;
  2004. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2005. if (SensorInfoDB[1] != 1) {
  2006. // 외부동체가 사용함이면 상태 검사
  2007. return;
  2008. }
  2009. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_ALT) {
  2010. WallPadInterface mWallPadInterface = new WallPadInterface();
  2011. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2012. if (sensorMag == 0) return;
  2013. }
  2014. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2015. int sensor = devSet.Get_Sensor_Set();
  2016. devSet.closeDB();
  2017. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2018. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2019. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2020. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) break;
  2021. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2022. {
  2023. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2024. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2025. break;
  2026. }*/
  2027. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2028. if (OutGoingSensorWaiting == 0) {
  2029. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2030. SensorThread.start();
  2031. }
  2032. OutGoingSensorWaiting |= SENSOR_OUT;
  2033. }
  2034. else {
  2035. Common.SendAppFinishReqBR(getApplicationContext());
  2036. newintent = new Intent(Intent.ACTION_MAIN);
  2037. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2038. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2039. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2040. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2041. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2042. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2043. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2044. iMAPstartActivity(newintent);
  2045. }
  2046. }
  2047. break;
  2048. }
  2049. }
  2050. else {
  2051. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2052. }
  2053. }
  2054. };
  2055. protected void iMAPstartActivity(Intent intent) {
  2056. try {
  2057. startActivity(intent);
  2058. } catch(Exception e) {
  2059. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2060. e.printStackTrace();
  2061. }
  2062. }
  2063. /**
  2064. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2065. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2066. * 1. 현관카메라 키이벤트 수신
  2067. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2068. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2069. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2070. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2071. * 6. 시스템 볼륨 원복
  2072. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2073. */
  2074. AudioManager mAudioManager;
  2075. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2076. Handler mDingDongHandler = new Handler() {
  2077. public void handleMessage(Message msg) {
  2078. try {
  2079. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2080. if (msg.what == 0) {
  2081. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2082. int nVolume = 10;
  2083. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) nVolume = 12;
  2084. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2085. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2086. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2087. mDingDongHandler.sendEmptyMessage(1);
  2088. } else if (msg.what == 1) {
  2089. // 띵똥 패스 체크
  2090. check1++;
  2091. if (check1 > 200) {
  2092. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2093. finishDingDongHandler();
  2094. check1 = 0;
  2095. return;
  2096. } else {
  2097. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2098. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2099. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2100. }
  2101. } else if (msg.what == 2) {
  2102. // 띵똥 음원 재생
  2103. mIOInterface.ctrlSetTalkPathDoor();
  2104. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2105. } else if (msg.what == 3) {
  2106. mIOInterface.ctrlSetTalkPathNormal();
  2107. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2108. mDingDongHandler.sendEmptyMessage(4);
  2109. } else if (msg.what == 4) {
  2110. // Normal 패스 체크
  2111. check2++;
  2112. if (check2 > 200) {
  2113. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2114. finishDingDongHandler();
  2115. check2 = 0;
  2116. return;
  2117. } else {
  2118. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2119. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2120. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2121. }
  2122. } else if (msg.what == 5) {
  2123. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2124. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2125. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2126. wdb.closeDB();
  2127. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2128. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2129. intent.setAction(define.NOTIFY_ACNAME);
  2130. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2131. sendBroadcast(intent);
  2132. }
  2133. } catch (Exception e) {
  2134. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2135. e.printStackTrace();
  2136. finishDingDongHandler();
  2137. }
  2138. }
  2139. };
  2140. private void finishDingDongHandler() {
  2141. try {
  2142. Log.d(TAG, "[finishDingDongHandler]");
  2143. if (mDingDongHandler != null) {
  2144. mDingDongHandler.removeMessages(0);
  2145. mDingDongHandler.removeMessages(1);
  2146. mDingDongHandler.removeMessages(2);
  2147. mDingDongHandler.removeMessages(3);
  2148. mDingDongHandler.removeMessages(4);
  2149. mDingDongHandler.removeMessages(5);
  2150. }
  2151. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2152. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2153. wdb.closeDB();
  2154. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2155. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2156. mIOInterface.ctrlSetTalkPathNormal();
  2157. } catch (Exception e) {
  2158. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2159. e.printStackTrace();
  2160. }
  2161. }
  2162. // 외출방범 대기 모드 중 사운드와 센서 체크
  2163. class OutgoingCheckSensor extends Thread {
  2164. public OutgoingCheckSensor() {
  2165. }
  2166. public void run() {
  2167. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2168. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2169. WallPadInterface wpifc = new WallPadInterface();
  2170. mWallpadStatusData.closeDB();
  2171. int checkcount = timedata / 5;
  2172. int i;
  2173. for (i = checkcount; i > 0; i--) {
  2174. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2175. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2176. mWallpadStatusData.closeDB();
  2177. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2178. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2179. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2180. try{Thread.sleep(5000);} catch (Exception e){e.printStackTrace();}
  2181. }
  2182. if (i==0) {
  2183. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2184. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2185. mWallpadStatusData.closeDB();
  2186. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2187. Common.SendAppFinishReqBR(getApplicationContext());
  2188. int base = 7000;
  2189. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  2190. int Menu_Start_Option = 1;
  2191. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2192. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2193. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2194. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2195. String Cuase = (OutGoingSensorWaiting&SENSOR_OUT)>0?"bugout":"bugin";
  2196. if ((OutGoingSensorWaiting&SENSOR_OUT)>0) Cuase = "bugout";
  2197. else if ((OutGoingSensorWaiting&SENSOR_MAG)>0) Cuase = "magnetic";
  2198. else if ((OutGoingSensorWaiting&SENSOR_IN)>0) Cuase = "bugin";
  2199. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2200. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2201. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2202. iMAPstartActivity(mIntent);
  2203. }
  2204. }
  2205. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2206. OutGoingSensorWaiting = 0;
  2207. }
  2208. }
  2209. @Override
  2210. public IBinder onBind(Intent arg0) {
  2211. return null;
  2212. }
  2213. public void imapsvrlog(String msg)
  2214. {
  2215. if (!log_sw) return;
  2216. Log.d(TAG, APIErrorCode.GetLogPrefix()+" IMAPSVR:"+msg);
  2217. }
  2218. public int onStartCommand(Intent intent, int flags, int startID) {
  2219. try {
  2220. try {
  2221. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2222. } catch (Exception e) {
  2223. e.printStackTrace();
  2224. }
  2225. SvrSock = new iMapSverSocket();
  2226. SvrSock.start();
  2227. } catch (IOException e) {
  2228. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2229. e.printStackTrace();
  2230. }
  2231. try {
  2232. mGleInterface = new jni();
  2233. }catch(Exception e) {
  2234. Log.e(TAG,"[Exception] mGleInterface init...");
  2235. e.printStackTrace();
  2236. }
  2237. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2238. AddressSet addr = DBMGR.getAddressMGR();
  2239. DBMGR.closeDB();
  2240. String AddressStr = addr.Dong+"동 "+addr.Ho+"호";
  2241. AddrDong = addr.Dong;
  2242. AddrHo = addr.Ho;
  2243. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  2244. "<imap ver=\"1.0\" address=\""+addr.IPAddress+"\" sender=\""+AddressStr+"\">\r\n";
  2245. Log.d(TAG, "*****************************************");
  2246. Log.d(TAG, "****************SchedulerThread**********");
  2247. Log.d(TAG, "*****************************************");
  2248. ScheServer = new SchedulerThread();
  2249. ScheServer.start();
  2250. // BR 등록 시작
  2251. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2252. IntentFilter mIntentFilter = new IntentFilter();
  2253. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2254. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2255. mIntentFilter = new IntentFilter();
  2256. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2257. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2258. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2259. mIntentFilter = new IntentFilter();
  2260. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2261. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2262. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2263. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2264. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2265. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2266. // BR 등록 완료
  2267. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2268. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL) IGW200APICheckHandler.sendEmptyMessage(0);
  2269. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2270. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  2271. IGW300APICheckHandler.sendEmptyMessage(0);
  2272. }
  2273. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2274. if (Version.getModelType() != MODEL_TYPE.IHN_1010_I_ALT) {
  2275. // IHN-1010-I-ALT는 네트워크 버전이 아니므로 device_bootup을 전송하지 않는다. (iMapServer service는 부팅과 동시에 자동으로 실행되므로 메인앱에서 실행할 필요가 없음)
  2276. // 아래 BR은 device_bootup을 전송하기위한 BR임
  2277. Intent notiIntent = new Intent();
  2278. notiIntent.setAction(define.NOTIFY_ACNAME);
  2279. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2280. getApplicationContext().sendBroadcast(notiIntent);
  2281. }
  2282. CheckMainStatus();
  2283. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2284. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2285. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2286. GwCheckThread.start();
  2287. }
  2288. return START_STICKY;
  2289. }
  2290. // 메인 서버 소켓 클래스
  2291. public class iMapSverSocket extends Thread
  2292. {
  2293. ServerSocket svr;
  2294. private SSLServerSocket sslsvr;
  2295. boolean receiveSocketRun = true;
  2296. public iMapSverSocket() throws IOException
  2297. {
  2298. /////////////////////////////////////////////////////////////////////
  2299. // 신형 단지서버 사용 유무를 가져온다.
  2300. /////////////////////////////////////////////////////////////////////
  2301. try {
  2302. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2303. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2304. wallpadDeviceSet.closeDB();
  2305. } catch(Exception e) {
  2306. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2307. e.printStackTrace();
  2308. mNewDanjiServer = false;
  2309. }
  2310. //////////////////////////////////////////////////
  2311. /////////////////////////////////////////////////////////////////////
  2312. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2313. /////////////////////////////////////////////////////////////////////
  2314. if(!mNewDanjiServer)
  2315. {
  2316. svr = new ServerSocket(port);
  2317. }
  2318. else
  2319. {
  2320. int svrport = port + 1000;
  2321. Log.i(TAG, "============================================");
  2322. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2323. Log.i(TAG, "============================================");
  2324. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2325. sslsvr = sslServerSocket.getServerSocket();
  2326. }
  2327. }
  2328. public void run()
  2329. {
  2330. while(receiveSocketRun)
  2331. {
  2332. try {
  2333. Socket sock = null;
  2334. /////////////////////////////////////////////////////////////////////
  2335. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2336. /////////////////////////////////////////////////////////////////////
  2337. if(!mNewDanjiServer)
  2338. {
  2339. sock = svr.accept();
  2340. }
  2341. else
  2342. {
  2343. sock = sslsvr.accept();
  2344. }
  2345. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2346. ProciMap.start();
  2347. } catch (IOException e) {
  2348. e.printStackTrace();
  2349. }
  2350. }
  2351. }
  2352. public void destoryThread()
  2353. {
  2354. receiveSocketRun = false;
  2355. try
  2356. {
  2357. if( svr != null )
  2358. {
  2359. svr.close();
  2360. svr = null;
  2361. }
  2362. if( sslsvr != null )
  2363. {
  2364. sslsvr.close();
  2365. sslsvr = null;
  2366. }
  2367. }
  2368. catch( Exception e)
  2369. {
  2370. e.printStackTrace();
  2371. }
  2372. }
  2373. }
  2374. // iMAP 서버 소켓 처리
  2375. public class iMapSverSocketThread extends Thread {
  2376. private final Socket iMAPSock;
  2377. String strRcvMSG;
  2378. WallPadiMAPUpgrade upgradeProc;
  2379. Document doc;
  2380. public iMapSverSocketThread(Socket sock) {
  2381. iMAPSock = sock;
  2382. }
  2383. public void run() {
  2384. try {
  2385. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2386. InputStream InStm = iMAPSock.getInputStream();
  2387. iMAPSock.setSoLinger(true, 3000);
  2388. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2389. strRcvMSG = "";
  2390. String InBuffer;
  2391. int i = 0;
  2392. boolean bRcvOK = false;
  2393. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2394. /////////////////////////////////////////////////////////////////////
  2395. // 신형단지서버 미사용중일 경우 기존 코드로,
  2396. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2397. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2398. /////////////////////////////////////////////////////////////////////
  2399. if (!mNewDanjiServer) {
  2400. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2401. try {
  2402. if (MsgReader.ready()) {
  2403. try {
  2404. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2405. InBuffer = "";
  2406. while (MsgReader.ready()) {
  2407. long charCnt = MsgReader.read(ReadData);
  2408. InBuffer += new String(ReadData, 0, (int)charCnt);
  2409. }
  2410. if (InBuffer != null) strRcvMSG += InBuffer;
  2411. if (0 < InBuffer.indexOf("</imap>")) {
  2412. bRcvOK = true;
  2413. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2414. break;
  2415. }
  2416. } catch (Exception e) {
  2417. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2418. e.printStackTrace();
  2419. return;
  2420. }
  2421. }
  2422. else {
  2423. Thread.sleep(100);
  2424. }
  2425. } catch (Exception e) {
  2426. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  2427. iMAPSock.close();
  2428. e.printStackTrace();
  2429. return;
  2430. }
  2431. }
  2432. }
  2433. else {
  2434. // SSL 암호화 데이터 수신부
  2435. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  2436. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2437. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2438. try {
  2439. InBuffer = "";
  2440. long charCnt = MsgReader.read(ReadData);
  2441. if (charCnt > 0) {
  2442. InBuffer += new String(ReadData, 0, (int)charCnt);
  2443. strRcvMSG += InBuffer;
  2444. if (-1 < InBuffer.indexOf("</imap>")) {
  2445. bRcvOK = true;
  2446. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  2447. break;
  2448. }
  2449. }
  2450. else {
  2451. Thread.sleep(100);
  2452. }
  2453. } catch (Exception e) {
  2454. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  2455. iMAPSock.close();
  2456. e.printStackTrace();
  2457. return;
  2458. }
  2459. }
  2460. }
  2461. if (!bRcvOK) {
  2462. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  2463. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  2464. Log.i(TAG, strRcvMSG);
  2465. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  2466. iMAPSock.close();
  2467. return;
  2468. }
  2469. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  2470. imapsvrlog( "Socket read end accept </imap>\n"+strRcvMSG);
  2471. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2472. DocumentBuilder builder = factory.newDocumentBuilder();
  2473. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  2474. doc = builder.parse(istream);
  2475. Element elelist = doc.getDocumentElement();
  2476. NodeList items = elelist.getElementsByTagName("service");
  2477. Node item = items.item(0);
  2478. NamedNodeMap attrs = item.getAttributes();
  2479. String retXML="";
  2480. for (int j=0; j< attrs.getLength(); j++) {
  2481. Node attr = attrs.item(j);
  2482. String cmd;
  2483. if (attr.getNodeName().equalsIgnoreCase("type")) {
  2484. cmd = attr.getNodeValue();
  2485. if (cmd.equalsIgnoreCase("notice")) {
  2486. iMAPSock.close();
  2487. }
  2488. }
  2489. else if (attr.getNodeName().equalsIgnoreCase("name")) {
  2490. cmd = attr.getNodeValue();
  2491. if (cmd.equalsIgnoreCase("event_notify")) {
  2492. retXML = ProcEventNotify(elelist);
  2493. }
  2494. else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  2495. ProcElevatorinfo(elelist);
  2496. retXML = null;
  2497. }
  2498. else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  2499. retXML = ProcCheckEpiceUpload(doc);
  2500. }
  2501. else if (cmd.equalsIgnoreCase("update_news")) {
  2502. retXML = ProcUpdateNews(doc);
  2503. }
  2504. else if (cmd.equalsIgnoreCase("update_weather")) {
  2505. retXML = ProcUpdateWeather(doc);
  2506. }
  2507. else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  2508. retXML = ProcSchduleInquiry(doc);
  2509. }
  2510. else if (cmd.equalsIgnoreCase("schedule_renew")) {
  2511. retXML = ProcSchduleRenew(doc);
  2512. }
  2513. else if (cmd.equalsIgnoreCase("schdule")) {
  2514. String SvcType="";
  2515. int k;
  2516. for (k = j + 1; k < attrs.getLength(); k++) {
  2517. Node attr1 = attrs.item(k);
  2518. SvcType = attr1.getNodeName();
  2519. if (SvcType.equalsIgnoreCase("shc_type")) {
  2520. SvcType = attr1.getNodeValue();
  2521. break;
  2522. }
  2523. }
  2524. retXML = ProcUpdateSchedule(elelist,SvcType);
  2525. }
  2526. else if (cmd.equalsIgnoreCase("device_reset")) {
  2527. retXML = ProcDeviceReset(elelist);
  2528. }
  2529. else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  2530. retXML = ProcNotifyparcel(doc);
  2531. }
  2532. else if (cmd.equalsIgnoreCase("notify_post_info")) {
  2533. // 스마트우편함 연동 여부
  2534. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  2535. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  2536. DevSet.closeDB();
  2537. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  2538. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  2539. }
  2540. else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2541. retXML = ProcNotifyBandLocation(elelist);
  2542. }
  2543. else if (cmd.equalsIgnoreCase("get_security_mode")) {
  2544. String Dong = null;
  2545. String Ho = null;
  2546. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  2547. String result;
  2548. String modeStr = null;
  2549. int status = statusDB.GetAlarmStatus();
  2550. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  2551. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  2552. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  2553. else if (status == WallpadStatusData.GUARD_OUT) modeStr = "unoccupied";
  2554. else if (status == WallpadStatusData.GUARD_OUT_WAIT) modeStr = "waitunoccupied";
  2555. result = "ok";
  2556. }
  2557. else {
  2558. modeStr = "null";
  2559. result = "fail";
  2560. }
  2561. try {
  2562. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  2563. Node GSM_item = GSM_items.item(0);
  2564. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  2565. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  2566. Node GSM_attr = GSM_attrsParam.item(k);
  2567. if (GSM_attr.getNodeName().equalsIgnoreCase("dong")) Dong = trimquotation(GSM_attr.getNodeValue());
  2568. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho")) Ho = trimquotation(GSM_attr.getNodeValue());
  2569. }
  2570. WallpadStatusData DBMGR = null;
  2571. DBMGR = new WallpadStatusData(getApplicationContext());
  2572. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  2573. DBMGR.closeDB();
  2574. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  2575. result = "fail";
  2576. }
  2577. } catch (Exception e) {
  2578. result = "fail";
  2579. }
  2580. retXML = XMLHeader +
  2581. " <service type=\"reply\" name=\"get_security_mode\" result=\""+result+"\">\r\n"+
  2582. " <home_info dong=\""+AddrDong+"\" ho=\""+AddrHo+"\" mode=\""+modeStr+"\"/>\r\n"+
  2583. " </service>\r\n"+
  2584. "</imap>\r\n";
  2585. statusDB.closeDB();
  2586. }
  2587. else if (cmd.equalsIgnoreCase("set_setup_info")) {
  2588. retXML = ProcSetsetup(doc);
  2589. }
  2590. else if (cmd.equalsIgnoreCase("get_setup_info")) {
  2591. retXML = ProcGetsetup(doc);
  2592. }
  2593. else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  2594. retXML = CheckPassword(doc);
  2595. }
  2596. else if (cmd.equalsIgnoreCase("device_live_check")) {
  2597. retXML = ProcDeviceLiveCheck();
  2598. }
  2599. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  2600. retXML = ProcPairingHdevSyncAlarm(elelist);
  2601. }
  2602. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  2603. retXML = ProcPairingHdevSyncSecurity(elelist);
  2604. }
  2605. else if (cmd.equalsIgnoreCase("notify_car_event")) {
  2606. retXML = ProcParkInformation(elelist);
  2607. }
  2608. else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2609. retXML = ProcSmartKeyEvent(elelist);
  2610. }
  2611. else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  2612. retXML = ProcParkInformation_cham_upis(elelist);
  2613. }
  2614. else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  2615. retXML = ProcauscultateReq(doc);
  2616. }
  2617. else if (cmd.equalsIgnoreCase("upgrade")) {
  2618. imapsvrlog( "Enter Upgrade");
  2619. procUpgrade();
  2620. retXML = null;
  2621. }
  2622. else if (cmd.equals("check_sip_activation")) {
  2623. String sip_result = "fail";
  2624. ActivityManager manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  2625. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  2626. // Jeff added below codes for call app (2018.01.25)
  2627. String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
  2628. for (int k = 0; k < rsi.size(); k++) {
  2629. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  2630. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  2631. sip_result = "ok";
  2632. break;
  2633. }
  2634. }
  2635. retXML = XMLHeader + "<service type=\"reply\" name=\"check_sip_activation\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  2636. }
  2637. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  2638. retXML = iCMDProcDevList(doc);
  2639. }
  2640. else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  2641. retXML = iCMDProcGASControl(elelist);
  2642. }
  2643. else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  2644. retXML = iCMDProcSDPSmartLightControl(doc);
  2645. }
  2646. else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  2647. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2648. retXML = iCMDProc_I_LightControl(doc);
  2649. }
  2650. else {
  2651. retXML = iCMDProcLivingLightControl(doc);
  2652. }
  2653. }
  2654. else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  2655. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I
  2656. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I) {
  2657. retXML = iCMDProcSDPConcentControl(doc);
  2658. }
  2659. else if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2660. retXML = iCMDProcEnergyMeterConcentControl(doc);
  2661. }
  2662. else {
  2663. retXML = iCMDProcMultiSWControl(doc);
  2664. }
  2665. }
  2666. else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  2667. retXML = iCMDProcDoorlockControl(doc);
  2668. }
  2669. else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  2670. retXML = iCMDProcTemperControl(doc);
  2671. }
  2672. else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  2673. retXML = iCMDProcModeControl(doc);
  2674. }
  2675. else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  2676. retXML = iCMDProcVentilControl(doc);
  2677. }
  2678. else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  2679. retXML = iCMDProcCurtainControl(doc);
  2680. }
  2681. else if (cmd.equalsIgnoreCase("remote_access_light")) {
  2682. if (ModelType == Version.MODEL_TYPE.IHN_1020GL) {
  2683. retXML = iCMDProcEnergyMeterLightControl(doc);
  2684. }
  2685. else {
  2686. retXML = iCMDProcLightControl(doc);
  2687. }
  2688. }
  2689. else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  2690. retXML = iCMDProcLightBatchControl(elelist);
  2691. }
  2692. //모바일 사용자 인증 관련 메시지
  2693. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  2694. ProcMobileDevice_AuthNumber(elelist);
  2695. }
  2696. else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  2697. retXML = ProcMobileDevice_ADD_Finish(elelist);
  2698. }
  2699. else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  2700. ProcMobileDevice_Delete(elelist);
  2701. }
  2702. else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  2703. retXML = ProcGetSmartKeyInfo(elelist);
  2704. }
  2705. else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  2706. retXML = ProcGetAppVersionInfo();
  2707. }
  2708. else if (cmd.equalsIgnoreCase("igate_init_info")) {
  2709. retXML = ProcIgateInitInfo(elelist);
  2710. }
  2711. else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  2712. retXML = ProcElecCarChargeEventInfo(elelist);
  2713. }
  2714. else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  2715. retXML = ProcEnergyTargetInfoAlarm(elelist);
  2716. }
  2717. else if (cmd.equalsIgnoreCase("check_call_option")) {
  2718. retXML = ProcCheckCallOption();
  2719. }
  2720. else if (cmd.equalsIgnoreCase("chat_sequence")) {
  2721. retXML = ProcChatSequence(elelist);
  2722. }
  2723. else if (cmd.equalsIgnoreCase("chat_message")) {
  2724. retXML = ProcChatMessage(elelist);
  2725. }
  2726. else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  2727. retXML = ProcEvacuationLadderOpen(elelist);
  2728. }
  2729. else if (cmd.equalsIgnoreCase("smart_light_info")) {
  2730. retXML = SmartLightDetailInfo(elelist);
  2731. }
  2732. else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  2733. retXML = KNXDeviceDetailInfo(elelist);
  2734. }
  2735. else if( cmd.equalsIgnoreCase("set_server_version")) {
  2736. retXML = ProcSetServerChange(elelist);
  2737. }
  2738. else if( cmd.equalsIgnoreCase("remote_access_onepass")) {
  2739. retXML = iCMDProcOnePass(elelist);
  2740. }
  2741. else if( cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  2742. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2743. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  2744. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  2745. }
  2746. }
  2747. break;
  2748. }
  2749. }
  2750. if (retXML != null) {
  2751. imapsvrlog( "Socket write line\n"+retXML+"\r\n SO :"+iMAPSock.getSoLinger());
  2752. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  2753. byte[] outBF = retXML.getBytes("euc-kr");
  2754. outstream.write(outBF);
  2755. outstream.flush();
  2756. try { Thread.sleep(3000);}catch (Exception e){e.printStackTrace(); };
  2757. iMAPSock.close();
  2758. }
  2759. else {
  2760. try {iMAPSock.close();}catch (Exception e){e.printStackTrace();}
  2761. }
  2762. } catch (Exception e) {
  2763. try {iMAPSock.close();}catch (Exception E){E.printStackTrace();}
  2764. e.printStackTrace();
  2765. }
  2766. }
  2767. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  2768. private void procUpgrade() {
  2769. imapsvrlog( "upgrade Start \n"+" "+WallPadiMAPUpgrade.active);
  2770. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  2771. String[] getstate = sdb.GetSystemUpdateStatus();
  2772. sdb.closeDB();
  2773. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  2774. for (int i = 0; i < getstate.length; i++) {
  2775. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  2776. }
  2777. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  2778. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  2779. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  2780. }
  2781. }
  2782. // " 제거
  2783. private String trimquotation(String sen) {
  2784. sen = sen.replaceAll("\"", "");
  2785. return sen.trim();
  2786. }
  2787. //remote_auscultate 처리
  2788. public String ProcauscultateReq(Document Doc) {
  2789. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  2790. NodeList items = Doc.getElementsByTagName("group");
  2791. Node item;
  2792. String itemname=null;
  2793. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  2794. SettManager.DeleteSettingData();
  2795. SettManager.DropTable();
  2796. try
  2797. {
  2798. for( int i = 0; i<items.getLength();i++)
  2799. {
  2800. item = items.item(i);
  2801. itemname = GetAttributeVal(item, "type");
  2802. String GetCNT = GetAttributeVal(item, "count");
  2803. if (Integer.parseInt(GetCNT)<=0)
  2804. continue;
  2805. Element SettingItem = (Element) item;
  2806. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  2807. for(int j=0;j<SettingList.getLength();j++)
  2808. {
  2809. Node subdevListitem = SettingList.item(j);
  2810. String devname = trimquotation(subdevListitem.getTextContent());
  2811. SettManager.InsertSettingData(itemname, devname, j);
  2812. }
  2813. }
  2814. }
  2815. catch (Exception e)
  2816. {
  2817. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  2818. e.printStackTrace();
  2819. SettManager.closeDB();
  2820. return RetVal;
  2821. }
  2822. SettManager.closeDB();
  2823. RetVal+="\"ok\" >\r\n </service>\r\n</imap>";
  2824. StatusBeatRequested = true;
  2825. Intent intent = new Intent();
  2826. intent.setAction(define.NOTIFY_ACNAME);
  2827. intent.putExtra(define.NOTIBR_KIND,define.NOTIFY_STARTSTATUSBEAT);
  2828. sendBroadcast(intent);
  2829. return RetVal;
  2830. }
  2831. public void DefaultProcauscultateReq(WallpadDevStatus SettManager)
  2832. {
  2833. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  2834. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n"+
  2835. "<service type=\"request\" name=\"remote_auscultate\">\r\n"+
  2836. " <guidemap devtype=\"homedev\" count=\"4\">\r\n"+
  2837. " <group type=\"ctrl_device\" count=\"5\">\r\n"+
  2838. " <unit>\"light\"</unit>\r\n"+
  2839. " <unit>\"thermostat\"</unit>\r\n"+
  2840. " <unit>\"gas\"</unit>\r\n"+
  2841. " <unit>\"doorlock\"</unit>\r\n"+
  2842. " <unit>\"ventil\"</unit>\r\n"+
  2843. " </group>\r\n"+
  2844. " <group type=\"talk_device\" count=\"4\">\r\n"+
  2845. " <unit>\"sub_homedev\"</unit>\r\n"+
  2846. " <unit>\"kitchen_tv\"</unit>\r\n"+
  2847. " <unit>\"bath_tv\"</unit>\r\n"+
  2848. " <unit>\"bath_phone\"</unit>\r\n"+
  2849. " </group>\r\n"+
  2850. " <group type=\"sensor\" count=\"6\">\r\n"+
  2851. " <unit>\"magnetic\"</unit>\r\n"+
  2852. " <unit>\"bugout\"</unit>\r\n"+
  2853. " <unit>\"bugin\"</unit>\r\n"+
  2854. " <unit>\"fire\"</unit>\r\n"+
  2855. " <unit>\"gas\"</unit>\r\n"+
  2856. " <unit>\"emergency\"</unit>\r\n"+
  2857. " </group>\r\n"+
  2858. " <group type=\"extended\" count=\"4\">\r\n"+
  2859. " <unit>\"gateway\"</unit>\r\n"+
  2860. " <unit>\"smartswitch\"</unit>\r\n"+
  2861. " <unit>\"handy\"</unit>\r\n"+
  2862. " <unit>\"energymeter\"</unit>\r\n"+
  2863. " </group>\r\n"+
  2864. " </guidemap>\r\n"+
  2865. "</service>\r\n"+
  2866. "</imap>\r\n";
  2867. try
  2868. {
  2869. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2870. DocumentBuilder builder = factory.newDocumentBuilder();
  2871. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  2872. Document doc = builder.parse(istream);
  2873. NodeList items = doc.getElementsByTagName("group");
  2874. Node item;
  2875. String itemname=null;
  2876. SettManager.DeleteSettingData();
  2877. SettManager.DropTable();
  2878. for( int i = 0; i<items.getLength();i++)
  2879. {
  2880. item = items.item(i);
  2881. itemname = GetAttributeVal(item, "type");
  2882. String GetCNT = GetAttributeVal(item, "count");
  2883. if (Integer.parseInt(GetCNT)<=0)
  2884. continue;
  2885. Element SettingItem = (Element) item;
  2886. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  2887. for(int j=0;j<SettingList.getLength();j++)
  2888. {
  2889. Node subdevListitem = SettingList.item(j);
  2890. String devname = trimquotation(subdevListitem.getTextContent());
  2891. SettManager.InsertSettingData(itemname, devname, j);
  2892. }
  2893. }
  2894. }
  2895. catch (Exception e)
  2896. {
  2897. e.printStackTrace();
  2898. }
  2899. }
  2900. String MakeFailMessage(String msg)
  2901. {
  2902. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\""+msg+"\"</first_failed>\r\n</service>\r\n</imap>";
  2903. }
  2904. //SetInfo의 각 항목들의 무결성 확인
  2905. final String isUse = "사용함";
  2906. final String isNotUse = "사용안함";
  2907. boolean CheckSubdevData(String devName, String devData) {
  2908. String[] SplitedMSG;
  2909. try {
  2910. if (devName.equals("가스밸브")) {
  2911. SplitedMSG = devData.split("[(]");
  2912. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2913. String UseStr = SplitedMSG[2].split("[)]")[0];
  2914. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  2915. }
  2916. else if (devName.equals("디지털도어락")) {
  2917. SplitedMSG = devData.split("[(]");
  2918. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2919. String[] UseStr = SplitedMSG[2].split("[)]");
  2920. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2921. if (!UseStr[1].equals("종류")) return false;
  2922. UseStr = SplitedMSG[3].split("[)]");
  2923. if (!UseStr[0].equals("무선")&&!UseStr[0].equals("유선")) return false;
  2924. }
  2925. else if (devName.equals("온도조절기")) {
  2926. SplitedMSG = devData.split("[(]");
  2927. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2928. String[] UseStr = SplitedMSG[2].split("[)]");
  2929. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2930. }
  2931. else if (devName.equals("조명제어기")) {
  2932. SplitedMSG = devData.split("[(]");
  2933. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2934. String[] UseStr = SplitedMSG[2].split("[)]");
  2935. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2936. /*
  2937. if (!UseStr[1].equals("종류"))
  2938. return false;
  2939. UseStr = SplitedMSG[3].split("[)]");
  2940. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  2941. return false;
  2942. */
  2943. }
  2944. else if (devName.equals("환기시스템")) {
  2945. SplitedMSG = devData.split("[(]");
  2946. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2947. String[] UseStr = SplitedMSG[2].split("[)]");
  2948. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2949. /*
  2950. if (!UseStr[1].equals("종류"))
  2951. return false;
  2952. UseStr = SplitedMSG[3].split("[)]");
  2953. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  2954. return false;
  2955. */
  2956. }
  2957. else if (devName.equals("시스템에어컨")) {
  2958. SplitedMSG = devData.split("[(]");
  2959. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2960. String[] UseStr = SplitedMSG[2].split("[)]");
  2961. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2962. }
  2963. else if (devName.equals("전동커튼")) {
  2964. SplitedMSG = devData.split("[(]");
  2965. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2966. String[] UseStr = SplitedMSG[2].split("[)]");
  2967. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2968. /*
  2969. if (!UseStr[1].equals("종류"))
  2970. return false;
  2971. UseStr = SplitedMSG[3].split("[)]");
  2972. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  2973. return false;
  2974. */
  2975. }
  2976. else if (devName.equals("실시간검침기")) {
  2977. SplitedMSG = devData.split("[(]");
  2978. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2979. String[] UseStr = SplitedMSG[2].split("[)]");
  2980. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2981. }
  2982. else if (devName.equals("스마트스위치&일괄소등")) {
  2983. SplitedMSG = devData.split("[(]");
  2984. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  2985. String[] UseStr = SplitedMSG[2].split("[)]");
  2986. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  2987. /*
  2988. if (!UseStr[1].equals("종류"))
  2989. return false;
  2990. UseStr = SplitedMSG[3].split("[)]");
  2991. if (!UseStr[0].equals("대외향스마트스위치")&&
  2992. !UseStr[0].equals("대외향일괄소등제어기")&&
  2993. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  2994. !UseStr[0].equals("현산향스마트스위치")&&
  2995. !UseStr[0].equals("현산향LCD스마트스위치"))
  2996. return false;
  2997. */
  2998. }
  2999. else if (devName.equals("무선리모컨")) {
  3000. SplitedMSG = devData.split("[(]");
  3001. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3002. String[] UseStr = SplitedMSG[2].split("[)]");
  3003. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3004. }
  3005. else if (devName.equals("현관카메라")) {
  3006. SplitedMSG = devData.split("[(]");
  3007. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3008. String[] UseStr = SplitedMSG[2].split("[)]");
  3009. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3010. /*
  3011. if (!UseStr[1].equals("종류"))
  3012. return false;
  3013. UseStr = SplitedMSG[3].split("[)]");
  3014. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  3015. return false;
  3016. */
  3017. }
  3018. else if (devName.equals("공지사항")) {
  3019. SplitedMSG = devData.split("[(]");
  3020. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3021. String[] UseStr = SplitedMSG[2].split("[)]");
  3022. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3023. }
  3024. else if (devName.equals("날씨")) {
  3025. SplitedMSG = devData.split("[(]");
  3026. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3027. String[] UseStr = SplitedMSG[2].split("[)]");
  3028. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3029. }
  3030. else if (devName.equals("메모")) {
  3031. SplitedMSG = devData.split("[(]");
  3032. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3033. String[] UseStr = SplitedMSG[2].split("[)]");
  3034. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3035. }
  3036. else if (devName.equals("전자액자")) {
  3037. SplitedMSG = devData.split("[(]");
  3038. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3039. String[] UseStr = SplitedMSG[2].split("[)]");
  3040. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3041. }
  3042. else if (devName.equals("일정표")) {
  3043. SplitedMSG = devData.split("[(]");
  3044. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3045. String[] UseStr = SplitedMSG[2].split("[)]");
  3046. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3047. }
  3048. else if (devName.equals("주차확인")) {
  3049. SplitedMSG = devData.split("[(]");
  3050. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3051. String[] UseStr = SplitedMSG[2].split("[)]");
  3052. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3053. /*
  3054. UseStr = SplitedMSG[3].split("[)]");
  3055. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3056. return false;
  3057. */
  3058. }
  3059. else if (devName.equals("시간설정")) {
  3060. SplitedMSG = devData.split("[(]");
  3061. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3062. String[] UseStr = SplitedMSG[2].split("[)]");
  3063. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3064. }
  3065. else if (devName.equals("원격검침")) {
  3066. SplitedMSG = devData.split("[(]");
  3067. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3068. String[] UseStr = SplitedMSG[2].split("[)]");
  3069. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3070. }
  3071. else if (devName.equals("뮤직")) {
  3072. SplitedMSG = devData.split("[(]");
  3073. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3074. String[] UseStr = SplitedMSG[2].split("[)]");
  3075. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3076. }
  3077. else if (devName.equals("영상재생")) {
  3078. SplitedMSG = devData.split("[(]");
  3079. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3080. String[] UseStr = SplitedMSG[2].split("[)]");
  3081. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3082. }
  3083. else if (devName.equals("CCTV")) {
  3084. SplitedMSG = devData.split("[(]");
  3085. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3086. String[] UseStr = SplitedMSG[2].split("[)]");
  3087. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3088. /*
  3089. UseStr = SplitedMSG[3].split("[)]");
  3090. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3091. return false;
  3092. */
  3093. }
  3094. else if (devName.equals("명칭설정")) {
  3095. SplitedMSG = devData.split("[(]");
  3096. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3097. String[] UseStr = SplitedMSG[2].split("[)]");
  3098. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3099. }
  3100. else if (devName.equals("출동경비")) {
  3101. SplitedMSG = devData.split("[(]");
  3102. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3103. String[] UseStr = SplitedMSG[2].split("[)]");
  3104. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3105. }
  3106. else if (devName.equals("경비실영상통화")) {
  3107. SplitedMSG = devData.split("[(]");
  3108. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3109. String[] UseStr = SplitedMSG[2].split("[)]");
  3110. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3111. }
  3112. else if (devName.equals("엘리베이터")) {
  3113. SplitedMSG = devData.split("[(]");
  3114. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3115. String[] UseStr = SplitedMSG[2].split("[)]");
  3116. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3117. /*
  3118. UseStr = SplitedMSG[3].split("[)]");
  3119. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3120. return false;
  3121. */
  3122. }
  3123. else if (devName.equals("현장특화기능")) {
  3124. SplitedMSG = devData.split("[(]");
  3125. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3126. String[] UseStr = SplitedMSG[2].split("[)]");
  3127. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3128. /*
  3129. UseStr = SplitedMSG[3].split("[)]");
  3130. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3131. return false;
  3132. */
  3133. }
  3134. else if (devName.equals("월패드카메라")) {
  3135. SplitedMSG = devData.split("[(]");
  3136. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3137. String[] UseStr = SplitedMSG[2].split("[)]");
  3138. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3139. }
  3140. else if (devName.equals("무드등")) {
  3141. SplitedMSG = devData.split("[(]");
  3142. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3143. String[] UseStr = SplitedMSG[2].split("[)]");
  3144. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3145. /*
  3146. UseStr = SplitedMSG[3].split("[)]");
  3147. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3148. return false;
  3149. */
  3150. }
  3151. else if (devName.equals("피난사다리")) {
  3152. SplitedMSG = devData.split("[(]");
  3153. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3154. String[] UseStr = SplitedMSG[2].split("[)]");
  3155. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3156. }
  3157. else if (devName.equals("동체설정")) {
  3158. return true;
  3159. /*
  3160. SplitedMSG = devData.split("[(]");
  3161. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3162. return false;
  3163. String[] UseStr = SplitedMSG[2].split("[)]");
  3164. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3165. return false;
  3166. if (UseStr[0].equals(isNotUse)) return true;
  3167. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3168. return false;
  3169. for (int i=3; i < SplitedMSG.length; i++)
  3170. {
  3171. UseStr = SplitedMSG[i].split("[)]");
  3172. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3173. return false;
  3174. if (i != SplitedMSG.length-1)
  3175. {
  3176. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3177. return false;
  3178. }
  3179. }
  3180. */
  3181. }
  3182. else if (devName.equals("알람발생")) {
  3183. SplitedMSG = devData.split("[(]");
  3184. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3185. String[] UseStr = SplitedMSG[2].split("[)]");
  3186. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3187. }
  3188. else {
  3189. Log.w("iMAP", "No Such Name, Set Setup devName ="+ devName + ", devData ="+devData);
  3190. Log.w("iMAP", "Return true");
  3191. return true;
  3192. }
  3193. }
  3194. catch (Exception e)
  3195. {
  3196. e.printStackTrace();
  3197. return false;
  3198. }
  3199. return true;
  3200. }
  3201. public String ProcSetsetup(Document ele) {
  3202. Common.DebugLog("ProcSetsetup------------------------->");
  3203. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3204. NodeList items = ele.getElementsByTagName("setting");
  3205. Node item;
  3206. String itemname=null;
  3207. String dateData=null;
  3208. String heartbeatP=null;
  3209. String Versions = null;
  3210. String SdbAccInit_Str = null;
  3211. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3212. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3213. if (!SettManager.StartTransaction()) {
  3214. ResetFlag = false;
  3215. RetVal+="\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3216. SettManager.EndTransaction(false);
  3217. SettManager.closeDB();
  3218. return RetVal;
  3219. }
  3220. try {
  3221. for (int i = 0; i < items.getLength(); i++) {
  3222. item = items.item(i);
  3223. itemname = GetAttributeVal(item, "name");
  3224. if (itemname.equals("beat_time")) {
  3225. heartbeatP = GetAttributeVal(item, "value");
  3226. }
  3227. else if (itemname.equals("ver_setting")) {
  3228. Versions = GetAttributeVal(item, "value");
  3229. }
  3230. else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3231. Element guardlist = (Element) item;
  3232. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3233. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3234. else continue;
  3235. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3236. Node GuardListitem = GuardCTList.item(j);
  3237. String guardname = GetAttributeVal(GuardListitem, "name");
  3238. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3239. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3240. }
  3241. }
  3242. else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3243. Element subdevList = (Element) item;
  3244. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3245. for (int j = 0; j < SubDevList.getLength(); j++) {
  3246. Node subdevListitem = SubDevList.item(j);
  3247. String devname = GetAttributeVal(subdevListitem, "name");
  3248. String devval = GetAttributeVal(subdevListitem, "value");
  3249. devname = devname.replaceAll("\\p{Z}", "");
  3250. devval = devval.replaceAll("\\p{Z}", "");
  3251. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  3252. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3253. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3254. }
  3255. if (CheckSubdevData(devname, devval)==false) {
  3256. ResetFlag = false;
  3257. Log.w("iMAP", "Set Setup Fail name : "+devname+ " Value : "+devval );
  3258. SettManager.EndTransaction(false);
  3259. SettManager.closeDB();
  3260. return MakeFailMessage(devname);
  3261. }
  3262. String[] SettingDBValue = SettManager.GetSettingData(devname);
  3263. if (SettingDBValue != null) {
  3264. String devInfo = SettingDBValue[1];
  3265. if (devInfo.equals(devval) == false) {
  3266. Log.w("iMAP", "Set Setup(imap) Name : "+devname+ " Value : "+devval );
  3267. Log.w("iMAP", "DB Setup Value : "+devInfo);
  3268. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3269. ResetFlag = true;
  3270. }
  3271. }
  3272. else {
  3273. Log.w("iMAP", "DB No Setup Name and Value");
  3274. Log.w("iMAP", "Set Setup(imap) Name : "+devname+ " Value : "+devval );
  3275. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3276. ResetFlag = true;
  3277. }
  3278. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3279. if (devname.equals("로고설정")) {
  3280. String devInfo = devval;
  3281. devInfo = devInfo.replace('(', '_');
  3282. devInfo = devInfo.replace(':', '_');
  3283. devInfo = devInfo.replace(')', '_');
  3284. String[] DetailInfo = devInfo.split("_");
  3285. int LogoType = 0;
  3286. if (DetailInfo[5].equals("표시안함") == true) {
  3287. LogoType = 0;
  3288. }
  3289. else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3290. LogoType = 1;
  3291. }
  3292. else if (DetailInfo[5].equals("양우내안애") == true) {
  3293. LogoType = 2;
  3294. }
  3295. else if (DetailInfo[5].equals("GSITM") == true) {
  3296. LogoType = 3;
  3297. }
  3298. else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3299. LogoType = 4;
  3300. }
  3301. else if (DetailInfo[5].equals("거실조명표시") == true) {
  3302. LogoType = 5;
  3303. }
  3304. else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3305. LogoType = 6;
  3306. }
  3307. else if (DetailInfo[5].equals("기타1") == true) {
  3308. LogoType = 7;
  3309. }
  3310. else if (DetailInfo[5].equals("기타2") == true) {
  3311. LogoType = 8;
  3312. }
  3313. if ((LogoType >= 0) && (LogoType <= 8)) {
  3314. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3315. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3316. }
  3317. }
  3318. else if (devname.equals("엘리베이터위젯복구")) {
  3319. String devInfo = devval;
  3320. devInfo = devInfo.replace('(', '_');
  3321. devInfo = devInfo.replace(':', '_');
  3322. devInfo = devInfo.replace(')', '_');
  3323. String[] DetailInfo = devInfo.split("_");
  3324. if (DetailInfo[3].equals("사용함") == true) {
  3325. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3326. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3327. }
  3328. }
  3329. else if (devname.equals("분전반알람설정")) {
  3330. try {
  3331. String devInfo = devval;
  3332. devInfo = devInfo.replace('(', '_');
  3333. devInfo = devInfo.replace(':', '_');
  3334. devInfo = devInfo.replace(')', '_');
  3335. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3336. //[0] - 기기번호
  3337. //[1] - 회로수
  3338. //[2] - 기기이름
  3339. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3340. //[4] - 명칭
  3341. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3342. String[] DetailInfo = devInfo.split("_");
  3343. for (int a = 0; a < DetailInfo.length; a++) {
  3344. if (DetailInfo[a].equals("누적전력초기화")) {
  3345. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3346. if ((a+1) <= DetailInfo.length) {
  3347. // 설정정보가 존재해야 인식하도록 함
  3348. if (DetailInfo[a+1].equals("1")) {
  3349. // 1(사용함) 일때
  3350. if (sdbAPI != null) {
  3351. if (sdbAPI.Set_AccPwReset() >= 0) {
  3352. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3353. }
  3354. else {
  3355. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3356. }
  3357. }
  3358. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3359. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3360. }
  3361. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3362. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3363. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3364. }
  3365. }
  3366. }
  3367. } catch (Exception e) {
  3368. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3369. e.printStackTrace();
  3370. }
  3371. }
  3372. else if (devname.equals("욕실폰통화음량값")) {
  3373. Intent Iintent = new Intent();
  3374. Iintent.setAction(define.NOTIFY_ACNAME);
  3375. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3376. sendBroadcast(Iintent);
  3377. }
  3378. else if (devname.equals("주방TV통화음량값")) {
  3379. Intent Iintent = new Intent();
  3380. Iintent.setAction(define.NOTIFY_ACNAME);
  3381. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3382. sendBroadcast(Iintent);
  3383. }
  3384. else if (devname.equals("현관카메라")) {
  3385. String devInfo = devval;
  3386. devInfo = devInfo.replace('(', '_');
  3387. devInfo = devInfo.replace(':', '_');
  3388. devInfo = devInfo.replace(')', '_');
  3389. String[] DetailInfo = devInfo.split("_");
  3390. if (devname.equalsIgnoreCase(DetailInfo[2])) {
  3391. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3392. else mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3393. }
  3394. }
  3395. else if (devname.equals("거동수상자녹화")) {
  3396. String devInfo = devval;
  3397. devInfo = devInfo.replace('(', '_');
  3398. devInfo = devInfo.replace(':', '_');
  3399. devInfo = devInfo.replace(')', '_');
  3400. String[] DetailInfo = devInfo.split("_");
  3401. // for (int k = 0; k < DetailInfo.length; k++) {
  3402. // Log.e(TAG, "[ProcSetsetup] DetailInfo[" + k + "] -> " + DetailInfo[k]);
  3403. // }
  3404. if (devname.equalsIgnoreCase(DetailInfo[2])) {
  3405. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3406. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  3407. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  3408. }
  3409. else {
  3410. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  3411. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  3412. }
  3413. }
  3414. }
  3415. else {
  3416. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3417. }
  3418. }
  3419. }
  3420. else if (itemname.equals("datetime")) {
  3421. dateData = GetAttributeVal(item, "value");
  3422. }
  3423. else {
  3424. String GetVal = GetAttributeVal(item, "value");
  3425. if (!GetVal.equals("list")) {
  3426. if (itemname.equals("site_code")) {
  3427. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3428. if (Existing_SiteCode_Array == null) {
  3429. ResetFlag = true;
  3430. }
  3431. else {
  3432. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3433. if (GetVal.equals(Existing_SiteCode) == false) {
  3434. ResetFlag = true;
  3435. }
  3436. }
  3437. }
  3438. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3439. }
  3440. else {
  3441. String GetCNT = GetAttributeVal(item, "count");
  3442. if (Integer.parseInt(GetCNT)<=0) continue;
  3443. Element SettingItem = (Element) item;
  3444. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3445. for (int j = 0; j < SettingList.getLength(); j++) {
  3446. Node subdevListitem = SettingList.item(j);
  3447. String devname = GetAttributeVal(subdevListitem, "name");
  3448. String devval = GetAttributeVal(subdevListitem, "value");
  3449. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3450. }
  3451. }
  3452. }
  3453. }
  3454. } catch (Exception e) {
  3455. ResetFlag = false;
  3456. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3457. e.printStackTrace();
  3458. SettManager.EndTransaction(false);
  3459. SettManager.closeDB();
  3460. return RetVal;
  3461. }
  3462. SettManager.EndTransaction(true);
  3463. SettManager.closeDB();
  3464. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3465. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3466. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3467. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3468. }
  3469. if (AfterTransactionTodoList != null) {
  3470. if (AfterTransactionTodoList.size() > 0) {
  3471. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3472. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3473. if (afterTransactionTodoListData != null) {
  3474. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3475. WallpadSalesSampleData mWallpadSalesSampleData;
  3476. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3477. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3478. mWallpadSalesSampleData.closeDB();
  3479. }
  3480. else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3481. //ifdb에 있는지
  3482. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3483. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3484. int result = devSet.Get_Elevator_Info();
  3485. devSet.closeDB();
  3486. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3487. // 엘리베이터가 사용함이면
  3488. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3489. boolean result_get_restoreUseOrNot;
  3490. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3491. if (wdb != null) {
  3492. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3493. if (result_get_restoreUseOrNot == false) {
  3494. wdb.SetElevator_Widget_Restore(true);
  3495. //위젯 DB 초기화
  3496. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3497. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3498. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3499. devSet2.initWidgetData();
  3500. devSet2.closeDB();
  3501. }
  3502. }
  3503. wdb.closeDB();
  3504. }
  3505. }
  3506. }
  3507. }
  3508. }
  3509. }
  3510. }
  3511. if (dateData!=null) {
  3512. try {
  3513. int year = Integer.parseInt(dateData.substring(0,4));
  3514. int month = Integer.parseInt(dateData.substring(4,6));
  3515. int day = Integer.parseInt(dateData.substring(6,8));
  3516. int hour = Integer.parseInt(dateData.substring(8,10));
  3517. int min = Integer.parseInt(dateData.substring(10,12));
  3518. int sec = Integer.parseInt(dateData.substring(12,14));
  3519. Calendar nowdate = new GregorianCalendar();
  3520. long settedtime = nowdate.getTimeInMillis();
  3521. nowdate.set(Calendar.YEAR, year);
  3522. nowdate.set(Calendar.MONTH, month);
  3523. nowdate.set(Calendar.DAY_OF_MONTH, day);
  3524. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  3525. nowdate.set(Calendar.MINUTE, min);
  3526. nowdate.set(Calendar.SECOND, sec);
  3527. long bootupmil = nowdate.getTimeInMillis();
  3528. if (Math.abs(bootupmil-settedtime) > 5000) {
  3529. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3530. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  3531. DBMGR.closeDB();
  3532. Intent Iintent = new Intent();
  3533. Iintent.setAction(define.NOTIFY_ACNAME);
  3534. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  3535. sendBroadcast(Iintent);
  3536. }
  3537. } catch(Exception e) {
  3538. e.printStackTrace();
  3539. }
  3540. }
  3541. if (heartbeatP != null) {
  3542. try {
  3543. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3544. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  3545. DBMGR.closeDB();
  3546. } catch(Exception e) {
  3547. e.printStackTrace();
  3548. RetVal +="\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3549. SettManager.closeDB();
  3550. return RetVal;
  3551. }
  3552. }
  3553. if (Versions != null) {
  3554. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3555. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  3556. DBMGR.SetSettingVer(Versions);
  3557. DBMGR.closeDB();
  3558. }
  3559. Intent intent = new Intent();
  3560. intent.setAction(define.NOTIFY_ACNAME);
  3561. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  3562. getApplicationContext().sendBroadcast(intent);
  3563. RetVal+="\"ok\" >\r\n </service>\r\n</imap>";
  3564. return RetVal;
  3565. }
  3566. public String ProcNotifyparcel(Document doc) {
  3567. NodeList param = doc.getElementsByTagName("move_info");
  3568. Node item = param.item(0);
  3569. String aa = item.getTextContent();
  3570. aa = trimquotation(aa);
  3571. param = doc.getElementsByTagName("params");
  3572. item = param.item(0);
  3573. if (item != null) {
  3574. String devname = GetAttributeVal(item, "message");
  3575. if (devname != null) {
  3576. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  3577. if (msgList[0].equalsIgnoreCase("remains")) {
  3578. int itemCount = Integer.parseInt(msgList[1]);
  3579. if (itemCount > 0) {
  3580. wakeupLCD();
  3581. Intent intent = new Intent();
  3582. intent.setAction(define.NOTIFY_ACNAME);
  3583. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  3584. intent.putExtra(define.NOTIBR_CONTENT, aa);
  3585. intent.putExtra("ITEM",itemCount);
  3586. getApplicationContext().sendBroadcast(intent);
  3587. }
  3588. }
  3589. }
  3590. }
  3591. String retVal = XMLHeader +
  3592. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n"+
  3593. "</imap>\r\n";
  3594. return retVal;
  3595. }
  3596. public String ProcNotiPostInfo(Document doc) {
  3597. NodeList param = doc.getElementsByTagName("move_info");
  3598. Node item = param.item(0);
  3599. String aa = item.getTextContent();
  3600. aa = trimquotation(aa);
  3601. if (item != null) {
  3602. String info = item.getTextContent();
  3603. if (info != null) {
  3604. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  3605. if (info.contains("post_in")) { // 우편물 보관
  3606. wakeupLCD();
  3607. int itemCount = -1;
  3608. param = doc.getElementsByTagName("params");
  3609. item = param.item(0);
  3610. if (item != null) {
  3611. String devname = GetAttributeVal(item, "message");
  3612. if (devname != null) {
  3613. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  3614. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  3615. if (msgList[0].equalsIgnoreCase("remains")) {
  3616. itemCount = Integer.parseInt(msgList[1]);
  3617. }
  3618. }
  3619. }
  3620. }
  3621. if (itemCount > 0) {
  3622. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  3623. Intent intent = new Intent();
  3624. intent.setAction(define.NOTIFY_ACNAME);
  3625. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  3626. intent.putExtra(define.NOTIBR_CONTENT, aa);
  3627. intent.putExtra("ITEM", itemCount);
  3628. getApplicationContext().sendBroadcast(intent);
  3629. } else {
  3630. // TODO 우편물 수량을 파악할 수 없는 경우에는 어떻게 구현하지????
  3631. }
  3632. }
  3633. }
  3634. }
  3635. String retVal = XMLHeader +
  3636. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n"+
  3637. "</imap>\r\n";
  3638. return retVal;
  3639. }
  3640. public String ProcNotifyBandLocation(Element ele) {
  3641. Log.d(TAG, "[ProcNotifyBandLocation] ========== START ==========");
  3642. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  3643. String strName = null, strDong = null, strHo = null, strCnt = null;
  3644. String strEventType = null, strEventTriggerType = null, strCardNum = null;
  3645. NodeList items = ele.getElementsByTagName("destination");
  3646. Node item = items.item(0);
  3647. NamedNodeMap attrsParam = item.getAttributes();
  3648. for (int j = 0; j < attrsParam.getLength(); j++) {
  3649. Node attr = attrsParam.item(j);
  3650. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  3651. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  3652. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  3653. }
  3654. items = ele.getElementsByTagName("event_info");
  3655. item = items.item(0);
  3656. attrsParam = item.getAttributes();
  3657. for (int j = 0; j < attrsParam.getLength(); j++) {
  3658. Node attr = attrsParam.item(j);
  3659. if (attr.getNodeName().equalsIgnoreCase("info_cnt")) strCnt = trimquotation(attr.getNodeValue());
  3660. }
  3661. items = ele.getElementsByTagName("event");
  3662. item = items.item(0);
  3663. attrsParam = item.getAttributes();
  3664. for (int j = 0; j < attrsParam.getLength(); j++) {
  3665. Node attr = attrsParam.item(j);
  3666. if (attr.getNodeName().equalsIgnoreCase("event_type")) strEventType = trimquotation(attr.getNodeValue());
  3667. else if (attr.getNodeName().equalsIgnoreCase("trigger_type")) strEventTriggerType = trimquotation(attr.getNodeValue());
  3668. else if (attr.getNodeName().equalsIgnoreCase("card_num")) strCardNum = trimquotation(attr.getNodeValue());
  3669. }
  3670. Log.i(TAG, "[ProcNotifyBandLocation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  3671. Log.i(TAG, "[ProcNotifyBandLocation] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strCardNum [" + strCardNum + "]");
  3672. if ((strName.equalsIgnoreCase("homedev")) && (strDong.equalsIgnoreCase(AddrDong)) && (strHo.equalsIgnoreCase(AddrHo))) {
  3673. Log.d(TAG, "[ProcNotifyBandLocation] Input EMData is Correct");
  3674. } else {
  3675. Log.d(TAG, "[ProcNotifyBandLocation] Input EMData is Wrong");
  3676. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  3677. return retXML;
  3678. }
  3679. // 데이터가 null인지 확인
  3680. if ((strEventType == null) || (strEventTriggerType == null) || (strCardNum == null)) {
  3681. return retXML;
  3682. }
  3683. int nCardNum = Integer.parseInt(strCardNum);
  3684. if (strEventType.equalsIgnoreCase("position") && (strEventTriggerType.equalsIgnoreCase("ble") || strEventTriggerType.equalsIgnoreCase("zigbee"))) {
  3685. Intent iIntent = new Intent();
  3686. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  3687. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  3688. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  3689. getApplicationContext().sendBroadcast(iIntent);
  3690. }
  3691. return retXML;
  3692. }
  3693. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  3694. public String ProcNotifypark(Document doc)
  3695. {
  3696. String MoveInfo = "none";
  3697. NodeList param = doc.getElementsByTagName("destination");
  3698. Node item = param.item(0);
  3699. if (item != null)
  3700. {
  3701. String dong = GetAttributeVal(item, "id_high").trim();
  3702. String ho = GetAttributeVal(item, "id_low").trim();
  3703. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  3704. return (XMLHeader +
  3705. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  3706. "</imap>\r\n");
  3707. }
  3708. param = doc.getElementsByTagName("move_info");
  3709. item = param.item(0);
  3710. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  3711. param = doc.getElementsByTagName("params");
  3712. item = param.item(0);
  3713. if (item != null)
  3714. {
  3715. String carnum = GetAttributeVal(item, "car_num");
  3716. String locinfo = GetAttributeVal(item, "loc_info");
  3717. String msg = GetAttributeVal(item, "message");
  3718. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  3719. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  3720. parkdb.closeDB();Intent intent = new Intent();
  3721. intent.setAction(define.NOTIFY_ACNAME);
  3722. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  3723. getApplicationContext().sendBroadcast(intent);
  3724. }
  3725. String retVal = XMLHeader +
  3726. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  3727. "</imap>\r\n";
  3728. return retVal;
  3729. }
  3730. */
  3731. public String ProcGetsetup(Document doc) {
  3732. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3733. NodeList items = doc.getElementsByTagName("variable");
  3734. String RetVal = XMLHeader+"<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n"+
  3735. " <guidemap devtype=\"homedev\" count=\""+items.getLength()+"\">\r\n";
  3736. Node item;
  3737. try {
  3738. for (int i = 0; i < items.getLength(); i++) {
  3739. item = items.item(i);
  3740. //String mRealTimeMeterData = item.getNodeValue();
  3741. String data = trimquotation(item.getTextContent());
  3742. List<String[]> gData = SettManager.GetSettingGroupData(data);
  3743. if (gData.size() == 1) {
  3744. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+gData.get(0)[1]+"\" />\r\n";
  3745. }
  3746. else if (gData.size() > 1) {
  3747. RetVal+=" <setting name=\""+data+"\" count=\""+gData.size()+"\" value=\"list\" >\r\n";
  3748. for (int k = 0 ; k <gData.size();k++) {
  3749. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  3750. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  3751. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  3752. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  3753. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  3754. }
  3755. RetVal+=" <list name=\""+gData.get(k)[0]+"\" value=\""+gData.get(k)[1]+"\" />\r\n";
  3756. }
  3757. RetVal+=" </setting>\r\n";
  3758. }
  3759. else
  3760. {
  3761. if (data.equals("beat_time"))
  3762. {
  3763. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3764. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  3765. DBMGR.closeDB();
  3766. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+heartbeatP+"\" />\r\n";
  3767. }
  3768. else if (data.equals("ver_setting"))
  3769. {
  3770. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3771. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+DBMGR.GetSettingVer()+"\" />\r\n";
  3772. DBMGR.closeDB();
  3773. }
  3774. else if (data.equals("datetime"))
  3775. {
  3776. Calendar cal = new GregorianCalendar();
  3777. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+String.format("%04d%02d%02d%02d%02d%02d",cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY),cal.get(Calendar.MINUTE),cal.get(Calendar.SECOND))+"\" />\r\n";
  3778. }
  3779. else if (data.equals("security_state"))
  3780. {
  3781. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3782. int alarmST = DBMGR.GetAlarmStatus();
  3783. String SEC_ST;
  3784. if (alarmST == WallpadStatusData.GUARD_OUT ) SEC_ST = "out";
  3785. else if (alarmST == WallpadStatusData.GUARD_IN ) SEC_ST = "in";
  3786. else SEC_ST = "normal";
  3787. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+SEC_ST+"\" />\r\n";
  3788. DBMGR.closeDB();
  3789. }
  3790. else if (data.equals("sensor_state"))
  3791. {
  3792. int senIDX = 0;
  3793. String resultStr = "";
  3794. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  3795. int BugSensor = DBMGR.Get_Sensor_Set();
  3796. WallPadInterface wpifc = new WallPadInterface();
  3797. if (BugSensor > 0)
  3798. {
  3799. if ((BugSensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  3800. {
  3801. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  3802. String Senret;
  3803. if (outSen>0) Senret = "detect";
  3804. else Senret = "undetect";
  3805. resultStr+=" <list name=\"in_move\" count=\"0\" value=\""+Senret+"\" />\r\n";
  3806. senIDX++;
  3807. }
  3808. else
  3809. {
  3810. if ((BugSensor&WallpadDeviceSet.SET_IN_MOTION) > 0)
  3811. {
  3812. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  3813. String Senret;
  3814. if (outSen>0) Senret = "detect";
  3815. else Senret = "undetect";
  3816. resultStr+=" <list name=\"in_move\" value=\""+Senret+"\" />\r\n";
  3817. senIDX++;
  3818. }
  3819. if ((BugSensor&WallpadDeviceSet.SET_OUT_MOTION) > 0)
  3820. {
  3821. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  3822. String Senret;
  3823. if (outSen>0) Senret = "detect";
  3824. else Senret = "undetect";
  3825. resultStr+=" <list name=\"out_move\" value=\""+Senret+"\" />\r\n";
  3826. senIDX++;
  3827. }
  3828. }
  3829. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  3830. String Senret;
  3831. if (outSen>0) Senret = "detect";
  3832. else Senret = "undetect";
  3833. resultStr+=" <list name=\"magnetic\" value=\""+Senret+"\" />\r\n";
  3834. senIDX++;
  3835. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  3836. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  3837. {
  3838. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  3839. if (outSen>0) Senret = "detect";
  3840. else Senret = "undetect";
  3841. resultStr+=" <list name=\"emergency\" value=\""+Senret+"\" />\r\n";
  3842. senIDX++;
  3843. }
  3844. DBMGR.closeDB();
  3845. }
  3846. if (senIDX > 0)
  3847. {
  3848. RetVal += " <setting name = \"sensor_state\" count = \""+senIDX+"\" value = \"list\" >\r\n";
  3849. RetVal += resultStr;
  3850. RetVal += " </setting>\r\n";
  3851. }
  3852. }
  3853. else if (data.equals("statusbeat_time"))
  3854. {
  3855. }
  3856. else
  3857. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\"\" />\r\n";
  3858. }
  3859. }
  3860. }
  3861. catch (Exception e)
  3862. {
  3863. e.printStackTrace();
  3864. }
  3865. SettManager.closeDB();
  3866. RetVal+=" </guidemap>\r\n </service>\r\n</imap>";
  3867. return RetVal;
  3868. }
  3869. public void ProcElevatorinfo(Element ele) {
  3870. try {
  3871. String floor;
  3872. String move_dir;
  3873. /*
  3874. NodeList evinfo = ele.getElementsByTagName("ev_count");
  3875. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  3876. Node info = evinfo.item(0);
  3877. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  3878. if (info != null)
  3879. {
  3880. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  3881. }
  3882. */
  3883. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  3884. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength() );
  3885. Node iinfo = ievinfo.item(0);
  3886. if (iinfo == null) {
  3887. Log.d("iMapServer" , "func ProcElevatorinfo info == null");
  3888. return;
  3889. }
  3890. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  3891. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  3892. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  3893. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  3894. if (move_dir.equalsIgnoreCase("up")) {
  3895. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  3896. }
  3897. else if (move_dir.equalsIgnoreCase("down")) {
  3898. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  3899. }
  3900. else if (move_dir.equalsIgnoreCase("stop")) {
  3901. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  3902. }
  3903. else if (move_dir.equalsIgnoreCase("wrong")) {
  3904. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  3905. }
  3906. else if (move_dir.equalsIgnoreCase("finish")) {
  3907. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  3908. }
  3909. Log.d("iMapServer" , "MoveDirForIntent: "+MoveDirForIntent);
  3910. byte updown = 0x00;
  3911. if (ievinfo != null) {
  3912. boolean downCall = false;
  3913. boolean upCall = false;
  3914. for (int i = 0; i < ievinfo.getLength(); i++ ) {
  3915. Node valItem = ievinfo.item(i);
  3916. if (valItem != null) {
  3917. if (downCall == false) downCall = GetAttributeVal(valItem, "ev_call_dir").equalsIgnoreCase("down");
  3918. if (upCall == false) upCall = GetAttributeVal(valItem, "ev_call_dir").equalsIgnoreCase("up");
  3919. }
  3920. }
  3921. Log.d("iMapServer" , "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall );
  3922. if (downCall == true && upCall == true) updown = 0x02;
  3923. else if (downCall == false && upCall == true) updown = 0x01;
  3924. }
  3925. Log.d(TAG , "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  3926. Intent intent = new Intent();
  3927. intent.setAction(define.NOTIFY_ACNAME);
  3928. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  3929. intent.putExtra(define.NOTIBR_FLOOR, floor);
  3930. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  3931. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  3932. getApplicationContext().sendBroadcast(intent);
  3933. } catch (Exception e) {
  3934. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  3935. e.printStackTrace();
  3936. }
  3937. }
  3938. private String MakeTargetStr(WallpadiCMDParser data) {
  3939. return " <target name=\""+data.target+"\" id = \""+data.tid+"\" msg_no=\""+data.msgno+"\"/>\r\n";
  3940. }
  3941. public String iCMDProcVentilControl(Document doc) {
  3942. try {
  3943. String unit_status = "null", mode = "null", unit_mode = "null";
  3944. String retStr = CheckiCMDProc("remote_access_ventil");
  3945. if (retStr != null) return retStr;
  3946. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  3947. String target= "null", tid= "null", msgno= "null";
  3948. NodeList items = doc.getElementsByTagName("target");
  3949. Node item = items.item(0);
  3950. if (item != null) {
  3951. NamedNodeMap attrs = item.getAttributes();
  3952. for (int j = 0; j< attrs.getLength(); j++) {
  3953. Node attr = attrs.item(j);
  3954. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  3955. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  3956. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  3957. }
  3958. }
  3959. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  3960. if (NewServerUse()) {
  3961. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  3962. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  3963. }
  3964. boolean procSucc = true;
  3965. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  3966. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  3967. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  3968. if (VentilCTR.Refresh(false) == 0) {
  3969. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  3970. boolean OnOff = false;
  3971. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  3972. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  3973. else procSucc = false;
  3974. }
  3975. else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  3976. byte strength = 0;
  3977. if (ventilParser.ctraction.equalsIgnoreCase("low")) strength = VentiAPI.WIND.LOW;
  3978. else if (ventilParser.ctraction.equalsIgnoreCase("mid")) strength = VentiAPI.WIND.MID;
  3979. else strength = VentiAPI.WIND.HI;
  3980. if (VentilCTR.data.OnOff) {
  3981. // 환기가 On인 경우
  3982. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  3983. else procSucc = false;
  3984. }
  3985. else {
  3986. // 환기가 Off인 경우
  3987. if (VentilCTR.SetOnOff(true) >= 0) {
  3988. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  3989. else procSucc = false;
  3990. }
  3991. else {
  3992. procSucc = false;
  3993. }
  3994. }
  3995. }
  3996. if (VentilCTR.Refresh(true) == 0) {
  3997. if (VentilCTR.data.OnOff == false) unit_status = "off";
  3998. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  3999. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4000. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4001. else unit_status = "unknown";
  4002. if (VentilCTR.data.Support.AutoDriving) {
  4003. mode = "normal/auto";
  4004. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4005. else unit_mode = "normal";
  4006. }
  4007. else {
  4008. mode = "normal";
  4009. unit_mode = "normal";
  4010. }
  4011. }
  4012. else {
  4013. procSucc = false;
  4014. }
  4015. }
  4016. else {
  4017. procSucc = false;
  4018. }
  4019. }
  4020. else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4021. if (VentilCTR.Refresh(false) == 0) {
  4022. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4023. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4024. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4025. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4026. else unit_status = "unknown";
  4027. if (VentilCTR.data.Support.AutoDriving) {
  4028. mode = "normal/auto";
  4029. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4030. else unit_mode = "normal";
  4031. }
  4032. else {
  4033. mode = "normal";
  4034. unit_mode = "normal";
  4035. }
  4036. }
  4037. else {
  4038. procSucc = false;
  4039. }
  4040. }
  4041. else {
  4042. procSucc = false;
  4043. }
  4044. if (procSucc == false) {
  4045. retStr+=(" result=\"fail\" >\r\n");
  4046. unit_status = "unknown";
  4047. }
  4048. else {
  4049. retStr+=(" result=\"ok\" >\r\n");
  4050. }
  4051. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4052. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4053. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4054. retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4055. return retStr;
  4056. } catch (Exception e) {
  4057. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4058. e.printStackTrace();
  4059. return null;
  4060. }
  4061. }
  4062. public String iCMDProcTemperControl(Document doc) {
  4063. try {
  4064. String retStr = CheckiCMDProc("remote_access_temper");
  4065. if (retStr != null) return retStr;
  4066. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4067. String target= "null", tid= "null", msgno= "null";
  4068. NodeList items = doc.getElementsByTagName("target");
  4069. Node item = items.item(0);
  4070. if (item != null) {
  4071. NamedNodeMap attrs = item.getAttributes();
  4072. for (int j = 0; j< attrs.getLength(); j++) {
  4073. Node attr = attrs.item(j);
  4074. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4075. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4076. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4077. }
  4078. }
  4079. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4080. if (NewServerUse()) {
  4081. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4082. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4083. }
  4084. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4085. String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4086. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4087. // 난방 종류를 얻어온다.
  4088. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4089. HeatingV1API heatingV1API = null;
  4090. HeatingV2API heatingV2API = null;
  4091. // 종류별 API를 로딩한다.
  4092. if(HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4093. else if(HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4094. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4095. if (tempercmd.actionTXT.equals("control")) {
  4096. String[] CtrList;
  4097. byte ctrl = 0;
  4098. byte roomNum = (byte)0xFF;
  4099. double temp = 0;
  4100. if (tempercmd.unitnum.equals("all")) {
  4101. if (tempercmd.ctraction.equals("on")) {
  4102. ctrl = 1;
  4103. }
  4104. else if (tempercmd.ctraction.equals("off")) {
  4105. ctrl = 0;
  4106. }
  4107. else {
  4108. retStr+="\"fail\">\r\n <target name=\""+tempercmd.target+"\" id=\""+tempercmd.tid+"\" msg_no=\""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap> ";
  4109. return retStr;
  4110. }
  4111. }
  4112. else {
  4113. CtrList = tempercmd.ctraction.split("/");
  4114. if (CtrList[0].equals("on")) ctrl = 1;
  4115. else ctrl = 0;
  4116. roomNum = (byte)0xFF;
  4117. temp = Double.parseDouble(CtrList[1]);
  4118. }
  4119. if (HeatingKind == 1) {
  4120. boolean OnOff = false;
  4121. if (ctrl == 1) OnOff = true;
  4122. if (tempercmd.unitnum.equals("all")) {
  4123. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4124. if (ret != APIErrorCode.C_SUCCESS) {
  4125. retStr+="\"fail\">\r\n <target name=\""+tempercmd.target+"\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4126. return retStr;
  4127. }
  4128. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4129. }
  4130. else {
  4131. for (byte i = 0; i < RoomList.length; i++) {
  4132. if (tempercmd.unitnum.equals(RoomList[i])) {
  4133. roomNum = i;
  4134. break;
  4135. }
  4136. }
  4137. if (roomNum == (byte) 0xFF) {
  4138. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\""+tempercmd.msgno+"\"/>\r\n </service>\r\n</imap>";
  4139. return retStr;
  4140. }
  4141. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff)?(byte)1:(byte)2, temp);
  4142. if (ret != APIErrorCode.C_SUCCESS) {
  4143. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4144. return retStr;
  4145. }
  4146. heatingV1API.Refresh(roomNum, false);
  4147. }
  4148. }
  4149. else if (HeatingKind == 2) {
  4150. byte Mode = HeatingV2.MODE.HeatingOFF;
  4151. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4152. if (tempercmd.unitnum.equals("all")) {
  4153. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4154. if (ret != APIErrorCode.C_SUCCESS) {
  4155. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4156. return retStr;
  4157. }
  4158. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4159. }
  4160. else {
  4161. for (byte i = 0; i < RoomList.length; i++) {
  4162. if (tempercmd.unitnum.equals(RoomList[i])) {
  4163. roomNum = i;
  4164. break;
  4165. }
  4166. }
  4167. if (roomNum == (byte) 0xFF) {
  4168. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4169. return retStr;
  4170. }
  4171. int ret = heatingV2API.SetEachRoomStatus(roomNum, Mode, temp);
  4172. if (ret != APIErrorCode.C_SUCCESS) {
  4173. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4174. return retStr;
  4175. }
  4176. heatingV2API.Refresh(roomNum, false);
  4177. }
  4178. }
  4179. else {
  4180. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4181. return retStr;
  4182. }
  4183. }
  4184. String resultStr=" <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4185. if (HeatingKind == 1) {
  4186. try {
  4187. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4188. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4189. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount +"\"/>\r\n";
  4190. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4191. String drvmode = "off";
  4192. for (byte i = 0; i < RoomCount ; i++) {
  4193. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4194. if (roomData.bOnOff) drvmode = "on";
  4195. else drvmode = "off";
  4196. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4197. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4198. }
  4199. resultStr += " </service>\r\n</imap>\r\n";
  4200. retStr+=("\"ok\">\r\n"+resultStr);
  4201. return retStr;
  4202. }
  4203. else {
  4204. String drvmode = "off";
  4205. byte roomNum = (byte) 0xFF;
  4206. for (byte i = 0; i < RoomList.length; i++) {
  4207. if (tempercmd.unitnum.equals(RoomList[i])) {
  4208. roomNum = i;
  4209. break;
  4210. }
  4211. }
  4212. if (roomNum == (byte) 0xFF) {
  4213. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4214. return retStr;
  4215. }
  4216. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4217. if (roomData.bOnOff) drvmode = "on";
  4218. else drvmode = "off";
  4219. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4220. resultStr += " <status_info unit_num=\""+RoomList[roomNum]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4221. resultStr += " </service>\r\n</imap>\r\n";
  4222. retStr+=("\"ok\">\r\n"+resultStr);
  4223. return retStr;
  4224. }
  4225. } catch (Exception e) {
  4226. e.printStackTrace();
  4227. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4228. return retStr;
  4229. }
  4230. }
  4231. else if (HeatingKind == 2) {
  4232. try {
  4233. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4234. resultStr += " <action> \""+tempercmd.actionTXT+"\"</action>\r\n";
  4235. resultStr += " <status_map dev_num=\"1\" unit_cnt = \""+RoomCount+"\" />\r\n";
  4236. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4237. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount );
  4238. String drvmode = "off";
  4239. for (byte i = 0; i < RoomCount; i++) {
  4240. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4241. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4242. else drvmode = "off";
  4243. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4244. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4245. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\" room_name=\"" + mDefaultRoomNameList_Heating[i] + "\"/>\r\n";
  4246. }
  4247. else {
  4248. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4249. }
  4250. }
  4251. resultStr += " </service>\r\n</imap>\r\n";
  4252. retStr+=("\"ok\">\r\n"+resultStr);
  4253. return retStr;
  4254. }
  4255. else {
  4256. String drvmode = "off";
  4257. byte roomNum = (byte) 0xFF;
  4258. for (byte i = 0; i < RoomList.length; i++) {
  4259. if (tempercmd.unitnum.equals(RoomList[i])) {
  4260. roomNum = i;
  4261. break;
  4262. }
  4263. }
  4264. if (roomNum == (byte) 0xFF) {
  4265. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4266. return retStr;
  4267. }
  4268. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[roomNum];
  4269. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4270. else drvmode = "off";
  4271. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4272. resultStr += " <status_info unit_num=\""+RoomList[roomNum]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4273. resultStr += " </service>\r\n</imap>\r\n";
  4274. retStr+=("\"ok\">\r\n"+resultStr);
  4275. return retStr;
  4276. }
  4277. } catch (Exception e) {
  4278. e.printStackTrace();
  4279. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4280. return retStr;
  4281. }
  4282. }
  4283. else {
  4284. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^" );
  4285. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4286. return retStr;
  4287. }
  4288. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4289. // return retStr;
  4290. } catch (Exception e) {
  4291. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4292. e.printStackTrace();
  4293. return null;
  4294. }
  4295. }
  4296. public String iCMDProcDoorlockControl(Document doc) {
  4297. try {
  4298. String DLStatus = "none";
  4299. String strResult = CheckiCMDProc("remote_access_doorlock");
  4300. if (strResult != null) return strResult;
  4301. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4302. String target= "null", tid= "null", msgno= "null";
  4303. NodeList items = doc.getElementsByTagName("target");
  4304. Node item = items.item(0);
  4305. if (item != null) {
  4306. NamedNodeMap attrs = item.getAttributes();
  4307. for (int j = 0; j< attrs.getLength(); j++) {
  4308. Node attr = attrs.item(j);
  4309. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4310. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4311. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4312. }
  4313. }
  4314. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4315. if (NewServerUse()) {
  4316. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4317. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4318. }
  4319. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4320. try {
  4321. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4322. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4323. DLStatus = "unknown";
  4324. }
  4325. else {
  4326. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce) DLStatus = "close";
  4327. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open|| doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce) DLStatus = "open";
  4328. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation) DLStatus = "ing";
  4329. else DLStatus="unknown";
  4330. }
  4331. } catch (Exception e) {
  4332. e.printStackTrace();
  4333. DLStatus="unknown";
  4334. }
  4335. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n"+
  4336. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n"+
  4337. " <action>\"status\"</action>\r\n"+
  4338. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n"+
  4339. " <status_info unit_num=\"doorlock1\" unit_status=\""+DLStatus+"\"/>\r\n </service>\r\n</imap>";
  4340. return retXML;
  4341. } catch (Exception e) {
  4342. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4343. e.printStackTrace();
  4344. return null;
  4345. }
  4346. }
  4347. /*
  4348. protected String iCMDProcsavelog(Document doc)
  4349. {
  4350. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4351. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4352. NodeList items = doc.getElementsByTagName("guidemap");
  4353. Node item = items.item(0);
  4354. NamedNodeMap attrsParam = item.getAttributes();
  4355. for(int j=0; j< attrsParam.getLength();j++)
  4356. {
  4357. Node attr = attrsParam.item(j);
  4358. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4359. {
  4360. String enable = attr.getNodeValue();
  4361. if (enable == null) return FailretStr;
  4362. if (enable.equals("false"))
  4363. {
  4364. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4365. logSet.SetLogDoing(0);
  4366. logSet.closeDB();
  4367. return SucretStr;
  4368. }
  4369. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4370. logSet.SetLogDoing(1);
  4371. logSet.closeDB();
  4372. }
  4373. }
  4374. items = doc.getElementsByTagName("setting");
  4375. item = items.item(0);
  4376. attrsParam = item.getAttributes();
  4377. String SaveType = "";
  4378. String FtpLoc = "";
  4379. String Ftpuser = "";
  4380. String FtpPW= "";
  4381. String period = "";
  4382. String FileSize = "";
  4383. for(int j=0; j< attrsParam.getLength();j++)
  4384. {
  4385. Node attr = attrsParam.item(j);
  4386. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4387. SaveType = attr.getNodeValue();
  4388. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4389. FtpLoc = attr.getNodeValue();
  4390. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4391. Ftpuser = attr.getNodeValue();
  4392. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4393. FtpPW = attr.getNodeValue();
  4394. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4395. period = attr.getNodeValue();
  4396. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4397. FileSize = attr.getNodeValue();
  4398. }
  4399. if (SaveType.equalsIgnoreCase("now"))
  4400. {
  4401. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4402. LogUpThread.start();
  4403. return SucretStr;
  4404. }
  4405. else if (SaveType.equalsIgnoreCase("periodic"))
  4406. {
  4407. try
  4408. {
  4409. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4410. period = period.trim();
  4411. String[] logperiod = period.split("[-]");
  4412. String StartDate = logperiod[0].replace(".", "_");
  4413. String EndDate = logperiod[1].replace(".", "_");
  4414. logSet.SetLogDoing(1);
  4415. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4416. if (FileSize.equalsIgnoreCase("null"))
  4417. logSet.SetLogLogFileSize(0);
  4418. else
  4419. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4420. logSet.SetLogStartDate(StartDate);
  4421. logSet.SetLogEndDate(EndDate);
  4422. logSet.closeDB();
  4423. return SucretStr;
  4424. }
  4425. catch (Exception e)
  4426. {
  4427. e.printStackTrace();
  4428. return FailretStr;
  4429. }
  4430. }
  4431. else
  4432. {
  4433. return FailretStr;
  4434. }
  4435. }
  4436. */
  4437. protected void SendLogSaved(String ftploc, String fname, String size)
  4438. {
  4439. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n"+
  4440. " <device_info devtype=\"homedev\" id_high=\""+AddrDong+"\" id_low=\""+AddrHo+"\"/>\r\n"+
  4441. " <file_info path=\""+ftploc+"\" name=\""+fname+"\" size=\""+size+"\"/>\r\n</service>\r\n</imap>";
  4442. SendToServer(SendMsg);
  4443. }
  4444. public final static int FTPLOGTRSUCC = 1110;
  4445. public final static int FTPLOGTRFAIL = 1120;
  4446. Handler FileTrHandler = new Handler(){
  4447. public void handleMessage(Message msg)
  4448. {
  4449. switch (msg.what)
  4450. {
  4451. case FTPLOGTRSUCC:
  4452. String[] getMSG = ((String)(msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4453. File fileinfo = new File(define.LOG_FILE_LOCATION+"/"+getMSG[1]);
  4454. int size = (int)(fileinfo.length()/1024);
  4455. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4456. imapsvrlog("FTPLOGTRSUCC");
  4457. break;
  4458. case FTPLOGTRFAIL:
  4459. imapsvrlog("FTPLOGTRFAIL");
  4460. break;
  4461. }
  4462. }
  4463. };
  4464. class LogUploader extends Thread
  4465. {
  4466. int fileidx = 0;
  4467. boolean TRing = false;
  4468. String FtpLoc;
  4469. String FtpID;
  4470. String FtpPasswd;
  4471. class ftpuploader extends WallPadFTPUploader
  4472. {
  4473. String filename;
  4474. public ftpuploader(Context ctx, String ftpPath, String User,String Passwd, String LocalFile)
  4475. {
  4476. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION+"/"+LocalFile);
  4477. filename = LocalFile;
  4478. }
  4479. protected void ProcUploadFail()
  4480. {
  4481. Message TrResult = FileTrHandler.obtainMessage();
  4482. TrResult.obj = ftpPATH+define.DEVCTR_CMD_SPLITER+filename+define.DEVCTR_CMD_SPLITER+id+define.DEVCTR_CMD_SPLITER+passwd;
  4483. TrResult.what = FTPLOGTRFAIL;
  4484. TRing = false;
  4485. imapsvrlog("Send Log Fail Message");
  4486. FileTrHandler.sendMessage(TrResult);
  4487. }
  4488. protected void ProcUploadSuccess()
  4489. {
  4490. Message TrResult = FileTrHandler.obtainMessage();
  4491. TrResult.obj = ftpPATH+define.DEVCTR_CMD_SPLITER+filename+define.DEVCTR_CMD_SPLITER+id+define.DEVCTR_CMD_SPLITER+passwd;
  4492. TrResult.what = FTPLOGTRSUCC;
  4493. TRing = false;
  4494. imapsvrlog("Send Log success Message");
  4495. FileTrHandler.sendMessage(TrResult);
  4496. }
  4497. }
  4498. public LogUploader(String loc, String user, String pw)
  4499. {
  4500. FtpLoc = loc;
  4501. FtpID = user;
  4502. FtpPasswd = pw;
  4503. }
  4504. public void run()
  4505. {
  4506. File LogLoc = new File(define.LOG_FILE_LOCATION);
  4507. String[] LogFileList = LogLoc.list();
  4508. while(true)
  4509. {
  4510. if (TRing == false)
  4511. {
  4512. if (fileidx < LogFileList.length)
  4513. {
  4514. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx] );
  4515. fileidx++;
  4516. TRing = true;
  4517. uploader.start();
  4518. }
  4519. else
  4520. return;
  4521. }
  4522. try {Thread.sleep(500); }catch(Exception e) {e.printStackTrace();}
  4523. }
  4524. }
  4525. }
  4526. public String iCMDProcDevList(Document ele) {
  4527. try {
  4528. String strResult = CheckiCMDProc("remote_get_home_devices");
  4529. if (strResult != null) return strResult;
  4530. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" result=";
  4531. String target= "null", tid= "null", msgno= "null";
  4532. NodeList items = ele.getElementsByTagName("target");
  4533. Node item = items.item(0);
  4534. if (item != null) {
  4535. NamedNodeMap attrs = item.getAttributes();
  4536. for (int j = 0; j< attrs.getLength(); j++) {
  4537. Node attr = attrs.item(j);
  4538. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4539. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4540. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4541. }
  4542. }
  4543. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4544. if (NewServerUse()) {
  4545. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  4546. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4547. }
  4548. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  4549. String[] devlist = {"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop"};
  4550. strResult += "\"ok\">\r\n";
  4551. strResult +=" <target name=\""+DevListCMD.target+"\" id=\""+DevListCMD.tid+"\" msg_no=\""+DevListCMD.msgno+"\"/>\r\n";
  4552. strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  4553. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  4554. for (int i = 0; i < devlist.length; i++) {
  4555. if (devlist[i].equals("gas")) {
  4556. try {
  4557. int Gasinfo = devSet.Get_GAS_Info();
  4558. if (Gasinfo == 0) strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  4559. else strResult +=" <devinfo name=\"gas\" value=\"1\"/>\r\n";
  4560. } catch (Exception e) {
  4561. e.printStackTrace();
  4562. strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  4563. }
  4564. }
  4565. else if (devlist[i].equals("cooktop")) {
  4566. try {
  4567. //int Gooktopinfo = devSet.Get_Cooktop_Info();
  4568. int Gooktopinfo = devSet.Get_GAS_Info();
  4569. if (Gooktopinfo == 0) strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  4570. else strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  4571. } catch (Exception e) {
  4572. e.printStackTrace();
  4573. strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  4574. }
  4575. }
  4576. else if (devlist[i].equals("doorlock")) {
  4577. try {
  4578. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  4579. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  4580. strResult +=" <devinfo name=\"doorlock\" value=\"1\"/>\r\n";
  4581. }
  4582. else {
  4583. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  4584. }
  4585. } catch (Exception e) {
  4586. e.printStackTrace();
  4587. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  4588. }
  4589. }
  4590. else if (devlist[i].equals("light")) {
  4591. try {
  4592. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  4593. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  4594. if (bSmartLightAsNormalLight) {
  4595. if (mSdbAPI != null) {
  4596. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\"/>\r\n";
  4597. }
  4598. else {
  4599. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  4600. }
  4601. }
  4602. else {
  4603. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  4604. }
  4605. }
  4606. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  4607. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  4608. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  4609. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\"/>\r\n";
  4610. }
  4611. else {
  4612. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  4613. }
  4614. }
  4615. else {
  4616. int[] lightinfo = devSet.Get_Light_info();
  4617. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  4618. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  4619. }
  4620. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  4621. strResult += " <devinfo name=\"light\" value=\"1\"/>\r\n";
  4622. }
  4623. else {
  4624. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  4625. int ret = multisw.Refresh((byte)0xFF, false);
  4626. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  4627. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\"/>\r\n";
  4628. }
  4629. }
  4630. } catch (Exception e) {
  4631. e.printStackTrace();
  4632. strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  4633. }
  4634. }
  4635. else if (devlist[i].equals("livinglight")) {
  4636. try {
  4637. int[] lightinfo = devSet.Get_Light_info();
  4638. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  4639. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  4640. if (bSmartLightAsNormalLight) {
  4641. if (mSdb_LivingRoomLightAPI != null) {
  4642. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\"/>\r\n";
  4643. }
  4644. else {
  4645. strResult += " <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  4646. }
  4647. }
  4648. else {
  4649. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  4650. }
  4651. }
  4652. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  4653. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\"/>\r\n";
  4654. }
  4655. else {
  4656. // if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  4657. // strResult += " <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  4658. // }
  4659. // else {
  4660. // strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\"/>\r\n";
  4661. // }
  4662. }
  4663. } catch (Exception e) {
  4664. e.printStackTrace();
  4665. strResult +=" <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  4666. }
  4667. }
  4668. else if (devlist[i].equals("ventil")) {
  4669. try {
  4670. int[] Ventilinfo = devSet.Get_Ventil_Info();
  4671. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  4672. else strResult +=" <devinfo name=\"ventil\" value=\"1\"/>\r\n";
  4673. } catch (Exception e) {
  4674. e.printStackTrace();
  4675. strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  4676. }
  4677. }
  4678. else if (devlist[i].equals("thermostat")) {
  4679. try {
  4680. int Temperinfo = devSet.Get_Temper_Info();
  4681. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4682. HeatingV1API heatingV1API = null;
  4683. HeatingV2API heatingV2API = null;
  4684. byte RoomCount = 0;
  4685. // 종류별 API를 로딩한다.
  4686. if (HeatingKind == 1) {
  4687. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4688. if (heatingV1API != null) {
  4689. RoomCount = heatingV1API.data.Device.RoomCount;
  4690. }
  4691. }
  4692. else if (HeatingKind == 2) {
  4693. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4694. if (heatingV2API != null) {
  4695. RoomCount = heatingV2API.data.Device.info.RoomCount;
  4696. }
  4697. }
  4698. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  4699. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\"/>\r\n";
  4700. } catch (Exception e) {
  4701. e.printStackTrace();
  4702. strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  4703. }
  4704. }
  4705. else if (devlist[i].equals("curtain")) {
  4706. try {
  4707. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  4708. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  4709. else strResult += " <devinfo name=\"curtain\" value=\"1\"/>\r\n";
  4710. } catch (Exception e) {
  4711. e.printStackTrace();
  4712. strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  4713. }
  4714. }
  4715. else if (devlist[i].equals("electric")) {
  4716. try {
  4717. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  4718. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  4719. int nOutlet = 0;
  4720. if (mSdb_LivingRoomLightAPI != null) {
  4721. if (mSdbAPI != null) {
  4722. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  4723. }
  4724. else {
  4725. nOutlet = 1;
  4726. }
  4727. }
  4728. else {
  4729. if (mSdbAPI != null) {
  4730. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  4731. }
  4732. else {
  4733. nOutlet = 0;
  4734. }
  4735. }
  4736. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\"/>\r\n";
  4737. }
  4738. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  4739. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  4740. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  4741. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\"/>\r\n";
  4742. }
  4743. else {
  4744. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  4745. }
  4746. }
  4747. else {
  4748. int[] lightinfo = devSet.Get_Light_info();
  4749. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  4750. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  4751. }
  4752. else {
  4753. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  4754. int ret = multisw.Refresh((byte)0xFF, false);
  4755. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  4756. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  4757. }
  4758. else {
  4759. int DeviceCount = 0;
  4760. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  4761. if (multisw.data.Device[j].info.ConcentCount > 0) {
  4762. DeviceCount++;
  4763. }
  4764. }
  4765. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\"/>\r\n";
  4766. }
  4767. }
  4768. }
  4769. } catch (Exception e) {
  4770. e.printStackTrace();
  4771. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  4772. }
  4773. }
  4774. else if (devlist[i].equals("smartlight")) {
  4775. if (!bSmartLightAsNormalLight) {
  4776. int nSmartLight = 0;
  4777. if (mSdb_LivingRoomLightAPI != null) {
  4778. if (mSdbAPI != null) {
  4779. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  4780. }
  4781. else {
  4782. nSmartLight = 1;
  4783. }
  4784. }
  4785. else {
  4786. if (mSdbAPI != null) {
  4787. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  4788. }
  4789. else {
  4790. nSmartLight = 0;
  4791. }
  4792. }
  4793. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\"/>\r\n";
  4794. }
  4795. }
  4796. }
  4797. strResult += " </service>\r\n</imap>\r\n";
  4798. devSet.closeDB();
  4799. return strResult;
  4800. } catch (Exception e) {
  4801. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  4802. e.printStackTrace();
  4803. return null;
  4804. }
  4805. }
  4806. public String iCMDProcMultiSWControl(Document ele) {
  4807. try {
  4808. String retStr = CheckiCMDProc(MULTISW_CTR);
  4809. if (retStr != null) return retStr;
  4810. else retStr = XMLHeader + " <service type=\"reply\" name=\""+MULTISW_CTR+"\"";
  4811. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  4812. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  4813. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  4814. int devNum = Integer.parseInt(multiswcmd.devnum);
  4815. int ret = multisw.Refresh((byte)0xFF, false);
  4816. String result;
  4817. if (ret==APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  4818. else result = "fail";
  4819. retStr+=(" result=\""+result+"\" >\r\n");
  4820. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  4821. retStr += MakeTargetStr(multiswcmd);
  4822. retStr += " <action>\"status\"</action>\r\n";
  4823. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum-1].device.ConcentCount + "\"/>\r\n";
  4824. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4825. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  4826. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.ConcentCount +"\" room_name=\"" + mDefaultRoomNameList_Light_HS[devNum - 1] + "\"/>\r\n";
  4827. }
  4828. else {
  4829. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.ConcentCount +"\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  4830. }
  4831. }
  4832. else {
  4833. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.ConcentCount +"\"/>\r\n";
  4834. }
  4835. String unitStr;
  4836. for (int i = 0;i < multisw.data.Device[devNum-1].device.ConcentCount;i++) {
  4837. Log.e(TAG, multisw.data.Device[devNum-1].device.ToDebugString((byte) i));
  4838. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  4839. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  4840. unitStr = (multisw.data.Device[devNum-1].device.GetConcent(i).Mode == MultiSwitch.CONCENT_MODE.Auto) ? "set/" : "unset/";
  4841. unitStr += (multisw.data.Device[devNum-1].device.GetConcent(i).Status == MultiSwitch.CONCENT_STATUS.On) ? "on" : "off";
  4842. retStr += " <status_info unit_num=\"switch"+(i+1)+"\" unit_status=\""+unitStr+"\" />\r\n";
  4843. }
  4844. }
  4845. retStr+=" </service>\r\n</imap>\r\n";
  4846. }
  4847. else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  4848. int devNum = Integer.parseInt(multiswcmd.devnum);
  4849. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  4850. {
  4851. multisw.Refresh((byte)0xFF, false);
  4852. String result;
  4853. int ret = -1;
  4854. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  4855. ret = multisw.SetConcentMode((byte)(devNum-1), (byte)(swNum-1), true);
  4856. }
  4857. else if(multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  4858. ret = multisw.SetConcentMode((byte)(devNum-1), (byte)(swNum-1), false);
  4859. }
  4860. else if(multiswcmd.ctraction.equalsIgnoreCase("on")) {
  4861. ret = multisw.SetConcentOnOff((byte)(devNum-1), (byte)(swNum-1), true);
  4862. }
  4863. else if(multiswcmd.ctraction.equalsIgnoreCase("off")) {
  4864. ret = multisw.SetConcentOnOff((byte)(devNum-1), (byte)(swNum-1), false);
  4865. }
  4866. if (ret==APIErrorCode.C_SUCCESS) result = "ok";
  4867. else result = "fail";
  4868. if (ret == APIErrorCode.C_SUCCESS) {
  4869. ret = multisw.Refresh((byte)0xFF, false);
  4870. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  4871. retStr+=(" result=\""+result+"\" > \r\n");
  4872. retStr += MakeTargetStr(multiswcmd);
  4873. retStr += " <action>\"control\"</action>\r\n";
  4874. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+multisw.data.Device[devNum-1].device.ConcentCount+"\"/>\r\n";
  4875. String unitStr;
  4876. for (int i = 0; i < multisw.data.Device[devNum-1].device.ConcentCount; i++) {
  4877. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  4878. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  4879. unitStr = (multisw.data.Device[devNum-1].device.GetConcent(i).Mode == MultiSwitch.CONCENT_MODE.Auto)?"set/":"unset/";
  4880. unitStr += (multisw.data.Device[devNum-1].device.GetConcent(i).Status == MultiSwitch.CONCENT_STATUS.Off)?"off":"on";
  4881. retStr += " <status_info unit_num=\"switch"+(i + 1)+"\" unit_status=\"" + unitStr + "\" />\r\n";
  4882. }
  4883. }
  4884. else {
  4885. retStr+=(" result=\"fail\"> \r\n");
  4886. }
  4887. }
  4888. else {
  4889. retStr+=(" result=\"fail\"> \r\n");
  4890. }
  4891. retStr+=" </service>\r\n</imap>\r\n";
  4892. }
  4893. }
  4894. return retStr;
  4895. } catch (Exception e) {
  4896. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  4897. e.printStackTrace();
  4898. return null;
  4899. }
  4900. }
  4901. public String iCMDProcSDPConcentControl(Document ele) {
  4902. try {
  4903. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  4904. String retStr = CheckiCMDProc("remote_access_electric");
  4905. if (retStr != null) return retStr;
  4906. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  4907. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4908. if (NewServerUse()) {
  4909. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  4910. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4911. }
  4912. if (mSdbAPI == null) {
  4913. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  4914. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  4915. return retStr;
  4916. }
  4917. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  4918. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  4919. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  4920. return retStr;
  4921. }
  4922. int nTotalLightCnt = 0;
  4923. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  4924. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  4925. }
  4926. else {
  4927. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  4928. }
  4929. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  4930. int nDevNo = 0;
  4931. try {
  4932. nDevNo = Integer.parseInt(concentcmd.devnum);
  4933. } catch (Exception e) {
  4934. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  4935. e.printStackTrace();
  4936. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  4937. return retStr;
  4938. }
  4939. if (nDevNo < 1 && 12 < nDevNo) {
  4940. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  4941. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  4942. return retStr;
  4943. }
  4944. String strAction = trimquotation(concentcmd.actionTXT);
  4945. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  4946. String dev_num = "null",unit_num = "null", ctrl_action = "null";
  4947. int nRet_Mode = -99, nRet_OnOff = -99;
  4948. boolean Set = false, OnOff = false; // 제어요청 상태
  4949. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  4950. if (strAction.equalsIgnoreCase("status")) {
  4951. retStr += " result=\"ok\">\r\n";
  4952. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  4953. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  4954. if (nDevNo == 1) {
  4955. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4956. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount +"\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  4957. }
  4958. else {
  4959. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount +"\"/>\r\n";
  4960. }
  4961. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  4962. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.CONCENT_MODE.Always) status_mode = "unset";
  4963. else status_mode = "set";
  4964. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.CONCENT_STATUS.On) status_onoff = "on";
  4965. else status_onoff = "off";
  4966. unit_status = status_mode + "/" + status_onoff;
  4967. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  4968. }
  4969. // retStr += " </status_map>\r\n";
  4970. retStr += " </service>\r\n</imap>\r\n";
  4971. }
  4972. else if (nDevNo > 1) {
  4973. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4974. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount +"\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  4975. }
  4976. else {
  4977. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  4978. }
  4979. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  4980. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.CONCENT_MODE.Always) status_mode = "unset";
  4981. else status_mode = "set";
  4982. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.CONCENT_STATUS.On) status_onoff = "on";
  4983. else status_onoff = "off";
  4984. unit_status = status_mode + "/" + status_onoff;
  4985. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  4986. }
  4987. // retStr += " </status_map>\r\n";
  4988. retStr += " </service>\r\n</imap>\r\n";
  4989. }
  4990. }
  4991. else if (strAction.equalsIgnoreCase("control")) {
  4992. NodeList items = ele.getElementsByTagName("params");
  4993. Node item = items.item(0);
  4994. if (item != null) {
  4995. NamedNodeMap attrs = item.getAttributes();
  4996. for (int i = 0; i< attrs.getLength(); i++) {
  4997. Node attr = attrs.item(i);
  4998. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  4999. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  5000. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) ctrl_action = attr.getNodeValue();
  5001. }
  5002. }
  5003. else {
  5004. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  5005. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5006. return retStr;
  5007. }
  5008. try {
  5009. nDevNo = Integer.parseInt(dev_num);
  5010. } catch (Exception e) {
  5011. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  5012. e.printStackTrace();
  5013. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5014. return retStr;
  5015. }
  5016. if (nDevNo < 1 && 12 < nDevNo) {
  5017. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5018. return retStr;
  5019. }
  5020. int nUnitNo = 0;
  5021. if (!unit_num.equalsIgnoreCase("all")) {
  5022. try {
  5023. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  5024. } catch (Exception e) {
  5025. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  5026. e.printStackTrace();
  5027. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5028. return retStr;
  5029. }
  5030. }
  5031. if (ctrl_action.contains("/")) {
  5032. String[] strParsed = ctrl_action.split("/");
  5033. if (strParsed[0].equals("set")) {
  5034. Set = true;
  5035. bCtrl_Set = true;
  5036. }
  5037. else if (strParsed[0].equals("unset")) {
  5038. Set = false;
  5039. bCtrl_Set = true;
  5040. }
  5041. if (strParsed[1].equals("on")) {
  5042. OnOff = true;
  5043. bCtrl_OnOff = true;
  5044. }
  5045. else if (strParsed[1].equals("off")) {
  5046. OnOff = false;
  5047. bCtrl_OnOff = true;
  5048. }
  5049. }
  5050. else {
  5051. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  5052. if (ctrl_action.equalsIgnoreCase("set")) {
  5053. Set = true;
  5054. bCtrl_Set = true;
  5055. }
  5056. else if (ctrl_action.equalsIgnoreCase("unset")) {
  5057. Set = false;
  5058. bCtrl_Set = true;
  5059. }
  5060. }
  5061. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  5062. if (ctrl_action.equalsIgnoreCase("on")) {
  5063. OnOff = true;
  5064. bCtrl_OnOff = true;
  5065. }
  5066. else if (ctrl_action.equalsIgnoreCase("off")) {
  5067. OnOff = false;
  5068. bCtrl_OnOff = true;
  5069. }
  5070. }
  5071. }
  5072. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  5073. if (nDevNo == 1) {
  5074. if (unit_num.equalsIgnoreCase("all")) {
  5075. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  5076. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  5077. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  5078. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5079. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5080. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5081. return retStr;
  5082. }
  5083. }
  5084. }
  5085. else {
  5086. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  5087. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  5088. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5089. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5090. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5091. return retStr;
  5092. }
  5093. }
  5094. }
  5095. else {
  5096. if (unit_num.equalsIgnoreCase("all")) {
  5097. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  5098. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  5099. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  5100. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5101. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5102. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5103. return retStr;
  5104. }
  5105. }
  5106. }
  5107. else {
  5108. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  5109. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  5110. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5111. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5112. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5113. return retStr;
  5114. }
  5115. }
  5116. }
  5117. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  5118. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5119. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  5120. return retStr;
  5121. }
  5122. retStr += " result=\"ok\">\r\n";
  5123. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  5124. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  5125. if (nDevNo == 1) {
  5126. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  5127. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  5128. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.CONCENT_MODE.Always) status_mode = "unset";
  5129. else status_mode = "set";
  5130. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.CONCENT_STATUS.On) status_onoff = "on";
  5131. else status_onoff = "off";
  5132. unit_status = status_mode + "/" + status_onoff;
  5133. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  5134. }
  5135. // retStr += " </status_map>\r\n";
  5136. retStr += " </service>\r\n</imap>\r\n";
  5137. }
  5138. else if (nDevNo > 1) {
  5139. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  5140. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  5141. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.CONCENT_MODE.Always) status_mode = "unset";
  5142. else status_mode = "set";
  5143. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.CONCENT_STATUS.On) status_onoff = "on";
  5144. else status_onoff = "off";
  5145. unit_status = status_mode + "/" + status_onoff;
  5146. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  5147. }
  5148. // retStr += " </status_map>\r\n";
  5149. retStr += " </service>\r\n</imap>\r\n";
  5150. }
  5151. }
  5152. else {
  5153. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  5154. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  5155. }
  5156. return retStr;
  5157. } catch (Exception e) {
  5158. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  5159. e.printStackTrace();
  5160. return null;
  5161. }
  5162. }
  5163. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  5164. try {
  5165. String retStr = CheckiCMDProc(MULTISW_CTR);
  5166. if (retStr != null) return retStr;
  5167. else retStr = XMLHeader + " <service type=\"reply\" name=\""+MULTISW_CTR+"\" ";
  5168. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  5169. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5170. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  5171. int devNum = Integer.parseInt(energymetercmd.devnum)-1;
  5172. int ret = energymeter.Refresh((byte)0xFF, false);
  5173. String result;
  5174. if (ret==APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  5175. else result = "fail";
  5176. retStr+=(" result=\""+result+"\" >\r\n");
  5177. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  5178. retStr += MakeTargetStr(energymetercmd);
  5179. retStr += " <action>\"status\"</action>\r\n";
  5180. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  5181. String unitStr;
  5182. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  5183. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  5184. if (i == 2) {
  5185. unitStr += "on";
  5186. }
  5187. else {
  5188. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  5189. }
  5190. retStr += " <status_info unit_num=\"switch"+(i + 1)+"\" unit_status=\"" + unitStr + "\"/>\r\n";
  5191. }
  5192. }
  5193. retStr+=" </service>\r\n</imap>\r\n";
  5194. }
  5195. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  5196. int devNum = Integer.parseInt(energymetercmd.devnum)-1;
  5197. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) -1;
  5198. byte cmd = 0;
  5199. int ret = 0;
  5200. String result;
  5201. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  5202. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  5203. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  5204. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  5205. if (cmd>0) {
  5206. energymeter.Refresh((byte)0xFF, false);
  5207. if (cmd == 1) {
  5208. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  5209. }
  5210. else if (cmd == 2) {
  5211. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  5212. }
  5213. else if (cmd == 3) {
  5214. ret = energymeter.SetConcentOnOff((byte) devNum, (byte)swNum, true);
  5215. }
  5216. else if (cmd == 4) {
  5217. ret = energymeter.SetConcentOnOff((byte) devNum, (byte)swNum, false);
  5218. }
  5219. if (ret==APIErrorCode.C_SUCCESS) result = "ok";
  5220. else result = "fail";
  5221. retStr+=(" result=\""+result+"\" >\r\n");
  5222. if (ret == APIErrorCode.C_SUCCESS) {
  5223. ret = energymeter.Refresh((byte)0xFF, false);
  5224. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  5225. retStr += MakeTargetStr(energymetercmd);
  5226. retStr += " <action>\"control\"</action>\r\n";
  5227. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  5228. String unitStr;
  5229. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  5230. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  5231. if (i == 2) {
  5232. unitStr += "on";
  5233. }
  5234. else {
  5235. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  5236. }
  5237. retStr += " <status_info unit_num=\"switch"+(i+1)+"\" unit_status=\""+unitStr+"\"/>\r\n";
  5238. }
  5239. }
  5240. else {
  5241. retStr+=(" result=\"fail\"> \r\n");
  5242. }
  5243. }
  5244. else {
  5245. retStr+=(" result=\"fail\"> \r\n");
  5246. }
  5247. retStr+=" </service>\r\n</imap>\r\n";
  5248. }
  5249. }
  5250. return retStr;
  5251. } catch (Exception e) {
  5252. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  5253. e.printStackTrace();
  5254. return null;
  5255. }
  5256. }
  5257. public String iCMDProcModeControl(Document doc) {
  5258. try {
  5259. String status = "unknown";
  5260. boolean SendBR = false;
  5261. String retStr = CheckiCMDProc("remote_access_mode");
  5262. if (retStr != null) return retStr;
  5263. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  5264. String target= "null", tid= "null", msgno= "null";
  5265. NodeList items = doc.getElementsByTagName("target");
  5266. Node item = items.item(0);
  5267. if (item != null) {
  5268. NamedNodeMap attrs = item.getAttributes();
  5269. for (int j = 0; j< attrs.getLength(); j++) {
  5270. Node attr = attrs.item(j);
  5271. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5272. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5273. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5274. }
  5275. }
  5276. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5277. if (NewServerUse()) {
  5278. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  5279. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5280. }
  5281. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  5282. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5283. int curState = SetData.GetAlarmStatus();
  5284. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  5285. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  5286. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  5287. switch (curState) {
  5288. case WallpadStatusData.GUARD_IN:
  5289. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  5290. Intent intent = new Intent();
  5291. intent.setAction(define.NOTIFY_ACNAME);
  5292. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5293. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  5294. getApplicationContext().sendBroadcast(intent);
  5295. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  5296. SendBR = true;
  5297. break;
  5298. case WallpadStatusData.GUARD_OUT:
  5299. break;
  5300. }
  5301. }
  5302. else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  5303. switch (curState) {
  5304. case WallpadStatusData.ALARM_NONE:
  5305. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5306. if (mIGW200.checkSensorforInmode()) {
  5307. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  5308. Intent intent = new Intent();
  5309. intent.setAction(define.NOTIFY_ACNAME);
  5310. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5311. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  5312. getApplicationContext().sendBroadcast(intent);
  5313. SendBR = true;
  5314. }
  5315. else {
  5316. SendBR = false;
  5317. }
  5318. }
  5319. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5320. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  5321. if (mIGW300.checkSensorforInmode()) {
  5322. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  5323. Intent intent = new Intent();
  5324. intent.setAction(define.NOTIFY_ACNAME);
  5325. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5326. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  5327. getApplicationContext().sendBroadcast(intent);
  5328. SendBR = true;
  5329. }
  5330. else {
  5331. SendBR = false;
  5332. }
  5333. }
  5334. else {
  5335. if (checkSensorforInmode()) {
  5336. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  5337. Intent intent = new Intent();
  5338. intent.setAction(define.NOTIFY_ACNAME);
  5339. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5340. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  5341. getApplicationContext().sendBroadcast(intent);
  5342. Sound().PlayMent(SND.mode.INMODE_SETTING);
  5343. SendBR = true;
  5344. }
  5345. else {
  5346. SendBR = false;
  5347. }
  5348. }
  5349. break;
  5350. default:
  5351. break;
  5352. }
  5353. }
  5354. else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  5355. if (GetUseIlgalControlForAdmin() == false) {
  5356. // 관리자용 일괄소등 원격제어 사용안할 시
  5357. switch (curState) {
  5358. case WallpadStatusData.ALARM_NONE:
  5359. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5360. if (mIGW200.checkSensorforOutmode()) {
  5361. Common.SendAppFinishReqBR(getApplicationContext());
  5362. Intent intent = new Intent();
  5363. intent.setAction(define.NOTIFY_ACNAME);
  5364. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5365. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  5366. getApplicationContext().sendBroadcast(intent);
  5367. SendBR = true;
  5368. }
  5369. else {
  5370. SendBR = false;
  5371. }
  5372. }
  5373. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5374. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  5375. if (mIGW300.checkSensorforOutmode()) {
  5376. Common.SendAppFinishReqBR(getApplicationContext());
  5377. Intent intent = new Intent();
  5378. intent.setAction(define.NOTIFY_ACNAME);
  5379. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5380. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  5381. getApplicationContext().sendBroadcast(intent);
  5382. SendBR = true;
  5383. }
  5384. else {
  5385. SendBR = false;
  5386. }
  5387. }
  5388. else {
  5389. if (checkSensorforOutmode()) {
  5390. Common.SendAppFinishReqBR(getApplicationContext());
  5391. Intent intent = new Intent();
  5392. intent.setAction(define.NOTIFY_ACNAME);
  5393. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5394. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  5395. getApplicationContext().sendBroadcast(intent);
  5396. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  5397. SendBR = true;
  5398. }
  5399. else {
  5400. SendBR = false;
  5401. }
  5402. }
  5403. break;
  5404. default:
  5405. break;
  5406. }
  5407. }
  5408. else {
  5409. // 관리자용 일괄소등 원격제어 사용 시
  5410. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  5411. SendBR = true;
  5412. }
  5413. }
  5414. }
  5415. else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  5416. int getStatus = SetData.GetAlarmStatus();
  5417. switch (getStatus) {
  5418. case WallpadStatusData.GUARD_IN:
  5419. status = "occupied";
  5420. break;
  5421. case WallpadStatusData.GUARD_OUT:
  5422. status = "unoccupied";
  5423. break;
  5424. case WallpadStatusData.ALARM_NONE:
  5425. status = "normal";
  5426. break;
  5427. case WallpadStatusData.ALARM_ARISE:
  5428. status = "emergency";
  5429. break;
  5430. default:
  5431. break;
  5432. }
  5433. retStr+=("\"ok\">\r\n ");
  5434. retStr+=" <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  5435. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  5436. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  5437. retStr += " <status_info unit_num=\"null\" unit_status=\""+status+"\" />\r\n </service>\r\n</imap>\r\n";
  5438. return retStr;
  5439. }
  5440. if (!SendBR) {
  5441. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  5442. SetData.closeDB();
  5443. return retStr;
  5444. }
  5445. else {
  5446. try { Thread.sleep(1000); } catch (Exception e){e.printStackTrace();}
  5447. int getStatus = SetData.GetAlarmStatus();
  5448. switch (getStatus) {
  5449. case WallpadStatusData.GUARD_IN:
  5450. status = "occupied";
  5451. break;
  5452. case WallpadStatusData.GUARD_OUT:
  5453. status = "unoccupied";
  5454. break;
  5455. case WallpadStatusData.ALARM_NONE:
  5456. status = "normal";
  5457. break;
  5458. case WallpadStatusData.ALARM_ARISE:
  5459. status = "emergency";
  5460. break;
  5461. }
  5462. }
  5463. retStr+="\"ok\">\r\n";
  5464. retStr+=" <target name=\"" + accmode.target+"\" id=\""+accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  5465. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  5466. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  5467. retStr += " <status_info unit_num=\"null\" unit_status=\""+status+"\" />\r\n </service>\r\n</imap>\r\n";
  5468. SetData.closeDB();
  5469. return retStr;
  5470. } catch (Exception e) {
  5471. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  5472. e.printStackTrace();
  5473. return null;
  5474. }
  5475. }
  5476. public String iCMDProcCurtainControl(Document ele) {
  5477. return " ";
  5478. }
  5479. public String iCMDProcSDPLightControl(Document ele) {
  5480. try {
  5481. String retStr = CheckiCMDProc("remote_access_light");
  5482. if (retStr != null) return retStr;
  5483. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  5484. String target= "null", tid= "null", msgno= "null";
  5485. NodeList items = ele.getElementsByTagName("target");
  5486. Node item = items.item(0);
  5487. if (item != null) {
  5488. NamedNodeMap attrs = item.getAttributes();
  5489. for (int j = 0; j< attrs.getLength(); j++) {
  5490. Node attr = attrs.item(j);
  5491. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5492. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5493. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5494. }
  5495. }
  5496. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5497. if (NewServerUse()) {
  5498. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  5499. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5500. }
  5501. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  5502. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5503. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  5504. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  5505. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  5506. retStr += "result=\"ok\">\r\n" +
  5507. " <action>\"status\"</action>\r\n" +
  5508. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  5509. for (int i=0 ; i< energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  5510. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
  5511. }
  5512. retStr+="\r\n</service>\r\n</imap>";
  5513. }
  5514. else {
  5515. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  5516. }
  5517. }
  5518. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  5519. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  5520. num--;
  5521. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  5522. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  5523. if (energymeter.SetLightOnOff( (byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  5524. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  5525. retStr += "result=\"ok\">\r\n" +
  5526. " <action>\"control\"</action>\r\n" +
  5527. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  5528. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  5529. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
  5530. }
  5531. retStr+="\r\n</service>\r\n</imap>";
  5532. }
  5533. else {
  5534. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  5535. }
  5536. }
  5537. else {
  5538. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  5539. }
  5540. }
  5541. else {
  5542. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  5543. }
  5544. energymetercmd = null;
  5545. return retStr;
  5546. } catch (Exception e) {
  5547. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  5548. e.printStackTrace();
  5549. return null;
  5550. }
  5551. }
  5552. public String iCMDProcEnergyMeterLightControl(Document ele) {
  5553. try {
  5554. String retStr = CheckiCMDProc("remote_access_light");
  5555. if (retStr != null) return retStr;
  5556. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  5557. String target= "null", tid= "null", msgno= "null";
  5558. NodeList items = ele.getElementsByTagName("target");
  5559. Node item = items.item(0);
  5560. if (item != null) {
  5561. NamedNodeMap attrs = item.getAttributes();
  5562. for (int j = 0; j< attrs.getLength(); j++) {
  5563. Node attr = attrs.item(j);
  5564. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5565. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5566. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5567. }
  5568. }
  5569. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5570. if (NewServerUse()) {
  5571. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  5572. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5573. }
  5574. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  5575. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5576. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  5577. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  5578. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  5579. retStr += "result=\"ok\">\r\n" +
  5580. " <action>\"status\"</action>\r\n" +
  5581. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  5582. for (int i=0 ; i< energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  5583. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
  5584. }
  5585. retStr+="\r\n</service>\r\n</imap>";
  5586. }
  5587. else {
  5588. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  5589. }
  5590. }
  5591. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  5592. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  5593. num--;
  5594. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  5595. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  5596. if (energymeter.SetLightOnOff( (byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  5597. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  5598. retStr += "result=\"ok\">\r\n" +
  5599. " <action>\"control\"</action>\r\n" +
  5600. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  5601. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  5602. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
  5603. }
  5604. retStr+="\r\n</service>\r\n</imap>";
  5605. }
  5606. else {
  5607. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  5608. }
  5609. }
  5610. else {
  5611. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  5612. }
  5613. }
  5614. else {
  5615. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  5616. }
  5617. energymetercmd = null;
  5618. return retStr;
  5619. } catch (Exception e) {
  5620. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  5621. e.printStackTrace();
  5622. return null;
  5623. }
  5624. }
  5625. public String iCMDProcLightControl(Document ele) {
  5626. try {
  5627. String retStr = CheckiCMDProc("remote_access_light");
  5628. if (retStr != null) return retStr;
  5629. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  5630. String target= "null", tid= "null", msgno= "null";
  5631. NodeList items = ele.getElementsByTagName("target");
  5632. Node item = items.item(0);
  5633. if (item != null) {
  5634. NamedNodeMap attrs = item.getAttributes();
  5635. for (int j = 0; j< attrs.getLength(); j++) {
  5636. Node attr = attrs.item(j);
  5637. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5638. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5639. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5640. }
  5641. }
  5642. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5643. if (NewServerUse()) {
  5644. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  5645. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5646. }
  5647. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  5648. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  5649. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  5650. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  5651. if (bSmartLightAsNormalLight) {
  5652. if (mSdbAPI != null) {
  5653. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  5654. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  5655. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  5656. retStr += "result=\"ok\">\r\n" +
  5657. " <action>\"status\"</action>\r\n";
  5658. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5659. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount +"\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  5660. }
  5661. else {
  5662. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount +"\"/>\r\n";
  5663. }
  5664. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  5665. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff ? "on" : "off");
  5666. }
  5667. retStr+=" </service>\r\n</imap>";
  5668. }
  5669. else {
  5670. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5671. }
  5672. }
  5673. else {
  5674. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5675. }
  5676. }
  5677. else {
  5678. if (mMultiSwitchAPI != null) {
  5679. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  5680. if (nResult == 0) {
  5681. if (mMultiSwitchAPI.data.Device[deviceNum].device.LightCount > 0) {
  5682. retStr += "result=\"ok\">\r\n" +
  5683. " <action>\"status\"</action>\r\n";
  5684. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5685. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  5686. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.LightCount +"\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  5687. }
  5688. else {
  5689. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.LightCount +"\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  5690. }
  5691. }
  5692. else {
  5693. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.LightCount +"\"/>\r\n";
  5694. }
  5695. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.LightCount; i++) {
  5696. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, mMultiSwitchAPI.data.Device[deviceNum].device.GetLightOnOff(i) ? "on" : "off");
  5697. }
  5698. retStr+=" </service>\r\n</imap>";
  5699. }
  5700. else {
  5701. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.LightCount);
  5702. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5703. }
  5704. }
  5705. else {
  5706. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  5707. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5708. }
  5709. }
  5710. else {
  5711. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  5712. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5713. }
  5714. }
  5715. }
  5716. else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  5717. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  5718. boolean OnOff = false;
  5719. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  5720. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  5721. if (bSmartLightAsNormalLight) {
  5722. if (mSdbAPI != null) {
  5723. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  5724. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  5725. if (ret >= 0) {
  5726. retStr += "result=\"ok\">\r\n" +
  5727. " <action>\"status\"</action>\r\n" +
  5728. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  5729. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  5730. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  5731. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  5732. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff ? "on" : "off");
  5733. }
  5734. retStr += " </service>\r\n</imap>";
  5735. }
  5736. else {
  5737. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5738. }
  5739. }
  5740. else {
  5741. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  5742. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  5743. if (ret >= 0) {
  5744. retStr += "result=\"ok\">\r\n" +
  5745. " <action>\"status\"</action>\r\n" +
  5746. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  5747. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  5748. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  5749. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  5750. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  5751. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff ? "on" : "off");
  5752. }
  5753. retStr += " </service>\r\n</imap>";
  5754. }
  5755. else {
  5756. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5757. }
  5758. }
  5759. }
  5760. else {
  5761. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5762. }
  5763. }
  5764. else {
  5765. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  5766. int nResultRefresh = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  5767. if (nResultRefresh == 0) {
  5768. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.LightCount; i++) {
  5769. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) i, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  5770. if (nCtrlResult == 0) {
  5771. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  5772. if (nResult == 0) {
  5773. if (mMultiSwitchAPI.data.Device[deviceNum].device.LightCount > 0) {
  5774. retStr += "result=\"ok\">\r\n" +
  5775. " <action>\"status\"</action>\r\n" +
  5776. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.LightCount + "\"/>\r\n";
  5777. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.LightCount; j++) {
  5778. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", j + 1, mMultiSwitchAPI.data.Device[deviceNum].device.GetLightOnOff(j) ? "on" : "off");
  5779. }
  5780. retStr += " </service>\r\n</imap>";
  5781. }
  5782. else {
  5783. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.LightCount);
  5784. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5785. }
  5786. }
  5787. else {
  5788. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  5789. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5790. }
  5791. }
  5792. else {
  5793. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  5794. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5795. }
  5796. }
  5797. }
  5798. else {
  5799. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  5800. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5801. }
  5802. }
  5803. else {
  5804. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  5805. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  5806. if (nCtrlResult == 0) {
  5807. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  5808. if (nResult == 0) {
  5809. if (mMultiSwitchAPI.data.Device[deviceNum].device.LightCount > 0) {
  5810. retStr += "result=\"ok\">\r\n" +
  5811. " <action>\"status\"</action>\r\n" +
  5812. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.LightCount + "\"/>\r\n";
  5813. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.LightCount; i++) {
  5814. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mMultiSwitchAPI.data.Device[deviceNum].device.GetLightOnOff(i) ? "on" : "off");
  5815. }
  5816. retStr += " </service>\r\n</imap>";
  5817. }
  5818. else {
  5819. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.LightCount);
  5820. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5821. }
  5822. }
  5823. else {
  5824. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  5825. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5826. }
  5827. }
  5828. else {
  5829. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  5830. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  5831. }
  5832. }
  5833. }
  5834. }
  5835. else {
  5836. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  5837. }
  5838. }
  5839. else {
  5840. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  5841. }
  5842. MSlightcmd = null;
  5843. return retStr;
  5844. } catch (Exception e) {
  5845. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  5846. e.printStackTrace();
  5847. return null;
  5848. }
  5849. }
  5850. public String iCMDProcSDPSmartLightControl(Document ele) {
  5851. try {
  5852. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  5853. String retStr = CheckiCMDProc("remote_access_smartlight");
  5854. if (retStr != null) return retStr;
  5855. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  5856. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5857. if (NewServerUse()) {
  5858. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  5859. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5860. }
  5861. if (mSdb_LivingRoomLightAPI == null) {
  5862. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5863. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  5864. return retStr;
  5865. }
  5866. if (mSdbAPI == null) {
  5867. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5868. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  5869. return retStr;
  5870. }
  5871. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  5872. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5873. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  5874. return retStr;
  5875. }
  5876. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  5877. if (mSdbAPI.Refresh((byte)0x00, (byte)i) != 0) {
  5878. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5879. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  5880. return retStr;
  5881. }
  5882. }
  5883. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  5884. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  5885. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  5886. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  5887. retStr += " result=\"ok\">\r\n";
  5888. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  5889. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  5890. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  5891. for (int i = 0; i < nTotalLightCnt; i++) {
  5892. if (i == 0) {
  5893. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  5894. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  5895. String status_power = "off", status_dim = "null", status_color = "null";
  5896. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  5897. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  5898. }
  5899. else {
  5900. status_power = "null";
  5901. }
  5902. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  5903. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  5904. }
  5905. else {
  5906. status_dim = "null";
  5907. }
  5908. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  5909. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  5910. }
  5911. else {
  5912. status_color = "null";
  5913. }
  5914. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  5915. }
  5916. retStr += " </status_map>\r\n";
  5917. }
  5918. else {
  5919. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  5920. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  5921. String status_power = "off", status_dim = "null", status_color = "null";
  5922. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  5923. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  5924. }
  5925. else {
  5926. status_power = "null";
  5927. }
  5928. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  5929. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  5930. }
  5931. else {
  5932. status_dim = "null";
  5933. }
  5934. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  5935. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  5936. }
  5937. else {
  5938. status_color = "null";
  5939. }
  5940. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  5941. }
  5942. retStr += " </status_map>\r\n";
  5943. }
  5944. }
  5945. retStr += " </service>\r\n</imap>\r\n";
  5946. }
  5947. else {
  5948. int nDevNo = 0;
  5949. try {
  5950. nDevNo = Integer.parseInt(lightcmd.devnum);
  5951. } catch (Exception e) {
  5952. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  5953. e.printStackTrace();
  5954. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5955. return retStr;
  5956. }
  5957. if ((nDevNo - 1) > nTotalLightCnt) {
  5958. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  5959. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5960. return retStr;
  5961. }
  5962. retStr += " result=\"ok\">\r\n";
  5963. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  5964. retStr += " <action>\"status\"</action>\r\n";
  5965. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  5966. if (nDevNo == 1) {
  5967. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  5968. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  5969. String status_power = "off", status_dim = "null", status_color = "null";
  5970. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  5971. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  5972. }
  5973. else {
  5974. status_power = "null";
  5975. }
  5976. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  5977. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  5978. }
  5979. else {
  5980. status_dim = "null";
  5981. }
  5982. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  5983. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  5984. }
  5985. else {
  5986. status_color = "null";
  5987. }
  5988. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  5989. }
  5990. retStr += " </status_map>\r\n";
  5991. }
  5992. else {
  5993. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\"null\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  5994. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  5995. String status_power = "off", status_dim = "null", status_color = "null";
  5996. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  5997. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  5998. }
  5999. else {
  6000. status_power = "null";
  6001. }
  6002. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  6003. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  6004. }
  6005. else {
  6006. status_dim = "null";
  6007. }
  6008. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  6009. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  6010. }
  6011. else {
  6012. status_color = "null";
  6013. }
  6014. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6015. }
  6016. retStr += " </status_map>\r\n";
  6017. }
  6018. retStr += " </service>\r\n</imap>\r\n";
  6019. }
  6020. }
  6021. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  6022. int nResult = 0;
  6023. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  6024. NodeList items = ele.getElementsByTagName("params");
  6025. Node item = items.item(0);
  6026. if (item != null) {
  6027. NamedNodeMap attrs = item.getAttributes();
  6028. for (int j = 0; j< attrs.getLength(); j++) {
  6029. Node attr = attrs.item(j);
  6030. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  6031. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  6032. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  6033. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  6034. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  6035. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  6036. }
  6037. }
  6038. if (dev_num.equalsIgnoreCase("all")) {
  6039. retStr += " result=\"ok\">\r\n";
  6040. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6041. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6042. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  6043. for (int i = 0; i < nTotalLightCnt; i++) {
  6044. if (i == 0) {
  6045. mSdb_LivingRoomLightAPI.SetLight((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6046. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6047. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6048. // if (!unit_status.equalsIgnoreCase("null")) {
  6049. // mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6050. // }
  6051. //
  6052. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6053. // mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6054. // }
  6055. //
  6056. // if (!unit_color.equalsIgnoreCase("null")) {
  6057. // mSdb_LivingRoomLightAPI.SetLightColor((byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6058. // }
  6059. }
  6060. else {
  6061. mSdbAPI.SetLight((byte) (i - 1), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6062. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6063. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6064. // if (!unit_status.equalsIgnoreCase("null")) {
  6065. // mSdbAPI.SetLightOnOff((byte) (i - 1), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6066. // }
  6067. //
  6068. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6069. // mSdbAPI.SetLightDimming((byte) (i - 1), (byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6070. // }
  6071. //
  6072. // if (!unit_color.equalsIgnoreCase("null")) {
  6073. // mSdbAPI.SetLightColor((byte) (i - 1), (byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6074. // }
  6075. }
  6076. }
  6077. mSdb_LivingRoomLightAPI.Refresh();
  6078. mSdbAPI.Refresh((byte) 0xFF, (byte) 0xFF);
  6079. for (int i = 0; i < nTotalLightCnt; i++) {
  6080. if (i == 0) {
  6081. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6082. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  6083. String status_power = "off", status_dim = "null", status_color = "null";
  6084. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  6085. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6086. }
  6087. else {
  6088. status_power = "null";
  6089. }
  6090. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  6091. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  6092. }
  6093. else {
  6094. status_dim = "null";
  6095. }
  6096. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  6097. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  6098. }
  6099. else {
  6100. status_color = "null";
  6101. }
  6102. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6103. }
  6104. retStr += " </status_map>\r\n";
  6105. }
  6106. else {
  6107. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  6108. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  6109. String status_power = "off", status_dim = "null", status_color = "null";
  6110. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  6111. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6112. }
  6113. else {
  6114. status_power = "null";
  6115. }
  6116. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  6117. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  6118. }
  6119. else {
  6120. status_dim = "null";
  6121. }
  6122. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  6123. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  6124. }
  6125. else {
  6126. status_color = "null";
  6127. }
  6128. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6129. }
  6130. retStr += " </status_map>\r\n";
  6131. }
  6132. }
  6133. retStr += " </service>\r\n</imap>\r\n";
  6134. }
  6135. else {
  6136. int nDevNo = 0;
  6137. int nUnitNo = 0;
  6138. try {
  6139. nDevNo = Integer.parseInt(dev_num);
  6140. } catch (Exception e) {
  6141. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  6142. e.printStackTrace();
  6143. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6144. return retStr;
  6145. }
  6146. if ((nDevNo - 1) > nTotalLightCnt) {
  6147. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  6148. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6149. return retStr;
  6150. }
  6151. retStr += " result=\"ok\">\r\n";
  6152. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6153. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6154. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6155. if (unit_num.equalsIgnoreCase("all")) {
  6156. if (nDevNo == 1) {
  6157. mSdb_LivingRoomLightAPI.SetLight((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6158. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6159. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6160. // if (!unit_status.equalsIgnoreCase("null")) {
  6161. // mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6162. // }
  6163. //
  6164. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6165. // mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6166. // }
  6167. //
  6168. // if (!unit_color.equalsIgnoreCase("null")) {
  6169. // mSdb_LivingRoomLightAPI.SetLightColor((byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6170. // }
  6171. }
  6172. else {
  6173. mSdbAPI.SetLight((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6174. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6175. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6176. // if (!unit_status.equalsIgnoreCase("null")) {
  6177. // mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6178. // }
  6179. //
  6180. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6181. // mSdbAPI.SetLightDimming((byte) (nDevNo -2), (byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6182. // }
  6183. //
  6184. // if (!unit_color.equalsIgnoreCase("null")) {
  6185. // mSdbAPI.SetLightColor((byte) (nDevNo -2), (byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6186. // }
  6187. }
  6188. }
  6189. else {
  6190. try {
  6191. nUnitNo = Integer.parseInt(unit_num);
  6192. } catch (Exception e) {
  6193. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  6194. e.printStackTrace();
  6195. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6196. return retStr;
  6197. }
  6198. if (nDevNo == 1) {
  6199. mSdb_LivingRoomLightAPI.SetLight((byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false,
  6200. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6201. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6202. // if (!unit_status.equalsIgnoreCase("null")) {
  6203. // mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  6204. // }
  6205. //
  6206. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6207. // mSdb_LivingRoomLightAPI.SetLightDimming((byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_dimming));
  6208. // }
  6209. //
  6210. // if (!unit_color.equalsIgnoreCase("null")) {
  6211. // mSdb_LivingRoomLightAPI.SetLightColor((byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_color));
  6212. // }
  6213. }
  6214. else {
  6215. mSdbAPI.SetLight((byte) (nDevNo -2), (byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false,
  6216. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6217. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6218. // if (!unit_status.equalsIgnoreCase("null")) {
  6219. // mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  6220. // }
  6221. //
  6222. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6223. // mSdbAPI.SetLightDimming((byte) (nDevNo -2), (byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_dimming));
  6224. // }
  6225. //
  6226. // if (!unit_color.equalsIgnoreCase("null")) {
  6227. // mSdbAPI.SetLightColor((byte) (nDevNo -2), (byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_color));
  6228. // }
  6229. }
  6230. }
  6231. if (nDevNo == 1) {
  6232. mSdb_LivingRoomLightAPI.Refresh();
  6233. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6234. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  6235. String status_power = "off", status_dim = "null", status_color = "null";
  6236. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  6237. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6238. }
  6239. else {
  6240. status_power = "null";
  6241. }
  6242. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  6243. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  6244. }
  6245. else {
  6246. status_dim = "null";
  6247. }
  6248. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  6249. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  6250. }
  6251. else {
  6252. status_color = "null";
  6253. }
  6254. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6255. }
  6256. retStr += " </status_map>\r\n";
  6257. }
  6258. else {
  6259. mSdbAPI.Refresh((byte) 0xFF, (byte) 0xFF);
  6260. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\"null\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  6261. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  6262. String status_power = "off", status_dim = "null", status_color = "null";
  6263. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  6264. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6265. }
  6266. else {
  6267. status_power = "null";
  6268. }
  6269. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  6270. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  6271. }
  6272. else {
  6273. status_dim = "null";
  6274. }
  6275. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  6276. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  6277. }
  6278. else {
  6279. status_color = "null";
  6280. }
  6281. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6282. }
  6283. retStr += " </status_map>\r\n";
  6284. }
  6285. retStr += " </service>\r\n</imap>\r\n";
  6286. }
  6287. }
  6288. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  6289. int nResult = 0;
  6290. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  6291. NodeList items = ele.getElementsByTagName("params");
  6292. Node item = items.item(0);
  6293. if (item != null) {
  6294. NamedNodeMap attrs = item.getAttributes();
  6295. for (int j = 0; j< attrs.getLength(); j++) {
  6296. Node attr = attrs.item(j);
  6297. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  6298. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  6299. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  6300. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  6301. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  6302. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  6303. }
  6304. }
  6305. if (dev_num.equalsIgnoreCase("all")) {
  6306. retStr += " result=\"ok\">\r\n";
  6307. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6308. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6309. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6310. if (!dev_mode.equals("null")) mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  6311. retStr += " <status_map dev_num=\"1\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"1\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6312. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  6313. retStr += " </service>\r\n</imap>\r\n";
  6314. }
  6315. else {
  6316. int nDevNo = 0;
  6317. try {
  6318. nDevNo = Integer.parseInt(dev_num);
  6319. } catch (Exception e) {
  6320. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  6321. e.printStackTrace();
  6322. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6323. return retStr;
  6324. }
  6325. if (nDevNo != 1) {
  6326. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  6327. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6328. return retStr;
  6329. }
  6330. retStr += " result=\"ok\">\r\n";
  6331. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6332. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6333. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6334. if (!dev_mode.equals("null")) mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  6335. retStr += " <status_map dev_num=\"1\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"1\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6336. retStr += " </service>\r\n</imap>\r\n";
  6337. }
  6338. }
  6339. else {
  6340. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6341. }
  6342. lightcmd = null;
  6343. return retStr;
  6344. } catch (Exception e) {
  6345. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  6346. e.printStackTrace();
  6347. return null;
  6348. }
  6349. }
  6350. public String iCMDProcLivingLightControl(Document ele) {
  6351. try {
  6352. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6353. String retStr = CheckiCMDProc("remote_access_livinglight");
  6354. if (retStr != null) return retStr;
  6355. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  6356. String target= "null", tid= "null", msgno= "null";
  6357. NodeList items = ele.getElementsByTagName("target");
  6358. Node item = items.item(0);
  6359. if (item != null) {
  6360. NamedNodeMap attrs = item.getAttributes();
  6361. for (int j = 0; j< attrs.getLength(); j++) {
  6362. Node attr = attrs.item(j);
  6363. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6364. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6365. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6366. }
  6367. }
  6368. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6369. if (NewServerUse()) {
  6370. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6371. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6372. }
  6373. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  6374. if (bSmartLightAsNormalLight) {
  6375. if (mSdb_LivingRoomLightAPI != null) {
  6376. mSdb_LivingRoomLightAPI.Refresh();
  6377. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+ lightcmd.devnum +"\" unit_cnt=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\"/>\r\n";
  6378. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  6379. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mSdb_LivingRoomLightAPI.data.Data.LedLight[i].Data.OnOff ? "on" : "off");
  6380. }
  6381. retStr+=" </service>\r\n</imap>\r\n";
  6382. }
  6383. else {
  6384. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  6385. }
  6386. }
  6387. else {
  6388. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  6389. if (lightCTR.Refresh(false)==0) {
  6390. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+ lightcmd.devnum +"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  6391. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  6392. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  6393. }
  6394. retStr+=" </service>\r\n</imap>\r\n";
  6395. }
  6396. else {
  6397. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  6398. }
  6399. }
  6400. }
  6401. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  6402. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  6403. boolean OnOff = false;
  6404. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6405. if (bSmartLightAsNormalLight) {
  6406. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  6407. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  6408. if (ret >= 0) {
  6409. ret = mSdb_LivingRoomLightAPI.Refresh();
  6410. if (ret >= 0) {
  6411. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\"/>\r\n";
  6412. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  6413. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mSdb_LivingRoomLightAPI.data.Data.LedLight[i].Data.OnOff ? "on" : "off");
  6414. }
  6415. retStr += " </service>\r\n</imap>\r\n";
  6416. } else {
  6417. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6418. }
  6419. }
  6420. else {
  6421. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6422. }
  6423. }
  6424. else {
  6425. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  6426. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  6427. if (ret >= 0) {
  6428. ret = mSdb_LivingRoomLightAPI.Refresh();
  6429. if (ret >= 0) {
  6430. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\"/>\r\n";
  6431. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  6432. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mSdb_LivingRoomLightAPI.data.Data.LedLight[i].Data.OnOff ? "on" : "off");
  6433. }
  6434. retStr += " </service>\r\n</imap>\r\n";
  6435. } else {
  6436. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6437. }
  6438. }
  6439. else {
  6440. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6441. }
  6442. }
  6443. }
  6444. else {
  6445. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  6446. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  6447. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  6448. if (ret >= 0) {
  6449. ret = lightCTR.Refresh(false);
  6450. if (ret >= 0) {
  6451. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  6452. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  6453. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  6454. }
  6455. retStr += " </service>\r\n</imap>\r\n";
  6456. } else {
  6457. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6458. }
  6459. }
  6460. else {
  6461. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6462. }
  6463. }
  6464. }
  6465. else {
  6466. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6467. }
  6468. }
  6469. else {
  6470. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6471. }
  6472. lightcmd = null;
  6473. return retStr;
  6474. } catch (Exception e) {
  6475. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  6476. e.printStackTrace();
  6477. return null;
  6478. }
  6479. }
  6480. public String iCMDProc_I_LightControl(Document ele) {
  6481. try {
  6482. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6483. String retStr = CheckiCMDProc("remote_access_livinglight");
  6484. if (retStr != null) return retStr;
  6485. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  6486. String target= "null", tid= "null", msgno= "null";
  6487. NodeList items = ele.getElementsByTagName("target");
  6488. Node item = items.item(0);
  6489. if (item != null) {
  6490. NamedNodeMap attrs = item.getAttributes();
  6491. for (int j = 0; j< attrs.getLength(); j++) {
  6492. Node attr = attrs.item(j);
  6493. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6494. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6495. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6496. }
  6497. }
  6498. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6499. if (NewServerUse()) {
  6500. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6501. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6502. }
  6503. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  6504. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  6505. if (lightCTR.Refresh(false)==0) {
  6506. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  6507. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  6508. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  6509. }
  6510. retStr+=" </service>\r\n</imap>\r\n";
  6511. }
  6512. else {
  6513. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6514. }
  6515. }
  6516. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  6517. if((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  6518. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  6519. int result = -999;
  6520. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  6521. result = lightCTR.LightProgramControl((byte)num, (byte)1);
  6522. }
  6523. else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  6524. result = lightCTR.LightProgramControl((byte)num, (byte)0);
  6525. }
  6526. if (result >= 0) {
  6527. // 제어 성공
  6528. try { Thread.sleep(1000);} catch (Exception e) {e.printStackTrace();}
  6529. lightCTR.Refresh(false);
  6530. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  6531. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  6532. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  6533. }
  6534. retStr+=" </service>\r\n</imap>";
  6535. }
  6536. else {
  6537. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  6538. }
  6539. }
  6540. else {
  6541. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  6542. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  6543. if (lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on")?true:false)==0) {
  6544. try { Thread.sleep(1000);} catch (Exception e) {e.printStackTrace();}
  6545. lightCTR.Refresh(false);
  6546. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  6547. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  6548. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  6549. }
  6550. retStr+=" </service>\r\n</imap>\r\n";
  6551. }
  6552. else {
  6553. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  6554. }
  6555. }
  6556. }
  6557. else {
  6558. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  6559. }
  6560. lightcmd = null;
  6561. return retStr;
  6562. } catch (Exception e) {
  6563. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  6564. e.printStackTrace();
  6565. return null;
  6566. }
  6567. }
  6568. public String iCMDProcGASControl(Element ele) {
  6569. try {
  6570. String target= "null", tid= "null", msgno= "null", devnum = "null", ctraction = "null", valvestatus = "null";
  6571. String strResult = CheckiCMDProc("remote_access_gas");
  6572. if (strResult != null) return strResult;
  6573. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  6574. NodeList items = ele.getElementsByTagName("target");
  6575. Node item = items.item(0);
  6576. if (item != null) {
  6577. NamedNodeMap attrs = item.getAttributes();
  6578. for (int j = 0; j< attrs.getLength(); j++) {
  6579. Node attr = attrs.item(j);
  6580. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6581. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6582. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6583. }
  6584. }
  6585. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6586. if (NewServerUse()) {
  6587. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  6588. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6589. }
  6590. NodeList itemsParam = ele.getElementsByTagName("params");
  6591. Node itemParam = itemsParam.item(0);
  6592. if (itemParam != null) {
  6593. NamedNodeMap attrsParam = itemParam.getAttributes();
  6594. for (int j = 0; j < attrsParam.getLength(); j++) {
  6595. Node attr = attrsParam.item(j);
  6596. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  6597. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  6598. //unitnum = attr.getNodeValue();
  6599. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) ctraction = attr.getNodeValue();
  6600. }
  6601. }
  6602. NodeList itemsaction = ele.getElementsByTagName("action");
  6603. Node itemaction = itemsaction.item(0);
  6604. Node text = itemaction.getFirstChild();
  6605. String actionTXT = text.getNodeValue();
  6606. GasAPI GasValveCTR = mWallPadAPI.Get_GasController();
  6607. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  6608. actionTXT = trimquotation(actionTXT);
  6609. if (actionTXT.equalsIgnoreCase("status")) {
  6610. // 가스밸브 상태 조회
  6611. int ret = GasValveCTR.Refresh((byte)0, false);
  6612. if (ret < 0) {
  6613. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  6614. return strResult;
  6615. }
  6616. if (GasValveCTR.data.DeviceCnt == 2) {
  6617. GasValveCTR.Refresh((byte)1, false);
  6618. }
  6619. byte GasStatus = GasAPI.GASSTATUS.Close;
  6620. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  6621. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  6622. GasStatus = GasAPI.GASSTATUS.Operation;
  6623. break;
  6624. }
  6625. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  6626. GasStatus = GasAPI.GASSTATUS.Open;
  6627. break;
  6628. }
  6629. }
  6630. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  6631. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  6632. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  6633. else valvestatus = "unknown";
  6634. }
  6635. else if (actionTXT.equalsIgnoreCase("control")) {
  6636. // 가스밸브 콘트롤
  6637. int ret = GasValveCTR.SetClose((byte)0xFF);
  6638. if (ret < 0) {
  6639. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  6640. return strResult;
  6641. }
  6642. ret = GasValveCTR.Refresh((byte)0, false);
  6643. if (ret < 0) {
  6644. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  6645. return strResult;
  6646. }
  6647. if (GasValveCTR.data.DeviceCnt == 2) {
  6648. GasValveCTR.Refresh((byte)1, false);
  6649. }
  6650. byte GasStatus = GasAPI.GASSTATUS.Close;
  6651. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  6652. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  6653. GasStatus = GasAPI.GASSTATUS.Operation;
  6654. break;
  6655. }
  6656. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  6657. GasStatus = GasAPI.GASSTATUS.Open;
  6658. break;
  6659. }
  6660. }
  6661. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  6662. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  6663. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  6664. else valvestatus = "unknown";
  6665. }
  6666. else {
  6667. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  6668. return strResult;
  6669. }
  6670. strResult += "\"ok\" >\r\n";
  6671. strResult += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  6672. strResult += " <action>\""+actionTXT+"\"</action>\r\n";
  6673. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  6674. strResult += " <status_info unit_num=\"gas1\" unit_status=\""+valvestatus+"\"/>\r\n";
  6675. strResult += " </service>\r\n";
  6676. strResult += "</imap> ";
  6677. return strResult;
  6678. } catch (Exception e) {
  6679. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  6680. e.printStackTrace();
  6681. return null;
  6682. }
  6683. }
  6684. private String iCMDProcLightBatchControl(Element ele) {
  6685. try {
  6686. String target= "null", tid= "null", msgno= "null", ctraction = "null", ilgalstatus = "null";
  6687. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  6688. if (retStr != null) return retStr;
  6689. NodeList items = ele.getElementsByTagName("target");
  6690. Node item = items.item(0);
  6691. if (item != null) {
  6692. NamedNodeMap attrs = item.getAttributes();
  6693. for (int j = 0; j < attrs.getLength(); j++) {
  6694. Node attr = attrs.item(j);
  6695. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6696. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6697. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6698. }
  6699. }
  6700. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6701. if (NewServerUse()) {
  6702. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6703. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6704. }
  6705. NodeList itemsParam = ele.getElementsByTagName("params");
  6706. Node itemParam = itemsParam.item(0);
  6707. if (itemParam != null) {
  6708. NamedNodeMap attrsParam = itemParam.getAttributes();
  6709. for (int j = 0; j < attrsParam.getLength(); j++) {
  6710. Node attr = attrsParam.item(j);
  6711. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  6712. ctraction = attr.getNodeValue();
  6713. }
  6714. }
  6715. }
  6716. NodeList itemsaction = ele.getElementsByTagName("action");
  6717. Node itemaction = itemsaction.item(0);
  6718. Node text = itemaction.getFirstChild();
  6719. String actionTXT = text.getNodeValue();
  6720. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  6721. actionTXT = trimquotation(actionTXT);
  6722. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  6723. if (actionTXT.equalsIgnoreCase("status")) {
  6724. // 일괄소등 상태 조회
  6725. int ret = mWallPadAPI.GetBatchSwitchStatus();
  6726. if (ret > 1) {
  6727. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  6728. return retStr;
  6729. }
  6730. if (ret == 0) {
  6731. ilgalstatus = "on";
  6732. }
  6733. else if (ret == 1) {
  6734. ilgalstatus = "off";
  6735. }
  6736. else {
  6737. ilgalstatus = "error";
  6738. }
  6739. }
  6740. else if (actionTXT.equalsIgnoreCase("control")) {
  6741. // 일괄소등 제어
  6742. int ret = -1;
  6743. int status = -1;
  6744. if(ctraction.equals("on") == true) {
  6745. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6746. status = 0;
  6747. }
  6748. else if(ctraction.equals("off") == true) {
  6749. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  6750. status = 1;
  6751. }
  6752. if (ret < 0) {
  6753. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  6754. return retStr;
  6755. }
  6756. if (status == 0) {
  6757. ilgalstatus = "on";
  6758. }
  6759. else if (status == 1) {
  6760. ilgalstatus = "off";
  6761. }
  6762. else {
  6763. ilgalstatus = "error";
  6764. }
  6765. }
  6766. else {
  6767. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  6768. return retStr;
  6769. }
  6770. retStr += "\"ok\" >\r\n";
  6771. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  6772. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  6773. retStr += " <status_info unit_status=\""+ilgalstatus+"\"/>\r\n </service>\r\n</imap> ";
  6774. return retStr;
  6775. } catch (Exception e) {
  6776. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  6777. e.printStackTrace();
  6778. return null;
  6779. }
  6780. }
  6781. private String iCMDProcEntireLightControl(Document ele) {
  6782. try {
  6783. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  6784. if (retStr != null) return retStr;
  6785. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  6786. String sDong = null;
  6787. String sHo = null;
  6788. String sDevice_Num = null;
  6789. String sSelCtrl_Action = null;
  6790. String sUnselCtrl_Action = null;
  6791. NodeList items = ele.getElementsByTagName("home_info");
  6792. Node item = items.item(0);
  6793. NamedNodeMap attrsParam = item.getAttributes();
  6794. for (int i = 0; i < attrsParam.getLength(); i++) {
  6795. Node attr = attrsParam.item(i);
  6796. if (attr.getNodeName().equalsIgnoreCase("dong"))
  6797. sDong = trimquotation(attr.getNodeValue());
  6798. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  6799. sHo = trimquotation(attr.getNodeValue());
  6800. }
  6801. WallpadStatusData DBMGR = null;
  6802. DBMGR = new WallpadStatusData(getApplicationContext());
  6803. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  6804. DBMGR.closeDB();
  6805. if (mSdb_LivingRoomLightAPI == null) {
  6806. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  6807. retStr += " result=\"fail\" >\r\n";
  6808. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6809. retStr += " </service>\r\n</imap>";
  6810. return retStr;
  6811. }
  6812. if (mSdbAPI == null) {
  6813. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  6814. retStr += " result=\"fail\" >\r\n";
  6815. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6816. retStr += " </service>\r\n</imap>";
  6817. return retStr;
  6818. }
  6819. if ((sDong.equalsIgnoreCase(addc.Dong)) && (sHo.equalsIgnoreCase(addc.Ho))) {
  6820. items = ele.getElementsByTagName("sel_ctrlinfo");
  6821. item = items.item(0);
  6822. attrsParam = item.getAttributes();
  6823. for (int i = 0; i < attrsParam.getLength(); i++) {
  6824. Node attr = attrsParam.item(i);
  6825. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  6826. sDevice_Num = trimquotation(attr.getNodeValue());
  6827. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6828. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  6829. }
  6830. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  6831. int result = -1; // 조명 제어 결과
  6832. boolean bLivingLightSel = false; // 거실조명 선택 여부
  6833. // ============================== 선택된 조명 ==============================
  6834. String[] sel_devNum = null;
  6835. if (sDevice_Num.contains("light")) {
  6836. if (sDevice_Num.contains("/")) sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  6837. else {
  6838. sel_devNum = new String[1];
  6839. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  6840. }
  6841. }
  6842. if (sel_devNum == null) sel_devNum = new String[0];
  6843. for (int i = 0; i < sel_devNum.length; i++) {
  6844. if (sel_devNum[i].equals("1")) {
  6845. bLivingLightSel = true;
  6846. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  6847. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  6848. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  6849. } else {
  6850. int nColor = 0;
  6851. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  6852. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  6853. if (nColor > 0) {
  6854. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  6855. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  6856. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  6857. }
  6858. }
  6859. // 거실조명 제어 결과
  6860. if (result < 0) {
  6861. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  6862. retStr += " result=\"fail\" >\r\n";
  6863. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6864. retStr += " </service>\r\n</imap>";
  6865. return retStr;
  6866. }
  6867. } else {
  6868. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  6869. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  6870. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  6871. } else {
  6872. int nColor = 0;
  6873. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  6874. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  6875. if (nColor > 0) {
  6876. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  6877. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  6878. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  6879. }
  6880. }
  6881. // 그 외 방 조명 제어 결과
  6882. if (result < 0) {
  6883. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  6884. retStr += " result=\"fail\" >\r\n";
  6885. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6886. retStr += " </service>\r\n</imap>";
  6887. return retStr;
  6888. }
  6889. }
  6890. }
  6891. // ============================== 선택안된 조명 ==============================
  6892. items = ele.getElementsByTagName("unsel_ctrlinfo");
  6893. item = items.item(0);
  6894. attrsParam = item.getAttributes();
  6895. for (int i = 0; i < attrsParam.getLength(); i++) {
  6896. Node attr = attrsParam.item(i);
  6897. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6898. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  6899. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  6900. }
  6901. if (!bLivingLightSel) {
  6902. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  6903. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  6904. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  6905. } else {
  6906. int nColor = 0;
  6907. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  6908. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  6909. if (nColor > 0) {
  6910. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  6911. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  6912. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  6913. }
  6914. }
  6915. if (result < 0) {
  6916. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  6917. retStr += " result=\"fail\" >\r\n";
  6918. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6919. retStr += " </service>\r\n</imap>";
  6920. return retStr;
  6921. }
  6922. }
  6923. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  6924. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  6925. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  6926. unsel_devNum.add(i + 1);
  6927. }
  6928. for (int i = 0; i < unsel_devNum.size(); i++) {
  6929. for (int j = 0; j < sel_devNum.length; j++) {
  6930. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1) unsel_devNum.remove(i);
  6931. }
  6932. }
  6933. for (int i = 0; i < unsel_devNum.size(); i++) {
  6934. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) -1) + "]");
  6935. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  6936. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  6937. } else {
  6938. int nColor = 0;
  6939. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  6940. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  6941. if (nColor > 0) {
  6942. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  6943. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  6944. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  6945. }
  6946. }
  6947. if (result < 0) {
  6948. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  6949. retStr += " result=\"fail\" >\r\n";
  6950. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6951. retStr += " </service>\r\n</imap>";
  6952. return retStr;
  6953. }
  6954. }
  6955. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  6956. retStr += " result=\"ok\">\r\n";
  6957. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6958. retStr += " </service>\r\n</imap>";
  6959. return retStr;
  6960. } else {
  6961. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  6962. retStr += " result=\"fail\" >\r\n";
  6963. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  6964. retStr += " </service>\r\n</imap>";
  6965. return retStr;
  6966. }
  6967. } catch (Exception e) {
  6968. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  6969. e.printStackTrace();
  6970. return null;
  6971. }
  6972. }
  6973. // 월패드에 원격제어 사용 여부를 확인하다.
  6974. private String CheckiCMDProc(String CMDStr) {
  6975. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  6976. try {
  6977. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  6978. mWallpadStatusData.closeDB();
  6979. if (!bRemoteCtrlEnabled) {
  6980. String retXML = XMLHeader +"<service type=\"reply\" name=\""+CMDStr+"\" result=\"deny\">\r\n"+
  6981. " </service>\r\n</imap>";
  6982. return retXML;
  6983. }
  6984. return null;
  6985. } catch (Exception e) {
  6986. mWallpadStatusData.closeDB();
  6987. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  6988. e.printStackTrace();
  6989. return null;
  6990. }
  6991. }
  6992. //메인으로 공지 해야 할 노티 사항을 처리
  6993. public String ProcEventNotify(Element ele) {
  6994. try {
  6995. NodeList items = ele.getElementsByTagName("event");
  6996. Node item = items.item(0);
  6997. Node text = item.getFirstChild();
  6998. String eventTXT = trimquotation(text.getNodeValue());
  6999. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  7000. // 새로운 공지사항 존재
  7001. wakeupLCD();
  7002. Intent intent = new Intent();
  7003. intent.setAction(define.NOTIFY_ACNAME);
  7004. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  7005. getApplicationContext().sendBroadcast(intent);
  7006. }
  7007. else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  7008. // 택배 도착
  7009. wakeupLCD();
  7010. Intent intent = new Intent();
  7011. intent.setAction(define.NOTIFY_ACNAME);
  7012. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  7013. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  7014. intent.putExtra("ITEM",1);
  7015. getApplicationContext().sendBroadcast(intent);
  7016. }
  7017. else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  7018. // 택배 반출
  7019. wakeupLCD();
  7020. Intent intent = new Intent();
  7021. intent.setAction(define.NOTIFY_ACNAME);
  7022. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  7023. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  7024. intent.putExtra("ITEM",0);
  7025. getApplicationContext().sendBroadcast(intent);
  7026. }
  7027. else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  7028. // 등록된 차량 도착
  7029. wakeupLCD();
  7030. // 팝업을 띄우도록 하자
  7031. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  7032. Common.CarInOoutEventBR(getApplicationContext(),"car_in", "");
  7033. }
  7034. else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  7035. // 내려가는 방향의 엘리베이터가 도착함
  7036. if (ElevatorDown != null) {
  7037. ElevatorDown.TimeOutCancel();
  7038. ElevatorDown.ClearElevator();
  7039. }
  7040. Intent intent = new Intent();
  7041. intent.setAction(define.NOTIFY_ACNAME);
  7042. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  7043. getApplicationContext().sendBroadcast(intent);
  7044. }
  7045. else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  7046. // 올라가는 방향의 엘리베이터가 도착함
  7047. if (ElevatorUp != null) {
  7048. ElevatorUp.TimeOutCancel();
  7049. ElevatorUp.ClearElevator();
  7050. }
  7051. Intent intent = new Intent();
  7052. intent.setAction(define.NOTIFY_ACNAME);
  7053. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  7054. getApplicationContext().sendBroadcast(intent);
  7055. }
  7056. else {
  7057. }
  7058. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  7059. "<event> \""+eventTXT+"\" </event>\r\n" + " </service>\r\n </imap> ";
  7060. return returnStr;
  7061. } catch (Exception e) {
  7062. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  7063. e.printStackTrace();
  7064. return null;
  7065. }
  7066. }
  7067. public String GetAttributeVal(Node node, String attname) {
  7068. NamedNodeMap attrs = node.getAttributes();
  7069. for (int j = 0; j < attrs.getLength(); j++) {
  7070. Node attr = attrs.item(j);
  7071. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  7072. }
  7073. return null;
  7074. }
  7075. public class imageFileFilter implements FilenameFilter {
  7076. public boolean accept(File dir, String name ) {
  7077. if (name.endsWith(".jpg") || name.endsWith(".JPG") || name.endsWith(".jpeg") || name.endsWith(".JPEG")||name.endsWith(".png")||name.endsWith(".PNG")||name.endsWith(".gif")||name.endsWith(".GIF")) return true;
  7078. else return false;
  7079. }
  7080. }
  7081. public String ProcCheckEpiceUpload(Document ele) {
  7082. try {
  7083. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  7084. NodeList items = ele.getElementsByTagName("filename");
  7085. Node item = items.item(0);
  7086. Node text = item.getFirstChild();
  7087. String filename = trimquotation(text.getNodeValue());
  7088. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  7089. String duplicate = null;
  7090. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  7091. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  7092. if (!dirInternal.exists()) dirInternal.mkdir();
  7093. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  7094. AddressSet addr = SetData.getAddressMGR();
  7095. if (!dirInternal.exists()) {
  7096. returnStr+=" <homeaddr dong=\""+addr.Dong+"\" ho=\""+addr.Ho+"\"/>\r\n"+
  7097. " <pics space=\""+define.MAX_ALBUM_PICTURE+"\" total=\""+define.MAX_ALBUM_PICTURE+"\" available=\"0\" duplicate=\"new\"/>\r\n"+
  7098. " </service>\r\n</imap>";
  7099. return returnStr;
  7100. }
  7101. imageFileFilter jpegfilter = new imageFileFilter();
  7102. String[] subfile = dirInternal.list(jpegfilter);
  7103. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  7104. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  7105. if (checkFile.exists()) duplicate = "exist";
  7106. else duplicate = "new";
  7107. returnStr+=" <homeaddr dong=\""+addr.Dong+"\" ho=\""+addr.Ho+"\"/>\r\n"+
  7108. " <pics space=\""+define.MAX_ALBUM_PICTURE+"\" total=\""+subfile.length+"\" available=\""+(define.MAX_ALBUM_PICTURE-subfile.length)+"\" duplicate=\""+duplicate+"\"/>\r\n"+
  7109. " </service>\r\n</imap>";
  7110. SetData.closeDB();
  7111. return returnStr;
  7112. } catch (Exception e) {
  7113. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  7114. e.printStackTrace();
  7115. return null;
  7116. }
  7117. }
  7118. private void playNotifySound(int nSoundID) {
  7119. try {
  7120. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  7121. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  7122. if (getCompareBSPVersion()) {
  7123. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  7124. }
  7125. else {
  7126. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  7127. }
  7128. boolean NeedPlay = false;
  7129. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  7130. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  7131. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  7132. }
  7133. else {
  7134. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  7135. }
  7136. SetData.closeDB();
  7137. if (NeedPlay) Sound().PlayMent(nSoundID);
  7138. } catch (Exception e) {
  7139. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  7140. e.printStackTrace();
  7141. }
  7142. }
  7143. private void wakeupLCD() {
  7144. try {
  7145. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  7146. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  7147. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  7148. mIOInterface.ctrlLcdWakeUp();
  7149. } catch (Exception e) {
  7150. Log.e(TAG, "[Exception] wakeupLCD()");
  7151. e.printStackTrace();
  7152. }
  7153. }
  7154. /**
  7155. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  7156. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  7157. * Jeff, 2020.09.07
  7158. * @return true: LCD backlight On, false: LCD backlight Off
  7159. */
  7160. public boolean checkLCDOnByCMD() {
  7161. try {
  7162. Runtime mRuntime = Runtime.getRuntime();
  7163. Process mProcess;
  7164. String cmd = "getprop persist.sys.lcdcon";
  7165. mProcess = mRuntime.exec(cmd);
  7166. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  7167. String line;
  7168. String strResult = null;
  7169. while ((line = br.readLine()) != null) {
  7170. strResult = line;
  7171. }
  7172. if (strResult.equals("0")) {
  7173. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  7174. return true;
  7175. }
  7176. else if (strResult.equals("1")) {
  7177. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  7178. return false;
  7179. }
  7180. else {
  7181. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  7182. return false;
  7183. }
  7184. } catch (Exception e) {
  7185. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  7186. e.printStackTrace();
  7187. return false;
  7188. }
  7189. }
  7190. /**
  7191. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  7192. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  7193. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  7194. */
  7195. public boolean getCompareBSPVersion() {
  7196. try {
  7197. StringBuilder strBSPVersion = new StringBuilder();
  7198. StringBuffer sysInfoBuffer = new StringBuffer();
  7199. sysInfoBuffer.append(Build.DISPLAY);
  7200. strBSPVersion.append(sysInfoBuffer.toString());
  7201. String result = strBSPVersion.toString();
  7202. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  7203. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  7204. Date date = simpleDateFormat.parse(result);
  7205. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  7206. if (date.compareTo(standardDate) >= 0) {
  7207. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  7208. return true;
  7209. }
  7210. } catch (Exception e) {
  7211. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  7212. e.printStackTrace();
  7213. }
  7214. return false;
  7215. }
  7216. public String ProcUpdateWeather(Document ele) {
  7217. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  7218. String nowloc ="";
  7219. String nowlcode="";
  7220. String nowdate="";
  7221. String nowtext="";
  7222. String nowcode="";
  7223. String nowtemp="";
  7224. String nowlo = "", nowhigh = "";
  7225. NodeList items = ele.getElementsByTagName("now");
  7226. Node item = items.item(0);
  7227. if (item == null)
  7228. return resultstr += "\"fail\"/> \r\n </imap>";
  7229. NamedNodeMap attrsParam = item.getAttributes();
  7230. for (int j = 0; j < attrsParam.getLength(); j++) {
  7231. Node attr = attrsParam.item(j);
  7232. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  7233. else if (attr.getNodeName().equalsIgnoreCase("loc_code")) nowlcode = attr.getNodeValue();
  7234. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  7235. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  7236. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  7237. else if (attr.getNodeName().equalsIgnoreCase("temperature")) nowtemp = attr.getNodeValue();
  7238. }
  7239. items = ele.getElementsByTagName("week");
  7240. String weekdate="", weektext="", weekcode="", weeklow="", weekhigh="", weekam="", weekpm = "";
  7241. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  7242. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  7243. Weathertbl.InitWeatherTable();
  7244. for (int i = 0; i < items.getLength(); i++) {
  7245. item = items.item(i);
  7246. attrsParam = item.getAttributes();
  7247. for (int j = 0; j < attrsParam.getLength(); j++) {
  7248. Node attr = attrsParam.item(j);
  7249. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  7250. else if (attr.getNodeName().equalsIgnoreCase("text")) weektext = attr.getNodeValue();
  7251. else if (attr.getNodeName().equalsIgnoreCase("code")) weekcode = attr.getNodeValue();
  7252. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  7253. else if (attr.getNodeName().equalsIgnoreCase("high")) weekhigh = attr.getNodeValue();
  7254. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  7255. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  7256. }
  7257. if ( i == 0) {
  7258. nowlo = weeklow;
  7259. nowhigh = weekhigh;
  7260. }
  7261. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  7262. }
  7263. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  7264. Intent intent = new Intent();
  7265. intent.setAction(define.NOTIFY_ACNAME);
  7266. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  7267. intent.putExtra(define.NOTIBR_CONTENT, nowcode+define.DEVCTR_DATA_SPLITER+nowlo+define.DEVCTR_DATA_SPLITER+nowhigh);
  7268. getApplicationContext().sendBroadcast(intent);
  7269. String WeatherVer = nowdate.substring(0,4)+"."+nowdate.substring(4,6)+"."+nowdate.substring(6,8)+"."+nowdate.substring(8,10);
  7270. DBMGR.SetWeatherVer(WeatherVer+define.DEVCTR_DATA_SPLITER+nowloc+define.DEVCTR_DATA_SPLITER+nowlcode+define.DEVCTR_DATA_SPLITER+nowcode+define.DEVCTR_DATA_SPLITER+nowtext+define.DEVCTR_DATA_SPLITER+nowtemp+define.DEVCTR_DATA_SPLITER+nowlo+define.DEVCTR_DATA_SPLITER+nowhigh);
  7271. DBMGR.closeDB();
  7272. return resultstr += "\"ok\"/> \r\n </imap>";
  7273. }
  7274. //iMAP update_news 처리
  7275. public String ProcUpdateNews(Document ele) {
  7276. NodeList items = ele.getElementsByTagName("ver_news");
  7277. Node item = items.item(0);
  7278. String strNewsVer = item.getTextContent();
  7279. strNewsVer = trimquotation(strNewsVer);
  7280. String retXML = XMLHeader+"<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n"+
  7281. " <ver_news>\""+strNewsVer+"\"</ver_news>\r\n<service/>\r\n</imap>";
  7282. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  7283. String NotiVer = DBMGR.GetNoticeVer();
  7284. int noticeCNT = DBMGR.GetNoticeCNT();
  7285. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  7286. String[] spdt = strNewsVer.split("[.]");
  7287. noticeCNT+=Integer.parseInt(spdt[spdt.length-1]);
  7288. }
  7289. else {
  7290. String[] spdt = strNewsVer.split("[.]");
  7291. int newcnt = Integer.parseInt(spdt[spdt.length-1]);
  7292. spdt = NotiVer.split("[.]");
  7293. newcnt-=Integer.parseInt(spdt[spdt.length-1]);
  7294. noticeCNT+=newcnt;
  7295. }
  7296. Log.d(TAG, "[ProcUpdateNews] News Version : " + strNewsVer);
  7297. DBMGR.SetNoticeVer(strNewsVer);
  7298. DBMGR.SetNoticeCNT(noticeCNT);
  7299. DBMGR.closeDB();
  7300. if (NotiVer.compareTo(strNewsVer) != 0) {
  7301. Intent intent = new Intent();
  7302. intent.setAction(define.NOTIFY_ACNAME);
  7303. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  7304. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  7305. getApplicationContext().sendBroadcast(intent);
  7306. }
  7307. return retXML;
  7308. }
  7309. //iMAP check_lobby_passwd 처리
  7310. public String CheckPassword(Document doc)
  7311. {
  7312. NodeList items = doc.getElementsByTagName("inpasswd");
  7313. Node item = items.item(0);
  7314. Node text = item.getFirstChild();
  7315. String passwd = trimquotation(text.getNodeValue());
  7316. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  7317. String settedpasswd = DBMGR.GetUserPW();
  7318. DBMGR.closeDB();
  7319. String retString = XMLHeader;
  7320. Common.DebugLog("================ CheckPassword ================ ");
  7321. Common.DebugLog("Saved Password :"+ settedpasswd);
  7322. Common.DebugLog("Input Password :"+ passwd);
  7323. Common.DebugLog("================ CheckPassword ================ ");
  7324. if (settedpasswd.equals(passwd))
  7325. {
  7326. retString+="<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  7327. }
  7328. else
  7329. {
  7330. retString+="<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>"+passwd+"</wrongpasswd>\r\n</service>";
  7331. }
  7332. retString+="</imap>";
  7333. return retString;
  7334. }
  7335. //schedule_renew 처리
  7336. protected String ProcSchduleRenew(Document doc)
  7337. {
  7338. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n "+
  7339. "<homeaddr dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" /> \r\n </service> \r\n </imap>";
  7340. WallpadScheduleData schedulDB=null;
  7341. try {
  7342. NodeList items = doc.getElementsByTagName("renew_info");
  7343. schedulDB = new WallpadScheduleData(getApplicationContext());
  7344. for(int i= 0 ;i < items.getLength();i++)
  7345. {
  7346. Node item = items.item(i);
  7347. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  7348. NamedNodeMap attrsParam = item.getAttributes();
  7349. String Type="none";
  7350. for(int j=0; j< attrsParam.getLength();j++)
  7351. {
  7352. Node attr = attrsParam.item(j);
  7353. String name = attr.getNodeName();
  7354. String Val = attr.getNodeValue();
  7355. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  7356. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  7357. else if (name.equalsIgnoreCase("rn_type"))
  7358. Type = Val;
  7359. else if (name.equalsIgnoreCase("rn_t_type"))
  7360. SCdata.inqttype = Val;
  7361. else if (name.equalsIgnoreCase("rn_c_type"))
  7362. SCdata.inqctype = Val;
  7363. else if (name.equalsIgnoreCase("rn_a_type"))
  7364. SCdata.inqatype = Val;
  7365. else if (name.equalsIgnoreCase("rn_i_type"))
  7366. SCdata.inqitype = Val;
  7367. else if (name.equalsIgnoreCase("rn_year"))
  7368. SCdata.inqyear = Integer.parseInt(Val);
  7369. else if (name.equalsIgnoreCase("rn_month"))
  7370. SCdata.inqmonth = Integer.parseInt(Val);
  7371. else if (name.equalsIgnoreCase("rn_day"))
  7372. SCdata.inqday = Integer.parseInt(Val);
  7373. else if (name.equalsIgnoreCase("rn_hour"))
  7374. SCdata.inqhour = Integer.parseInt(Val);
  7375. else if (name.equalsIgnoreCase("rn_message"))
  7376. SCdata.inqmsg = Val;
  7377. }
  7378. if (Type.equals("delete"))
  7379. {
  7380. schedulDB.DeleteSchedule(SCdata);
  7381. }
  7382. else if (Type.equals("add"))
  7383. {
  7384. schedulDB.AddSchedule(SCdata);
  7385. }
  7386. else if (Type.equals("change"))
  7387. {
  7388. schedulDB.UpdateSchedule(SCdata);
  7389. }
  7390. }
  7391. schedulDB.closeDB();
  7392. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  7393. // Intent intent = new Intent();
  7394. // intent.setAction(define.NOTIFY_ACNAME);
  7395. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  7396. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  7397. // getApplicationContext().sendBroadcast(intent);
  7398. }
  7399. catch (Exception e)
  7400. {
  7401. e.printStackTrace();
  7402. if (schedulDB != null) schedulDB.closeDB();
  7403. }
  7404. return retXML;
  7405. }
  7406. //schedule_inquiry 처리
  7407. @SuppressWarnings("unused")
  7408. public String ProcSchduleInquiry(Document doc)
  7409. {
  7410. WallpadScheduleData schedulDB=null;
  7411. String retXML;
  7412. int QYear = 0;
  7413. int QMonth = 0;
  7414. try {
  7415. NodeList items = doc.getElementsByTagName("inquiry_time");
  7416. schedulDB = new WallpadScheduleData(getApplicationContext());
  7417. Node item = items.item(0);
  7418. NamedNodeMap attrsParam = item.getAttributes();
  7419. for(int j=0; j< attrsParam.getLength();j++)
  7420. {
  7421. Node attr = attrsParam.item(j);
  7422. if (attr.getNodeName().equalsIgnoreCase("year"))
  7423. QYear = Integer.parseInt(attr.getNodeValue());
  7424. else if (attr.getNodeName().equalsIgnoreCase("month"))
  7425. QMonth = Integer.parseInt(attr.getNodeValue());
  7426. }
  7427. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  7428. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  7429. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  7430. " <inquiry_time year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  7431. " <inquiry_count>"+SCData.size()+"</inquiry_count>\r\n";
  7432. if(SCData != null)
  7433. {
  7434. if (SCData.size()>0)
  7435. {
  7436. for(int i = 0; i<SCData.size(); i++)
  7437. {
  7438. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  7439. retXML+="<renew_info inq_num=\""+(i+1)+"\" inq_t_type=\""+SCINQDATA.inqttype+"\" inq_c_type=\""+SCINQDATA.inqctype+"\" inq_a_type=\""+SCINQDATA.inqatype+"\" inq_i_type=\""+SCINQDATA.inqitype+"\" inq_year=\""+
  7440. SCINQDATA.inqyear+"\" inq_month=\""+SCINQDATA.inqmonth+"\" inq_day=\""+SCINQDATA.inqday+"\" inq_hour=\""+SCINQDATA.inqhour+"\" inq_message=\""+SCINQDATA.inqmsg+"\"/>\r\n";
  7441. }
  7442. }
  7443. retXML+="</service>\r\n</imap>";
  7444. }
  7445. else
  7446. {
  7447. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  7448. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  7449. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  7450. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  7451. }
  7452. }
  7453. catch (Exception e)
  7454. {
  7455. e.printStackTrace();
  7456. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  7457. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  7458. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  7459. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  7460. }
  7461. schedulDB.closeDB();
  7462. return retXML;
  7463. }
  7464. public String ProcUpdateSchedule(Element ele, String type)
  7465. {
  7466. String retXML = "";
  7467. return retXML;
  7468. }
  7469. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  7470. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  7471. private void setDefaultLauncher() {
  7472. try
  7473. {
  7474. PackageManager pm = getPackageManager();
  7475. IntentFilter filter = new IntentFilter();
  7476. filter.addAction(Intent.ACTION_MAIN);
  7477. filter.addCategory(Intent.CATEGORY_HOME);
  7478. filter.addCategory(Intent.CATEGORY_DEFAULT);
  7479. Context context = getApplicationContext();
  7480. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  7481. ComponentName[] components = new ComponentName[] {new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  7482. pm.clearPackagePreferredActivities("com.android.launcher");
  7483. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  7484. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  7485. try{Thread.sleep(300);}catch(Exception e){e.printStackTrace();}
  7486. // 리셋코드 추가
  7487. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  7488. try {
  7489. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  7490. powerMg.reboot(null);
  7491. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  7492. } catch (Exception e) {
  7493. e.printStackTrace();
  7494. }
  7495. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  7496. } catch (Exception e) {
  7497. e.printStackTrace();
  7498. }
  7499. }
  7500. public String ProcDeviceReset(Element ele)
  7501. {
  7502. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  7503. "</imap>\r\n";
  7504. NodeList resettype = ele.getElementsByTagName("guidemap");
  7505. Node resettypeItem = resettype.item(0);
  7506. String type = GetAttributeVal(resettypeItem, "type");
  7507. if (type.equals("now"))
  7508. {
  7509. setDefaultLauncher();
  7510. Intent intent = new Intent();
  7511. intent.setAction(define.NOTIFY_ACNAME);
  7512. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  7513. getApplicationContext().sendBroadcast(intent);
  7514. }
  7515. else if (type.equals("disable"))
  7516. {
  7517. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  7518. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE,0,0 );
  7519. SetReset.closeDB();
  7520. }
  7521. else if (type.equals("week") || type.equals("month"))
  7522. {
  7523. int Resettype = type.equals("week")?WallpadStatusData.RESET_WEEK:WallpadStatusData.RESET_MONTH;
  7524. NodeList periodList = ele.getElementsByTagName("period");
  7525. Node perioditem = periodList.item(0);
  7526. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  7527. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  7528. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  7529. SetReset.SetResetSchedule(Resettype,cycle,time );
  7530. SetReset.closeDB();
  7531. }
  7532. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  7533. // Intent intent = new Intent();
  7534. // intent.setAction(define.NOTIFY_ACNAME);
  7535. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  7536. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  7537. // getApplicationContext().sendBroadcast(intent);
  7538. return retXML;
  7539. }
  7540. public String ProcDeviceLiveCheck()
  7541. {
  7542. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  7543. return retXML;
  7544. }
  7545. public String ProcPairingHdevSyncAlarm(Element ele) {
  7546. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  7547. return retXML;
  7548. }
  7549. public String ProcPairingHdevSyncSecurity(Element ele) {
  7550. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  7551. return retXML;
  7552. }
  7553. public String ProcParkInformation(Element ele) {
  7554. try {
  7555. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  7556. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  7557. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  7558. NodeList items = ele.getElementsByTagName("destination");
  7559. Node item = items.item(0);
  7560. Node text;
  7561. NamedNodeMap attrsParam = item.getAttributes();
  7562. for (int j = 0; j < attrsParam.getLength(); j++) {
  7563. Node attr = attrsParam.item(j);
  7564. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  7565. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  7566. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  7567. }
  7568. items = ele.getElementsByTagName("move_info");
  7569. item = items.item(0);
  7570. text = item.getFirstChild();
  7571. strCarMove = trimquotation(text.getNodeValue());
  7572. items = ele.getElementsByTagName("params");
  7573. item = items.item(0);
  7574. attrsParam = item.getAttributes();
  7575. for (int j = 0; j < attrsParam.getLength(); j++) {
  7576. Node attr = attrsParam.item(j);
  7577. if (attr.getNodeName().equalsIgnoreCase("car_num")) strCarNo = trimquotation(attr.getNodeValue());
  7578. else if (attr.getNodeName().equalsIgnoreCase("loc_info")) strCarLocation = trimquotation(attr.getNodeValue());
  7579. else if (attr.getNodeName().equalsIgnoreCase("message")) strMsg = trimquotation(attr.getNodeValue());
  7580. }
  7581. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  7582. try {
  7583. int iTempDong = Integer.parseInt(AddrDong);
  7584. String sTempDong = Integer.toString(iTempDong);
  7585. int iTempHo = Integer.parseInt(AddrHo);
  7586. String sTempHo = Integer.toString(iTempHo);
  7587. if ((strName.equalsIgnoreCase("homedev") == true) && (strDong.equalsIgnoreCase(sTempDong) == true) && (strHo.equalsIgnoreCase(sTempHo) == true)) {
  7588. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  7589. }
  7590. else {
  7591. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  7592. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  7593. return retXML;
  7594. }
  7595. } catch(Exception e) {
  7596. e.printStackTrace();
  7597. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  7598. return retXML;
  7599. }
  7600. //DB정보 업데이트!
  7601. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  7602. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  7603. CarDB.closeDB();
  7604. //DB정보 업데이트!
  7605. if (strCarMove.equalsIgnoreCase("in")) {
  7606. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  7607. // 팝업을 띄우도록 하자
  7608. wakeupLCD();
  7609. if (strMsg.equalsIgnoreCase("guest")) {
  7610. Intent iIntent = new Intent();
  7611. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  7612. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  7613. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  7614. getApplicationContext().sendBroadcast(iIntent);
  7615. }
  7616. else {
  7617. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  7618. }
  7619. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  7620. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  7621. }
  7622. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  7623. if (strCarMove.equalsIgnoreCase("park")) {
  7624. //주차정보 얻어오도록 intent 알림
  7625. SendGetParkingInfoIntent();
  7626. }
  7627. }
  7628. else {
  7629. //주차정보 얻어오도록 intent 알림
  7630. SendGetParkingInfoIntent();
  7631. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  7632. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  7633. }
  7634. return retXML;
  7635. } catch (Exception e) {
  7636. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  7637. e.printStackTrace();
  7638. return null;
  7639. }
  7640. }
  7641. /**
  7642. * 스마트키 이벤트 수신시 처리
  7643. * **/
  7644. public String ProcSmartKeyEvent(Element ele) {
  7645. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  7646. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  7647. String strName = null, strDong = null, strHo = null, strCnt = null;
  7648. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  7649. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  7650. NodeList items = ele.getElementsByTagName("destination");
  7651. Node item = items.item(0);
  7652. NamedNodeMap attrsParam = item.getAttributes();
  7653. for (int j = 0; j < attrsParam.getLength(); j++) {
  7654. Node attr = attrsParam.item(j);
  7655. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  7656. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  7657. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  7658. }
  7659. items = ele.getElementsByTagName("event_info");
  7660. item = items.item(0);
  7661. attrsParam = item.getAttributes();
  7662. for (int j = 0; j < attrsParam.getLength(); j++) {
  7663. Node attr = attrsParam.item(j);
  7664. if (attr.getNodeName().equalsIgnoreCase("info_cnt")) strCnt = trimquotation(attr.getNodeValue());
  7665. }
  7666. items = ele.getElementsByTagName("event");
  7667. item = items.item(0);
  7668. attrsParam = item.getAttributes();
  7669. for (int j = 0; j < attrsParam.getLength(); j++) {
  7670. Node attr = attrsParam.item(j);
  7671. if (attr.getNodeName().equalsIgnoreCase("event_type")) strEventType = trimquotation(attr.getNodeValue());
  7672. else if (attr.getNodeName().equalsIgnoreCase("trigger_type")) strEventTriggerType = trimquotation(attr.getNodeValue());
  7673. else if (attr.getNodeName().equalsIgnoreCase("uid")) strEventUID = trimquotation(attr.getNodeValue());
  7674. else if (attr.getNodeName().equalsIgnoreCase("sn")) strEventSN = trimquotation(attr.getNodeValue());
  7675. else if (attr.getNodeName().equalsIgnoreCase("sitecode")) strEventSitecode = trimquotation(attr.getNodeValue());
  7676. else if (attr.getNodeName().equalsIgnoreCase("dong")) strEventDong = trimquotation(attr.getNodeValue());
  7677. else if (attr.getNodeName().equalsIgnoreCase("ho")) strEventHo = trimquotation(attr.getNodeValue());
  7678. else if (attr.getNodeName().equalsIgnoreCase("card_num")) strEventCardNo = trimquotation(attr.getNodeValue());
  7679. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt")) strEventIssueCnt = trimquotation(attr.getNodeValue());
  7680. else if (attr.getNodeName().equalsIgnoreCase("card_type")) strEventCardType = trimquotation(attr.getNodeValue());
  7681. else if (attr.getNodeName().equalsIgnoreCase("location")) strEventLocation = trimquotation(attr.getNodeValue());
  7682. }
  7683. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  7684. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  7685. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  7686. if ((strName.equalsIgnoreCase("homedev")) && (strDong.equalsIgnoreCase(AddrDong)) && (strHo.equalsIgnoreCase(AddrHo))) {
  7687. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  7688. }
  7689. else {
  7690. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  7691. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  7692. return retXML;
  7693. }
  7694. //데이터가 null인지 확인
  7695. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  7696. return retXML;
  7697. }
  7698. //비상알람이 맞으면 아래 사항 처리
  7699. if (strEventType.equalsIgnoreCase("emergency")) {
  7700. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  7701. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  7702. wakeupLCD();
  7703. // 팝업을 띄우도록 하자
  7704. String CardNum = "";
  7705. try {
  7706. int iEvent_Dong = Integer.parseInt(strEventDong);
  7707. CardNum += String.format("%04d", iEvent_Dong);
  7708. int iEvent_Ho = Integer.parseInt(strEventHo);
  7709. CardNum += String.format("%04d", iEvent_Ho);
  7710. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  7711. CardNum += String.format("%03d", iEvent_CardNum);
  7712. } catch(Exception e) {
  7713. e.printStackTrace();
  7714. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  7715. return retXML;
  7716. }
  7717. Intent iIntent = new Intent();
  7718. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  7719. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  7720. iIntent.putExtra("LOCATION", strEventLocation);
  7721. iIntent.putExtra("CARD_NO", CardNum);
  7722. getApplicationContext().sendBroadcast(iIntent);
  7723. }
  7724. }
  7725. }
  7726. return retXML;
  7727. }
  7728. public String ProcParkInformation_cham_upis(Element ele)
  7729. {
  7730. Log.d(TAG, "ProcParkInformation_cham_upis START");
  7731. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  7732. String infoName = null;
  7733. String infoDong = null;
  7734. String infoHo = null;
  7735. String infoCarMove = null;
  7736. String infoCarnum = null;
  7737. String infoCarLocation = null;
  7738. String infoMessage = null;
  7739. NodeList items = ele.getElementsByTagName("home_info");
  7740. Node item = items.item(0);
  7741. Node text;
  7742. NamedNodeMap attrsParam = item.getAttributes();
  7743. for(int j=0; j< attrsParam.getLength();j++)
  7744. {
  7745. Node attr = attrsParam.item(j);
  7746. if (attr.getNodeName().equalsIgnoreCase("dong"))
  7747. infoDong = trimquotation(attr.getNodeValue());
  7748. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  7749. infoHo = trimquotation(attr.getNodeValue());
  7750. }
  7751. items = ele.getElementsByTagName("park_info");
  7752. item = items.item(0);
  7753. attrsParam = item.getAttributes();
  7754. for(int j=0; j< attrsParam.getLength();j++)
  7755. {
  7756. Node attr = attrsParam.item(j);
  7757. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  7758. infoCarnum = trimquotation(attr.getNodeValue());
  7759. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  7760. infoCarLocation = trimquotation(attr.getNodeValue());
  7761. else if (attr.getNodeName().equalsIgnoreCase("message"))
  7762. infoMessage = trimquotation(attr.getNodeValue());
  7763. }
  7764. Log.d(TAG, "ProcParkInformation infoName :"+infoName);
  7765. Log.d(TAG, "ProcParkInformation infoDong :"+infoDong);
  7766. Log.d(TAG, "ProcParkInformation infoHo :"+infoHo);
  7767. Log.d(TAG, "ProcParkInformation infoCarMove :"+infoCarMove);
  7768. Log.d(TAG, "ProcParkInformation infoCarnum :"+infoCarnum);
  7769. Log.d(TAG, "ProcParkInformation infoCarLocation :"+infoCarLocation);
  7770. Log.d(TAG, "ProcParkInformation infoMessage :"+infoMessage);
  7771. if((infoDong.equalsIgnoreCase(AddrDong) == true) &&
  7772. (infoHo.equalsIgnoreCase(AddrHo) == true))
  7773. {
  7774. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  7775. }
  7776. else
  7777. {
  7778. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  7779. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  7780. return retXML;
  7781. }
  7782. infoCarMove = "park";
  7783. //DB정보 업데이트!
  7784. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  7785. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  7786. CarDB.closeDB();
  7787. //DB정보 업데이트!
  7788. Intent iIntent = new Intent();
  7789. iIntent.setAction(define.NOTIFY_ACNAME);
  7790. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  7791. this.sendBroadcast(iIntent);
  7792. /*
  7793. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  7794. {
  7795. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  7796. // 팝업을 띄우도록 하자
  7797. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  7798. }
  7799. */
  7800. return retXML;
  7801. }
  7802. public String ProcGetSmartKeyInfo(Element ele)
  7803. {
  7804. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  7805. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  7806. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  7807. NodeList items = ele.getElementsByTagName("info_type");
  7808. Node item = items.item(0);
  7809. Node text = item.getFirstChild();
  7810. String sInfo_type = trimquotation(text.getNodeValue());
  7811. String sCard_info = null;
  7812. String sMessage = null;
  7813. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  7814. {
  7815. items = ele.getElementsByTagName("uid_info");
  7816. item = items.item(0);
  7817. text = item.getFirstChild();
  7818. sCard_info = trimquotation(text.getNodeValue());
  7819. //==============================================//
  7820. items = ele.getElementsByTagName("message");
  7821. item = items.item(0);
  7822. text = item.getFirstChild();
  7823. sMessage = trimquotation(text.getNodeValue());
  7824. //==============================================//
  7825. //쿼리문 작성
  7826. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  7827. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  7828. for(int i=0; i<SyncData.size(); i++)
  7829. {
  7830. if(SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true)
  7831. {
  7832. NewData.add(SyncData.get(i));
  7833. }
  7834. }
  7835. wallpadSmartKeyRegData.closeDB();
  7836. }
  7837. else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  7838. {
  7839. items = ele.getElementsByTagName("sn_info");
  7840. item = items.item(0);
  7841. text = item.getFirstChild();
  7842. sCard_info = trimquotation(text.getNodeValue());
  7843. //==============================================//
  7844. items = ele.getElementsByTagName("message");
  7845. item = items.item(0);
  7846. text = item.getFirstChild();
  7847. sMessage = trimquotation(text.getNodeValue());
  7848. //==============================================//
  7849. //쿼리문 작성
  7850. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  7851. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  7852. for(int i=0; i<SyncData.size(); i++)
  7853. {
  7854. if(SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true)
  7855. {
  7856. NewData.add(SyncData.get(i));
  7857. }
  7858. }
  7859. wallpadSmartKeyRegData.closeDB();
  7860. }
  7861. else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  7862. {
  7863. items = ele.getElementsByTagName("uid_info");
  7864. item = items.item(0);
  7865. text = item.getFirstChild();
  7866. sCard_info = trimquotation(text.getNodeValue());
  7867. //==============================================//
  7868. items = ele.getElementsByTagName("message");
  7869. item = items.item(0);
  7870. text = item.getFirstChild();
  7871. sMessage = trimquotation(text.getNodeValue());
  7872. //==============================================//
  7873. //쿼리문 작성
  7874. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  7875. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  7876. for(int i=0; i<SyncData.size(); i++)
  7877. {
  7878. if(SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true)
  7879. {
  7880. NewData.add(SyncData.get(i));
  7881. }
  7882. }
  7883. if(NewData.size() > 0)
  7884. {
  7885. NewData = SyncData;
  7886. }
  7887. wallpadSmartKeyRegData.closeDB();
  7888. }
  7889. else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  7890. {
  7891. items = ele.getElementsByTagName("sn_info");
  7892. item = items.item(0);
  7893. text = item.getFirstChild();
  7894. sCard_info = trimquotation(text.getNodeValue());
  7895. //==============================================//
  7896. items = ele.getElementsByTagName("message");
  7897. item = items.item(0);
  7898. text = item.getFirstChild();
  7899. sMessage = trimquotation(text.getNodeValue());
  7900. //==============================================//
  7901. //쿼리문 작성
  7902. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  7903. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  7904. for(int i=0; i<SyncData.size(); i++)
  7905. {
  7906. if(SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true)
  7907. {
  7908. NewData.add(SyncData.get(i));
  7909. }
  7910. }
  7911. if(NewData.size() > 0)
  7912. {
  7913. NewData = SyncData;
  7914. }
  7915. wallpadSmartKeyRegData.closeDB();
  7916. }
  7917. else if (sInfo_type.equalsIgnoreCase("hkey"))
  7918. {
  7919. String dong = "";
  7920. String ho = "";
  7921. String Num = "all";
  7922. //==============================================//
  7923. items = ele.getElementsByTagName("message");
  7924. item = items.item(0);
  7925. text = item.getFirstChild();
  7926. sMessage = trimquotation(text.getNodeValue());
  7927. //==============================================//
  7928. items = ele.getElementsByTagName("hkey_info");
  7929. item = items.item(0);
  7930. if (item == null)
  7931. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  7932. NamedNodeMap attrsParam = item.getAttributes();
  7933. for(int j=0; j< attrsParam.getLength();j++)
  7934. {
  7935. Node attr = attrsParam.item(j);
  7936. if (attr.getNodeName().equalsIgnoreCase("dong"))
  7937. dong = attr.getNodeValue();
  7938. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  7939. ho = attr.getNodeValue();
  7940. else if (attr.getNodeName().equalsIgnoreCase("num"))
  7941. Num = attr.getNodeValue();
  7942. }
  7943. if(!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo))))
  7944. {
  7945. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :"+ dong+ "-" + ho);
  7946. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  7947. }
  7948. //쿼리문 작성
  7949. int intNum = 0;
  7950. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  7951. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  7952. for(int i=0; i<SyncData.size(); i++)
  7953. {
  7954. if(Num.equalsIgnoreCase("all") == true)
  7955. {
  7956. NewData.add(SyncData.get(i));
  7957. }
  7958. else
  7959. {
  7960. try
  7961. {
  7962. intNum = Integer.parseInt(Num);
  7963. }
  7964. catch (Exception e)
  7965. {
  7966. e.printStackTrace();
  7967. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  7968. }
  7969. if(SyncData.get(i).id == intNum)
  7970. {
  7971. NewData.add(SyncData.get(i));
  7972. }
  7973. }
  7974. }
  7975. wallpadSmartKeyRegData.closeDB();
  7976. }
  7977. else if (sInfo_type.equalsIgnoreCase("dkey"))
  7978. {
  7979. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  7980. }
  7981. else if (sInfo_type.equalsIgnoreCase("mkey"))
  7982. {
  7983. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  7984. }
  7985. if(NewData.size() == 0)
  7986. {
  7987. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  7988. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  7989. retXML += " <hkey_info dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" count = \""+NewData.size()+"\" />\r\n";
  7990. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  7991. retXML += " </service>\r\n</imap>";
  7992. return retXML;
  7993. }
  7994. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  7995. retXML += " <hkey_info dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" count = \""+NewData.size()+"\" />\r\n";
  7996. for(int i = 0; i<NewData.size(); i++)
  7997. {
  7998. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  7999. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  8000. String strFormat = sFormat.format(date);
  8001. retXML += " <key_info index = \""+NewData.get(i).id+"\" "
  8002. + "sn = \""+NewData.get(i).SerialNumber+"\" "
  8003. + "uid = \""+NewData.get(i).Uid+"\" "
  8004. + "key_num = \""+NewData.get(i).id+"\" "
  8005. + "issue_cnt = \""+1+"\" "
  8006. + "issued_date = \""+strFormat+"\" "
  8007. + "message = \""+"null"+"\" "
  8008. + "/>\r\n";
  8009. }
  8010. retXML += " </service>\r\n</imap>";
  8011. return retXML;
  8012. }
  8013. public void ProcMobileDevice_AuthNumber(Element ele) {
  8014. String sDong = null;
  8015. String sHo = null;
  8016. String sIP = null;
  8017. String sType = null;
  8018. String sDevice_Name = null;
  8019. String sTwinID = null;
  8020. String sAuthNumber = null;
  8021. try {
  8022. NodeList items = ele.getElementsByTagName("home_info");
  8023. Node item = items.item(0);
  8024. NamedNodeMap attrsParam = item.getAttributes();
  8025. for (int i=0; i< attrsParam.getLength(); i++) {
  8026. Node attr = attrsParam.item(i);
  8027. if (attr.getNodeName().equalsIgnoreCase("dong")) sDong = trimquotation(attr.getNodeValue());
  8028. else if (attr.getNodeName().equalsIgnoreCase("ho")) sHo = trimquotation(attr.getNodeValue());
  8029. else if (attr.getNodeName().equalsIgnoreCase("ip")) sIP = trimquotation(attr.getNodeValue());
  8030. else if (attr.getNodeName().equalsIgnoreCase("type")) sType = trimquotation(attr.getNodeValue());
  8031. }
  8032. WallpadStatusData DBMGR = null;
  8033. DBMGR = new WallpadStatusData(getApplicationContext());
  8034. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8035. DBMGR.closeDB();
  8036. if((sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  8037. items = ele.getElementsByTagName("device_info");
  8038. item = items.item(0);
  8039. attrsParam = item.getAttributes();
  8040. for (int i = 0; i < attrsParam.getLength(); i++) {
  8041. Node attr = attrsParam.item(i);
  8042. if (attr.getNodeName().equalsIgnoreCase("alias")) sDevice_Name = trimquotation(attr.getNodeValue());
  8043. else if (attr.getNodeName().equalsIgnoreCase("twinid")) sTwinID = trimquotation(attr.getNodeValue());
  8044. else if (attr.getNodeName().equalsIgnoreCase("auth_number")) sAuthNumber = trimquotation(attr.getNodeValue());
  8045. }
  8046. /**데이터 전달**/
  8047. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  8048. Log.d(TAG, "sTwinID :" + sTwinID);
  8049. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  8050. Intent intent = new Intent();
  8051. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  8052. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  8053. intent.putExtra("AuthNumber", sAuthNumber);
  8054. if (NewServerUse()) {
  8055. getApplicationContext().sendBroadcast(intent);
  8056. }
  8057. }
  8058. else {
  8059. }
  8060. } catch (Exception e) {
  8061. e.printStackTrace();
  8062. }
  8063. }
  8064. public String ProcMobileDevice_ADD_Finish(Element ele) {
  8065. String retXML = "";
  8066. String sDong = null;
  8067. String sHo = null;
  8068. String sIP = null;
  8069. String sType = null;
  8070. String sDevice_Name = null;
  8071. String sTwinID = null;
  8072. try
  8073. {
  8074. NodeList items = ele.getElementsByTagName("home_info");
  8075. Node item = items.item(0);
  8076. NamedNodeMap attrsParam = item.getAttributes();
  8077. for(int i=0; i< attrsParam.getLength(); i++)
  8078. {
  8079. Node attr = attrsParam.item(i);
  8080. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8081. sDong = trimquotation(attr.getNodeValue());
  8082. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8083. sHo = trimquotation(attr.getNodeValue());
  8084. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  8085. sIP = trimquotation(attr.getNodeValue());
  8086. else if (attr.getNodeName().equalsIgnoreCase("type"))
  8087. sType = trimquotation(attr.getNodeValue());
  8088. }
  8089. WallpadStatusData DBMGR = null;
  8090. DBMGR = new WallpadStatusData(getApplicationContext());
  8091. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8092. DBMGR.closeDB();
  8093. if((sDong.equalsIgnoreCase(addc.Dong) == true) &&
  8094. (sHo.equalsIgnoreCase(addc.Ho) == true) &&
  8095. (sIP.equalsIgnoreCase(addc.IPAddress) == true))
  8096. {
  8097. items = ele.getElementsByTagName("device_info");
  8098. item = items.item(0);
  8099. attrsParam = item.getAttributes();
  8100. for(int i=0; i< attrsParam.getLength(); i++)
  8101. {
  8102. Node attr = attrsParam.item(i);
  8103. if (attr.getNodeName().equalsIgnoreCase("alias"))
  8104. sDevice_Name = trimquotation(attr.getNodeValue());
  8105. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  8106. sTwinID = trimquotation(attr.getNodeValue());
  8107. }
  8108. /**데이터 전달**/
  8109. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  8110. Log.d(TAG, "sTwinID :" + sTwinID);
  8111. Intent intent = new Intent();
  8112. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  8113. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  8114. if(NewServerUse())
  8115. {
  8116. getApplicationContext().sendBroadcast(intent);
  8117. }
  8118. else
  8119. {
  8120. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8121. retXML += " </service>\r\n</imap>";
  8122. return retXML;
  8123. }
  8124. String tempType = "main";
  8125. //DB에 저장 필요
  8126. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  8127. if(wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  8128. {
  8129. wallpadMobileDeviceData.closeDB();
  8130. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8131. retXML += " </service>\r\n</imap>";
  8132. return retXML;
  8133. }
  8134. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  8135. wallpadMobileDeviceData.closeDB();
  8136. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  8137. retXML += " <home_info dong=\""+addc.Dong+"\" ho=\""+ addc.Ho+"\" ip=\""+ addc.IPAddress+"\" type=\""+ tempType +"\"/>\r\n";
  8138. retXML += " <device_info alias=\""+sDevice_Name+"\" twinid=\""+sTwinID+"\" />\r\n";
  8139. retXML += " </service>\r\n</imap>";
  8140. return retXML;
  8141. }
  8142. else
  8143. {
  8144. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8145. retXML += " </service>\r\n</imap>";
  8146. return retXML;
  8147. }
  8148. }
  8149. catch (Exception e)
  8150. {
  8151. e.printStackTrace();
  8152. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8153. retXML += " </service>\r\n</imap>";
  8154. return retXML;
  8155. }
  8156. }
  8157. public void ProcMobileDevice_Delete(Element ele)
  8158. {
  8159. String sDong = null;
  8160. String sHo = null;
  8161. String sIP = null;
  8162. String sType = null;
  8163. String sDevice_Name = null;
  8164. String sTwinID = null;
  8165. Log.d(TAG, "ProcMobileDevice_Delete");
  8166. try
  8167. {
  8168. NodeList items = ele.getElementsByTagName("home_info");
  8169. Node item = items.item(0);
  8170. NamedNodeMap attrsParam = item.getAttributes();
  8171. for(int i=0; i< attrsParam.getLength(); i++)
  8172. {
  8173. Node attr = attrsParam.item(i);
  8174. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8175. sDong = trimquotation(attr.getNodeValue());
  8176. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8177. sHo = trimquotation(attr.getNodeValue());
  8178. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  8179. sIP = trimquotation(attr.getNodeValue());
  8180. else if (attr.getNodeName().equalsIgnoreCase("type"))
  8181. sType = trimquotation(attr.getNodeValue());
  8182. }
  8183. WallpadStatusData DBMGR = null;
  8184. DBMGR = new WallpadStatusData(getApplicationContext());
  8185. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8186. DBMGR.closeDB();
  8187. if((sDong.equalsIgnoreCase(addc.Dong) == true) &&
  8188. (sHo.equalsIgnoreCase(addc.Ho) == true) &&
  8189. (sIP.equalsIgnoreCase(addc.IPAddress) == true))
  8190. {
  8191. if(NewServerUse())
  8192. {
  8193. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  8194. items = ele.getElementsByTagName("device_info");
  8195. for(int i = 0; i< items.getLength(); i++)
  8196. {
  8197. item = items.item(i);
  8198. attrsParam = item.getAttributes();
  8199. for(int j=0; j < attrsParam.getLength(); j++)
  8200. {
  8201. Node attr = attrsParam.item(j);
  8202. if (attr.getNodeName().equalsIgnoreCase("alias"))
  8203. sDevice_Name = trimquotation(attr.getNodeValue());
  8204. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  8205. sTwinID = trimquotation(attr.getNodeValue());
  8206. }
  8207. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  8208. Log.d(TAG, "sTwinID :" + sTwinID);
  8209. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  8210. }
  8211. wallpadMobileDeviceData.closeDB();
  8212. Intent intent = new Intent();
  8213. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  8214. getApplicationContext().sendBroadcast(intent);
  8215. }
  8216. }
  8217. else
  8218. {
  8219. }
  8220. }
  8221. catch (Exception e)
  8222. {
  8223. e.printStackTrace();
  8224. }
  8225. }
  8226. public String ProcGetAppVersionInfo()
  8227. {
  8228. String retXML = "";
  8229. MainDatabaseManager mDBM = new MainDatabaseManager( getApplicationContext() , null, null);
  8230. int AppCount;
  8231. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  8232. retXML= XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  8233. retXML += " <home_info dong = \""+AddrDong+"\" ho=\""+AddrHo+"\" platform=\"Android\" count=\""+AppCount+"\" />\r\n";
  8234. for(int i =0; i<AppCount; i++)
  8235. {
  8236. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE+i);
  8237. if(getString != null)
  8238. {
  8239. retXML += " <app_list name=\""+getString[0]+"\" version=\""+getString[1]+"\" />\r\n";
  8240. }
  8241. }
  8242. retXML += " </service>\r\n</imap>";
  8243. return retXML;
  8244. }
  8245. public String ProcIgateInitInfo(Element ele)
  8246. {
  8247. String retXML = "";
  8248. String ctrl_baudrate = "";
  8249. String ctrl_open = "";
  8250. String ctrl_framecheck = "";
  8251. String ctrl_message = "";
  8252. String eth_mode = "";
  8253. String eth_ip = "";
  8254. String eth_mac = "";
  8255. String eth_gw = "";
  8256. String eth_sm = "";
  8257. String noti_send = "";
  8258. String noti_level = "";
  8259. String noti_ip = "";
  8260. String noti_port= "";
  8261. try
  8262. {
  8263. NodeList items = ele.getElementsByTagName("ctrl_param");
  8264. Node item = items.item(0);
  8265. NamedNodeMap attrsParam = item.getAttributes();
  8266. for(int i=0; i< attrsParam.getLength(); i++)
  8267. {
  8268. Node attr = attrsParam.item(i);
  8269. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  8270. ctrl_baudrate = trimquotation(attr.getNodeValue());
  8271. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  8272. ctrl_open = trimquotation(attr.getNodeValue());
  8273. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  8274. ctrl_framecheck = trimquotation(attr.getNodeValue());
  8275. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  8276. ctrl_message = trimquotation(attr.getNodeValue());
  8277. }
  8278. items = ele.getElementsByTagName("eth_param");
  8279. item = items.item(0);
  8280. attrsParam = item.getAttributes();
  8281. for(int i=0; i< attrsParam.getLength(); i++)
  8282. {
  8283. Node attr = attrsParam.item(i);
  8284. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  8285. eth_mode = trimquotation(attr.getNodeValue());
  8286. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  8287. eth_ip = trimquotation(attr.getNodeValue());
  8288. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  8289. eth_mac = trimquotation(attr.getNodeValue());
  8290. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  8291. eth_gw = trimquotation(attr.getNodeValue());
  8292. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  8293. eth_sm = trimquotation(attr.getNodeValue());
  8294. }
  8295. items = ele.getElementsByTagName("noti_param");
  8296. item = items.item(0);
  8297. attrsParam = item.getAttributes();
  8298. for(int i=0; i< attrsParam.getLength(); i++)
  8299. {
  8300. Node attr = attrsParam.item(i);
  8301. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  8302. noti_send = trimquotation(attr.getNodeValue());
  8303. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  8304. noti_level = trimquotation(attr.getNodeValue());
  8305. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  8306. noti_ip = trimquotation(attr.getNodeValue());
  8307. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  8308. noti_port = trimquotation(attr.getNodeValue());
  8309. }
  8310. wallpaddbmgr WallpadDBMGR = null;
  8311. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  8312. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  8313. if(RowCount_GatewayData > 100)
  8314. {
  8315. WallpadDBMGR.DeleteLH_GatewayData("50");
  8316. }
  8317. WallpadDBMGR.InsertLH_GatewayData(ctrl_baudrate, ctrl_open, ctrl_framecheck, ctrl_message, eth_mode, eth_ip, eth_mac, eth_gw, eth_sm, noti_send, noti_level, noti_ip, noti_port);
  8318. WallpadDBMGR.closeDB();
  8319. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  8320. retXML += " </service>\r\n</imap>";
  8321. return retXML;
  8322. }
  8323. catch (Exception e)
  8324. {
  8325. e.printStackTrace();
  8326. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  8327. retXML += " </service>\r\n</imap>";
  8328. return retXML;
  8329. }
  8330. }
  8331. public String ProcElecCarChargeEventInfo(Element ele) {
  8332. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  8333. String retXML = "";
  8334. String sName = "", sId_High = "", sId_Low = "", sCard_Num ="", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  8335. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  8336. try {
  8337. NodeList items = ele.getElementsByTagName("destination");
  8338. Node item = items.item(0);
  8339. NamedNodeMap attrsParam = item.getAttributes();
  8340. for (int i = 0; i < attrsParam.getLength(); i++) {
  8341. Node attr = attrsParam.item(i);
  8342. if (attr.getNodeName().equalsIgnoreCase("name")) sName = trimquotation(attr.getNodeValue());
  8343. else if (attr.getNodeName().equalsIgnoreCase("id_high")) sId_High = trimquotation(attr.getNodeValue());
  8344. else if (attr.getNodeName().equalsIgnoreCase("id_low")) sId_Low = trimquotation(attr.getNodeValue());
  8345. }
  8346. WallpadStatusData DBMGR = null;
  8347. DBMGR = new WallpadStatusData(getApplicationContext());
  8348. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8349. DBMGR.closeDB();
  8350. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  8351. items = ele.getElementsByTagName("charging_info");
  8352. item = items.item(0);
  8353. attrsParam = item.getAttributes();
  8354. for (int i = 0; i < attrsParam.getLength(); i++) {
  8355. Node attr = attrsParam.item(i);
  8356. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  8357. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  8358. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  8359. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  8360. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  8361. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  8362. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  8363. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  8364. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  8365. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  8366. ))
  8367. {
  8368. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  8369. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  8370. retXML += " </service>\r\n</imap>";
  8371. return retXML;
  8372. }
  8373. if (attr.getNodeName().equalsIgnoreCase("card_num")) sCard_Num = trimquotation(attr.getNodeValue());
  8374. else if (attr.getNodeName().equalsIgnoreCase("car_num")) sCar_Num = trimquotation(attr.getNodeValue());
  8375. else if (attr.getNodeName().equalsIgnoreCase("charger_num")) sCharger_Num = trimquotation(attr.getNodeValue());
  8376. else if (attr.getNodeName().equalsIgnoreCase("charger_loc")) sCharger_Loc = trimquotation(attr.getNodeValue());
  8377. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  8378. sCharging_Status = trimquotation(attr.getNodeValue());
  8379. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  8380. (sCharging_Status.equalsIgnoreCase("charging")) ||
  8381. (sCharging_Status.equalsIgnoreCase("full")) ||
  8382. (sCharging_Status.equalsIgnoreCase("charged")) ||
  8383. (sCharging_Status.equalsIgnoreCase("stop")) ||
  8384. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  8385. (sCharging_Status.equalsIgnoreCase("check")) ||
  8386. (sCharging_Status.equalsIgnoreCase("commerror"))
  8387. ))
  8388. {
  8389. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  8390. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  8391. retXML += " </service>\r\n</imap>";
  8392. return retXML;
  8393. }
  8394. }
  8395. else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  8396. sCharger_sort = trimquotation(attr.getNodeValue());
  8397. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  8398. (sCharger_sort.equalsIgnoreCase("fast")) ||
  8399. (sCharger_sort.equalsIgnoreCase("no_info"))
  8400. ))
  8401. {
  8402. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  8403. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  8404. retXML += " </service>\r\n</imap>";
  8405. return retXML;
  8406. }
  8407. }
  8408. else if (attr.getNodeName().equalsIgnoreCase("charging_ratio")) sCharging_Ratio = trimquotation(attr.getNodeValue());
  8409. else if (attr.getNodeName().equalsIgnoreCase("start_time")) sStart_Time = trimquotation(attr.getNodeValue());
  8410. else if (attr.getNodeName().equalsIgnoreCase("remain_time")) sRemain_Time = trimquotation(attr.getNodeValue());
  8411. }
  8412. items = ele.getElementsByTagName("message");
  8413. item = items.item(0);
  8414. Node text = item.getFirstChild();
  8415. sMessage = trimquotation(text.getNodeValue());
  8416. /**데이터 전달**/
  8417. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  8418. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  8419. Intent intent = new Intent();
  8420. intent.setAction(define.NOTIFY_ACNAME);
  8421. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  8422. intent.putExtra("sCard_Num", sCard_Num);
  8423. intent.putExtra("sCar_Num", sCar_Num);
  8424. intent.putExtra("sCharger_Num", sCharger_Num);
  8425. intent.putExtra("sCharger_Loc", sCharger_Loc);
  8426. intent.putExtra("sCharging_Status", sCharging_Status);
  8427. intent.putExtra("sCharger_sort", sCharger_sort);
  8428. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  8429. intent.putExtra("sStart_Time", sStart_Time);
  8430. intent.putExtra("sRemain_Time", sRemain_Time);
  8431. intent.putExtra("sMessage", sMessage);
  8432. WallpadDeviceSet devDB = null;
  8433. devDB = new WallpadDeviceSet(getApplicationContext());
  8434. int retInt = -1;
  8435. retInt = devDB.GetDeviceSetted("전기차충전");
  8436. devDB.closeDB();
  8437. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  8438. getApplicationContext().sendBroadcast(intent);
  8439. }
  8440. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  8441. retXML += " <source name=\"homedev\" id_high=\""+sId_High+"\" id_low=\""+ sId_Low+"\" />\r\n";
  8442. retXML += " </service>\r\n</imap>";
  8443. return retXML;
  8444. }
  8445. else {
  8446. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  8447. retXML += " </service>\r\n</imap>";
  8448. return retXML;
  8449. }
  8450. } catch (Exception e) {
  8451. e.printStackTrace();
  8452. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  8453. retXML += " </service>\r\n</imap>";
  8454. return retXML;
  8455. }
  8456. }
  8457. public String ProcEnergyTargetInfoAlarm(Element ele) {
  8458. String retXML = "";
  8459. String sName = "";
  8460. String sId_High = "";
  8461. String sId_Low = "";
  8462. String vName[];
  8463. String vTarget[];
  8464. String vTarget_Cost[];
  8465. String vUsed[];
  8466. String vUsed_Cost[];
  8467. String vPredict[];
  8468. String vPredict_Cost[];
  8469. String vAlarm_info[];
  8470. String vRead_Date[];
  8471. String vRead_Day[];
  8472. String vV_Msg[];
  8473. String sMessage = "";
  8474. try
  8475. {
  8476. NodeList items = ele.getElementsByTagName("source");
  8477. Node item = items.item(0);
  8478. NamedNodeMap attrsParam = item.getAttributes();
  8479. for(int i=0; i< attrsParam.getLength(); i++)
  8480. {
  8481. Node attr = attrsParam.item(i);
  8482. if (attr.getNodeName().equalsIgnoreCase("name"))
  8483. sName = trimquotation(attr.getNodeValue());
  8484. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  8485. sId_High = trimquotation(attr.getNodeValue());
  8486. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  8487. sId_Low = trimquotation(attr.getNodeValue());
  8488. }
  8489. WallpadStatusData DBMGR = null;
  8490. DBMGR = new WallpadStatusData(getApplicationContext());
  8491. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8492. DBMGR.closeDB();
  8493. if((sName.equalsIgnoreCase("home") == true) &&
  8494. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  8495. (sId_Low.equalsIgnoreCase(addc.Ho) == true))
  8496. {
  8497. items = ele.getElementsByTagName("valuelist");
  8498. Log.d(TAG, "items.getLength() :" + items.getLength());
  8499. vName = new String[items.getLength()];
  8500. vTarget = new String[items.getLength()];
  8501. vTarget_Cost = new String[items.getLength()];
  8502. vUsed = new String[items.getLength()];
  8503. vUsed_Cost = new String[items.getLength()];
  8504. vPredict = new String[items.getLength()];
  8505. vPredict_Cost = new String[items.getLength()];
  8506. vAlarm_info = new String[items.getLength()];
  8507. vRead_Date = new String[items.getLength()];
  8508. vRead_Day = new String[items.getLength()];
  8509. vV_Msg = new String[items.getLength()];
  8510. for (int j = 0; j < items.getLength(); j++)
  8511. {
  8512. Log.d(TAG, "j :" + j);
  8513. item = items.item(j);
  8514. attrsParam = item.getAttributes();
  8515. Log.d(TAG, "attrsParam :" + attrsParam);
  8516. for(int i=0; i< attrsParam.getLength(); i++)
  8517. {
  8518. Node attr = attrsParam.item(i);
  8519. if(!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  8520. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  8521. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  8522. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  8523. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  8524. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  8525. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  8526. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  8527. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  8528. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  8529. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  8530. ))
  8531. {
  8532. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  8533. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  8534. retXML += " </service>\r\n</imap>";
  8535. return retXML;
  8536. }
  8537. if (attr.getNodeName().equalsIgnoreCase("name"))
  8538. {
  8539. vName[j] = trimquotation(attr.getNodeValue());
  8540. if(!((vName[j].equalsIgnoreCase("elect") == true) ||
  8541. (vName[j].equalsIgnoreCase("water") == true) ||
  8542. (vName[j].equalsIgnoreCase("gas") == true) ||
  8543. (vName[j].equalsIgnoreCase("heating") == true) ||
  8544. (vName[j].equalsIgnoreCase("hotwater") == true)
  8545. ))
  8546. {
  8547. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  8548. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  8549. retXML += " </service>\r\n</imap>";
  8550. return retXML;
  8551. }
  8552. }
  8553. else if (attr.getNodeName().equalsIgnoreCase("target"))
  8554. vTarget[j] = trimquotation(attr.getNodeValue());
  8555. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  8556. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  8557. else if (attr.getNodeName().equalsIgnoreCase("used"))
  8558. vUsed[j] = trimquotation(attr.getNodeValue());
  8559. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  8560. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  8561. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  8562. vPredict[j] = trimquotation(attr.getNodeValue());
  8563. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  8564. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  8565. else if (attr.getNodeName().equalsIgnoreCase("alarm_info"))
  8566. {
  8567. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  8568. if(!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  8569. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  8570. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  8571. ))
  8572. {
  8573. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  8574. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  8575. retXML += " </service>\r\n</imap>";
  8576. return retXML;
  8577. }
  8578. }
  8579. else if (attr.getNodeName().equalsIgnoreCase("read_date"))
  8580. {
  8581. vRead_Date[j] = trimquotation(attr.getNodeValue());
  8582. if(!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  8583. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  8584. ))
  8585. {
  8586. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  8587. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  8588. retXML += " </service>\r\n</imap>";
  8589. return retXML;
  8590. }
  8591. }
  8592. else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  8593. vRead_Day[j] = trimquotation(attr.getNodeValue());
  8594. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  8595. vV_Msg[j] = trimquotation(attr.getNodeValue());
  8596. }
  8597. }
  8598. items = ele.getElementsByTagName("message");
  8599. item = items.item(0);
  8600. Node text = item.getFirstChild();
  8601. sMessage = trimquotation(text.getNodeValue());
  8602. /**데이터 전달**/
  8603. for(int i = 0; i<vName.length; i++)
  8604. {
  8605. Log.d(TAG, "vName["+i+"]: " + vName[i]);
  8606. Log.d(TAG, "vTarget"+i+"]: " + vTarget[i]);
  8607. Log.d(TAG, "vTarget_Cost["+i+"]: " + vTarget_Cost[i]);
  8608. Log.d(TAG, "vUsed["+i+"]: " + vUsed[i]);
  8609. Log.d(TAG, "vUsed_Cost["+i+"]: " + vUsed_Cost[i]);
  8610. Log.d(TAG, "vPredict["+i+"]: " + vPredict[i]);
  8611. Log.d(TAG, "vPredict_Cost["+i+"]: " + vPredict_Cost[i]);
  8612. Log.d(TAG, "vAlarm_info["+i+"]: " + vAlarm_info[i]);
  8613. Log.d(TAG, "vRead_Date["+i+"]: " + vRead_Date[i]);
  8614. Log.d(TAG, "vRead_Day["+i+"]: " + vRead_Day[i]);
  8615. Log.d(TAG, "vV_Msg["+i+"]: " + vV_Msg[i]);
  8616. }
  8617. Intent intent = new Intent();
  8618. intent.setAction(define.NOTIFY_ACNAME);
  8619. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  8620. for(int i = 0; i<vName.length; i++)
  8621. {
  8622. if(vName[i].equals("elect"))
  8623. {
  8624. intent.putExtra("elect_target", vTarget[i]);
  8625. intent.putExtra("elect_used", vUsed[i]);
  8626. intent.putExtra("elect_info", vAlarm_info[i]);
  8627. }
  8628. else if(vName[i].equals("water"))
  8629. {
  8630. intent.putExtra("water_target", vTarget[i]);
  8631. intent.putExtra("water_used", vUsed[i]);
  8632. intent.putExtra("water_info", vAlarm_info[i]);
  8633. }
  8634. else if(vName[i].equals("gas"))
  8635. {
  8636. intent.putExtra("gas_target", vTarget[i]);
  8637. intent.putExtra("gas_used", vUsed[i]);
  8638. intent.putExtra("gas_info", vAlarm_info[i]);
  8639. }
  8640. else if(vName[i].equals("heating"))
  8641. {
  8642. intent.putExtra("heating_target", vTarget[i]);
  8643. intent.putExtra("heating_used", vUsed[i]);
  8644. intent.putExtra("heating_info", vAlarm_info[i]);
  8645. }
  8646. else if(vName[i].equals("hotwater"))
  8647. {
  8648. intent.putExtra("hotwater_target", vTarget[i]);
  8649. intent.putExtra("hotwater_used", vUsed[i]);
  8650. intent.putExtra("hotwater_info", vAlarm_info[i]);
  8651. }
  8652. }
  8653. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  8654. retXML += " <source name=\"home\" id_high=\""+sId_High+"\" id_low=\""+ sId_Low+"\" count=\""+vName.length+"\""+" s_msg=\"null\" />\r\n";
  8655. for(int i = 0; i<vName.length; i++)
  8656. {
  8657. retXML += " <valuelist name=\""+vName[i]+"\" alarm_info=\""+vAlarm_info[i]+"\" v_msg=\"null\" />\r\n";
  8658. }
  8659. retXML += " <message>\"null\"</message>\r\n";
  8660. retXML += " </service>\r\n</imap>";
  8661. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  8662. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  8663. devSet.closeDB();
  8664. if (MetringDB != null)
  8665. {
  8666. try
  8667. {
  8668. String devInfo = MetringDB[1];
  8669. devInfo = devInfo.replace('(', '_');
  8670. devInfo = devInfo.replace(':', '_');
  8671. devInfo = devInfo.replace(')', '_');
  8672. String[] MetringInfo = devInfo.split("_");
  8673. // MetringInfo[1] -> 회로수
  8674. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  8675. // MetringInfo[4] -> IP
  8676. // MetringInfo[5] -> IP정보
  8677. // MetringInfo[6] -> 검침일사용자설정
  8678. // MetringInfo[7] -> 사용함 또는 사용안함
  8679. if(MetringInfo[3].equals("사용함") == true)
  8680. {
  8681. getApplicationContext().sendBroadcast(intent);
  8682. }
  8683. }
  8684. catch (Exception e)
  8685. {
  8686. e.printStackTrace();
  8687. }
  8688. }
  8689. else
  8690. {
  8691. }
  8692. return retXML;
  8693. }
  8694. else
  8695. {
  8696. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  8697. retXML += " </service>\r\n</imap>";
  8698. return retXML;
  8699. }
  8700. }
  8701. catch(Exception e)
  8702. {
  8703. e.printStackTrace();
  8704. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  8705. retXML += " </service>\r\n</imap>";
  8706. return retXML;
  8707. }
  8708. }
  8709. public String ProcCheckCallOption()
  8710. {
  8711. int[] resultDB = {0, 0};
  8712. String retXML = "";
  8713. String sOption = "sip";
  8714. String sMessage = "null";
  8715. try
  8716. {
  8717. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  8718. resultDB = devSet.Get_Handicapped_Mode();
  8719. devSet.closeDB();
  8720. if(resultDB[0] == 0)
  8721. {
  8722. //장애인모드 사용 안함
  8723. }
  8724. else if (resultDB[0] == 1)
  8725. {
  8726. //장애인모드 사용함
  8727. }
  8728. switch(resultDB[1])
  8729. {
  8730. case 0: //일반모드
  8731. sOption = "sip";
  8732. break;
  8733. case 1: //청각장애인
  8734. sOption = "deaf";
  8735. break;
  8736. case 2: //시각장애인
  8737. sOption = "blind";
  8738. break;
  8739. default:
  8740. break;
  8741. }
  8742. if(resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  8743. {
  8744. //본 구문에 들어올수 없음
  8745. sOption = "none";
  8746. }
  8747. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  8748. retXML += " <option>\""+sOption+"\"</option>\r\n";
  8749. retXML += " <message>\""+sMessage+"\"</message>\r\n";
  8750. retXML += " </service>\r\n</imap>";
  8751. return retXML;
  8752. }
  8753. catch(Exception e)
  8754. {
  8755. e.printStackTrace();
  8756. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  8757. retXML += " </service>\r\n</imap>";
  8758. return retXML;
  8759. }
  8760. }
  8761. public String ProcChatSequence(Element ele)
  8762. {
  8763. String retXML = "";
  8764. String sFrom = "error";
  8765. String sTo = "error";
  8766. String sContact = "error";
  8767. String sSequence = "error";
  8768. String sStatus = "error";
  8769. String sMessage = "error";
  8770. String reply_Sequence = "error";
  8771. String reply_Status = "error";
  8772. String reply_Message = "null";
  8773. try
  8774. {
  8775. NodeList items = ele.getElementsByTagName("sequence");
  8776. Node item = items.item(0);
  8777. NamedNodeMap attrsParam = item.getAttributes();
  8778. sSequence = trimquotation(item.getTextContent());
  8779. ///////////////////////////////////////////////
  8780. items = ele.getElementsByTagName("status");
  8781. item = items.item(0);
  8782. attrsParam = item.getAttributes();
  8783. sStatus = trimquotation(item.getTextContent());
  8784. ///////////////////////////////////////////////
  8785. items = ele.getElementsByTagName("message");
  8786. item = items.item(0);
  8787. attrsParam = item.getAttributes();
  8788. sMessage = trimquotation(item.getTextContent());
  8789. ///////////////////////////////////////////////
  8790. items = ele.getElementsByTagName("from");
  8791. item = items.item(0);
  8792. attrsParam = item.getAttributes();
  8793. sFrom = trimquotation(item.getTextContent());
  8794. ///////////////////////////////////////////////
  8795. items = ele.getElementsByTagName("to");
  8796. item = items.item(0);
  8797. attrsParam = item.getAttributes();
  8798. sTo = trimquotation(item.getTextContent());
  8799. ///////////////////////////////////////////////
  8800. items = ele.getElementsByTagName("contact");
  8801. item = items.item(0);
  8802. attrsParam = item.getAttributes();
  8803. sContact = trimquotation(item.getTextContent());
  8804. ///////////////////////////////////////////////
  8805. if(!((sSequence.equalsIgnoreCase("try") == true) ||
  8806. (sSequence.equalsIgnoreCase("start") == true) ||
  8807. (sSequence.equalsIgnoreCase("quit") == true) ||
  8808. (sSequence.equalsIgnoreCase("cancel") == true) ||
  8809. (sSequence.equalsIgnoreCase("ok") == true) ||
  8810. (sSequence.equalsIgnoreCase("busy") == true) ||
  8811. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  8812. (sSequence.equalsIgnoreCase("reject") == true)
  8813. ))
  8814. {
  8815. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  8816. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  8817. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  8818. retXML += " </service>\r\n</imap>";
  8819. return retXML;
  8820. }
  8821. if(!((sStatus.equalsIgnoreCase("idle") == true) ||
  8822. (sStatus.equalsIgnoreCase("ringing") == true) ||
  8823. (sStatus.equalsIgnoreCase("talking") == true)
  8824. ))
  8825. {
  8826. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  8827. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  8828. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  8829. retXML += " </service>\r\n</imap>";
  8830. return retXML;
  8831. }
  8832. //입력값 처리 필요!!
  8833. //김용성 과장님 작업필요
  8834. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  8835. //확인 하시고 위 정보 확인해주세요.
  8836. Log.d(TAG, "sFrom:" + sFrom);
  8837. Log.d(TAG, "sTo:" + sTo);
  8838. Log.d(TAG, "Contact:" + sContact);
  8839. Log.d(TAG, "sSequence:" + sSequence);
  8840. Log.d(TAG, "sStatus:" + sStatus);
  8841. if(sSequence.equalsIgnoreCase("try") == true)
  8842. {
  8843. //채팅 요청
  8844. }
  8845. else if(sSequence.equalsIgnoreCase("start") == true)
  8846. {
  8847. //채팅 시작
  8848. }
  8849. else if(sSequence.equalsIgnoreCase("quit") == true)
  8850. {
  8851. //채팅 종료
  8852. }
  8853. else if(sSequence.equalsIgnoreCase("cancel") == true)
  8854. {
  8855. //취소
  8856. }
  8857. else if(sSequence.equalsIgnoreCase("ok") == true)
  8858. {
  8859. //요청확인
  8860. }
  8861. else if(sSequence.equalsIgnoreCase("busy") == true)
  8862. {
  8863. //통화중
  8864. }
  8865. else if(sSequence.equalsIgnoreCase("busy_sip") == true)
  8866. {
  8867. //SIP 통화중
  8868. }
  8869. else if(sSequence.equalsIgnoreCase("reject") == true)
  8870. {
  8871. //거절
  8872. }
  8873. if(sStatus.equalsIgnoreCase("idle") == true)
  8874. {
  8875. //대기
  8876. }
  8877. else if(sStatus.equalsIgnoreCase("ringing") == true)
  8878. {
  8879. //연결중
  8880. }
  8881. else if(sStatus.equalsIgnoreCase("talking") == true)
  8882. {
  8883. //통화중
  8884. }
  8885. //응답값 입력 필요!!
  8886. //김용성 과장님 작업필요
  8887. reply_Message = "null";
  8888. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  8889. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  8890. retXML += " </service>\r\n</imap>";
  8891. return retXML;
  8892. }
  8893. catch(Exception e)
  8894. {
  8895. e.printStackTrace();
  8896. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  8897. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  8898. retXML += " </service>\r\n</imap>";
  8899. return retXML;
  8900. }
  8901. }
  8902. public String ProcChatMessage(Element ele)
  8903. {
  8904. String retXML = "";
  8905. String sChatMessage = "error";
  8906. String sMessage = "error";
  8907. try
  8908. {
  8909. NodeList items = ele.getElementsByTagName("chat");
  8910. Node item = items.item(0);
  8911. NamedNodeMap attrsParam = item.getAttributes();
  8912. sChatMessage = trimquotation(item.getTextContent());
  8913. ///////////////////////////////////////////////
  8914. items = ele.getElementsByTagName("message");
  8915. item = items.item(0);
  8916. attrsParam = item.getAttributes();
  8917. sMessage = trimquotation(item.getTextContent());
  8918. ///////////////////////////////////////////////
  8919. //test
  8920. Log.d(TAG, "sChatMessage is " + sChatMessage);
  8921. Log.d(TAG, "sMessage is " + sMessage);
  8922. //test
  8923. Intent intent = new Intent();
  8924. intent.setAction(define.NOTIFY_ACNAME);
  8925. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  8926. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  8927. intent.putExtra("ADD_MESSAGE", sMessage);
  8928. getApplicationContext().sendBroadcast(intent);
  8929. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  8930. retXML += " <message>\""+"null"+"\"</message>\r\n";
  8931. retXML += " </service>\r\n</imap>";
  8932. return retXML;
  8933. }
  8934. catch(Exception e)
  8935. {
  8936. e.printStackTrace();
  8937. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  8938. retXML += " </service>\r\n</imap>";
  8939. return retXML;
  8940. }
  8941. }
  8942. public String ProcEvacuationLadderOpen(Element ele)
  8943. {
  8944. String retXML = "";
  8945. try
  8946. {
  8947. String sDong = null;
  8948. String sHo = null;
  8949. NodeList items = ele.getElementsByTagName("home_info");
  8950. Node item = items.item(0);
  8951. NamedNodeMap attrsParam = item.getAttributes();
  8952. for(int i=0; i< attrsParam.getLength(); i++)
  8953. {
  8954. Node attr = attrsParam.item(i);
  8955. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8956. sDong = trimquotation(attr.getNodeValue());
  8957. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8958. sHo = trimquotation(attr.getNodeValue());
  8959. }
  8960. WallpadStatusData DBMGR = null;
  8961. DBMGR = new WallpadStatusData(getApplicationContext());
  8962. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8963. DBMGR.closeDB();
  8964. String myIP =addc.IPAddress;
  8965. String DownStair = null;
  8966. String[] SplitedString = myIP.split("\\.");
  8967. if(SplitedString != null)
  8968. {
  8969. if(SplitedString.length == 4)
  8970. {
  8971. int temp = Integer.parseInt(SplitedString[2]);
  8972. temp = temp - 1;
  8973. String tempDownStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  8974. Log.d(TAG, "DownStair IP address : " + tempDownStairIP);
  8975. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  8976. DownStair = String.valueOf(temp);
  8977. }
  8978. }
  8979. if ((sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo.equalsIgnoreCase(DownStair) == true))
  8980. {
  8981. /**
  8982. * 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  8983. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  8984. * **/
  8985. WallpadDeviceSet devset;
  8986. devset = new WallpadDeviceSet(getApplicationContext());
  8987. int StatusVal = devset.GetDeviceSetted("피난사다리");
  8988. devset.closeDB();
  8989. if ( StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  8990. {
  8991. /**
  8992. * 피난사다리 알림!!!
  8993. * **/
  8994. ReceiveNetworkLadderBr();
  8995. }
  8996. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  8997. retXML += " </service>\r\n</imap>";
  8998. return retXML;
  8999. }
  9000. else
  9001. {
  9002. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  9003. retXML += " </service>\r\n</imap>";
  9004. return retXML;
  9005. }
  9006. }
  9007. catch(Exception e)
  9008. {
  9009. e.printStackTrace();
  9010. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  9011. retXML += " </service>\r\n</imap>";
  9012. return retXML;
  9013. }
  9014. }
  9015. private void ReceiveNetworkLadderBr()
  9016. {
  9017. int base = 7000;
  9018. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  9019. int Menu_Start_Option = 1;
  9020. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  9021. int AlarmStatus = wdb.GetAlarmStatus();
  9022. wdb.closeDB();
  9023. boolean MgrAppRun = false;
  9024. final String packageNameMgr = "com.artncore.managersetting";
  9025. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  9026. if( MgrAppRun )
  9027. return;
  9028. if (AlarmStatus == WallpadStatusData.ALARM_ARISE ||AlarmStatus == WallpadStatusData.ALARM_STOP) return;
  9029. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  9030. int StatusVal = devset.GetDeviceSetted("피난사다리");
  9031. devset.closeDB();
  9032. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  9033. Common.SendAppFinishReqBR(getApplicationContext());
  9034. Intent newintent = new Intent(Intent.ACTION_MAIN);
  9035. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  9036. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  9037. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  9038. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  9039. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  9040. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  9041. getApplicationContext().startActivity(newintent);
  9042. }
  9043. }
  9044. /**
  9045. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  9046. * @param ele Element Xml 데이터
  9047. * @return String 타입의 응답 메시지 생성
  9048. * **/
  9049. public String SmartLightDetailInfo(Element ele)
  9050. {
  9051. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  9052. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  9053. }
  9054. /**
  9055. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  9056. * @param ele Element Xml 데이터
  9057. * @return String 타입의 응답 메시지 생성
  9058. * **/
  9059. public String KNXDeviceDetailInfo(Element ele) {
  9060. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  9061. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  9062. }
  9063. public String ProcSetServerChange(Element ele) {
  9064. String retXML = "";
  9065. String versionTXT = null;
  9066. try {
  9067. boolean bRet = false;
  9068. NodeList items = ele.getElementsByTagName("ver_server");
  9069. Node item = items.item(0);
  9070. Node text = item.getFirstChild();
  9071. versionTXT = trimquotation(text.getNodeValue());
  9072. if (versionTXT.equalsIgnoreCase("1.0")) {
  9073. bRet = true;
  9074. }
  9075. else if ( versionTXT.indexOf("2.") >= 0) {
  9076. bRet = true;
  9077. }
  9078. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9079. if (SetData != null && bRet == true) {
  9080. SetData.SetServerVer(versionTXT);
  9081. SetData.closeDB();
  9082. }
  9083. if (bRet == true) {
  9084. try {
  9085. iMapSverReload tSock = new iMapSverReload();
  9086. tSock.start();
  9087. } catch (IOException e) {
  9088. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  9089. e.printStackTrace();
  9090. }
  9091. }
  9092. // 버전 체크해서
  9093. // 응답하고 나서
  9094. // 수신부 쓰레드 재 로딩..
  9095. if (versionTXT != null && bRet == true) {
  9096. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  9097. retXML += " </service>\r\n</imap>";
  9098. return retXML;
  9099. }
  9100. else {
  9101. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  9102. retXML += " </service>\r\n</imap>";
  9103. return retXML;
  9104. }
  9105. } catch (Exception e) {
  9106. e.printStackTrace();
  9107. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  9108. retXML += " </service>\r\n</imap>";
  9109. return retXML;
  9110. }
  9111. }
  9112. // 메인 서버 소켓 클래스
  9113. public class iMapSverReload extends Thread {
  9114. ServerSocket svr;
  9115. public iMapSverReload() throws IOException {
  9116. /////////////////////////////////////////////////////////////////////
  9117. // 신형 단지서버 사용 유무를 가져온다.
  9118. /////////////////////////////////////////////////////////////////////
  9119. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9120. if (SetData != null) {
  9121. String serverVesionInfo = SetData.GetServerVer();
  9122. SetData.closeDB();
  9123. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  9124. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  9125. boolean retValue = devset.SetSubDevListItem( false , define.DEVICE_ID_NEW_DANJI_SERVER);
  9126. devset.closeDB();
  9127. }
  9128. else {
  9129. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  9130. boolean retValue = devset.SetSubDevListItem( true , define.DEVICE_ID_NEW_DANJI_SERVER);
  9131. devset.closeDB();
  9132. }
  9133. }
  9134. try {
  9135. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  9136. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  9137. wallpadDeviceSet.closeDB();
  9138. } catch(Exception e) {
  9139. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  9140. e.printStackTrace();
  9141. mNewDanjiServer = false;
  9142. }
  9143. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer );
  9144. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  9145. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  9146. // 관리 PC IP도 변경하도록 한다.
  9147. if (mNewDanjiServer == true) {
  9148. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  9149. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  9150. wallpadStatusData.closeDB();
  9151. }
  9152. else {
  9153. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  9154. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  9155. wallpadStatusData.closeDB();
  9156. }
  9157. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  9158. }
  9159. public void run() {
  9160. try {
  9161. try{ Thread.sleep(400); }catch(Exception e){ e.printStackTrace(); }
  9162. SvrSock.destoryThread();
  9163. for( int i = 0 ; i < 20 ; i++ )
  9164. {
  9165. if( SvrSock.isAlive() == false )
  9166. {
  9167. Log.d(TAG, " Receive Socket Reload i = : " + i );
  9168. break;
  9169. }
  9170. else
  9171. {
  9172. Log.d(TAG, " is Live Socket Reload i = : " + i );
  9173. }
  9174. try{ Thread.sleep(100); }catch(Exception e){ e.printStackTrace(); }
  9175. }
  9176. SvrSock = new iMapSverSocket();
  9177. SvrSock.start();
  9178. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  9179. try{ Thread.sleep(3000); }catch(Exception e){ e.printStackTrace(); }
  9180. try
  9181. {
  9182. Intent intent = new Intent();
  9183. intent.setAction(define.NOTIFY_ACNAME);
  9184. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  9185. getApplicationContext().sendBroadcast(intent);
  9186. }
  9187. catch( Exception e)
  9188. {
  9189. e.printStackTrace();
  9190. }
  9191. } catch (IOException e) {
  9192. e.printStackTrace();
  9193. }
  9194. }
  9195. }
  9196. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  9197. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  9198. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  9199. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  9200. public static final int SCHEDULE_START_CALLAPP = 30004;
  9201. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  9202. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  9203. public class SchedulerThread extends Thread
  9204. {
  9205. boolean doRun;
  9206. AddressSet addr;
  9207. String AddressStr;
  9208. String IPaddr;
  9209. String VerBSP = "";
  9210. String VerAPP;
  9211. String VerSetting;
  9212. String VerNews;
  9213. String VerWeather;
  9214. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  9215. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  9216. private jni mGleInterface = null;
  9217. private final int LIVE_SIGNAL_TIME = 20;
  9218. private int m_LiveSignalCount = 0;
  9219. private int m_MainAppLiveCount = 0;
  9220. Handler ScheDuleHandler = new Handler(){
  9221. public void handleMessage(Message msg) {
  9222. switch (msg.what) {
  9223. case SCHEDULE_START_HEARTBEAT:
  9224. {
  9225. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  9226. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9227. heartbeatP = DBMGR.GetHeartbeatPeriod();
  9228. DBMGR.closeDB();
  9229. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  9230. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  9231. }
  9232. break;
  9233. case SCHEDULE_CHANGE_HEARTBEAT:
  9234. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  9235. synchronized (ScheduleList) {
  9236. ScheduleData CheckData;
  9237. for (int i = 0; i < ScheduleList.size(); i++) {
  9238. CheckData = ScheduleList.get(i);
  9239. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  9240. Calendar cal = new GregorianCalendar();
  9241. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9242. heartbeatP = DBMGR.GetHeartbeatPeriod();
  9243. DBMGR.closeDB();
  9244. cal.add(Calendar.MINUTE,heartbeatP);
  9245. CheckData.TData = cal;
  9246. ScheduleList.set(i, CheckData);
  9247. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  9248. return;
  9249. }
  9250. }
  9251. }
  9252. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  9253. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  9254. break;
  9255. case SCHEDULE_START_STATUSBEAT:
  9256. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  9257. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  9258. break;
  9259. case SCHEDULE_CHANGE_STATUSBEAT:
  9260. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  9261. synchronized(ScheduleList) {
  9262. ScheduleData CheckData;
  9263. for (int i = 0; i < ScheduleList.size(); i++) {
  9264. CheckData = ScheduleList.get(i);
  9265. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  9266. Calendar cal = new GregorianCalendar();
  9267. cal.add(Calendar.MINUTE,heartbeatP);
  9268. CheckData.TData = cal;
  9269. ScheduleList.set(i, CheckData);
  9270. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  9271. return;
  9272. }
  9273. }
  9274. }
  9275. break;
  9276. case SCHEDULE_START_CALLAPP:
  9277. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  9278. // Bundle bundle = new Bundle();
  9279. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  9280. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  9281. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  9282. // .putExtra(ITEM_CALL_DATA, bundle);
  9283. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  9284. // iMAPstartActivity(intent);
  9285. break;
  9286. }
  9287. }
  9288. };
  9289. Handler GetHandler(){
  9290. return ScheDuleHandler;
  9291. }
  9292. public class ScheduleData
  9293. {
  9294. Calendar TData;
  9295. String ActionSTR;
  9296. public ScheduleData(Calendar tdata, String ActionStr)
  9297. {
  9298. TData = tdata;
  9299. ActionSTR = ActionStr;
  9300. }
  9301. }
  9302. public SchedulerThread()
  9303. {
  9304. doRun = true;
  9305. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9306. addr = DBMGR.getAddressMGR();
  9307. VerAPP = DBMGR.GetAPPVer();
  9308. VerSetting = DBMGR.GetSettingVer();
  9309. VerNews = DBMGR.GetNoticeVer();
  9310. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  9311. DBMGR.closeDB();
  9312. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  9313. {
  9314. try { mGleInterface = new jni(); }
  9315. catch(Exception e) { Log.e( "iMapServer" ,"[ExceptionError] - onCreate->mGleInterface Create : " + e); }
  9316. }
  9317. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT))
  9318. {
  9319. VerAPP = GetAppVersion();
  9320. }
  9321. AddressStr = addr.Dong+"동"+addr.Ho+"호";
  9322. IPaddr = addr.IPAddress;
  9323. ScheDulerHandler = ScheDuleHandler;
  9324. }
  9325. public void reg_schedule(int min, String Action)
  9326. {
  9327. for (int i = 0; i <ScheduleList.size();i++)
  9328. {
  9329. ScheduleData scdata = ScheduleList.get(i);
  9330. if (scdata.ActionSTR.equals(Action))
  9331. {
  9332. ScheduleList.remove(i);
  9333. break;
  9334. }
  9335. }
  9336. Calendar cal = new GregorianCalendar();
  9337. cal.add(Calendar.MINUTE,min);
  9338. ScheduleData regData = new ScheduleData(cal,Action );
  9339. synchronized(ScheduleList)
  9340. {
  9341. ScheduleList.add(regData);
  9342. }
  9343. }
  9344. private void doSchedule(String doing)
  9345. {
  9346. String[] doingData = doing.split(";");
  9347. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT))
  9348. {
  9349. try{
  9350. String SendingStr = MakeHeartbeat();
  9351. SendToServer(SendingStr);
  9352. Calendar cal = new GregorianCalendar();
  9353. String timedata = String.format("%04d",cal.get(Calendar.YEAR))+"."+String.format("%02d",cal.get(Calendar.MONTH)+1)+"."+String.format("%02d",cal.get(Calendar.DAY_OF_MONTH))+"."+String.format("%02d",cal.get(Calendar.HOUR_OF_DAY))+"."+String.format("%02d",cal.get(Calendar.MINUTE))+"."+String.format("%02d",cal.get(Calendar.SECOND));
  9354. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9355. DBMGR.SetLastHeartbeat(timedata);
  9356. heartbeatP = DBMGR.GetHeartbeatPeriod();
  9357. DBMGR.closeDB();
  9358. }
  9359. catch (Exception e)
  9360. {
  9361. e.printStackTrace();
  9362. }
  9363. }
  9364. else if (doingData[0].equals("UPDATETIME"))
  9365. {
  9366. }
  9367. else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT))
  9368. {
  9369. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  9370. if (!Common.getDeviceServeiceLoadComplite()) return;
  9371. String SendingStr = MakeStatusReport();
  9372. if (SendingStr == null) return;
  9373. SendToServer(SendingStr);
  9374. Calendar cal = new GregorianCalendar();
  9375. String timedata = String.format("%04d",cal.get(Calendar.YEAR))+"."+String.format("%02d",cal.get(Calendar.MONTH)+1)+"."+String.format("%02d",cal.get(Calendar.DAY_OF_MONTH))+"."+String.format("%02d",cal.get(Calendar.HOUR_OF_DAY))+"."+String.format("%02d",cal.get(Calendar.MINUTE))+"."+String.format("%02d",cal.get(Calendar.SECOND));
  9376. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9377. DBMGR.SetLastStatusbeat(timedata);
  9378. DBMGR.closeDB();
  9379. int StatusP = 720;
  9380. try {
  9381. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  9382. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  9383. devset.closeDB();
  9384. if (StatusVal == null) StatusP = 720;
  9385. else StatusP = Integer.parseInt(StatusVal[1]);
  9386. }
  9387. catch(Exception e)
  9388. {
  9389. e.printStackTrace();
  9390. }
  9391. reg_schedule(StatusP,SCHEDULE_ACTION_STATUSBEAT);
  9392. }
  9393. }
  9394. private String MakeHeartbeat() {
  9395. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9396. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  9397. VerNews = DBMGR.GetNoticeVer();
  9398. VerSetting = DBMGR.GetSettingVer();
  9399. String VerServer = DBMGR.GetServerVer();
  9400. DBMGR.closeDB();
  9401. if (VerServer == null) {
  9402. Log.d(TAG, "VerServer null");
  9403. VerServer = "1.0";
  9404. }
  9405. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  9406. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  9407. wallpadDeviceSet.closeDB();
  9408. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  9409. // 스마트 분전반
  9410. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  9411. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  9412. String retStr = XMLHeader+
  9413. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  9414. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  9415. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  9416. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  9417. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  9418. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  9419. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  9420. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  9421. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  9422. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  9423. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  9424. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n"+
  9425. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n"+
  9426. "</service>\r\n</imap>";
  9427. return retStr;
  9428. }
  9429. else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  9430. // TODO KNX 분전반
  9431. // String retStr = XMLHeader+
  9432. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  9433. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  9434. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  9435. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  9436. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  9437. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  9438. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  9439. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  9440. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  9441. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  9442. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  9443. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  9444. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  9445. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  9446. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  9447. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  9448. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  9449. // "</service>\r\n</imap>";
  9450. String retStr = XMLHeader+
  9451. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  9452. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  9453. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  9454. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  9455. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  9456. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  9457. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  9458. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  9459. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  9460. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  9461. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  9462. "</service>\r\n</imap>";
  9463. return retStr;
  9464. }
  9465. else {
  9466. String retStr = XMLHeader+
  9467. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  9468. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  9469. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  9470. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  9471. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  9472. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  9473. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  9474. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  9475. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  9476. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  9477. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  9478. "</service>\r\n</imap>";
  9479. return retStr;
  9480. }
  9481. }
  9482. public String GetAppVersion() {
  9483. PackageInfo pi = null;
  9484. try {
  9485. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  9486. }
  9487. catch (Exception e) {e.printStackTrace();}
  9488. return pi.versionName;
  9489. }
  9490. public void run()
  9491. {
  9492. while(/*doRun*/ true)
  9493. {
  9494. //Common.DebugLog("SchedulerThread ------ 10Sec");
  9495. CheckHeartBeat();
  9496. CheckStatusBeat();
  9497. CheckWallPadLiveSignal();
  9498. LiveCheckRebooting();
  9499. try { Thread.sleep(10000);} catch (Exception e) {e.printStackTrace();}
  9500. }
  9501. }
  9502. public void SetLive() {
  9503. m_MainAppLiveCount++;
  9504. }
  9505. private int CheckTime30Sec = 0 ;
  9506. private void LiveCheckRebooting() {
  9507. try {
  9508. CheckTime30Sec++;
  9509. if (CheckTime30Sec%20 == 0) {
  9510. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  9511. // // 10초마다 수행되는 함수이니....
  9512. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  9513. // if (m_MainAppLiveCount == 0) {
  9514. // //리셋
  9515. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  9516. // {
  9517. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  9518. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  9519. // pm.userActivity(8, true);
  9520. // }
  9521. // else
  9522. // {
  9523. // Log.d(TAG, "Main App Down Reset IHN_750");
  9524. // WallPadInterface wpdifc = new WallPadInterface();
  9525. // wpdifc.WachdogSystemReset();
  9526. // }
  9527. // }
  9528. // }
  9529. CheckTime30Sec = 0;
  9530. }
  9531. if( CheckTime30Sec >= 30000)
  9532. {
  9533. CheckTime30Sec = 0;
  9534. }
  9535. }
  9536. catch( Exception e )
  9537. {
  9538. e.printStackTrace();
  9539. }
  9540. }
  9541. private void CheckWallPadLiveSignal()
  9542. {
  9543. try
  9544. {
  9545. int nTime = LIVE_SIGNAL_TIME / 10;
  9546. m_LiveSignalCount++;
  9547. if( m_LiveSignalCount >= nTime )
  9548. {
  9549. m_LiveSignalCount = 0;
  9550. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  9551. }
  9552. }
  9553. catch( Exception e )
  9554. {
  9555. Log.e("imapServer" , "CheckWallPadLiveSignal Exeption :" + e);
  9556. }
  9557. }
  9558. protected void CheckStatusBeat()
  9559. {
  9560. try {
  9561. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  9562. String statusbeatdata = WPD.GetLastStatusbeat();
  9563. WPD.closeDB();
  9564. int StatusP = 720;
  9565. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  9566. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  9567. if (StatusVal == null) StatusP = 720;
  9568. else
  9569. StatusP = Integer.parseInt(StatusVal[1]);
  9570. devset.closeDB();
  9571. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  9572. }
  9573. catch(Exception e)
  9574. {
  9575. e.printStackTrace();
  9576. }
  9577. }
  9578. protected void CheckHeartBeat()
  9579. {
  9580. try {
  9581. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  9582. String heartbeatdata = WPD.GetLastHeartbeat();
  9583. int heartbeatPer = WPD.GetHeartbeatPeriod();
  9584. WPD.closeDB();
  9585. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  9586. }
  9587. catch(Exception e)
  9588. {
  9589. e.printStackTrace();
  9590. }
  9591. }
  9592. protected boolean CheckTime(String CheckT, int period)
  9593. {
  9594. Calendar last = new GregorianCalendar();
  9595. String[] timedata = CheckT.split("[.]");
  9596. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  9597. last.set(Calendar.MONTH, Integer.parseInt(timedata[1])-1);
  9598. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  9599. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  9600. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  9601. last.add(Calendar.MINUTE, period);
  9602. Calendar checkCal = new GregorianCalendar();
  9603. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  9604. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  9605. return true;
  9606. return false;
  9607. }
  9608. }
  9609. class SendMSGToSVR extends Thread
  9610. {
  9611. String sendmsg;
  9612. public SendMSGToSVR(String msg)
  9613. {
  9614. sendmsg = msg;
  9615. }
  9616. public void run()
  9617. {
  9618. Socket sock;
  9619. try {
  9620. // 신형 단지서버 사용 유무를 가져온다.
  9621. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  9622. boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  9623. wallpadDeviceSet.closeDB();
  9624. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9625. SVRIP = DBMGR.GetServerIP();
  9626. port = DBMGR.GetServerPort();
  9627. DBMGR.closeDB();
  9628. /////////////////////////////////////////////////////////////////////
  9629. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  9630. // 사용중일 경우 암호화 소켓을 생성한다.
  9631. /////////////////////////////////////////////////////////////////////
  9632. if(!bNewDanjiServer)
  9633. {
  9634. sock = new Socket(SVRIP,port);
  9635. }
  9636. else
  9637. {
  9638. int setport = port + 1000;
  9639. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  9640. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  9641. sock = sslClientSocket.getSocket();
  9642. }
  9643. /////////////////////////////////////////////////////////////////////
  9644. sock.setSoLinger(true, 1000);
  9645. DataOutputStream outstream = new DataOutputStream(sock.getOutputStream());
  9646. byte[] outBF = sendmsg.getBytes("euc-kr");
  9647. outstream.write(outBF);
  9648. outstream.flush();
  9649. sock.close();
  9650. } catch (Exception e) {
  9651. e.printStackTrace();
  9652. }
  9653. }
  9654. }
  9655. private void SendToServer(String msg)
  9656. {
  9657. SendMSGToSVR msan = new SendMSGToSVR(msg);
  9658. msan.start();
  9659. }
  9660. boolean StatusBeatRequested = false;
  9661. private String MakeStatusReport()
  9662. {
  9663. try
  9664. {
  9665. String ServiceType = StatusBeatRequested?"requested":"notice";
  9666. StatusBeatRequested = false;
  9667. String RetData = XMLHeader+"<service type=\""+ServiceType+"\" name=\"statusbeat\"> \r\n";
  9668. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  9669. String[] typeList = SettManager.GetTypeList();
  9670. if (typeList == null || typeList.length == 0) {
  9671. DefaultProcauscultateReq(SettManager);
  9672. typeList = SettManager.GetTypeList();
  9673. }
  9674. SettManager.closeDB();
  9675. String[] ControlList;
  9676. String Vender = "null";
  9677. String devid = "null";
  9678. String Model = "null";
  9679. String subunitcnt = "null";
  9680. String statusRate = "null";
  9681. String statusType = "null";
  9682. String message = "null";
  9683. int itemCNT = 0;
  9684. int totalGroup = 0;
  9685. int totalItem = 0;
  9686. String ControlDEVList;
  9687. String ContentList = " ";
  9688. for (int i = 0; i < typeList.length; i++)
  9689. {
  9690. if (typeList[i].equals("ctrl_device"))
  9691. {
  9692. SettManager = new WallpadDevStatus(getApplicationContext());
  9693. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  9694. SettManager.closeDB();
  9695. ControlDEVList = "";
  9696. for (int k = 0; k < ControlList.length; k++)
  9697. {
  9698. if (ControlList[k].equals("light"))
  9699. {
  9700. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9701. int[] lightinfo = devSet.Get_Light_info();
  9702. devSet.closeDB();
  9703. if (lightinfo[0]==1)
  9704. {
  9705. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)
  9706. {
  9707. subunitcnt = String.valueOf(lightinfo[2]);
  9708. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  9709. devid = "0x11";
  9710. Vender = "null";
  9711. Model = "null";
  9712. lightCTR.TRInfo.GetTransactionList(0);
  9713. statusRate = String.format("%d/%d",lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess+lightCTR.TRInfo.RecentFail));
  9714. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  9715. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9716. message = "null";
  9717. ControlDEVList+=" <unit type=\"light\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  9718. itemCNT++;
  9719. }
  9720. else
  9721. {
  9722. subunitcnt = String.valueOf(lightinfo[2]);
  9723. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  9724. MultiSW.Refresh((byte)0xFF, false);
  9725. byte Bdevid = 0x51;
  9726. for(int j = 0; j <MultiSW.data.DeviceCnt;j++ )
  9727. {
  9728. devid = String.format("0x%02X",Bdevid+j);
  9729. Vender = "null";
  9730. Model = "null";
  9731. MultiSW.TRInfo.GetTransactionList(j);
  9732. statusRate = String.format("%d/%d",MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess+MultiSW.TRInfo.RecentFail));
  9733. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  9734. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9735. ControlDEVList+=" <unit type=\"light\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  9736. itemCNT++;
  9737. }
  9738. }
  9739. }
  9740. else
  9741. {
  9742. Vender = "null";
  9743. devid = "null";
  9744. Model = "null";
  9745. subunitcnt = "null";
  9746. statusRate = "null";
  9747. message = "null";
  9748. }
  9749. }
  9750. else if (ControlList[k].equals("thermostat"))
  9751. {
  9752. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9753. int ret = devSet.Get_Temper_Info();
  9754. devSet.closeDB();
  9755. if (ret == 1)
  9756. {
  9757. // 난방 종류를 얻어온다.
  9758. int HeatingKind = mWallPadAPI.GetHeatingKind();
  9759. HeatingV1API heatingV1API = null;
  9760. HeatingV2API heatingV2API = null;
  9761. // 종류별 API를 로딩한다.
  9762. if(HeatingKind == 1)
  9763. {
  9764. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  9765. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  9766. devid = "0x21";
  9767. Vender = "null";
  9768. Model = "null";
  9769. heatingV1API.TRInfo.GetTransactionList(0);
  9770. statusRate = String.format("%d/%d",heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess+heatingV1API.TRInfo.RecentFail));
  9771. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  9772. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9773. message = "null";
  9774. }
  9775. else if(HeatingKind == 2)
  9776. {
  9777. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  9778. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  9779. devid = "0x28";
  9780. Vender = "null";
  9781. Model = "null";
  9782. heatingV2API.TRInfo.GetTransactionList(0);
  9783. statusRate = String.format("%d/%d",heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess+heatingV2API.TRInfo.RecentFail));
  9784. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  9785. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9786. message = "null";
  9787. }
  9788. else
  9789. {
  9790. subunitcnt = "null";
  9791. devid = "null";
  9792. Vender = "null";
  9793. Model = "null";
  9794. statusRate = "0/0";
  9795. statusType = "bad";
  9796. message = "null";
  9797. }
  9798. ControlDEVList+=" <unit type=\"thermostat\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  9799. itemCNT++;
  9800. }
  9801. else
  9802. {
  9803. }
  9804. }
  9805. else if (ControlList[k].equals("gas"))
  9806. {
  9807. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9808. if (devSet.Get_GAS_Info() == 1)
  9809. {
  9810. GasAPI GasCTR = mWallPadAPI.Get_GasController();
  9811. subunitcnt = "1";
  9812. devid = "0x31";
  9813. Vender = "null";
  9814. Model = "null";
  9815. GasCTR.TRInfo.GetTransactionList(0);
  9816. statusRate = String.format("%d/%d",GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess+GasCTR.TRInfo.RecentFail));
  9817. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  9818. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9819. message = "null";
  9820. ControlDEVList+=" <unit type=\"gas\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  9821. itemCNT++;
  9822. }
  9823. else
  9824. {
  9825. }
  9826. devSet.closeDB();
  9827. }
  9828. else if (ControlList[k].equals("doorlock"))
  9829. {
  9830. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9831. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  9832. if (doorlockInfo[0] == 1)
  9833. {
  9834. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  9835. subunitcnt = "1";
  9836. devid = "0x41";
  9837. Vender = "null";
  9838. Model = "null";
  9839. DoorCTR.TRInfo.GetTransactionList(0);
  9840. statusRate = String.format("%d/%d",DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess+DoorCTR.TRInfo.RecentFail));
  9841. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  9842. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9843. message = "null";
  9844. ControlDEVList+=" <unit type=\"doorlock\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  9845. itemCNT++;
  9846. }
  9847. else
  9848. {
  9849. }
  9850. devSet.closeDB();
  9851. }
  9852. else if (ControlList[k].equals("ventil"))
  9853. {
  9854. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9855. int[] ventilInfo = devSet.Get_Ventil_Info();
  9856. if (ventilInfo[0] == 1)
  9857. {
  9858. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  9859. subunitcnt = "1";
  9860. devid = "0x61";
  9861. Vender = "null";
  9862. Model = "null";
  9863. VentilCTR.TRInfo.GetTransactionList(0);
  9864. statusRate = String.format("%d/%d",VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess+VentilCTR.TRInfo.RecentFail));
  9865. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  9866. statusType = surate>70?"good":surate>30?"notgood":"bad";
  9867. message = "null";
  9868. ControlDEVList+=" <unit type=\"ventil\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  9869. itemCNT++;
  9870. }
  9871. else
  9872. {
  9873. }
  9874. devSet.closeDB();
  9875. }
  9876. else if (ControlList[k].equals("aircon"))
  9877. {
  9878. }
  9879. else if (ControlList[k].equals("curtain"))
  9880. {
  9881. }
  9882. }
  9883. if (itemCNT > 0)
  9884. {
  9885. ContentList+="<group type=\"ctrl_device\" count=\""+itemCNT+"\">\r\n";
  9886. ContentList+=ControlDEVList;
  9887. ContentList+="</group>\r\n";
  9888. totalGroup++;
  9889. totalItem+=itemCNT;
  9890. }
  9891. }
  9892. else if (typeList[i].equals("talk_device"))
  9893. {
  9894. SettManager = new WallpadDevStatus(getApplicationContext());
  9895. ControlList = SettManager.GetSettingGroupData("talk_device");
  9896. SettManager.closeDB();
  9897. itemCNT = 0;
  9898. ControlDEVList = "";
  9899. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  9900. testAPI.GetVersion();
  9901. for (int k = 0; k < ControlList.length; k++)
  9902. {
  9903. if (ControlList[k].equals("kitchen_tv"))
  9904. {
  9905. ControlDEVList+=" <unit type=\"kitchen_tv\" id=\"0x02\" vendor=\""+testAPI.KitchenTV_Maker+"\" model=\""+testAPI.KitchenTV_Name+"\" subunit_cnt=\"0\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  9906. itemCNT++;
  9907. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  9908. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  9909. }
  9910. else if (ControlList[k].equals("bath_phone"))
  9911. {
  9912. ControlDEVList+=" <unit type=\"bath_phone\" id=\"0x02\" vendor=\""+testAPI.BathTV_Maker+"\" model=\""+testAPI.BathTV_Name+"\" subunit_cnt=\"0\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  9913. itemCNT++;
  9914. }
  9915. else if (ControlList[k].equals("subhome_dev"))
  9916. {
  9917. }
  9918. }
  9919. if (itemCNT > 0)
  9920. {
  9921. ContentList+="<group type=\"talk_device\" count=\""+itemCNT+"\">\r\n";
  9922. ContentList+=ControlDEVList;
  9923. ContentList+="</group>\r\n";
  9924. totalGroup++;
  9925. totalItem+=itemCNT;
  9926. }
  9927. }
  9928. else if (typeList[i].equals("sensor"))
  9929. {
  9930. SettManager = new WallpadDevStatus(getApplicationContext());
  9931. ControlList = SettManager.GetSettingGroupData("sensor");
  9932. SettManager.closeDB();
  9933. itemCNT = 0;
  9934. ControlDEVList = "";
  9935. for (int k = 0; k < ControlList.length; k++)
  9936. {
  9937. if (ControlList[k].equals("magnetic"))
  9938. {
  9939. WallPadInterface wpifc = new WallPadInterface();
  9940. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  9941. String SenStateCom;
  9942. String SenStateType;
  9943. if (MagSen==1)
  9944. {
  9945. SenStateCom = "1/1";
  9946. SenStateType = "";
  9947. }
  9948. else
  9949. {
  9950. SenStateCom = "0/1";
  9951. SenStateType = "perfect";
  9952. }
  9953. ControlDEVList+= " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  9954. itemCNT++;
  9955. }
  9956. else if (ControlList[k].equals("bugout"))
  9957. {
  9958. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9959. int sensor = devSet.Get_Sensor_Set();
  9960. devSet.closeDB();
  9961. if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0)
  9962. {
  9963. WallPadInterface wpifc = new WallPadInterface();
  9964. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  9965. String SenStateCom;
  9966. String SenStateType;
  9967. if (outSen==1)
  9968. {
  9969. SenStateCom = "1/1";
  9970. SenStateType = "bad";
  9971. }
  9972. else
  9973. {
  9974. SenStateCom = "0/1";
  9975. SenStateType = "perfect";
  9976. }
  9977. ControlDEVList+= " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  9978. itemCNT++;
  9979. }
  9980. }
  9981. else if (ControlList[k].equals("bugin"))
  9982. {
  9983. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9984. int sensor = devSet.Get_Sensor_Set();
  9985. devSet.closeDB();
  9986. if ((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0)
  9987. {
  9988. WallPadInterface wpifc = new WallPadInterface();
  9989. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  9990. String SenStateCom;
  9991. String SenStateType;
  9992. if (InSen==1)
  9993. {
  9994. SenStateCom = "1/1";
  9995. SenStateType = "bad";
  9996. }
  9997. else
  9998. {
  9999. SenStateCom = "0/1";
  10000. SenStateType = "perfect";
  10001. }
  10002. ControlDEVList+= " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  10003. itemCNT++;
  10004. }
  10005. }
  10006. else if (ControlList[k].equals("fire"))
  10007. {
  10008. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  10009. }
  10010. else if (ControlList[k].equals("gas"))
  10011. {
  10012. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  10013. }
  10014. }
  10015. if (itemCNT > 0)
  10016. {
  10017. ContentList+="<group type=\"sensor\" count=\""+itemCNT+"\">\r\n";
  10018. ContentList+=ControlDEVList;
  10019. ContentList+="</group>\r\n";
  10020. totalGroup++;
  10021. totalItem+=itemCNT;
  10022. }
  10023. }
  10024. else if (typeList[i].equals("extended"))
  10025. {
  10026. SettManager = new WallpadDevStatus(getApplicationContext());
  10027. ControlList = SettManager.GetSettingGroupData("extended");
  10028. SettManager.closeDB();
  10029. itemCNT=0;
  10030. ControlDEVList = "";
  10031. for (int k = 0; k < ControlList.length; k++)
  10032. {
  10033. if (ControlList[k].equals("gateway"))
  10034. {
  10035. }
  10036. else if (ControlList[k].equals("handy"))
  10037. {
  10038. }
  10039. else if (ControlList[k].equals("smartswitch"))
  10040. {
  10041. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10042. int[] BatchInfo = devSet.Get_BatchSW_Info();
  10043. devSet.closeDB();
  10044. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART )
  10045. {
  10046. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  10047. SmartSWCTR.TRInfo.GetTransactionList(0);
  10048. subunitcnt = "1";
  10049. statusRate = String.format("%d/%d",SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess+SmartSWCTR.TRInfo.RecentFail));
  10050. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  10051. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10052. message = "null";
  10053. ControlDEVList+=" <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10054. itemCNT++;
  10055. }
  10056. else
  10057. {
  10058. }
  10059. }
  10060. else if (ControlList[k].equals("energymeter"))
  10061. {
  10062. }
  10063. }
  10064. if (itemCNT > 0)
  10065. {
  10066. ContentList+="<group type=\"extended\" count=\""+itemCNT+"\">\r\n";
  10067. ContentList+=ControlDEVList;
  10068. ContentList+="</group>\r\n";
  10069. totalGroup++;
  10070. totalItem+=itemCNT;
  10071. }
  10072. }
  10073. }
  10074. SettManager.closeDB();
  10075. ContentList+="</guidemap> \r\n";
  10076. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\""+totalGroup+"\" device_cnt=\""+totalItem+"\">\r\n";
  10077. RetData += ContentList;
  10078. String LogSet;
  10079. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  10080. RetData+=LogSet;
  10081. try {
  10082. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  10083. String[] ResetData = WsDB.GetResetSchedule();
  10084. WsDB.closeDB();
  10085. if (!ResetData[0].equals("NONE"))
  10086. {
  10087. int type = Integer.parseInt(ResetData[0]);
  10088. if (type == WallpadStatusData.RESET_MONTH)
  10089. LogSet="<reset_info enable=\"true\" type=\"month\" cycle=\""+ResetData[1]+"\" time=\""+ResetData[2]+"\"/>\r\n";
  10090. else if (type == WallpadStatusData.RESET_WEEK)
  10091. LogSet="<reset_info enable=\"true\" type=\"week\" cycle=\""+ResetData[1]+"\" time=\""+ResetData[2]+"\"/>\r\n";
  10092. else
  10093. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  10094. }
  10095. else
  10096. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  10097. }
  10098. catch (Exception e)
  10099. {
  10100. e.printStackTrace();
  10101. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  10102. }
  10103. RetData+=LogSet;
  10104. RetData+="</service>\r\n</imap>\r\n";
  10105. return RetData;
  10106. }
  10107. catch( Exception e )
  10108. {
  10109. e.printStackTrace();
  10110. return null;
  10111. }
  10112. }
  10113. private String getKNXDeviceStatus(int device) {
  10114. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  10115. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  10116. String status = knxHeartbeat.getStatus();
  10117. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  10118. return status;
  10119. }
  10120. private String getKNXDeviceCause(int device) {
  10121. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  10122. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  10123. String cause = knxHeartbeat.getCause();
  10124. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  10125. return cause;
  10126. }
  10127. //mWallPadAPI
  10128. // private String TAG = "*yskim*";
  10129. //private IGW200dAPI iGW200dAPI = null;
  10130. /**
  10131. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  10132. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  10133. * 본 딜레이 코드를 임시로 적용한다.
  10134. */
  10135. @SuppressLint("HandlerLeak")
  10136. protected Handler IGW200APICheckHandler = new Handler() {
  10137. @SuppressLint("HandlerLeak")
  10138. @Override
  10139. public void handleMessage(Message msg) {
  10140. if (msg.what == 0) {
  10141. if (mWallPadAPI != null) {
  10142. Common.DebugLog("handleMessage what 0 ");
  10143. if (mWallPadAPI.Check_Connect()) IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  10144. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  10145. }
  10146. }
  10147. else if(msg.what == 1) {
  10148. Common.DebugLog("handleMessage what 1 ");
  10149. setIGE200Interface();
  10150. }
  10151. }
  10152. };
  10153. public void setIGE200Interface() {
  10154. try {
  10155. Common.DebugLog("setIGE200Interface");
  10156. mIGW200 = new IGW200(this, mWallPadAPI);
  10157. } catch (Exception e) {
  10158. Log.e(TAG, "[Exception] setIGE200Interface()");
  10159. e.printStackTrace();
  10160. }
  10161. }
  10162. /**
  10163. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  10164. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  10165. * 본 딜레이 코드를 임시로 적용한다.
  10166. */
  10167. @SuppressLint("HandlerLeak")
  10168. protected Handler IGW300APICheckHandler = new Handler() {
  10169. @SuppressLint("HandlerLeak")
  10170. @Override
  10171. public void handleMessage(Message msg) {
  10172. if (msg.what == 0) {
  10173. if (mWallPadAPI != null) {
  10174. Common.DebugLog("handleMessage what 0 ");
  10175. if (mWallPadAPI.Check_Connect()) IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  10176. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  10177. }
  10178. }
  10179. else if(msg.what == 1) {
  10180. Common.DebugLog("handleMessage what 1 ");
  10181. setIGE300Interface();
  10182. }
  10183. }
  10184. };
  10185. public void setIGE300Interface() {
  10186. try {
  10187. Common.DebugLog("setIGE300Interface");
  10188. mIGW300 = new IGW300(this, mWallPadAPI);
  10189. } catch (Exception e) {
  10190. Log.e(TAG, "[Exception] setIGE300Interface()");
  10191. e.printStackTrace();
  10192. }
  10193. }
  10194. // 외출모드 연동
  10195. private void ModeRunCtrlWorking( boolean WallpadUI , boolean BedMode )
  10196. {
  10197. try
  10198. {
  10199. bSmartSwitch485ComebackMode = false;
  10200. String [] mOutModeTextContents = { "엘리베이터호출" , "일괄소등" , "가스닫기", "난방외출모드" , "환기끄기", "쿡탑콘센트차단"};
  10201. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  10202. String outLinkCtrl = wd.GetOutModeLinkDevice();
  10203. if( BedMode == true )
  10204. outLinkCtrl = wd.GetInBedLinkDevice();
  10205. wd.closeDB();
  10206. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  10207. if( WallpadUI == false )
  10208. {
  10209. if( outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0 ) // 엘리베이터 호출
  10210. {
  10211. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0] );
  10212. CallElevatorBtn(false);
  10213. }
  10214. }
  10215. if( outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0 ) // 일괄소등 처리
  10216. {
  10217. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1] );
  10218. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  10219. }
  10220. if( (outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  10221. {
  10222. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2] );
  10223. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  10224. }
  10225. if( outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  10226. {
  10227. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3] );
  10228. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  10229. }
  10230. if( outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0 ) // 환기끄기
  10231. {
  10232. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4] );
  10233. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  10234. }
  10235. }
  10236. catch( Exception e )
  10237. {
  10238. Log.e("YSKIM", e.toString());
  10239. }
  10240. }
  10241. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  10242. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  10243. private boolean bSmartSwitch485ComebackMode = false ;
  10244. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  10245. try {
  10246. if (bSmartSwitch485ComebackMode == true) return;
  10247. String [] mCombackHomeTextContents = { "일괄소등해제" , "환기동작" , "난방외출모드해제", "웰컴조명" };
  10248. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  10249. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  10250. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  10251. wd.closeDB();
  10252. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  10253. // 일괄소등 해제
  10254. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0] );
  10255. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  10256. }
  10257. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0 ) {
  10258. // 환기동작
  10259. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1] );
  10260. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  10261. }
  10262. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  10263. // 난방 외출모드 해제
  10264. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2] );
  10265. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  10266. }
  10267. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  10268. // 웰컴조명 켜기
  10269. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3] );
  10270. // 웰컴조명 Handler 실행
  10271. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  10272. }
  10273. } catch (Exception e) {
  10274. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  10275. e.printStackTrace();
  10276. }
  10277. }
  10278. private Handler WelcomeLightHandler = new Handler()
  10279. {
  10280. int LightOnCount = 0;
  10281. @Override
  10282. public void handleMessage(Message msg)
  10283. {
  10284. if(msg.what == 0)
  10285. {
  10286. try
  10287. {
  10288. if(LightOnCount == 0)
  10289. {
  10290. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  10291. }
  10292. // 일괄소등 해제이면
  10293. if(mWallPadAPI.GetBatchSwitchStatus() == 1)
  10294. {
  10295. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  10296. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  10297. }
  10298. else
  10299. {
  10300. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  10301. LightOnCount++;
  10302. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  10303. if(LightOnCount > 10)
  10304. {
  10305. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  10306. LightOnCount = 0;
  10307. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  10308. }
  10309. }
  10310. }
  10311. catch (Exception e1)
  10312. {
  10313. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  10314. e1.printStackTrace();
  10315. }
  10316. }
  10317. else if(msg.what == 1)
  10318. {
  10319. try
  10320. {
  10321. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  10322. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  10323. LightOnCount = 0;
  10324. }
  10325. catch (Exception e1)
  10326. {
  10327. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  10328. e1.printStackTrace();
  10329. }
  10330. }
  10331. else if(msg.what == 2)
  10332. {
  10333. // Do Nothing
  10334. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  10335. WelcomeLightHandler.removeMessages(0);
  10336. }
  10337. }
  10338. };
  10339. //방범 및 알람 상태 확인 Resume 시 처리
  10340. private void CheckMainStatus() {
  10341. //try {Thread.sleep(100);}catch (Exception e){e.printStackTrace();}
  10342. try {
  10343. final String packageName = "com.artncore.apps.ic_wallpad";
  10344. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  10345. //CallAppRun = getForegroundAPK().equals(packageName);
  10346. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  10347. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10348. int alarmstate = SetData.GetAlarmStatus();
  10349. SetData.closeDB();
  10350. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate );
  10351. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  10352. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE" );
  10353. return;
  10354. }
  10355. else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  10356. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  10357. int base = 7000;
  10358. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  10359. int Menu_Start_Id = 0;
  10360. SetData = new WallpadStatusData(getApplicationContext());
  10361. int alarmtype = SetData.GetAlarmType();
  10362. SetData.closeDB();
  10363. switch (alarmtype) {
  10364. case WallpadStatusData.ALARM_ALERT:
  10365. Menu_Start_Id = Menu_Id_List[1];
  10366. break;
  10367. case WallpadStatusData.ALARM_EMM:
  10368. Menu_Start_Id = Menu_Id_List[0];
  10369. break;
  10370. case WallpadStatusData.ALARM_EVAC:
  10371. Menu_Start_Id = Menu_Id_List[3];
  10372. break;
  10373. case WallpadStatusData.ALARM_INVADE:
  10374. Menu_Start_Id =Menu_Id_List[2];
  10375. break;
  10376. case WallpadStatusData.ALARM_HEATING_LEAK:
  10377. Menu_Start_Id =Menu_Id_List[4];
  10378. break;
  10379. default:
  10380. Menu_Start_Id = Menu_Id_List[1];
  10381. break;
  10382. }
  10383. if (Menu_Start_Id > 0) {
  10384. /*
  10385. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  10386. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  10387. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  10388. * "RESUME"을 전달한다.
  10389. */
  10390. Intent newintent = new Intent(Intent.ACTION_MAIN);
  10391. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10392. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  10393. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  10394. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  10395. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10396. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10397. startActivity(newintent);
  10398. return;
  10399. }
  10400. }
  10401. else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  10402. if (OutModeRunAppRun == true) {
  10403. Log.d(TAG, "already outmoderun app running !!!!");
  10404. return;
  10405. }
  10406. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10407. int sensor = devset.Get_Sensor_Set();
  10408. devset.closeDB();
  10409. int base = 7000;
  10410. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  10411. int Menu_Start_Id = 0;
  10412. int Menu_Start_Option = 1;
  10413. if (sensor > 0) {
  10414. WallPadInterface wpifc = new WallPadInterface();
  10415. int[] SensorInfoDB;
  10416. int inSen = 0;
  10417. int outSen = 0;
  10418. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  10419. if (SensorInfoDB[0] == 1) {
  10420. // 내부동체가 사용함이면 상태 검사
  10421. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  10422. }
  10423. if (SensorInfoDB[1] == 1) {
  10424. // 외부동체가 사용함이면 상태 검사
  10425. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  10426. }
  10427. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  10428. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  10429. if (((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0 &&( outSen > 0 || inSen > 0)) ||
  10430. ((sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  10431. ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  10432. Intent newintent = new Intent(Intent.ACTION_MAIN);
  10433. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10434. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  10435. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10436. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0)?"bugout":"bugin");
  10437. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10438. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10439. startActivity(newintent);
  10440. return;
  10441. }
  10442. }
  10443. base = 8000;
  10444. Menu_Id_List = new int[]{ base+11};
  10445. Menu_Start_Id = base+11;
  10446. Menu_Start_Option = -1;
  10447. Intent intent = new Intent(Intent.ACTION_MAIN);
  10448. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10449. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  10450. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10451. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  10452. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10453. startActivity(intent);
  10454. }
  10455. else if (alarmstate == WallpadStatusData.GUARD_IN) {
  10456. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10457. int sensor = devset.Get_Sensor_Set();
  10458. devset.closeDB();
  10459. int base = 7000;
  10460. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  10461. int Menu_Start_Option = 1;
  10462. if (sensor > 0) {
  10463. WallPadInterface wpifc = new WallPadInterface();
  10464. int[] SensorInfoDB;
  10465. int outSen = 0;SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  10466. if (SensorInfoDB[1] == 1) {
  10467. // 외부동체가 사용함이면 상태 검사
  10468. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  10469. }
  10470. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  10471. if (((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0 &&( outSen > 0 )) ||
  10472. ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  10473. Intent newintent = new Intent(Intent.ACTION_MAIN);
  10474. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10475. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  10476. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10477. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  10478. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10479. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10480. startActivity(newintent);
  10481. return;
  10482. }
  10483. }
  10484. }
  10485. else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  10486. WallPadInterface wpifc = new WallPadInterface();
  10487. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  10488. return;
  10489. }
  10490. else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  10491. int base = 4000;
  10492. int Menu_Start_Id = 0;
  10493. int[] Menu_Id_List = new int[]{ base+11, base+21};
  10494. Menu_Start_Id = base+11;
  10495. Intent intent = new Intent(Intent.ACTION_MAIN);
  10496. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10497. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  10498. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  10499. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity","kr.co.icontrols.wallpadsecurity.MainActivity"));
  10500. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10501. startActivity(intent);
  10502. return;
  10503. }
  10504. } catch (Exception e) {
  10505. Log.e(TAG, "[Exception] CheckMainStatus()");
  10506. e.printStackTrace();
  10507. }
  10508. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10509. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  10510. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  10511. // {
  10512. // WallPadInterface wpifc = new WallPadInterface();
  10513. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  10514. //
  10515. // if (fleeSensor > 0)
  10516. // {
  10517. // int base = 7000;
  10518. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  10519. // int Menu_Start_Option = 1;
  10520. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  10521. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10522. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  10523. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10524. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  10525. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10526. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  10527. // startActivity(newintent);
  10528. // devset.closeDB();
  10529. // return;
  10530. // }
  10531. // }
  10532. //
  10533. // StatusVal = devset.GetDeviceSetted("알람발생");
  10534. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  10535. // {
  10536. // WallPadInterface wpifc = new WallPadInterface();
  10537. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  10538. //
  10539. // if (AlarmSensor > 0)
  10540. // {
  10541. // int base = 7000;
  10542. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  10543. // int Menu_Start_Option = 1;
  10544. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  10545. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10546. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  10547. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10548. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  10549. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10550. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  10551. // startActivity(newintent);
  10552. // devset.closeDB();
  10553. // return;
  10554. // }
  10555. //
  10556. // }
  10557. // devset.closeDB();
  10558. }
  10559. /**
  10560. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  10561. *
  10562. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  10563. */
  10564. public boolean GetUseIlgalControlForAdmin()
  10565. {
  10566. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10567. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  10568. devSet.closeDB();
  10569. boolean result = false;
  10570. if (MetringDB != null)
  10571. {
  10572. try
  10573. {
  10574. String devInfo = MetringDB[1];
  10575. devInfo = devInfo.replace('(', '_');
  10576. devInfo = devInfo.replace(':', '_');
  10577. devInfo = devInfo.replace(')', '_');
  10578. String[] MetringInfo = devInfo.split("_");
  10579. if (MetringInfo[3].equals("사용함") == true)
  10580. {
  10581. result = true;
  10582. }
  10583. }
  10584. catch (Exception e)
  10585. {
  10586. e.printStackTrace();
  10587. }
  10588. }
  10589. return result;
  10590. }
  10591. class SendLHGWCheck extends Thread
  10592. {
  10593. private iMAP_hn_config_read m_HnGWConfigRead = null;
  10594. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  10595. private boolean retSucces = false;
  10596. private int retryCount = 0;
  10597. public SendLHGWCheck()
  10598. {
  10599. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  10600. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  10601. retryCount = 0;
  10602. }
  10603. public void run()
  10604. {
  10605. try {
  10606. try{Thread.sleep(2000);}catch(Exception e){e.printStackTrace();}
  10607. for( int i = 0 ; i < 10 ; i++ )
  10608. {
  10609. m_HnGWConfigRead.DoWork();
  10610. m_HnGWConfigRead.SetRetCtr(new RetProci()
  10611. {
  10612. @Override
  10613. public void ProcSuccess()
  10614. {
  10615. retSucces = true;
  10616. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount );
  10617. }
  10618. @Override
  10619. public void ProcError()
  10620. {
  10621. }
  10622. @Override
  10623. public void ProcDoing()
  10624. {
  10625. // TODO Auto-generated method stub
  10626. }
  10627. });
  10628. if( retSucces == true )
  10629. break;
  10630. retryCount++;
  10631. try{Thread.sleep(3000);}catch(Exception e){e.printStackTrace();}
  10632. }
  10633. m_HnGWEmptyMsg.DoWork();
  10634. m_HnGWEmptyMsg.SetRetCtr(new RetProci()
  10635. {
  10636. @Override
  10637. public void ProcSuccess()
  10638. {
  10639. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess " );
  10640. }
  10641. @Override
  10642. public void ProcError()
  10643. {
  10644. Log.d(TAG, "HN GW EmptyMsg Send ProcError " );
  10645. }
  10646. @Override
  10647. public void ProcDoing()
  10648. {
  10649. // TODO Auto-generated method stub
  10650. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing " );
  10651. }
  10652. });
  10653. } catch (Exception e) {
  10654. e.printStackTrace();
  10655. }
  10656. }
  10657. }
  10658. //Reset Handler
  10659. private Handler mResetHandler = new Handler() {
  10660. @Override
  10661. public void handleMessage(Message msg) {
  10662. if (msg.what == 0) {
  10663. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  10664. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  10665. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  10666. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  10667. if (NowMainStatus == false) {
  10668. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  10669. ResetCount = 1;
  10670. }
  10671. ResetCount++;
  10672. NowMainStatus = true;
  10673. if (ResetCount == 30) {
  10674. mResetHandler.sendEmptyMessageDelayed(1, 10);
  10675. }
  10676. else {
  10677. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  10678. }
  10679. }
  10680. else {
  10681. if (NowMainStatus == true) {
  10682. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  10683. ResetCount = 1;
  10684. }
  10685. ResetCount++;
  10686. NowMainStatus = false;
  10687. if (ResetCount == 180) {
  10688. // 3분
  10689. mResetHandler.sendEmptyMessageDelayed(1, 10);
  10690. }
  10691. else {
  10692. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  10693. }
  10694. }
  10695. }
  10696. else if (msg.what == 1) {
  10697. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  10698. setDefaultLauncher();
  10699. Intent intent = new Intent();
  10700. intent.setAction(define.NOTIFY_ACNAME);
  10701. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  10702. getApplicationContext().sendBroadcast(intent);
  10703. }
  10704. }
  10705. };
  10706. // 통화주체를 다루는 enum
  10707. public enum CALLOWNER {
  10708. NONE,
  10709. WALLPAD,
  10710. SUB_WALLPAD,
  10711. KITCHEN_TV,
  10712. BATH_PHONE,
  10713. BATH_TV,
  10714. UNIVERSAL_DEVICE,
  10715. ERROR;
  10716. }
  10717. public enum CALLEVENTTYPE {
  10718. RECEIVE_CALL, // 호출 수신 (호출 수신)
  10719. TRYING_CALL, // 호출 시도중 (호출 발신)
  10720. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  10721. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  10722. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  10723. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  10724. CONNECT_CALL, // 통화 시작
  10725. TERMINATE_CALL, // 통화 종료
  10726. CANCEL_CALL, // 호출 취소
  10727. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  10728. REJECT_CALL, // 호출수신 거절
  10729. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  10730. FORWARD_CALL, // 착신전환 설정
  10731. CALLERID, // Caller ID
  10732. TIMEOUT_1STCALL, // 1st Call Timeout
  10733. TIMEOUT_2NDCALL, // 2nd Call Timeout
  10734. TIMEOUT_3RDCALL, // 3rd Call Timeout
  10735. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  10736. DOOR_OPEN, // 문열림 설정
  10737. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  10738. PSTN_DTMF, // PSTN DTMF 수신
  10739. DETECT_STRANGER, // 거동수상자 발생
  10740. NONE;
  10741. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  10742. try {
  10743. if (value.equals(RECEIVE_CALL.toString())) {
  10744. return RECEIVE_CALL;
  10745. } else if (value.equals(TRYING_CALL.toString())) {
  10746. return TRYING_CALL;
  10747. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  10748. return RECEIVE_CALL_2ND;
  10749. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  10750. return RECEIVE_CALL_ACK;
  10751. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  10752. return REQUEST_FRONT_MONITORING;
  10753. } else if (value.equals(CONNECT_CALL.toString())) {
  10754. return CONNECT_CALL;
  10755. } else if (value.equals(TERMINATE_CALL.toString())) {
  10756. return TERMINATE_CALL;
  10757. } else if (value.equals(CANCEL_CALL.toString())) {
  10758. return CANCEL_CALL;
  10759. } else if (value.equals(REJECT_CALL.toString())) {
  10760. return REJECT_CALL;
  10761. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  10762. return REJECT_BUSY_CALL;
  10763. } else if (value.equals(FORWARD_CALL.toString())) {
  10764. return FORWARD_CALL;
  10765. } else if (value.equals(CALLERID.toString())) {
  10766. return CALLERID;
  10767. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  10768. return TIMEOUT_1STCALL;
  10769. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  10770. return TIMEOUT_2NDCALL;
  10771. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  10772. return TIMEOUT_3RDCALL;
  10773. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  10774. return MOIP_VIDEO_SET;
  10775. } else if (value.equals(DOOR_OPEN.toString())) {
  10776. return DOOR_OPEN;
  10777. } else if (value.equals(PSTN_RING.toString())) {
  10778. return PSTN_RING;
  10779. } else if (value.equals(PSTN_DTMF.toString())) {
  10780. return PSTN_DTMF;
  10781. } else if (value.equals(DETECT_STRANGER.toString())) {
  10782. return DETECT_STRANGER;
  10783. } else if (value.equals(NONE.toString())) {
  10784. return NONE;
  10785. } else {
  10786. return null;
  10787. }
  10788. } catch (Exception e) {
  10789. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  10790. e.printStackTrace();
  10791. return null;
  10792. }
  10793. }
  10794. }
  10795. public enum CALLTYPE {
  10796. NONE,
  10797. FRONT,
  10798. RESIDENCE,
  10799. LOBBY,
  10800. GUARD,
  10801. PSTN,
  10802. IHUB,
  10803. ERROR,
  10804. }
  10805. public static class CALLTRIGGER {
  10806. public static String CALLOWNER = "CALLOWNER";
  10807. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  10808. public static String CALLTYPE = "CALLTYPE";
  10809. public enum SOURCE {
  10810. USER,
  10811. CALL_RECEIVE,
  10812. SUBPHONE
  10813. }
  10814. public enum TYPE {
  10815. MENU,
  10816. FRONT,
  10817. LOBBY,
  10818. GUARD,
  10819. RESIDENCE,
  10820. PSTN
  10821. }
  10822. }
  10823. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  10824. int TAB_TALKFRONT = 130011;
  10825. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  10826. try {
  10827. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType +"], nAlramStatus [" + nAlramStatus +"]");
  10828. if (!bWallPadCallLive) {
  10829. sendLCDBacklightStatus(true);
  10830. // 통화어플을 실행시킨다.
  10831. if (nAlramStatus != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  10832. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  10833. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  10834. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  10835. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  10836. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  10837. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10838. mIntent.setComponent(mComponentName);
  10839. startActivity(mIntent);
  10840. playFrontBell(eCallOwner, eEventType, eCallType);
  10841. }
  10842. else {
  10843. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  10844. // if (getUseSmartDoorCam()) {
  10845. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  10846. // }
  10847. }
  10848. } catch (Exception e) {
  10849. Log.e(TAG, "[Exception] runCallMainActivity()");
  10850. e.printStackTrace();
  10851. }
  10852. }
  10853. private String getTopActivity() {
  10854. try {
  10855. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  10856. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  10857. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  10858. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  10859. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  10860. return mComponentName.getPackageName();
  10861. } catch (Exception e) {
  10862. Log.e(TAG, "[Exception] getTopActivity()");
  10863. e.printStackTrace();
  10864. return null;
  10865. }
  10866. }
  10867. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  10868. try {
  10869. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  10870. WallPadInterface Wiface = new WallPadInterface();
  10871. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  10872. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  10873. }
  10874. } catch (Exception e) {
  10875. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  10876. e.printStackTrace();
  10877. }
  10878. }
  10879. private class AfterTransactionTodoListData
  10880. {
  10881. String Title;
  10882. int Valueint;
  10883. String ValueString;
  10884. private AfterTransactionTodoListData(String title, int valueint, String valueString)
  10885. {
  10886. Title = title;
  10887. Valueint = valueint;
  10888. ValueString = valueString;
  10889. }
  10890. }
  10891. /**
  10892. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  10893. * **/
  10894. public void SendGetParkingInfoIntent()
  10895. {
  10896. Intent iIntent = new Intent();
  10897. iIntent.setAction(define.NOTIFY_ACNAME);
  10898. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  10899. this.sendBroadcast(iIntent);
  10900. }
  10901. /**
  10902. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  10903. * **/
  10904. public Handler SendParkingInfoIntentAfter20min = new Handler()
  10905. {
  10906. @SuppressLint("HandlerLeak")
  10907. @Override
  10908. public void handleMessage(Message msg)
  10909. {
  10910. if (msg.what == 0)
  10911. {
  10912. SendGetParkingInfoIntent();
  10913. }
  10914. }
  10915. };
  10916. /**
  10917. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  10918. * **/
  10919. public Handler mWallPadOutmodeSleepHandler = new Handler()
  10920. {
  10921. @SuppressLint("HandlerLeak")
  10922. @Override
  10923. public void handleMessage(Message msg)
  10924. {
  10925. if(msg.what == 0)
  10926. {
  10927. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  10928. }
  10929. }
  10930. };
  10931. // Handler
  10932. public final class HANDLERMSG {
  10933. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  10934. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  10935. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  10936. public final static int CALLAPP_FINISHING_END = 300;
  10937. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  10938. }
  10939. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  10940. public void handleMessage(Message msg) {
  10941. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 +"]");
  10942. switch (msg.what) {
  10943. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  10944. bGlobalScreenRun = true;
  10945. break;
  10946. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  10947. bGlobalScreenRun = false;
  10948. break;
  10949. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  10950. break;
  10951. case HANDLERMSG.CALLAPP_FINISHING_END:
  10952. // bBlockCallEvent = false;
  10953. break;
  10954. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  10955. int time = Sound().PlayMent(SND.call.DINGDONG);
  10956. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  10957. if (time < 0) time = 2088;
  10958. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  10959. break;
  10960. default:
  10961. Log.v(TAG, "iMAPServerHandler : "+ msg.what);
  10962. break;
  10963. }
  10964. }
  10965. };
  10966. public void sendHandlerMsg(int what, int arg1, int arg2) {
  10967. try {
  10968. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 +"]");
  10969. Message HandleMsg = iMAPServerHandler.obtainMessage();
  10970. HandleMsg.what = what;
  10971. HandleMsg.arg1 = arg1;
  10972. HandleMsg.arg2 = arg2;
  10973. iMAPServerHandler.sendMessage(HandleMsg);
  10974. } catch (Exception e) {
  10975. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  10976. e.printStackTrace();
  10977. }
  10978. }
  10979. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  10980. try {
  10981. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 +"], delay [" + delay +"]");
  10982. Message HandleMsg = iMAPServerHandler.obtainMessage();
  10983. HandleMsg.what = what;
  10984. HandleMsg.arg1 = arg1;
  10985. HandleMsg.arg2 = arg2;
  10986. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  10987. } catch (Exception e) {
  10988. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  10989. e.printStackTrace();
  10990. }
  10991. }
  10992. int mSensitivity = 0, mDuration = 0;
  10993. int MIN_SENSOR_SENSITIVITY = 1;
  10994. int MAX_SENSOR_SENSITIVITY = 5;
  10995. int MIN_SENSOR_DURATION = 30;
  10996. int MAX_SENSOR_DURATION = 250;
  10997. int DEFAULT_SENSOR_SENSITIVITY = 3;
  10998. int DEFAULT_SENSOR_DURATION = 60;
  10999. private final int COMPONENT_USE = 1;
  11000. /**
  11001. * 스마트현관카메라 사용여부 판별
  11002. */
  11003. private boolean getUseSmartDoorCam() {
  11004. try {
  11005. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11006. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  11007. mWallpadDeviceSet.closeDB();
  11008. if (nFrontCam[0] == COMPONENT_USE) {
  11009. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  11010. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  11011. return true;
  11012. }
  11013. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  11014. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  11015. return true;
  11016. }
  11017. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  11018. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  11019. return true;
  11020. }
  11021. else {
  11022. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  11023. return false;
  11024. }
  11025. }
  11026. else {
  11027. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  11028. return false;
  11029. }
  11030. } catch (Exception e) {
  11031. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  11032. e.printStackTrace();
  11033. return false;
  11034. }
  11035. }
  11036. private int getSmartDoorCamType() {
  11037. try {
  11038. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11039. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  11040. mWallpadDeviceSet.closeDB();
  11041. if (nFrontCam[0] == COMPONENT_USE) {
  11042. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  11043. return nFrontCam[1];
  11044. }
  11045. }
  11046. } catch (Exception e) {
  11047. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  11048. e.printStackTrace();
  11049. }
  11050. return -1;
  11051. }
  11052. /**
  11053. * 방문객원격통화 솔루션 사용여부 판별
  11054. */
  11055. private boolean getRemoteCallUseInfo() {
  11056. try {
  11057. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  11058. if (mWallpadDeviceSet != null) {
  11059. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  11060. if (astrRemoteCall != null) {
  11061. if (astrRemoteCall[1].contains("사용함")) return true;
  11062. } else {
  11063. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  11064. }
  11065. }
  11066. mWallpadDeviceSet.closeDB();
  11067. } catch (Exception e) {
  11068. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  11069. e.printStackTrace();
  11070. }
  11071. return false;
  11072. }
  11073. /*
  11074. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  11075. */
  11076. private RealTimeMeterAPI mRealTimeMeterAPI;
  11077. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  11078. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  11079. public Thread saveRealmeterDataThread = null;
  11080. private void startRealtimemeterInfo() {
  11081. try {
  11082. // 영업샘플 모드 판단
  11083. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  11084. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  11085. }
  11086. else {
  11087. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  11088. // 실시간 검침기 사용유무 판단
  11089. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11090. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  11091. mWallpadDeviceSet.closeDB();
  11092. boolean bRealtimemeterUsage = false;
  11093. int nRealtimemeterCntDB = -99;
  11094. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  11095. // 실시간 검침 사용함
  11096. bRealtimemeterUsage = true;
  11097. nRealtimemeterCntDB = naRealtimemtInfo[1];
  11098. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  11099. }
  11100. else {
  11101. // 실시간 검침 사용하지 않음
  11102. bRealtimemeterUsage = false;
  11103. }
  11104. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB +"]");
  11105. }
  11106. } catch (Exception e) {
  11107. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  11108. e.printStackTrace();
  11109. }
  11110. }
  11111. private void startSmartIoTCamInfo() {
  11112. try {
  11113. // 영업샘플 모드 판단
  11114. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  11115. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  11116. }
  11117. else {
  11118. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  11119. if (getUseSmartDoorCam()) {
  11120. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  11121. }
  11122. else {
  11123. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  11124. }
  11125. }
  11126. } catch (Exception e) {
  11127. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  11128. e.printStackTrace();
  11129. }
  11130. }
  11131. private void startDistributionPanel() {
  11132. try {
  11133. // 영업샘플 모드 판단
  11134. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  11135. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I) {
  11136. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  11137. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11138. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  11139. mWallpadDeviceSet.closeDB();
  11140. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST) initSmartDistributionPanelHandler.sendEmptyMessage(0);
  11141. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) initKNXDistributionPanelHandler.sendEmptyMessage(0);
  11142. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  11143. }
  11144. else {
  11145. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  11146. }
  11147. } catch (Exception e) {
  11148. Log.e(TAG, "[Exception] startDistributionPanel()");
  11149. e.printStackTrace();
  11150. }
  11151. }
  11152. // =================================================================================================
  11153. // [[ Device ]] region
  11154. // =================================================================================================
  11155. /**
  11156. * 디바이스 API 를 Load 한다.
  11157. *
  11158. * @param wpapi - 생성시 전달받은 WallPadAPI
  11159. * @return (int) - >=0 : 성공, <0 : 실패
  11160. */
  11161. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  11162. // 1. Mode Check
  11163. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  11164. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  11165. return -1;
  11166. }
  11167. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  11168. // 2. wpapi Check
  11169. if (wpapi == null) {
  11170. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  11171. return -2;
  11172. }
  11173. // 3. Load API
  11174. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  11175. try {
  11176. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  11177. } catch(Exception e) {
  11178. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  11179. e.printStackTrace();
  11180. return -100;
  11181. }
  11182. if (mRealTimeMeterAPI == null) {
  11183. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  11184. return -4;
  11185. }
  11186. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  11187. return 0;
  11188. }
  11189. /**
  11190. * 제어기 상태를 가져온다.
  11191. *
  11192. * @param real - (boolean) true : 실시간 , false : 가장최근
  11193. * @return (int) - >=0 : 성공, <0 : 실패
  11194. */
  11195. @SuppressWarnings("unused")
  11196. private int updateRealtimemeterData(boolean real) {
  11197. try {
  11198. // 1. Api Load Check
  11199. if (mRealTimeMeterAPI == null) {
  11200. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  11201. return -1;
  11202. }
  11203. // 2. reflash
  11204. try {
  11205. int ret = mRealTimeMeterAPI.Refresh(real);
  11206. if (ret < 0) {
  11207. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  11208. return -2;
  11209. }
  11210. } catch(Exception e) {
  11211. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  11212. e.printStackTrace();
  11213. return -100;
  11214. }
  11215. // 3. Range Check
  11216. if (mRealTimeMeterAPI.data == null) {
  11217. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  11218. return -9;
  11219. }
  11220. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  11221. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  11222. return -10;
  11223. }
  11224. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  11225. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  11226. return -11;
  11227. }
  11228. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  11229. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  11230. return -12;
  11231. }
  11232. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  11233. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  11234. return -13;
  11235. }
  11236. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  11237. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  11238. return -14;
  11239. }
  11240. // 4. Data Copy
  11241. mRealTimeMeterData = mRealTimeMeterAPI.data;
  11242. // 5. Debug msg
  11243. if (DEBUG_REALMETER_DATA_LOG_ON) {
  11244. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  11245. Log.i(TAG, "[updateRealtimemeterData] - OK");
  11246. }
  11247. return 0;
  11248. } catch (Exception e) {
  11249. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  11250. e.printStackTrace();
  11251. return -99;
  11252. }
  11253. }
  11254. /**
  11255. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  11256. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  11257. * 본 딜레이 코드를 임시로 적용한다.
  11258. */
  11259. @SuppressLint("HandlerLeak")
  11260. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  11261. @SuppressLint("HandlerLeak")
  11262. @Override
  11263. public void handleMessage(Message msg) {
  11264. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  11265. if (msg.what == 0) {
  11266. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  11267. if (updateRealtimemeterData(false) == 0) {
  11268. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  11269. }
  11270. else {
  11271. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  11272. }
  11273. }
  11274. else {
  11275. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  11276. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  11277. }
  11278. }
  11279. else if (msg.what == 1) {
  11280. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  11281. if (mRealTimeMeterAPI != null) {
  11282. // Device_BrRegistration(true);
  11283. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11284. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  11285. mWallpadDeviceSet.closeDB();
  11286. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  11287. saveRealmeterDataThread = new saveRealmeterData();
  11288. saveRealmeterDataThread.start();
  11289. }
  11290. // RemoveUsedData();
  11291. // ShowUsedDataGraph();
  11292. }
  11293. }
  11294. }
  11295. };
  11296. protected Handler initSmartDistributionPanelHandler = new Handler() {
  11297. @SuppressLint("HandlerLeak")
  11298. @Override
  11299. public void handleMessage(Message msg) {
  11300. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  11301. if (msg.what == 0) {
  11302. if (mWallPadAPI.Check_Connect()) initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  11303. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  11304. } else if (msg.what == 1) {
  11305. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  11306. mSdbAPI = mWallPadAPI.Get_SdbController();
  11307. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  11308. mSdb_LivingRoomLightAPI.Refresh();
  11309. }
  11310. }
  11311. };
  11312. protected Handler initKNXDistributionPanelHandler = new Handler() {
  11313. @SuppressLint("HandlerLeak")
  11314. @Override
  11315. public void handleMessage(Message msg) {
  11316. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  11317. if (msg.what == 0) {
  11318. if (mWallPadAPI.Check_Connect()) initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  11319. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  11320. } else if (msg.what == 1) {
  11321. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  11322. mKnxAPI = mWallPadAPI.Get_KnxController();
  11323. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  11324. mKnx_LivingRoomLightAPI.Refresh();
  11325. }
  11326. }
  11327. };
  11328. protected Handler initSmartIoTFunctionHandler = new Handler() {
  11329. @SuppressLint("HandlerLeak")
  11330. @Override
  11331. public void handleMessage(Message msg) {
  11332. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  11333. if (msg.what == 0) {
  11334. if (mWallPadAPI.Check_Connect()) initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  11335. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  11336. } else if (msg.what == 1) {
  11337. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  11338. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  11339. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (상태 Off, LED Off)
  11340. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  11341. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  11342. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  11343. // 설정값을 확인하여 스마트 IoT 현관카메라의 상태를 전송한다. (거동수상자 녹화를 위한 자동 On 기능 활성화)
  11344. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  11345. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  11346. }
  11347. else {
  11348. // 설정값을 확인하여 스마트 IoT 현관카메라의 상태를 전송한다. (거동수상자 녹화를 위한 자동 On 기능 비활성화)
  11349. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  11350. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  11351. }
  11352. }
  11353. }
  11354. };
  11355. // 스마트현관카메라 MODE 제어
  11356. private void ctrlSmartIOTCamStatusMode(byte mode) {
  11357. try {
  11358. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  11359. if (mSmartKeyRfDoorAPI != null) {
  11360. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  11361. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  11362. }
  11363. else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  11364. } catch (Exception e) {
  11365. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  11366. e.printStackTrace();
  11367. }
  11368. }
  11369. // 스마트현관카메라 LED 상태 제어
  11370. private void ctrlSmartIOTCamLEDMode(byte mode) {
  11371. try {
  11372. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  11373. if (mSmartKeyRfDoorAPI != null) {
  11374. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  11375. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  11376. }
  11377. else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  11378. } catch (Exception e) {
  11379. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  11380. e.printStackTrace();
  11381. }
  11382. }
  11383. // =================================================================================================
  11384. // [[ Thread ]] region
  11385. // =================================================================================================
  11386. /**
  11387. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  11388. * 10분에 한번씩 저장
  11389. */
  11390. @SuppressLint("UseValueOf")
  11391. class saveRealmeterData extends Thread {
  11392. @Override
  11393. public void run() {
  11394. super.run();
  11395. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  11396. int ret;
  11397. wallpaddbmgr WallpadDBMGRforThread = null;
  11398. while(true) {
  11399. try {
  11400. Thread.sleep(1000 * 60 * 3); //3분마다
  11401. if (mRealTimeMeterAPI != null) {
  11402. ret = mRealTimeMeterAPI.Refresh(false);
  11403. if (ret == 0) {
  11404. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  11405. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :"+ mRealTimeMeterAPI.data.Elec.Acc);
  11406. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  11407. WallpadDBMGRforThread.InsertRealTimeMeterData(
  11408. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  11409. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  11410. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  11411. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  11412. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  11413. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  11414. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  11415. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  11416. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  11417. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  11418. );
  11419. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  11420. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :"+ tempInt);
  11421. if (tempInt > 6000) {
  11422. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  11423. }
  11424. WallpadDBMGRforThread.closeDB();
  11425. }
  11426. else {
  11427. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  11428. }
  11429. }
  11430. else {
  11431. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  11432. }
  11433. } catch (InterruptedException e1) {
  11434. // TODO Auto-generated catch block
  11435. if (WallpadDBMGRforThread != null) {
  11436. WallpadDBMGRforThread.closeDB();
  11437. }
  11438. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  11439. e1.printStackTrace();
  11440. }
  11441. }
  11442. }
  11443. }
  11444. /**
  11445. * 단지서버 2.0 사용여부
  11446. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  11447. * **/
  11448. public boolean NewServerUse() {
  11449. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11450. if (SetData != null) {
  11451. String serverVesionInfo = SetData.GetServerVer();
  11452. SetData.closeDB();
  11453. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  11454. return true;
  11455. }
  11456. }
  11457. return false;
  11458. }
  11459. /**
  11460. * 단지서버2.0 적용시에만 사용한다.
  11461. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  11462. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  11463. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  11464. **/
  11465. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  11466. String REMOTETYPE_SVR2WEB = "danji_web_control";
  11467. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  11468. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  11469. try {
  11470. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  11471. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  11472. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  11473. NodeList mNodeList = doc.getElementsByTagName("device_info");
  11474. Node mNode = mNodeList.item(0);
  11475. if (mNode != null) {
  11476. String alias = "null", twinid = "null";
  11477. NamedNodeMap attrsParam = mNode.getAttributes();
  11478. for (int j=0; j< attrsParam.getLength(); j++) {
  11479. Node attr = attrsParam.item(j);
  11480. if (attr.getNodeName().equalsIgnoreCase("alias")) alias = attr.getNodeValue();
  11481. else if (attr.getNodeName().equalsIgnoreCase("twinid")) twinid = attr.getNodeValue();
  11482. }
  11483. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  11484. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  11485. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  11486. return MOBILE_USER_AUTH_PASSED;
  11487. }
  11488. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  11489. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  11490. mWallpadMobileDeviceData.closeDB();
  11491. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  11492. else {
  11493. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  11494. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11495. return strReplyMsg;
  11496. }
  11497. }
  11498. else {
  11499. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  11500. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  11501. return strReplyMsg;
  11502. }
  11503. }
  11504. else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  11505. NodeList mNodeList = doc.getElementsByTagName("password_info");
  11506. Node mNode = mNodeList.item(0);
  11507. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  11508. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  11509. mWallpadStatusData.closeDB();
  11510. if (!checkPWValidation(strSavedWebCtrlPW)) {
  11511. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  11512. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11513. return strReplyMsg;
  11514. }
  11515. if (mNode != null) {
  11516. String strReceivedPW = "000000";
  11517. NamedNodeMap attrsParam = mNode.getAttributes();
  11518. for (int j=0; j< attrsParam.getLength(); j++) {
  11519. Node attr = attrsParam.item(j);
  11520. if (attr.getNodeName().equalsIgnoreCase("password")) strReceivedPW = attr.getNodeValue();
  11521. }
  11522. if (!checkPWValidation(strReceivedPW)) {
  11523. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  11524. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11525. return strReplyMsg;
  11526. }
  11527. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  11528. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  11529. return WEB_USER_AUTH_PASSED;
  11530. }
  11531. else {
  11532. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  11533. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11534. return strReplyMsg;
  11535. }
  11536. }
  11537. else {
  11538. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  11539. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  11540. return strReplyMsg;
  11541. }
  11542. }
  11543. else {
  11544. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  11545. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11546. return strReplyMsg;
  11547. }
  11548. } catch (Exception e) {
  11549. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  11550. e.printStackTrace();
  11551. return null;
  11552. }
  11553. }
  11554. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  11555. try {
  11556. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  11557. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  11558. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  11559. NodeList mNodeList = ele.getElementsByTagName("device_info");
  11560. Node mNode = mNodeList.item(0);
  11561. if (mNode != null) {
  11562. String alias = "null", twinid = "null";
  11563. NamedNodeMap attrsParam = mNode.getAttributes();
  11564. for (int j=0; j< attrsParam.getLength(); j++) {
  11565. Node attr = attrsParam.item(j);
  11566. if (attr.getNodeName().equalsIgnoreCase("alias")) alias = attr.getNodeValue();
  11567. else if (attr.getNodeName().equalsIgnoreCase("twinid")) twinid = attr.getNodeValue();
  11568. }
  11569. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  11570. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  11571. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  11572. return MOBILE_USER_AUTH_PASSED;
  11573. }
  11574. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  11575. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  11576. mWallpadMobileDeviceData.closeDB();
  11577. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  11578. else {
  11579. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  11580. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  11581. return strReplyMsg;
  11582. }
  11583. }
  11584. else {
  11585. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  11586. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  11587. return strReplyMsg;
  11588. }
  11589. }
  11590. else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  11591. NodeList mNodeList = ele.getElementsByTagName("password_info");
  11592. Node mNode = mNodeList.item(0);
  11593. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  11594. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  11595. mWallpadStatusData.closeDB();
  11596. if (!checkPWValidation(strSavedWebCtrlPW)) {
  11597. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  11598. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11599. return strReplyMsg;
  11600. }
  11601. if (mNode != null) {
  11602. String strReceivedPW = "000000";
  11603. NamedNodeMap attrsParam = mNode.getAttributes();
  11604. for (int j=0; j< attrsParam.getLength(); j++) {
  11605. Node attr = attrsParam.item(j);
  11606. if (attr.getNodeName().equalsIgnoreCase("password")) strReceivedPW = attr.getNodeValue();
  11607. }
  11608. if (!checkPWValidation(strReceivedPW)) {
  11609. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  11610. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11611. return strReplyMsg;
  11612. }
  11613. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  11614. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  11615. return WEB_USER_AUTH_PASSED;
  11616. }
  11617. else {
  11618. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  11619. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11620. return strReplyMsg;
  11621. }
  11622. }
  11623. else {
  11624. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  11625. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  11626. return strReplyMsg;
  11627. }
  11628. }
  11629. else {
  11630. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  11631. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  11632. return strReplyMsg;
  11633. }
  11634. } catch (Exception e) {
  11635. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  11636. e.printStackTrace();
  11637. return null;
  11638. }
  11639. }
  11640. String[] astrPreventedPWs = { "000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852" };
  11641. private boolean checkPWValidation(String strPW) {
  11642. try {
  11643. // null 확인
  11644. if (strPW == null) {
  11645. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  11646. return false;
  11647. }
  11648. // 입력된 비밀번호 길이 확인
  11649. if (strPW.length() != 6) {
  11650. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  11651. return false;
  11652. }
  11653. // 사전 금지된 비밀번호 확인
  11654. for (int i = 0; i < astrPreventedPWs.length; i++) {
  11655. if (strPW.contains(astrPreventedPWs[i])) {
  11656. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  11657. return false;
  11658. }
  11659. }
  11660. /*// 연속된 비밀번호 확인
  11661. int nSerialNoCnt = 0;
  11662. int nCompareNo = 0;
  11663. int[] naPW = new int[strPW.length()];
  11664. for (int i = 0; i < naPW.length; i++)
  11665. {
  11666. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  11667. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  11668. if (i ==0) {
  11669. nCompareNo = naPW[i];
  11670. nCompareNo++;
  11671. }
  11672. else if (0 < i && i < 6) {
  11673. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  11674. nCompareNo++;
  11675. }
  11676. else {
  11677. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  11678. }
  11679. }
  11680. if (nSerialNoCnt > 3) {
  11681. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  11682. return false;
  11683. }*/
  11684. // 동일한 번호 5회이상 입력 확인
  11685. int nSameNoCnt = 0;
  11686. for (int i = 0; i < strPW.length() - 1; i++) {
  11687. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  11688. nSameNoCnt++;
  11689. }
  11690. }
  11691. if (nSameNoCnt > 4) {
  11692. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  11693. return false;
  11694. }
  11695. // 동, 호정보 확인
  11696. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11697. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  11698. DBMGR.closeDB();
  11699. String strDong = addr.Dong;
  11700. String strHo = addr.Ho;
  11701. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  11702. if (strPW.substring(0,4).contains(strDong)) {
  11703. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  11704. return false;
  11705. }
  11706. if (strPW.substring(0,4).contains(strHo)) {
  11707. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  11708. return false;
  11709. }
  11710. return true;
  11711. } catch (Exception e) {
  11712. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  11713. e.printStackTrace();
  11714. return false;
  11715. }
  11716. }
  11717. public String iCMDProcOnePass(Element ele) {
  11718. String[] strTarget = { "null", "null", "null" }; // name, id, msg_no
  11719. String[] strDeviceInfo = { "null", "null" }; // alias, twinid
  11720. String strAction = "null", strTargetLobbyIP = "null";
  11721. try {
  11722. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  11723. String retStr = CheckiCMDProc("remote_access_onepass");
  11724. if (retStr != null) return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  11725. // 단지서버 2.0 사용여부 확인
  11726. if (!NewServerUse()) {
  11727. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  11728. }
  11729. // 메시지 송신지 구분
  11730. NodeList items = ele.getElementsByTagName("target");
  11731. Node item = items.item(0);
  11732. if (item != null) {
  11733. NamedNodeMap attrs = item.getAttributes();
  11734. for (int j = 0; j< attrs.getLength(); j++) {
  11735. Node attr = attrs.item(j);
  11736. if (attr.getNodeName().equalsIgnoreCase("name")) strTarget[0] = attr.getNodeValue();
  11737. else if (attr.getNodeName().equalsIgnoreCase("id")) strTarget[1] = attr.getNodeValue();
  11738. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) strTarget[2] = attr.getNodeValue();
  11739. }
  11740. }
  11741. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  11742. if (NewServerUse()) {
  11743. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  11744. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  11745. if (ServerCheckResult.contains("fail")) return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  11746. else if (ServerCheckResult.contains("deny")) return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  11747. else if (ServerCheckResult.contains("none")) return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  11748. else return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  11749. }
  11750. }
  11751. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  11752. Node itemDeviceParam = itemsDeviceParam.item(0);
  11753. if (itemDeviceParam != null) {
  11754. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  11755. for (int j=0; j< attrsParam.getLength(); j++) {
  11756. Node attr = attrsParam.item(j);
  11757. if (attr.getNodeName().equalsIgnoreCase("alias")) strDeviceInfo[0] = attr.getNodeValue();
  11758. else if (attr.getNodeName().equalsIgnoreCase("twinid")) strDeviceInfo[1] = attr.getNodeValue();
  11759. }
  11760. }
  11761. else {
  11762. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  11763. }
  11764. // 명령어 구분
  11765. NodeList itemsaction = ele.getElementsByTagName("action");
  11766. Node itemaction = itemsaction.item(0);
  11767. Node text = itemaction.getFirstChild();
  11768. strAction = text.getNodeValue();
  11769. strAction = trimquotation(strAction);
  11770. // 문열림 타겟 로비폰 IP
  11771. NodeList itemsParam = ele.getElementsByTagName("params");
  11772. Node itemParam = itemsParam.item(0);
  11773. if (itemParam != null) {
  11774. NamedNodeMap attrsParam = itemParam.getAttributes();
  11775. for (int j = 0; j < attrsParam.getLength(); j++) {
  11776. Node attr = attrsParam.item(j);
  11777. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) strTargetLobbyIP = attr.getNodeValue();
  11778. }
  11779. }
  11780. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  11781. if (strAction.equalsIgnoreCase("authorize_request")) {
  11782. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  11783. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  11784. }
  11785. else {
  11786. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  11787. }
  11788. } catch (Exception e) {
  11789. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  11790. e.printStackTrace();
  11791. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  11792. }
  11793. }
  11794. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  11795. try {
  11796. String strReplyXml = XMLHeader;
  11797. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  11798. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  11799. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  11800. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  11801. strReplyXml += " </service>\n";
  11802. strReplyXml += "</imap>";
  11803. return strReplyXml;
  11804. } catch (Exception e) {
  11805. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  11806. e.printStackTrace();
  11807. return "ERROR";
  11808. }
  11809. }
  11810. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  11811. try {
  11812. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName +"]");
  11813. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  11814. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  11815. miMAPLobbyOnePass.SetRetCtr(new RetProci(){
  11816. @Override
  11817. public void ProcSuccess() {
  11818. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  11819. }
  11820. @Override
  11821. public void ProcError() {
  11822. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  11823. }
  11824. @Override
  11825. public void ProcDoing() {
  11826. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  11827. }
  11828. });
  11829. } catch (Exception e) {
  11830. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  11831. e.printStackTrace();
  11832. }
  11833. }
  11834. private void saveBlackoutStatus(boolean bOccurred) {
  11835. try {
  11836. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  11837. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  11838. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  11839. mEditor.putBoolean("status", bOccurred);
  11840. mEditor.commit();
  11841. } catch (Exception e) {
  11842. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  11843. e.printStackTrace();
  11844. }
  11845. }
  11846. private boolean getBlackoutStatus() {
  11847. try {
  11848. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  11849. return mSharedPreferences.getBoolean("status", false);
  11850. } catch (Exception e) {
  11851. Log.e(TAG, "[Exception] getBlackoutStatus()");
  11852. e.printStackTrace();
  11853. return false;
  11854. }
  11855. }
  11856. /**
  11857. * JEFF, 2019.12.25
  11858. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  11859. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  11860. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  11861. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  11862. */
  11863. int MAX_WALLPADCALL_LIVE_CNT = 2;
  11864. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  11865. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  11866. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  11867. Handler handlerCheckWallPadCallLive = new Handler() {
  11868. public void handleMessage(Message msg) {
  11869. super.handleMessage(msg);
  11870. sendWallPadCallLiveBR_Request();
  11871. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  11872. }
  11873. };
  11874. private void sendWallPadCallLiveBR_Request() {
  11875. try {
  11876. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  11877. Intent mIntent = new Intent();
  11878. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  11879. getApplicationContext().sendBroadcast(mIntent);
  11880. if (nWallPadCallACKCnt >= 0) {
  11881. nWallPadCallACKCnt--;
  11882. }
  11883. else {
  11884. bWallPadCallLive = false;
  11885. Common.bWallPadCallLive = bWallPadCallLive;
  11886. }
  11887. if (bWallPadCallLive != getCallAppRunning()) {
  11888. setCallAppRunning(bWallPadCallLive);
  11889. }
  11890. Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  11891. } catch (Exception e) {
  11892. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  11893. e.printStackTrace();
  11894. }
  11895. }
  11896. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  11897. @Override
  11898. public void onReceive(Context context, Intent intent) {
  11899. try {
  11900. String strActionName = intent.getAction();
  11901. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  11902. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  11903. bWallPadCallLive = true;
  11904. Common.bWallPadCallLive = bWallPadCallLive;
  11905. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  11906. Log.w(TAG,"[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "]");
  11907. }
  11908. else {
  11909. Log.w(TAG,"[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  11910. }
  11911. } catch (Exception e) {
  11912. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  11913. e.printStackTrace();
  11914. }
  11915. }
  11916. };
  11917. static class CALLCTRLHANDLERMSG {
  11918. static final int RELEASE_BLOCK_FRONTCALL = 100;
  11919. }
  11920. boolean bBlockFrontCall = false;
  11921. Handler handlerCallCtrl = new Handler() {
  11922. public void handleMessage(Message msg) {
  11923. super.handleMessage(msg);
  11924. int nMSG = msg.what;
  11925. switch (nMSG) {
  11926. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  11927. bBlockFrontCall = false;
  11928. break;
  11929. }
  11930. }
  11931. };
  11932. /**
  11933. * JEFF, 2019.12.31
  11934. * WallPadCall 실행여부를 DB에 저장한다.
  11935. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  11936. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  11937. */
  11938. public void setCallAppRunning(boolean bRunning) {
  11939. try {
  11940. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  11941. mWallpadStatusData.SetCallAPKStatus(bRunning);
  11942. mWallpadStatusData.closeDB();
  11943. } catch (Exception e) {
  11944. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  11945. e.printStackTrace();
  11946. }
  11947. }
  11948. private boolean getCallAppRunning() {
  11949. boolean bRunning = false;
  11950. try {
  11951. WallpadStatusData WallpadStatusData = new WallpadStatusData(getApplicationContext());
  11952. bRunning = WallpadStatusData.GetCallAPKStatusRunning();
  11953. WallpadStatusData.closeDB();
  11954. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  11955. return bRunning;
  11956. } catch (Exception e) {
  11957. Log.d(TAG, "[Exception] getCallAppRunning()");
  11958. e.printStackTrace();
  11959. return false;
  11960. }
  11961. }
  11962. /**
  11963. * 통화앱 종료코드
  11964. */
  11965. public void killWallPadCall() {
  11966. try {
  11967. Log.i(TAG, "[killWallPadCall] ===== START =====");
  11968. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  11969. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  11970. Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  11971. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  11972. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  11973. // android.os.Process.killProcess(nWallPadCallPID);
  11974. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  11975. // if(list != null){
  11976. // for(int i=0;i<list.size();++i){
  11977. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  11978. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  11979. // android.os.Process.killProcess(pid);
  11980. // }
  11981. // }
  11982. // }
  11983. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  11984. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  11985. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  11986. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  11987. // android.os.Process.killProcess(pid);
  11988. } catch (Exception e) {
  11989. Log.e(TAG, "[Exception] killWallPadCall()");
  11990. e.printStackTrace();
  11991. }
  11992. }
  11993. private void checkForegroundActivity() {
  11994. try {
  11995. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  11996. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  11997. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  11998. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  11999. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  12000. } catch (Exception e) {
  12001. Log.e(TAG, "[Exception] checkForegroundActivity()");
  12002. e.printStackTrace();
  12003. }
  12004. }
  12005. /**
  12006. * JEFF, 2020.01.04
  12007. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  12008. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  12009. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  12010. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  12011. */
  12012. static long lConnectionPeriod = 0;
  12013. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  12014. boolean bRingGeneratorRun = false;
  12015. private void startIGW300RingGenerator() {
  12016. try {
  12017. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  12018. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  12019. bRingGeneratorRun = true;
  12020. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  12021. mIGW300RingGeneratorThread.start();
  12022. }
  12023. else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  12024. } catch (Exception e) {
  12025. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  12026. e.printStackTrace();
  12027. }
  12028. }
  12029. private void stopIGW300RingGenerator() {
  12030. try {
  12031. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  12032. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  12033. lConnectionPeriod = -999;
  12034. bRingGeneratorRun = false;
  12035. mIGW300RingGeneratorThread = null;
  12036. }
  12037. else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  12038. } catch (Exception e) {
  12039. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  12040. e.printStackTrace();
  12041. }
  12042. }
  12043. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  12044. private class IGW300RingGeneratorThread extends Thread {
  12045. public IGW300RingGeneratorThread() {
  12046. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  12047. }
  12048. public void run() {
  12049. try {
  12050. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  12051. if (bRingGeneratorRun) Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  12052. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  12053. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  12054. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  12055. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  12056. try {
  12057. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  12058. } catch (InterruptedException e) {
  12059. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  12060. e.printStackTrace();
  12061. }
  12062. }
  12063. bRingGeneratorRun = false;
  12064. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  12065. } catch (Exception e) {
  12066. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  12067. e.printStackTrace();
  12068. }
  12069. }
  12070. }
  12071. private void sendPSTNRingEvent(int nKeyCode) {
  12072. try {
  12073. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  12074. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  12075. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  12076. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  12077. intent.putExtra("keycode",nKeyCode);
  12078. getApplicationContext().sendBroadcast(intent);
  12079. } catch(Exception e) {
  12080. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  12081. e.printStackTrace();
  12082. }
  12083. }
  12084. /**
  12085. * 월패드 타입 판별
  12086. * @return bResult
  12087. * false: 메인월패드
  12088. * true: 서브월패드
  12089. */
  12090. public boolean getIsSubWallpad() {
  12091. boolean bResult = false;
  12092. try {
  12093. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  12094. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  12095. mWallpadDeviceSet.closeDB();
  12096. if(DBinfo != null) {
  12097. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  12098. else bResult = false;
  12099. }
  12100. } catch (Exception e) {
  12101. Log.e(TAG, "[Exception] getIsSubWallpad()");
  12102. e.printStackTrace();
  12103. }
  12104. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  12105. return bResult;
  12106. }
  12107. /**
  12108. * JEFF, 2020.02.05
  12109. * 월패드 비상접점 신호 사용 여부 확인
  12110. */
  12111. public boolean getEmergencyIOUsage() {
  12112. boolean bResult = false;
  12113. try {
  12114. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  12115. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  12116. mWallpadDeviceSet.closeDB();
  12117. } catch (Exception e) {
  12118. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  12119. e.printStackTrace();
  12120. }
  12121. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  12122. return bResult;
  12123. }
  12124. /**
  12125. * JEFF, 2020.02.05
  12126. * 거동수상자 녹화기능 활성화 확인
  12127. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  12128. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  12129. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  12130. */
  12131. public boolean getStrangerRecordingManagerSetting() {
  12132. boolean bResult = false;
  12133. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12134. try {
  12135. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  12136. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  12137. mWallpadDeviceSet.closeDB();
  12138. if (nFrontCam[0] == COMPONENT_USE) {
  12139. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  12140. if (bRecord) bResult = true;
  12141. else bResult = false;
  12142. }
  12143. else bResult = false;
  12144. }
  12145. else bResult = false;
  12146. } catch (Exception e) {
  12147. mWallpadDeviceSet.closeDB();
  12148. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  12149. e.printStackTrace();
  12150. }
  12151. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  12152. return bResult;
  12153. }
  12154. /**
  12155. * Edited by jeff (2020.06.22)
  12156. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  12157. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  12158. * @param bOn
  12159. */
  12160. private void sendLCDBacklightStatus(boolean bOn) {
  12161. try {
  12162. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  12163. Intent mIntent = new Intent();
  12164. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  12165. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  12166. getApplicationContext().sendBroadcast(mIntent);
  12167. } catch (Exception e) {
  12168. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  12169. e.printStackTrace() ;
  12170. }
  12171. }
  12172. // 명칭 관련
  12173. boolean bRoomNameLog = true;
  12174. public static final int HEATING = 1;
  12175. public static final int LIGHT = 2;
  12176. private String[] mRoomNameList_Light = null; //조명 방 명칭
  12177. private String[] mRoomNameList_Heating = null; //난방 방 명칭
  12178. private String[] mDefaultRoomNameList = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  12179. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  12180. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  12181. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  12182. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  12183. /**
  12184. * DB 에서 룸이름 정보를 가져온다.
  12185. *
  12186. * @return (String []) null - 실패, not null
  12187. */
  12188. private String[] getDBRoomName() {
  12189. try {
  12190. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  12191. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  12192. wallpadStatusData.closeDB();
  12193. if (strRoomNameList == null) {
  12194. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  12195. return null;
  12196. }
  12197. if (bRoomNameLog) {
  12198. for (int i = 0; i < strRoomNameList.length; i++)
  12199. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  12200. }
  12201. return strRoomNameList;
  12202. } catch (Exception e) {
  12203. Log.e(TAG, "[Exception] getDBRoomName()");
  12204. e.printStackTrace();
  12205. }
  12206. return null;
  12207. }
  12208. /**
  12209. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  12210. *
  12211. * @param nDeviceType - int
  12212. * @return (String []) null - 실패, not null
  12213. */
  12214. private String[] getDBRoomName(int nDeviceType) {
  12215. try {
  12216. String[] strRoomNameList = null;
  12217. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  12218. if (nDeviceType == HEATING) {
  12219. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  12220. }
  12221. else {
  12222. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  12223. }
  12224. wallpadStatusData.closeDB();
  12225. if (strRoomNameList == null) {
  12226. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  12227. return null;
  12228. }
  12229. if (bRoomNameLog) {
  12230. for (int i = 0; i < strRoomNameList.length; i++)
  12231. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  12232. }
  12233. return strRoomNameList;
  12234. } catch (Exception e) {
  12235. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  12236. e.printStackTrace();
  12237. }
  12238. return null;
  12239. }
  12240. /**
  12241. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  12242. **/
  12243. private void getRoomName() {
  12244. try {
  12245. Log.i(TAG, "[getRoomName] ====================");
  12246. // WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12247. // boolean bRoomNameEach = wallpadDeviceSet.GetEachRoomNameInfo();
  12248. // wallpadDeviceSet.closeDB();
  12249. // Log.i(TAG, "[getRoomName] bRoomNameEach [" + bRoomNameEach + "]");
  12250. //
  12251. // if (bRoomNameEach) {
  12252. // // 명칭 난방, 조명 분리 사용
  12253. // mRoomNameList_Light = getDBRoomName(LIGHT);
  12254. // if (mRoomNameList_Light == null) {
  12255. // mRoomNameList_Light = mDefaultRoomNameList_Light;
  12256. // }
  12257. //
  12258. // if (getEasyModeUXUsage()) {
  12259. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  12260. // }
  12261. // else {
  12262. // mRoomNameList_Heating = getDBRoomName(HEATING);
  12263. // if (mRoomNameList_Heating == null) {
  12264. // mRoomNameList_Heating = mDefaultRoomNameList_Heating;
  12265. // }
  12266. // }
  12267. // }
  12268. // else {
  12269. // // 명칭 통합사용
  12270. // mRoomNameList_Light = getDBRoomName();
  12271. // if (mRoomNameList_Light == null) {
  12272. // mRoomNameList_Light = mDefaultRoomNameList;
  12273. // }
  12274. //
  12275. // if (getEasyModeUXUsage()) {
  12276. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  12277. // }
  12278. // else {
  12279. // mRoomNameList_Heating = getDBRoomName();
  12280. // if (mRoomNameList_Heating == null) {
  12281. // mRoomNameList_Heating = mDefaultRoomNameList;
  12282. // }
  12283. // }
  12284. // }
  12285. //
  12286. // if (bRoomNameLog) {
  12287. // for (int i = 0; i < mRoomNameList_Light.length; i++) {
  12288. // Log.i(TAG, "[getRoomName] mRoomNameList_Light[" + i + "] " + mRoomNameList_Light[i]);
  12289. // }
  12290. //
  12291. // for (int i = 0; i < mRoomNameList_Heating.length; i++) {
  12292. // Log.i(TAG, "[getRoomName] mRoomNameList_Heating[" + i + "] " + mRoomNameList_Heating[i]);
  12293. // }
  12294. // }
  12295. } catch (Exception e) {
  12296. Log.e(TAG, "[Exception] getRoomName()");
  12297. e.printStackTrace();
  12298. }
  12299. }
  12300. public boolean getEasyModeUXUsage() {
  12301. try {
  12302. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  12303. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  12304. deviceSet.closeDB();
  12305. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  12306. boolean bUse = data.GetEasyModeUxUse();
  12307. data.closeDB();
  12308. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  12309. return bSupport & bUse;
  12310. } catch (Exception e) {
  12311. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  12312. e.printStackTrace();
  12313. }
  12314. return false;
  12315. }
  12316. /**
  12317. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  12318. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  12319. * 재설정 5초 후 월패드 재부팅을 실행한다.
  12320. * 2020.11.18 SEULKI
  12321. */
  12322. public void checkDoorCamConfig() {
  12323. try {
  12324. if (Build.VERSION.SDK_INT > 23) {
  12325. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  12326. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  12327. if (!checkAvailableBSPDoorCamConfig()) {
  12328. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  12329. return;
  12330. }
  12331. if (getBSPDoorCamConfig() != getDBDoorCamConfig()) {
  12332. if (getDBDoorCamConfig() == 1) {
  12333. Log.d(TAG, "[checkDoorCamConfig] CameraSet - WALLPAD_CAM_AHD_FRONT");
  12334. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  12335. } else if (getDBDoorCamConfig() == 0) {
  12336. Log.d(TAG, "[checkDoorCamConfig] CameraSet - WALLPAD_CAM_NORMAL_FRONT");
  12337. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  12338. }
  12339. // 재부팅
  12340. setDefaultLauncher();
  12341. Intent intent = new Intent();
  12342. intent.setAction(define.NOTIFY_ACNAME);
  12343. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12344. getApplicationContext().sendBroadcast(intent);
  12345. }
  12346. }
  12347. }
  12348. } catch (Exception e) {
  12349. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  12350. e.printStackTrace();
  12351. }
  12352. }
  12353. /**
  12354. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  12355. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  12356. * @return true: 지원, false: 미지원
  12357. */
  12358. private boolean checkAvailableBSPDoorCamConfig() {
  12359. try {
  12360. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  12361. if (nCurrentVer >= 2020111801) return true;
  12362. else return false;
  12363. } catch (Exception e) {
  12364. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  12365. e.printStackTrace();
  12366. return false;
  12367. }
  12368. }
  12369. /**
  12370. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  12371. * @return 1 - 스마트현관카메라
  12372. * 0 - 일반현관카메라
  12373. * 2020.11.18 SEULKI
  12374. */
  12375. public int getBSPDoorCamConfig() {
  12376. try {
  12377. Runtime mRuntime = Runtime.getRuntime();
  12378. String cmd = "getprop camera.setting.value";
  12379. Process mProcess = mRuntime.exec(cmd);
  12380. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  12381. String line;
  12382. String strResult = null;
  12383. while ((line = br.readLine()) != null) {
  12384. strResult = line;
  12385. }
  12386. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  12387. if (strResult.equals("0")) {
  12388. Log.e(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  12389. return 1;
  12390. } else if (strResult.equals("1")) {
  12391. Log.e(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  12392. return 0;
  12393. }
  12394. } catch (Exception e) {
  12395. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  12396. e.printStackTrace();
  12397. }
  12398. return -1;
  12399. }
  12400. /**
  12401. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  12402. * @return 1 - 스마트현관카메라
  12403. * 0 - 일반현관카메라
  12404. * 2020.11.18 SEULKI
  12405. */
  12406. public int getDBDoorCamConfig() {
  12407. try {
  12408. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12409. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  12410. mWallpadDeviceSet.closeDB();
  12411. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  12412. Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA");
  12413. return 1;
  12414. } else {
  12415. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  12416. return 0;
  12417. }
  12418. } catch (Exception e) {
  12419. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  12420. e.printStackTrace();
  12421. }
  12422. return -1;
  12423. }
  12424. // private void demoPushMsg()
  12425. // {
  12426. // String urlStr1 = "";
  12427. //
  12428. // if(android.os.Build.VERSION.SDK_INT > 9 )
  12429. // {
  12430. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  12431. // StrictMode.setThreadPolicy(policy);
  12432. // }
  12433. //
  12434. // String Msg ="";
  12435. // try {
  12436. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  12437. // } catch (UnsupportedEncodingException e1) {
  12438. // // TODO Auto-generated catch block
  12439. // e1.printStackTrace();
  12440. // }
  12441. //
  12442. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  12443. // Log.d(TAG , "################ : " + urlStr1);
  12444. // try
  12445. // {
  12446. // //URLEncoder.encode(s)
  12447. // HttpClient client = new DefaultHttpClient();
  12448. //
  12449. // HttpGet get = new HttpGet();
  12450. // //get.setURI(new URI("http://www.google.com/"));
  12451. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  12452. // HttpResponse resp = client.execute(get);
  12453. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  12454. // String str = null;
  12455. // StringBuilder sb = new StringBuilder();
  12456. // while((str = br.readLine()) != null)
  12457. // {
  12458. // sb.append(str).append("\n");
  12459. // }
  12460. // br.close();
  12461. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  12462. // //txt.setText(sb.toString());
  12463. // }catch(Exception e)
  12464. // {
  12465. //
  12466. // e.printStackTrace();
  12467. //
  12468. // }
  12469. //
  12470. //
  12471. // }
  12472. //
  12473. //
  12474. // public static boolean checkForExternal(String str) {
  12475. // int length = str.length();
  12476. // for (int i = 0; i < length; i++) {
  12477. // if (str.charAt(i) > 0x7F) {
  12478. // return true;
  12479. // }
  12480. // }
  12481. // return false;
  12482. // }
  12483. //
  12484. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  12485. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  12486. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  12487. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  12488. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  12489. //
  12490. // public static String encodeUrl(String url) {
  12491. // if (checkForExternal(url)) {
  12492. // try {
  12493. // String value = URLEncoder.encode(url, "UTF-8");
  12494. // value = COLON.matcher(value).replaceAll(":");
  12495. // value = SLASH.matcher(value).replaceAll("/");
  12496. // value = QUEST_MARK.matcher(value).replaceAll("?");
  12497. // value = EQUAL.matcher(value).replaceAll("=");
  12498. // return AMP.matcher(value).replaceAll("&");
  12499. // } catch (UnsupportedEncodingException e) {
  12500. // //throw LOGGER.getIllegalStateException(e);
  12501. // return null;
  12502. // }
  12503. // } else {
  12504. // return url;
  12505. // }
  12506. // }
  12507. }