iMapServer.java 864 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716
  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.Messenger;
  23. import android.os.PowerManager;
  24. import android.os.RemoteException;
  25. import android.provider.Settings;
  26. import android.util.Log;
  27. import android.view.KeyEvent;
  28. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  29. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  30. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  31. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  32. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  33. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  34. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  35. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  36. import com.artncore.WallPadDataMgr.WallpadStatusData;
  37. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  38. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  39. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  40. import com.artncore.WallPadKNXSystem.WallPadKNX;
  41. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  42. import com.artncore.commons.APIErrorCode;
  43. import com.artncore.commons.API_Menu;
  44. import com.artncore.commons.DataClasses;
  45. import com.artncore.commons.DataClasses.HeatingV1;
  46. import com.artncore.commons.DataClasses.HeatingV2;
  47. import com.artncore.commons.DataClasses.MultiSwitch;
  48. import com.artncore.commons.KNX_DataClasses;
  49. import com.artncore.commons.define;
  50. import com.artncore.deviceinterface.WallPadInterface;
  51. import com.artncore.wallpadapi.AirQualitySensorAPI;
  52. import com.artncore.wallpadapi.CooktopAPI;
  53. import com.artncore.wallpadapi.DLockAPI;
  54. import com.artncore.wallpadapi.EnergyMeterAPI;
  55. import com.artncore.wallpadapi.GasAPI;
  56. import com.artncore.wallpadapi.HeatingV1API;
  57. import com.artncore.wallpadapi.HeatingV2API;
  58. import com.artncore.wallpadapi.IGW200dAPI;
  59. import com.artncore.wallpadapi.IGW300API;
  60. import com.artncore.wallpadapi.IntLightAPI;
  61. import com.artncore.wallpadapi.KnxAPI;
  62. import com.artncore.wallpadapi.KnxSystemAirconAPI;
  63. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  64. import com.artncore.wallpadapi.LightAPI;
  65. import com.artncore.wallpadapi.MultiSwitchAPI;
  66. import com.artncore.wallpadapi.PhonNRemocon;
  67. import com.artncore.wallpadapi.RealTimeMeterAPI;
  68. import com.artncore.wallpadapi.SdbAPI;
  69. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  70. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  71. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  72. import com.artncore.wallpadapi.VentiAPI;
  73. import com.artncore.wallpadapi.WallPadAPI;
  74. import com.artncore.wallpadimap.RetProci;
  75. import com.artncore.wallpadimap.WallPadFTPUploader;
  76. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  77. import com.artncore.wallpadimap.WallpadiCMDParser;
  78. import com.util.LogUtil;
  79. import org.apache.commons.net.ftp.FTP;
  80. import org.w3c.dom.Document;
  81. import org.w3c.dom.Element;
  82. import org.w3c.dom.NamedNodeMap;
  83. import org.w3c.dom.Node;
  84. import org.w3c.dom.NodeList;
  85. import java.io.BufferedReader;
  86. import java.io.ByteArrayInputStream;
  87. import java.io.DataOutputStream;
  88. import java.io.File;
  89. import java.io.FilenameFilter;
  90. import java.io.IOException;
  91. import java.io.InputStream;
  92. import java.io.InputStreamReader;
  93. import java.net.ServerSocket;
  94. import java.net.Socket;
  95. import java.text.SimpleDateFormat;
  96. import java.util.ArrayList;
  97. import java.util.Calendar;
  98. import java.util.Date;
  99. import java.util.GregorianCalendar;
  100. import java.util.LinkedList;
  101. import java.util.List;
  102. import java.util.Queue;
  103. import javax.net.ssl.SSLServerSocket;
  104. import javax.xml.parsers.DocumentBuilder;
  105. import javax.xml.parsers.DocumentBuilderFactory;
  106. import kr.co.icontrols.gledeviceinterface.jni;
  107. import kr.co.icontrols.hdcftp.HDCFTPManager;
  108. import kr.co.icontrols.sslapi.SSLClient;
  109. import kr.co.icontrols.sslapi.SSLServer;
  110. import kr.co.icontrols.wallpadmain.IOInterface;
  111. import kr.co.icontrols.wallpadmain.MainActivity;
  112. import kr.co.icontrols.wallpadmain.R;
  113. import kr.co.icontrols.wallpadmain.declare.Common;
  114. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  115. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  116. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  117. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  118. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  119. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  120. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  121. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  122. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  123. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  124. import kr.co.icontrols.wallpadsupport.Version;
  125. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  126. import kr.co.icontrols.wallpadsupport.WpadSound;
  127. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  128. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  129. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  130. public class iMapServer extends Service {
  131. private String TAG = "iMapServer";
  132. static final int EVENTTIMELIMITE = 2000;
  133. iMapSverSocket SvrSock;
  134. int port = 10000;
  135. String StrAddr = "";
  136. String IPaddr;
  137. String AddrDong;
  138. String AddrHo;
  139. int ho;
  140. boolean log_sw = true;
  141. String SVRIP = "";
  142. static WallPadAPI mWallPadAPI;
  143. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  144. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  145. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  146. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  147. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  148. private IGW200 mIGW200;
  149. private IGW300 mIGW300;
  150. PhonNRemocon PnRCtr;
  151. boolean CallConnected = false;
  152. long ALERTTIME = 0;
  153. long CALLTIME = 0;
  154. long OPENDOORTIME = 0;
  155. long currentTime = 0;
  156. long DoorDelayTime = 0;
  157. static Handler ScheDulerHandler;
  158. static final boolean iMAPDOORCTR = true;
  159. private jni mGleInterface = null;
  160. IOInterface mIOInterface = null;
  161. private boolean ResetFlag = false;
  162. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  163. private int ResetCount = 0;
  164. private boolean NowMainStatus = false;
  165. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  166. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  167. public iMapServer() {
  168. Log.i(TAG, "[iMapServer] ========== START ==========");
  169. }
  170. public static final int SENSOR_MAG = 0x01;
  171. public static final int SENSOR_IN = 0x02;
  172. public static final int SENSOR_OUT = 0x04;
  173. static int PORT_NUM_iMAP = 10000;
  174. static int SOCKET_WAIT_TIME = 40;
  175. static long lSocketConnectionPeriod = 0;
  176. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  177. static int SOCKET_BUFFER_SIZE_READ = 50;
  178. public static final String ITEM_MENU_TYPE = "call_menu";
  179. static final int DOOR_DELAY_TIME = 3000;
  180. static final String MULTISW_CTR = "remote_access_electric";
  181. String XMLHeader;
  182. SchedulerThread ScheServer;
  183. int OutGoingSensorWaiting = 0;
  184. private int ModelType = Version.getModelType();
  185. private WpadSound mSound;
  186. private WpadSound Sound() {
  187. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  188. return mSound;
  189. }
  190. /**
  191. * 신형 단지서버 사용 유무
  192. */
  193. private boolean mNewDanjiServer = false;
  194. /**
  195. * 방범 앱 재실행 여부
  196. */
  197. private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
  198. /**
  199. * JEFF, 2019.12.31
  200. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  201. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  202. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  203. * 통화앱 종료 BR을 삭제하면 안됨
  204. */
  205. // 통화어플이 종료중인 경우에는 호출 무시
  206. // private boolean bBlockCallEvent = false;
  207. ////////////////////////////////////////////////////////////////////////////////
  208. // 엘리베이터관련
  209. ////////////////////////////////////////////////////////////////////////////////
  210. /**
  211. * 엘리베이터 호출관련 class
  212. * <p>
  213. * shkang
  214. */
  215. private class ElevatorClass {
  216. /**
  217. * 엘리베이터 호출 타임아웃 (단위:초)
  218. */
  219. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
  220. /**
  221. * 상향/하향 플레그 true:상향UP, false:하향DN
  222. */
  223. private boolean mUpDn = false;
  224. /**
  225. * 엘리베이터 호출중
  226. */
  227. private boolean mCallElevator = false;
  228. /**
  229. * 엘리베이터 호출 API
  230. */
  231. private WallPadiMAPNotifyAPI mElevatorAPI;
  232. /**
  233. * 엘리베이터 호출 타이머
  234. */
  235. private CountDownTimer mElevatorTimer;
  236. /**
  237. * 엘리베이터 호출중 상태 가져오기
  238. */
  239. public boolean getElevatorCalling() {
  240. return mCallElevator;
  241. }
  242. /**
  243. * 엘리베이터 호출 상태 클리어
  244. */
  245. public void ClearElevator() {
  246. mCallElevator = false;
  247. }
  248. /**
  249. * 생성자
  250. *
  251. * @param Up - (boolean) true:상향, false:하향
  252. */
  253. private ElevatorClass(boolean Up) {
  254. try {
  255. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
  256. // 1. Input Param
  257. mUpDn = Up;
  258. mCallElevator = false;
  259. // 2. Create API
  260. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  261. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  262. @Override
  263. public void ProcDoing() {
  264. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  265. }
  266. @Override
  267. public void ProcError() {
  268. Log.i(TAG, "[ElevatorClass] ProcError()");
  269. mCallElevator = false;
  270. // 엘리베이터 호출 에러 알림
  271. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  272. }
  273. @Override
  274. public void ProcSuccess() {
  275. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  276. mCallElevator = true;
  277. // 엘리베이터 호출 성공 알림
  278. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  279. // "엘리베이터를 호출하였습니다" 멘트출력
  280. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  281. Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
  282. if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
  283. Sound().PlayMent(WpadSound.SND.elevator.CALL);
  284. bOutModeRestart = false;
  285. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  286. // 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
  287. // 타임아웃 시작
  288. TimeOutStart();
  289. }
  290. });
  291. // 3. Create Timer
  292. mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  293. @Override
  294. public void onFinish() {
  295. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  296. mCallElevator = false;
  297. // 호출 타임아웃 알림
  298. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  299. }
  300. @Override
  301. public void onTick(long arg0) {
  302. int RemainingTime = (int) (arg0 / 1000);
  303. if (RemainingTime <= 10) {
  304. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  305. }
  306. }
  307. };
  308. } catch (RuntimeException re) {
  309. LogUtil.errorLogInfo("", TAG, re);
  310. } catch (Exception e) {
  311. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  312. //e.printStackTrace();
  313. LogUtil.errorLogInfo("", TAG, e);
  314. }
  315. }
  316. /**
  317. * 엘리베이터 호출을 한다.
  318. */
  319. public void CallElevator() {
  320. try {
  321. if (mElevatorAPI == null) return;
  322. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  323. mCallElevator = true;
  324. } catch (RuntimeException re) {
  325. LogUtil.errorLogInfo("", TAG, re);
  326. } catch (Exception e) {
  327. Log.e(TAG, "[Exception] CallElevator()");
  328. //e.printStackTrace();
  329. LogUtil.errorLogInfo("", TAG, e);
  330. }
  331. }
  332. /**
  333. * 엘리베이터 상향호출 타임아웃을 취소한다.
  334. */
  335. public void TimeOutCancel() {
  336. try {
  337. if (mElevatorTimer == null) return;
  338. mElevatorTimer.cancel();
  339. } catch (RuntimeException re) {
  340. LogUtil.errorLogInfo("", TAG, re);
  341. } catch (Exception e) {
  342. Log.e(TAG, "[Exception] TimeOutCancel()");
  343. //e.printStackTrace();
  344. LogUtil.errorLogInfo("", TAG, e);
  345. }
  346. }
  347. /**
  348. * 엘리베이터 상향호출 타임아웃을 시작한다.
  349. */
  350. private void TimeOutStart() {
  351. try {
  352. if (mElevatorTimer == null) return;
  353. mElevatorTimer.cancel();
  354. mElevatorTimer.start();
  355. } catch (RuntimeException re) {
  356. LogUtil.errorLogInfo("", TAG, re);
  357. } catch (Exception e) {
  358. Log.e(TAG, "[Exception] TimeOutStart()");
  359. //e.printStackTrace();
  360. LogUtil.errorLogInfo("", TAG, e);
  361. }
  362. }
  363. /**
  364. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  365. *
  366. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  367. */
  368. private void SendNotifyKindBR(int kind) {
  369. try {
  370. Intent notiIntent = new Intent();
  371. notiIntent.setAction(define.NOTIFY_ACNAME);
  372. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  373. getApplicationContext().sendBroadcast(notiIntent);
  374. } catch (RuntimeException re) {
  375. LogUtil.errorLogInfo("", TAG, re);
  376. } catch (Exception e) {
  377. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  378. //e.printStackTrace();
  379. LogUtil.errorLogInfo("", TAG, e);
  380. }
  381. }
  382. }
  383. /**
  384. * 엘리베이터 상향호출 Class
  385. */
  386. private ElevatorClass ElevatorUp;
  387. /**
  388. * 엘리베이터 하향호출 Class
  389. */
  390. private ElevatorClass ElevatorDown;
  391. /**
  392. * 엘리베이터 호출한다.
  393. *
  394. * @param Up (boolean) true : 상향, false : 하향
  395. */
  396. private void CallElevatorBtn(boolean Up) {
  397. try {
  398. Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
  399. if (Up) {
  400. // 상향호출
  401. if (ElevatorUp == null) {
  402. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  403. return;
  404. }
  405. ElevatorUp.CallElevator();
  406. } else {
  407. // 하향호출
  408. if (ElevatorDown == null) {
  409. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  410. return;
  411. }
  412. ElevatorDown.CallElevator();
  413. }
  414. } catch (RuntimeException re) {
  415. LogUtil.errorLogInfo("", TAG, re);
  416. } catch (Exception e) {
  417. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  418. //e.printStackTrace();
  419. LogUtil.errorLogInfo("", TAG, e);
  420. }
  421. }
  422. ////////////////////////////////////////////////////////////////////////////////
  423. ////////////////////////////////////////////////////////////////////////////////
  424. @Override
  425. public void onCreate() {
  426. try {
  427. super.onCreate();
  428. Log.i(TAG, "[onCreate] ========== START ==========");
  429. setGlobalScreenAppRunningStatus(false);
  430. ModelType = Version.getModelType();
  431. mSound = new WpadSound(getApplicationContext());
  432. ElevatorUp = new ElevatorClass(true);
  433. ElevatorDown = new ElevatorClass(false);
  434. } catch (RuntimeException re) {
  435. Log.e(TAG, "[Exception] onCreate()");
  436. //e.printStackTrace();
  437. LogUtil.errorLogInfo("", TAG, re);
  438. } catch (Exception e) {
  439. Log.e(TAG, "[Exception] onCreate()");
  440. //e.printStackTrace();
  441. LogUtil.errorLogInfo("", TAG, e);
  442. }
  443. }
  444. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  445. try {
  446. Intent notiIntent = new Intent();
  447. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  448. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  449. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  450. getApplicationContext().sendBroadcast(notiIntent);
  451. } catch (RuntimeException re) {
  452. LogUtil.errorLogInfo("", TAG, re);
  453. } catch (Exception e) {
  454. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  455. //e.printStackTrace();
  456. LogUtil.errorLogInfo("", TAG, e);
  457. }
  458. }
  459. protected String GetForegroundAPP() {
  460. try {
  461. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  462. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  463. ComponentName topActivity = taskInfo.get(0).topActivity;
  464. String str = topActivity.getPackageName();
  465. return str;
  466. } catch (RuntimeException re) {
  467. LogUtil.errorLogInfo("", TAG, re);
  468. return " ";
  469. } catch (Exception e) {
  470. Log.e(TAG, "[Exception] GetForegroundAPP()");
  471. //e.printStackTrace();
  472. LogUtil.errorLogInfo("", TAG, e);
  473. return " ";
  474. }
  475. }
  476. long lSavedTimestamp = 0;
  477. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  478. public void onReceive(Context context, Intent intent) {
  479. try {
  480. String strActionName = intent.getAction();
  481. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
  482. if (strActionName.equals(define.NOTIFY_DAIL)) {
  483. long lTimestamp = System.currentTimeMillis();
  484. long lInterval = lTimestamp - lSavedTimestamp;
  485. if (lInterval < 1000) return;
  486. else
  487. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
  488. lSavedTimestamp = lTimestamp;
  489. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  490. if (mSdb_LivingRoomLightAPI == null) {
  491. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  492. return;
  493. }
  494. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  495. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  496. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  497. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  498. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  499. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  500. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  501. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  502. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  503. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  504. mSdb_LivingRoomLightAPI.SetControlMode(false);
  505. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  506. }
  507. return;
  508. }
  509. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  510. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  511. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  512. return;
  513. }
  514. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  515. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  516. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  517. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  518. } else {
  519. setGlobalScreenAppRunningStatus(false);
  520. }
  521. } else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  522. if (mKnx_LivingRoomLightAPI == null) {
  523. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  524. return;
  525. }
  526. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  527. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  528. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  529. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  530. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  531. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  532. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  533. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  534. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  535. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  536. mKnx_LivingRoomLightAPI.SetControlMode(false);
  537. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  538. }
  539. return;
  540. }
  541. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  542. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  543. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  544. return;
  545. }
  546. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  547. 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 + "]");
  548. }
  549. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  550. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  551. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  552. } else {
  553. setGlobalScreenAppRunningStatus(false);
  554. }
  555. } else {
  556. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  557. }
  558. } else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  559. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  560. } else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
  561. int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
  562. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
  563. switch (kind) {
  564. case define.NOTIFY_SCREEN_TOUCHED:
  565. setTimeStamp_ScreenTouched();
  566. break;
  567. case define.NOTIFY_DOOR_OPENED:
  568. setTimeStamp_Magnetic();
  569. break;
  570. }
  571. } else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  572. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
  573. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  574. switch (kind) {
  575. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  576. procUploadMissedVisitorPic(intent);
  577. break;
  578. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  579. // bBlockCallEvent = true;
  580. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  581. break;
  582. case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
  583. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
  584. Sound().Play(SND.mode.OUTMODE_SETTING);
  585. break;
  586. case Common.BR_MAIN_NOTI.SOUND_INMODE:
  587. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
  588. Sound().Play(SND.mode.INMODE_SETTING);
  589. break;
  590. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  591. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  592. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  593. break;
  594. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
  595. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  596. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  597. break;
  598. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
  599. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  600. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  601. break;
  602. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  603. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  604. CallElevatorBtn(false);
  605. break;
  606. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  607. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  608. CallElevatorBtn(true);
  609. break;
  610. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
  611. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  612. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  613. int CalledWallPadUI = intent.getIntExtra("Called", 0);
  614. if (CalledWallPadUI == 1) {
  615. ModeRunCtrlWorking(true, false);
  616. } else {
  617. ModeRunCtrlWorking(false, false);
  618. }
  619. break;
  620. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
  621. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  622. ModeReleaseCtrlWorking(false);
  623. break;
  624. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
  625. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  626. CheckMainStatus();
  627. break;
  628. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
  629. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  630. ModeRunCtrlWorking(false, false);
  631. break;
  632. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
  633. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  634. ModeReleaseCtrlWorking(false);
  635. break;
  636. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
  637. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  638. if (ElevatorUp != null && ElevatorDown != null) {
  639. boolean UpCalling = ElevatorUp.getElevatorCalling();
  640. boolean DownCalling = ElevatorDown.getElevatorCalling();
  641. Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
  642. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  643. if (UpCalling && DownCalling)
  644. Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  645. else if (UpCalling && !DownCalling)
  646. Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  647. else if (!UpCalling && DownCalling)
  648. Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  649. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  650. Log.d(TAG, " ElvCallState : " + ElvCallState);
  651. SendBRElevatorCallState(ElvCallState);
  652. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  653. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  654. // sendIntent.putExtra("ELV", ElvCallState);
  655. // getApplicationContext().sendBroadcast(sendIntent);
  656. }
  657. break;
  658. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  659. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  660. try {
  661. if (ScheServer != null) {
  662. ScheServer.SetLive();
  663. }
  664. } catch (RuntimeException re) {
  665. LogUtil.errorLogInfo("", TAG, re);
  666. } catch (Exception e) {
  667. //e.printStackTrace();
  668. LogUtil.errorLogInfo("", TAG, e);
  669. }
  670. break;
  671. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  672. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  673. stopIGW300RingGenerator();
  674. break;
  675. }
  676. } else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  677. int kind = intent.getIntExtra("KIND", 0);
  678. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  679. switch (kind) {
  680. case define.NOTIFY_SERVER_VERSION:
  681. try {
  682. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  683. iMapSverReload tSock = new iMapSverReload();
  684. tSock.start();
  685. } catch (IOException e) {
  686. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  687. //e.printStackTrace();
  688. LogUtil.errorLogInfo("", TAG, e);
  689. }
  690. break;
  691. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  692. // 제어기기 엘리베이터 상향 호출 요청
  693. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  694. CallElevatorBtn(true);
  695. break;
  696. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  697. // 제어기기에서 엘리베이터 하향 호출 요청
  698. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  699. CallElevatorBtn(false);
  700. break;
  701. case define.NOTIFY_SUBDEVCALLBUSY:
  702. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  703. CallConnected = true;
  704. break;
  705. case define.NOTIFY_SUBDEVCALLEND:
  706. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  707. CallConnected = false;
  708. break;
  709. case define.NOTIFY_STARTHEARTBEAT:
  710. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  711. {
  712. Message msg = ScheDulerHandler.obtainMessage();
  713. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  714. ScheDulerHandler.sendMessage(msg);
  715. }
  716. break;
  717. case define.NOTIFY_STARTSTATUSBEAT:
  718. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  719. {
  720. Message msg = ScheDulerHandler.obtainMessage();
  721. msg.what = SCHEDULE_START_STATUSBEAT;
  722. ScheDulerHandler.sendMessage(msg);
  723. }
  724. break;
  725. case define.NOTIFY_OUTGOINGSETTED:
  726. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  727. OutGoingSensorWaiting = 0;
  728. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  729. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  730. sdata.closeDB();
  731. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  732. return;
  733. WallPadInterface wpifc = new WallPadInterface();
  734. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
  735. OutGoingSensorWaiting |= SENSOR_MAG;
  736. int[] SensorInfoDB;
  737. int sensorIn = 0;
  738. int sensorOut = 0;
  739. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  740. if (SensorInfoDB[0] == 1) {
  741. // 내부동체가 사용함이면 상태 검사
  742. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
  743. OutGoingSensorWaiting |= SENSOR_IN;
  744. }
  745. if (SensorInfoDB[1] == 1) {
  746. // 외부동체가 사용함이면 상태 검사
  747. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
  748. OutGoingSensorWaiting |= SENSOR_OUT;
  749. }
  750. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  751. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  752. if (OutGoingSensorWaiting > 0) {
  753. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  754. SensorThread.start();
  755. }
  756. break;
  757. case define.NOTIFY_DOOR_SET_DELAY:
  758. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  759. DoorDelayTime = System.currentTimeMillis();
  760. imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
  761. break;
  762. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  763. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  764. Common.setDeviceServeiceLoadComplite();
  765. startRealtimemeterInfo(); // 실시간 검침기 확인
  766. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  767. startDistributionPanel(); // 분전반 확인
  768. getRoomName();
  769. break;
  770. case define.NOTIFY_DLOCK_SET_OUTING:
  771. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  772. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  773. try {
  774. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  775. int AlarmStatus = DBMGR.GetAlarmStatus();
  776. DBMGR.closeDB();
  777. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  778. // 센서 체크하고
  779. // 현관폰으로 사운드 출력하고
  780. boolean bSensorOk = false;
  781. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  782. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  783. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  784. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  785. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  786. bSensorOk = mIGW300.checkSensorforOutmode();
  787. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  788. bSensorOk = mIGW200.checkSensorforOutmode();
  789. } else {
  790. bSensorOk = checkSensorforOutmode();
  791. }
  792. if (bSensorOk) {
  793. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  794. CallOutModeRunActivity();
  795. } else {
  796. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  797. }
  798. }
  799. } catch (RuntimeException re) {
  800. LogUtil.errorLogInfo("", TAG, re);
  801. } catch (Exception e) {
  802. //e.printStackTrace();
  803. LogUtil.errorLogInfo("", TAG, e);
  804. }
  805. break;
  806. case define.NOTIFY_DLOCK_FREE_OUTING:
  807. // 도어락 외출모드 해제
  808. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  809. try {
  810. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  811. int AlarmStatus = DBMGR.GetAlarmStatus();
  812. DBMGR.closeDB();
  813. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  814. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  815. Common.SendAppFinishReqBR(getApplicationContext());
  816. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  817. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  818. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  819. devDB.closeDB();
  820. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  821. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  822. }
  823. }
  824. } catch (RuntimeException re) {
  825. LogUtil.errorLogInfo("", TAG, re);
  826. } catch (Exception e) {
  827. //e.printStackTrace();
  828. LogUtil.errorLogInfo("", TAG, e);
  829. }
  830. break;
  831. case define.NOTIFY_SMARTSW_SET_OUTING:
  832. // 485 대외향 스마트스위치 외출모드
  833. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  834. setUnoccupiedModeByNotHDCSmartSwitch();
  835. break;
  836. case define.NOTIFY_SMARTSW_FREE_OUTING:
  837. //대외향 485 스마트스위치 외출모드 해제
  838. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  839. releaseUnoccupiedModeByNotHDCSmartSwitch();
  840. break;
  841. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  842. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  843. String Type = intent.getStringExtra("TYPE");
  844. String Device = intent.getStringExtra("DEVICE");
  845. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  846. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  847. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  848. iMAPSmartLightEvent imapSmartLightEvent;
  849. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  850. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  851. imapSmartLightEvent.SetRetCtr(new RetProci() {
  852. @Override
  853. public void ProcSuccess() {
  854. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  855. }
  856. @Override
  857. public void ProcError() {
  858. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  859. }
  860. @Override
  861. public void ProcDoing() {
  862. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  863. }
  864. });
  865. break;
  866. case define.NOTIFY_KNX_DEVICE_EVENT:
  867. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  868. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  869. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  870. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  871. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  872. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  873. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  874. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  875. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  876. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  877. @Override
  878. public void ProcSuccess() {
  879. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  880. }
  881. @Override
  882. public void ProcError() {
  883. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  884. }
  885. @Override
  886. public void ProcDoing() {
  887. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  888. }
  889. });
  890. break;
  891. case define.NOTIFY_SMART_DCAM_DETECT:
  892. // 스마트현관카메라 거동수상자 발생
  893. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  894. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  895. if (!bWallPadCallLive && !bBlockFrontCall) {
  896. if (getStrangerRecordingManagerSetting()) {
  897. if (getStrangerRecordingUserSetting()) {
  898. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  899. Intent Newintent = new Intent();
  900. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  901. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  902. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  903. getApplicationContext().sendBroadcast(Newintent);
  904. } else {
  905. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  906. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  907. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  908. }
  909. } else {
  910. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  911. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  912. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  913. }
  914. } else {
  915. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  916. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  917. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  918. }
  919. break;
  920. case define.NOTIFY_SMART_DCAM_RELEASE:
  921. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  922. break;
  923. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  924. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  925. if (getStrangerRecordingManagerSetting()) {
  926. if (getStrangerRecordingUserSetting()) {
  927. // 알람 상태 확인
  928. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  929. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  930. mWallpadStatusData.closeDB();
  931. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  932. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  933. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  934. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  935. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  936. } else {
  937. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  938. Intent Newintent = new Intent();
  939. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  940. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  941. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  942. getApplicationContext().sendBroadcast(Newintent);
  943. }
  944. } else {
  945. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  946. }
  947. } else {
  948. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  949. }
  950. break;
  951. case define.NOTIFY_REJECT_RECORD_STRANGER:
  952. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  953. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  954. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  955. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  956. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  957. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  958. }
  959. break;
  960. case define.NOTIFY_ROOMNAME_CHANGED:
  961. getRoomName();
  962. break;
  963. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  964. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  965. break;
  966. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  967. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  968. break;
  969. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  970. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  971. break;
  972. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  973. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  974. break;
  975. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  976. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  977. break;
  978. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  979. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  980. break;
  981. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  982. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  983. break;
  984. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  985. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  986. break;
  987. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  988. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  989. break;
  990. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  991. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  992. break;
  993. case define.NOTIFY_FINISH_RECORD_STRANGER:
  994. // 녹화 종료 알림
  995. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  996. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  997. mWallpadStatusData.closeDB();
  998. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
  999. if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
  1000. break;
  1001. case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
  1002. // 사용자 설정화면에서 원격제어시 조명제어 타입 변경
  1003. getDeviceCtrlOption();
  1004. break;
  1005. default:
  1006. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  1007. break;
  1008. }
  1009. }
  1010. } catch (RuntimeException re) {
  1011. LogUtil.errorLogInfo("", TAG, re);
  1012. } catch (Exception e) {
  1013. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1014. //e.printStackTrace();
  1015. LogUtil.errorLogInfo("", TAG, e);
  1016. }
  1017. }
  1018. };
  1019. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1020. try {
  1021. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1022. // 485 대외향 스마트스위치 외출모드
  1023. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1024. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1025. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1026. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1027. mWallpadStatusData.closeDB();
  1028. if (UseGuardSensorCheck == false) {
  1029. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1030. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1031. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1032. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
  1033. mWallpadStatusData.closeDB();
  1034. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1035. //메인화면 업데이트
  1036. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1037. getApplicationContext().sendBroadcast(newIntent);
  1038. ModeRunCtrlWorking(false, false);
  1039. }
  1040. } else {
  1041. // 실제 외출 방범 모드를 설정하도록 한다.
  1042. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1043. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1044. // 센서 체크하고
  1045. // 센서 체크하는 부분이 들어가야 함
  1046. Common.SendAppFinishReqBR(getApplicationContext());
  1047. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1048. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1049. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1050. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1051. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1052. if (mIGW300.checkSensorforOutmode()) {
  1053. CallOutModeWaitingActivity(AlarmStatus);
  1054. } else {
  1055. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1056. }
  1057. } else {
  1058. if (checkSensorforOutmode()) {
  1059. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1060. CallOutModeWaitingActivity(AlarmStatus);
  1061. } else {
  1062. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1063. }
  1064. }
  1065. }
  1066. }
  1067. } catch (RuntimeException re) {
  1068. LogUtil.errorLogInfo("", TAG, re);
  1069. } catch (Exception e) {
  1070. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1071. //e.printStackTrace();
  1072. LogUtil.errorLogInfo("", TAG, e);
  1073. }
  1074. }
  1075. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1076. try {
  1077. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1078. //대외향 485 스마트스위치 외출모드 해제
  1079. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1080. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1081. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1082. mWallpadStatusData.closeDB();
  1083. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
  1084. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1085. if (OutModePwRelease) {
  1086. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1087. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1088. // 요청하여도 해제 되지 않으며
  1089. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1090. Intent notiIntent = new Intent();
  1091. notiIntent.setAction(define.NOTIFY_ACNAME);
  1092. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1093. getApplicationContext().sendBroadcast(notiIntent);
  1094. } else {
  1095. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1096. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1097. // 처리하고.
  1098. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1099. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1100. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1101. mWallpadStatusData.closeDB();
  1102. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1103. Common.SendAppFinishReqBR(getApplicationContext());
  1104. }
  1105. } else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1106. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1107. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1108. ModeReleaseCtrlWorking(false);
  1109. bSmartSwitch485ComebackMode = true;
  1110. Intent notiIntent = new Intent();
  1111. notiIntent.setAction(define.NOTIFY_ACNAME);
  1112. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1113. getApplicationContext().sendBroadcast(notiIntent);
  1114. } else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1115. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1116. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1117. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1118. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1119. mWallpadStatusData.closeDB();
  1120. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1121. //메인화면 업데이트
  1122. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1123. getApplicationContext().sendBroadcast(newIntent);
  1124. ModeReleaseCtrlWorking(false);
  1125. }
  1126. } catch (RuntimeException re) {
  1127. LogUtil.errorLogInfo("", TAG, re);
  1128. } catch (Exception e) {
  1129. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1130. //e.printStackTrace();
  1131. LogUtil.errorLogInfo("", TAG, e);
  1132. }
  1133. }
  1134. /**
  1135. * 스마트현관카메라 녹화 여부 판별
  1136. * 사용자 화면에서 설정
  1137. */
  1138. private boolean getStrangerRecordingUserSetting() {
  1139. boolean bResult = false;
  1140. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1141. try {
  1142. bResult = DBMGR.GetStrangerRecordingOnOff();
  1143. DBMGR.closeDB();
  1144. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1145. } catch (RuntimeException re) {
  1146. LogUtil.errorLogInfo("", TAG, re);
  1147. DBMGR.closeDB();
  1148. bResult = false;
  1149. } catch (Exception e) {
  1150. DBMGR.closeDB();
  1151. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1152. //e.printStackTrace();
  1153. LogUtil.errorLogInfo("", TAG, e);
  1154. bResult = false;
  1155. }
  1156. return bResult;
  1157. }
  1158. private boolean getStrangerTakePic() {
  1159. try {
  1160. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1161. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1162. DBMGR.closeDB();
  1163. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1164. return bResult;
  1165. } catch (RuntimeException re) {
  1166. LogUtil.errorLogInfo("", TAG, re);
  1167. return false;
  1168. } catch (Exception e) {
  1169. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1170. //e.printStackTrace();
  1171. LogUtil.errorLogInfo("", TAG, e);
  1172. return false;
  1173. }
  1174. }
  1175. // 관리자 설정 항목에 있음
  1176. private boolean getStrangerRecordUsage() {
  1177. try {
  1178. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1179. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1180. mWallpadDeviceSet.closeDB();
  1181. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1182. return bResult;
  1183. } catch (RuntimeException re) {
  1184. LogUtil.errorLogInfo("", TAG, re);
  1185. return false;
  1186. } catch (Exception e) {
  1187. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1188. //e.printStackTrace();
  1189. LogUtil.errorLogInfo("", TAG, e);
  1190. return false;
  1191. }
  1192. }
  1193. private boolean checkSensorforOutmode() {
  1194. try {
  1195. WallPadInterface wallPadInterface = new WallPadInterface();
  1196. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1197. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1198. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1199. int[] SensorInfoDB;
  1200. int sensorIn = 0;
  1201. int sensorOut = 0;
  1202. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1203. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1204. if (SensorInfoDB[0] == 1) {
  1205. // 내부동체가 사용함이면 상태 검사
  1206. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1207. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1208. }
  1209. if (SensorInfoDB[1] == 1) {
  1210. // 외부동체가 사용함이면 상태 검사
  1211. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1212. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1213. }
  1214. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1215. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1216. // 동체 사용 설정 체크..
  1217. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1218. int sensor = devSet.Get_Sensor_Set();
  1219. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1220. devSet.closeDB();
  1221. int OtherInSensor = 0;
  1222. // 내부동체 사용안함 이면
  1223. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1224. // 외부동체 사용안함 이면
  1225. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1226. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1227. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1228. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1229. return true;
  1230. } else {
  1231. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1232. return false;
  1233. }
  1234. } catch (RuntimeException re) {
  1235. LogUtil.errorLogInfo("", TAG, re);
  1236. return false;
  1237. } catch (Exception e) {
  1238. //e.printStackTrace();
  1239. LogUtil.errorLogInfo("", TAG, e);
  1240. return false;
  1241. }
  1242. }
  1243. private boolean checkSensorforInmode() {
  1244. try {
  1245. WallPadInterface wallPadInterface = new WallPadInterface();
  1246. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1247. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1248. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1249. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1250. if (sensorMag == 0) {
  1251. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1252. return true;
  1253. } else {
  1254. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1255. return false;
  1256. }
  1257. } catch (RuntimeException re) {
  1258. LogUtil.errorLogInfo("", TAG, re);
  1259. return false;
  1260. } catch (Exception e) {
  1261. Log.e(TAG, e.toString());
  1262. //e.printStackTrace();
  1263. LogUtil.errorLogInfo("", TAG, e);
  1264. return false;
  1265. }
  1266. }
  1267. /////////////////////
  1268. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1269. //////////////
  1270. /////////////////////
  1271. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1272. //////////////
  1273. public void playSoundthroughDoorphone(int SoundIdx) {
  1274. try {
  1275. WallPadInterface Wiface = new WallPadInterface();
  1276. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1277. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1278. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1279. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1280. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1281. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1282. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1283. if (getUseSmartDoorCam()) {
  1284. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1285. }
  1286. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1287. /*
  1288. JEFF (2019.01.14)
  1289. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1290. 강신구입니다.
  1291. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1292. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1293. 내용 공유합니다.
  1294. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1295. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1296. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1297. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1298. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1299. 문제 없습니다.
  1300. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1301. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1302. 문의사항은 하기 연락바랍니다.
  1303. 감사합니다.
  1304. */
  1305. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1306. } else {
  1307. // 대외향 모델 처리
  1308. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
  1309. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1310. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1311. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1312. }
  1313. try {
  1314. Thread.sleep(100);
  1315. } catch (RuntimeException re) {
  1316. LogUtil.errorLogInfo("", TAG, re);
  1317. } catch (Exception e) {
  1318. LogUtil.errorLogInfo("", TAG, e);
  1319. }
  1320. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1321. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1322. try {
  1323. Thread.sleep(1500);
  1324. } catch (RuntimeException re) {
  1325. LogUtil.errorLogInfo("", TAG, re);
  1326. } catch (Exception e) {
  1327. LogUtil.errorLogInfo("", TAG, e);
  1328. }
  1329. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1330. int SLevel = Wdb.GetDoorSoundLevel();
  1331. Wdb.closeDB();
  1332. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1333. if (SLevel != -1) {
  1334. /**
  1335. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1336. * **/
  1337. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1338. } else {
  1339. // 사용안함이면
  1340. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1341. }
  1342. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1343. int time = Sound().PlayMent(SoundIdx);
  1344. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1345. if (0 > time) {
  1346. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1347. time = 1000;
  1348. }
  1349. try {
  1350. Thread.sleep(time + 1000);
  1351. } catch (RuntimeException re) {
  1352. LogUtil.errorLogInfo("", TAG, re);
  1353. } catch (Exception e) {
  1354. LogUtil.errorLogInfo("", TAG, e);
  1355. }
  1356. amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1357. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1358. try {
  1359. Thread.sleep(100);
  1360. } catch (RuntimeException re) {
  1361. LogUtil.errorLogInfo("", TAG, re);
  1362. } catch (Exception e) {
  1363. LogUtil.errorLogInfo("", TAG, e);
  1364. }
  1365. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1366. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1367. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1368. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1369. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1370. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1371. if (getUseSmartDoorCam()) {
  1372. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1373. }
  1374. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1375. /*
  1376. JEFF (2019.01.14)
  1377. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1378. 강신구입니다.
  1379. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1380. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1381. 내용 공유합니다.
  1382. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1383. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1384. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1385. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1386. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1387. 문제 없습니다.
  1388. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1389. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1390. 문의사항은 하기 연락바랍니다.
  1391. 감사합니다.
  1392. */
  1393. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1394. } else {
  1395. // 대외향 모델 처리
  1396. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1397. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1398. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1399. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1400. }
  1401. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1402. } catch (RuntimeException re) {
  1403. LogUtil.errorLogInfo("", TAG, re);
  1404. } catch (Exception e) {
  1405. //e.printStackTrace();
  1406. LogUtil.errorLogInfo("", TAG, e);
  1407. }
  1408. }
  1409. public void CallOutModeRunActivity() {
  1410. int base = 8000;
  1411. int[] Menu_Id_List = {base + 11};
  1412. int Menu_StartId = base + 11;
  1413. int Menu_Option = -1;
  1414. Intent intent = new Intent(Intent.ACTION_MAIN);
  1415. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1416. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1417. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1418. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1419. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1420. startActivity(intent);
  1421. }
  1422. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1423. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1424. int base = 4000;
  1425. int[] Menu_Id_List = {base + 11, base + 21};
  1426. int Menu_StartId = base + 11;
  1427. int Menu_Option = 1000;
  1428. Intent intent = new Intent(Intent.ACTION_MAIN);
  1429. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1430. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1431. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1432. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1433. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  1434. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1435. startActivity(intent);
  1436. }
  1437. private boolean getGlobalScreenAppRunningStatus() {
  1438. boolean bRunning = false;
  1439. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1440. try {
  1441. bRunning = DBMGR.getGlobalScreenAPKRun();
  1442. DBMGR.closeDB();
  1443. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1444. return bRunning;
  1445. } catch (RuntimeException re) {
  1446. LogUtil.errorLogInfo("", TAG, re);
  1447. DBMGR.closeDB();
  1448. } catch (Exception e) {
  1449. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1450. //e.printStackTrace();
  1451. LogUtil.errorLogInfo("", TAG, e);
  1452. DBMGR.closeDB();
  1453. }
  1454. return bRunning;
  1455. }
  1456. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1457. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1458. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1459. try {
  1460. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1461. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1462. DBMGR.closeDB();
  1463. } catch (RuntimeException re) {
  1464. LogUtil.errorLogInfo("", TAG, re);
  1465. DBMGR.closeDB();
  1466. } catch (Exception e) {
  1467. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1468. //e.printStackTrace();
  1469. LogUtil.errorLogInfo("", TAG, e);
  1470. DBMGR.closeDB();
  1471. }
  1472. }
  1473. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1474. boolean bGlobalScreenRun = false;
  1475. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1476. try {
  1477. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1478. wakeupLCD();
  1479. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1480. setGlobalScreenAppRunningStatus(true);
  1481. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1482. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1483. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1484. mIntent.putExtra("ONOFF", hOnOff);
  1485. mIntent.putExtra("DIAL", hDial);
  1486. mIntent.putExtra("LEVEL", hLevel);
  1487. mIntent.putExtra("COLOR", hColor);
  1488. mIntent.putExtra("CONTROL", hControl);
  1489. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1490. mIntent.setComponent(mComponentName);
  1491. startActivity(mIntent);
  1492. } else {
  1493. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1494. }
  1495. } catch (RuntimeException re) {
  1496. LogUtil.errorLogInfo("", TAG, re);
  1497. } catch (Exception e) {
  1498. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1499. //e.printStackTrace();
  1500. LogUtil.errorLogInfo("", TAG, e);
  1501. }
  1502. }
  1503. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1504. try {
  1505. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1506. wakeupLCD();
  1507. if (!getGlobalScreenAppRunningStatus()) {
  1508. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1509. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1510. return;
  1511. }
  1512. setGlobalScreenAppRunningStatus(true);
  1513. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1514. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1515. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1516. mIntent.putExtra("SCREENID", nScreenID);
  1517. mIntent.putExtra("ONOFF", hOnOff);
  1518. mIntent.putExtra("DIAL", hDial);
  1519. mIntent.putExtra("LEVEL", hLevel);
  1520. mIntent.putExtra("COLOR", hColor);
  1521. mIntent.putExtra("CONTROL", hControl);
  1522. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1523. mIntent.setComponent(mComponentName);
  1524. startActivity(mIntent);
  1525. } else {
  1526. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1527. }
  1528. } catch (RuntimeException re) {
  1529. LogUtil.errorLogInfo("", TAG, re);
  1530. } catch (Exception e) {
  1531. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1532. //e.printStackTrace();
  1533. LogUtil.errorLogInfo("", TAG, e);
  1534. }
  1535. }
  1536. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1537. public void sendBlackoutReleasedBR() {
  1538. try {
  1539. Intent notiIntent = new Intent();
  1540. notiIntent.setAction(strBLACKOUT_RELEASED);
  1541. getApplicationContext().sendBroadcast(notiIntent);
  1542. } catch (RuntimeException re) {
  1543. LogUtil.errorLogInfo("", TAG, re);
  1544. } catch (Exception e) {
  1545. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1546. //e.printStackTrace();
  1547. LogUtil.errorLogInfo("", TAG, e);
  1548. }
  1549. }
  1550. private int getCurrentScreen() {
  1551. int nScreenID = 0;
  1552. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1553. try {
  1554. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1555. DBMGR.closeDB();
  1556. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1557. return nScreenID;
  1558. } catch (RuntimeException re) {
  1559. LogUtil.errorLogInfo("", TAG, re);
  1560. DBMGR.closeDB();
  1561. } catch (Exception e) {
  1562. Log.e(TAG, "[Exception] getCurrentScreen()");
  1563. //e.printStackTrace();
  1564. LogUtil.errorLogInfo("", TAG, e);
  1565. DBMGR.closeDB();
  1566. }
  1567. return nScreenID;
  1568. }
  1569. private void setCurrentScreen(int nScreenID) {
  1570. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1571. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1572. try {
  1573. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1574. DBMGR.closeDB();
  1575. } catch (RuntimeException re) {
  1576. LogUtil.errorLogInfo("", TAG, re);
  1577. DBMGR.closeDB();
  1578. } catch (Exception e) {
  1579. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1580. //e.printStackTrace();
  1581. LogUtil.errorLogInfo("", TAG, e);
  1582. DBMGR.closeDB();
  1583. }
  1584. }
  1585. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1586. private void procUploadMissedVisitorPic(Intent intent) {
  1587. try {
  1588. String strDong = intent.getStringExtra("DONG");
  1589. String strHo = intent.getStringExtra("HO");
  1590. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1591. int nCnt = intent.getIntExtra("CNT", 0);
  1592. String[] strMissedPicURI = new String[nCnt];
  1593. strArrayMissedPicURI.clear();
  1594. for (int i = 0; i < nCnt; i++) {
  1595. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1596. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1597. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1598. }
  1599. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1600. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1601. }
  1602. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1603. } catch (RuntimeException re) {
  1604. LogUtil.errorLogInfo("", TAG, re);
  1605. } catch (Exception e) {
  1606. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1607. //e.printStackTrace();
  1608. LogUtil.errorLogInfo("", TAG, e);
  1609. }
  1610. }
  1611. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1612. try {
  1613. String strURI = "", strFileName = "", strTime = "", strType = "";
  1614. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1615. // strURI = strArrayMissedPicURI.get(i).toString();
  1616. // strFileName = extractFileName(strURI);
  1617. // strTime = extractFileTime(strURI);
  1618. // strType = extractCallType(strFileName);
  1619. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1620. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1621. // }
  1622. if (strArrayMissedPicURI.size() > 0) {
  1623. strURI = strArrayMissedPicURI.get(0).toString();
  1624. strFileName = extractFileName(strURI);
  1625. strTime = extractFileTime(strFileName);
  1626. strType = extractCallType(strFileName);
  1627. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1628. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1629. } else {
  1630. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1631. }
  1632. } catch (RuntimeException re) {
  1633. LogUtil.errorLogInfo("", TAG, re);
  1634. } catch (Exception e) {
  1635. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1636. //e.printStackTrace();
  1637. LogUtil.errorLogInfo("", TAG, e);
  1638. }
  1639. }
  1640. public class uploadVisitorPicture extends Thread {
  1641. HDCFTPManager mFTPManager;
  1642. boolean bMainServer2dot0 = false;
  1643. String strRemoteIP = "10.0.1.1";
  1644. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1645. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1646. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1647. try {
  1648. strDong = dong;
  1649. strHo = ho;
  1650. strType = type;
  1651. strTime = time;
  1652. strFileName = filename;
  1653. strUploadFile = uploadfile;
  1654. bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1655. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1656. wallpadDeviceSet.closeDB();
  1657. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
  1658. } catch (RuntimeException re) {
  1659. LogUtil.errorLogInfo("", TAG, re);
  1660. } catch (Exception e) {
  1661. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1662. //e.printStackTrace();
  1663. LogUtil.errorLogInfo("", TAG, e);
  1664. }
  1665. }
  1666. public void run() {
  1667. try {
  1668. mFTPManager = new HDCFTPManager();
  1669. if (!mFTPManager.isFTPConnected()) {
  1670. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1671. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1672. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1673. return;
  1674. }
  1675. }
  1676. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1677. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1678. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1679. return;
  1680. }
  1681. if (!bMainServer2dot0) {
  1682. if (!mFTPManager.setPassiveMode()) {
  1683. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1684. disconnectFTP();
  1685. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1686. return;
  1687. }
  1688. }
  1689. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1690. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1691. disconnectFTP();
  1692. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1693. return;
  1694. }
  1695. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1696. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1697. disconnectFTP();
  1698. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1699. return;
  1700. }
  1701. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1702. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1703. disconnectFTP();
  1704. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1705. return;
  1706. }
  1707. disconnectFTP();
  1708. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1709. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1710. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1711. } catch (RuntimeException re) {
  1712. LogUtil.errorLogInfo("", TAG, re);
  1713. } catch (Exception e) {
  1714. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1715. //e.printStackTrace();
  1716. LogUtil.errorLogInfo("", TAG, e);
  1717. }
  1718. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1719. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1720. }
  1721. public boolean disconnectFTP() {
  1722. try {
  1723. if (mFTPManager.logoutFTP()) {
  1724. if (mFTPManager.disconnectFTP()) {
  1725. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1726. return true;
  1727. }
  1728. }
  1729. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1730. return false;
  1731. } catch (RuntimeException re) {
  1732. LogUtil.errorLogInfo("", TAG, re);
  1733. return false;
  1734. } catch (Exception e) {
  1735. Log.e(TAG, "[Exception] disconnectFTP()");
  1736. //e.printStackTrace();
  1737. LogUtil.errorLogInfo("", TAG, e);
  1738. return false;
  1739. }
  1740. }
  1741. }
  1742. private String extractCallType(String strFileName) {
  1743. try {
  1744. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1745. String[] strParse_01 = strFileName.split("_");
  1746. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1747. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1748. else return "none";
  1749. } catch (RuntimeException re) {
  1750. LogUtil.errorLogInfo("", TAG, re);
  1751. return null;
  1752. } catch (Exception e) {
  1753. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1754. //e.printStackTrace();
  1755. LogUtil.errorLogInfo("", TAG, e);
  1756. return null;
  1757. }
  1758. }
  1759. private String extractFileName(String strTargetFile) {
  1760. try {
  1761. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1762. String[] strParse_01 = strTargetFile.split("/");
  1763. return strParse_01[strParse_01.length - 1];
  1764. } catch (RuntimeException re) {
  1765. LogUtil.errorLogInfo("", TAG, re);
  1766. return null;
  1767. } catch (Exception e) {
  1768. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1769. //e.printStackTrace();
  1770. LogUtil.errorLogInfo("", TAG, e);
  1771. return null;
  1772. }
  1773. }
  1774. private String extractFileTime(String strFileName) {
  1775. try {
  1776. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1777. String[] strParse_01 = strFileName.split("\\.");
  1778. String[] strParse_02 = strParse_01[0].split("_");
  1779. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1780. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1781. // 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);
  1782. return strParse_02[5] + "_" + strParse_02[6];
  1783. } catch (RuntimeException re) {
  1784. LogUtil.errorLogInfo("", TAG, re);
  1785. return null;
  1786. } catch (Exception e) {
  1787. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1788. //e.printStackTrace();
  1789. LogUtil.errorLogInfo("", TAG, e);
  1790. return null;
  1791. }
  1792. }
  1793. String strRemoteURI, strUserID, strPW, strPath;
  1794. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1795. String strKey_Pass = "passwd";
  1796. 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) {
  1797. try {
  1798. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1799. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1800. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1801. visitor_access_info.setResultCtrl(new RetProci() {
  1802. @Override
  1803. public void ProcSuccess() {
  1804. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1805. visitor_access_info.SetItem("ftp_info");
  1806. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1807. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1808. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1809. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1810. strUserID = strReply_User;
  1811. strPW = strReply_PW;
  1812. strPath = strReply_Path;
  1813. strRemoteURI = strPath + "/" + strFileName;
  1814. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1815. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1816. mUploadVisitorPicture.start();
  1817. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1818. // mUploadVisitorPicture.start();
  1819. }
  1820. @Override
  1821. public void ProcError() {
  1822. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1823. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1824. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1825. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1826. }
  1827. @Override
  1828. public void ProcDoing() {
  1829. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1830. }
  1831. });
  1832. return true;
  1833. }
  1834. } catch (RuntimeException re) {
  1835. LogUtil.errorLogInfo("", TAG, re);
  1836. } catch (Exception e) {
  1837. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1838. //e.printStackTrace();
  1839. LogUtil.errorLogInfo("", TAG, e);
  1840. }
  1841. return false;
  1842. }
  1843. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1844. try {
  1845. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1846. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1847. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1848. visitor_upload_complete.setResultCtrl(new RetProci() {
  1849. @Override
  1850. public void ProcSuccess() {
  1851. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1852. }
  1853. @Override
  1854. public void ProcError() {
  1855. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1856. }
  1857. @Override
  1858. public void ProcDoing() {
  1859. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1860. }
  1861. });
  1862. return true;
  1863. }
  1864. } catch (RuntimeException re) {
  1865. LogUtil.errorLogInfo("", TAG, re);
  1866. } catch (Exception e) {
  1867. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1868. //e.printStackTrace();
  1869. LogUtil.errorLogInfo("", TAG, e);
  1870. }
  1871. return false;
  1872. }
  1873. /**
  1874. * 이통사 연동 서비스를 위한 BR
  1875. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1876. *
  1877. * @param kind (String) "lobby" or "home"
  1878. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1879. */
  1880. public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
  1881. try {
  1882. Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
  1883. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1884. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1885. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1886. Intent mIntent = new Intent();
  1887. mIntent.setAction(BR_VISITOR_EVENT);
  1888. mIntent.putExtra("KIND", kind);
  1889. mIntent.putExtra("TIME", datetime);
  1890. mIntent.putExtra("FILENAME", filename);
  1891. getApplicationContext().sendBroadcast(mIntent);
  1892. } catch (RuntimeException re) {
  1893. LogUtil.errorLogInfo("", TAG, re);
  1894. } catch (Exception e) {
  1895. Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
  1896. //e.printStackTrace();
  1897. LogUtil.errorLogInfo("", TAG, e);
  1898. }
  1899. }
  1900. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1901. public void onReceive(Context context, Intent intent) {
  1902. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1903. Bundle bundle;
  1904. WallpadDeviceSet devset;
  1905. Intent newintent;
  1906. boolean CallAppRun = false;
  1907. boolean MgrAppRun = false;
  1908. final String packageName = "com.artncore.apps.ic_wallpad";
  1909. final String packageNameMgr = "com.artncore.managersetting";
  1910. //CallAppRun = getForegroundAPK().equals(packageName);
  1911. // CallAppRun = getCallAppRunning();
  1912. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1913. int base = 7000;
  1914. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  1915. int Menu_Start_Option = 1;
  1916. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1917. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1918. int keyevt = ReceiveEvt.getKeyCode();
  1919. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1920. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1921. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1922. sdata.closeDB();
  1923. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1924. return;
  1925. }
  1926. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1927. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1928. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1929. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1930. mWallpadStatusData.closeDB();
  1931. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1932. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1933. sdata.closeDB();
  1934. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1935. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1936. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1937. int nModelType = Version.getModelType();
  1938. switch (ReceiveEvt.getKeyCode()) {
  1939. case 251: // 현산향 비상버튼 다운 업 처리
  1940. try {
  1941. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1942. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1943. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1944. } else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1945. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1946. }
  1947. }
  1948. } catch (RuntimeException re) {
  1949. LogUtil.errorLogInfo("", TAG, re);
  1950. } catch (Exception e) {
  1951. //e.printStackTrace();
  1952. LogUtil.errorLogInfo("", TAG, e);
  1953. }
  1954. break;
  1955. case WallPadInterface.EVT_RING:
  1956. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1957. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1958. // 전화 수신 링 수신
  1959. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1960. if (Version.getGatewayUsage()) {
  1961. // 국선 시작만 올라온다.
  1962. startIGW300RingGenerator();
  1963. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1964. } else {
  1965. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1966. }
  1967. break;
  1968. case WallPadInterface.EVT_END_RING:
  1969. // 전화 수신 링 종료
  1970. // Jeff added below codes for call app (2018.01.25)
  1971. // This event is managed by WallPadCall
  1972. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  1973. if (Version.getGatewayUsage()) {
  1974. stopIGW300RingGenerator();
  1975. }
  1976. break;
  1977. case WallPadInterface.BTN_EMR:
  1978. case WallPadInterface.BTN_EMR_IHN1010:
  1979. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  1980. // 월패드 비상버튼 입력 SA 와 GLE 공통
  1981. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  1982. if (MgrAppRun) return;
  1983. if (Common.DIAGNOSTIC_MODE) return;
  1984. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1985. return;
  1986. //currentTime = System.currentTimeMillis();
  1987. //if (ALERTTIME > currentTime) break;
  1988. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  1989. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  1990. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  1991. break;
  1992. devset = new WallpadDeviceSet(getApplicationContext());
  1993. int StatusVal = devset.GetDeviceSetted("알람발생");
  1994. devset.closeDB();
  1995. Log.d("imap", "StatusVal : " + StatusVal);
  1996. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  1997. // 보안 처리가 필요함..
  1998. // 지속적으로 이벤트가 들어올 경우 대비
  1999. Common.SendAppFinishReqBR(getApplicationContext());
  2000. newintent = new Intent(Intent.ACTION_MAIN);
  2001. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2002. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2003. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2004. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2005. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2006. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2007. iMAPstartActivity(newintent);
  2008. }
  2009. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2010. if (getIsSubWallpad()) {
  2011. Intent notiIntent = new Intent();
  2012. notiIntent.setAction(define.NOTIFY_ACNAME);
  2013. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2014. getApplicationContext().sendBroadcast(notiIntent);
  2015. }
  2016. break;
  2017. case WallPadInterface.BTN_CALL:
  2018. case WallPadInterface.BTN_CALL_IHN1010:
  2019. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2020. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2021. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2022. // Jeff added below codes for call app (2018.01.25)
  2023. try {
  2024. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2025. if (getIsSubWallpad()) {
  2026. // 서브월패드
  2027. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2028. } else {
  2029. // 메인월패드
  2030. if (MainActivity.bRecordStatus) {
  2031. // 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2032. Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2033. Intent iIntent = new Intent();
  2034. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2035. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
  2036. getApplicationContext().sendBroadcast(iIntent);
  2037. }
  2038. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2039. }
  2040. } catch (RuntimeException re) {
  2041. LogUtil.errorLogInfo("", TAG, re);
  2042. } catch (Exception e) {
  2043. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2044. //e.printStackTrace();
  2045. LogUtil.errorLogInfo("", TAG, e);
  2046. }
  2047. break;
  2048. case WallPadInterface.BTN_OPEN:
  2049. // 월패드 문여림 버튼 입력 상태 SA
  2050. break;
  2051. case WallPadInterface.BTN_DOOR:
  2052. case WallPadInterface.BTN_DOOR_IHN1010:
  2053. // 현관 도어폰 벨 눌림 입력 상태
  2054. // Jeff added below codes for call app (2018.01.25)
  2055. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2056. if (!bWallPadCallLive && !bBlockFrontCall) {
  2057. if (MainActivity.bRecordStatus) {
  2058. // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2059. Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2060. Intent iIntent = new Intent();
  2061. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2062. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
  2063. getApplicationContext().sendBroadcast(iIntent);
  2064. }
  2065. bBlockFrontCall = true;
  2066. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2067. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2068. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2069. try {
  2070. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2071. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2072. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2073. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2074. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2075. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2076. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2077. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2078. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2079. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2080. }
  2081. if (!Version.getGatewayUsage()) {
  2082. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2083. }
  2084. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2085. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2086. } catch (RuntimeException re) {
  2087. LogUtil.errorLogInfo("", TAG, re);
  2088. } catch (Exception e) {
  2089. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2090. //e.printStackTrace();
  2091. LogUtil.errorLogInfo("", TAG, e);
  2092. }
  2093. } else {
  2094. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2095. }
  2096. break;
  2097. case WallPadInterface.BTN_CAMERA_SET:
  2098. Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
  2099. Intent iIntent = new Intent();
  2100. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2101. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
  2102. getApplicationContext().sendBroadcast(iIntent);
  2103. break;
  2104. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2105. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
  2106. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2107. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
  2108. && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
  2109. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2110. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2111. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2112. if (MgrAppRun) return;
  2113. if (Common.DIAGNOSTIC_MODE) return;
  2114. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  2115. return;
  2116. //currentTime = System.currentTimeMillis();
  2117. //if (ALERTTIME > currentTime) break;
  2118. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2119. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2120. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2121. break;
  2122. devset = new WallpadDeviceSet(getApplicationContext());
  2123. StatusVal = devset.GetDeviceSetted("알람발생");
  2124. devset.closeDB();
  2125. Log.d("imap", "StatusVal : " + StatusVal);
  2126. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2127. // 보안 처리가 필요함..
  2128. // 지속적으로 이벤트가 들어올 경우 대비
  2129. Common.SendAppFinishReqBR(getApplicationContext());
  2130. newintent = new Intent(Intent.ACTION_MAIN);
  2131. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2132. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2133. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2134. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2135. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2136. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2137. iMAPstartActivity(newintent);
  2138. }
  2139. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2140. if (getIsSubWallpad()) {
  2141. Intent notiIntent = new Intent();
  2142. notiIntent.setAction(define.NOTIFY_ACNAME);
  2143. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2144. getApplicationContext().sendBroadcast(notiIntent);
  2145. }
  2146. } else {
  2147. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2148. if (!getEmergencyIOUsage()) {
  2149. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2150. return;
  2151. }
  2152. if (MgrAppRun) {
  2153. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2154. return;
  2155. }
  2156. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2157. break;
  2158. devset = new WallpadDeviceSet(getApplicationContext());
  2159. StatusVal = devset.GetDeviceSetted("알람발생");
  2160. devset.closeDB();
  2161. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2162. Common.SendAppFinishReqBR(getApplicationContext());
  2163. newintent = new Intent(Intent.ACTION_MAIN);
  2164. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2165. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2166. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2167. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2168. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2169. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2170. iMAPstartActivity(newintent);
  2171. }
  2172. }
  2173. break;
  2174. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2175. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2176. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2177. // 대외향의 경우 여기에서 마그네틱이 감지된다.
  2178. if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
  2179. if (MgrAppRun) return;
  2180. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
  2181. WallPadInterface mWallPadInterface = new WallPadInterface();
  2182. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2183. if (sensorMag == 0) return;
  2184. }
  2185. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2186. break;
  2187. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2188. break;
  2189. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2190. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2191. if (OutGoingSensorWaiting == 0) {
  2192. // wakeupLCD();
  2193. mIOInterface.ctrlLcdWakeUp();
  2194. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2195. SensorThread.start();
  2196. }
  2197. OutGoingSensorWaiting |= SENSOR_MAG;
  2198. } else {
  2199. Common.SendAppFinishReqBR(getApplicationContext());
  2200. newintent = new Intent(Intent.ACTION_MAIN);
  2201. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2202. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2203. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2204. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2205. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2206. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2207. iMAPstartActivity(newintent);
  2208. }
  2209. break;
  2210. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2211. saveBlackoutStatus(true);
  2212. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2213. break;
  2214. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2215. saveBlackoutStatus(false);
  2216. sendBlackoutReleasedBR();
  2217. break;
  2218. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2219. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2220. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2221. if (MgrAppRun) return;
  2222. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2223. break;
  2224. devset = new WallpadDeviceSet(getApplicationContext());
  2225. StatusVal = devset.GetDeviceSetted("피난사다리");
  2226. int LadderSend = devset.getEscapeLadderDownSend();
  2227. String pentHouseHo = devset.getPentHouseHoEscapeLadder();
  2228. devset.closeDB();
  2229. Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
  2230. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2231. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2232. Common.SendAppFinishReqBR(getApplicationContext());
  2233. newintent = new Intent(Intent.ACTION_MAIN);
  2234. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2235. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2236. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2237. if (!pentHouseHo.equals("")) {
  2238. // 윗집이 펜트하우스인 경우
  2239. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2240. } else {
  2241. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  2242. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2243. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  2244. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2245. }
  2246. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2247. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2248. iMAPstartActivity(newintent);
  2249. }
  2250. break;
  2251. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2252. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2253. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2254. {
  2255. // 내부동체가 상태가 변경된 경우
  2256. int[] SensorInfoDB;
  2257. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2258. if (SensorInfoDB[0] != 1) {
  2259. //내부동체가 사용함이면 상태 검사
  2260. return;
  2261. }
  2262. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
  2263. WallPadInterface mWallPadInterface = new WallPadInterface();
  2264. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2265. if (sensorMag == 0) return;
  2266. }
  2267. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2268. int sensor = devSet.Get_Sensor_Set();
  2269. devSet.closeDB();
  2270. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2271. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2272. break;
  2273. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2274. if (OutGoingSensorWaiting == 0) {
  2275. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2276. SensorThread.start();
  2277. }
  2278. OutGoingSensorWaiting |= SENSOR_IN;
  2279. }
  2280. break;
  2281. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2282. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2283. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2284. {
  2285. // 외부동체가 상태가 변경된 경우
  2286. int[] SensorInfoDB;
  2287. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2288. if (SensorInfoDB[1] != 1) {
  2289. // 외부동체가 사용함이면 상태 검사
  2290. return;
  2291. }
  2292. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
  2293. WallPadInterface mWallPadInterface = new WallPadInterface();
  2294. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2295. if (sensorMag == 0) return;
  2296. }
  2297. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2298. int sensor = devSet.Get_Sensor_Set();
  2299. devSet.closeDB();
  2300. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2301. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2302. break;
  2303. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2304. break;
  2305. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2306. break;
  2307. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2308. {
  2309. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2310. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2311. break;
  2312. }*/
  2313. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2314. if (OutGoingSensorWaiting == 0) {
  2315. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2316. SensorThread.start();
  2317. }
  2318. OutGoingSensorWaiting |= SENSOR_OUT;
  2319. } else {
  2320. Common.SendAppFinishReqBR(getApplicationContext());
  2321. newintent = new Intent(Intent.ACTION_MAIN);
  2322. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2323. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2324. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2325. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2326. newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2327. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2328. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2329. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2330. iMAPstartActivity(newintent);
  2331. }
  2332. }
  2333. break;
  2334. }
  2335. } else {
  2336. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2337. }
  2338. }
  2339. };
  2340. protected void iMAPstartActivity(Intent intent) {
  2341. try {
  2342. startActivity(intent);
  2343. } catch (RuntimeException re) {
  2344. LogUtil.errorLogInfo("", TAG, re);
  2345. } catch (Exception e) {
  2346. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2347. //e.printStackTrace();
  2348. LogUtil.errorLogInfo("", TAG, e);
  2349. }
  2350. }
  2351. /**
  2352. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2353. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2354. * 1. 현관카메라 키이벤트 수신
  2355. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2356. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2357. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2358. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2359. * 6. 시스템 볼륨 원복
  2360. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2361. */
  2362. AudioManager mAudioManager;
  2363. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2364. Handler mDingDongHandler = new Handler() {
  2365. public void handleMessage(Message msg) {
  2366. try {
  2367. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2368. if (msg.what == 0) {
  2369. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2370. int nVolume = 10;
  2371. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
  2372. nVolume = 12;
  2373. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2374. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2375. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2376. mDingDongHandler.sendEmptyMessage(1);
  2377. } else if (msg.what == 1) {
  2378. // 띵똥 패스 체크
  2379. check1++;
  2380. if (check1 > 200) {
  2381. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2382. finishDingDongHandler();
  2383. check1 = 0;
  2384. return;
  2385. } else {
  2386. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2387. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2388. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2389. }
  2390. } else if (msg.what == 2) {
  2391. // 띵똥 음원 재생
  2392. mIOInterface.ctrlSetTalkPathDoor();
  2393. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2394. } else if (msg.what == 3) {
  2395. mIOInterface.ctrlSetTalkPathNormal();
  2396. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2397. mDingDongHandler.sendEmptyMessage(4);
  2398. } else if (msg.what == 4) {
  2399. // Normal 패스 체크
  2400. check2++;
  2401. if (check2 > 200) {
  2402. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2403. finishDingDongHandler();
  2404. check2 = 0;
  2405. return;
  2406. } else {
  2407. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2408. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2409. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2410. }
  2411. } else if (msg.what == 5) {
  2412. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2413. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2414. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2415. wdb.closeDB();
  2416. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2417. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2418. intent.setAction(define.NOTIFY_ACNAME);
  2419. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2420. sendBroadcast(intent);
  2421. }
  2422. } catch (RuntimeException re) {
  2423. LogUtil.errorLogInfo("", TAG, re);
  2424. finishDingDongHandler();
  2425. } catch (Exception e) {
  2426. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2427. //e.printStackTrace();
  2428. LogUtil.errorLogInfo("", TAG, e);
  2429. finishDingDongHandler();
  2430. }
  2431. }
  2432. };
  2433. private void finishDingDongHandler() {
  2434. try {
  2435. Log.d(TAG, "[finishDingDongHandler]");
  2436. if (mDingDongHandler != null) {
  2437. mDingDongHandler.removeMessages(0);
  2438. mDingDongHandler.removeMessages(1);
  2439. mDingDongHandler.removeMessages(2);
  2440. mDingDongHandler.removeMessages(3);
  2441. mDingDongHandler.removeMessages(4);
  2442. mDingDongHandler.removeMessages(5);
  2443. }
  2444. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2445. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2446. wdb.closeDB();
  2447. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2448. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2449. mIOInterface.ctrlSetTalkPathNormal();
  2450. } catch (RuntimeException re) {
  2451. LogUtil.errorLogInfo("", TAG, re);
  2452. } catch (Exception e) {
  2453. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2454. //e.printStackTrace();
  2455. LogUtil.errorLogInfo("", TAG, e);
  2456. }
  2457. }
  2458. // 외출방범 대기 모드 중 사운드와 센서 체크
  2459. class OutgoingCheckSensor extends Thread {
  2460. public OutgoingCheckSensor() {
  2461. }
  2462. public void run() {
  2463. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2464. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2465. WallPadInterface wpifc = new WallPadInterface();
  2466. mWallpadStatusData.closeDB();
  2467. int checkcount = timedata / 5;
  2468. int i;
  2469. for (i = checkcount; i > 0; i--) {
  2470. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2471. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2472. mWallpadStatusData.closeDB();
  2473. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2474. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2475. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2476. try {
  2477. Thread.sleep(5000);
  2478. } catch (RuntimeException re) {
  2479. LogUtil.errorLogInfo("", TAG, re);
  2480. } catch (Exception e) {
  2481. LogUtil.errorLogInfo("", TAG, e);
  2482. }
  2483. }
  2484. if (i == 0) {
  2485. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2486. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2487. mWallpadStatusData.closeDB();
  2488. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2489. Common.SendAppFinishReqBR(getApplicationContext());
  2490. int base = 7000;
  2491. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  2492. int Menu_Start_Option = 1;
  2493. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2494. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2495. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2496. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2497. String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
  2498. if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
  2499. else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
  2500. else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
  2501. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2502. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2503. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2504. iMAPstartActivity(mIntent);
  2505. }
  2506. }
  2507. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2508. OutGoingSensorWaiting = 0;
  2509. }
  2510. }
  2511. @Override
  2512. public IBinder onBind(Intent arg0) {
  2513. return mMessenger.getBinder();
  2514. //return null;
  2515. }
  2516. public void imapsvrlog(String msg) {
  2517. if (!log_sw) return;
  2518. Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
  2519. }
  2520. public int onStartCommand(Intent intent, int flags, int startID) {
  2521. try {
  2522. try {
  2523. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2524. } catch (RuntimeException re) {
  2525. LogUtil.errorLogInfo("", TAG, re);
  2526. } catch (Exception e) {
  2527. //e.printStackTrace();
  2528. LogUtil.errorLogInfo("", TAG, e);
  2529. }
  2530. getDeviceCtrlOption();
  2531. SvrSock = new iMapSverSocket();
  2532. SvrSock.start();
  2533. } catch (IOException e) {
  2534. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2535. //e.printStackTrace();
  2536. LogUtil.errorLogInfo("", TAG, e);
  2537. }
  2538. try {
  2539. mGleInterface = new jni();
  2540. } catch (RuntimeException re) {
  2541. LogUtil.errorLogInfo("", TAG, re);
  2542. } catch (Exception e) {
  2543. Log.e(TAG, "[Exception] mGleInterface init...");
  2544. //e.printStackTrace();
  2545. LogUtil.errorLogInfo("", TAG, e);
  2546. }
  2547. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2548. AddressSet addr = DBMGR.getAddressMGR();
  2549. DBMGR.closeDB();
  2550. String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
  2551. AddrDong = addr.Dong;
  2552. AddrHo = addr.Ho;
  2553. ho = Integer.valueOf(AddrHo.substring(0, 1));
  2554. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  2555. "<imap ver=\"1.0\" address=\"" + addr.IPAddress + "\" sender=\"" + AddressStr + "\">\r\n";
  2556. Log.d(TAG, "*****************************************");
  2557. Log.d(TAG, "****************SchedulerThread**********");
  2558. Log.d(TAG, "*****************************************");
  2559. ScheServer = new SchedulerThread();
  2560. ScheServer.start();
  2561. // BR 등록 시작
  2562. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2563. IntentFilter mIntentFilter = new IntentFilter();
  2564. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2565. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2566. mIntentFilter = new IntentFilter();
  2567. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2568. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2569. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2570. mIntentFilter = new IntentFilter();
  2571. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2572. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2573. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2574. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2575. mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
  2576. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2577. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2578. // BR 등록 완료
  2579. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2580. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
  2581. IGW200APICheckHandler.sendEmptyMessage(0);
  2582. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2583. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2584. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2585. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2586. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2587. IGW300APICheckHandler.sendEmptyMessage(0);
  2588. }
  2589. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2590. mIOInterface.setEmergencyType();
  2591. Intent notiIntent = new Intent();
  2592. notiIntent.setAction(define.NOTIFY_ACNAME);
  2593. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2594. getApplicationContext().sendBroadcast(notiIntent);
  2595. CheckMainStatus();
  2596. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2597. getAirQualityUsage();
  2598. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2599. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2600. GwCheckThread.start();
  2601. }
  2602. getResidentSafetyCheckSetting();
  2603. return START_STICKY;
  2604. }
  2605. //멀티기기 정보 전송을 위한 추가
  2606. public static final int MSG_REGISTER_CLIENT = 1;
  2607. //public static final int MSG_UNREGISTER_CLIENT = 2;
  2608. public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
  2609. public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
  2610. public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
  2611. public static final int MSG_SEND_TO_ACTIVITY = 4;
  2612. private Messenger mClient = null; // Activity 에서 가져온 Messenger
  2613. String remote_get_home_devices1;
  2614. String remote_get_home_devices2;
  2615. String remote_get_home_devices3;
  2616. /**
  2617. * activity로부터 binding 된 Messenger
  2618. */
  2619. private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
  2620. @Override
  2621. public boolean handleMessage(Message msg) {
  2622. Log.w("test", "ControlService - message what : " + msg.what + " , msg.obj " + msg.obj);
  2623. switch (msg.what) {
  2624. case MSG_REGISTER_CLIENT:
  2625. mClient = msg.replyTo; // activity로부터 가져온
  2626. break;
  2627. case MSG_SEND_TO_SERVICE_DEVICES1:
  2628. remote_get_home_devices1 = (String) msg.obj; // activity로부터 가져온
  2629. break;
  2630. case MSG_SEND_TO_SERVICE_DEVICES2:
  2631. remote_get_home_devices2 = (String) msg.obj; // activity로부터 가져온
  2632. break;
  2633. case MSG_SEND_TO_SERVICE_DEVICES3:
  2634. remote_get_home_devices3 = (String) msg.obj; // activity로부터 가져온
  2635. break;
  2636. default:
  2637. sendMsgToActivity(1234);
  2638. break;
  2639. }
  2640. return false;
  2641. }
  2642. }));
  2643. private void sendMsgToActivity(int sendValue) {
  2644. try {
  2645. Bundle bundle = new Bundle();
  2646. bundle.putInt("fromService", sendValue);
  2647. bundle.putString("test", "abcdefg");
  2648. Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
  2649. msg.setData(bundle);
  2650. mClient.send(msg); // msg 보내기
  2651. } catch (RemoteException e) {
  2652. }
  2653. }
  2654. // 메인 서버 소켓 클래스
  2655. public class iMapSverSocket extends Thread {
  2656. ServerSocket svr;
  2657. private SSLServerSocket sslsvr;
  2658. boolean receiveSocketRun = true;
  2659. public iMapSverSocket() throws IOException {
  2660. /////////////////////////////////////////////////////////////////////
  2661. // 신형 단지서버 사용 유무를 가져온다.
  2662. /////////////////////////////////////////////////////////////////////
  2663. try {
  2664. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2665. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2666. wallpadDeviceSet.closeDB();
  2667. } catch (RuntimeException re) {
  2668. LogUtil.errorLogInfo("", TAG, re);
  2669. mNewDanjiServer = false;
  2670. } catch (Exception e) {
  2671. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2672. //e.printStackTrace();
  2673. LogUtil.errorLogInfo("", TAG, e);
  2674. mNewDanjiServer = false;
  2675. }
  2676. //////////////////////////////////////////////////
  2677. /////////////////////////////////////////////////////////////////////
  2678. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2679. /////////////////////////////////////////////////////////////////////
  2680. if (!mNewDanjiServer) {
  2681. svr = new ServerSocket(port);
  2682. } else {
  2683. int svrport = port + 1000;
  2684. Log.i(TAG, "============================================");
  2685. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2686. Log.i(TAG, "============================================");
  2687. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2688. sslsvr = sslServerSocket.getServerSocket();
  2689. }
  2690. }
  2691. public void run() {
  2692. while (receiveSocketRun) {
  2693. try {
  2694. Socket sock = null;
  2695. /////////////////////////////////////////////////////////////////////
  2696. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2697. /////////////////////////////////////////////////////////////////////
  2698. if (!mNewDanjiServer) {
  2699. sock = svr.accept();
  2700. } else {
  2701. sock = sslsvr.accept();
  2702. }
  2703. //madeinlab accept 대기중에 모바일에서 요청오면 아래 쓰레드 돌려서 처리.
  2704. //아래 쓰레드가 돌기전에 다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
  2705. sendMsgToActivity(1234);
  2706. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2707. ProciMap.start();
  2708. } catch (IOException e) {
  2709. //e.printStackTrace();
  2710. LogUtil.errorLogInfo("", TAG, e);
  2711. }
  2712. }
  2713. }
  2714. public void destoryThread() {
  2715. receiveSocketRun = false;
  2716. try {
  2717. if (svr != null) {
  2718. svr.close();
  2719. svr = null;
  2720. }
  2721. if (sslsvr != null) {
  2722. sslsvr.close();
  2723. sslsvr = null;
  2724. }
  2725. } catch (RuntimeException re) {
  2726. LogUtil.errorLogInfo("", TAG, re);
  2727. } catch (Exception e) {
  2728. //e.printStackTrace();
  2729. LogUtil.errorLogInfo("", TAG, e);
  2730. }
  2731. }
  2732. }
  2733. public String getRemoteIPAddress(Socket Sock) {
  2734. try {
  2735. // Log.i(TAG, "[getRemoteIPAddress] == START ==");
  2736. if (Sock == null) return "10.0.1.1";
  2737. String strRemoteIP = Sock.getRemoteSocketAddress().toString();
  2738. String[] strSplited_01 = strRemoteIP.split(":");
  2739. String[] strSplited_02 = strSplited_01[0].split("/");
  2740. strRemoteIP = strSplited_02[1];
  2741. return strRemoteIP;
  2742. } catch (Exception e) {
  2743. Log.e(TAG, "[Exception] getRemoteIPAddress(Sock)");
  2744. e.printStackTrace();
  2745. return "10.0.1.1";
  2746. }
  2747. }
  2748. // iMAP 서버 소켓 처리
  2749. public class iMapSverSocketThread extends Thread {
  2750. private final Socket iMAPSock;
  2751. String strRcvMSG;
  2752. WallPadiMAPUpgrade upgradeProc;
  2753. Document doc;
  2754. public iMapSverSocketThread(Socket sock) {
  2755. iMAPSock = sock;
  2756. }
  2757. public void run() {
  2758. try {
  2759. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2760. InputStream InStm = iMAPSock.getInputStream();
  2761. iMAPSock.setSoLinger(true, 3000);
  2762. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2763. strRcvMSG = "";
  2764. String InBuffer;
  2765. int i = 0;
  2766. boolean bRcvOK = false;
  2767. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2768. /////////////////////////////////////////////////////////////////////
  2769. // 신형단지서버 미사용중일 경우 기존 코드로,
  2770. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2771. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2772. /////////////////////////////////////////////////////////////////////
  2773. if (!mNewDanjiServer) {
  2774. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2775. try {
  2776. if (MsgReader.ready()) {
  2777. try {
  2778. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2779. InBuffer = "";
  2780. while (MsgReader.ready()) {
  2781. long charCnt = MsgReader.read(ReadData);
  2782. InBuffer += new String(ReadData, 0, (int) charCnt);
  2783. }
  2784. if (InBuffer != null) strRcvMSG += InBuffer;
  2785. if (0 < InBuffer.indexOf("</imap>")) {
  2786. bRcvOK = true;
  2787. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2788. break;
  2789. }
  2790. } catch (RuntimeException re) {
  2791. LogUtil.errorLogInfo("", TAG, re);
  2792. return;
  2793. } catch (Exception e) {
  2794. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2795. //e.printStackTrace();
  2796. LogUtil.errorLogInfo("", TAG, e);
  2797. return;
  2798. }
  2799. } else {
  2800. Thread.sleep(100);
  2801. }
  2802. } catch (RuntimeException re) {
  2803. LogUtil.errorLogInfo("", TAG, re);
  2804. iMAPSock.close();
  2805. return;
  2806. } catch (Exception e) {
  2807. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  2808. iMAPSock.close();
  2809. //e.printStackTrace();
  2810. LogUtil.errorLogInfo("", TAG, e);
  2811. return;
  2812. }
  2813. }
  2814. } else {
  2815. // SSL 암호화 데이터 수신부
  2816. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  2817. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2818. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2819. try {
  2820. InBuffer = "";
  2821. long charCnt = MsgReader.read(ReadData);
  2822. if (charCnt > 0) {
  2823. InBuffer += new String(ReadData, 0, (int) charCnt);
  2824. strRcvMSG += InBuffer;
  2825. if (-1 < InBuffer.indexOf("</imap>")) {
  2826. bRcvOK = true;
  2827. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  2828. break;
  2829. }
  2830. } else {
  2831. Thread.sleep(100);
  2832. }
  2833. } catch (RuntimeException re) {
  2834. LogUtil.errorLogInfo("", TAG, re);
  2835. iMAPSock.close();
  2836. return;
  2837. } catch (Exception e) {
  2838. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  2839. iMAPSock.close();
  2840. //e.printStackTrace();
  2841. LogUtil.errorLogInfo("", TAG, e);
  2842. return;
  2843. }
  2844. }
  2845. }
  2846. if (!bRcvOK) {
  2847. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  2848. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  2849. Log.i(TAG, strRcvMSG);
  2850. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  2851. iMAPSock.close();
  2852. return;
  2853. }
  2854. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  2855. imapsvrlog("Socket read end accept </imap>\n" + strRcvMSG);
  2856. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2857. DocumentBuilder builder = factory.newDocumentBuilder();
  2858. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  2859. doc = builder.parse(istream);
  2860. Element elelist = doc.getDocumentElement();
  2861. NodeList items = elelist.getElementsByTagName("service");
  2862. Node item = items.item(0);
  2863. NamedNodeMap attrs = item.getAttributes();
  2864. String retXML = "";
  2865. for (int j = 0; j < attrs.getLength(); j++) {
  2866. Node attr = attrs.item(j);
  2867. String cmd;
  2868. if (attr.getNodeName().equalsIgnoreCase("type")) {
  2869. cmd = attr.getNodeValue();
  2870. if (cmd.equalsIgnoreCase("notice")) {
  2871. iMAPSock.close();
  2872. }
  2873. } else if (attr.getNodeName().equalsIgnoreCase("name")) {
  2874. cmd = attr.getNodeValue();
  2875. if (cmd.equalsIgnoreCase("event_notify")) {
  2876. retXML = ProcEventNotify(elelist);
  2877. } else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  2878. ProcElevatorinfo(elelist);
  2879. retXML = null;
  2880. } else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  2881. retXML = ProcCheckEpiceUpload(doc);
  2882. } else if (cmd.equalsIgnoreCase("update_news")) {
  2883. retXML = ProcUpdateNews(doc);
  2884. } else if (cmd.equalsIgnoreCase("update_weather")) {
  2885. retXML = ProcUpdateWeather(doc);
  2886. } else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  2887. retXML = ProcSchduleInquiry(doc);
  2888. } else if (cmd.equalsIgnoreCase("schedule_renew")) {
  2889. retXML = ProcSchduleRenew(doc);
  2890. } else if (cmd.equalsIgnoreCase("schdule")) {
  2891. String SvcType = "";
  2892. int k;
  2893. for (k = j + 1; k < attrs.getLength(); k++) {
  2894. Node attr1 = attrs.item(k);
  2895. SvcType = attr1.getNodeName();
  2896. if (SvcType.equalsIgnoreCase("shc_type")) {
  2897. SvcType = attr1.getNodeValue();
  2898. break;
  2899. }
  2900. }
  2901. retXML = ProcUpdateSchedule(elelist, SvcType);
  2902. } else if (cmd.equalsIgnoreCase("device_reset")) {
  2903. retXML = ProcDeviceReset(elelist);
  2904. } else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  2905. retXML = ProcNotifyparcel(doc);
  2906. } else if (cmd.equalsIgnoreCase("notify_post_info")) {
  2907. // 스마트우편함 연동 여부
  2908. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  2909. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  2910. DevSet.closeDB();
  2911. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  2912. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  2913. } else if (cmd.equalsIgnoreCase("get_security_mode")) {
  2914. String Dong = null;
  2915. String Ho = null;
  2916. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  2917. String result;
  2918. String modeStr = null;
  2919. int status = statusDB.GetAlarmStatus();
  2920. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  2921. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  2922. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  2923. else if (status == WallpadStatusData.GUARD_OUT)
  2924. modeStr = "unoccupied";
  2925. else if (status == WallpadStatusData.GUARD_OUT_WAIT)
  2926. modeStr = "waitunoccupied";
  2927. result = "ok";
  2928. } else {
  2929. modeStr = "null";
  2930. result = "fail";
  2931. }
  2932. try {
  2933. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  2934. Node GSM_item = GSM_items.item(0);
  2935. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  2936. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  2937. Node GSM_attr = GSM_attrsParam.item(k);
  2938. if (GSM_attr.getNodeName().equalsIgnoreCase("dong"))
  2939. Dong = trimquotation(GSM_attr.getNodeValue());
  2940. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho"))
  2941. Ho = trimquotation(GSM_attr.getNodeValue());
  2942. }
  2943. WallpadStatusData DBMGR = null;
  2944. DBMGR = new WallpadStatusData(getApplicationContext());
  2945. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  2946. DBMGR.closeDB();
  2947. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  2948. result = "fail";
  2949. }
  2950. } catch (RuntimeException re) {
  2951. LogUtil.errorLogInfo("", TAG, re);
  2952. result = "fail";
  2953. } catch (Exception e) {
  2954. result = "fail";
  2955. }
  2956. retXML = XMLHeader +
  2957. " <service type=\"reply\" name=\"get_security_mode\" result=\"" + result + "\">\r\n" +
  2958. " <home_info dong=\"" + AddrDong + "\" ho=\"" + AddrHo + "\" mode=\"" + modeStr + "\"/>\r\n" +
  2959. " </service>\r\n" +
  2960. "</imap>\r\n";
  2961. statusDB.closeDB();
  2962. } else if (cmd.equalsIgnoreCase("set_setup_info")) {
  2963. retXML = ProcSetsetup(doc);
  2964. } else if (cmd.equalsIgnoreCase("get_setup_info")) {
  2965. retXML = ProcGetsetup(doc);
  2966. } else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  2967. retXML = CheckPassword(doc);
  2968. } else if (cmd.equalsIgnoreCase("device_live_check")) {
  2969. retXML = ProcDeviceLiveCheck();
  2970. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  2971. retXML = ProcPairingHdevSyncAlarm(elelist);
  2972. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  2973. retXML = ProcPairingHdevSyncSecurity(elelist);
  2974. } else if (cmd.equalsIgnoreCase("notify_car_event")) {
  2975. retXML = ProcParkInformation(elelist);
  2976. } else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2977. retXML = ProcSmartKeyEvent(elelist);
  2978. } else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  2979. retXML = ProcParkInformation_cham_upis(elelist);
  2980. } else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  2981. retXML = ProcauscultateReq(doc);
  2982. } else if (cmd.equalsIgnoreCase("upgrade")) {
  2983. imapsvrlog("Enter Upgrade");
  2984. procUpgrade();
  2985. retXML = null;
  2986. } else if (cmd.equals("check_sip_activation")) {
  2987. String sip_result = "fail";
  2988. ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  2989. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  2990. //add KSJ 2021.11.02 socket addr 가져오기 위해 추가
  2991. String strIP = getRemoteIPAddress(iMAPSock);
  2992. //~add KSJ
  2993. // Jeff added below codes for call app (2018.01.25)
  2994. String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
  2995. for (int k = 0; k < rsi.size(); k++) {
  2996. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  2997. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  2998. sip_result = "ok";
  2999. break;
  3000. }
  3001. }
  3002. if(bWallPadCallLive && m_bWallpadCallScreen == false)
  3003. {
  3004. sip_result = "fail";
  3005. }
  3006. 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";
  3007. //add KSJ 2021.11.02 check_sip_activation msg recv 이후 wallpadcall app start
  3008. String[] IP_Parse = strIP.split("\\.");
  3009. Log.d(TAG, "1" + strIP);
  3010. //Log.d(TAG, "2" + strSplit[1]);
  3011. //Log.d(TAG, "3" + strSplit[2]);
  3012. //Log.d(TAG, "4" + strSplit[3]);
  3013. CALLTYPE eCallType = CALLTYPE.LOBBY;
  3014. if (IP_Parse[2].equals("0")) {
  3015. eCallType = CALLTYPE.LOBBY;
  3016. if (IP_Parse[3].equals("11"))
  3017. eCallType = CALLTYPE.FRONT;
  3018. } else if (IP_Parse[2].equals("129")) {
  3019. eCallType = CALLTYPE.FRONT;
  3020. } else {
  3021. eCallType = CALLTYPE.RESIDENCE;
  3022. }
  3023. if ((eCallType == CALLTYPE.LOBBY) || (eCallType == CALLTYPE.FRONT))
  3024. runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
  3025. }
  3026. //add KSJ 2021.11.02 stop_talking msg 추가 (wallpadcall 종료)
  3027. else if (cmd.equals("stop_talking")) {
  3028. Common.SendAppFinishReqBR(getApplicationContext());
  3029. }
  3030. //~add KSJ
  3031. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3032. retXML = iCMDProcDevList(doc);
  3033. } else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3034. retXML = iCMDProcGASControl(elelist);
  3035. } else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3036. // 현대건설 더펜트하우스 와 구분하여 처리
  3037. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3038. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  3039. mWallpadDeviceSet.closeDB();
  3040. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  3041. retXML = iCMDProcChumDamSmartLightControl(doc);
  3042. }
  3043. else {
  3044. retXML = iCMDProcSDPSmartLightControl(doc);
  3045. }
  3046. } else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3047. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3048. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3049. retXML = iCMDProc_I_LightControl(doc);
  3050. } else {
  3051. retXML = iCMDProcLivingLightControl(doc);
  3052. }
  3053. } else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3054. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I
  3055. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
  3056. || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
  3057. retXML = iCMDProcSDPConcentControl(doc);
  3058. } else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3059. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3060. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3061. } else {
  3062. retXML = iCMDProcMultiSWControl(doc);
  3063. }
  3064. } else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3065. retXML = iCMDProcDoorlockControl(doc);
  3066. } else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3067. retXML = iCMDProcTemperControl(doc);
  3068. } else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3069. retXML = iCMDProcModeControl(doc);
  3070. } else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3071. retXML = iCMDProcVentilControl(doc);
  3072. } else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3073. retXML = iCMDProcCurtainControl(doc);
  3074. } else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3075. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3076. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3077. retXML = iCMDProcEnergyMeterLightControl(doc);
  3078. } else {
  3079. retXML = iCMDProcLightControl(doc);
  3080. }
  3081. } else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3082. retXML = iCMDProcLightBatchControl(elelist);
  3083. }
  3084. //모바일 사용자 인증 관련 메시지
  3085. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3086. ProcMobileDevice_AuthNumber(elelist);
  3087. } else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3088. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3089. } else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3090. ProcMobileDevice_Delete(elelist);
  3091. } else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3092. retXML = ProcGetSmartKeyInfo(elelist);
  3093. } else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3094. retXML = ProcGetAppVersionInfo();
  3095. } else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3096. retXML = ProcIgateInitInfo(elelist);
  3097. } else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3098. retXML = ProcElecCarChargeEventInfo(elelist);
  3099. } else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3100. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3101. } else if (cmd.equalsIgnoreCase("check_call_option")) {
  3102. retXML = ProcCheckCallOption();
  3103. } else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3104. retXML = ProcChatSequence(elelist);
  3105. } else if (cmd.equalsIgnoreCase("chat_message")) {
  3106. retXML = ProcChatMessage(elelist);
  3107. } else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3108. retXML = ProcEvacuationLadderOpen(elelist);
  3109. } else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3110. retXML = SmartLightDetailInfo(elelist);
  3111. } else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3112. retXML = KNXDeviceDetailInfo(elelist);
  3113. } else if (cmd.equalsIgnoreCase("set_server_version")) {
  3114. retXML = ProcSetServerChange(elelist);
  3115. } else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
  3116. retXML = iCMDProcOnePass(elelist);
  3117. } else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3118. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3119. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3120. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3121. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3122. }
  3123. } else if (cmd.equalsIgnoreCase("check_resident_safety")) {
  3124. retXML = iCMDProcResidentSafety(elelist);
  3125. }
  3126. break;
  3127. }
  3128. }
  3129. if (retXML != null) {
  3130. imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
  3131. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3132. byte[] outBF = retXML.getBytes("euc-kr");
  3133. outstream.write(outBF);
  3134. outstream.flush();
  3135. try {
  3136. Thread.sleep(3000);
  3137. } catch (RuntimeException re) {
  3138. LogUtil.errorLogInfo("", TAG, re);
  3139. } catch (Exception e) {
  3140. LogUtil.errorLogInfo("", TAG, e);
  3141. }
  3142. iMAPSock.close();
  3143. } else {
  3144. try {
  3145. iMAPSock.close();
  3146. } catch (RuntimeException re) {
  3147. LogUtil.errorLogInfo("", TAG, re);
  3148. } catch (Exception e) {
  3149. LogUtil.errorLogInfo("", TAG, e);
  3150. }
  3151. }
  3152. } catch (RuntimeException re) {
  3153. LogUtil.errorLogInfo("", TAG, re);
  3154. } catch (Exception e) {
  3155. try {
  3156. iMAPSock.close();
  3157. } catch (RuntimeException re) {
  3158. LogUtil.errorLogInfo("", TAG, re);
  3159. } catch (Exception E) {
  3160. LogUtil.errorLogInfo("", TAG, E);
  3161. }
  3162. LogUtil.errorLogInfo("", TAG, e);
  3163. }
  3164. }
  3165. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3166. private void procUpgrade() {
  3167. imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
  3168. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3169. String[] getstate = sdb.GetSystemUpdateStatus();
  3170. sdb.closeDB();
  3171. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3172. for (int i = 0; i < getstate.length; i++) {
  3173. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3174. }
  3175. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3176. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3177. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3178. }
  3179. }
  3180. // " 제거
  3181. private String trimquotation(String sen) {
  3182. sen = sen.replaceAll("\"", "");
  3183. return sen.trim();
  3184. }
  3185. //remote_auscultate 처리
  3186. public String ProcauscultateReq(Document Doc) {
  3187. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3188. NodeList items = Doc.getElementsByTagName("group");
  3189. Node item;
  3190. String itemname = null;
  3191. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3192. SettManager.DeleteSettingData();
  3193. SettManager.DropTable();
  3194. try {
  3195. for (int i = 0; i < items.getLength(); i++) {
  3196. item = items.item(i);
  3197. itemname = GetAttributeVal(item, "type");
  3198. String GetCNT = GetAttributeVal(item, "count");
  3199. if (Integer.parseInt(GetCNT) <= 0)
  3200. continue;
  3201. Element SettingItem = (Element) item;
  3202. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3203. for (int j = 0; j < SettingList.getLength(); j++) {
  3204. Node subdevListitem = SettingList.item(j);
  3205. String devname = trimquotation(subdevListitem.getTextContent());
  3206. SettManager.InsertSettingData(itemname, devname, j);
  3207. }
  3208. }
  3209. } catch (RuntimeException re) {
  3210. LogUtil.errorLogInfo("", TAG, re);
  3211. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3212. SettManager.closeDB();
  3213. return RetVal;
  3214. } catch (Exception e) {
  3215. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3216. //e.printStackTrace();
  3217. LogUtil.errorLogInfo("", TAG, e);
  3218. SettManager.closeDB();
  3219. return RetVal;
  3220. }
  3221. SettManager.closeDB();
  3222. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3223. StatusBeatRequested = true;
  3224. Intent intent = new Intent();
  3225. intent.setAction(define.NOTIFY_ACNAME);
  3226. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
  3227. sendBroadcast(intent);
  3228. return RetVal;
  3229. }
  3230. public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
  3231. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  3232. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n" +
  3233. "<service type=\"request\" name=\"remote_auscultate\">\r\n" +
  3234. " <guidemap devtype=\"homedev\" count=\"4\">\r\n" +
  3235. " <group type=\"ctrl_device\" count=\"5\">\r\n" +
  3236. " <unit>\"light\"</unit>\r\n" +
  3237. " <unit>\"thermostat\"</unit>\r\n" +
  3238. " <unit>\"gas\"</unit>\r\n" +
  3239. " <unit>\"doorlock\"</unit>\r\n" +
  3240. " <unit>\"ventil\"</unit>\r\n" +
  3241. " </group>\r\n" +
  3242. " <group type=\"talk_device\" count=\"4\">\r\n" +
  3243. " <unit>\"sub_homedev\"</unit>\r\n" +
  3244. " <unit>\"kitchen_tv\"</unit>\r\n" +
  3245. " <unit>\"bath_tv\"</unit>\r\n" +
  3246. " <unit>\"bath_phone\"</unit>\r\n" +
  3247. " </group>\r\n" +
  3248. " <group type=\"sensor\" count=\"6\">\r\n" +
  3249. " <unit>\"magnetic\"</unit>\r\n" +
  3250. " <unit>\"bugout\"</unit>\r\n" +
  3251. " <unit>\"bugin\"</unit>\r\n" +
  3252. " <unit>\"fire\"</unit>\r\n" +
  3253. " <unit>\"gas\"</unit>\r\n" +
  3254. " <unit>\"emergency\"</unit>\r\n" +
  3255. " </group>\r\n" +
  3256. " <group type=\"extended\" count=\"4\">\r\n" +
  3257. " <unit>\"gateway\"</unit>\r\n" +
  3258. " <unit>\"smartswitch\"</unit>\r\n" +
  3259. " <unit>\"handy\"</unit>\r\n" +
  3260. " <unit>\"energymeter\"</unit>\r\n" +
  3261. " </group>\r\n" +
  3262. " </guidemap>\r\n" +
  3263. "</service>\r\n" +
  3264. "</imap>\r\n";
  3265. try {
  3266. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3267. DocumentBuilder builder = factory.newDocumentBuilder();
  3268. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3269. Document doc = builder.parse(istream);
  3270. NodeList items = doc.getElementsByTagName("group");
  3271. Node item;
  3272. String itemname = null;
  3273. SettManager.DeleteSettingData();
  3274. SettManager.DropTable();
  3275. for (int i = 0; i < items.getLength(); i++) {
  3276. item = items.item(i);
  3277. itemname = GetAttributeVal(item, "type");
  3278. String GetCNT = GetAttributeVal(item, "count");
  3279. if (Integer.parseInt(GetCNT) <= 0)
  3280. continue;
  3281. Element SettingItem = (Element) item;
  3282. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3283. for (int j = 0; j < SettingList.getLength(); j++) {
  3284. Node subdevListitem = SettingList.item(j);
  3285. String devname = trimquotation(subdevListitem.getTextContent());
  3286. SettManager.InsertSettingData(itemname, devname, j);
  3287. }
  3288. }
  3289. } catch (RuntimeException re) {
  3290. LogUtil.errorLogInfo("", TAG, re);
  3291. } catch (Exception e) {
  3292. //e.printStackTrace();
  3293. LogUtil.errorLogInfo("", TAG, e);
  3294. }
  3295. }
  3296. String MakeFailMessage(String msg) {
  3297. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\"" + msg + "\"</first_failed>\r\n</service>\r\n</imap>";
  3298. }
  3299. //SetInfo의 각 항목들의 무결성 확인
  3300. final String isUse = "사용함";
  3301. final String isNotUse = "사용안함";
  3302. boolean CheckSubdevData(String devName, String devData) {
  3303. String[] SplitedMSG;
  3304. try {
  3305. if (devName.equals("가스밸브")) {
  3306. SplitedMSG = devData.split("[(]");
  3307. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3308. String UseStr = SplitedMSG[2].split("[)]")[0];
  3309. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3310. } else if (devName.equals("디지털도어락")) {
  3311. SplitedMSG = devData.split("[(]");
  3312. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3313. String[] UseStr = SplitedMSG[2].split("[)]");
  3314. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3315. if (!UseStr[1].equals("종류")) return false;
  3316. UseStr = SplitedMSG[3].split("[)]");
  3317. if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
  3318. } else if (devName.equals("온도조절기")) {
  3319. SplitedMSG = devData.split("[(]");
  3320. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3321. String[] UseStr = SplitedMSG[2].split("[)]");
  3322. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3323. } else if (devName.equals("조명제어기")) {
  3324. SplitedMSG = devData.split("[(]");
  3325. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3326. String[] UseStr = SplitedMSG[2].split("[)]");
  3327. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3328. /*
  3329. if (!UseStr[1].equals("종류"))
  3330. return false;
  3331. UseStr = SplitedMSG[3].split("[)]");
  3332. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3333. return false;
  3334. */
  3335. } else if (devName.equals("환기시스템")) {
  3336. SplitedMSG = devData.split("[(]");
  3337. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3338. String[] UseStr = SplitedMSG[2].split("[)]");
  3339. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3340. /*
  3341. if (!UseStr[1].equals("종류"))
  3342. return false;
  3343. UseStr = SplitedMSG[3].split("[)]");
  3344. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  3345. return false;
  3346. */
  3347. } else if (devName.equals("시스템에어컨")) {
  3348. SplitedMSG = devData.split("[(]");
  3349. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3350. String[] UseStr = SplitedMSG[2].split("[)]");
  3351. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3352. } else if (devName.equals("전동커튼")) {
  3353. SplitedMSG = devData.split("[(]");
  3354. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3355. String[] UseStr = SplitedMSG[2].split("[)]");
  3356. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3357. /*
  3358. if (!UseStr[1].equals("종류"))
  3359. return false;
  3360. UseStr = SplitedMSG[3].split("[)]");
  3361. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  3362. return false;
  3363. */
  3364. } else if (devName.equals("실시간검침기")) {
  3365. SplitedMSG = devData.split("[(]");
  3366. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3367. String[] UseStr = SplitedMSG[2].split("[)]");
  3368. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3369. } else if (devName.equals("스마트스위치&일괄소등")) {
  3370. SplitedMSG = devData.split("[(]");
  3371. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3372. String[] UseStr = SplitedMSG[2].split("[)]");
  3373. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3374. /*
  3375. if (!UseStr[1].equals("종류"))
  3376. return false;
  3377. UseStr = SplitedMSG[3].split("[)]");
  3378. if (!UseStr[0].equals("대외향스마트스위치")&&
  3379. !UseStr[0].equals("대외향일괄소등제어기")&&
  3380. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  3381. !UseStr[0].equals("현산향스마트스위치")&&
  3382. !UseStr[0].equals("현산향LCD스마트스위치"))
  3383. return false;
  3384. */
  3385. } else if (devName.equals("무선리모컨")) {
  3386. SplitedMSG = devData.split("[(]");
  3387. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3388. String[] UseStr = SplitedMSG[2].split("[)]");
  3389. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3390. } else if (devName.equals("현관카메라")) {
  3391. SplitedMSG = devData.split("[(]");
  3392. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3393. String[] UseStr = SplitedMSG[2].split("[)]");
  3394. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3395. /*
  3396. if (!UseStr[1].equals("종류"))
  3397. return false;
  3398. UseStr = SplitedMSG[3].split("[)]");
  3399. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  3400. return false;
  3401. */
  3402. } else if (devName.equals("공지사항")) {
  3403. SplitedMSG = devData.split("[(]");
  3404. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3405. String[] UseStr = SplitedMSG[2].split("[)]");
  3406. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3407. } else if (devName.equals("날씨")) {
  3408. SplitedMSG = devData.split("[(]");
  3409. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3410. String[] UseStr = SplitedMSG[2].split("[)]");
  3411. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3412. } else if (devName.equals("메모")) {
  3413. SplitedMSG = devData.split("[(]");
  3414. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3415. String[] UseStr = SplitedMSG[2].split("[)]");
  3416. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3417. } else if (devName.equals("전자액자")) {
  3418. SplitedMSG = devData.split("[(]");
  3419. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3420. String[] UseStr = SplitedMSG[2].split("[)]");
  3421. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3422. } else if (devName.equals("일정표")) {
  3423. SplitedMSG = devData.split("[(]");
  3424. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3425. String[] UseStr = SplitedMSG[2].split("[)]");
  3426. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3427. } else if (devName.equals("주차확인")) {
  3428. SplitedMSG = devData.split("[(]");
  3429. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3430. String[] UseStr = SplitedMSG[2].split("[)]");
  3431. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3432. /*
  3433. UseStr = SplitedMSG[3].split("[)]");
  3434. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3435. return false;
  3436. */
  3437. } else if (devName.equals("시간설정")) {
  3438. SplitedMSG = devData.split("[(]");
  3439. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3440. String[] UseStr = SplitedMSG[2].split("[)]");
  3441. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3442. } else if (devName.equals("원격검침")) {
  3443. SplitedMSG = devData.split("[(]");
  3444. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3445. String[] UseStr = SplitedMSG[2].split("[)]");
  3446. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3447. } else if (devName.equals("뮤직")) {
  3448. SplitedMSG = devData.split("[(]");
  3449. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3450. String[] UseStr = SplitedMSG[2].split("[)]");
  3451. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3452. } else if (devName.equals("영상재생")) {
  3453. SplitedMSG = devData.split("[(]");
  3454. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3455. String[] UseStr = SplitedMSG[2].split("[)]");
  3456. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3457. } else if (devName.equals("CCTV")) {
  3458. SplitedMSG = devData.split("[(]");
  3459. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3460. String[] UseStr = SplitedMSG[2].split("[)]");
  3461. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3462. /*
  3463. UseStr = SplitedMSG[3].split("[)]");
  3464. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3465. return false;
  3466. */
  3467. } else if (devName.equals("명칭설정")) {
  3468. SplitedMSG = devData.split("[(]");
  3469. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3470. String[] UseStr = SplitedMSG[2].split("[)]");
  3471. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3472. } else if (devName.equals("출동경비")) {
  3473. SplitedMSG = devData.split("[(]");
  3474. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3475. String[] UseStr = SplitedMSG[2].split("[)]");
  3476. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3477. } else if (devName.equals("경비실영상통화")) {
  3478. SplitedMSG = devData.split("[(]");
  3479. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3480. String[] UseStr = SplitedMSG[2].split("[)]");
  3481. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3482. } else if (devName.equals("엘리베이터")) {
  3483. SplitedMSG = devData.split("[(]");
  3484. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3485. String[] UseStr = SplitedMSG[2].split("[)]");
  3486. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3487. /*
  3488. UseStr = SplitedMSG[3].split("[)]");
  3489. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3490. return false;
  3491. */
  3492. } else if (devName.equals("현장특화기능")) {
  3493. SplitedMSG = devData.split("[(]");
  3494. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3495. String[] UseStr = SplitedMSG[2].split("[)]");
  3496. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3497. /*
  3498. UseStr = SplitedMSG[3].split("[)]");
  3499. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3500. return false;
  3501. */
  3502. } else if (devName.equals("월패드카메라")) {
  3503. SplitedMSG = devData.split("[(]");
  3504. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3505. String[] UseStr = SplitedMSG[2].split("[)]");
  3506. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3507. } else if (devName.equals("무드등")) {
  3508. SplitedMSG = devData.split("[(]");
  3509. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3510. String[] UseStr = SplitedMSG[2].split("[)]");
  3511. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3512. /*
  3513. UseStr = SplitedMSG[3].split("[)]");
  3514. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3515. return false;
  3516. */
  3517. } else if (devName.equals("피난사다리")) {
  3518. SplitedMSG = devData.split("[(]");
  3519. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3520. String[] UseStr = SplitedMSG[2].split("[)]");
  3521. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3522. } else if (devName.equals("동체설정")) {
  3523. return true;
  3524. /*
  3525. SplitedMSG = devData.split("[(]");
  3526. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3527. return false;
  3528. String[] UseStr = SplitedMSG[2].split("[)]");
  3529. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3530. return false;
  3531. if (UseStr[0].equals(isNotUse)) return true;
  3532. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3533. return false;
  3534. for (int i=3; i < SplitedMSG.length; i++)
  3535. {
  3536. UseStr = SplitedMSG[i].split("[)]");
  3537. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3538. return false;
  3539. if (i != SplitedMSG.length-1)
  3540. {
  3541. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3542. return false;
  3543. }
  3544. }
  3545. */
  3546. } else if (devName.equals("알람발생")) {
  3547. SplitedMSG = devData.split("[(]");
  3548. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3549. String[] UseStr = SplitedMSG[2].split("[)]");
  3550. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3551. } else if (devName.equals("UI순서")) {
  3552. SplitedMSG = devData.split("[(]");
  3553. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3554. String[] UseStr = SplitedMSG[2].split("[)]");
  3555. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3556. } else {
  3557. Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
  3558. Log.w("iMAP", "Return true");
  3559. return true;
  3560. }
  3561. } catch (RuntimeException re) {
  3562. LogUtil.errorLogInfo("", TAG, re);
  3563. return false;
  3564. } catch (Exception e) {
  3565. //e.printStackTrace();
  3566. LogUtil.errorLogInfo("", TAG, e);
  3567. return false;
  3568. }
  3569. return true;
  3570. }
  3571. public String ProcSetsetup(Document ele) {
  3572. Common.DebugLog("ProcSetsetup------------------------->");
  3573. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3574. NodeList items = ele.getElementsByTagName("setting");
  3575. Node item;
  3576. String itemname = null;
  3577. String dateData = null;
  3578. String heartbeatP = null;
  3579. String Versions = null;
  3580. String SdbAccInit_Str = null;
  3581. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3582. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3583. if (!SettManager.StartTransaction()) {
  3584. ResetFlag = false;
  3585. RetVal += "\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3586. SettManager.EndTransaction(false);
  3587. SettManager.closeDB();
  3588. return RetVal;
  3589. }
  3590. try {
  3591. for (int i = 0; i < items.getLength(); i++) {
  3592. item = items.item(i);
  3593. itemname = GetAttributeVal(item, "name");
  3594. if (itemname != null) {
  3595. if (itemname.equals("beat_time")) {
  3596. heartbeatP = GetAttributeVal(item, "value");
  3597. } else if (itemname.equals("ver_setting")) {
  3598. Versions = GetAttributeVal(item, "value");
  3599. } else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3600. Element guardlist = (Element) item;
  3601. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3602. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3603. else continue;
  3604. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3605. Node GuardListitem = GuardCTList.item(j);
  3606. String guardname = GetAttributeVal(GuardListitem, "name");
  3607. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3608. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3609. }
  3610. } else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3611. Element subdevList = (Element) item;
  3612. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3613. for (int j = 0; j < SubDevList.getLength(); j++) {
  3614. Node subdevListitem = SubDevList.item(j);
  3615. String devname = GetAttributeVal(subdevListitem, "name");
  3616. String devval = GetAttributeVal(subdevListitem, "value");
  3617. if (devname != null && devval != null) {
  3618. devname = devname.replaceAll("\\p{Z}", "");
  3619. devval = devval.replaceAll("\\p{Z}", "");
  3620. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  3621. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3622. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3623. }
  3624. if (CheckSubdevData(devname, devval) == false) {
  3625. ResetFlag = false;
  3626. Log.w("iMAP", "Set Setup Fail name : " + devname + " Value : " + devval);
  3627. SettManager.EndTransaction(false);
  3628. SettManager.closeDB();
  3629. return MakeFailMessage(devname);
  3630. }
  3631. String[] SettingDBValue = SettManager.GetSettingData(devname);
  3632. if (SettingDBValue != null) {
  3633. String devInfo = SettingDBValue[1];
  3634. if (devInfo.equals(devval) == false) {
  3635. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3636. Log.w("iMAP", "DB Setup Value : " + devInfo);
  3637. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3638. ResetFlag = true;
  3639. }
  3640. } else {
  3641. Log.w("iMAP", "DB No Setup Name and Value");
  3642. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3643. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3644. ResetFlag = true;
  3645. }
  3646. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3647. if (devname.equals("로고설정")) {
  3648. String devInfo = devval;
  3649. devInfo = devInfo.replace('(', '_');
  3650. devInfo = devInfo.replace(':', '_');
  3651. devInfo = devInfo.replace(')', '_');
  3652. String[] DetailInfo = devInfo.split("_");
  3653. int LogoType = 0;
  3654. if (DetailInfo[5].equals("표시안함") == true) {
  3655. LogoType = 0;
  3656. } else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3657. LogoType = 1;
  3658. } else if (DetailInfo[5].equals("양우내안애") == true) {
  3659. LogoType = 2;
  3660. } else if (DetailInfo[5].equals("GSITM") == true) {
  3661. LogoType = 3;
  3662. } else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3663. LogoType = 4;
  3664. } else if (DetailInfo[5].equals("거실조명표시") == true) {
  3665. LogoType = 5;
  3666. } else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3667. LogoType = 6;
  3668. } else if (DetailInfo[5].equals("기타1") == true) {
  3669. LogoType = 7;
  3670. } else if (DetailInfo[5].equals("기타2") == true) {
  3671. LogoType = 8;
  3672. }
  3673. if ((LogoType >= 0) && (LogoType <= 8)) {
  3674. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3675. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3676. }
  3677. } else if (devname.equals("엘리베이터위젯복구")) {
  3678. String devInfo = devval;
  3679. devInfo = devInfo.replace('(', '_');
  3680. devInfo = devInfo.replace(':', '_');
  3681. devInfo = devInfo.replace(')', '_');
  3682. String[] DetailInfo = devInfo.split("_");
  3683. if (DetailInfo[3].equals("사용함") == true) {
  3684. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3685. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3686. }
  3687. } else if (devname.equals("분전반알람설정")) {
  3688. try {
  3689. String devInfo = devval;
  3690. devInfo = devInfo.replace('(', '_');
  3691. devInfo = devInfo.replace(':', '_');
  3692. devInfo = devInfo.replace(')', '_');
  3693. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3694. //[0] - 기기번호
  3695. //[1] - 회로수
  3696. //[2] - 기기이름
  3697. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3698. //[4] - 명칭
  3699. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3700. String[] DetailInfo = devInfo.split("_");
  3701. for (int a = 0; a < DetailInfo.length; a++) {
  3702. if (DetailInfo[a].equals("누적전력초기화")) {
  3703. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3704. if ((a + 1) <= DetailInfo.length) {
  3705. // 설정정보가 존재해야 인식하도록 함
  3706. if (DetailInfo[a + 1].equals("1")) {
  3707. // 1(사용함) 일때
  3708. if (sdbAPI != null) {
  3709. if (sdbAPI.Set_AccPwReset() >= 0) {
  3710. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3711. } else {
  3712. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3713. }
  3714. }
  3715. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3716. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3717. }
  3718. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3719. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3720. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3721. }
  3722. }
  3723. }
  3724. } catch (RuntimeException re) {
  3725. LogUtil.errorLogInfo("", TAG, re);
  3726. } catch (Exception e) {
  3727. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3728. //e.printStackTrace();
  3729. LogUtil.errorLogInfo("", TAG, e);
  3730. }
  3731. } else if (devname.equals("욕실폰통화음량값")) {
  3732. Intent Iintent = new Intent();
  3733. Iintent.setAction(define.NOTIFY_ACNAME);
  3734. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3735. sendBroadcast(Iintent);
  3736. } else if (devname.equals("주방TV통화음량값")) {
  3737. Intent Iintent = new Intent();
  3738. Iintent.setAction(define.NOTIFY_ACNAME);
  3739. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3740. sendBroadcast(Iintent);
  3741. } else if (devname.equals("현관카메라")) {
  3742. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3743. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3744. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3745. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  3746. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3747. String devInfo = devval;
  3748. if (devInfo != null) {
  3749. devInfo = devInfo.replace('(', '_');
  3750. devInfo = devInfo.replace(':', '_');
  3751. devInfo = devInfo.replace(')', '_');
  3752. String[] DetailInfo = devInfo.split("_");
  3753. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3754. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  3755. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3756. if (mIOInterface != null)
  3757. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3758. } else {
  3759. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  3760. if (mIOInterface != null)
  3761. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3762. }
  3763. }
  3764. }
  3765. }
  3766. } else if (devname.equals("거동수상자녹화")) {
  3767. String devInfo = devval;
  3768. devInfo = devInfo.replace('(', '_');
  3769. devInfo = devInfo.replace(':', '_');
  3770. devInfo = devInfo.replace(')', '_');
  3771. String[] DetailInfo = devInfo.split("_");
  3772. } else if (devname.equals("스마트현관카메라좌우반전")) {
  3773. String devInfo = devval;
  3774. if (devInfo != null) {
  3775. devInfo = devInfo.replace('(', '_');
  3776. devInfo = devInfo.replace(':', '_');
  3777. devInfo = devInfo.replace(')', '_');
  3778. }
  3779. String[] DetailInfo = devInfo.split("_");
  3780. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3781. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3782. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3783. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3784. } else {
  3785. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  3786. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  3787. }
  3788. }
  3789. } else {
  3790. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3791. }
  3792. }
  3793. }
  3794. } else if (itemname.equals("datetime")) {
  3795. dateData = GetAttributeVal(item, "value");
  3796. } else {
  3797. String GetVal = GetAttributeVal(item, "value");
  3798. if (GetVal != null) {
  3799. if (!GetVal.equals("list")) {
  3800. if (itemname.equals("site_code")) {
  3801. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3802. if (Existing_SiteCode_Array == null) {
  3803. ResetFlag = true;
  3804. } else {
  3805. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3806. if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
  3807. ResetFlag = true;
  3808. }
  3809. }
  3810. }
  3811. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3812. } else {
  3813. String GetCNT = GetAttributeVal(item, "count");
  3814. if (Integer.parseInt(GetCNT) <= 0) continue;
  3815. Element SettingItem = (Element) item;
  3816. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3817. for (int j = 0; j < SettingList.getLength(); j++) {
  3818. Node subdevListitem = SettingList.item(j);
  3819. String devname = GetAttributeVal(subdevListitem, "name");
  3820. String devval = GetAttributeVal(subdevListitem, "value");
  3821. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3822. }
  3823. }
  3824. }
  3825. }
  3826. }
  3827. }
  3828. } catch (RuntimeException re) {
  3829. LogUtil.errorLogInfo("", TAG, re);
  3830. ResetFlag = false;
  3831. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3832. SettManager.EndTransaction(false);
  3833. SettManager.closeDB();
  3834. return RetVal;
  3835. } catch (Exception e) {
  3836. ResetFlag = false;
  3837. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3838. //e.printStackTrace();
  3839. LogUtil.errorLogInfo("", TAG, e);
  3840. SettManager.EndTransaction(false);
  3841. SettManager.closeDB();
  3842. return RetVal;
  3843. }
  3844. SettManager.EndTransaction(true);
  3845. SettManager.closeDB();
  3846. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3847. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3848. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3849. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3850. }
  3851. if (AfterTransactionTodoList != null) {
  3852. if (AfterTransactionTodoList.size() > 0) {
  3853. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3854. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3855. if (afterTransactionTodoListData != null) {
  3856. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3857. WallpadSalesSampleData mWallpadSalesSampleData;
  3858. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3859. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3860. mWallpadSalesSampleData.closeDB();
  3861. } else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3862. //ifdb에 있는지
  3863. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3864. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3865. int result = devSet.Get_Elevator_Info();
  3866. devSet.closeDB();
  3867. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3868. // 엘리베이터가 사용함이면
  3869. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3870. boolean result_get_restoreUseOrNot;
  3871. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3872. if (wdb != null) {
  3873. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3874. if (result_get_restoreUseOrNot == false) {
  3875. wdb.SetElevator_Widget_Restore(true);
  3876. //위젯 DB 초기화
  3877. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3878. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3879. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3880. devSet2.initWidgetData();
  3881. devSet2.closeDB();
  3882. }
  3883. }
  3884. wdb.closeDB();
  3885. }
  3886. }
  3887. }
  3888. }
  3889. }
  3890. }
  3891. }
  3892. if (dateData != null) {
  3893. try {
  3894. int year = Integer.parseInt(dateData.substring(0, 4));
  3895. int month = Integer.parseInt(dateData.substring(4, 6));
  3896. int day = Integer.parseInt(dateData.substring(6, 8));
  3897. int hour = Integer.parseInt(dateData.substring(8, 10));
  3898. int min = Integer.parseInt(dateData.substring(10, 12));
  3899. int sec = Integer.parseInt(dateData.substring(12, 14));
  3900. Calendar nowdate = new GregorianCalendar();
  3901. long settedtime = nowdate.getTimeInMillis();
  3902. nowdate.set(Calendar.YEAR, year);
  3903. nowdate.set(Calendar.MONTH, month);
  3904. nowdate.set(Calendar.DAY_OF_MONTH, day);
  3905. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  3906. nowdate.set(Calendar.MINUTE, min);
  3907. nowdate.set(Calendar.SECOND, sec);
  3908. long bootupmil = nowdate.getTimeInMillis();
  3909. if (Math.abs(bootupmil - settedtime) > 5000) {
  3910. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3911. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  3912. DBMGR.closeDB();
  3913. Intent Iintent = new Intent();
  3914. Iintent.setAction(define.NOTIFY_ACNAME);
  3915. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  3916. sendBroadcast(Iintent);
  3917. }
  3918. } catch (RuntimeException re) {
  3919. LogUtil.errorLogInfo("", TAG, re);
  3920. } catch (Exception e) {
  3921. //e.printStackTrace();
  3922. LogUtil.errorLogInfo("", TAG, e);
  3923. }
  3924. }
  3925. if (heartbeatP != null) {
  3926. try {
  3927. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3928. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  3929. DBMGR.closeDB();
  3930. } catch (RuntimeException re) {
  3931. LogUtil.errorLogInfo("", TAG, re);
  3932. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3933. SettManager.closeDB();
  3934. return RetVal;
  3935. } catch (Exception e) {
  3936. //e.printStackTrace();
  3937. LogUtil.errorLogInfo("", TAG, e);
  3938. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3939. SettManager.closeDB();
  3940. return RetVal;
  3941. }
  3942. }
  3943. if (Versions != null) {
  3944. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3945. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  3946. DBMGR.SetSettingVer(Versions);
  3947. DBMGR.closeDB();
  3948. }
  3949. Intent intent = new Intent();
  3950. intent.setAction(define.NOTIFY_ACNAME);
  3951. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  3952. getApplicationContext().sendBroadcast(intent);
  3953. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3954. return RetVal;
  3955. }
  3956. public String ProcNotifyparcel(Document doc) {
  3957. String moveInfo = "null";
  3958. String boxNo = "null";
  3959. String serviceInfo = "null";
  3960. String receiverInfo = "null";
  3961. String message = "null";
  3962. int remainCnt = 0;
  3963. try {
  3964. NodeList param = doc.getElementsByTagName("move_info");
  3965. Node item = param.item(0);
  3966. moveInfo = trimquotation(item.getTextContent());
  3967. param = doc.getElementsByTagName("params");
  3968. item = param.item(0);
  3969. if (item != null) {
  3970. boxNo = GetAttributeVal(item, "box_num");
  3971. serviceInfo = GetAttributeVal(item, "service_info");
  3972. receiverInfo = GetAttributeVal(item, "receiver_info");
  3973. message = GetAttributeVal(item, "message");
  3974. if (message != null) {
  3975. String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
  3976. if (msgList[0].equalsIgnoreCase("remains")) {
  3977. remainCnt = Integer.parseInt(msgList[1]);
  3978. if (remainCnt > 0) {
  3979. wakeupLCD();
  3980. Intent intent = new Intent();
  3981. intent.setAction(define.NOTIFY_ACNAME);
  3982. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  3983. intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
  3984. intent.putExtra("BOX_NO", boxNo);
  3985. intent.putExtra("SERVICE_INFO", serviceInfo);
  3986. intent.putExtra("RECEIVER_INFO", receiverInfo);
  3987. intent.putExtra("REMAIN_CNT", remainCnt);
  3988. getApplicationContext().sendBroadcast(intent);
  3989. }
  3990. }
  3991. }
  3992. }
  3993. String retVal = XMLHeader +
  3994. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n" +
  3995. "</imap>\r\n";
  3996. return retVal;
  3997. } catch (RuntimeException re) {
  3998. LogUtil.errorLogInfo("", TAG, re);
  3999. String retVal = XMLHeader +
  4000. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4001. "</imap>\r\n";
  4002. return retVal;
  4003. } catch (Exception e) {
  4004. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4005. //e.printStackTrace();
  4006. LogUtil.errorLogInfo("", TAG, e);
  4007. String retVal = XMLHeader +
  4008. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4009. "</imap>\r\n";
  4010. return retVal;
  4011. }
  4012. }
  4013. public String ProcNotiPostInfo(Document doc) {
  4014. NodeList param = doc.getElementsByTagName("move_info");
  4015. Node item = param.item(0);
  4016. String aa = item.getTextContent();
  4017. aa = trimquotation(aa);
  4018. if (item != null) {
  4019. String info = item.getTextContent();
  4020. if (info != null) {
  4021. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4022. if (info.contains("post_in")) { // 우편물 보관
  4023. wakeupLCD();
  4024. int itemCount = -1;
  4025. param = doc.getElementsByTagName("params");
  4026. item = param.item(0);
  4027. if (item != null) {
  4028. String devname = GetAttributeVal(item, "message");
  4029. if (devname != null) {
  4030. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4031. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4032. if (msgList[0].equalsIgnoreCase("remains")) {
  4033. itemCount = Integer.parseInt(msgList[1]);
  4034. }
  4035. }
  4036. }
  4037. }
  4038. if (itemCount > 0) {
  4039. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4040. Intent intent = new Intent();
  4041. intent.setAction(define.NOTIFY_ACNAME);
  4042. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4043. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4044. intent.putExtra("ITEM", itemCount);
  4045. getApplicationContext().sendBroadcast(intent);
  4046. }
  4047. }
  4048. }
  4049. }
  4050. String retVal = XMLHeader +
  4051. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n" +
  4052. "</imap>\r\n";
  4053. return retVal;
  4054. }
  4055. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4056. public String ProcNotifypark(Document doc)
  4057. {
  4058. String MoveInfo = "none";
  4059. NodeList param = doc.getElementsByTagName("destination");
  4060. Node item = param.item(0);
  4061. if (item != null)
  4062. {
  4063. String dong = GetAttributeVal(item, "id_high").trim();
  4064. String ho = GetAttributeVal(item, "id_low").trim();
  4065. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4066. return (XMLHeader +
  4067. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4068. "</imap>\r\n");
  4069. }
  4070. param = doc.getElementsByTagName("move_info");
  4071. item = param.item(0);
  4072. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4073. param = doc.getElementsByTagName("params");
  4074. item = param.item(0);
  4075. if (item != null)
  4076. {
  4077. String carnum = GetAttributeVal(item, "car_num");
  4078. String locinfo = GetAttributeVal(item, "loc_info");
  4079. String msg = GetAttributeVal(item, "message");
  4080. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4081. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4082. parkdb.closeDB();Intent intent = new Intent();
  4083. intent.setAction(define.NOTIFY_ACNAME);
  4084. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4085. getApplicationContext().sendBroadcast(intent);
  4086. }
  4087. String retVal = XMLHeader +
  4088. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4089. "</imap>\r\n";
  4090. return retVal;
  4091. }
  4092. */
  4093. public String ProcGetsetup(Document doc) {
  4094. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4095. NodeList items = doc.getElementsByTagName("variable");
  4096. String RetVal = XMLHeader + "<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n" +
  4097. " <guidemap devtype=\"homedev\" count=\"" + items.getLength() + "\">\r\n";
  4098. Node item;
  4099. try {
  4100. for (int i = 0; i < items.getLength(); i++) {
  4101. item = items.item(i);
  4102. //String mRealTimeMeterData = item.getNodeValue();
  4103. String data = trimquotation(item.getTextContent());
  4104. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4105. if (gData.size() == 1) {
  4106. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + gData.get(0)[1] + "\" />\r\n";
  4107. } else if (gData.size() > 1) {
  4108. RetVal += " <setting name=\"" + data + "\" count=\"" + gData.size() + "\" value=\"list\" >\r\n";
  4109. RetVal += " <list name=\"DeviceInfo\" value=\"" + Build.MODEL + "/" + getAOSVerCode() + "\" />\r\n";
  4110. for (int k = 0; k < gData.size(); k++) {
  4111. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4112. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4113. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4114. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4115. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4116. }
  4117. RetVal += " <list name=\"" + gData.get(k)[0] + "\" value=\"" + gData.get(k)[1] + "\" />\r\n";
  4118. }
  4119. if (bAirQualityEnable) {
  4120. RetVal += " <list name=\"공기질센서버전\" value=\"" + getAirQualityInfo() + "\" />\r\n";
  4121. }
  4122. RetVal += " </setting>\r\n";
  4123. } else {
  4124. if (data.equals("beat_time")) {
  4125. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4126. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4127. DBMGR.closeDB();
  4128. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + heartbeatP + "\" />\r\n";
  4129. } else if (data.equals("ver_setting")) {
  4130. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4131. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + DBMGR.GetSettingVer() + "\" />\r\n";
  4132. DBMGR.closeDB();
  4133. } else if (data.equals("datetime")) {
  4134. Calendar cal = new GregorianCalendar();
  4135. 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";
  4136. } else if (data.equals("security_state")) {
  4137. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4138. int alarmST = DBMGR.GetAlarmStatus();
  4139. String SEC_ST;
  4140. if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
  4141. else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
  4142. else SEC_ST = "normal";
  4143. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + SEC_ST + "\" />\r\n";
  4144. DBMGR.closeDB();
  4145. } else if (data.equals("sensor_state")) {
  4146. int senIDX = 0;
  4147. String resultStr = "";
  4148. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4149. int BugSensor = DBMGR.Get_Sensor_Set();
  4150. WallPadInterface wpifc = new WallPadInterface();
  4151. if (BugSensor > 0) {
  4152. if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4153. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4154. String Senret;
  4155. if (outSen > 0) Senret = "detect";
  4156. else Senret = "undetect";
  4157. resultStr += " <list name=\"in_move\" count=\"0\" value=\"" + Senret + "\" />\r\n";
  4158. senIDX++;
  4159. } else {
  4160. if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4161. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4162. String Senret;
  4163. if (outSen > 0) Senret = "detect";
  4164. else Senret = "undetect";
  4165. resultStr += " <list name=\"in_move\" value=\"" + Senret + "\" />\r\n";
  4166. senIDX++;
  4167. }
  4168. if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4169. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4170. String Senret;
  4171. if (outSen > 0) Senret = "detect";
  4172. else Senret = "undetect";
  4173. resultStr += " <list name=\"out_move\" value=\"" + Senret + "\" />\r\n";
  4174. senIDX++;
  4175. }
  4176. }
  4177. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4178. String Senret;
  4179. if (outSen > 0) Senret = "detect";
  4180. else Senret = "undetect";
  4181. resultStr += " <list name=\"magnetic\" value=\"" + Senret + "\" />\r\n";
  4182. senIDX++;
  4183. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4184. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4185. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4186. if (outSen > 0) Senret = "detect";
  4187. else Senret = "undetect";
  4188. resultStr += " <list name=\"emergency\" value=\"" + Senret + "\" />\r\n";
  4189. senIDX++;
  4190. }
  4191. DBMGR.closeDB();
  4192. }
  4193. if (senIDX > 0) {
  4194. RetVal += " <setting name = \"sensor_state\" count = \"" + senIDX + "\" value = \"list\" >\r\n";
  4195. RetVal += resultStr;
  4196. RetVal += " </setting>\r\n";
  4197. }
  4198. } else if (data.equals("statusbeat_time")) {
  4199. } else {
  4200. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"\" />\r\n";
  4201. }
  4202. }
  4203. }
  4204. } catch (RuntimeException re) {
  4205. LogUtil.errorLogInfo("", TAG, re);
  4206. } catch (Exception e) {
  4207. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4208. //e.printStackTrace();
  4209. LogUtil.errorLogInfo("", TAG, e);
  4210. }
  4211. SettManager.closeDB();
  4212. RetVal += " </guidemap>\r\n </service>\r\n</imap>";
  4213. return RetVal;
  4214. }
  4215. public void ProcElevatorinfo(Element ele) {
  4216. try {
  4217. String floor;
  4218. String move_dir;
  4219. /*
  4220. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4221. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4222. Node info = evinfo.item(0);
  4223. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4224. if (info != null)
  4225. {
  4226. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4227. }
  4228. */
  4229. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4230. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
  4231. Node iinfo = ievinfo.item(0);
  4232. if (iinfo == null) {
  4233. Log.d("iMapServer", "func ProcElevatorinfo info == null");
  4234. return;
  4235. }
  4236. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4237. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4238. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4239. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4240. if (move_dir != null) {
  4241. if (move_dir.equalsIgnoreCase("up")) {
  4242. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4243. } else if (move_dir.equalsIgnoreCase("down")) {
  4244. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4245. } else if (move_dir.equalsIgnoreCase("stop")) {
  4246. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4247. } else if (move_dir.equalsIgnoreCase("wrong")) {
  4248. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4249. } else if (move_dir.equalsIgnoreCase("finish")) {
  4250. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4251. }
  4252. Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
  4253. }
  4254. byte updown = 0x00;
  4255. if (ievinfo != null) {
  4256. boolean downCall = false;
  4257. boolean upCall = false;
  4258. for (int i = 0; i < ievinfo.getLength(); i++) {
  4259. Node valItem = ievinfo.item(i);
  4260. if (valItem != null) {
  4261. if (downCall == false) {
  4262. String val = GetAttributeVal(valItem, "ev_call_dir");
  4263. if (val != null)
  4264. downCall = val.equalsIgnoreCase("down");
  4265. }
  4266. if (upCall == false) {
  4267. String val = GetAttributeVal(valItem, "ev_call_dir");
  4268. if (val != null) {
  4269. upCall = val.equalsIgnoreCase("up");
  4270. }
  4271. }
  4272. }
  4273. }
  4274. Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
  4275. if (downCall == true && upCall == true) updown = 0x02;
  4276. else if (downCall == false && upCall == true) updown = 0x01;
  4277. }
  4278. Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  4279. Intent intent = new Intent();
  4280. intent.setAction(define.NOTIFY_ACNAME);
  4281. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  4282. intent.putExtra(define.NOTIBR_FLOOR, floor);
  4283. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  4284. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  4285. getApplicationContext().sendBroadcast(intent);
  4286. } catch (RuntimeException re) {
  4287. LogUtil.errorLogInfo("", TAG, re);
  4288. } catch (Exception e) {
  4289. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  4290. //e.printStackTrace();
  4291. LogUtil.errorLogInfo("", TAG, e);
  4292. }
  4293. }
  4294. private String MakeTargetStr(WallpadiCMDParser data) {
  4295. return " <target name=\"" + data.target + "\" id = \"" + data.tid + "\" msg_no=\"" + data.msgno + "\"/>\r\n";
  4296. }
  4297. public String iCMDProcVentilControl(Document doc) {
  4298. try {
  4299. String unit_status = "null", mode = "null", unit_mode = "null";
  4300. String retStr = CheckiCMDProc("remote_access_ventil");
  4301. if (retStr != null) return retStr;
  4302. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  4303. String target = "null", tid = "null", msgno = "null";
  4304. NodeList items = doc.getElementsByTagName("target");
  4305. Node item = items.item(0);
  4306. if (item != null) {
  4307. NamedNodeMap attrs = item.getAttributes();
  4308. for (int j = 0; j < attrs.getLength(); j++) {
  4309. Node attr = attrs.item(j);
  4310. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4311. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4312. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4313. msgno = attr.getNodeValue();
  4314. }
  4315. }
  4316. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4317. if (NewServerUse()) {
  4318. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4319. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4320. return ServerCheckResult;
  4321. }
  4322. boolean procSucc = true;
  4323. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  4324. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  4325. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  4326. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4327. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  4328. boolean OnOff = false;
  4329. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  4330. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  4331. else procSucc = false;
  4332. } else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  4333. byte strength = 0;
  4334. if (ventilParser.ctraction.equalsIgnoreCase("low"))
  4335. strength = VentiAPI.WIND.LOW;
  4336. else if (ventilParser.ctraction.equalsIgnoreCase("mid"))
  4337. strength = VentiAPI.WIND.MID;
  4338. else strength = VentiAPI.WIND.HI;
  4339. if (VentilCTR.data.OnOff) {
  4340. // 환기가 On인 경우
  4341. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4342. else procSucc = false;
  4343. } else {
  4344. // 환기가 Off인 경우
  4345. if (VentilCTR.SetOnOff(true) >= 0) {
  4346. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4347. else procSucc = false;
  4348. } else {
  4349. procSucc = false;
  4350. }
  4351. }
  4352. }
  4353. if (VentilCTR.Refresh(true) == 0) {
  4354. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4355. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4356. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4357. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4358. else unit_status = "unknown";
  4359. if (VentilCTR.data.Support.AutoDriving) {
  4360. mode = "normal/auto";
  4361. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4362. else unit_mode = "normal";
  4363. } else {
  4364. mode = "normal";
  4365. unit_mode = "normal";
  4366. }
  4367. } else {
  4368. procSucc = false;
  4369. }
  4370. } else {
  4371. procSucc = false;
  4372. }
  4373. } else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4374. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4375. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4376. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4377. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4378. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4379. else unit_status = "unknown";
  4380. if (VentilCTR.data.Support.AutoDriving) {
  4381. mode = "normal/auto";
  4382. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4383. else unit_mode = "normal";
  4384. } else {
  4385. mode = "normal";
  4386. unit_mode = "normal";
  4387. }
  4388. } else {
  4389. procSucc = false;
  4390. }
  4391. } else {
  4392. procSucc = false;
  4393. }
  4394. if (procSucc == false) {
  4395. retStr += (" result=\"fail\" >\r\n");
  4396. unit_status = "unknown";
  4397. } else {
  4398. retStr += (" result=\"ok\" >\r\n");
  4399. }
  4400. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4401. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4402. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4403. // retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4404. retStr += " <status_info unit_num=\"ventil\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4405. return retStr;
  4406. } catch (RuntimeException re) {
  4407. LogUtil.errorLogInfo("", TAG, re);
  4408. return null;
  4409. } catch (Exception e) {
  4410. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4411. //e.printStackTrace();
  4412. LogUtil.errorLogInfo("", TAG, e);
  4413. return null;
  4414. }
  4415. }
  4416. public String iCMDProcTemperControl(Document doc) {
  4417. try {
  4418. String retStr = CheckiCMDProc("remote_access_temper");
  4419. if (retStr != null) return retStr;
  4420. else
  4421. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4422. String target = "null", tid = "null", msgno = "null";
  4423. NodeList items = doc.getElementsByTagName("target");
  4424. Node item = items.item(0);
  4425. if (item != null) {
  4426. NamedNodeMap attrs = item.getAttributes();
  4427. for (int j = 0; j < attrs.getLength(); j++) {
  4428. Node attr = attrs.item(j);
  4429. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4430. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4431. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4432. msgno = attr.getNodeValue();
  4433. }
  4434. }
  4435. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4436. if (NewServerUse()) {
  4437. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4438. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4439. return ServerCheckResult;
  4440. }
  4441. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4442. String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4443. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4444. // 난방 종류를 얻어온다.
  4445. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4446. HeatingV1API heatingV1API = null;
  4447. HeatingV2API heatingV2API = null;
  4448. // 종류별 API를 로딩한다.
  4449. if (HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4450. else if (HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4451. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4452. if (tempercmd.actionTXT.equals("control")) {
  4453. String[] CtrList;
  4454. byte ctrl = 0;
  4455. byte roomNum = (byte) 0xFF;
  4456. double temp = 0;
  4457. if (tempercmd.unitnum.equals("all")) {
  4458. if (tempercmd.ctraction.equals("on")) {
  4459. ctrl = 1;
  4460. } else if (tempercmd.ctraction.equals("off")) {
  4461. ctrl = 0;
  4462. } else {
  4463. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\" />\r\n </service>\r\n</imap> ";
  4464. return retStr;
  4465. }
  4466. } else {
  4467. CtrList = tempercmd.ctraction.split("/");
  4468. if (CtrList[0].equals("on")) ctrl = 1;
  4469. else ctrl = 0;
  4470. roomNum = (byte) 0xFF;
  4471. temp = Double.parseDouble(CtrList[1]);
  4472. }
  4473. if (HeatingKind == 1) {
  4474. boolean OnOff = false;
  4475. if (ctrl == 1) OnOff = true;
  4476. if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
  4477. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4478. if (ret != APIErrorCode.C_SUCCESS) {
  4479. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4480. return retStr;
  4481. }
  4482. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4483. } else {
  4484. for (byte i = 0; i < RoomList.length; i++) {
  4485. if (tempercmd.unitnum.equals(RoomList[i])) {
  4486. roomNum = i;
  4487. break;
  4488. }
  4489. }
  4490. if (roomNum == (byte) 0xFF) {
  4491. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4492. return retStr;
  4493. }
  4494. if (heatingV1API != null) {
  4495. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
  4496. if (ret != APIErrorCode.C_SUCCESS) {
  4497. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4498. return retStr;
  4499. }
  4500. heatingV1API.Refresh(roomNum, false);
  4501. }
  4502. }
  4503. } else if (HeatingKind == 2) {
  4504. byte Mode = HeatingV2.MODE.HeatingOFF;
  4505. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4506. if (tempercmd.unitnum.equals("all")) {
  4507. if (heatingV2API != null) {
  4508. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4509. if (ret != APIErrorCode.C_SUCCESS) {
  4510. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4511. return retStr;
  4512. }
  4513. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4514. }
  4515. } else {
  4516. for (byte i = 0; i < RoomList.length; i++) {
  4517. if (tempercmd.unitnum.equals(RoomList[i])) {
  4518. roomNum = i;
  4519. break;
  4520. }
  4521. }
  4522. if (roomNum == (byte) 0xFF) {
  4523. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4524. return retStr;
  4525. }
  4526. if (heatingV2API != null) {
  4527. int ret = heatingV2API.SetEachRoomStatus(roomNum, Mode, temp);
  4528. if (ret != APIErrorCode.C_SUCCESS) {
  4529. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4530. return retStr;
  4531. }
  4532. heatingV2API.Refresh(roomNum, false);
  4533. }
  4534. }
  4535. } else {
  4536. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4537. return retStr;
  4538. }
  4539. }
  4540. String resultStr = " <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4541. if (HeatingKind == 1) {
  4542. try {
  4543. if (heatingV1API == null) {
  4544. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4545. return retStr;
  4546. }
  4547. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4548. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4549. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount + "\"/>\r\n";
  4550. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4551. String drvmode = "off";
  4552. for (byte i = 0; i < RoomCount; i++) {
  4553. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4554. if (roomData.bOnOff) drvmode = "on";
  4555. else drvmode = "off";
  4556. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4557. resultStr += " <status_info unit_num=\"" + RoomList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4558. }
  4559. resultStr += " </service>\r\n</imap>\r\n";
  4560. retStr += ("\"ok\">\r\n" + resultStr);
  4561. return retStr;
  4562. } else {
  4563. String drvmode = "off";
  4564. byte roomNum = (byte) 0xFF;
  4565. for (byte i = 0; i < RoomList.length; i++) {
  4566. if (tempercmd.unitnum.equals(RoomList[i])) {
  4567. roomNum = i;
  4568. break;
  4569. }
  4570. }
  4571. if (roomNum == (byte) 0xFF) {
  4572. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4573. return retStr;
  4574. }
  4575. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4576. if (roomData.bOnOff) drvmode = "on";
  4577. else drvmode = "off";
  4578. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4579. resultStr += " <status_info unit_num=\"" + RoomList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4580. resultStr += " </service>\r\n</imap>\r\n";
  4581. retStr += ("\"ok\">\r\n" + resultStr);
  4582. return retStr;
  4583. }
  4584. } catch (RuntimeException re) {
  4585. LogUtil.errorLogInfo("", TAG, re);
  4586. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4587. return retStr;
  4588. } catch (Exception e) {
  4589. //e.printStackTrace();
  4590. LogUtil.errorLogInfo("", TAG, e);
  4591. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4592. return retStr;
  4593. }
  4594. } else if (HeatingKind == 2) {
  4595. try {
  4596. if (heatingV2API == null) {
  4597. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4598. return retStr;
  4599. }
  4600. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4601. resultStr += " <action> \"" + tempercmd.actionTXT + "\"</action>\r\n";
  4602. resultStr += " <status_map dev_num=\"1\" unit_cnt = \"" + RoomCount + "\" />\r\n";
  4603. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4604. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
  4605. String drvmode = "off";
  4606. for (byte i = 0; i < RoomCount; i++) {
  4607. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4608. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4609. else drvmode = "off";
  4610. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4611. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4612. resultStr += " <status_info unit_num=\"" + RoomList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + mDefaultRoomNameList_Heating[i] + "\"/>\r\n";
  4613. } else {
  4614. resultStr += " <status_info unit_num=\"" + RoomList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4615. }
  4616. }
  4617. resultStr += " </service>\r\n</imap>\r\n";
  4618. retStr += ("\"ok\">\r\n" + resultStr);
  4619. return retStr;
  4620. } else {
  4621. String drvmode = "off";
  4622. byte roomNum = (byte) 0xFF;
  4623. for (byte i = 0; i < RoomList.length; i++) {
  4624. if (tempercmd.unitnum.equals(RoomList[i])) {
  4625. roomNum = i;
  4626. break;
  4627. }
  4628. }
  4629. if (roomNum == (byte) 0xFF) {
  4630. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4631. return retStr;
  4632. }
  4633. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[roomNum];
  4634. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4635. else drvmode = "off";
  4636. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4637. resultStr += " <status_info unit_num=\"" + RoomList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4638. resultStr += " </service>\r\n</imap>\r\n";
  4639. retStr += ("\"ok\">\r\n" + resultStr);
  4640. return retStr;
  4641. }
  4642. } catch (RuntimeException re) {
  4643. LogUtil.errorLogInfo("", TAG, re);
  4644. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4645. return retStr;
  4646. } catch (Exception e) {
  4647. //e.printStackTrace();
  4648. LogUtil.errorLogInfo("", TAG, e);
  4649. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4650. return retStr;
  4651. }
  4652. } else {
  4653. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
  4654. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4655. return retStr;
  4656. }
  4657. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4658. // return retStr;
  4659. } catch (RuntimeException re) {
  4660. LogUtil.errorLogInfo("", TAG, re);
  4661. return null;
  4662. } catch (Exception e) {
  4663. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4664. //e.printStackTrace();
  4665. LogUtil.errorLogInfo("", TAG, e);
  4666. return null;
  4667. }
  4668. }
  4669. public String iCMDProcDoorlockControl(Document doc) {
  4670. try {
  4671. String DLStatus = "none";
  4672. String strResult = CheckiCMDProc("remote_access_doorlock");
  4673. if (strResult != null) return strResult;
  4674. else
  4675. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4676. String target = "null", tid = "null", msgno = "null";
  4677. NodeList items = doc.getElementsByTagName("target");
  4678. Node item = items.item(0);
  4679. if (item != null) {
  4680. NamedNodeMap attrs = item.getAttributes();
  4681. for (int j = 0; j < attrs.getLength(); j++) {
  4682. Node attr = attrs.item(j);
  4683. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4684. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4685. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4686. msgno = attr.getNodeValue();
  4687. }
  4688. }
  4689. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4690. if (NewServerUse()) {
  4691. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4692. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4693. return ServerCheckResult;
  4694. }
  4695. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4696. try {
  4697. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4698. if (doorStatus != null) {
  4699. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4700. DLStatus = "unknown";
  4701. } else {
  4702. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce)
  4703. DLStatus = "close";
  4704. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce)
  4705. DLStatus = "open";
  4706. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation)
  4707. DLStatus = "ing";
  4708. else DLStatus = "unknown";
  4709. }
  4710. }
  4711. } catch (RuntimeException re) {
  4712. LogUtil.errorLogInfo("", TAG, re);
  4713. DLStatus = "unknown";
  4714. } catch (Exception e) {
  4715. //e.printStackTrace();
  4716. LogUtil.errorLogInfo("", TAG, e);
  4717. DLStatus = "unknown";
  4718. }
  4719. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n" +
  4720. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n" +
  4721. " <action>\"status\"</action>\r\n" +
  4722. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n" +
  4723. " <status_info unit_num=\"doorlock1\" unit_status=\"" + DLStatus + "\"/>\r\n </service>\r\n</imap>";
  4724. return retXML;
  4725. } catch (RuntimeException re) {
  4726. LogUtil.errorLogInfo("", TAG, re);
  4727. return null;
  4728. } catch (Exception e) {
  4729. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4730. //e.printStackTrace();
  4731. LogUtil.errorLogInfo("", TAG, e);
  4732. return null;
  4733. }
  4734. }
  4735. /*
  4736. protected String iCMDProcsavelog(Document doc)
  4737. {
  4738. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4739. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4740. NodeList items = doc.getElementsByTagName("guidemap");
  4741. Node item = items.item(0);
  4742. NamedNodeMap attrsParam = item.getAttributes();
  4743. for(int j=0; j< attrsParam.getLength();j++)
  4744. {
  4745. Node attr = attrsParam.item(j);
  4746. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4747. {
  4748. String enable = attr.getNodeValue();
  4749. if (enable == null) return FailretStr;
  4750. if (enable.equals("false"))
  4751. {
  4752. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4753. logSet.SetLogDoing(0);
  4754. logSet.closeDB();
  4755. return SucretStr;
  4756. }
  4757. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4758. logSet.SetLogDoing(1);
  4759. logSet.closeDB();
  4760. }
  4761. }
  4762. items = doc.getElementsByTagName("setting");
  4763. item = items.item(0);
  4764. attrsParam = item.getAttributes();
  4765. String SaveType = "";
  4766. String FtpLoc = "";
  4767. String Ftpuser = "";
  4768. String FtpPW= "";
  4769. String period = "";
  4770. String FileSize = "";
  4771. for(int j=0; j< attrsParam.getLength();j++)
  4772. {
  4773. Node attr = attrsParam.item(j);
  4774. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4775. SaveType = attr.getNodeValue();
  4776. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4777. FtpLoc = attr.getNodeValue();
  4778. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4779. Ftpuser = attr.getNodeValue();
  4780. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4781. FtpPW = attr.getNodeValue();
  4782. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4783. period = attr.getNodeValue();
  4784. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4785. FileSize = attr.getNodeValue();
  4786. }
  4787. if (SaveType.equalsIgnoreCase("now"))
  4788. {
  4789. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4790. LogUpThread.start();
  4791. return SucretStr;
  4792. }
  4793. else if (SaveType.equalsIgnoreCase("periodic"))
  4794. {
  4795. try
  4796. {
  4797. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4798. period = period.trim();
  4799. String[] logperiod = period.split("[-]");
  4800. String StartDate = logperiod[0].replace(".", "_");
  4801. String EndDate = logperiod[1].replace(".", "_");
  4802. logSet.SetLogDoing(1);
  4803. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4804. if (FileSize.equalsIgnoreCase("null"))
  4805. logSet.SetLogLogFileSize(0);
  4806. else
  4807. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4808. logSet.SetLogStartDate(StartDate);
  4809. logSet.SetLogEndDate(EndDate);
  4810. logSet.closeDB();
  4811. return SucretStr;
  4812. }
  4813. catch (RuntimeException re) {
  4814. LogUtil.errorLogInfo("", TAG, re);
  4815. }
  4816. catch (Exception e)
  4817. {
  4818. e.printStackTrace();
  4819. return FailretStr;
  4820. }
  4821. }
  4822. else
  4823. {
  4824. return FailretStr;
  4825. }
  4826. }
  4827. */
  4828. protected void SendLogSaved(String ftploc, String fname, String size) {
  4829. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n" +
  4830. " <device_info devtype=\"homedev\" id_high=\"" + AddrDong + "\" id_low=\"" + AddrHo + "\"/>\r\n" +
  4831. " <file_info path=\"" + ftploc + "\" name=\"" + fname + "\" size=\"" + size + "\"/>\r\n</service>\r\n</imap>";
  4832. SendToServer(SendMsg);
  4833. }
  4834. public final static int FTPLOGTRSUCC = 1110;
  4835. public final static int FTPLOGTRFAIL = 1120;
  4836. Handler FileTrHandler = new Handler() {
  4837. public void handleMessage(Message msg) {
  4838. switch (msg.what) {
  4839. case FTPLOGTRSUCC:
  4840. String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4841. File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
  4842. int size = (int) (fileinfo.length() / 1024);
  4843. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4844. imapsvrlog("FTPLOGTRSUCC");
  4845. break;
  4846. case FTPLOGTRFAIL:
  4847. imapsvrlog("FTPLOGTRFAIL");
  4848. break;
  4849. }
  4850. }
  4851. };
  4852. class LogUploader extends Thread {
  4853. int fileidx = 0;
  4854. boolean TRing = false;
  4855. String FtpLoc;
  4856. String FtpID;
  4857. String FtpPasswd;
  4858. class ftpuploader extends WallPadFTPUploader {
  4859. String filename;
  4860. public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
  4861. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
  4862. filename = LocalFile;
  4863. }
  4864. protected void ProcUploadFail() {
  4865. Message TrResult = FileTrHandler.obtainMessage();
  4866. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4867. TrResult.what = FTPLOGTRFAIL;
  4868. TRing = false;
  4869. imapsvrlog("Send Log Fail Message");
  4870. FileTrHandler.sendMessage(TrResult);
  4871. }
  4872. protected void ProcUploadSuccess() {
  4873. Message TrResult = FileTrHandler.obtainMessage();
  4874. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4875. TrResult.what = FTPLOGTRSUCC;
  4876. TRing = false;
  4877. imapsvrlog("Send Log success Message");
  4878. FileTrHandler.sendMessage(TrResult);
  4879. }
  4880. }
  4881. public LogUploader(String loc, String user, String pw) {
  4882. FtpLoc = loc;
  4883. FtpID = user;
  4884. FtpPasswd = pw;
  4885. }
  4886. public void run() {
  4887. File LogLoc = new File(define.LOG_FILE_LOCATION);
  4888. String[] LogFileList = LogLoc.list();
  4889. while (true) {
  4890. if (TRing == false) {
  4891. if (LogFileList != null && fileidx < LogFileList.length) {
  4892. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
  4893. fileidx++;
  4894. TRing = true;
  4895. uploader.start();
  4896. } else
  4897. return;
  4898. }
  4899. try {
  4900. Thread.sleep(500);
  4901. } catch (RuntimeException re) {
  4902. LogUtil.errorLogInfo("", TAG, re);
  4903. } catch (Exception e) {
  4904. LogUtil.errorLogInfo("", TAG, e);
  4905. }
  4906. }
  4907. }
  4908. }
  4909. public String iCMDProcDevList(Document ele) {
  4910. try {
  4911. String strResult = CheckiCMDProc("remote_get_home_devices");
  4912. if (strResult != null) return strResult;
  4913. else
  4914. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" result=";
  4915. String target = "null", tid = "null", msgno = "null";
  4916. NodeList items = ele.getElementsByTagName("target");
  4917. Node item = items.item(0);
  4918. if (item != null) {
  4919. NamedNodeMap attrs = item.getAttributes();
  4920. for (int j = 0; j < attrs.getLength(); j++) {
  4921. Node attr = attrs.item(j);
  4922. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4923. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4924. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4925. msgno = attr.getNodeValue();
  4926. }
  4927. }
  4928. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4929. if (NewServerUse()) {
  4930. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  4931. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4932. return ServerCheckResult;
  4933. }
  4934. GasAPI mGasAPI = null;
  4935. CooktopAPI mCooktopAPI = null;
  4936. if (mWallPadAPI.GetGasKind() == 1) {
  4937. mGasAPI = mWallPadAPI.Get_GasController();
  4938. } else if (mWallPadAPI.GetGasKind() == 2) {
  4939. mCooktopAPI = mWallPadAPI.Get_CookTopController();
  4940. }
  4941. Log.i(TAG, "[iCMDProcDevList] bLightCMDUseAsSmartLight: " + bLightCMDUseAsSmartLight);
  4942. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  4943. String[] devlist = {"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
  4944. strResult += "\"ok\">\r\n";
  4945. strResult += " <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
  4946. strResult += " <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
  4947. //strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  4948. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  4949. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  4950. int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  4951. String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
  4952. mWallpadDeviceSet.closeDB();
  4953. String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
  4954. String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
  4955. String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
  4956. strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
  4957. strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
  4958. strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
  4959. for (int i = 0; i < devlist.length; i++) {
  4960. if (devlist[i].equals("cooktop")) {
  4961. if (mWallPadAPI.GetGasKind() == 1) {
  4962. // 가스밸브
  4963. int Gasinfo = devSet.Get_GAS_Info();
  4964. if (Gasinfo == 1) {
  4965. // 사용함
  4966. if (bGasAsCooktopOutlet) {
  4967. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4968. strResult += " <devinfo name=\"cooktop\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4969. } else {
  4970. strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4971. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4972. }
  4973. } else {
  4974. // 사용안함
  4975. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4976. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4977. }
  4978. } else if (mWallPadAPI.GetGasKind() == 2) {
  4979. // 하이브리드 쿡탑
  4980. if (mCooktopAPI != null) {
  4981. int nGas = 0;
  4982. int nOutlet = 0;
  4983. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  4984. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  4985. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
  4986. nGas++;
  4987. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
  4988. nOutlet++;
  4989. }
  4990. }
  4991. strResult += " <devinfo name=\"gas\" value=\"" + nGas + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4992. strResult += " <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4993. }
  4994. } else {
  4995. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4996. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4997. }
  4998. }
  4999. else if (devlist[i].equals("doorlock")) {
  5000. try {
  5001. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5002. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5003. strResult += " <devinfo name=\"doorlock\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5004. } else {
  5005. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5006. }
  5007. } catch (RuntimeException re) {
  5008. LogUtil.errorLogInfo("", TAG, re);
  5009. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5010. } catch (Exception e) {
  5011. //e.printStackTrace();
  5012. LogUtil.errorLogInfo("", TAG, e);
  5013. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5014. }
  5015. }
  5016. else if (devlist[i].equals("light")) {
  5017. try {
  5018. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5019. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5020. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5021. if (bLightCMDUseAsSmartLight) {
  5022. if (mSdbAPI != null) {
  5023. strResult += " <devinfo name=\"light\" value=\"" + mSdbAPI.data.BadRoom_Em_Count + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5024. } else {
  5025. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5026. }
  5027. } else {
  5028. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5029. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5030. }
  5031. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5032. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5033. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5034. strResult += " <devinfo name=\"light\" value=\"" + energymeter.data.RoomCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5035. } else {
  5036. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5037. }
  5038. } else {
  5039. int[] lightinfo = devSet.Get_Light_info();
  5040. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5041. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5042. } else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5043. strResult += " <devinfo name=\"light\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5044. } else {
  5045. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5046. int ret = multisw.Refresh((byte) 0xFF, false);
  5047. if (ret < 0 || multisw.data.DeviceCnt < 1)
  5048. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5049. else
  5050. strResult += " <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5051. }
  5052. }
  5053. } catch (RuntimeException re) {
  5054. LogUtil.errorLogInfo("", TAG, re);
  5055. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5056. } catch (Exception e) {
  5057. //e.printStackTrace();
  5058. LogUtil.errorLogInfo("", TAG, e);
  5059. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5060. }
  5061. }
  5062. else if (devlist[i].equals("livinglight")) {
  5063. try {
  5064. int[] lightinfo = devSet.Get_Light_info();
  5065. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5066. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5067. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5068. if (bLightCMDUseAsSmartLight) {
  5069. if (mSdb_LivingRoomLightAPI != null) {
  5070. strResult += " <devinfo name=\"livinglight\" value=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5071. } else {
  5072. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5073. }
  5074. } else {
  5075. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5076. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5077. }
  5078. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5079. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5080. } else {
  5081. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5082. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5083. } else {
  5084. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5085. }
  5086. }
  5087. } catch (RuntimeException re) {
  5088. LogUtil.errorLogInfo("", TAG, re);
  5089. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5090. } catch (Exception e) {
  5091. //e.printStackTrace();
  5092. LogUtil.errorLogInfo("", TAG, e);
  5093. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5094. }
  5095. }
  5096. else if (devlist[i].equals("ventil")) {
  5097. try {
  5098. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5099. if (Ventilinfo[0] == 0)
  5100. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5101. else
  5102. strResult += " <devinfo name=\"ventil\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5103. } catch (RuntimeException re) {
  5104. LogUtil.errorLogInfo("", TAG, re);
  5105. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5106. } catch (Exception e) {
  5107. //e.printStackTrace();
  5108. LogUtil.errorLogInfo("", TAG, e);
  5109. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5110. }
  5111. }
  5112. else if (devlist[i].equals("thermostat")) {
  5113. try {
  5114. int Temperinfo = devSet.Get_Temper_Info();
  5115. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5116. HeatingV1API heatingV1API = null;
  5117. HeatingV2API heatingV2API = null;
  5118. byte RoomCount = 0;
  5119. // 종류별 API를 로딩한다.
  5120. if (HeatingKind == 1) {
  5121. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5122. if (heatingV1API != null) {
  5123. RoomCount = heatingV1API.data.Device.RoomCount;
  5124. }
  5125. } else if (HeatingKind == 2) {
  5126. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5127. if (heatingV2API != null) {
  5128. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5129. }
  5130. }
  5131. if (Temperinfo == 0)
  5132. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5133. else
  5134. strResult += " <devinfo name=\"thermostat\" value=\"" + RoomCount + "\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5135. } catch (RuntimeException re) {
  5136. LogUtil.errorLogInfo("", TAG, re);
  5137. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5138. } catch (Exception e) {
  5139. //e.printStackTrace();
  5140. LogUtil.errorLogInfo("", TAG, e);
  5141. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5142. }
  5143. }
  5144. else if (devlist[i].equals("curtain")) {
  5145. try {
  5146. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5147. if (Curtaininfo[0] == 0)
  5148. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5149. else
  5150. strResult += " <devinfo name=\"curtain\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5151. } catch (RuntimeException re) {
  5152. LogUtil.errorLogInfo("", TAG, re);
  5153. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5154. } catch (Exception e) {
  5155. //e.printStackTrace();
  5156. LogUtil.errorLogInfo("", TAG, e);
  5157. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5158. }
  5159. }
  5160. else if (devlist[i].equals("electric")) {
  5161. try {
  5162. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5163. // 청담 콘센트 처리
  5164. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5165. int BadConcentCount = 0;
  5166. if (KnxApi != null) {
  5167. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5168. if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
  5169. BadConcentCount = 1;
  5170. }
  5171. int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  5172. for (int k = 0; k < BadConCount; k++) {
  5173. if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
  5174. BadConcentCount++;
  5175. }
  5176. Log.e(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
  5177. strResult += " <devinfo name=\"electric\" value=\"" + BadConcentCount + "\" floor=\"" + ho + "\"/>\r\n";
  5178. }
  5179. } else {
  5180. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5181. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5182. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5183. int nOutlet = 0;
  5184. if (mSdb_LivingRoomLightAPI != null) {
  5185. if (mSdbAPI != null) {
  5186. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5187. } else {
  5188. nOutlet = 1;
  5189. }
  5190. } else {
  5191. if (mSdbAPI != null) {
  5192. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5193. } else {
  5194. nOutlet = 0;
  5195. }
  5196. }
  5197. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"" + ho + "\"/>\r\n";
  5198. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5199. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5200. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5201. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"" + ho + "\"/>\r\n";
  5202. } else {
  5203. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5204. }
  5205. } else {
  5206. int[] lightinfo = devSet.Get_Light_info();
  5207. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5208. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5209. } else {
  5210. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5211. int ret = multisw.Refresh((byte) 0xFF, false);
  5212. if (ret < 0 || multisw.data.DeviceCnt < 1) {
  5213. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5214. } else {
  5215. int DeviceCount = 0;
  5216. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5217. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5218. DeviceCount++;
  5219. }
  5220. }
  5221. strResult += " <devinfo name=\"electric\" value=\"" + DeviceCount + "\" floor=\"" + ho + "\"/>\r\n";
  5222. }
  5223. }
  5224. }
  5225. }
  5226. } catch (RuntimeException re) {
  5227. LogUtil.errorLogInfo("", TAG, re);
  5228. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5229. } catch (Exception e) {
  5230. //e.printStackTrace();
  5231. LogUtil.errorLogInfo("", TAG, e);
  5232. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5233. }
  5234. }
  5235. else if (devlist[i].equals("smartlight")) {
  5236. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5237. // KNX 조명 처리
  5238. try {
  5239. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5240. if (KnxApi != null) {
  5241. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5242. if (KnxApi.data == null)
  5243. Log.e(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
  5244. if (KnxApi.data.MasterController == null)
  5245. Log.e(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
  5246. if (ret >= 0) {
  5247. int LivingLightCount = 0;
  5248. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  5249. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  5250. } else {
  5251. if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  5252. LivingLightCount = 1;
  5253. }
  5254. int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
  5255. strResult += " <devinfo name=\"smartlight\" value=\"" + AllEMcount + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5256. }
  5257. }
  5258. } catch (Exception ek) {
  5259. strResult += " <devinfo name=\"smartlight\" value=\"" + 0 + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5260. }
  5261. } else {
  5262. if (!bLightCMDUseAsSmartLight) {
  5263. int nSmartLight = 0;
  5264. if (mSdb_LivingRoomLightAPI != null) {
  5265. if (mSdbAPI != null) {
  5266. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5267. } else {
  5268. nSmartLight = 1;
  5269. }
  5270. } else {
  5271. if (mSdbAPI != null) {
  5272. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5273. } else {
  5274. nSmartLight = 0;
  5275. }
  5276. }
  5277. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5278. }
  5279. }
  5280. }
  5281. else if (devlist[i].equals("sysaircon")) {
  5282. // 에어컨 처리
  5283. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5284. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  5285. if (airconAPI != null) {
  5286. int nCount = airconAPI.data.Device.info.InsideAirconCount;
  5287. Log.e(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
  5288. // 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
  5289. strResult += " <devinfo name=\"sysaircon\" value=\"" + nCount + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5290. } else {
  5291. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5292. }
  5293. } else {
  5294. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5295. }
  5296. }
  5297. }
  5298. //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
  5299. strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5300. strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5301. if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
  5302. strResult += remote_get_home_devices1;
  5303. }
  5304. if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
  5305. strResult += remote_get_home_devices2;
  5306. }
  5307. if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
  5308. strResult += remote_get_home_devices3;
  5309. }
  5310. /*
  5311. for (int i = 0; i < devlist.length; i++) {
  5312. if (devlist[i].equals("cooktop")) {
  5313. if (mWallPadAPI.GetGasKind() == 1) {
  5314. // 가스밸브
  5315. int Gasinfo = devSet.Get_GAS_Info();
  5316. if (Gasinfo == 1) {
  5317. // 사용함
  5318. if (bGasAsCooktopOutlet) {
  5319. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5320. strResult +=" <devinfo name=\"cooktop\" value=\"1\" floor=\"2\"/>\r\n";
  5321. }
  5322. else {
  5323. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n";
  5324. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5325. }
  5326. }
  5327. else {
  5328. // 사용안함
  5329. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5330. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5331. }
  5332. }
  5333. else if (mWallPadAPI.GetGasKind() == 2) {
  5334. // 하이브리드 쿡탑
  5335. if (mCooktopAPI != null) {
  5336. int nGas = 0; int nOutlet = 0;
  5337. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5338. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5339. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5340. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5341. }
  5342. }
  5343. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"2\"/>\r\n";
  5344. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5345. }
  5346. }
  5347. else {
  5348. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5349. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5350. }
  5351. }
  5352. else if (devlist[i].equals("doorlock")) {
  5353. try {
  5354. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5355. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5356. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"2\"/>\r\n";
  5357. }
  5358. else {
  5359. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5360. }
  5361. } catch (RuntimeException re) {
  5362. LogUtil.errorLogInfo("", TAG, re);
  5363. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5364. }
  5365. catch (Exception e) {
  5366. //e.printStackTrace();
  5367. LogUtil.errorLogInfo("", TAG, e);
  5368. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5369. }
  5370. }
  5371. else if (devlist[i].equals("light")) {
  5372. try {
  5373. 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. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5376. if (bLightCMDUseAsSmartLight) {
  5377. if (mSdbAPI != null) {
  5378. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"2\"/>\r\n";
  5379. }
  5380. else {
  5381. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5382. }
  5383. }
  5384. else {
  5385. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5386. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5387. }
  5388. }
  5389. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5390. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5391. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5392. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"2\"/>\r\n";
  5393. }
  5394. else {
  5395. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5396. }
  5397. }
  5398. else {
  5399. int[] lightinfo = devSet.Get_Light_info();
  5400. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5401. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5402. }
  5403. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5404. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"2\"/>\r\n";
  5405. }
  5406. else {
  5407. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5408. int ret = multisw.Refresh((byte)0xFF, false);
  5409. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5410. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"2\"/>\r\n";
  5411. }
  5412. }
  5413. } catch (RuntimeException re) {
  5414. LogUtil.errorLogInfo("", TAG, re);
  5415. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5416. }
  5417. catch (Exception e) {
  5418. //e.printStackTrace();
  5419. LogUtil.errorLogInfo("", TAG, e);
  5420. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5421. }
  5422. }
  5423. else if (devlist[i].equals("livinglight")) {
  5424. try {
  5425. int[] lightinfo = devSet.Get_Light_info();
  5426. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5427. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5428. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5429. if (bLightCMDUseAsSmartLight) {
  5430. if (mSdb_LivingRoomLightAPI != null) {
  5431. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"2\"/>\r\n";
  5432. }
  5433. else {
  5434. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5435. }
  5436. }
  5437. else {
  5438. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5439. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5440. }
  5441. }
  5442. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5443. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5444. }
  5445. else {
  5446. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5447. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5448. }
  5449. else {
  5450. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5451. }
  5452. }
  5453. } catch (RuntimeException re) {
  5454. LogUtil.errorLogInfo("", TAG, re);
  5455. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5456. }
  5457. catch (Exception e) {
  5458. //e.printStackTrace();
  5459. LogUtil.errorLogInfo("", TAG, e);
  5460. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5461. }
  5462. }
  5463. else if (devlist[i].equals("ventil")) {
  5464. try {
  5465. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5466. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5467. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n";
  5468. } catch (RuntimeException re) {
  5469. LogUtil.errorLogInfo("", TAG, re);
  5470. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5471. }
  5472. catch (Exception e) {
  5473. //e.printStackTrace();
  5474. LogUtil.errorLogInfo("", TAG, e);
  5475. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5476. }
  5477. }
  5478. else if (devlist[i].equals("thermostat")) {
  5479. try {
  5480. int Temperinfo = devSet.Get_Temper_Info();
  5481. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5482. HeatingV1API heatingV1API = null;
  5483. HeatingV2API heatingV2API = null;
  5484. byte RoomCount = 0;
  5485. // 종류별 API를 로딩한다.
  5486. if (HeatingKind == 1) {
  5487. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5488. if (heatingV1API != null) {
  5489. RoomCount = heatingV1API.data.Device.RoomCount;
  5490. }
  5491. }
  5492. else if (HeatingKind == 2) {
  5493. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5494. if (heatingV2API != null) {
  5495. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5496. }
  5497. }
  5498. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5499. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"2\"/>\r\n";
  5500. } catch (RuntimeException re) {
  5501. LogUtil.errorLogInfo("", TAG, re);
  5502. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5503. }
  5504. catch (Exception e) {
  5505. //e.printStackTrace();
  5506. LogUtil.errorLogInfo("", TAG, e);
  5507. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5508. }
  5509. }
  5510. else if (devlist[i].equals("curtain")) {
  5511. try {
  5512. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5513. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5514. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"2\"/>\r\n";
  5515. } catch (RuntimeException re) {
  5516. LogUtil.errorLogInfo("", TAG, re);
  5517. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5518. }
  5519. catch (Exception e) {
  5520. //e.printStackTrace();
  5521. LogUtil.errorLogInfo("", TAG, e);
  5522. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5523. }
  5524. }
  5525. else if (devlist[i].equals("electric")) {
  5526. try {
  5527. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5528. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5529. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5530. int nOutlet = 0;
  5531. if (mSdb_LivingRoomLightAPI != null) {
  5532. if (mSdbAPI != null) {
  5533. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5534. }
  5535. else {
  5536. nOutlet = 1;
  5537. }
  5538. }
  5539. else {
  5540. if (mSdbAPI != null) {
  5541. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5542. }
  5543. else {
  5544. nOutlet = 0;
  5545. }
  5546. }
  5547. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5548. }
  5549. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5550. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5551. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5552. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"2\"/>\r\n";
  5553. }
  5554. else {
  5555. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5556. }
  5557. }
  5558. else {
  5559. int[] lightinfo = devSet.Get_Light_info();
  5560. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5561. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5562. }
  5563. else {
  5564. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5565. int ret = multisw.Refresh((byte)0xFF, false);
  5566. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5567. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5568. }
  5569. else {
  5570. int DeviceCount = 0;
  5571. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5572. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5573. DeviceCount++;
  5574. }
  5575. }
  5576. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"2\"/>\r\n";
  5577. }
  5578. }
  5579. }
  5580. } catch (RuntimeException re) {
  5581. LogUtil.errorLogInfo("", TAG, re);
  5582. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5583. }
  5584. catch (Exception e) {
  5585. //e.printStackTrace();
  5586. LogUtil.errorLogInfo("", TAG, e);
  5587. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5588. }
  5589. }
  5590. else if (devlist[i].equals("smartlight")) {
  5591. if (!bLightCMDUseAsSmartLight) {
  5592. int nSmartLight = 0;
  5593. if (mSdb_LivingRoomLightAPI != null) {
  5594. if (mSdbAPI != null) {
  5595. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5596. }
  5597. else {
  5598. nSmartLight = 1;
  5599. }
  5600. }
  5601. else {
  5602. if (mSdbAPI != null) {
  5603. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5604. }
  5605. else {
  5606. nSmartLight = 0;
  5607. }
  5608. }
  5609. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"2\"/>\r\n";
  5610. }
  5611. }
  5612. }
  5613. for (int i = 0; i < devlist.length; i++) {
  5614. if (devlist[i].equals("cooktop")) {
  5615. if (mWallPadAPI.GetGasKind() == 1) {
  5616. // 가스밸브
  5617. int Gasinfo = devSet.Get_GAS_Info();
  5618. if (Gasinfo == 1) {
  5619. // 사용함
  5620. if (bGasAsCooktopOutlet) {
  5621. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5622. strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5623. }
  5624. else {
  5625. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n";
  5626. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5627. }
  5628. }
  5629. else {
  5630. // 사용안함
  5631. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5632. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5633. }
  5634. }
  5635. else if (mWallPadAPI.GetGasKind() == 2) {
  5636. // 하이브리드 쿡탑
  5637. if (mCooktopAPI != null) {
  5638. int nGas = 0; int nOutlet = 0;
  5639. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5640. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5641. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5642. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5643. }
  5644. }
  5645. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"3\"/>\r\n";
  5646. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5647. }
  5648. }
  5649. else {
  5650. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5651. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5652. }
  5653. }
  5654. else if (devlist[i].equals("doorlock")) {
  5655. try {
  5656. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5657. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5658. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"3\"/>\r\n";
  5659. }
  5660. else {
  5661. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5662. }
  5663. } catch (RuntimeException re) {
  5664. LogUtil.errorLogInfo("", TAG, re);
  5665. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5666. }
  5667. catch (Exception e) {
  5668. //e.printStackTrace();
  5669. LogUtil.errorLogInfo("", TAG, e);
  5670. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5671. }
  5672. }
  5673. else if (devlist[i].equals("light")) {
  5674. try {
  5675. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5676. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5677. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5678. if (bLightCMDUseAsSmartLight) {
  5679. if (mSdbAPI != null) {
  5680. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"3\"/>\r\n";
  5681. }
  5682. else {
  5683. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5684. }
  5685. }
  5686. else {
  5687. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5688. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5689. }
  5690. }
  5691. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5692. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5693. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5694. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"3\"/>\r\n";
  5695. }
  5696. else {
  5697. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5698. }
  5699. }
  5700. else {
  5701. int[] lightinfo = devSet.Get_Light_info();
  5702. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5703. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5704. }
  5705. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5706. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"3\"/>\r\n";
  5707. }
  5708. else {
  5709. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5710. int ret = multisw.Refresh((byte)0xFF, false);
  5711. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5712. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"3\"/>\r\n";
  5713. }
  5714. }
  5715. } catch (RuntimeException re) {
  5716. LogUtil.errorLogInfo("", TAG, re);
  5717. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5718. }
  5719. catch (Exception e) {
  5720. //e.printStackTrace();
  5721. LogUtil.errorLogInfo("", TAG, e);
  5722. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5723. }
  5724. }
  5725. else if (devlist[i].equals("livinglight")) {
  5726. try {
  5727. int[] lightinfo = devSet.Get_Light_info();
  5728. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5729. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5730. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5731. if (bLightCMDUseAsSmartLight) {
  5732. if (mSdb_LivingRoomLightAPI != null) {
  5733. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"3\"/>\r\n";
  5734. }
  5735. else {
  5736. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5737. }
  5738. }
  5739. else {
  5740. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5741. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5742. }
  5743. }
  5744. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5745. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5746. }
  5747. else {
  5748. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5749. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5750. }
  5751. else {
  5752. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5753. }
  5754. }
  5755. } catch (RuntimeException re) {
  5756. LogUtil.errorLogInfo("", TAG, re);
  5757. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5758. }
  5759. catch (Exception e) {
  5760. //e.printStackTrace();
  5761. LogUtil.errorLogInfo("", TAG, e);
  5762. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5763. }
  5764. }
  5765. else if (devlist[i].equals("ventil")) {
  5766. try {
  5767. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5768. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5769. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n";
  5770. } catch (RuntimeException re) {
  5771. LogUtil.errorLogInfo("", TAG, re);
  5772. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5773. }
  5774. catch (Exception e) {
  5775. //e.printStackTrace();
  5776. LogUtil.errorLogInfo("", TAG, e);
  5777. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5778. }
  5779. }
  5780. else if (devlist[i].equals("thermostat")) {
  5781. try {
  5782. int Temperinfo = devSet.Get_Temper_Info();
  5783. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5784. HeatingV1API heatingV1API = null;
  5785. HeatingV2API heatingV2API = null;
  5786. byte RoomCount = 0;
  5787. // 종류별 API를 로딩한다.
  5788. if (HeatingKind == 1) {
  5789. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5790. if (heatingV1API != null) {
  5791. RoomCount = heatingV1API.data.Device.RoomCount;
  5792. }
  5793. }
  5794. else if (HeatingKind == 2) {
  5795. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5796. if (heatingV2API != null) {
  5797. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5798. }
  5799. }
  5800. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5801. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"3\"/>\r\n";
  5802. } catch (RuntimeException re) {
  5803. LogUtil.errorLogInfo("", TAG, re);
  5804. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5805. }
  5806. catch (Exception e) {
  5807. //e.printStackTrace();
  5808. LogUtil.errorLogInfo("", TAG, e);
  5809. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5810. }
  5811. }
  5812. else if (devlist[i].equals("curtain")) {
  5813. try {
  5814. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5815. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5816. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"3\"/>\r\n";
  5817. } catch (RuntimeException re) {
  5818. LogUtil.errorLogInfo("", TAG, re);
  5819. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5820. }
  5821. catch (Exception e) {
  5822. //e.printStackTrace();
  5823. LogUtil.errorLogInfo("", TAG, e);
  5824. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5825. }
  5826. }
  5827. else if (devlist[i].equals("electric")) {
  5828. try {
  5829. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5830. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5831. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5832. int nOutlet = 0;
  5833. if (mSdb_LivingRoomLightAPI != null) {
  5834. if (mSdbAPI != null) {
  5835. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5836. }
  5837. else {
  5838. nOutlet = 1;
  5839. }
  5840. }
  5841. else {
  5842. if (mSdbAPI != null) {
  5843. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5844. }
  5845. else {
  5846. nOutlet = 0;
  5847. }
  5848. }
  5849. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5850. }
  5851. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5852. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5853. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5854. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"3\"/>\r\n";
  5855. }
  5856. else {
  5857. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5858. }
  5859. }
  5860. else {
  5861. int[] lightinfo = devSet.Get_Light_info();
  5862. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5863. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5864. }
  5865. else {
  5866. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5867. int ret = multisw.Refresh((byte)0xFF, false);
  5868. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5869. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5870. }
  5871. else {
  5872. int DeviceCount = 0;
  5873. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5874. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5875. DeviceCount++;
  5876. }
  5877. }
  5878. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"3\"/>\r\n";
  5879. }
  5880. }
  5881. }
  5882. } catch (RuntimeException re) {
  5883. LogUtil.errorLogInfo("", TAG, re);
  5884. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5885. }
  5886. catch (Exception e) {
  5887. //e.printStackTrace();
  5888. LogUtil.errorLogInfo("", TAG, e);
  5889. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5890. }
  5891. }
  5892. else if (devlist[i].equals("smartlight")) {
  5893. if (!bLightCMDUseAsSmartLight) {
  5894. int nSmartLight = 0;
  5895. if (mSdb_LivingRoomLightAPI != null) {
  5896. if (mSdbAPI != null) {
  5897. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5898. }
  5899. else {
  5900. nSmartLight = 1;
  5901. }
  5902. }
  5903. else {
  5904. if (mSdbAPI != null) {
  5905. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5906. }
  5907. else {
  5908. nSmartLight = 0;
  5909. }
  5910. }
  5911. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"3\"/>\r\n";
  5912. }
  5913. }
  5914. }
  5915. */
  5916. strResult += " </service>\r\n</imap>\r\n";
  5917. devSet.closeDB();
  5918. return strResult;
  5919. } catch (RuntimeException re) {
  5920. LogUtil.errorLogInfo("", TAG, re);
  5921. return null;
  5922. } catch (Exception e) {
  5923. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  5924. //e.printStackTrace();
  5925. LogUtil.errorLogInfo("", TAG, e);
  5926. return null;
  5927. }
  5928. }
  5929. public String iCMDProcMultiSWControl(Document ele) {
  5930. try {
  5931. String retStr = CheckiCMDProc(MULTISW_CTR);
  5932. if (retStr != null) return retStr;
  5933. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\"";
  5934. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  5935. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5936. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  5937. int devNum = Integer.parseInt(multiswcmd.devnum);
  5938. if (multisw != null) {
  5939. int ret = multisw.Refresh((byte) 0xFF, false);
  5940. String result;
  5941. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  5942. else result = "fail";
  5943. retStr += (" result=\"" + result + "\" >\r\n");
  5944. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5945. retStr += MakeTargetStr(multiswcmd);
  5946. retStr += " <action>\"status\"</action>\r\n";
  5947. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5948. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5949. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  5950. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[devNum - 1] + "\"/>\r\n";
  5951. } else {
  5952. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  5953. }
  5954. } else {
  5955. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5956. }
  5957. String unitStr;
  5958. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5959. Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
  5960. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5961. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5962. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5963. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  5964. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  5965. }
  5966. }
  5967. retStr += " </service>\r\n</imap>\r\n";
  5968. }
  5969. } else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  5970. int devNum = Integer.parseInt(multiswcmd.devnum);
  5971. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  5972. {
  5973. if (multisw != null) {
  5974. multisw.Refresh((byte) 0xFF, false);
  5975. String result;
  5976. int ret = -1;
  5977. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  5978. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
  5979. } else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  5980. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
  5981. } else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
  5982. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
  5983. } else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
  5984. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
  5985. }
  5986. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  5987. else result = "fail";
  5988. if (ret == APIErrorCode.C_SUCCESS) {
  5989. ret = multisw.Refresh((byte) 0xFF, false);
  5990. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5991. retStr += (" result=\"" + result + "\" > \r\n");
  5992. retStr += MakeTargetStr(multiswcmd);
  5993. retStr += " <action>\"control\"</action>\r\n";
  5994. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5995. String unitStr;
  5996. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5997. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5998. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5999. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  6000. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
  6001. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  6002. }
  6003. } else {
  6004. retStr += (" result=\"fail\"> \r\n");
  6005. }
  6006. } else {
  6007. retStr += (" result=\"fail\"> \r\n");
  6008. }
  6009. retStr += " </service>\r\n</imap>\r\n";
  6010. }
  6011. }
  6012. }
  6013. return retStr;
  6014. } catch (RuntimeException re) {
  6015. LogUtil.errorLogInfo("", TAG, re);
  6016. return null;
  6017. } catch (Exception e) {
  6018. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  6019. //e.printStackTrace();
  6020. LogUtil.errorLogInfo("", TAG, e);
  6021. return null;
  6022. }
  6023. }
  6024. public String iCMDProcSDPConcentControl(Document ele) {
  6025. try {
  6026. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  6027. String retStr = CheckiCMDProc("remote_access_electric");
  6028. if (retStr != null) return retStr;
  6029. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  6030. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6031. if (NewServerUse()) {
  6032. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  6033. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6034. return ServerCheckResult;
  6035. }
  6036. if (mSdbAPI == null) {
  6037. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6038. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  6039. return retStr;
  6040. }
  6041. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6042. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6043. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6044. return retStr;
  6045. }
  6046. int nTotalLightCnt = 0;
  6047. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  6048. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6049. } else {
  6050. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  6051. }
  6052. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  6053. int nDevNo = 0;
  6054. try {
  6055. nDevNo = Integer.parseInt(concentcmd.devnum);
  6056. } catch (RuntimeException re) {
  6057. LogUtil.errorLogInfo("", TAG, re);
  6058. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6059. return retStr;
  6060. } catch (Exception e) {
  6061. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  6062. //e.printStackTrace();
  6063. LogUtil.errorLogInfo("", TAG, e);
  6064. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6065. return retStr;
  6066. }
  6067. if (nDevNo < 1 && 12 < nDevNo) {
  6068. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6069. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  6070. return retStr;
  6071. }
  6072. String strAction = trimquotation(concentcmd.actionTXT);
  6073. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  6074. String dev_num = "null", unit_num = "null", ctrl_action = "null";
  6075. int nRet_Mode = -99, nRet_OnOff = -99;
  6076. boolean Set = false, OnOff = false; // 제어요청 상태
  6077. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  6078. if (strAction.equalsIgnoreCase("status")) {
  6079. retStr += " result=\"ok\">\r\n";
  6080. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6081. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6082. if (nDevNo == 1) {
  6083. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6084. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  6085. } else {
  6086. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6087. }
  6088. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6089. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6090. status_mode = "unset";
  6091. else status_mode = "set";
  6092. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6093. status_onoff = "on";
  6094. else status_onoff = "off";
  6095. unit_status = status_mode + "/" + status_onoff;
  6096. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6097. }
  6098. // retStr += " </status_map>\r\n";
  6099. retStr += " </service>\r\n</imap>\r\n";
  6100. } else if (nDevNo > 1) {
  6101. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6102. 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";
  6103. } else {
  6104. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6105. }
  6106. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6107. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6108. status_mode = "unset";
  6109. else status_mode = "set";
  6110. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6111. status_onoff = "on";
  6112. else status_onoff = "off";
  6113. unit_status = status_mode + "/" + status_onoff;
  6114. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6115. }
  6116. // retStr += " </status_map>\r\n";
  6117. retStr += " </service>\r\n</imap>\r\n";
  6118. }
  6119. } else if (strAction.equalsIgnoreCase("control")) {
  6120. NodeList items = ele.getElementsByTagName("params");
  6121. Node item = items.item(0);
  6122. if (item != null) {
  6123. NamedNodeMap attrs = item.getAttributes();
  6124. for (int i = 0; i < attrs.getLength(); i++) {
  6125. Node attr = attrs.item(i);
  6126. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  6127. dev_num = attr.getNodeValue();
  6128. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  6129. unit_num = attr.getNodeValue();
  6130. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6131. ctrl_action = attr.getNodeValue();
  6132. }
  6133. } else {
  6134. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  6135. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6136. return retStr;
  6137. }
  6138. try {
  6139. nDevNo = Integer.parseInt(dev_num);
  6140. } catch (RuntimeException re) {
  6141. LogUtil.errorLogInfo("", TAG, re);
  6142. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6143. return retStr;
  6144. } catch (Exception e) {
  6145. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  6146. //e.printStackTrace();
  6147. LogUtil.errorLogInfo("", TAG, e);
  6148. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6149. return retStr;
  6150. }
  6151. if (nDevNo < 1 && 12 < nDevNo) {
  6152. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6153. return retStr;
  6154. }
  6155. int nUnitNo = 0;
  6156. if (!unit_num.equalsIgnoreCase("all")) {
  6157. try {
  6158. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  6159. } catch (RuntimeException re) {
  6160. LogUtil.errorLogInfo("", TAG, re);
  6161. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6162. return retStr;
  6163. } catch (Exception e) {
  6164. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  6165. //e.printStackTrace();
  6166. LogUtil.errorLogInfo("", TAG, e);
  6167. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6168. return retStr;
  6169. }
  6170. }
  6171. if (ctrl_action.contains("/")) {
  6172. String[] strParsed = ctrl_action.split("/");
  6173. if (strParsed[0].equals("set")) {
  6174. Set = true;
  6175. bCtrl_Set = true;
  6176. } else if (strParsed[0].equals("unset")) {
  6177. Set = false;
  6178. bCtrl_Set = true;
  6179. }
  6180. if (strParsed[1].equals("on")) {
  6181. OnOff = true;
  6182. bCtrl_OnOff = true;
  6183. } else if (strParsed[1].equals("off")) {
  6184. OnOff = false;
  6185. bCtrl_OnOff = true;
  6186. }
  6187. } else {
  6188. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  6189. if (ctrl_action.equalsIgnoreCase("set")) {
  6190. Set = true;
  6191. bCtrl_Set = true;
  6192. } else if (ctrl_action.equalsIgnoreCase("unset")) {
  6193. Set = false;
  6194. bCtrl_Set = true;
  6195. }
  6196. }
  6197. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  6198. if (ctrl_action.equalsIgnoreCase("on")) {
  6199. OnOff = true;
  6200. bCtrl_OnOff = true;
  6201. } else if (ctrl_action.equalsIgnoreCase("off")) {
  6202. OnOff = false;
  6203. bCtrl_OnOff = true;
  6204. }
  6205. }
  6206. }
  6207. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  6208. if (nDevNo == 1) {
  6209. if (unit_num.equalsIgnoreCase("all")) {
  6210. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6211. if (bCtrl_Set)
  6212. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  6213. if (bCtrl_OnOff)
  6214. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  6215. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6216. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6217. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6218. return retStr;
  6219. }
  6220. }
  6221. } else {
  6222. if (bCtrl_Set)
  6223. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  6224. if (bCtrl_OnOff)
  6225. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  6226. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6227. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6228. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6229. return retStr;
  6230. }
  6231. }
  6232. } else {
  6233. if (unit_num.equalsIgnoreCase("all")) {
  6234. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6235. if (bCtrl_Set)
  6236. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  6237. if (bCtrl_OnOff)
  6238. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  6239. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6240. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6241. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6242. return retStr;
  6243. }
  6244. }
  6245. } else {
  6246. if (bCtrl_Set)
  6247. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  6248. if (bCtrl_OnOff)
  6249. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  6250. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6251. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6252. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6253. return retStr;
  6254. }
  6255. }
  6256. }
  6257. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6258. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6259. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6260. return retStr;
  6261. }
  6262. retStr += " result=\"ok\">\r\n";
  6263. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6264. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6265. if (nDevNo == 1) {
  6266. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6267. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6268. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6269. status_mode = "unset";
  6270. else status_mode = "set";
  6271. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6272. status_onoff = "on";
  6273. else status_onoff = "off";
  6274. unit_status = status_mode + "/" + status_onoff;
  6275. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6276. }
  6277. // retStr += " </status_map>\r\n";
  6278. retStr += " </service>\r\n</imap>\r\n";
  6279. } else if (nDevNo > 1) {
  6280. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6281. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6282. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6283. status_mode = "unset";
  6284. else status_mode = "set";
  6285. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6286. status_onoff = "on";
  6287. else status_onoff = "off";
  6288. unit_status = status_mode + "/" + status_onoff;
  6289. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6290. }
  6291. // retStr += " </status_map>\r\n";
  6292. retStr += " </service>\r\n</imap>\r\n";
  6293. }
  6294. } else {
  6295. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  6296. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6297. }
  6298. return retStr;
  6299. } catch (RuntimeException re) {
  6300. LogUtil.errorLogInfo("", TAG, re);
  6301. return null;
  6302. } catch (Exception e) {
  6303. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  6304. //e.printStackTrace();
  6305. LogUtil.errorLogInfo("", TAG, e);
  6306. return null;
  6307. }
  6308. }
  6309. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  6310. try {
  6311. String retStr = CheckiCMDProc(MULTISW_CTR);
  6312. if (retStr != null) return retStr;
  6313. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\" ";
  6314. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6315. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6316. if (energymetercmd == null) return null;
  6317. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6318. if (energymeter == null) return null;
  6319. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6320. int ret = energymeter.Refresh((byte) 0xFF, false);
  6321. String result;
  6322. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  6323. else result = "fail";
  6324. retStr += (" result=\"" + result + "\" >\r\n");
  6325. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6326. retStr += MakeTargetStr(energymetercmd);
  6327. retStr += " <action>\"status\"</action>\r\n";
  6328. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6329. String unitStr;
  6330. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6331. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6332. if (i == 2) {
  6333. unitStr += "on";
  6334. } else {
  6335. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6336. }
  6337. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6338. }
  6339. }
  6340. retStr += " </service>\r\n</imap>\r\n";
  6341. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6342. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6343. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
  6344. byte cmd = 0;
  6345. int ret = 0;
  6346. String result;
  6347. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  6348. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  6349. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  6350. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  6351. if (cmd > 0) {
  6352. if (energymeter != null) {
  6353. energymeter.Refresh((byte) 0xFF, false);
  6354. if (cmd == 1) {
  6355. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  6356. } else if (cmd == 2) {
  6357. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  6358. } else if (cmd == 3) {
  6359. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
  6360. } else if (cmd == 4) {
  6361. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
  6362. }
  6363. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6364. else result = "fail";
  6365. retStr += (" result=\"" + result + "\" >\r\n");
  6366. if (ret == APIErrorCode.C_SUCCESS) {
  6367. ret = energymeter.Refresh((byte) 0xFF, false);
  6368. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6369. retStr += MakeTargetStr(energymetercmd);
  6370. retStr += " <action>\"control\"</action>\r\n";
  6371. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6372. String unitStr;
  6373. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6374. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6375. if (i == 2) {
  6376. unitStr += "on";
  6377. } else {
  6378. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6379. }
  6380. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6381. }
  6382. } else {
  6383. retStr += (" result=\"fail\"> \r\n");
  6384. }
  6385. } else {
  6386. retStr += (" result=\"fail\"> \r\n");
  6387. }
  6388. retStr += " </service>\r\n</imap>\r\n";
  6389. }
  6390. }
  6391. }
  6392. return retStr;
  6393. } catch (RuntimeException re) {
  6394. LogUtil.errorLogInfo("", TAG, re);
  6395. return null;
  6396. } catch (Exception e) {
  6397. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  6398. //e.printStackTrace();
  6399. LogUtil.errorLogInfo("", TAG, e);
  6400. return null;
  6401. }
  6402. }
  6403. public String iCMDProcModeControl(Document doc) {
  6404. try {
  6405. String status = "unknown";
  6406. boolean SendBR = false;
  6407. String retStr = CheckiCMDProc("remote_access_mode");
  6408. if (retStr != null) return retStr;
  6409. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  6410. String target = "null", tid = "null", msgno = "null";
  6411. NodeList items = doc.getElementsByTagName("target");
  6412. Node item = items.item(0);
  6413. if (item != null) {
  6414. NamedNodeMap attrs = item.getAttributes();
  6415. for (int j = 0; j < attrs.getLength(); j++) {
  6416. Node attr = attrs.item(j);
  6417. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6418. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6419. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6420. msgno = attr.getNodeValue();
  6421. }
  6422. }
  6423. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6424. if (NewServerUse()) {
  6425. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  6426. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6427. return ServerCheckResult;
  6428. }
  6429. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  6430. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  6431. int curState = SetData.GetAlarmStatus();
  6432. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  6433. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  6434. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  6435. switch (curState) {
  6436. case WallpadStatusData.GUARD_IN:
  6437. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  6438. Intent intent = new Intent();
  6439. intent.setAction(define.NOTIFY_ACNAME);
  6440. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6441. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  6442. getApplicationContext().sendBroadcast(intent);
  6443. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  6444. SendBR = true;
  6445. break;
  6446. case WallpadStatusData.GUARD_OUT:
  6447. break;
  6448. }
  6449. } else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  6450. switch (curState) {
  6451. case WallpadStatusData.ALARM_NONE:
  6452. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6453. if (mIGW200.checkSensorforInmode()) {
  6454. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6455. Intent intent = new Intent();
  6456. intent.setAction(define.NOTIFY_ACNAME);
  6457. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6458. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6459. getApplicationContext().sendBroadcast(intent);
  6460. SendBR = true;
  6461. } else {
  6462. SendBR = false;
  6463. }
  6464. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  6465. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6466. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6467. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6468. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6469. if (mIGW300.checkSensorforInmode()) {
  6470. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6471. Intent intent = new Intent();
  6472. intent.setAction(define.NOTIFY_ACNAME);
  6473. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6474. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6475. getApplicationContext().sendBroadcast(intent);
  6476. SendBR = true;
  6477. } else {
  6478. SendBR = false;
  6479. }
  6480. } else {
  6481. if (checkSensorforInmode()) {
  6482. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6483. Intent intent = new Intent();
  6484. intent.setAction(define.NOTIFY_ACNAME);
  6485. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6486. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6487. getApplicationContext().sendBroadcast(intent);
  6488. Sound().PlayMent(SND.mode.INMODE_SETTING);
  6489. SendBR = true;
  6490. } else {
  6491. SendBR = false;
  6492. }
  6493. }
  6494. break;
  6495. default:
  6496. break;
  6497. }
  6498. } else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  6499. if (GetUseIlgalControlForAdmin() == false) {
  6500. // 관리자용 일괄소등 원격제어 사용안할 시
  6501. switch (curState) {
  6502. case WallpadStatusData.ALARM_NONE:
  6503. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6504. if (mIGW200.checkSensorforOutmode()) {
  6505. Common.SendAppFinishReqBR(getApplicationContext());
  6506. Intent intent = new Intent();
  6507. intent.setAction(define.NOTIFY_ACNAME);
  6508. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6509. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6510. getApplicationContext().sendBroadcast(intent);
  6511. SendBR = true;
  6512. } else {
  6513. SendBR = false;
  6514. }
  6515. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  6516. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6517. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6518. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6519. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6520. if (mIGW300.checkSensorforOutmode()) {
  6521. Common.SendAppFinishReqBR(getApplicationContext());
  6522. Intent intent = new Intent();
  6523. intent.setAction(define.NOTIFY_ACNAME);
  6524. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6525. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6526. getApplicationContext().sendBroadcast(intent);
  6527. SendBR = true;
  6528. } else {
  6529. SendBR = false;
  6530. }
  6531. } else {
  6532. if (checkSensorforOutmode()) {
  6533. Common.SendAppFinishReqBR(getApplicationContext());
  6534. Intent intent = new Intent();
  6535. intent.setAction(define.NOTIFY_ACNAME);
  6536. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6537. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6538. getApplicationContext().sendBroadcast(intent);
  6539. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  6540. SendBR = true;
  6541. } else {
  6542. SendBR = false;
  6543. }
  6544. }
  6545. break;
  6546. default:
  6547. break;
  6548. }
  6549. } else {
  6550. // 관리자용 일괄소등 원격제어 사용 시
  6551. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6552. SendBR = true;
  6553. }
  6554. }
  6555. } else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  6556. int getStatus = SetData.GetAlarmStatus();
  6557. switch (getStatus) {
  6558. case WallpadStatusData.GUARD_IN:
  6559. status = "occupied";
  6560. break;
  6561. case WallpadStatusData.GUARD_OUT:
  6562. status = "unoccupied";
  6563. break;
  6564. case WallpadStatusData.ALARM_NONE:
  6565. status = "normal";
  6566. break;
  6567. case WallpadStatusData.ALARM_ARISE:
  6568. status = "emergency";
  6569. break;
  6570. default:
  6571. break;
  6572. }
  6573. retStr += ("\"ok\">\r\n ");
  6574. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6575. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6576. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6577. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6578. return retStr;
  6579. }
  6580. if (!SendBR) {
  6581. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6582. SetData.closeDB();
  6583. return retStr;
  6584. } else {
  6585. try {
  6586. Thread.sleep(1000);
  6587. } catch (RuntimeException re) {
  6588. LogUtil.errorLogInfo("", TAG, re);
  6589. } catch (Exception e) {
  6590. LogUtil.errorLogInfo("", TAG, e);
  6591. }
  6592. int getStatus = SetData.GetAlarmStatus();
  6593. switch (getStatus) {
  6594. case WallpadStatusData.GUARD_IN:
  6595. status = "occupied";
  6596. break;
  6597. case WallpadStatusData.GUARD_OUT:
  6598. status = "unoccupied";
  6599. break;
  6600. case WallpadStatusData.ALARM_NONE:
  6601. status = "normal";
  6602. break;
  6603. case WallpadStatusData.ALARM_ARISE:
  6604. status = "emergency";
  6605. break;
  6606. }
  6607. }
  6608. retStr += "\"ok\">\r\n";
  6609. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6610. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6611. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6612. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6613. SetData.closeDB();
  6614. return retStr;
  6615. } catch (RuntimeException re) {
  6616. LogUtil.errorLogInfo("", TAG, re);
  6617. return null;
  6618. } catch (Exception e) {
  6619. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6620. //e.printStackTrace();
  6621. LogUtil.errorLogInfo("", TAG, e);
  6622. return null;
  6623. }
  6624. }
  6625. public String iCMDProcCurtainControl(Document ele) {
  6626. return " ";
  6627. }
  6628. public String iCMDProcSDPLightControl(Document ele) {
  6629. try {
  6630. String retStr = CheckiCMDProc("remote_access_light");
  6631. if (retStr != null) return retStr;
  6632. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6633. String target = "null", tid = "null", msgno = "null";
  6634. NodeList items = ele.getElementsByTagName("target");
  6635. Node item = items.item(0);
  6636. if (item != null) {
  6637. NamedNodeMap attrs = item.getAttributes();
  6638. for (int j = 0; j < attrs.getLength(); j++) {
  6639. Node attr = attrs.item(j);
  6640. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6641. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6642. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6643. msgno = attr.getNodeValue();
  6644. }
  6645. }
  6646. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6647. if (NewServerUse()) {
  6648. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6649. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6650. return ServerCheckResult;
  6651. }
  6652. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6653. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6654. if (energymetercmd == null) return null;
  6655. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6656. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6657. if (energymeter == null) return null;
  6658. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6659. retStr += "result=\"ok\">\r\n" +
  6660. " <action>\"status\"</action>\r\n" +
  6661. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6662. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6663. 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");
  6664. }
  6665. retStr += "\r\n</service>\r\n</imap>";
  6666. } else {
  6667. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6668. }
  6669. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6670. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6671. num--;
  6672. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6673. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6674. if (energymeter == null) return null;
  6675. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6676. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6677. retStr += "result=\"ok\">\r\n" +
  6678. " <action>\"control\"</action>\r\n" +
  6679. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6680. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6681. 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");
  6682. }
  6683. retStr += "\r\n</service>\r\n</imap>";
  6684. } else {
  6685. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6686. }
  6687. } else {
  6688. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6689. }
  6690. } else {
  6691. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6692. }
  6693. energymetercmd = null;
  6694. return retStr;
  6695. } catch (RuntimeException re) {
  6696. LogUtil.errorLogInfo("", TAG, re);
  6697. return null;
  6698. } catch (Exception e) {
  6699. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6700. //e.printStackTrace();
  6701. LogUtil.errorLogInfo("", TAG, e);
  6702. return null;
  6703. }
  6704. }
  6705. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6706. try {
  6707. String retStr = CheckiCMDProc("remote_access_light");
  6708. if (retStr != null) return retStr;
  6709. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6710. String target = "null", tid = "null", msgno = "null";
  6711. NodeList items = ele.getElementsByTagName("target");
  6712. Node item = items.item(0);
  6713. if (item != null) {
  6714. NamedNodeMap attrs = item.getAttributes();
  6715. for (int j = 0; j < attrs.getLength(); j++) {
  6716. Node attr = attrs.item(j);
  6717. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6718. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6719. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6720. msgno = attr.getNodeValue();
  6721. }
  6722. }
  6723. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6724. if (NewServerUse()) {
  6725. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6726. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6727. return ServerCheckResult;
  6728. }
  6729. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6730. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6731. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6732. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6733. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6734. retStr += "result=\"ok\">\r\n" +
  6735. " <action>\"status\"</action>\r\n" +
  6736. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6737. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6738. 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");
  6739. }
  6740. retStr += "\r\n</service>\r\n</imap>";
  6741. } else {
  6742. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6743. }
  6744. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6745. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6746. num--;
  6747. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6748. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6749. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6750. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6751. retStr += "result=\"ok\">\r\n" +
  6752. " <action>\"control\"</action>\r\n" +
  6753. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6754. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6755. 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");
  6756. }
  6757. retStr += "\r\n</service>\r\n</imap>";
  6758. } else {
  6759. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6760. }
  6761. } else {
  6762. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6763. }
  6764. } else {
  6765. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6766. }
  6767. energymetercmd = null;
  6768. return retStr;
  6769. } catch (RuntimeException re) {
  6770. LogUtil.errorLogInfo("", TAG, re);
  6771. return null;
  6772. } catch (Exception e) {
  6773. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6774. //e.printStackTrace();
  6775. LogUtil.errorLogInfo("", TAG, e);
  6776. return null;
  6777. }
  6778. }
  6779. public String iCMDProcLightControl(Document ele) {
  6780. try {
  6781. String retStr = CheckiCMDProc("remote_access_light");
  6782. if (retStr != null) return retStr;
  6783. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6784. String target = "null", tid = "null", msgno = "null";
  6785. NodeList items = ele.getElementsByTagName("target");
  6786. Node item = items.item(0);
  6787. if (item != null) {
  6788. NamedNodeMap attrs = item.getAttributes();
  6789. for (int j = 0; j < attrs.getLength(); j++) {
  6790. Node attr = attrs.item(j);
  6791. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6792. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6793. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6794. msgno = attr.getNodeValue();
  6795. }
  6796. }
  6797. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6798. if (NewServerUse()) {
  6799. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6800. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6801. return ServerCheckResult;
  6802. }
  6803. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6804. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6805. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6806. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6807. if (bLightCMDUseAsSmartLight) {
  6808. if (mSdbAPI != null) {
  6809. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6810. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6811. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6812. retStr += "result=\"ok\">\r\n" +
  6813. " <action>\"status\"</action>\r\n";
  6814. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6815. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6816. } else {
  6817. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6818. }
  6819. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6820. 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");
  6821. }
  6822. retStr += " </service>\r\n</imap>";
  6823. } else {
  6824. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6825. }
  6826. } else {
  6827. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6828. }
  6829. } else {
  6830. if (mMultiSwitchAPI != null) {
  6831. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6832. if (nResult == 0) {
  6833. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6834. retStr += "result=\"ok\">\r\n" +
  6835. " <action>\"status\"</action>\r\n";
  6836. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6837. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6838. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6839. } else {
  6840. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6841. }
  6842. } else {
  6843. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6844. }
  6845. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6846. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mMultiSwitchAPI.data.Device[deviceNum].device.getLightPower(i) ? "on" : "off");
  6847. }
  6848. retStr += " </service>\r\n</imap>";
  6849. } else {
  6850. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6851. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6852. }
  6853. } else {
  6854. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6855. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6856. }
  6857. } else {
  6858. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  6859. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6860. }
  6861. }
  6862. } else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  6863. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6864. boolean OnOff = false;
  6865. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6866. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  6867. if (bLightCMDUseAsSmartLight) {
  6868. if (mSdbAPI != null) {
  6869. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6870. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  6871. if (ret >= 0) {
  6872. retStr += "result=\"ok\">\r\n" +
  6873. " <action>\"status\"</action>\r\n" +
  6874. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6875. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6876. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6877. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6878. 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");
  6879. }
  6880. retStr += " </service>\r\n</imap>";
  6881. } else {
  6882. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6883. }
  6884. } else {
  6885. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6886. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  6887. if (ret >= 0) {
  6888. retStr += "result=\"ok\">\r\n" +
  6889. " <action>\"status\"</action>\r\n" +
  6890. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6891. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6892. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6893. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6894. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  6895. 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");
  6896. }
  6897. retStr += " </service>\r\n</imap>";
  6898. } else {
  6899. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6900. }
  6901. }
  6902. } else {
  6903. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6904. }
  6905. } else {
  6906. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6907. if (mMultiSwitchAPI != null) {
  6908. int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6909. if (nResultRefresh == 0) {
  6910. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6911. if (nCtrlResult == 0) {
  6912. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6913. if (nResult == 0) {
  6914. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6915. retStr += "result=\"ok\">\r\n" +
  6916. " <action>\"status\"</action>\r\n" +
  6917. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6918. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  6919. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", j + 1, mMultiSwitchAPI.data.Device[deviceNum].device.getLightPower(j) ? "on" : "off");
  6920. }
  6921. retStr += " </service>\r\n</imap>";
  6922. } else {
  6923. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6924. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6925. }
  6926. } else {
  6927. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6928. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6929. }
  6930. } else {
  6931. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6932. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6933. }
  6934. } else {
  6935. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6936. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6937. }
  6938. }
  6939. } else {
  6940. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6941. if (mMultiSwitchAPI != null) {
  6942. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6943. if (nCtrlResult == 0) {
  6944. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6945. if (nResult == 0) {
  6946. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6947. retStr += "result=\"ok\">\r\n" +
  6948. " <action>\"status\"</action>\r\n" +
  6949. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6950. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6951. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, mMultiSwitchAPI.data.Device[deviceNum].device.getLightPower(i) ? "on" : "off");
  6952. }
  6953. retStr += " </service>\r\n</imap>";
  6954. } else {
  6955. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6956. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6957. }
  6958. } else {
  6959. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6960. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6961. }
  6962. } else {
  6963. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6964. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6965. }
  6966. }
  6967. }
  6968. }
  6969. } else {
  6970. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6971. }
  6972. } else {
  6973. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6974. }
  6975. MSlightcmd = null;
  6976. return retStr;
  6977. } catch (RuntimeException re) {
  6978. LogUtil.errorLogInfo("", TAG, re);
  6979. return null;
  6980. } catch (Exception e) {
  6981. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  6982. //e.printStackTrace();
  6983. LogUtil.errorLogInfo("", TAG, e);
  6984. return null;
  6985. }
  6986. }
  6987. public String iCMDProcSDPSmartLightControl(Document ele) {
  6988. try {
  6989. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6990. String retStr = CheckiCMDProc("remote_access_smartlight");
  6991. if (retStr != null) return retStr;
  6992. else
  6993. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  6994. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6995. if (NewServerUse()) {
  6996. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  6997. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6998. return ServerCheckResult;
  6999. }
  7000. if (mSdb_LivingRoomLightAPI == null) {
  7001. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7002. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  7003. return retStr;
  7004. }
  7005. if (mSdbAPI == null) {
  7006. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7007. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  7008. return retStr;
  7009. }
  7010. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7011. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7012. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7013. return retStr;
  7014. }
  7015. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7016. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
  7017. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7018. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7019. return retStr;
  7020. }
  7021. }
  7022. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  7023. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7024. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7025. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7026. retStr += " result=\"ok\">\r\n";
  7027. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7028. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7029. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7030. for (int i = 0; i < nTotalLightCnt; i++) {
  7031. if (i == 0) {
  7032. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7033. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7034. String status_power = "off", status_dim = "null", status_color = "null";
  7035. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7036. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7037. } else {
  7038. status_power = "null";
  7039. }
  7040. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7041. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7042. } else {
  7043. status_dim = "null";
  7044. }
  7045. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7046. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7047. } else {
  7048. status_color = "null";
  7049. }
  7050. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7051. }
  7052. retStr += " </status_map>\r\n";
  7053. } else {
  7054. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7055. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7056. String status_power = "off", status_dim = "null", status_color = "null";
  7057. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7058. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7059. } else {
  7060. status_power = "null";
  7061. }
  7062. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7063. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7064. } else {
  7065. status_dim = "null";
  7066. }
  7067. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7068. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7069. } else {
  7070. status_color = "null";
  7071. }
  7072. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7073. }
  7074. retStr += " </status_map>\r\n";
  7075. }
  7076. }
  7077. retStr += " </service>\r\n</imap>\r\n";
  7078. } else {
  7079. int nDevNo = 0;
  7080. try {
  7081. nDevNo = Integer.parseInt(lightcmd.devnum);
  7082. } catch (RuntimeException re) {
  7083. LogUtil.errorLogInfo("", TAG, re);
  7084. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7085. return retStr;
  7086. } catch (Exception e) {
  7087. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  7088. //e.printStackTrace();
  7089. LogUtil.errorLogInfo("", TAG, e);
  7090. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7091. return retStr;
  7092. }
  7093. if ((nDevNo - 1) > nTotalLightCnt) {
  7094. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7095. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7096. return retStr;
  7097. }
  7098. retStr += " result=\"ok\">\r\n";
  7099. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7100. retStr += " <action>\"status\"</action>\r\n";
  7101. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7102. if (nDevNo == 1) {
  7103. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7104. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7105. String status_power = "off", status_dim = "null", status_color = "null";
  7106. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7107. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7108. } else {
  7109. status_power = "null";
  7110. }
  7111. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7112. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7113. } else {
  7114. status_dim = "null";
  7115. }
  7116. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7117. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7118. } else {
  7119. status_color = "null";
  7120. }
  7121. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7122. }
  7123. retStr += " </status_map>\r\n";
  7124. } else {
  7125. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  7126. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7127. String status_power = "off", status_dim = "null", status_color = "null";
  7128. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7129. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7130. } else {
  7131. status_power = "null";
  7132. }
  7133. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7134. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7135. } else {
  7136. status_dim = "null";
  7137. }
  7138. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7139. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7140. } else {
  7141. status_color = "null";
  7142. }
  7143. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7144. }
  7145. retStr += " </status_map>\r\n";
  7146. }
  7147. retStr += " </service>\r\n</imap>\r\n";
  7148. }
  7149. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7150. int nResult = -99;
  7151. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7152. NodeList items = ele.getElementsByTagName("params");
  7153. Node item = items.item(0);
  7154. if (item != null) {
  7155. NamedNodeMap attrs = item.getAttributes();
  7156. for (int j = 0; j < attrs.getLength(); j++) {
  7157. Node attr = attrs.item(j);
  7158. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7159. dev_num = attr.getNodeValue();
  7160. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7161. dev_mode = attr.getNodeValue();
  7162. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7163. unit_num = attr.getNodeValue();
  7164. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7165. unit_status = attr.getNodeValue();
  7166. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7167. unit_dimming = attr.getNodeValue();
  7168. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7169. unit_color = attr.getNodeValue();
  7170. }
  7171. }
  7172. if (dev_num.equalsIgnoreCase("all")) {
  7173. nResult = 0;
  7174. for (int i = 0; i < nTotalLightCnt; i++) {
  7175. if (i == 0) {
  7176. nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7177. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7178. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7179. } else {
  7180. nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7181. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7182. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7183. }
  7184. }
  7185. if (nResult != 0) {
  7186. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7187. Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
  7188. return retStr;
  7189. } else {
  7190. retStr += " result=\"ok\">\r\n";
  7191. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7192. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7193. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7194. }
  7195. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7196. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7197. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7198. return retStr;
  7199. }
  7200. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
  7201. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7202. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7203. return retStr;
  7204. }
  7205. for (int i = 0; i < nTotalLightCnt; i++) {
  7206. if (i == 0) {
  7207. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7208. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7209. String status_power = "off", status_dim = "null", status_color = "null";
  7210. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7211. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7212. } else {
  7213. status_power = "null";
  7214. }
  7215. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7216. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7217. } else {
  7218. status_dim = "null";
  7219. }
  7220. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7221. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7222. } else {
  7223. status_color = "null";
  7224. }
  7225. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7226. }
  7227. retStr += " </status_map>\r\n";
  7228. } else {
  7229. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7230. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7231. String status_power = "off", status_dim = "null", status_color = "null";
  7232. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7233. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7234. } else {
  7235. status_power = "null";
  7236. }
  7237. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7238. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7239. } else {
  7240. status_dim = "null";
  7241. }
  7242. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7243. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7244. } else {
  7245. status_color = "null";
  7246. }
  7247. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7248. }
  7249. retStr += " </status_map>\r\n";
  7250. }
  7251. }
  7252. retStr += " </service>\r\n</imap>\r\n";
  7253. } else {
  7254. int nDevNo = 0;
  7255. int nUnitNo = 0;
  7256. try {
  7257. nDevNo = Integer.parseInt(dev_num);
  7258. } catch (RuntimeException re) {
  7259. LogUtil.errorLogInfo("", TAG, re);
  7260. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7261. return retStr;
  7262. } catch (Exception e) {
  7263. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7264. //e.printStackTrace();
  7265. LogUtil.errorLogInfo("", TAG, e);
  7266. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7267. return retStr;
  7268. }
  7269. if ((nDevNo - 1) > nTotalLightCnt) {
  7270. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7271. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7272. return retStr;
  7273. }
  7274. nResult = -99;
  7275. if (unit_num.equalsIgnoreCase("all")) {
  7276. if (nDevNo == 1) {
  7277. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7278. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7279. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7280. } else {
  7281. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7282. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7283. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7284. }
  7285. if (nResult != 0) {
  7286. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7287. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7288. return retStr;
  7289. }
  7290. } else {
  7291. try {
  7292. nUnitNo = Integer.parseInt(unit_num);
  7293. } catch (RuntimeException re) {
  7294. LogUtil.errorLogInfo("", TAG, re);
  7295. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7296. return retStr;
  7297. } catch (Exception e) {
  7298. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7299. //e.printStackTrace();
  7300. LogUtil.errorLogInfo("", TAG, e);
  7301. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7302. return retStr;
  7303. }
  7304. nResult = -99;
  7305. if (nDevNo == 1) {
  7306. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7307. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7308. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7309. } else {
  7310. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7311. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7312. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7313. }
  7314. if (nResult != 0) {
  7315. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7316. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7317. return retStr;
  7318. }
  7319. }
  7320. if (nDevNo == 1) {
  7321. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7322. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7323. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7324. return retStr;
  7325. } else {
  7326. retStr += " result=\"ok\">\r\n";
  7327. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7328. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7329. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7330. }
  7331. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7332. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7333. String status_power = "off", status_dim = "null", status_color = "null";
  7334. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7335. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7336. } else {
  7337. status_power = "null";
  7338. }
  7339. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7340. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7341. } else {
  7342. status_dim = "null";
  7343. }
  7344. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7345. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7346. } else {
  7347. status_color = "null";
  7348. }
  7349. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7350. }
  7351. retStr += " </status_map>\r\n";
  7352. } else {
  7353. int nRealDevNo = (byte) (nDevNo - 2);
  7354. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
  7355. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7356. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7357. return retStr;
  7358. } else {
  7359. retStr += " result=\"ok\">\r\n";
  7360. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7361. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7362. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7363. }
  7364. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount + "\">\r\n";
  7365. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
  7366. String status_power = "off", status_dim = "null", status_color = "null";
  7367. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
  7368. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7369. } else {
  7370. status_power = "null";
  7371. }
  7372. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
  7373. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
  7374. } else {
  7375. status_dim = "null";
  7376. }
  7377. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
  7378. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
  7379. } else {
  7380. status_color = "null";
  7381. }
  7382. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7383. }
  7384. retStr += " </status_map>\r\n";
  7385. }
  7386. retStr += " </service>\r\n</imap>\r\n";
  7387. }
  7388. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  7389. int nResult = 0;
  7390. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7391. NodeList items = ele.getElementsByTagName("params");
  7392. Node item = items.item(0);
  7393. if (item != null) {
  7394. NamedNodeMap attrs = item.getAttributes();
  7395. for (int j = 0; j < attrs.getLength(); j++) {
  7396. Node attr = attrs.item(j);
  7397. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7398. dev_num = attr.getNodeValue();
  7399. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7400. dev_mode = attr.getNodeValue();
  7401. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7402. unit_num = attr.getNodeValue();
  7403. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7404. unit_status = attr.getNodeValue();
  7405. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7406. unit_dimming = attr.getNodeValue();
  7407. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7408. unit_color = attr.getNodeValue();
  7409. }
  7410. }
  7411. if (dev_num.equalsIgnoreCase("all")) {
  7412. if (!dev_mode.equals("null")) {
  7413. nResult = -99;
  7414. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7415. if (nResult != 0) {
  7416. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7417. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7418. return retStr;
  7419. }
  7420. } else {
  7421. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7422. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7423. return retStr;
  7424. }
  7425. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7426. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7427. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7428. return retStr;
  7429. } else {
  7430. retStr += " result=\"ok\">\r\n";
  7431. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7432. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7433. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7434. }
  7435. retStr += " <status_map dev_num=\"1\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[0] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7436. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  7437. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7438. } else {
  7439. int nDevNo = 0;
  7440. try {
  7441. nDevNo = Integer.parseInt(dev_num);
  7442. } catch (RuntimeException re) {
  7443. LogUtil.errorLogInfo("", TAG, re);
  7444. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7445. return retStr;
  7446. } catch (Exception e) {
  7447. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7448. //e.printStackTrace();
  7449. LogUtil.errorLogInfo("", TAG, e);
  7450. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7451. return retStr;
  7452. }
  7453. if (nDevNo != 1) {
  7454. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  7455. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7456. return retStr;
  7457. }
  7458. if (!dev_mode.equals("null")) {
  7459. nResult = -99;
  7460. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7461. if (nResult != 0) {
  7462. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7463. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7464. return retStr;
  7465. }
  7466. } else {
  7467. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7468. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7469. return retStr;
  7470. }
  7471. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7472. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7473. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7474. return retStr;
  7475. } else {
  7476. retStr += " result=\"ok\">\r\n";
  7477. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7478. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7479. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7480. }
  7481. retStr += " <status_map dev_num=\"1\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[0] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[0] + "\">\r\n";
  7482. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7483. String status_power = "off", status_dim = "null", status_color = "null";
  7484. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7485. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7486. } else {
  7487. status_power = "null";
  7488. }
  7489. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7490. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7491. } else {
  7492. status_dim = "null";
  7493. }
  7494. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7495. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7496. } else {
  7497. status_color = "null";
  7498. }
  7499. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7500. }
  7501. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7502. }
  7503. } else {
  7504. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7505. }
  7506. lightcmd = null;
  7507. return retStr;
  7508. } catch (RuntimeException re) {
  7509. LogUtil.errorLogInfo("", TAG, re);
  7510. return null;
  7511. } catch (Exception e) {
  7512. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7513. //e.printStackTrace();
  7514. LogUtil.errorLogInfo("", TAG, e);
  7515. return null;
  7516. }
  7517. }
  7518. private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
  7519. byte type = 0;
  7520. //각 스위치 개수는 4개임
  7521. switch (lightIndex) {
  7522. case 0:
  7523. type = benEm.Info.LightType_1;
  7524. break;
  7525. case 1:
  7526. type = benEm.Info.LightType_2;
  7527. break;
  7528. case 2:
  7529. type = benEm.Info.LightType_3;
  7530. break;
  7531. case 3:
  7532. type = benEm.Info.LightType_4;
  7533. break;
  7534. default:
  7535. break;
  7536. }
  7537. return type;
  7538. }
  7539. public String iCMDProcChumDamSmartLightControl(Document ele) {
  7540. try {
  7541. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7542. String retStr = CheckiCMDProc("remote_access_smartlight");
  7543. if (retStr != null) return retStr;
  7544. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7545. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7546. if (NewServerUse()) {
  7547. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7548. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7549. }
  7550. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  7551. if (KnxApi == null) {
  7552. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7553. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
  7554. return retStr;
  7555. }
  7556. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7557. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7558. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7559. return retStr;
  7560. }
  7561. int LivingLightCount = 0;
  7562. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  7563. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  7564. } else {
  7565. if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  7566. LivingLightCount = 1;
  7567. }
  7568. WallpadStatusData DBMGR = null;
  7569. DBMGR = new WallpadStatusData(getApplicationContext());
  7570. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  7571. DBMGR.closeDB();
  7572. //기준층 명칭
  7573. String[] mDefaultRoomNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  7574. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
  7575. String[] mEtypeRoomNameList = new String[]{"거실", "침실1", "침실2", "침실3", "식당", "주방", "드레스룸1",
  7576. "서재", "다용도실", "메이드룸","욕실1","파우더룸","간이주방","테라스계단","오픈라운지","스위치1","스위치2","스위치3","스위치4","스위치5","스위치6","스위치7","스위치8"};
  7577. String [] knxRoomNameList = null;
  7578. // 기준층 A, B, C 타입과 D타입 2003호 , E타입 2001호 구분하여 처리
  7579. if(Integer.parseInt(addc.Ho) == 2001 || Integer.parseInt(addc.Ho) == 2003)
  7580. {
  7581. knxRoomNameList = mEtypeRoomNameList;
  7582. Log.e(TAG, "yskim[iCMDProcChumDamSmartLightControl] mEtypeRoomNameList");
  7583. }
  7584. else
  7585. {
  7586. knxRoomNameList = mDefaultRoomNameList;
  7587. Log.e(TAG, "yskim[iCMDProcChumDamSmartLightControl] mDefaultRoomNameList");
  7588. }
  7589. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  7590. String[] strValue = devSet.GetSettingData("KNX명칭");
  7591. devSet.closeDB();
  7592. // 현대건설 더 펜트하우스 서버에서 설정된 명칭이 있다면 그 명칭을 사용하도록 한다.
  7593. if( strValue != null ) {
  7594. String strLight = strValue[1].substring( (strValue[1].indexOf("조명(") + 3) , (strValue[1].indexOf(")난방(")));
  7595. String strHeating = strValue[1].substring( (strValue[1].indexOf("난방(") + 3) , (strValue[1].indexOf(")에어컨(")));
  7596. String strAircon = strValue[1].substring( (strValue[1].indexOf("에어컨(") + 4) , (strValue[1].indexOf("))")));
  7597. // DebugLogOutput("[Create] - room name strlight " + strLight);
  7598. // DebugLogOutput("[Create] - room name strHeating " + strHeating);
  7599. // DebugLogOutput("[Create] - room name strAircon " + strAircon);
  7600. if( strLight != null)knxRoomNameList = strLight.split("_");
  7601. }
  7602. int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  7603. int totalLightCount = LivingLightCount + BadLightCount;
  7604. //mData.MasterController.Info.Light_SwitchCount
  7605. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
  7606. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
  7607. {
  7608. retStr += " result=\"ok\">\r\n";
  7609. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7610. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7611. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7612. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7613. for (int i = 0; i < totalLightCount; i++) {
  7614. if (i == 0) {
  7615. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7616. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7617. String status_power = "off", status_dim = "null", status_color = "null";
  7618. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
  7619. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7620. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
  7621. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7622. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7623. }
  7624. retStr += " </status_map>\r\n";
  7625. } else {
  7626. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7627. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7628. String status_power = "off", status_dim = "null", status_color = "null";
  7629. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7630. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff);
  7631. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming);
  7632. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7633. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7634. status_dim ="null";
  7635. // zzz
  7636. //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
  7637. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7638. }
  7639. retStr += " </status_map>\r\n";
  7640. }
  7641. }
  7642. }
  7643. else
  7644. {
  7645. int nResult = 0;
  7646. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7647. NodeList items = ele.getElementsByTagName("params");
  7648. Node item = items.item(0);
  7649. if (item != null) {
  7650. NamedNodeMap attrs = item.getAttributes();
  7651. for (int j = 0; j< attrs.getLength(); j++) {
  7652. Node attr = attrs.item(j);
  7653. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7654. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7655. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7656. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7657. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7658. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7659. }
  7660. }
  7661. int nDevNo = Integer.parseInt(dev_num);
  7662. if (nDevNo == 1) {
  7663. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7664. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7665. String status_power = "off", status_dim = "null", status_color = "null";
  7666. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
  7667. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7668. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
  7669. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7670. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7671. }
  7672. retStr += " </status_map>\r\n";
  7673. } else {
  7674. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount + "\">\r\n";
  7675. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
  7676. String status_power = "off", status_dim = "null", status_color = "null";
  7677. status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7678. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff : " + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Info.Support.OnOff);
  7679. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming : " + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Info.Support.Dimming);
  7680. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
  7681. // zzz
  7682. //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) );
  7683. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
  7684. status_dim ="null";
  7685. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7686. }
  7687. retStr += " </status_map>\r\n";
  7688. }
  7689. }
  7690. retStr += " </service>\r\n</imap>\r\n";
  7691. }
  7692. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7693. int nResult = 0;
  7694. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7695. NodeList items = ele.getElementsByTagName("params");
  7696. Node item = items.item(0);
  7697. if (item != null) {
  7698. NamedNodeMap attrs = item.getAttributes();
  7699. for (int j = 0; j< attrs.getLength(); j++) {
  7700. Node attr = attrs.item(j);
  7701. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7702. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7703. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7704. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7705. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7706. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7707. }
  7708. }
  7709. if (dev_num.equalsIgnoreCase("ALL")) {
  7710. // 일괄소등 실행/해제
  7711. if (!unit_status.equalsIgnoreCase("null")) {
  7712. KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
  7713. }
  7714. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7715. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7716. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7717. return retStr;
  7718. }
  7719. retStr += " result=\"ok\">\r\n";
  7720. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7721. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7722. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7723. for (int i = 0; i < totalLightCount; i++) {
  7724. if (i == 0) {
  7725. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ "null" + "\" dev_name=\""+ knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7726. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7727. String status_power = "off", status_dim = "null", status_color = "null";
  7728. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
  7729. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7730. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
  7731. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7732. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7733. }
  7734. retStr += " </status_map>\r\n";
  7735. }
  7736. else {
  7737. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7738. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7739. String status_power = "off", status_dim = "null", status_color = "null";
  7740. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7741. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff);
  7742. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming);
  7743. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7744. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7745. status_dim ="null";
  7746. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7747. }
  7748. retStr += " </status_map>\r\n";
  7749. }
  7750. }
  7751. retStr += " </service>\r\n</imap>\r\n";
  7752. }
  7753. else {
  7754. int nDevNo = 0;
  7755. int nUnitNo = 0;
  7756. try {
  7757. nDevNo = Integer.parseInt(dev_num);
  7758. } catch (Exception e) {
  7759. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7760. e.printStackTrace();
  7761. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7762. return retStr;
  7763. }
  7764. if ((nDevNo - 1) > totalLightCount) {
  7765. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
  7766. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7767. return retStr;
  7768. }
  7769. // retStr += " result=\"ok\">\r\n";
  7770. // retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7771. // retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7772. // retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7773. if (unit_num.equalsIgnoreCase("all")) {
  7774. if (nDevNo == 1) {
  7775. // 거실 조명 일괄제어일 경우
  7776. if (!unit_status.equalsIgnoreCase("null")) {
  7777. int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7778. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7779. }
  7780. if (!unit_dimming.equalsIgnoreCase("null")) {
  7781. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7782. }
  7783. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7784. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7785. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7786. return retStr;
  7787. }
  7788. retStr += " result=\"ok\">\r\n";
  7789. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7790. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7791. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7792. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7793. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7794. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7795. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7796. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7797. }
  7798. }
  7799. else {
  7800. // 각각 EM 조명 일괄제어일 경우
  7801. if (!unit_status.equalsIgnoreCase("null")) {
  7802. KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7803. //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7804. }
  7805. if (!unit_dimming.equalsIgnoreCase("null")) {
  7806. Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : ");
  7807. if( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_2 == 0x0F
  7808. || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_3 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_4 == 0x0F)
  7809. {
  7810. Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] ==> Fan : " + nDevNo );
  7811. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7812. // 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
  7813. int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
  7814. Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7815. }
  7816. }
  7817. else {
  7818. int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7819. Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7820. }
  7821. //KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
  7822. }
  7823. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7824. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7825. Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7826. return retStr;
  7827. }
  7828. retStr += " result=\"ok\">\r\n";
  7829. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7830. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7831. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7832. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  7833. nDevNo = Integer.parseInt(dev_num);
  7834. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7835. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7836. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7837. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7838. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7839. status_dim ="null";
  7840. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7841. }
  7842. }
  7843. // retStr += " </status_map>\r\n";
  7844. // retStr += " </service>\r\n</imap>\r\n";
  7845. }
  7846. else {
  7847. // 회로별 제어일경우
  7848. try {
  7849. nUnitNo = Integer.parseInt(unit_num);
  7850. } catch (Exception e) {
  7851. Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7852. e.printStackTrace();
  7853. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7854. return retStr;
  7855. }
  7856. if (nDevNo == 1) {
  7857. if (!unit_status.equalsIgnoreCase("null")) {
  7858. int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
  7859. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7860. }
  7861. if (!unit_dimming.equalsIgnoreCase("null")) {
  7862. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7863. //mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  7864. }
  7865. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7866. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7867. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7868. return retStr;
  7869. }
  7870. retStr += " result=\"ok\">\r\n";
  7871. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7872. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7873. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7874. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7875. nDevNo = Integer.parseInt(dev_num);
  7876. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7877. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7878. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7879. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7880. }
  7881. }
  7882. else {
  7883. if (!unit_status.equalsIgnoreCase("null")) {
  7884. KnxApi.SetLightOnOff((byte) (nDevNo -2), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7885. //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7886. //회로별 제어는 On/Off 만 가능함
  7887. }
  7888. if (!unit_dimming.equalsIgnoreCase("null")) {
  7889. KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)(nUnitNo-1),(byte) Integer.parseInt(unit_dimming));
  7890. //일괄제어라 회로별 제어기능은 없음
  7891. // 시험 2021.05.12
  7892. }
  7893. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7894. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7895. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7896. return retStr;
  7897. }
  7898. retStr += " result=\"ok\">\r\n";
  7899. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7900. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7901. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7902. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  7903. nDevNo = Integer.parseInt(dev_num);
  7904. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7905. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7906. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7907. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7908. status_dim ="null";
  7909. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7910. }
  7911. }
  7912. }
  7913. retStr += " </status_map>\r\n";
  7914. retStr += " </service>\r\n</imap>\r\n";
  7915. }
  7916. }
  7917. else {
  7918. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7919. }
  7920. return retStr;
  7921. } catch (Exception e) {
  7922. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7923. e.printStackTrace();
  7924. return null;
  7925. }
  7926. }
  7927. public String iCMDProcLivingLightControl(Document ele) {
  7928. try {
  7929. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7930. String retStr = CheckiCMDProc("remote_access_livinglight");
  7931. if (retStr != null) return retStr;
  7932. else
  7933. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  7934. String target = "null", tid = "null", msgno = "null";
  7935. NodeList items = ele.getElementsByTagName("target");
  7936. Node item = items.item(0);
  7937. if (item != null) {
  7938. NamedNodeMap attrs = item.getAttributes();
  7939. for (int j = 0; j < attrs.getLength(); j++) {
  7940. Node attr = attrs.item(j);
  7941. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7942. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7943. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  7944. msgno = attr.getNodeValue();
  7945. }
  7946. }
  7947. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7948. if (NewServerUse()) {
  7949. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7950. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  7951. return ServerCheckResult;
  7952. }
  7953. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7954. if (bLightCMDUseAsSmartLight) {
  7955. if (mSdb_LivingRoomLightAPI != null) {
  7956. mSdb_LivingRoomLightAPI.Refresh();
  7957. 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";
  7958. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7959. 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");
  7960. }
  7961. retStr += " </service>\r\n</imap>\r\n";
  7962. } else {
  7963. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7964. }
  7965. } else {
  7966. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  7967. if (lightCTR != null) {
  7968. if (lightCTR.Refresh(false) == 0) {
  7969. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  7970. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  7971. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7972. }
  7973. retStr += " </service>\r\n</imap>\r\n";
  7974. } else {
  7975. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7976. }
  7977. }
  7978. }
  7979. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7980. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  7981. boolean OnOff = false;
  7982. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  7983. if (bLightCMDUseAsSmartLight) {
  7984. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  7985. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  7986. if (ret >= 0) {
  7987. ret = mSdb_LivingRoomLightAPI.Refresh();
  7988. if (ret >= 0) {
  7989. 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";
  7990. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7991. 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");
  7992. }
  7993. retStr += " </service>\r\n</imap>\r\n";
  7994. } else {
  7995. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7996. }
  7997. } else {
  7998. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7999. }
  8000. } else {
  8001. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8002. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  8003. if (ret >= 0) {
  8004. ret = mSdb_LivingRoomLightAPI.Refresh();
  8005. if (ret >= 0) {
  8006. 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";
  8007. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8008. 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");
  8009. }
  8010. retStr += " </service>\r\n</imap>\r\n";
  8011. } else {
  8012. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8013. }
  8014. } else {
  8015. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8016. }
  8017. }
  8018. } else {
  8019. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8020. if (lightCTR != null) {
  8021. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8022. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  8023. if (ret >= 0) {
  8024. ret = lightCTR.Refresh(false);
  8025. if (ret >= 0) {
  8026. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8027. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8028. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8029. }
  8030. retStr += " </service>\r\n</imap>\r\n";
  8031. } else {
  8032. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8033. }
  8034. } else {
  8035. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8036. }
  8037. } else {
  8038. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8039. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  8040. if (ret >= 0) {
  8041. ret = lightCTR.Refresh(false);
  8042. if (ret >= 0) {
  8043. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8044. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8045. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8046. }
  8047. retStr += " </service>\r\n</imap>\r\n";
  8048. } else {
  8049. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8050. }
  8051. } else {
  8052. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8053. }
  8054. }
  8055. }
  8056. }
  8057. } else {
  8058. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8059. }
  8060. } else {
  8061. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  8062. }
  8063. lightcmd = null;
  8064. return retStr;
  8065. } catch (RuntimeException re) {
  8066. LogUtil.errorLogInfo("", TAG, re);
  8067. return null;
  8068. } catch (Exception e) {
  8069. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  8070. //e.printStackTrace();
  8071. LogUtil.errorLogInfo("", TAG, e);
  8072. return null;
  8073. }
  8074. }
  8075. public String iCMDProc_I_LightControl(Document ele) {
  8076. try {
  8077. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  8078. String retStr = CheckiCMDProc("remote_access_livinglight");
  8079. if (retStr != null) return retStr;
  8080. else
  8081. retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  8082. String target = "null", tid = "null", msgno = "null";
  8083. NodeList items = ele.getElementsByTagName("target");
  8084. Node item = items.item(0);
  8085. if (item != null) {
  8086. NamedNodeMap attrs = item.getAttributes();
  8087. for (int j = 0; j < attrs.getLength(); j++) {
  8088. Node attr = attrs.item(j);
  8089. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8090. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8091. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8092. msgno = attr.getNodeValue();
  8093. }
  8094. }
  8095. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8096. if (NewServerUse()) {
  8097. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8098. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8099. return ServerCheckResult;
  8100. }
  8101. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  8102. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8103. if (lightCTR != null && lightCTR.Refresh(false) == 0) {
  8104. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8105. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8106. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8107. }
  8108. retStr += " </service>\r\n</imap>\r\n";
  8109. } else {
  8110. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  8111. }
  8112. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8113. if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  8114. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  8115. int result = -999;
  8116. if (lightCTR != null) {
  8117. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  8118. result = lightCTR.LightProgramControl((byte) num, (byte) 1);
  8119. } else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  8120. result = lightCTR.LightProgramControl((byte) num, (byte) 0);
  8121. }
  8122. if (result >= 0) {
  8123. // 제어 성공
  8124. try {
  8125. Thread.sleep(1000);
  8126. } catch (RuntimeException re) {
  8127. LogUtil.errorLogInfo("", TAG, re);
  8128. } catch (Exception e) {
  8129. LogUtil.errorLogInfo("", TAG, e);
  8130. }
  8131. lightCTR.Refresh(false);
  8132. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8133. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8134. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8135. }
  8136. retStr += " </service>\r\n</imap>";
  8137. } else {
  8138. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8139. }
  8140. } else {
  8141. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8142. }
  8143. } else {
  8144. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8145. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  8146. if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  8147. try {
  8148. Thread.sleep(1000);
  8149. } catch (RuntimeException re) {
  8150. LogUtil.errorLogInfo("", TAG, re);
  8151. } catch (Exception e) {
  8152. LogUtil.errorLogInfo("", TAG, e);
  8153. }
  8154. lightCTR.Refresh(false);
  8155. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8156. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8157. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8158. }
  8159. retStr += " </service>\r\n</imap>\r\n";
  8160. } else {
  8161. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8162. }
  8163. }
  8164. } else {
  8165. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  8166. }
  8167. lightcmd = null;
  8168. return retStr;
  8169. } catch (RuntimeException re) {
  8170. LogUtil.errorLogInfo("", TAG, re);
  8171. return null;
  8172. } catch (Exception e) {
  8173. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  8174. //e.printStackTrace();
  8175. LogUtil.errorLogInfo("", TAG, e);
  8176. return null;
  8177. }
  8178. }
  8179. public String iCMDProcGASControl(Element ele) {
  8180. try {
  8181. String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
  8182. String strResult = CheckiCMDProc("remote_access_gas");
  8183. if (strResult != null) return strResult;
  8184. else
  8185. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  8186. NodeList items = ele.getElementsByTagName("target");
  8187. Node item = items.item(0);
  8188. if (item != null) {
  8189. NamedNodeMap attrs = item.getAttributes();
  8190. for (int j = 0; j < attrs.getLength(); j++) {
  8191. Node attr = attrs.item(j);
  8192. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8193. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8194. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8195. msgno = attr.getNodeValue();
  8196. }
  8197. }
  8198. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8199. if (NewServerUse()) {
  8200. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  8201. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8202. return ServerCheckResult;
  8203. }
  8204. NodeList itemsParam = ele.getElementsByTagName("params");
  8205. Node itemParam = itemsParam.item(0);
  8206. if (itemParam != null) {
  8207. NamedNodeMap attrsParam = itemParam.getAttributes();
  8208. for (int j = 0; j < attrsParam.getLength(); j++) {
  8209. Node attr = attrsParam.item(j);
  8210. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8211. devnum = attr.getNodeValue();
  8212. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  8213. //unitnum = attr.getNodeValue();
  8214. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8215. ctraction = attr.getNodeValue();
  8216. }
  8217. }
  8218. NodeList itemsaction = ele.getElementsByTagName("action");
  8219. Node itemaction = itemsaction.item(0);
  8220. Node text = itemaction.getFirstChild();
  8221. String actionTXT = text.getNodeValue();
  8222. //수정
  8223. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  8224. actionTXT = trimquotation(actionTXT);
  8225. GasAPI GasValveCTR = null;
  8226. CooktopAPI HybridCookTopCTR = null;
  8227. if (mWallPadAPI.GetGasKind() == 2) {
  8228. //하이브리드
  8229. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  8230. } else {
  8231. GasValveCTR = mWallPadAPI.Get_GasController();
  8232. }
  8233. if (actionTXT.equalsIgnoreCase("status")) {
  8234. // 가스밸브 상태 조회
  8235. if (mWallPadAPI.GetGasKind() == 2) {
  8236. //하이브리드
  8237. if (HybridCookTopCTR != null) {
  8238. //전체 정보가져오기
  8239. int ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8240. if (ret < 0) {
  8241. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8242. return strResult;
  8243. }
  8244. int OnOpenCount = 0;
  8245. int OperationCount = 0;
  8246. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8247. // 콘센트 ON/OFF 업데이트
  8248. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8249. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8250. OnOpenCount++;
  8251. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8252. OperationCount++;
  8253. }
  8254. }
  8255. }
  8256. if (OperationCount > 0) {
  8257. valvestatus = "ing";
  8258. } else if (OnOpenCount > 0) {
  8259. valvestatus = "open";
  8260. } else {
  8261. valvestatus = "close";
  8262. }
  8263. }
  8264. } else {
  8265. if (GasValveCTR != null) {
  8266. int ret = GasValveCTR.Refresh((byte) 0, false);
  8267. if (ret < 0) {
  8268. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8269. return strResult;
  8270. }
  8271. if (GasValveCTR.data.DeviceCnt == 2) {
  8272. GasValveCTR.Refresh((byte) 1, false);
  8273. }
  8274. byte GasStatus = GasAPI.GASSTATUS.Close;
  8275. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8276. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8277. GasStatus = GasAPI.GASSTATUS.Operation;
  8278. break;
  8279. }
  8280. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8281. GasStatus = GasAPI.GASSTATUS.Open;
  8282. break;
  8283. }
  8284. }
  8285. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8286. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8287. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8288. else valvestatus = "unknown";
  8289. }
  8290. }
  8291. } else if (actionTXT.equalsIgnoreCase("control")) {
  8292. // 가스밸브 콘트롤
  8293. if (mWallPadAPI.GetGasKind() == 2) {
  8294. //하이브리드
  8295. if (HybridCookTopCTR != null) {
  8296. int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
  8297. if (ret < 0) {
  8298. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8299. return strResult;
  8300. }
  8301. ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8302. if (ret < 0) {
  8303. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8304. return strResult;
  8305. }
  8306. int OnOpenCount = 0;
  8307. int OperationCount = 0;
  8308. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8309. // 콘센트 ON/OFF 업데이트
  8310. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8311. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8312. OnOpenCount++;
  8313. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8314. OperationCount++;
  8315. }
  8316. }
  8317. }
  8318. if (OperationCount > 0) {
  8319. valvestatus = "ing";
  8320. } else if (OnOpenCount > 0) {
  8321. valvestatus = "open";
  8322. } else {
  8323. valvestatus = "close";
  8324. }
  8325. }
  8326. } else {
  8327. if (GasValveCTR != null) {
  8328. int ret = GasValveCTR.SetClose((byte) 0xFF);
  8329. if (ret < 0) {
  8330. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8331. return strResult;
  8332. }
  8333. ret = GasValveCTR.Refresh((byte) 0, false);
  8334. if (ret < 0) {
  8335. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8336. return strResult;
  8337. }
  8338. if (GasValveCTR.data.DeviceCnt == 2) {
  8339. GasValveCTR.Refresh((byte) 1, false);
  8340. }
  8341. byte GasStatus = GasAPI.GASSTATUS.Close;
  8342. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8343. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8344. GasStatus = GasAPI.GASSTATUS.Operation;
  8345. break;
  8346. }
  8347. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8348. GasStatus = GasAPI.GASSTATUS.Open;
  8349. break;
  8350. }
  8351. }
  8352. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8353. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8354. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8355. else valvestatus = "unknown";
  8356. }
  8357. }
  8358. } else {
  8359. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8360. return strResult;
  8361. }
  8362. strResult += "\"ok\" >\r\n";
  8363. strResult += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8364. strResult += " <action>\"" + actionTXT + "\"</action>\r\n";
  8365. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  8366. strResult += " <status_info unit_num=\"gas1\" unit_status=\"" + valvestatus + "\"/>\r\n";
  8367. strResult += " </service>\r\n";
  8368. strResult += "</imap> ";
  8369. return strResult;
  8370. } catch (RuntimeException re) {
  8371. LogUtil.errorLogInfo("", TAG, re);
  8372. return null;
  8373. } catch (Exception e) {
  8374. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  8375. //e.printStackTrace();
  8376. LogUtil.errorLogInfo("", TAG, e);
  8377. return null;
  8378. }
  8379. }
  8380. private String iCMDProcLightBatchControl(Element ele) {
  8381. try {
  8382. String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
  8383. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  8384. if (retStr != null) return retStr;
  8385. NodeList items = ele.getElementsByTagName("target");
  8386. Node item = items.item(0);
  8387. if (item != null) {
  8388. NamedNodeMap attrs = item.getAttributes();
  8389. for (int j = 0; j < attrs.getLength(); j++) {
  8390. Node attr = attrs.item(j);
  8391. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8392. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8393. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8394. msgno = attr.getNodeValue();
  8395. }
  8396. }
  8397. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8398. if (NewServerUse()) {
  8399. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8400. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8401. return ServerCheckResult;
  8402. }
  8403. NodeList itemsParam = ele.getElementsByTagName("params");
  8404. Node itemParam = itemsParam.item(0);
  8405. if (itemParam != null) {
  8406. NamedNodeMap attrsParam = itemParam.getAttributes();
  8407. for (int j = 0; j < attrsParam.getLength(); j++) {
  8408. Node attr = attrsParam.item(j);
  8409. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8410. ctraction = attr.getNodeValue();
  8411. }
  8412. }
  8413. }
  8414. NodeList itemsaction = ele.getElementsByTagName("action");
  8415. Node itemaction = itemsaction.item(0);
  8416. Node text = itemaction.getFirstChild();
  8417. String actionTXT = text.getNodeValue();
  8418. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  8419. actionTXT = trimquotation(actionTXT);
  8420. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8421. if (actionTXT.equalsIgnoreCase("status")) {
  8422. // 일괄소등 상태 조회
  8423. int ret = mWallPadAPI.GetBatchSwitchStatus();
  8424. if (ret > 1) {
  8425. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8426. return retStr;
  8427. }
  8428. if (ret == 0) {
  8429. ilgalstatus = "on";
  8430. } else if (ret == 1) {
  8431. ilgalstatus = "off";
  8432. } else {
  8433. ilgalstatus = "error";
  8434. }
  8435. } else if (actionTXT.equalsIgnoreCase("control")) {
  8436. // 일괄소등 제어
  8437. int ret = -1;
  8438. int status = -1;
  8439. if (ctraction.equals("on") == true) {
  8440. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  8441. status = 0;
  8442. } else if (ctraction.equals("off") == true) {
  8443. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  8444. status = 1;
  8445. }
  8446. if (ret < 0) {
  8447. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8448. return retStr;
  8449. }
  8450. if (status == 0) {
  8451. ilgalstatus = "on";
  8452. } else if (status == 1) {
  8453. ilgalstatus = "off";
  8454. } else {
  8455. ilgalstatus = "error";
  8456. }
  8457. } else {
  8458. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8459. return retStr;
  8460. }
  8461. retStr += "\"ok\" >\r\n";
  8462. retStr += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8463. retStr += " <action>\"" + actionTXT + "\"</action>\r\n";
  8464. retStr += " <status_info unit_status=\"" + ilgalstatus + "\"/>\r\n </service>\r\n</imap> ";
  8465. return retStr;
  8466. } catch (RuntimeException re) {
  8467. LogUtil.errorLogInfo("", TAG, re);
  8468. return null;
  8469. } catch (Exception e) {
  8470. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  8471. //e.printStackTrace();
  8472. LogUtil.errorLogInfo("", TAG, e);
  8473. return null;
  8474. }
  8475. }
  8476. private String iCMDProcEntireLightControl(Document ele) {
  8477. try {
  8478. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  8479. if (retStr != null) return retStr;
  8480. else
  8481. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  8482. String sDong = null;
  8483. String sHo = null;
  8484. String sDevice_Num = null;
  8485. String sSelCtrl_Action = null;
  8486. String sUnselCtrl_Action = null;
  8487. NodeList items = ele.getElementsByTagName("home_info");
  8488. Node item = items.item(0);
  8489. NamedNodeMap attrsParam = item.getAttributes();
  8490. for (int i = 0; i < attrsParam.getLength(); i++) {
  8491. Node attr = attrsParam.item(i);
  8492. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8493. sDong = trimquotation(attr.getNodeValue());
  8494. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8495. sHo = trimquotation(attr.getNodeValue());
  8496. }
  8497. WallpadStatusData DBMGR = null;
  8498. DBMGR = new WallpadStatusData(getApplicationContext());
  8499. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8500. DBMGR.closeDB();
  8501. if (mSdb_LivingRoomLightAPI == null) {
  8502. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  8503. retStr += " result=\"fail\" >\r\n";
  8504. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8505. retStr += " </service>\r\n</imap>";
  8506. return retStr;
  8507. }
  8508. if (mSdbAPI == null) {
  8509. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  8510. retStr += " result=\"fail\" >\r\n";
  8511. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8512. retStr += " </service>\r\n</imap>";
  8513. return retStr;
  8514. }
  8515. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
  8516. items = ele.getElementsByTagName("sel_ctrlinfo");
  8517. item = items.item(0);
  8518. attrsParam = item.getAttributes();
  8519. for (int i = 0; i < attrsParam.getLength(); i++) {
  8520. Node attr = attrsParam.item(i);
  8521. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8522. sDevice_Num = trimquotation(attr.getNodeValue());
  8523. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8524. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  8525. }
  8526. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  8527. int result = -1; // 조명 제어 결과
  8528. boolean bLivingLightSel = false; // 거실조명 선택 여부
  8529. // ============================== 선택된 조명 ==============================
  8530. String[] sel_devNum = null;
  8531. if (sDevice_Num != null && sDevice_Num.contains("light")) {
  8532. if (sDevice_Num.contains("/"))
  8533. sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  8534. else {
  8535. sel_devNum = new String[1];
  8536. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  8537. }
  8538. }
  8539. if (sel_devNum == null) sel_devNum = new String[0];
  8540. for (int i = 0; i < sel_devNum.length; i++) {
  8541. if (sel_devNum[i].equals("1")) {
  8542. bLivingLightSel = true;
  8543. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  8544. if (sSelCtrl_Action != null) {
  8545. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8546. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8547. } else {
  8548. int nColor = 0;
  8549. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8550. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8551. if (nColor > 0) {
  8552. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8553. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8554. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8555. }
  8556. }
  8557. // 거실조명 제어 결과
  8558. if (result < 0) {
  8559. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  8560. retStr += " result=\"fail\" >\r\n";
  8561. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8562. retStr += " </service>\r\n</imap>";
  8563. return retStr;
  8564. }
  8565. }
  8566. } else {
  8567. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  8568. if (sSelCtrl_Action != null) {
  8569. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8570. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  8571. } else {
  8572. int nColor = 0;
  8573. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8574. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8575. if (nColor > 0) {
  8576. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  8577. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  8578. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  8579. }
  8580. }
  8581. }
  8582. // 그 외 방 조명 제어 결과
  8583. if (result < 0) {
  8584. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  8585. retStr += " result=\"fail\" >\r\n";
  8586. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8587. retStr += " </service>\r\n</imap>";
  8588. return retStr;
  8589. }
  8590. }
  8591. }
  8592. // ============================== 선택안된 조명 ==============================
  8593. items = ele.getElementsByTagName("unsel_ctrlinfo");
  8594. item = items.item(0);
  8595. attrsParam = item.getAttributes();
  8596. for (int i = 0; i < attrsParam.getLength(); i++) {
  8597. Node attr = attrsParam.item(i);
  8598. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8599. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  8600. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  8601. }
  8602. if (!bLivingLightSel) {
  8603. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  8604. if (sUnselCtrl_Action != null) {
  8605. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8606. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8607. } else {
  8608. int nColor = 0;
  8609. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8610. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8611. if (nColor > 0) {
  8612. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8613. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8614. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8615. }
  8616. }
  8617. }
  8618. if (result < 0) {
  8619. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  8620. retStr += " result=\"fail\" >\r\n";
  8621. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8622. retStr += " </service>\r\n</imap>";
  8623. return retStr;
  8624. }
  8625. }
  8626. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  8627. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  8628. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  8629. unsel_devNum.add(i + 1);
  8630. }
  8631. for (int i = 0; i < unsel_devNum.size(); i++) {
  8632. for (int j = 0; j < sel_devNum.length; j++) {
  8633. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
  8634. unsel_devNum.remove(i);
  8635. }
  8636. }
  8637. for (int i = 0; i < unsel_devNum.size(); i++) {
  8638. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
  8639. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8640. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  8641. } else {
  8642. int nColor = 0;
  8643. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8644. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8645. if (nColor > 0) {
  8646. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  8647. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  8648. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  8649. }
  8650. }
  8651. if (result < 0) {
  8652. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  8653. retStr += " result=\"fail\" >\r\n";
  8654. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8655. retStr += " </service>\r\n</imap>";
  8656. return retStr;
  8657. }
  8658. }
  8659. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  8660. retStr += " result=\"ok\">\r\n";
  8661. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8662. retStr += " </service>\r\n</imap>";
  8663. return retStr;
  8664. } else {
  8665. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  8666. retStr += " result=\"fail\" >\r\n";
  8667. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8668. retStr += " </service>\r\n</imap>";
  8669. return retStr;
  8670. }
  8671. } catch (RuntimeException re) {
  8672. LogUtil.errorLogInfo("", TAG, re);
  8673. return null;
  8674. } catch (Exception e) {
  8675. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  8676. //e.printStackTrace();
  8677. LogUtil.errorLogInfo("", TAG, e);
  8678. return null;
  8679. }
  8680. }
  8681. // 월패드에 원격제어 사용 여부를 확인하다.
  8682. private String CheckiCMDProc(String CMDStr) {
  8683. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  8684. try {
  8685. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  8686. mWallpadStatusData.closeDB();
  8687. if (!bRemoteCtrlEnabled) {
  8688. String retXML = XMLHeader + "<service type=\"reply\" name=\"" + CMDStr + "\" result=\"deny\">\r\n" +
  8689. " </service>\r\n</imap>";
  8690. return retXML;
  8691. }
  8692. return null;
  8693. } catch (RuntimeException re) {
  8694. LogUtil.errorLogInfo("", TAG, re);
  8695. mWallpadStatusData.closeDB();
  8696. return null;
  8697. } catch (Exception e) {
  8698. mWallpadStatusData.closeDB();
  8699. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  8700. //e.printStackTrace();
  8701. LogUtil.errorLogInfo("", TAG, e);
  8702. return null;
  8703. }
  8704. }
  8705. //메인으로 공지 해야 할 노티 사항을 처리
  8706. public String ProcEventNotify(Element ele) {
  8707. try {
  8708. NodeList items = ele.getElementsByTagName("event");
  8709. Node item = items.item(0);
  8710. Node text = item.getFirstChild();
  8711. String eventTXT = trimquotation(text.getNodeValue());
  8712. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  8713. // 새로운 공지사항 존재
  8714. wakeupLCD();
  8715. Intent intent = new Intent();
  8716. intent.setAction(define.NOTIFY_ACNAME);
  8717. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  8718. getApplicationContext().sendBroadcast(intent);
  8719. } else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  8720. // 택배 도착
  8721. wakeupLCD();
  8722. Intent intent = new Intent();
  8723. intent.setAction(define.NOTIFY_ACNAME);
  8724. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  8725. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  8726. intent.putExtra("REMAIN_CNT", 1);
  8727. getApplicationContext().sendBroadcast(intent);
  8728. } else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  8729. // 택배 반출
  8730. wakeupLCD();
  8731. Intent intent = new Intent();
  8732. intent.setAction(define.NOTIFY_ACNAME);
  8733. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  8734. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  8735. intent.putExtra("REMAIN_CNT", 0);
  8736. getApplicationContext().sendBroadcast(intent);
  8737. } else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  8738. // 등록된 차량 도착
  8739. wakeupLCD();
  8740. // 팝업을 띄우도록 하자
  8741. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  8742. Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
  8743. } else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  8744. // 내려가는 방향의 엘리베이터가 도착함
  8745. if (ElevatorDown != null) {
  8746. ElevatorDown.TimeOutCancel();
  8747. ElevatorDown.ClearElevator();
  8748. }
  8749. Intent intent = new Intent();
  8750. intent.setAction(define.NOTIFY_ACNAME);
  8751. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  8752. getApplicationContext().sendBroadcast(intent);
  8753. } else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  8754. // 올라가는 방향의 엘리베이터가 도착함
  8755. if (ElevatorUp != null) {
  8756. ElevatorUp.TimeOutCancel();
  8757. ElevatorUp.ClearElevator();
  8758. }
  8759. Intent intent = new Intent();
  8760. intent.setAction(define.NOTIFY_ACNAME);
  8761. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  8762. getApplicationContext().sendBroadcast(intent);
  8763. } else {
  8764. }
  8765. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  8766. "<event> \"" + eventTXT + "\" </event>\r\n" + " </service>\r\n </imap> ";
  8767. return returnStr;
  8768. } catch (RuntimeException re) {
  8769. LogUtil.errorLogInfo("", TAG, re);
  8770. return null;
  8771. } catch (Exception e) {
  8772. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  8773. //e.printStackTrace();
  8774. LogUtil.errorLogInfo("", TAG, e);
  8775. return null;
  8776. }
  8777. }
  8778. public String GetAttributeVal(Node node, String attname) {
  8779. NamedNodeMap attrs = node.getAttributes();
  8780. for (int j = 0; j < attrs.getLength(); j++) {
  8781. Node attr = attrs.item(j);
  8782. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  8783. }
  8784. return null;
  8785. }
  8786. public class imageFileFilter implements FilenameFilter {
  8787. public boolean accept(File dir, String name) {
  8788. 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"))
  8789. return true;
  8790. else return false;
  8791. }
  8792. }
  8793. public String ProcCheckEpiceUpload(Document ele) {
  8794. try {
  8795. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  8796. NodeList items = ele.getElementsByTagName("filename");
  8797. Node item = items.item(0);
  8798. Node text = item.getFirstChild();
  8799. String filename = trimquotation(text.getNodeValue());
  8800. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  8801. String duplicate = null;
  8802. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  8803. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  8804. if (!dirInternal.exists()) dirInternal.mkdir();
  8805. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  8806. AddressSet addr = SetData.getAddressMGR();
  8807. if (!dirInternal.exists()) {
  8808. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  8809. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + define.MAX_ALBUM_PICTURE + "\" available=\"0\" duplicate=\"new\"/>\r\n" +
  8810. " </service>\r\n</imap>";
  8811. return returnStr;
  8812. }
  8813. imageFileFilter jpegfilter = new imageFileFilter();
  8814. String[] subfile = dirInternal.list(jpegfilter);
  8815. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  8816. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  8817. if (checkFile.exists()) duplicate = "exist";
  8818. else duplicate = "new";
  8819. if (subfile != null) {
  8820. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  8821. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + subfile.length + "\" available=\"" + (define.MAX_ALBUM_PICTURE - subfile.length) + "\" duplicate=\"" + duplicate + "\"/>\r\n" +
  8822. " </service>\r\n</imap>";
  8823. }
  8824. SetData.closeDB();
  8825. return returnStr;
  8826. } catch (RuntimeException re) {
  8827. LogUtil.errorLogInfo("", TAG, re);
  8828. return null;
  8829. } catch (Exception e) {
  8830. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  8831. //e.printStackTrace();
  8832. LogUtil.errorLogInfo("", TAG, e);
  8833. return null;
  8834. }
  8835. }
  8836. private void playNotifySound(int nSoundID) {
  8837. try {
  8838. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  8839. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  8840. if (getCompareBSPVersion()) {
  8841. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  8842. } else {
  8843. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  8844. }
  8845. boolean NeedPlay = false;
  8846. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  8847. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  8848. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  8849. } else {
  8850. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  8851. }
  8852. SetData.closeDB();
  8853. if (NeedPlay) Sound().PlayMent(nSoundID);
  8854. } catch (RuntimeException re) {
  8855. LogUtil.errorLogInfo("", TAG, re);
  8856. } catch (Exception e) {
  8857. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  8858. //e.printStackTrace();
  8859. LogUtil.errorLogInfo("", TAG, e);
  8860. }
  8861. }
  8862. private void wakeupLCD() {
  8863. try {
  8864. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  8865. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  8866. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  8867. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  8868. int AlarmStatus = WsDB.GetAlarmStatus();
  8869. WsDB.closeDB();
  8870. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  8871. Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
  8872. return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
  8873. } else {
  8874. Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
  8875. mIOInterface.ctrlLcdWakeUp();
  8876. }
  8877. } catch (RuntimeException re) {
  8878. LogUtil.errorLogInfo("", TAG, re);
  8879. } catch (Exception e) {
  8880. Log.e(TAG, "[Exception] wakeupLCD()");
  8881. //e.printStackTrace();
  8882. LogUtil.errorLogInfo("", TAG, e);
  8883. }
  8884. }
  8885. /**
  8886. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  8887. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  8888. * Jeff, 2020.09.07
  8889. *
  8890. * @return true: LCD backlight On, false: LCD backlight Off
  8891. */
  8892. public boolean checkLCDOnByCMD() {
  8893. try {
  8894. Runtime mRuntime = Runtime.getRuntime();
  8895. Process mProcess;
  8896. String cmd = "getprop persist.sys.lcdcon";
  8897. mProcess = mRuntime.exec(cmd);
  8898. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  8899. String line;
  8900. String strResult = null;
  8901. while ((line = br.readLine()) != null) {
  8902. strResult = line;
  8903. }
  8904. if (strResult != null) {
  8905. if (strResult.equals("0")) {
  8906. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  8907. return true;
  8908. } else if (strResult.equals("1")) {
  8909. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  8910. return false;
  8911. } else {
  8912. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  8913. return false;
  8914. }
  8915. } else
  8916. return false;
  8917. } catch (RuntimeException re) {
  8918. LogUtil.errorLogInfo("", TAG, re);
  8919. return false;
  8920. } catch (Exception e) {
  8921. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  8922. //e.printStackTrace();
  8923. LogUtil.errorLogInfo("", TAG, e);
  8924. return false;
  8925. }
  8926. }
  8927. /**
  8928. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  8929. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  8930. *
  8931. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  8932. */
  8933. public boolean getCompareBSPVersion() {
  8934. try {
  8935. StringBuilder strBSPVersion = new StringBuilder();
  8936. StringBuffer sysInfoBuffer = new StringBuffer();
  8937. sysInfoBuffer.append(Build.DISPLAY);
  8938. strBSPVersion.append(sysInfoBuffer.toString());
  8939. String result = strBSPVersion.toString();
  8940. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  8941. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  8942. Date date = simpleDateFormat.parse(result);
  8943. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  8944. if (date.compareTo(standardDate) >= 0) {
  8945. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  8946. return true;
  8947. }
  8948. } catch (RuntimeException re) {
  8949. LogUtil.errorLogInfo("", TAG, re);
  8950. } catch (Exception e) {
  8951. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  8952. //e.printStackTrace();
  8953. LogUtil.errorLogInfo("", TAG, e);
  8954. }
  8955. return false;
  8956. }
  8957. public String ProcUpdateWeather(Document ele) {
  8958. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  8959. String nowloc = "";
  8960. String nowlcode = "";
  8961. String nowdate = "";
  8962. String nowtext = "";
  8963. String nowcode = "";
  8964. String nowtemp = "";
  8965. String nowlo = "", nowhigh = "";
  8966. NodeList items = ele.getElementsByTagName("now");
  8967. Node item = items.item(0);
  8968. if (item == null)
  8969. return resultstr += "\"fail\"/> \r\n </imap>";
  8970. NamedNodeMap attrsParam = item.getAttributes();
  8971. for (int j = 0; j < attrsParam.getLength(); j++) {
  8972. Node attr = attrsParam.item(j);
  8973. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  8974. else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
  8975. nowlcode = attr.getNodeValue();
  8976. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  8977. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  8978. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  8979. else if (attr.getNodeName().equalsIgnoreCase("temperature"))
  8980. nowtemp = attr.getNodeValue();
  8981. }
  8982. items = ele.getElementsByTagName("week");
  8983. String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
  8984. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8985. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  8986. Weathertbl.InitWeatherTable();
  8987. for (int i = 0; i < items.getLength(); i++) {
  8988. item = items.item(i);
  8989. attrsParam = item.getAttributes();
  8990. for (int j = 0; j < attrsParam.getLength(); j++) {
  8991. Node attr = attrsParam.item(j);
  8992. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  8993. else if (attr.getNodeName().equalsIgnoreCase("text"))
  8994. weektext = attr.getNodeValue();
  8995. else if (attr.getNodeName().equalsIgnoreCase("code"))
  8996. weekcode = attr.getNodeValue();
  8997. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  8998. else if (attr.getNodeName().equalsIgnoreCase("high"))
  8999. weekhigh = attr.getNodeValue();
  9000. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  9001. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  9002. }
  9003. if (i == 0) {
  9004. nowlo = weeklow;
  9005. nowhigh = weekhigh;
  9006. }
  9007. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  9008. }
  9009. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  9010. Intent intent = new Intent();
  9011. intent.setAction(define.NOTIFY_ACNAME);
  9012. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  9013. intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
  9014. getApplicationContext().sendBroadcast(intent);
  9015. String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
  9016. 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);
  9017. //air
  9018. items = ele.getElementsByTagName("air");
  9019. String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
  9020. item = items.item(0);
  9021. if (item != null) {
  9022. attrsParam = item.getAttributes();
  9023. for (int j = 0; j < attrsParam.getLength(); j++) {
  9024. Node attr = attrsParam.item(j);
  9025. if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
  9026. else if (attr.getNodeName().equalsIgnoreCase("pm25"))
  9027. airpm25 = attr.getNodeValue();
  9028. else if (attr.getNodeName().equalsIgnoreCase("co2"))
  9029. airco2 = attr.getNodeValue();
  9030. else if (attr.getNodeName().equalsIgnoreCase("ozone"))
  9031. airozone = attr.getNodeValue();
  9032. else if (attr.getNodeName().equalsIgnoreCase("air_index"))
  9033. air_index = attr.getNodeValue();
  9034. }
  9035. Intent intentAir = new Intent();
  9036. intentAir.setAction(define.NOTIFY_ACNAME);
  9037. intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
  9038. getApplicationContext().sendBroadcast(intentAir);
  9039. DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
  9040. }
  9041. DBMGR.closeDB();
  9042. return resultstr += "\"ok\"/> \r\n </imap>";
  9043. }
  9044. //iMAP update_news 처리
  9045. public String ProcUpdateNews(Document ele) {
  9046. NodeList items = ele.getElementsByTagName("ver_news");
  9047. Node item = items.item(0);
  9048. String strNewsVer = item.getTextContent();
  9049. strNewsVer = trimquotation(strNewsVer);
  9050. String retXML = XMLHeader + "<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n" +
  9051. " <ver_news>\"" + strNewsVer + "\"</ver_news>\r\n<service/>\r\n</imap>";
  9052. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9053. String NotiVer = DBMGR.GetNoticeVer();
  9054. int noticeCNT = DBMGR.GetNoticeCNT();
  9055. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  9056. String[] spdt = strNewsVer.split("[.]");
  9057. noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
  9058. } else {
  9059. String[] spdt = strNewsVer.split("[.]");
  9060. int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
  9061. spdt = NotiVer.split("[.]");
  9062. newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
  9063. noticeCNT += newcnt;
  9064. }
  9065. Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
  9066. DBMGR.SetNoticeVer(strNewsVer);
  9067. DBMGR.SetNoticeCNT(noticeCNT);
  9068. DBMGR.closeDB();
  9069. if (NotiVer.compareTo(strNewsVer) != 0) {
  9070. Intent intent = new Intent();
  9071. intent.setAction(define.NOTIFY_ACNAME);
  9072. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9073. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  9074. getApplicationContext().sendBroadcast(intent);
  9075. }
  9076. return retXML;
  9077. }
  9078. //iMAP check_lobby_passwd 처리
  9079. public String CheckPassword(Document doc) {
  9080. NodeList items = doc.getElementsByTagName("inpasswd");
  9081. Node item = items.item(0);
  9082. Node text = item.getFirstChild();
  9083. String passwd = trimquotation(text.getNodeValue());
  9084. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9085. String settedpasswd = DBMGR.GetUserPW();
  9086. DBMGR.closeDB();
  9087. String retString = XMLHeader;
  9088. Common.DebugLog("================ CheckPassword ================ ");
  9089. Common.DebugLog("Saved Password :" + settedpasswd);
  9090. Common.DebugLog("Input Password :" + passwd);
  9091. Common.DebugLog("================ CheckPassword ================ ");
  9092. if (settedpasswd.equals(passwd)) {
  9093. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  9094. } else {
  9095. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>" + passwd + "</wrongpasswd>\r\n</service>";
  9096. }
  9097. retString += "</imap>";
  9098. return retString;
  9099. }
  9100. //schedule_renew 처리
  9101. protected String ProcSchduleRenew(Document doc) {
  9102. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n " +
  9103. "<homeaddr dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" /> \r\n </service> \r\n </imap>";
  9104. WallpadScheduleData schedulDB = null;
  9105. try {
  9106. NodeList items = doc.getElementsByTagName("renew_info");
  9107. schedulDB = new WallpadScheduleData(getApplicationContext());
  9108. for (int i = 0; i < items.getLength(); i++) {
  9109. Node item = items.item(i);
  9110. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  9111. NamedNodeMap attrsParam = item.getAttributes();
  9112. String Type = "none";
  9113. for (int j = 0; j < attrsParam.getLength(); j++) {
  9114. Node attr = attrsParam.item(j);
  9115. String name = attr.getNodeName();
  9116. String Val = attr.getNodeValue();
  9117. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  9118. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  9119. else if (name.equalsIgnoreCase("rn_type"))
  9120. Type = Val;
  9121. else if (name.equalsIgnoreCase("rn_t_type"))
  9122. SCdata.inqttype = Val;
  9123. else if (name.equalsIgnoreCase("rn_c_type"))
  9124. SCdata.inqctype = Val;
  9125. else if (name.equalsIgnoreCase("rn_a_type"))
  9126. SCdata.inqatype = Val;
  9127. else if (name.equalsIgnoreCase("rn_i_type"))
  9128. SCdata.inqitype = Val;
  9129. else if (name.equalsIgnoreCase("rn_year"))
  9130. SCdata.inqyear = Integer.parseInt(Val);
  9131. else if (name.equalsIgnoreCase("rn_month"))
  9132. SCdata.inqmonth = Integer.parseInt(Val);
  9133. else if (name.equalsIgnoreCase("rn_day"))
  9134. SCdata.inqday = Integer.parseInt(Val);
  9135. else if (name.equalsIgnoreCase("rn_hour"))
  9136. SCdata.inqhour = Integer.parseInt(Val);
  9137. else if (name.equalsIgnoreCase("rn_message"))
  9138. SCdata.inqmsg = Val;
  9139. }
  9140. if (Type.equals("delete")) {
  9141. schedulDB.DeleteSchedule(SCdata);
  9142. } else if (Type.equals("add")) {
  9143. schedulDB.AddSchedule(SCdata);
  9144. } else if (Type.equals("change")) {
  9145. schedulDB.UpdateSchedule(SCdata);
  9146. }
  9147. }
  9148. schedulDB.closeDB();
  9149. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  9150. // Intent intent = new Intent();
  9151. // intent.setAction(define.NOTIFY_ACNAME);
  9152. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9153. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  9154. // getApplicationContext().sendBroadcast(intent);
  9155. } catch (RuntimeException re) {
  9156. LogUtil.errorLogInfo("", TAG, re);
  9157. if (schedulDB != null) schedulDB.closeDB();
  9158. } catch (Exception e) {
  9159. //e.printStackTrace();
  9160. LogUtil.errorLogInfo("", TAG, e);
  9161. if (schedulDB != null) schedulDB.closeDB();
  9162. }
  9163. return retXML;
  9164. }
  9165. //schedule_inquiry 처리
  9166. @SuppressWarnings("unused")
  9167. public String ProcSchduleInquiry(Document doc) {
  9168. WallpadScheduleData schedulDB = null;
  9169. String retXML;
  9170. int QYear = 0;
  9171. int QMonth = 0;
  9172. try {
  9173. NodeList items = doc.getElementsByTagName("inquiry_time");
  9174. schedulDB = new WallpadScheduleData(getApplicationContext());
  9175. Node item = items.item(0);
  9176. NamedNodeMap attrsParam = item.getAttributes();
  9177. for (int j = 0; j < attrsParam.getLength(); j++) {
  9178. Node attr = attrsParam.item(j);
  9179. if (attr.getNodeName().equalsIgnoreCase("year"))
  9180. QYear = Integer.parseInt(attr.getNodeValue());
  9181. else if (attr.getNodeName().equalsIgnoreCase("month"))
  9182. QMonth = Integer.parseInt(attr.getNodeValue());
  9183. }
  9184. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  9185. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9186. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9187. " <inquiry_time year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9188. " <inquiry_count>" + SCData.size() + "</inquiry_count>\r\n";
  9189. if (SCData != null) {
  9190. if (SCData.size() > 0) {
  9191. for (int i = 0; i < SCData.size(); i++) {
  9192. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  9193. 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=\"" +
  9194. SCINQDATA.inqyear + "\" inq_month=\"" + SCINQDATA.inqmonth + "\" inq_day=\"" + SCINQDATA.inqday + "\" inq_hour=\"" + SCINQDATA.inqhour + "\" inq_message=\"" + SCINQDATA.inqmsg + "\"/>\r\n";
  9195. }
  9196. }
  9197. retXML += "</service>\r\n</imap>";
  9198. } else {
  9199. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9200. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9201. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9202. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9203. }
  9204. } catch (RuntimeException re) {
  9205. LogUtil.errorLogInfo("", TAG, re);
  9206. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9207. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9208. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9209. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9210. } catch (Exception e) {
  9211. //e.printStackTrace();
  9212. LogUtil.errorLogInfo("", TAG, e);
  9213. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9214. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9215. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9216. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9217. }
  9218. schedulDB.closeDB();
  9219. return retXML;
  9220. }
  9221. public String ProcUpdateSchedule(Element ele, String type) {
  9222. String retXML = "";
  9223. return retXML;
  9224. }
  9225. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  9226. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  9227. private void setDefaultLauncher() {
  9228. try {
  9229. PackageManager pm = getPackageManager();
  9230. IntentFilter filter = new IntentFilter();
  9231. filter.addAction(Intent.ACTION_MAIN);
  9232. filter.addCategory(Intent.CATEGORY_HOME);
  9233. filter.addCategory(Intent.CATEGORY_DEFAULT);
  9234. Context context = getApplicationContext();
  9235. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  9236. ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  9237. pm.clearPackagePreferredActivities("com.android.launcher");
  9238. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  9239. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  9240. try {
  9241. Thread.sleep(300);
  9242. } catch (RuntimeException re) {
  9243. LogUtil.errorLogInfo("", TAG, re);
  9244. } catch (Exception e) {
  9245. LogUtil.errorLogInfo("", TAG, e);
  9246. }
  9247. // 리셋코드 추가
  9248. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  9249. try {
  9250. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9251. powerMg.reboot(null);
  9252. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  9253. } catch (RuntimeException re) {
  9254. LogUtil.errorLogInfo("", TAG, re);
  9255. } catch (Exception e) {
  9256. //e.printStackTrace();
  9257. LogUtil.errorLogInfo("", TAG, e);
  9258. }
  9259. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  9260. } catch (RuntimeException re) {
  9261. LogUtil.errorLogInfo("", TAG, re);
  9262. } catch (Exception e) {
  9263. //e.printStackTrace();
  9264. LogUtil.errorLogInfo("", TAG, e);
  9265. }
  9266. }
  9267. public String ProcDeviceReset(Element ele) {
  9268. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  9269. "</imap>\r\n";
  9270. NodeList resettype = ele.getElementsByTagName("guidemap");
  9271. Node resettypeItem = resettype.item(0);
  9272. String type = GetAttributeVal(resettypeItem, "type");
  9273. if (type != null) {
  9274. if (type.equals("now")) {
  9275. setDefaultLauncher();
  9276. Intent intent = new Intent();
  9277. intent.setAction(define.NOTIFY_ACNAME);
  9278. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  9279. getApplicationContext().sendBroadcast(intent);
  9280. } else if (type.equals("disable")) {
  9281. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9282. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
  9283. SetReset.closeDB();
  9284. } else if (type.equals("week") || type.equals("month")) {
  9285. int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
  9286. NodeList periodList = ele.getElementsByTagName("period");
  9287. Node perioditem = periodList.item(0);
  9288. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  9289. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  9290. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9291. SetReset.SetResetSchedule(Resettype, cycle, time);
  9292. SetReset.closeDB();
  9293. }
  9294. }
  9295. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  9296. // Intent intent = new Intent();
  9297. // intent.setAction(define.NOTIFY_ACNAME);
  9298. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9299. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  9300. // getApplicationContext().sendBroadcast(intent);
  9301. return retXML;
  9302. }
  9303. public String ProcDeviceLiveCheck() {
  9304. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  9305. return retXML;
  9306. }
  9307. public String ProcPairingHdevSyncAlarm(Element ele) {
  9308. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  9309. return retXML;
  9310. }
  9311. public String ProcPairingHdevSyncSecurity(Element ele) {
  9312. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  9313. return retXML;
  9314. }
  9315. public String ProcParkInformation(Element ele) {
  9316. try {
  9317. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  9318. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  9319. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  9320. NodeList items = ele.getElementsByTagName("destination");
  9321. Node item = items.item(0);
  9322. Node text;
  9323. NamedNodeMap attrsParam = item.getAttributes();
  9324. for (int j = 0; j < attrsParam.getLength(); j++) {
  9325. Node attr = attrsParam.item(j);
  9326. if (attr.getNodeName().equalsIgnoreCase("name"))
  9327. strName = trimquotation(attr.getNodeValue());
  9328. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9329. strDong = trimquotation(attr.getNodeValue());
  9330. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9331. strHo = trimquotation(attr.getNodeValue());
  9332. }
  9333. items = ele.getElementsByTagName("move_info");
  9334. item = items.item(0);
  9335. text = item.getFirstChild();
  9336. strCarMove = trimquotation(text.getNodeValue());
  9337. items = ele.getElementsByTagName("params");
  9338. item = items.item(0);
  9339. attrsParam = item.getAttributes();
  9340. for (int j = 0; j < attrsParam.getLength(); j++) {
  9341. Node attr = attrsParam.item(j);
  9342. if (attr.getNodeName().equalsIgnoreCase("car_num"))
  9343. strCarNo = trimquotation(attr.getNodeValue());
  9344. else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
  9345. strCarLocation = trimquotation(attr.getNodeValue());
  9346. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9347. strMsg = trimquotation(attr.getNodeValue());
  9348. }
  9349. if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
  9350. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  9351. try {
  9352. int iTempDong = Integer.parseInt(AddrDong);
  9353. String sTempDong = Integer.toString(iTempDong);
  9354. int iTempHo = Integer.parseInt(AddrHo);
  9355. String sTempHo = Integer.toString(iTempHo);
  9356. if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  9357. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9358. } else {
  9359. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9360. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9361. return retXML;
  9362. }
  9363. } catch (RuntimeException re) {
  9364. LogUtil.errorLogInfo("", TAG, re);
  9365. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9366. return retXML;
  9367. } catch (Exception e) {
  9368. //e.printStackTrace();
  9369. LogUtil.errorLogInfo("", TAG, e);
  9370. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9371. return retXML;
  9372. }
  9373. //DB정보 업데이트!
  9374. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9375. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  9376. CarDB.closeDB();
  9377. //DB정보 업데이트!
  9378. if (strCarMove.equalsIgnoreCase("in")) {
  9379. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9380. // 팝업을 띄우도록 하자
  9381. wakeupLCD();
  9382. if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
  9383. Intent iIntent = new Intent();
  9384. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9385. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9386. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  9387. getApplicationContext().sendBroadcast(iIntent);
  9388. } else {
  9389. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9390. }
  9391. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  9392. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  9393. }
  9394. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  9395. if (strCarMove.equalsIgnoreCase("park")) {
  9396. //주차정보 얻어오도록 intent 알림
  9397. SendGetParkingInfoIntent();
  9398. }
  9399. } else {
  9400. //주차정보 얻어오도록 intent 알림
  9401. SendGetParkingInfoIntent();
  9402. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  9403. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  9404. }
  9405. return retXML;
  9406. } catch (RuntimeException re) {
  9407. LogUtil.errorLogInfo("", TAG, re);
  9408. return null;
  9409. } catch (Exception e) {
  9410. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  9411. //e.printStackTrace();
  9412. LogUtil.errorLogInfo("", TAG, e);
  9413. return null;
  9414. }
  9415. }
  9416. /**
  9417. * 스마트키 이벤트 수신시 처리
  9418. **/
  9419. public String ProcSmartKeyEvent(Element ele) {
  9420. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  9421. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  9422. String strName = null, strDong = null, strHo = null, strCnt = null;
  9423. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  9424. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  9425. NodeList items = ele.getElementsByTagName("destination");
  9426. Node item = items.item(0);
  9427. NamedNodeMap attrsParam = item.getAttributes();
  9428. for (int j = 0; j < attrsParam.getLength(); j++) {
  9429. Node attr = attrsParam.item(j);
  9430. if (attr.getNodeName().equalsIgnoreCase("name"))
  9431. strName = trimquotation(attr.getNodeValue());
  9432. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9433. strDong = trimquotation(attr.getNodeValue());
  9434. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9435. strHo = trimquotation(attr.getNodeValue());
  9436. }
  9437. items = ele.getElementsByTagName("event_info");
  9438. item = items.item(0);
  9439. attrsParam = item.getAttributes();
  9440. for (int j = 0; j < attrsParam.getLength(); j++) {
  9441. Node attr = attrsParam.item(j);
  9442. if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
  9443. strCnt = trimquotation(attr.getNodeValue());
  9444. }
  9445. items = ele.getElementsByTagName("event");
  9446. item = items.item(0);
  9447. attrsParam = item.getAttributes();
  9448. for (int j = 0; j < attrsParam.getLength(); j++) {
  9449. Node attr = attrsParam.item(j);
  9450. if (attr.getNodeName().equalsIgnoreCase("event_type"))
  9451. strEventType = trimquotation(attr.getNodeValue());
  9452. else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
  9453. strEventTriggerType = trimquotation(attr.getNodeValue());
  9454. else if (attr.getNodeName().equalsIgnoreCase("uid"))
  9455. strEventUID = trimquotation(attr.getNodeValue());
  9456. else if (attr.getNodeName().equalsIgnoreCase("sn"))
  9457. strEventSN = trimquotation(attr.getNodeValue());
  9458. else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
  9459. strEventSitecode = trimquotation(attr.getNodeValue());
  9460. else if (attr.getNodeName().equalsIgnoreCase("dong"))
  9461. strEventDong = trimquotation(attr.getNodeValue());
  9462. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9463. strEventHo = trimquotation(attr.getNodeValue());
  9464. else if (attr.getNodeName().equalsIgnoreCase("card_num"))
  9465. strEventCardNo = trimquotation(attr.getNodeValue());
  9466. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
  9467. strEventIssueCnt = trimquotation(attr.getNodeValue());
  9468. else if (attr.getNodeName().equalsIgnoreCase("card_type"))
  9469. strEventCardType = trimquotation(attr.getNodeValue());
  9470. else if (attr.getNodeName().equalsIgnoreCase("location"))
  9471. strEventLocation = trimquotation(attr.getNodeValue());
  9472. }
  9473. if (strName != null && strDong != null && strHo != null && strCnt != null)
  9474. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  9475. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  9476. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  9477. if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
  9478. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  9479. } else {
  9480. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  9481. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9482. return retXML;
  9483. }
  9484. //데이터가 null인지 확인
  9485. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  9486. return retXML;
  9487. }
  9488. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  9489. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9490. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9491. wakeupLCD();
  9492. // 팝업을 띄우도록 하자
  9493. String CardNum = "";
  9494. try {
  9495. int iEvent_Dong = Integer.parseInt(strEventDong);
  9496. CardNum += String.format("%04d", iEvent_Dong);
  9497. int iEvent_Ho = Integer.parseInt(strEventHo);
  9498. CardNum += String.format("%04d", iEvent_Ho);
  9499. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  9500. CardNum += String.format("%03d", iEvent_CardNum);
  9501. } catch (RuntimeException re) {
  9502. LogUtil.errorLogInfo("", TAG, re);
  9503. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9504. return retXML;
  9505. } catch (Exception e) {
  9506. //e.printStackTrace();
  9507. LogUtil.errorLogInfo("", TAG, e);
  9508. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9509. return retXML;
  9510. }
  9511. Intent iIntent = new Intent();
  9512. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9513. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  9514. iIntent.putExtra("LOCATION", strEventLocation);
  9515. iIntent.putExtra("CARD_NO", CardNum);
  9516. getApplicationContext().sendBroadcast(iIntent);
  9517. }
  9518. }
  9519. } else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  9520. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9521. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9522. int nCardNum;
  9523. try {
  9524. nCardNum = Integer.parseInt(strEventCardNo);
  9525. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  9526. } catch (RuntimeException re) {
  9527. LogUtil.errorLogInfo("", TAG, re);
  9528. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9529. return retXML;
  9530. } catch (Exception e) {
  9531. //e.printStackTrace();
  9532. LogUtil.errorLogInfo("", TAG, e);
  9533. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9534. return retXML;
  9535. }
  9536. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9537. boolean bBandUse = deviceSet.getBandLocationUsage();
  9538. deviceSet.closeDB();
  9539. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  9540. wakeupLCD();
  9541. Intent iIntent = new Intent();
  9542. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9543. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  9544. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  9545. getApplicationContext().sendBroadcast(iIntent);
  9546. }
  9547. }
  9548. }
  9549. }
  9550. return retXML;
  9551. }
  9552. public String ProcParkInformation_cham_upis(Element ele) {
  9553. Log.d(TAG, "ProcParkInformation_cham_upis START");
  9554. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  9555. String infoName = null;
  9556. String infoDong = null;
  9557. String infoHo = null;
  9558. String infoCarMove = null;
  9559. String infoCarnum = null;
  9560. String infoCarLocation = null;
  9561. String infoMessage = null;
  9562. NodeList items = ele.getElementsByTagName("home_info");
  9563. Node item = items.item(0);
  9564. Node text;
  9565. NamedNodeMap attrsParam = item.getAttributes();
  9566. for (int j = 0; j < attrsParam.getLength(); j++) {
  9567. Node attr = attrsParam.item(j);
  9568. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9569. infoDong = trimquotation(attr.getNodeValue());
  9570. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9571. infoHo = trimquotation(attr.getNodeValue());
  9572. }
  9573. items = ele.getElementsByTagName("park_info");
  9574. item = items.item(0);
  9575. attrsParam = item.getAttributes();
  9576. for (int j = 0; j < attrsParam.getLength(); j++) {
  9577. Node attr = attrsParam.item(j);
  9578. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  9579. infoCarnum = trimquotation(attr.getNodeValue());
  9580. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  9581. infoCarLocation = trimquotation(attr.getNodeValue());
  9582. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9583. infoMessage = trimquotation(attr.getNodeValue());
  9584. }
  9585. Log.d(TAG, "ProcParkInformation infoName :" + infoName);
  9586. if (infoDong != null)
  9587. Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
  9588. Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
  9589. Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
  9590. Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
  9591. Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
  9592. Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
  9593. if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  9594. (infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
  9595. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9596. } else {
  9597. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9598. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  9599. return retXML;
  9600. }
  9601. infoCarMove = "park";
  9602. //DB정보 업데이트!
  9603. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9604. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  9605. CarDB.closeDB();
  9606. //DB정보 업데이트!
  9607. Intent iIntent = new Intent();
  9608. iIntent.setAction(define.NOTIFY_ACNAME);
  9609. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  9610. this.sendBroadcast(iIntent);
  9611. /*
  9612. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  9613. {
  9614. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9615. // 팝업을 띄우도록 하자
  9616. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9617. }
  9618. */
  9619. return retXML;
  9620. }
  9621. public String ProcGetSmartKeyInfo(Element ele) {
  9622. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  9623. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  9624. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  9625. NodeList items = ele.getElementsByTagName("info_type");
  9626. Node item = items.item(0);
  9627. Node text = item.getFirstChild();
  9628. String sInfo_type = trimquotation(text.getNodeValue());
  9629. String sCard_info = null;
  9630. String sMessage = null;
  9631. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  9632. {
  9633. items = ele.getElementsByTagName("uid_info");
  9634. item = items.item(0);
  9635. text = item.getFirstChild();
  9636. sCard_info = trimquotation(text.getNodeValue());
  9637. //==============================================//
  9638. items = ele.getElementsByTagName("message");
  9639. item = items.item(0);
  9640. text = item.getFirstChild();
  9641. sMessage = trimquotation(text.getNodeValue());
  9642. //==============================================//
  9643. //쿼리문 작성
  9644. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9645. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9646. for (int i = 0; i < SyncData.size(); i++) {
  9647. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  9648. NewData.add(SyncData.get(i));
  9649. }
  9650. }
  9651. wallpadSmartKeyRegData.closeDB();
  9652. } else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  9653. {
  9654. items = ele.getElementsByTagName("sn_info");
  9655. item = items.item(0);
  9656. text = item.getFirstChild();
  9657. sCard_info = trimquotation(text.getNodeValue());
  9658. //==============================================//
  9659. items = ele.getElementsByTagName("message");
  9660. item = items.item(0);
  9661. text = item.getFirstChild();
  9662. sMessage = trimquotation(text.getNodeValue());
  9663. //==============================================//
  9664. //쿼리문 작성
  9665. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9666. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9667. for (int i = 0; i < SyncData.size(); i++) {
  9668. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  9669. NewData.add(SyncData.get(i));
  9670. }
  9671. }
  9672. wallpadSmartKeyRegData.closeDB();
  9673. } else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  9674. {
  9675. items = ele.getElementsByTagName("uid_info");
  9676. item = items.item(0);
  9677. text = item.getFirstChild();
  9678. sCard_info = trimquotation(text.getNodeValue());
  9679. //==============================================//
  9680. items = ele.getElementsByTagName("message");
  9681. item = items.item(0);
  9682. text = item.getFirstChild();
  9683. sMessage = trimquotation(text.getNodeValue());
  9684. //==============================================//
  9685. //쿼리문 작성
  9686. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9687. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9688. for (int i = 0; i < SyncData.size(); i++) {
  9689. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  9690. NewData.add(SyncData.get(i));
  9691. }
  9692. }
  9693. if (NewData.size() > 0) {
  9694. NewData = SyncData;
  9695. }
  9696. wallpadSmartKeyRegData.closeDB();
  9697. } else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  9698. {
  9699. items = ele.getElementsByTagName("sn_info");
  9700. item = items.item(0);
  9701. text = item.getFirstChild();
  9702. sCard_info = trimquotation(text.getNodeValue());
  9703. //==============================================//
  9704. items = ele.getElementsByTagName("message");
  9705. item = items.item(0);
  9706. text = item.getFirstChild();
  9707. sMessage = trimquotation(text.getNodeValue());
  9708. //==============================================//
  9709. //쿼리문 작성
  9710. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9711. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9712. for (int i = 0; i < SyncData.size(); i++) {
  9713. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  9714. NewData.add(SyncData.get(i));
  9715. }
  9716. }
  9717. if (NewData.size() > 0) {
  9718. NewData = SyncData;
  9719. }
  9720. wallpadSmartKeyRegData.closeDB();
  9721. } else if (sInfo_type.equalsIgnoreCase("hkey")) {
  9722. String dong = "";
  9723. String ho = "";
  9724. String Num = "all";
  9725. //==============================================//
  9726. items = ele.getElementsByTagName("message");
  9727. item = items.item(0);
  9728. text = item.getFirstChild();
  9729. sMessage = trimquotation(text.getNodeValue());
  9730. //==============================================//
  9731. items = ele.getElementsByTagName("hkey_info");
  9732. item = items.item(0);
  9733. if (item == null)
  9734. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9735. NamedNodeMap attrsParam = item.getAttributes();
  9736. for (int j = 0; j < attrsParam.getLength(); j++) {
  9737. Node attr = attrsParam.item(j);
  9738. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9739. dong = attr.getNodeValue();
  9740. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9741. ho = attr.getNodeValue();
  9742. else if (attr.getNodeName().equalsIgnoreCase("num"))
  9743. Num = attr.getNodeValue();
  9744. }
  9745. if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
  9746. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
  9747. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9748. }
  9749. //쿼리문 작성
  9750. int intNum = 0;
  9751. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9752. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9753. for (int i = 0; i < SyncData.size(); i++) {
  9754. if (Num.equalsIgnoreCase("all") == true) {
  9755. NewData.add(SyncData.get(i));
  9756. } else {
  9757. try {
  9758. intNum = Integer.parseInt(Num);
  9759. } catch (RuntimeException re) {
  9760. LogUtil.errorLogInfo("", TAG, re);
  9761. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9762. } catch (Exception e) {
  9763. //e.printStackTrace();
  9764. LogUtil.errorLogInfo("", TAG, e);
  9765. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9766. }
  9767. if (SyncData.get(i).id == intNum) {
  9768. NewData.add(SyncData.get(i));
  9769. }
  9770. }
  9771. }
  9772. wallpadSmartKeyRegData.closeDB();
  9773. } else if (sInfo_type.equalsIgnoreCase("dkey")) {
  9774. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  9775. } else if (sInfo_type.equalsIgnoreCase("mkey")) {
  9776. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  9777. }
  9778. if (NewData.size() == 0) {
  9779. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  9780. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  9781. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  9782. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  9783. retXML += " </service>\r\n</imap>";
  9784. return retXML;
  9785. }
  9786. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  9787. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  9788. for (int i = 0; i < NewData.size(); i++) {
  9789. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  9790. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  9791. String strFormat = sFormat.format(date);
  9792. retXML += " <key_info index = \"" + NewData.get(i).id + "\" "
  9793. + "sn = \"" + NewData.get(i).SerialNumber + "\" "
  9794. + "uid = \"" + NewData.get(i).Uid + "\" "
  9795. + "key_num = \"" + NewData.get(i).id + "\" "
  9796. + "issue_cnt = \"" + 1 + "\" "
  9797. + "issued_date = \"" + strFormat + "\" "
  9798. + "message = \"" + "null" + "\" "
  9799. + "/>\r\n";
  9800. }
  9801. retXML += " </service>\r\n</imap>";
  9802. return retXML;
  9803. }
  9804. public void ProcMobileDevice_AuthNumber(Element ele) {
  9805. String sDong = null;
  9806. String sHo = null;
  9807. String sIP = null;
  9808. String sType = null;
  9809. String sDevice_Name = null;
  9810. String sTwinID = null;
  9811. String sAuthNumber = null;
  9812. try {
  9813. NodeList items = ele.getElementsByTagName("home_info");
  9814. Node item = items.item(0);
  9815. NamedNodeMap attrsParam = item.getAttributes();
  9816. for (int i = 0; i < attrsParam.getLength(); i++) {
  9817. Node attr = attrsParam.item(i);
  9818. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9819. sDong = trimquotation(attr.getNodeValue());
  9820. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9821. sHo = trimquotation(attr.getNodeValue());
  9822. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  9823. sIP = trimquotation(attr.getNodeValue());
  9824. else if (attr.getNodeName().equalsIgnoreCase("type"))
  9825. sType = trimquotation(attr.getNodeValue());
  9826. }
  9827. WallpadStatusData DBMGR = null;
  9828. DBMGR = new WallpadStatusData(getApplicationContext());
  9829. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9830. DBMGR.closeDB();
  9831. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  9832. items = ele.getElementsByTagName("device_info");
  9833. item = items.item(0);
  9834. attrsParam = item.getAttributes();
  9835. for (int i = 0; i < attrsParam.getLength(); i++) {
  9836. Node attr = attrsParam.item(i);
  9837. if (attr.getNodeName().equalsIgnoreCase("alias"))
  9838. sDevice_Name = trimquotation(attr.getNodeValue());
  9839. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  9840. sTwinID = trimquotation(attr.getNodeValue());
  9841. else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
  9842. sAuthNumber = trimquotation(attr.getNodeValue());
  9843. }
  9844. /**데이터 전달**/
  9845. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9846. Log.d(TAG, "sTwinID :" + sTwinID);
  9847. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  9848. Intent intent = new Intent();
  9849. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  9850. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  9851. intent.putExtra("AuthNumber", sAuthNumber);
  9852. if (NewServerUse()) {
  9853. getApplicationContext().sendBroadcast(intent);
  9854. }
  9855. } else {
  9856. }
  9857. } catch (RuntimeException re) {
  9858. LogUtil.errorLogInfo("", TAG, re);
  9859. } catch (Exception e) {
  9860. //e.printStackTrace();
  9861. LogUtil.errorLogInfo("", TAG, e);
  9862. }
  9863. }
  9864. public String ProcMobileDevice_ADD_Finish(Element ele) {
  9865. String retXML = "";
  9866. String sDong = null;
  9867. String sHo = null;
  9868. String sIP = null;
  9869. String sType = null;
  9870. String sDevice_Name = null;
  9871. String sTwinID = null;
  9872. try {
  9873. NodeList items = ele.getElementsByTagName("home_info");
  9874. Node item = items.item(0);
  9875. NamedNodeMap attrsParam = item.getAttributes();
  9876. for (int i = 0; i < attrsParam.getLength(); i++) {
  9877. Node attr = attrsParam.item(i);
  9878. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9879. sDong = trimquotation(attr.getNodeValue());
  9880. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9881. sHo = trimquotation(attr.getNodeValue());
  9882. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  9883. sIP = trimquotation(attr.getNodeValue());
  9884. else if (attr.getNodeName().equalsIgnoreCase("type"))
  9885. sType = trimquotation(attr.getNodeValue());
  9886. }
  9887. WallpadStatusData DBMGR = null;
  9888. DBMGR = new WallpadStatusData(getApplicationContext());
  9889. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9890. DBMGR.closeDB();
  9891. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  9892. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  9893. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  9894. items = ele.getElementsByTagName("device_info");
  9895. item = items.item(0);
  9896. attrsParam = item.getAttributes();
  9897. for (int i = 0; i < attrsParam.getLength(); i++) {
  9898. Node attr = attrsParam.item(i);
  9899. if (attr.getNodeName().equalsIgnoreCase("alias"))
  9900. sDevice_Name = trimquotation(attr.getNodeValue());
  9901. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  9902. sTwinID = trimquotation(attr.getNodeValue());
  9903. }
  9904. /**데이터 전달**/
  9905. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9906. Log.d(TAG, "sTwinID :" + sTwinID);
  9907. Intent intent = new Intent();
  9908. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  9909. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  9910. if (NewServerUse()) {
  9911. getApplicationContext().sendBroadcast(intent);
  9912. } else {
  9913. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9914. retXML += " </service>\r\n</imap>";
  9915. return retXML;
  9916. }
  9917. String tempType = "main";
  9918. //DB에 저장 필요
  9919. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  9920. if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  9921. {
  9922. wallpadMobileDeviceData.closeDB();
  9923. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9924. retXML += " </service>\r\n</imap>";
  9925. return retXML;
  9926. }
  9927. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  9928. wallpadMobileDeviceData.closeDB();
  9929. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  9930. retXML += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" ip=\"" + addc.IPAddress + "\" type=\"" + tempType + "\"/>\r\n";
  9931. retXML += " <device_info alias=\"" + sDevice_Name + "\" twinid=\"" + sTwinID + "\" />\r\n";
  9932. retXML += " </service>\r\n</imap>";
  9933. return retXML;
  9934. } else {
  9935. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9936. retXML += " </service>\r\n</imap>";
  9937. return retXML;
  9938. }
  9939. } catch (RuntimeException re) {
  9940. LogUtil.errorLogInfo("", TAG, re);
  9941. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9942. retXML += " </service>\r\n</imap>";
  9943. return retXML;
  9944. } catch (Exception e) {
  9945. //e.printStackTrace();
  9946. LogUtil.errorLogInfo("", TAG, e);
  9947. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9948. retXML += " </service>\r\n</imap>";
  9949. return retXML;
  9950. }
  9951. }
  9952. public void ProcMobileDevice_Delete(Element ele) {
  9953. String sDong = null;
  9954. String sHo = null;
  9955. String sIP = null;
  9956. String sType = null;
  9957. String sDevice_Name = null;
  9958. String sTwinID = null;
  9959. Log.d(TAG, "ProcMobileDevice_Delete");
  9960. try {
  9961. NodeList items = ele.getElementsByTagName("home_info");
  9962. Node item = items.item(0);
  9963. NamedNodeMap attrsParam = item.getAttributes();
  9964. for (int i = 0; i < attrsParam.getLength(); i++) {
  9965. Node attr = attrsParam.item(i);
  9966. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9967. sDong = trimquotation(attr.getNodeValue());
  9968. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9969. sHo = trimquotation(attr.getNodeValue());
  9970. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  9971. sIP = trimquotation(attr.getNodeValue());
  9972. else if (attr.getNodeName().equalsIgnoreCase("type"))
  9973. sType = trimquotation(attr.getNodeValue());
  9974. }
  9975. WallpadStatusData DBMGR = null;
  9976. DBMGR = new WallpadStatusData(getApplicationContext());
  9977. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9978. DBMGR.closeDB();
  9979. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  9980. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  9981. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  9982. if (NewServerUse()) {
  9983. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  9984. items = ele.getElementsByTagName("device_info");
  9985. for (int i = 0; i < items.getLength(); i++) {
  9986. item = items.item(i);
  9987. attrsParam = item.getAttributes();
  9988. for (int j = 0; j < attrsParam.getLength(); j++) {
  9989. Node attr = attrsParam.item(j);
  9990. if (attr.getNodeName().equalsIgnoreCase("alias"))
  9991. sDevice_Name = trimquotation(attr.getNodeValue());
  9992. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  9993. sTwinID = trimquotation(attr.getNodeValue());
  9994. }
  9995. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9996. Log.d(TAG, "sTwinID :" + sTwinID);
  9997. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  9998. }
  9999. wallpadMobileDeviceData.closeDB();
  10000. Intent intent = new Intent();
  10001. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  10002. getApplicationContext().sendBroadcast(intent);
  10003. }
  10004. } else {
  10005. }
  10006. } catch (RuntimeException re) {
  10007. LogUtil.errorLogInfo("", TAG, re);
  10008. } catch (Exception e) {
  10009. //e.printStackTrace();
  10010. LogUtil.errorLogInfo("", TAG, e);
  10011. }
  10012. }
  10013. public String ProcGetAppVersionInfo() {
  10014. String retXML = "";
  10015. MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
  10016. int AppCount;
  10017. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  10018. retXML = XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  10019. retXML += " <home_info dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\" platform=\"Android\" count=\"" + AppCount + "\" />\r\n";
  10020. for (int i = 0; i < AppCount; i++) {
  10021. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
  10022. if (getString != null) {
  10023. retXML += " <app_list name=\"" + getString[0] + "\" version=\"" + getString[1] + "\" />\r\n";
  10024. }
  10025. }
  10026. retXML += " </service>\r\n</imap>";
  10027. return retXML;
  10028. }
  10029. public String ProcIgateInitInfo(Element ele) {
  10030. String retXML = "";
  10031. String ctrl_baudrate = "";
  10032. String ctrl_open = "";
  10033. String ctrl_framecheck = "";
  10034. String ctrl_message = "";
  10035. String eth_mode = "";
  10036. String eth_ip = "";
  10037. String eth_mac = "";
  10038. String eth_gw = "";
  10039. String eth_sm = "";
  10040. String noti_send = "";
  10041. String noti_level = "";
  10042. String noti_ip = "";
  10043. String noti_port = "";
  10044. try {
  10045. NodeList items = ele.getElementsByTagName("ctrl_param");
  10046. Node item = items.item(0);
  10047. NamedNodeMap attrsParam = item.getAttributes();
  10048. for (int i = 0; i < attrsParam.getLength(); i++) {
  10049. Node attr = attrsParam.item(i);
  10050. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  10051. ctrl_baudrate = trimquotation(attr.getNodeValue());
  10052. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  10053. ctrl_open = trimquotation(attr.getNodeValue());
  10054. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  10055. ctrl_framecheck = trimquotation(attr.getNodeValue());
  10056. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  10057. ctrl_message = trimquotation(attr.getNodeValue());
  10058. }
  10059. items = ele.getElementsByTagName("eth_param");
  10060. item = items.item(0);
  10061. attrsParam = item.getAttributes();
  10062. for (int i = 0; i < attrsParam.getLength(); i++) {
  10063. Node attr = attrsParam.item(i);
  10064. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  10065. eth_mode = trimquotation(attr.getNodeValue());
  10066. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  10067. eth_ip = trimquotation(attr.getNodeValue());
  10068. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  10069. eth_mac = trimquotation(attr.getNodeValue());
  10070. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  10071. eth_gw = trimquotation(attr.getNodeValue());
  10072. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  10073. eth_sm = trimquotation(attr.getNodeValue());
  10074. }
  10075. items = ele.getElementsByTagName("noti_param");
  10076. item = items.item(0);
  10077. attrsParam = item.getAttributes();
  10078. for (int i = 0; i < attrsParam.getLength(); i++) {
  10079. Node attr = attrsParam.item(i);
  10080. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  10081. noti_send = trimquotation(attr.getNodeValue());
  10082. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  10083. noti_level = trimquotation(attr.getNodeValue());
  10084. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  10085. noti_ip = trimquotation(attr.getNodeValue());
  10086. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  10087. noti_port = trimquotation(attr.getNodeValue());
  10088. }
  10089. wallpaddbmgr WallpadDBMGR = null;
  10090. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  10091. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  10092. if (RowCount_GatewayData > 100) {
  10093. WallpadDBMGR.DeleteLH_GatewayData("50");
  10094. }
  10095. 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);
  10096. WallpadDBMGR.closeDB();
  10097. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  10098. retXML += " </service>\r\n</imap>";
  10099. return retXML;
  10100. } catch (RuntimeException re) {
  10101. LogUtil.errorLogInfo("", TAG, re);
  10102. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10103. retXML += " </service>\r\n</imap>";
  10104. return retXML;
  10105. } catch (Exception e) {
  10106. //e.printStackTrace();
  10107. LogUtil.errorLogInfo("", TAG, e);
  10108. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10109. retXML += " </service>\r\n</imap>";
  10110. return retXML;
  10111. }
  10112. }
  10113. public String ProcElecCarChargeEventInfo(Element ele) {
  10114. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  10115. String retXML = "";
  10116. String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  10117. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  10118. try {
  10119. NodeList items = ele.getElementsByTagName("destination");
  10120. Node item = items.item(0);
  10121. NamedNodeMap attrsParam = item.getAttributes();
  10122. for (int i = 0; i < attrsParam.getLength(); i++) {
  10123. Node attr = attrsParam.item(i);
  10124. if (attr.getNodeName().equalsIgnoreCase("name"))
  10125. sName = trimquotation(attr.getNodeValue());
  10126. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10127. sId_High = trimquotation(attr.getNodeValue());
  10128. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10129. sId_Low = trimquotation(attr.getNodeValue());
  10130. }
  10131. WallpadStatusData DBMGR = null;
  10132. DBMGR = new WallpadStatusData(getApplicationContext());
  10133. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10134. DBMGR.closeDB();
  10135. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  10136. items = ele.getElementsByTagName("charging_info");
  10137. item = items.item(0);
  10138. attrsParam = item.getAttributes();
  10139. for (int i = 0; i < attrsParam.getLength(); i++) {
  10140. Node attr = attrsParam.item(i);
  10141. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  10142. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  10143. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  10144. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  10145. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  10146. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  10147. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  10148. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  10149. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  10150. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  10151. )) {
  10152. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10153. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10154. retXML += " </service>\r\n</imap>";
  10155. return retXML;
  10156. }
  10157. if (attr.getNodeName().equalsIgnoreCase("card_num"))
  10158. sCard_Num = trimquotation(attr.getNodeValue());
  10159. else if (attr.getNodeName().equalsIgnoreCase("car_num"))
  10160. sCar_Num = trimquotation(attr.getNodeValue());
  10161. else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
  10162. sCharger_Num = trimquotation(attr.getNodeValue());
  10163. else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
  10164. sCharger_Loc = trimquotation(attr.getNodeValue());
  10165. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  10166. sCharging_Status = trimquotation(attr.getNodeValue());
  10167. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  10168. (sCharging_Status.equalsIgnoreCase("charging")) ||
  10169. (sCharging_Status.equalsIgnoreCase("full")) ||
  10170. (sCharging_Status.equalsIgnoreCase("charged")) ||
  10171. (sCharging_Status.equalsIgnoreCase("stop")) ||
  10172. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  10173. (sCharging_Status.equalsIgnoreCase("check")) ||
  10174. (sCharging_Status.equalsIgnoreCase("commerror"))
  10175. )) {
  10176. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  10177. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10178. retXML += " </service>\r\n</imap>";
  10179. return retXML;
  10180. }
  10181. } else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  10182. sCharger_sort = trimquotation(attr.getNodeValue());
  10183. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  10184. (sCharger_sort.equalsIgnoreCase("fast")) ||
  10185. (sCharger_sort.equalsIgnoreCase("no_info"))
  10186. )) {
  10187. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  10188. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10189. retXML += " </service>\r\n</imap>";
  10190. return retXML;
  10191. }
  10192. } else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
  10193. sCharging_Ratio = trimquotation(attr.getNodeValue());
  10194. else if (attr.getNodeName().equalsIgnoreCase("start_time"))
  10195. sStart_Time = trimquotation(attr.getNodeValue());
  10196. else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
  10197. sRemain_Time = trimquotation(attr.getNodeValue());
  10198. }
  10199. items = ele.getElementsByTagName("message");
  10200. item = items.item(0);
  10201. Node text = item.getFirstChild();
  10202. sMessage = trimquotation(text.getNodeValue());
  10203. /**데이터 전달**/
  10204. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  10205. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  10206. Intent intent = new Intent();
  10207. intent.setAction(define.NOTIFY_ACNAME);
  10208. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  10209. intent.putExtra("sCard_Num", sCard_Num);
  10210. intent.putExtra("sCar_Num", sCar_Num);
  10211. intent.putExtra("sCharger_Num", sCharger_Num);
  10212. intent.putExtra("sCharger_Loc", sCharger_Loc);
  10213. intent.putExtra("sCharging_Status", sCharging_Status);
  10214. intent.putExtra("sCharger_sort", sCharger_sort);
  10215. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  10216. intent.putExtra("sStart_Time", sStart_Time);
  10217. intent.putExtra("sRemain_Time", sRemain_Time);
  10218. intent.putExtra("sMessage", sMessage);
  10219. WallpadDeviceSet devDB = null;
  10220. devDB = new WallpadDeviceSet(getApplicationContext());
  10221. int retInt = -1;
  10222. retInt = devDB.GetDeviceSetted("전기차충전");
  10223. devDB.closeDB();
  10224. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10225. getApplicationContext().sendBroadcast(intent);
  10226. }
  10227. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  10228. retXML += " <source name=\"homedev\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" />\r\n";
  10229. retXML += " </service>\r\n</imap>";
  10230. return retXML;
  10231. } else {
  10232. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10233. retXML += " </service>\r\n</imap>";
  10234. return retXML;
  10235. }
  10236. } catch (RuntimeException re) {
  10237. LogUtil.errorLogInfo("", TAG, re);
  10238. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10239. retXML += " </service>\r\n</imap>";
  10240. return retXML;
  10241. } catch (Exception e) {
  10242. //e.printStackTrace();
  10243. LogUtil.errorLogInfo("", TAG, e);
  10244. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10245. retXML += " </service>\r\n</imap>";
  10246. return retXML;
  10247. }
  10248. }
  10249. public String ProcEnergyTargetInfoAlarm(Element ele) {
  10250. String retXML = "";
  10251. String sName = "";
  10252. String sId_High = "";
  10253. String sId_Low = "";
  10254. String vName[];
  10255. String vTarget[];
  10256. String vTarget_Cost[];
  10257. String vUsed[];
  10258. String vUsed_Cost[];
  10259. String vPredict[];
  10260. String vPredict_Cost[];
  10261. String vAlarm_info[];
  10262. String vRead_Date[];
  10263. String vRead_Day[];
  10264. String vV_Msg[];
  10265. String sMessage = "";
  10266. try {
  10267. NodeList items = ele.getElementsByTagName("source");
  10268. Node item = items.item(0);
  10269. NamedNodeMap attrsParam = item.getAttributes();
  10270. for (int i = 0; i < attrsParam.getLength(); i++) {
  10271. Node attr = attrsParam.item(i);
  10272. if (attr.getNodeName().equalsIgnoreCase("name"))
  10273. sName = trimquotation(attr.getNodeValue());
  10274. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10275. sId_High = trimquotation(attr.getNodeValue());
  10276. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10277. sId_Low = trimquotation(attr.getNodeValue());
  10278. }
  10279. WallpadStatusData DBMGR = null;
  10280. DBMGR = new WallpadStatusData(getApplicationContext());
  10281. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10282. DBMGR.closeDB();
  10283. if ((sName.equalsIgnoreCase("home") == true) &&
  10284. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  10285. (sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
  10286. items = ele.getElementsByTagName("valuelist");
  10287. Log.d(TAG, "items.getLength() :" + items.getLength());
  10288. vName = new String[items.getLength()];
  10289. vTarget = new String[items.getLength()];
  10290. vTarget_Cost = new String[items.getLength()];
  10291. vUsed = new String[items.getLength()];
  10292. vUsed_Cost = new String[items.getLength()];
  10293. vPredict = new String[items.getLength()];
  10294. vPredict_Cost = new String[items.getLength()];
  10295. vAlarm_info = new String[items.getLength()];
  10296. vRead_Date = new String[items.getLength()];
  10297. vRead_Day = new String[items.getLength()];
  10298. vV_Msg = new String[items.getLength()];
  10299. for (int j = 0; j < items.getLength(); j++) {
  10300. Log.d(TAG, "j :" + j);
  10301. item = items.item(j);
  10302. attrsParam = item.getAttributes();
  10303. Log.d(TAG, "attrsParam :" + attrsParam);
  10304. for (int i = 0; i < attrsParam.getLength(); i++) {
  10305. Node attr = attrsParam.item(i);
  10306. if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  10307. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  10308. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  10309. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  10310. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  10311. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  10312. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  10313. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  10314. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  10315. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  10316. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  10317. )) {
  10318. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10319. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10320. retXML += " </service>\r\n</imap>";
  10321. return retXML;
  10322. }
  10323. if (attr.getNodeName().equalsIgnoreCase("name")) {
  10324. vName[j] = trimquotation(attr.getNodeValue());
  10325. if (!((vName[j].equalsIgnoreCase("elect") == true) ||
  10326. (vName[j].equalsIgnoreCase("water") == true) ||
  10327. (vName[j].equalsIgnoreCase("gas") == true) ||
  10328. (vName[j].equalsIgnoreCase("heating") == true) ||
  10329. (vName[j].equalsIgnoreCase("hotwater") == true)
  10330. )) {
  10331. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  10332. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10333. retXML += " </service>\r\n</imap>";
  10334. return retXML;
  10335. }
  10336. } else if (attr.getNodeName().equalsIgnoreCase("target"))
  10337. vTarget[j] = trimquotation(attr.getNodeValue());
  10338. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  10339. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  10340. else if (attr.getNodeName().equalsIgnoreCase("used"))
  10341. vUsed[j] = trimquotation(attr.getNodeValue());
  10342. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  10343. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  10344. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  10345. vPredict[j] = trimquotation(attr.getNodeValue());
  10346. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  10347. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  10348. else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
  10349. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  10350. if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  10351. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  10352. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  10353. )) {
  10354. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  10355. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10356. retXML += " </service>\r\n</imap>";
  10357. return retXML;
  10358. }
  10359. } else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
  10360. vRead_Date[j] = trimquotation(attr.getNodeValue());
  10361. if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  10362. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  10363. )) {
  10364. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  10365. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10366. retXML += " </service>\r\n</imap>";
  10367. return retXML;
  10368. }
  10369. } else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  10370. vRead_Day[j] = trimquotation(attr.getNodeValue());
  10371. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  10372. vV_Msg[j] = trimquotation(attr.getNodeValue());
  10373. }
  10374. }
  10375. items = ele.getElementsByTagName("message");
  10376. item = items.item(0);
  10377. Node text = item.getFirstChild();
  10378. sMessage = trimquotation(text.getNodeValue());
  10379. /**데이터 전달**/
  10380. for (int i = 0; i < vName.length; i++) {
  10381. Log.d(TAG, "vName[" + i + "]: " + vName[i]);
  10382. Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
  10383. Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
  10384. Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
  10385. Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
  10386. Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
  10387. Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
  10388. Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
  10389. Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
  10390. Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
  10391. Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
  10392. }
  10393. Intent intent = new Intent();
  10394. intent.setAction(define.NOTIFY_ACNAME);
  10395. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  10396. for (int i = 0; i < vName.length; i++) {
  10397. if (vName[i].equals("elect")) {
  10398. intent.putExtra("elect_target", vTarget[i]);
  10399. intent.putExtra("elect_used", vUsed[i]);
  10400. intent.putExtra("elect_info", vAlarm_info[i]);
  10401. } else if (vName[i].equals("water")) {
  10402. intent.putExtra("water_target", vTarget[i]);
  10403. intent.putExtra("water_used", vUsed[i]);
  10404. intent.putExtra("water_info", vAlarm_info[i]);
  10405. } else if (vName[i].equals("gas")) {
  10406. intent.putExtra("gas_target", vTarget[i]);
  10407. intent.putExtra("gas_used", vUsed[i]);
  10408. intent.putExtra("gas_info", vAlarm_info[i]);
  10409. } else if (vName[i].equals("heating")) {
  10410. intent.putExtra("heating_target", vTarget[i]);
  10411. intent.putExtra("heating_used", vUsed[i]);
  10412. intent.putExtra("heating_info", vAlarm_info[i]);
  10413. } else if (vName[i].equals("hotwater")) {
  10414. intent.putExtra("hotwater_target", vTarget[i]);
  10415. intent.putExtra("hotwater_used", vUsed[i]);
  10416. intent.putExtra("hotwater_info", vAlarm_info[i]);
  10417. }
  10418. }
  10419. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  10420. retXML += " <source name=\"home\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" count=\"" + vName.length + "\"" + " s_msg=\"null\" />\r\n";
  10421. for (int i = 0; i < vName.length; i++) {
  10422. retXML += " <valuelist name=\"" + vName[i] + "\" alarm_info=\"" + vAlarm_info[i] + "\" v_msg=\"null\" />\r\n";
  10423. }
  10424. retXML += " <message>\"null\"</message>\r\n";
  10425. retXML += " </service>\r\n</imap>";
  10426. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10427. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  10428. devSet.closeDB();
  10429. if (MetringDB != null) {
  10430. try {
  10431. String devInfo = MetringDB[1];
  10432. devInfo = devInfo.replace('(', '_');
  10433. devInfo = devInfo.replace(':', '_');
  10434. devInfo = devInfo.replace(')', '_');
  10435. String[] MetringInfo = devInfo.split("_");
  10436. // MetringInfo[1] -> 회로수
  10437. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  10438. // MetringInfo[4] -> IP
  10439. // MetringInfo[5] -> IP정보
  10440. // MetringInfo[6] -> 검침일사용자설정
  10441. // MetringInfo[7] -> 사용함 또는 사용안함
  10442. if (MetringInfo[3].equals("사용함") == true) {
  10443. getApplicationContext().sendBroadcast(intent);
  10444. }
  10445. } catch (RuntimeException re) {
  10446. LogUtil.errorLogInfo("", TAG, re);
  10447. } catch (Exception e) {
  10448. //e.printStackTrace();
  10449. LogUtil.errorLogInfo("", TAG, e);
  10450. }
  10451. } else {
  10452. }
  10453. return retXML;
  10454. } else {
  10455. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10456. retXML += " </service>\r\n</imap>";
  10457. return retXML;
  10458. }
  10459. } catch (RuntimeException re) {
  10460. LogUtil.errorLogInfo("", TAG, re);
  10461. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10462. retXML += " </service>\r\n</imap>";
  10463. return retXML;
  10464. } catch (Exception e) {
  10465. //e.printStackTrace();
  10466. LogUtil.errorLogInfo("", TAG, e);
  10467. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10468. retXML += " </service>\r\n</imap>";
  10469. return retXML;
  10470. }
  10471. }
  10472. public String ProcCheckCallOption() {
  10473. int[] resultDB = {0, 0};
  10474. String retXML = "";
  10475. String sOption = "sip";
  10476. String sMessage = "null";
  10477. try {
  10478. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10479. resultDB = devSet.Get_Handicapped_Mode();
  10480. devSet.closeDB();
  10481. if (resultDB[0] == 0) {
  10482. //장애인모드 사용 안함
  10483. } else if (resultDB[0] == 1) {
  10484. //장애인모드 사용함
  10485. }
  10486. switch (resultDB[1]) {
  10487. case 0: //일반모드
  10488. sOption = "sip";
  10489. break;
  10490. case 1: //청각장애인
  10491. sOption = "deaf";
  10492. break;
  10493. case 2: //시각장애인
  10494. sOption = "blind";
  10495. break;
  10496. default:
  10497. break;
  10498. }
  10499. if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  10500. {
  10501. //본 구문에 들어올수 없음
  10502. sOption = "none";
  10503. }
  10504. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  10505. retXML += " <option>\"" + sOption + "\"</option>\r\n";
  10506. retXML += " <message>\"" + sMessage + "\"</message>\r\n";
  10507. retXML += " </service>\r\n</imap>";
  10508. return retXML;
  10509. } catch (RuntimeException re) {
  10510. LogUtil.errorLogInfo("", TAG, re);
  10511. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10512. retXML += " </service>\r\n</imap>";
  10513. return retXML;
  10514. } catch (Exception e) {
  10515. //e.printStackTrace();
  10516. LogUtil.errorLogInfo("", TAG, e);
  10517. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10518. retXML += " </service>\r\n</imap>";
  10519. return retXML;
  10520. }
  10521. }
  10522. public String ProcChatSequence(Element ele) {
  10523. String retXML = "";
  10524. String sFrom = "error";
  10525. String sTo = "error";
  10526. String sContact = "error";
  10527. String sSequence = "error";
  10528. String sStatus = "error";
  10529. String sMessage = "error";
  10530. String reply_Sequence = "error";
  10531. String reply_Status = "error";
  10532. String reply_Message = "null";
  10533. try {
  10534. NodeList items = ele.getElementsByTagName("sequence");
  10535. Node item = items.item(0);
  10536. NamedNodeMap attrsParam = item.getAttributes();
  10537. sSequence = trimquotation(item.getTextContent());
  10538. ///////////////////////////////////////////////
  10539. items = ele.getElementsByTagName("status");
  10540. item = items.item(0);
  10541. attrsParam = item.getAttributes();
  10542. sStatus = trimquotation(item.getTextContent());
  10543. ///////////////////////////////////////////////
  10544. items = ele.getElementsByTagName("message");
  10545. item = items.item(0);
  10546. attrsParam = item.getAttributes();
  10547. sMessage = trimquotation(item.getTextContent());
  10548. ///////////////////////////////////////////////
  10549. items = ele.getElementsByTagName("from");
  10550. item = items.item(0);
  10551. attrsParam = item.getAttributes();
  10552. sFrom = trimquotation(item.getTextContent());
  10553. ///////////////////////////////////////////////
  10554. items = ele.getElementsByTagName("to");
  10555. item = items.item(0);
  10556. attrsParam = item.getAttributes();
  10557. sTo = trimquotation(item.getTextContent());
  10558. ///////////////////////////////////////////////
  10559. items = ele.getElementsByTagName("contact");
  10560. item = items.item(0);
  10561. attrsParam = item.getAttributes();
  10562. sContact = trimquotation(item.getTextContent());
  10563. ///////////////////////////////////////////////
  10564. if (!((sSequence.equalsIgnoreCase("try") == true) ||
  10565. (sSequence.equalsIgnoreCase("start") == true) ||
  10566. (sSequence.equalsIgnoreCase("quit") == true) ||
  10567. (sSequence.equalsIgnoreCase("cancel") == true) ||
  10568. (sSequence.equalsIgnoreCase("ok") == true) ||
  10569. (sSequence.equalsIgnoreCase("busy") == true) ||
  10570. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  10571. (sSequence.equalsIgnoreCase("reject") == true)
  10572. )) {
  10573. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  10574. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10575. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10576. retXML += " </service>\r\n</imap>";
  10577. return retXML;
  10578. }
  10579. if (!((sStatus.equalsIgnoreCase("idle") == true) ||
  10580. (sStatus.equalsIgnoreCase("ringing") == true) ||
  10581. (sStatus.equalsIgnoreCase("talking") == true)
  10582. )) {
  10583. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  10584. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10585. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10586. retXML += " </service>\r\n</imap>";
  10587. return retXML;
  10588. }
  10589. //입력값 처리 필요!!
  10590. //김용성 과장님 작업필요
  10591. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  10592. //확인 하시고 위 정보 확인해주세요.
  10593. Log.d(TAG, "sFrom:" + sFrom);
  10594. Log.d(TAG, "sTo:" + sTo);
  10595. Log.d(TAG, "Contact:" + sContact);
  10596. Log.d(TAG, "sSequence:" + sSequence);
  10597. Log.d(TAG, "sStatus:" + sStatus);
  10598. if (sSequence.equalsIgnoreCase("try") == true) {
  10599. //채팅 요청
  10600. } else if (sSequence.equalsIgnoreCase("start") == true) {
  10601. //채팅 시작
  10602. } else if (sSequence.equalsIgnoreCase("quit") == true) {
  10603. //채팅 종료
  10604. } else if (sSequence.equalsIgnoreCase("cancel") == true) {
  10605. //취소
  10606. } else if (sSequence.equalsIgnoreCase("ok") == true) {
  10607. //요청확인
  10608. } else if (sSequence.equalsIgnoreCase("busy") == true) {
  10609. //통화중
  10610. } else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
  10611. //SIP 통화중
  10612. } else if (sSequence.equalsIgnoreCase("reject") == true) {
  10613. //거절
  10614. }
  10615. if (sStatus.equalsIgnoreCase("idle") == true) {
  10616. //대기
  10617. } else if (sStatus.equalsIgnoreCase("ringing") == true) {
  10618. //연결중
  10619. } else if (sStatus.equalsIgnoreCase("talking") == true) {
  10620. //통화중
  10621. }
  10622. //응답값 입력 필요!!
  10623. //김용성 과장님 작업필요
  10624. reply_Message = "null";
  10625. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  10626. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10627. retXML += " </service>\r\n</imap>";
  10628. return retXML;
  10629. } catch (RuntimeException re) {
  10630. LogUtil.errorLogInfo("", TAG, re);
  10631. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10632. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10633. retXML += " </service>\r\n</imap>";
  10634. return retXML;
  10635. } catch (Exception e) {
  10636. //e.printStackTrace();
  10637. LogUtil.errorLogInfo("", TAG, e);
  10638. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10639. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10640. retXML += " </service>\r\n</imap>";
  10641. return retXML;
  10642. }
  10643. }
  10644. public String ProcChatMessage(Element ele) {
  10645. String retXML = "";
  10646. String sChatMessage = "error";
  10647. String sMessage = "error";
  10648. try {
  10649. NodeList items = ele.getElementsByTagName("chat");
  10650. Node item = items.item(0);
  10651. NamedNodeMap attrsParam = item.getAttributes();
  10652. sChatMessage = trimquotation(item.getTextContent());
  10653. ///////////////////////////////////////////////
  10654. items = ele.getElementsByTagName("message");
  10655. item = items.item(0);
  10656. attrsParam = item.getAttributes();
  10657. sMessage = trimquotation(item.getTextContent());
  10658. ///////////////////////////////////////////////
  10659. //test
  10660. Log.d(TAG, "sChatMessage is " + sChatMessage);
  10661. Log.d(TAG, "sMessage is " + sMessage);
  10662. //test
  10663. Intent intent = new Intent();
  10664. intent.setAction(define.NOTIFY_ACNAME);
  10665. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  10666. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  10667. intent.putExtra("ADD_MESSAGE", sMessage);
  10668. getApplicationContext().sendBroadcast(intent);
  10669. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  10670. retXML += " <message>\"" + "null" + "\"</message>\r\n";
  10671. retXML += " </service>\r\n</imap>";
  10672. return retXML;
  10673. } catch (RuntimeException re) {
  10674. LogUtil.errorLogInfo("", TAG, re);
  10675. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10676. retXML += " </service>\r\n</imap>";
  10677. return retXML;
  10678. } catch (Exception e) {
  10679. //e.printStackTrace();
  10680. LogUtil.errorLogInfo("", TAG, e);
  10681. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10682. retXML += " </service>\r\n</imap>";
  10683. return retXML;
  10684. }
  10685. }
  10686. public String ProcEvacuationLadderOpen(Element ele) {
  10687. String retXML = "";
  10688. try {
  10689. String sDong = null;
  10690. String sHo = null;
  10691. NodeList items = ele.getElementsByTagName("home_info");
  10692. Node item = items.item(0);
  10693. NamedNodeMap attrsParam = item.getAttributes();
  10694. for (int i = 0; i < attrsParam.getLength(); i++) {
  10695. Node attr = attrsParam.item(i);
  10696. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10697. sDong = trimquotation(attr.getNodeValue());
  10698. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10699. sHo = trimquotation(attr.getNodeValue());
  10700. }
  10701. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  10702. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  10703. deviceSet.closeDB();
  10704. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  10705. WallpadStatusData DBMGR = null;
  10706. DBMGR = new WallpadStatusData(getApplicationContext());
  10707. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10708. DBMGR.closeDB();
  10709. String myIP = addc.IPAddress;
  10710. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  10711. String[] SplitedString = myIP.split("\\.");
  10712. if (SplitedString != null) {
  10713. if (SplitedString.length == 4) {
  10714. int temp = Integer.parseInt(SplitedString[2]);
  10715. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  10716. temp = temp - 1;
  10717. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  10718. temp = temp + 1;
  10719. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  10720. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  10721. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  10722. DestStair = String.valueOf(temp);
  10723. }
  10724. }
  10725. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
  10726. /**
  10727. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  10728. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  10729. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  10730. * **/
  10731. WallpadDeviceSet devset;
  10732. devset = new WallpadDeviceSet(getApplicationContext());
  10733. int StatusVal = devset.GetDeviceSetted("피난사다리");
  10734. devset.closeDB();
  10735. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10736. /**
  10737. * 피난사다리 알림!!!
  10738. * **/
  10739. ReceiveNetworkLadderBr(ladderDownSend);
  10740. }
  10741. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  10742. retXML += " </service>\r\n</imap>";
  10743. return retXML;
  10744. } else {
  10745. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  10746. retXML += " </service>\r\n</imap>";
  10747. return retXML;
  10748. }
  10749. } catch (RuntimeException re) {
  10750. LogUtil.errorLogInfo("", TAG, re);
  10751. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  10752. retXML += " </service>\r\n</imap>";
  10753. return retXML;
  10754. } catch (Exception e) {
  10755. //e.printStackTrace();
  10756. LogUtil.errorLogInfo("", TAG, e);
  10757. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  10758. retXML += " </service>\r\n</imap>";
  10759. return retXML;
  10760. }
  10761. }
  10762. private void ReceiveNetworkLadderBr(int val) {
  10763. int base = 7000;
  10764. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  10765. int Menu_Start_Option = 1;
  10766. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  10767. int AlarmStatus = wdb.GetAlarmStatus();
  10768. wdb.closeDB();
  10769. boolean MgrAppRun = false;
  10770. final String packageNameMgr = "com.artncore.managersetting";
  10771. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  10772. if (MgrAppRun)
  10773. return;
  10774. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  10775. return;
  10776. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10777. int StatusVal = devset.GetDeviceSetted("피난사다리");
  10778. devset.closeDB();
  10779. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10780. Common.SendAppFinishReqBR(getApplicationContext());
  10781. Intent newintent = new Intent(Intent.ACTION_MAIN);
  10782. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10783. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  10784. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10785. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  10786. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  10787. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  10788. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  10789. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10790. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10791. getApplicationContext().startActivity(newintent);
  10792. }
  10793. }
  10794. /**
  10795. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  10796. *
  10797. * @param ele Element Xml 데이터
  10798. * @return String 타입의 응답 메시지 생성
  10799. **/
  10800. public String SmartLightDetailInfo(Element ele) {
  10801. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  10802. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  10803. }
  10804. /**
  10805. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  10806. *
  10807. * @param ele Element Xml 데이터
  10808. * @return String 타입의 응답 메시지 생성
  10809. **/
  10810. public String KNXDeviceDetailInfo(Element ele) {
  10811. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  10812. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  10813. }
  10814. public String ProcSetServerChange(Element ele) {
  10815. String retXML = "";
  10816. String versionTXT = null;
  10817. try {
  10818. boolean bRet = false;
  10819. NodeList items = ele.getElementsByTagName("ver_server");
  10820. Node item = items.item(0);
  10821. Node text = item.getFirstChild();
  10822. versionTXT = trimquotation(text.getNodeValue());
  10823. if (versionTXT.equalsIgnoreCase("1.0")) {
  10824. bRet = true;
  10825. } else if (versionTXT.indexOf("2.") >= 0) {
  10826. bRet = true;
  10827. }
  10828. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10829. if (SetData != null && bRet == true) {
  10830. SetData.SetServerVer(versionTXT);
  10831. SetData.closeDB();
  10832. }
  10833. if (bRet == true) {
  10834. try {
  10835. iMapSverReload tSock = new iMapSverReload();
  10836. tSock.start();
  10837. } catch (IOException e) {
  10838. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  10839. //e.printStackTrace();
  10840. LogUtil.errorLogInfo("", TAG, e);
  10841. }
  10842. }
  10843. // 버전 체크해서
  10844. // 응답하고 나서
  10845. // 수신부 쓰레드 재 로딩..
  10846. if (versionTXT != null && bRet == true) {
  10847. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  10848. retXML += " </service>\r\n</imap>";
  10849. return retXML;
  10850. } else {
  10851. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10852. retXML += " </service>\r\n</imap>";
  10853. return retXML;
  10854. }
  10855. } catch (RuntimeException re) {
  10856. LogUtil.errorLogInfo("", TAG, re);
  10857. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10858. retXML += " </service>\r\n</imap>";
  10859. return retXML;
  10860. } catch (Exception e) {
  10861. //e.printStackTrace();
  10862. LogUtil.errorLogInfo("", TAG, e);
  10863. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10864. retXML += " </service>\r\n</imap>";
  10865. return retXML;
  10866. }
  10867. }
  10868. // 메인 서버 소켓 클래스
  10869. public class iMapSverReload extends Thread {
  10870. ServerSocket svr;
  10871. public iMapSverReload() throws IOException {
  10872. /////////////////////////////////////////////////////////////////////
  10873. // 신형 단지서버 사용 유무를 가져온다.
  10874. /////////////////////////////////////////////////////////////////////
  10875. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10876. if (SetData != null) {
  10877. String serverVesionInfo = SetData.GetServerVer();
  10878. SetData.closeDB();
  10879. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  10880. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10881. boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
  10882. devset.closeDB();
  10883. } else {
  10884. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10885. boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
  10886. devset.closeDB();
  10887. }
  10888. }
  10889. try {
  10890. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  10891. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  10892. wallpadDeviceSet.closeDB();
  10893. } catch (RuntimeException re) {
  10894. LogUtil.errorLogInfo("", TAG, re);
  10895. mNewDanjiServer = false;
  10896. } catch (Exception e) {
  10897. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  10898. //e.printStackTrace();
  10899. LogUtil.errorLogInfo("", TAG, e);
  10900. mNewDanjiServer = false;
  10901. }
  10902. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
  10903. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  10904. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  10905. // 관리 PC IP도 변경하도록 한다.
  10906. if (mNewDanjiServer == true) {
  10907. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  10908. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  10909. wallpadStatusData.closeDB();
  10910. } else {
  10911. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  10912. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  10913. wallpadStatusData.closeDB();
  10914. }
  10915. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  10916. }
  10917. public void run() {
  10918. try {
  10919. try {
  10920. Thread.sleep(400);
  10921. } catch (RuntimeException re) {
  10922. LogUtil.errorLogInfo("", TAG, re);
  10923. } catch (Exception e) {
  10924. LogUtil.errorLogInfo("", TAG, e);
  10925. }
  10926. SvrSock.destoryThread();
  10927. for (int i = 0; i < 20; i++) {
  10928. if (SvrSock.isAlive() == false) {
  10929. Log.d(TAG, " Receive Socket Reload i = : " + i);
  10930. break;
  10931. } else {
  10932. Log.d(TAG, " is Live Socket Reload i = : " + i);
  10933. }
  10934. try {
  10935. Thread.sleep(100);
  10936. } catch (RuntimeException re) {
  10937. LogUtil.errorLogInfo("", TAG, re);
  10938. } catch (Exception e) {
  10939. LogUtil.errorLogInfo("", TAG, e);
  10940. }
  10941. }
  10942. SvrSock = new iMapSverSocket();
  10943. SvrSock.start();
  10944. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  10945. try {
  10946. Thread.sleep(3000);
  10947. } catch (RuntimeException re) {
  10948. LogUtil.errorLogInfo("", TAG, re);
  10949. } catch (Exception e) {
  10950. LogUtil.errorLogInfo("", TAG, e);
  10951. }
  10952. try {
  10953. Intent intent = new Intent();
  10954. intent.setAction(define.NOTIFY_ACNAME);
  10955. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  10956. getApplicationContext().sendBroadcast(intent);
  10957. } catch (RuntimeException re) {
  10958. LogUtil.errorLogInfo("", TAG, re);
  10959. } catch (Exception e) {
  10960. //e.printStackTrace();
  10961. LogUtil.errorLogInfo("", TAG, e);
  10962. }
  10963. } catch (IOException e) {
  10964. //e.printStackTrace();
  10965. LogUtil.errorLogInfo("", TAG, e);
  10966. }
  10967. }
  10968. }
  10969. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  10970. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  10971. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  10972. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  10973. public static final int SCHEDULE_START_CALLAPP = 30004;
  10974. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  10975. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  10976. public class SchedulerThread extends Thread {
  10977. boolean doRun;
  10978. AddressSet addr;
  10979. String AddressStr;
  10980. String IPaddr;
  10981. String VerBSP = "";
  10982. String VerAPP;
  10983. String VerSetting;
  10984. String VerNews;
  10985. String VerWeather;
  10986. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  10987. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  10988. private jni mGleInterface = null;
  10989. private final int LIVE_SIGNAL_TIME = 20;
  10990. private int m_LiveSignalCount = 0;
  10991. private int m_MainAppLiveCount = 0;
  10992. Handler ScheDuleHandler = new Handler() {
  10993. public void handleMessage(Message msg) {
  10994. switch (msg.what) {
  10995. case SCHEDULE_START_HEARTBEAT: {
  10996. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  10997. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10998. heartbeatP = DBMGR.GetHeartbeatPeriod();
  10999. DBMGR.closeDB();
  11000. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11001. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11002. }
  11003. break;
  11004. case SCHEDULE_CHANGE_HEARTBEAT:
  11005. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  11006. synchronized (ScheduleList) {
  11007. ScheduleData CheckData;
  11008. for (int i = 0; i < ScheduleList.size(); i++) {
  11009. CheckData = ScheduleList.get(i);
  11010. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11011. Calendar cal = new GregorianCalendar();
  11012. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11013. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11014. DBMGR.closeDB();
  11015. cal.add(Calendar.MINUTE, heartbeatP);
  11016. CheckData.TData = cal;
  11017. ScheduleList.set(i, CheckData);
  11018. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11019. return;
  11020. }
  11021. }
  11022. }
  11023. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11024. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11025. break;
  11026. case SCHEDULE_START_STATUSBEAT:
  11027. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  11028. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11029. break;
  11030. case SCHEDULE_CHANGE_STATUSBEAT:
  11031. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  11032. synchronized (ScheduleList) {
  11033. ScheduleData CheckData;
  11034. for (int i = 0; i < ScheduleList.size(); i++) {
  11035. CheckData = ScheduleList.get(i);
  11036. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11037. Calendar cal = new GregorianCalendar();
  11038. cal.add(Calendar.MINUTE, heartbeatP);
  11039. CheckData.TData = cal;
  11040. ScheduleList.set(i, CheckData);
  11041. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11042. return;
  11043. }
  11044. }
  11045. }
  11046. break;
  11047. case SCHEDULE_START_CALLAPP:
  11048. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  11049. // Bundle bundle = new Bundle();
  11050. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  11051. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  11052. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  11053. // .putExtra(ITEM_CALL_DATA, bundle);
  11054. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11055. // iMAPstartActivity(intent);
  11056. break;
  11057. }
  11058. }
  11059. };
  11060. Handler GetHandler() {
  11061. return ScheDuleHandler;
  11062. }
  11063. public class ScheduleData {
  11064. Calendar TData;
  11065. String ActionSTR;
  11066. public ScheduleData(Calendar tdata, String ActionStr) {
  11067. TData = tdata;
  11068. ActionSTR = ActionStr;
  11069. }
  11070. }
  11071. public SchedulerThread() {
  11072. doRun = true;
  11073. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11074. addr = DBMGR.getAddressMGR();
  11075. VerAPP = DBMGR.GetAPPVer();
  11076. VerSetting = DBMGR.GetSettingVer();
  11077. VerNews = DBMGR.GetNoticeVer();
  11078. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11079. DBMGR.closeDB();
  11080. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  11081. try {
  11082. mGleInterface = new jni();
  11083. } catch (RuntimeException re) {
  11084. LogUtil.errorLogInfo("", TAG, re);
  11085. } catch (Exception e) {
  11086. Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
  11087. }
  11088. }
  11089. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
  11090. VerAPP = GetAppVersion();
  11091. }
  11092. AddressStr = addr.Dong + "동" + addr.Ho + "호";
  11093. IPaddr = addr.IPAddress;
  11094. ScheDulerHandler = ScheDuleHandler;
  11095. }
  11096. public void reg_schedule(int min, String Action) {
  11097. for (int i = 0; i < ScheduleList.size(); i++) {
  11098. ScheduleData scdata = ScheduleList.get(i);
  11099. if (scdata.ActionSTR.equals(Action)) {
  11100. ScheduleList.remove(i);
  11101. break;
  11102. }
  11103. }
  11104. Calendar cal = new GregorianCalendar();
  11105. cal.add(Calendar.MINUTE, min);
  11106. ScheduleData regData = new ScheduleData(cal, Action);
  11107. synchronized (ScheduleList) {
  11108. ScheduleList.add(regData);
  11109. }
  11110. }
  11111. private void doSchedule(String doing) {
  11112. String[] doingData = doing.split(";");
  11113. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11114. try {
  11115. String SendingStr = MakeHeartbeat();
  11116. SendToServer(SendingStr);
  11117. Calendar cal = new GregorianCalendar();
  11118. 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));
  11119. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11120. DBMGR.SetLastHeartbeat(timedata);
  11121. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11122. DBMGR.closeDB();
  11123. } catch (RuntimeException re) {
  11124. LogUtil.errorLogInfo("", TAG, re);
  11125. } catch (Exception e) {
  11126. //e.printStackTrace();
  11127. LogUtil.errorLogInfo("", TAG, e);
  11128. }
  11129. } else if (doingData[0].equals("UPDATETIME")) {
  11130. } else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11131. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  11132. if (!Common.getDeviceServeiceLoadComplite()) return;
  11133. String SendingStr = MakeStatusReport();
  11134. if (SendingStr == null) return;
  11135. SendToServer(SendingStr);
  11136. Calendar cal = new GregorianCalendar();
  11137. 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));
  11138. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11139. DBMGR.SetLastStatusbeat(timedata);
  11140. DBMGR.closeDB();
  11141. int StatusP = 720;
  11142. try {
  11143. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11144. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11145. devset.closeDB();
  11146. if (StatusVal == null) StatusP = 720;
  11147. else StatusP = Integer.parseInt(StatusVal[1]);
  11148. } catch (RuntimeException re) {
  11149. LogUtil.errorLogInfo("", TAG, re);
  11150. } catch (Exception e) {
  11151. //e.printStackTrace();
  11152. LogUtil.errorLogInfo("", TAG, e);
  11153. }
  11154. reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
  11155. }
  11156. }
  11157. private String MakeHeartbeat() {
  11158. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11159. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11160. VerNews = DBMGR.GetNoticeVer();
  11161. VerSetting = DBMGR.GetSettingVer();
  11162. String VerServer = DBMGR.GetServerVer();
  11163. DBMGR.closeDB();
  11164. if (VerServer == null) {
  11165. Log.d(TAG, "VerServer null");
  11166. VerServer = "1.0";
  11167. }
  11168. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11169. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  11170. wallpadDeviceSet.closeDB();
  11171. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  11172. // 스마트 분전반
  11173. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  11174. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  11175. String retStr = XMLHeader +
  11176. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11177. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11178. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11179. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11180. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11181. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11182. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11183. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11184. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11185. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11186. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11187. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n" +
  11188. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n" +
  11189. "</service>\r\n</imap>";
  11190. return retStr;
  11191. } else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  11192. // TODO KNX 분전반
  11193. // String retStr = XMLHeader+
  11194. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  11195. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  11196. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  11197. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  11198. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  11199. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  11200. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  11201. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  11202. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  11203. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  11204. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11205. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  11206. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  11207. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  11208. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  11209. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  11210. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  11211. // "</service>\r\n</imap>";
  11212. String retStr = XMLHeader +
  11213. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11214. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11215. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11216. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11217. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11218. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11219. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11220. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11221. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11222. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11223. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11224. "</service>\r\n</imap>";
  11225. return retStr;
  11226. } else {
  11227. String retStr = XMLHeader +
  11228. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11229. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11230. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11231. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11232. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11233. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11234. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11235. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11236. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11237. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11238. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11239. "</service>\r\n</imap>";
  11240. return retStr;
  11241. }
  11242. }
  11243. public String GetAppVersion() {
  11244. PackageInfo pi = null;
  11245. try {
  11246. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  11247. } catch (RuntimeException re) {
  11248. LogUtil.errorLogInfo("", TAG, re);
  11249. } catch (Exception e) {
  11250. LogUtil.errorLogInfo("", TAG, e);
  11251. }
  11252. return pi.versionName;
  11253. }
  11254. boolean isAlawaysrun = true;
  11255. public void run() {
  11256. while (/*doRun*/ isAlawaysrun) {
  11257. //Common.DebugLog("SchedulerThread ------ 10Sec");
  11258. CheckHeartBeat();
  11259. CheckStatusBeat();
  11260. CheckWallPadLiveSignal();
  11261. LiveCheckRebooting();
  11262. try {
  11263. Thread.sleep(10000);
  11264. } catch (RuntimeException re) {
  11265. LogUtil.errorLogInfo("", TAG, re);
  11266. } catch (Exception e) {
  11267. LogUtil.errorLogInfo("", TAG, e);
  11268. }
  11269. }
  11270. }
  11271. public void SetLive() {
  11272. m_MainAppLiveCount++;
  11273. }
  11274. private int CheckTime30Sec = 0;
  11275. private void LiveCheckRebooting() {
  11276. try {
  11277. CheckTime30Sec++;
  11278. if (CheckTime30Sec % 20 == 0) {
  11279. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  11280. // // 10초마다 수행되는 함수이니....
  11281. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  11282. // if (m_MainAppLiveCount == 0) {
  11283. // //리셋
  11284. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  11285. // {
  11286. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  11287. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  11288. // pm.userActivity(8, true);
  11289. // }
  11290. // else
  11291. // {
  11292. // Log.d(TAG, "Main App Down Reset IHN_750");
  11293. // WallPadInterface wpdifc = new WallPadInterface();
  11294. // wpdifc.WachdogSystemReset();
  11295. // }
  11296. // }
  11297. // }
  11298. CheckTime30Sec = 0;
  11299. }
  11300. if (CheckTime30Sec >= 30000) {
  11301. CheckTime30Sec = 0;
  11302. }
  11303. } catch (RuntimeException re) {
  11304. LogUtil.errorLogInfo("", TAG, re);
  11305. } catch (Exception e) {
  11306. //e.printStackTrace();
  11307. LogUtil.errorLogInfo("", TAG, e);
  11308. }
  11309. }
  11310. private void CheckWallPadLiveSignal() {
  11311. try {
  11312. int nTime = LIVE_SIGNAL_TIME / 10;
  11313. m_LiveSignalCount++;
  11314. if (m_LiveSignalCount >= nTime) {
  11315. m_LiveSignalCount = 0;
  11316. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  11317. }
  11318. } catch (RuntimeException re) {
  11319. LogUtil.errorLogInfo("", TAG, re);
  11320. } catch (Exception e) {
  11321. Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
  11322. }
  11323. }
  11324. protected void CheckStatusBeat() {
  11325. try {
  11326. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11327. String statusbeatdata = WPD.GetLastStatusbeat();
  11328. WPD.closeDB();
  11329. int StatusP = 720;
  11330. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11331. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11332. if (StatusVal == null) StatusP = 720;
  11333. else
  11334. StatusP = Integer.parseInt(StatusVal[1]);
  11335. devset.closeDB();
  11336. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11337. } catch (RuntimeException re) {
  11338. LogUtil.errorLogInfo("", TAG, re);
  11339. } catch (Exception e) {
  11340. //e.printStackTrace();
  11341. LogUtil.errorLogInfo("", TAG, e);
  11342. }
  11343. }
  11344. protected void CheckHeartBeat() {
  11345. try {
  11346. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11347. String heartbeatdata = WPD.GetLastHeartbeat();
  11348. int heartbeatPer = WPD.GetHeartbeatPeriod();
  11349. WPD.closeDB();
  11350. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11351. } catch (RuntimeException re) {
  11352. LogUtil.errorLogInfo("", TAG, re);
  11353. } catch (Exception e) {
  11354. //e.printStackTrace();
  11355. LogUtil.errorLogInfo("", TAG, e);
  11356. }
  11357. }
  11358. protected boolean CheckTime(String CheckT, int period) {
  11359. Calendar last = new GregorianCalendar();
  11360. String[] timedata = CheckT.split("[.]");
  11361. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  11362. last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
  11363. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  11364. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  11365. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  11366. last.add(Calendar.MINUTE, period);
  11367. Calendar checkCal = new GregorianCalendar();
  11368. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  11369. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  11370. return true;
  11371. return false;
  11372. }
  11373. }
  11374. class SendMSGToSVR extends Thread {
  11375. String sendmsg;
  11376. public SendMSGToSVR(String msg) {
  11377. sendmsg = msg;
  11378. }
  11379. public void run() {
  11380. Socket sock = null;
  11381. DataOutputStream outstream = null;
  11382. try {
  11383. // 신형 단지서버 사용 유무를 가져온다.
  11384. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11385. boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11386. wallpadDeviceSet.closeDB();
  11387. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11388. SVRIP = DBMGR.GetServerIP();
  11389. port = DBMGR.GetServerPort();
  11390. DBMGR.closeDB();
  11391. /////////////////////////////////////////////////////////////////////
  11392. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  11393. // 사용중일 경우 암호화 소켓을 생성한다.
  11394. /////////////////////////////////////////////////////////////////////
  11395. if (!bNewDanjiServer) {
  11396. sock = new Socket(SVRIP, port);
  11397. } else {
  11398. int setport = port + 1000;
  11399. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  11400. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  11401. sock = sslClientSocket.getSocket();
  11402. }
  11403. /////////////////////////////////////////////////////////////////////
  11404. if (sock != null) {
  11405. sock.setSoLinger(true, 1000);
  11406. outstream = new DataOutputStream(sock.getOutputStream());
  11407. byte[] outBF = sendmsg.getBytes("euc-kr");
  11408. outstream.write(outBF);
  11409. outstream.flush();
  11410. }
  11411. } catch (RuntimeException re) {
  11412. LogUtil.errorLogInfo("", TAG, re);
  11413. } catch (Exception e) {
  11414. //e.printStackTrace();
  11415. LogUtil.errorLogInfo("", TAG, e);
  11416. } finally {
  11417. if (outstream != null) {
  11418. try {
  11419. outstream.close();
  11420. } catch (IOException e) {
  11421. LogUtil.errorLogInfo("", TAG, e);
  11422. }
  11423. }
  11424. outstream = null;
  11425. if (sock != null) {
  11426. try {
  11427. sock.close();
  11428. } catch (IOException e) {
  11429. LogUtil.errorLogInfo("", TAG, e);
  11430. }
  11431. }
  11432. sock = null;
  11433. }
  11434. }
  11435. }
  11436. private void SendToServer(String msg) {
  11437. SendMSGToSVR msan = new SendMSGToSVR(msg);
  11438. msan.start();
  11439. }
  11440. boolean StatusBeatRequested = false;
  11441. private String MakeStatusReport() {
  11442. try {
  11443. String ServiceType = StatusBeatRequested ? "requested" : "notice";
  11444. StatusBeatRequested = false;
  11445. String RetData = XMLHeader + "<service type=\"" + ServiceType + "\" name=\"statusbeat\"> \r\n";
  11446. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  11447. String[] typeList = SettManager.GetTypeList();
  11448. if (typeList == null || typeList.length == 0) {
  11449. DefaultProcauscultateReq(SettManager);
  11450. typeList = SettManager.GetTypeList();
  11451. }
  11452. SettManager.closeDB();
  11453. String[] ControlList;
  11454. String Vender = "null";
  11455. String devid = "null";
  11456. String Model = "null";
  11457. String subunitcnt = "null";
  11458. String statusRate = "null";
  11459. String statusType = "null";
  11460. String message = "null";
  11461. int itemCNT = 0;
  11462. int totalGroup = 0;
  11463. int totalItem = 0;
  11464. String ControlDEVList;
  11465. String ContentList = " ";
  11466. if (typeList != null) {
  11467. for (int i = 0; i < typeList.length; i++) {
  11468. if (typeList[i].equals("ctrl_device")) {
  11469. SettManager = new WallpadDevStatus(getApplicationContext());
  11470. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  11471. SettManager.closeDB();
  11472. ControlDEVList = "";
  11473. if (ControlList != null) {
  11474. for (int k = 0; k < ControlList.length; k++) {
  11475. if (ControlList[k].equals("light")) {
  11476. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11477. int[] lightinfo = devSet.Get_Light_info();
  11478. devSet.closeDB();
  11479. if (lightinfo[0] == 1) {
  11480. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  11481. subunitcnt = String.valueOf(lightinfo[2]);
  11482. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  11483. devid = "0x11";
  11484. Vender = "null";
  11485. Model = "null";
  11486. if (lightCTR != null) {
  11487. lightCTR.TRInfo.GetTransactionList(0);
  11488. statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
  11489. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  11490. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11491. message = "null";
  11492. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11493. itemCNT++;
  11494. }
  11495. } else {
  11496. subunitcnt = String.valueOf(lightinfo[2]);
  11497. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  11498. if (MultiSW != null) {
  11499. MultiSW.Refresh((byte) 0xFF, false);
  11500. byte Bdevid = 0x51;
  11501. for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
  11502. devid = String.format("0x%02X", Bdevid + j);
  11503. Vender = "null";
  11504. Model = "null";
  11505. MultiSW.TRInfo.GetTransactionList(j);
  11506. statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
  11507. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  11508. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11509. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11510. itemCNT++;
  11511. }
  11512. }
  11513. }
  11514. } else {
  11515. Vender = "null";
  11516. devid = "null";
  11517. Model = "null";
  11518. subunitcnt = "null";
  11519. statusRate = "null";
  11520. message = "null";
  11521. }
  11522. } else if (ControlList[k].equals("thermostat")) {
  11523. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11524. int ret = devSet.Get_Temper_Info();
  11525. devSet.closeDB();
  11526. if (ret == 1) {
  11527. // 난방 종류를 얻어온다.
  11528. int HeatingKind = mWallPadAPI.GetHeatingKind();
  11529. HeatingV1API heatingV1API = null;
  11530. HeatingV2API heatingV2API = null;
  11531. // 종류별 API를 로딩한다.
  11532. if (HeatingKind == 1) {
  11533. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  11534. if (heatingV1API != null) {
  11535. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  11536. devid = "0x21";
  11537. Vender = "null";
  11538. Model = "null";
  11539. heatingV1API.TRInfo.GetTransactionList(0);
  11540. statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
  11541. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  11542. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11543. message = "null";
  11544. }
  11545. } else if (HeatingKind == 2) {
  11546. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  11547. if (heatingV2API != null) {
  11548. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  11549. devid = "0x28";
  11550. Vender = "null";
  11551. Model = "null";
  11552. heatingV2API.TRInfo.GetTransactionList(0);
  11553. statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
  11554. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  11555. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11556. message = "null";
  11557. }
  11558. } else {
  11559. subunitcnt = "null";
  11560. devid = "null";
  11561. Vender = "null";
  11562. Model = "null";
  11563. statusRate = "0/0";
  11564. statusType = "bad";
  11565. message = "null";
  11566. }
  11567. ControlDEVList += " <unit type=\"thermostat\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11568. itemCNT++;
  11569. } else {
  11570. }
  11571. } else if (ControlList[k].equals("gas")) {
  11572. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11573. if (devSet.Get_GAS_Info() == 1) {
  11574. //여기서 신우전자확인이 더 필요함
  11575. GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
  11576. CooktopAPI HybridCookTopCTR = null;
  11577. subunitcnt = "1";
  11578. devid = "0x31";
  11579. Vender = "null";
  11580. Model = "null";
  11581. if (mWallPadAPI.GetGasKind() == 2) {
  11582. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  11583. if (HybridCookTopCTR != null) {
  11584. HybridCookTopCTR.TRInfo.GetTransactionList(0);
  11585. statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
  11586. double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
  11587. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11588. message = "null";
  11589. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11590. itemCNT++;
  11591. }
  11592. } else {
  11593. GasCTR = mWallPadAPI.Get_GasController();
  11594. if (GasCTR != null) {
  11595. GasCTR.TRInfo.GetTransactionList(0);
  11596. statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
  11597. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  11598. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11599. message = "null";
  11600. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11601. itemCNT++;
  11602. }
  11603. }
  11604. } else {
  11605. }
  11606. devSet.closeDB();
  11607. } else if (ControlList[k].equals("doorlock")) {
  11608. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11609. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  11610. if (doorlockInfo[0] == 1) {
  11611. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  11612. subunitcnt = "1";
  11613. devid = "0x41";
  11614. Vender = "null";
  11615. Model = "null";
  11616. if (DoorCTR != null) {
  11617. DoorCTR.TRInfo.GetTransactionList(0);
  11618. statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
  11619. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  11620. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11621. message = "null";
  11622. ControlDEVList += " <unit type=\"doorlock\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11623. itemCNT++;
  11624. }
  11625. } else {
  11626. }
  11627. devSet.closeDB();
  11628. } else if (ControlList[k].equals("ventil")) {
  11629. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11630. int[] ventilInfo = devSet.Get_Ventil_Info();
  11631. if (ventilInfo[0] == 1) {
  11632. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  11633. subunitcnt = "1";
  11634. devid = "0x61";
  11635. Vender = "null";
  11636. Model = "null";
  11637. if (VentilCTR != null) {
  11638. VentilCTR.TRInfo.GetTransactionList(0);
  11639. statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
  11640. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  11641. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11642. message = "null";
  11643. ControlDEVList += " <unit type=\"ventil\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11644. itemCNT++;
  11645. }
  11646. } else {
  11647. }
  11648. devSet.closeDB();
  11649. } else if (ControlList[k].equals("aircon")) {
  11650. } else if (ControlList[k].equals("curtain")) {
  11651. }
  11652. }
  11653. if (itemCNT > 0) {
  11654. ContentList += "<group type=\"ctrl_device\" count=\"" + itemCNT + "\">\r\n";
  11655. ContentList += ControlDEVList;
  11656. ContentList += "</group>\r\n";
  11657. totalGroup++;
  11658. totalItem += itemCNT;
  11659. }
  11660. }
  11661. } else if (typeList[i].equals("talk_device")) {
  11662. SettManager = new WallpadDevStatus(getApplicationContext());
  11663. ControlList = SettManager.GetSettingGroupData("talk_device");
  11664. SettManager.closeDB();
  11665. itemCNT = 0;
  11666. ControlDEVList = "";
  11667. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  11668. if (testAPI != null)
  11669. testAPI.GetVersion();
  11670. if (ControlList != null) {
  11671. for (int k = 0; k < ControlList.length; k++) {
  11672. if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
  11673. 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";
  11674. itemCNT++;
  11675. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  11676. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  11677. } else if (ControlList[k].equals("bath_phone") && testAPI != null) {
  11678. 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";
  11679. itemCNT++;
  11680. } else if (ControlList[k].equals("subhome_dev")) {
  11681. }
  11682. }
  11683. if (itemCNT > 0) {
  11684. ContentList += "<group type=\"talk_device\" count=\"" + itemCNT + "\">\r\n";
  11685. ContentList += ControlDEVList;
  11686. ContentList += "</group>\r\n";
  11687. totalGroup++;
  11688. totalItem += itemCNT;
  11689. }
  11690. }
  11691. } else if (typeList[i].equals("sensor")) {
  11692. SettManager = new WallpadDevStatus(getApplicationContext());
  11693. ControlList = SettManager.GetSettingGroupData("sensor");
  11694. SettManager.closeDB();
  11695. itemCNT = 0;
  11696. ControlDEVList = "";
  11697. if (ControlList != null) {
  11698. for (int k = 0; k < ControlList.length; k++) {
  11699. if (ControlList[k].equals("magnetic")) {
  11700. WallPadInterface wpifc = new WallPadInterface();
  11701. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  11702. String SenStateCom;
  11703. String SenStateType;
  11704. if (MagSen == 1) {
  11705. SenStateCom = "1/1";
  11706. SenStateType = "";
  11707. } else {
  11708. SenStateCom = "0/1";
  11709. SenStateType = "perfect";
  11710. }
  11711. ControlDEVList += " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  11712. itemCNT++;
  11713. } else if (ControlList[k].equals("bugout")) {
  11714. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11715. int sensor = devSet.Get_Sensor_Set();
  11716. devSet.closeDB();
  11717. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  11718. WallPadInterface wpifc = new WallPadInterface();
  11719. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11720. String SenStateCom;
  11721. String SenStateType;
  11722. if (outSen == 1) {
  11723. SenStateCom = "1/1";
  11724. SenStateType = "bad";
  11725. } else {
  11726. SenStateCom = "0/1";
  11727. SenStateType = "perfect";
  11728. }
  11729. ControlDEVList += " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  11730. itemCNT++;
  11731. }
  11732. } else if (ControlList[k].equals("bugin")) {
  11733. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11734. int sensor = devSet.Get_Sensor_Set();
  11735. devSet.closeDB();
  11736. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  11737. WallPadInterface wpifc = new WallPadInterface();
  11738. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  11739. String SenStateCom;
  11740. String SenStateType;
  11741. if (InSen == 1) {
  11742. SenStateCom = "1/1";
  11743. SenStateType = "bad";
  11744. } else {
  11745. SenStateCom = "0/1";
  11746. SenStateType = "perfect";
  11747. }
  11748. ControlDEVList += " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  11749. itemCNT++;
  11750. }
  11751. } else if (ControlList[k].equals("fire")) {
  11752. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  11753. } else if (ControlList[k].equals("gas")) {
  11754. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  11755. }
  11756. }
  11757. if (itemCNT > 0) {
  11758. ContentList += "<group type=\"sensor\" count=\"" + itemCNT + "\">\r\n";
  11759. ContentList += ControlDEVList;
  11760. ContentList += "</group>\r\n";
  11761. totalGroup++;
  11762. totalItem += itemCNT;
  11763. }
  11764. }
  11765. } else if (typeList[i].equals("extended")) {
  11766. SettManager = new WallpadDevStatus(getApplicationContext());
  11767. ControlList = SettManager.GetSettingGroupData("extended");
  11768. SettManager.closeDB();
  11769. itemCNT = 0;
  11770. ControlDEVList = "";
  11771. if (ControlList != null) {
  11772. for (int k = 0; k < ControlList.length; k++) {
  11773. if (ControlList[k].equals("gateway")) {
  11774. } else if (ControlList[k].equals("handy")) {
  11775. } else if (ControlList[k].equals("smartswitch")) {
  11776. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11777. int[] BatchInfo = devSet.Get_BatchSW_Info();
  11778. devSet.closeDB();
  11779. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
  11780. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  11781. SmartSWCTR.TRInfo.GetTransactionList(0);
  11782. subunitcnt = "1";
  11783. statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
  11784. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  11785. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11786. message = "null";
  11787. ControlDEVList += " <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11788. itemCNT++;
  11789. } else {
  11790. }
  11791. } else if (ControlList[k].equals("energymeter")) {
  11792. }
  11793. }
  11794. if (itemCNT > 0) {
  11795. ContentList += "<group type=\"extended\" count=\"" + itemCNT + "\">\r\n";
  11796. ContentList += ControlDEVList;
  11797. ContentList += "</group>\r\n";
  11798. totalGroup++;
  11799. totalItem += itemCNT;
  11800. }
  11801. }
  11802. }
  11803. }
  11804. SettManager.closeDB();
  11805. ContentList += "</guidemap> \r\n";
  11806. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\"" + totalGroup + "\" device_cnt=\"" + totalItem + "\">\r\n";
  11807. RetData += ContentList;
  11808. String LogSet;
  11809. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  11810. RetData += LogSet;
  11811. try {
  11812. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  11813. String[] ResetData = WsDB.GetResetSchedule();
  11814. WsDB.closeDB();
  11815. if (!ResetData[0].equals("NONE")) {
  11816. int type = Integer.parseInt(ResetData[0]);
  11817. if (type == WallpadStatusData.RESET_MONTH)
  11818. LogSet = "<reset_info enable=\"true\" type=\"month\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  11819. else if (type == WallpadStatusData.RESET_WEEK)
  11820. LogSet = "<reset_info enable=\"true\" type=\"week\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  11821. else
  11822. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11823. } else
  11824. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11825. } catch (RuntimeException re) {
  11826. LogUtil.errorLogInfo("", TAG, re);
  11827. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11828. } catch (Exception e) {
  11829. //e.printStackTrace();
  11830. LogUtil.errorLogInfo("", TAG, e);
  11831. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11832. }
  11833. RetData += LogSet;
  11834. RetData += "</service>\r\n</imap>\r\n";
  11835. }
  11836. return RetData;
  11837. } catch (RuntimeException re) {
  11838. LogUtil.errorLogInfo("", TAG, re);
  11839. return null;
  11840. } catch (Exception e) {
  11841. //e.printStackTrace();
  11842. LogUtil.errorLogInfo("", TAG, e);
  11843. return null;
  11844. }
  11845. }
  11846. private String getKNXDeviceStatus(int device) {
  11847. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  11848. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  11849. String status = knxHeartbeat.getStatus();
  11850. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  11851. return status;
  11852. }
  11853. private String getKNXDeviceCause(int device) {
  11854. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  11855. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  11856. String cause = knxHeartbeat.getCause();
  11857. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  11858. return cause;
  11859. }
  11860. //mWallPadAPI
  11861. // private String TAG = "*yskim*";
  11862. //private IGW200dAPI iGW200dAPI = null;
  11863. /**
  11864. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  11865. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  11866. * 본 딜레이 코드를 임시로 적용한다.
  11867. */
  11868. @SuppressLint("HandlerLeak")
  11869. protected Handler IGW200APICheckHandler = new Handler() {
  11870. @SuppressLint("HandlerLeak")
  11871. @Override
  11872. public void handleMessage(Message msg) {
  11873. if (msg.what == 0) {
  11874. if (mWallPadAPI != null) {
  11875. Common.DebugLog("handleMessage what 0 ");
  11876. if (mWallPadAPI.Check_Connect())
  11877. IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  11878. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  11879. }
  11880. } else if (msg.what == 1) {
  11881. Common.DebugLog("handleMessage what 1 ");
  11882. setIGE200Interface();
  11883. }
  11884. }
  11885. };
  11886. public void setIGE200Interface() {
  11887. try {
  11888. Common.DebugLog("setIGE200Interface");
  11889. mIGW200 = new IGW200(this, mWallPadAPI);
  11890. } catch (RuntimeException re) {
  11891. LogUtil.errorLogInfo("", TAG, re);
  11892. } catch (Exception e) {
  11893. Log.e(TAG, "[Exception] setIGE200Interface()");
  11894. //e.printStackTrace();
  11895. LogUtil.errorLogInfo("", TAG, e);
  11896. }
  11897. }
  11898. /**
  11899. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  11900. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  11901. * 본 딜레이 코드를 임시로 적용한다.
  11902. */
  11903. @SuppressLint("HandlerLeak")
  11904. protected Handler IGW300APICheckHandler = new Handler() {
  11905. @SuppressLint("HandlerLeak")
  11906. @Override
  11907. public void handleMessage(Message msg) {
  11908. if (msg.what == 0) {
  11909. if (mWallPadAPI != null) {
  11910. Common.DebugLog("handleMessage what 0 ");
  11911. if (mWallPadAPI.Check_Connect())
  11912. IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  11913. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  11914. }
  11915. } else if (msg.what == 1) {
  11916. Common.DebugLog("handleMessage what 1 ");
  11917. setIGE300Interface();
  11918. }
  11919. }
  11920. };
  11921. public void setIGE300Interface() {
  11922. try {
  11923. Common.DebugLog("setIGE300Interface");
  11924. mIGW300 = new IGW300(this, mWallPadAPI);
  11925. } catch (RuntimeException re) {
  11926. LogUtil.errorLogInfo("", TAG, re);
  11927. } catch (Exception e) {
  11928. Log.e(TAG, "[Exception] setIGE300Interface()");
  11929. //e.printStackTrace();
  11930. LogUtil.errorLogInfo("", TAG, e);
  11931. }
  11932. }
  11933. // 외출모드 연동
  11934. private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
  11935. try {
  11936. bSmartSwitch485ComebackMode = false;
  11937. String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
  11938. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  11939. String outLinkCtrl = wd.GetOutModeLinkDevice();
  11940. if (BedMode == true)
  11941. outLinkCtrl = wd.GetInBedLinkDevice();
  11942. wd.closeDB();
  11943. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  11944. if (WallpadUI == false) {
  11945. if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
  11946. {
  11947. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
  11948. CallElevatorBtn(false);
  11949. }
  11950. }
  11951. if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
  11952. {
  11953. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
  11954. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  11955. }
  11956. if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  11957. {
  11958. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
  11959. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  11960. }
  11961. if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  11962. {
  11963. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
  11964. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  11965. }
  11966. if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
  11967. {
  11968. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
  11969. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  11970. }
  11971. } catch (RuntimeException re) {
  11972. LogUtil.errorLogInfo("", TAG, re);
  11973. } catch (Exception e) {
  11974. Log.e("YSKIM", e.toString());
  11975. }
  11976. }
  11977. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  11978. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  11979. private boolean bSmartSwitch485ComebackMode = false;
  11980. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  11981. try {
  11982. if (bSmartSwitch485ComebackMode == true) return;
  11983. String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
  11984. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  11985. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  11986. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  11987. wd.closeDB();
  11988. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  11989. // 일괄소등 해제
  11990. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
  11991. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  11992. }
  11993. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
  11994. // 환기동작
  11995. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
  11996. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  11997. }
  11998. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  11999. // 난방 외출모드 해제
  12000. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
  12001. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  12002. }
  12003. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  12004. // 웰컴조명 켜기
  12005. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
  12006. // 웰컴조명 Handler 실행
  12007. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  12008. }
  12009. } catch (RuntimeException re) {
  12010. LogUtil.errorLogInfo("", TAG, re);
  12011. } catch (Exception e) {
  12012. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  12013. //e.printStackTrace();
  12014. LogUtil.errorLogInfo("", TAG, e);
  12015. }
  12016. }
  12017. private Handler WelcomeLightHandler = new Handler() {
  12018. int LightOnCount = 0;
  12019. @Override
  12020. public void handleMessage(Message msg) {
  12021. if (msg.what == 0) {
  12022. try {
  12023. if (LightOnCount == 0) {
  12024. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  12025. }
  12026. // 일괄소등 해제이면
  12027. if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
  12028. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  12029. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  12030. } else {
  12031. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  12032. LightOnCount++;
  12033. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  12034. if (LightOnCount > 10) {
  12035. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  12036. LightOnCount = 0;
  12037. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  12038. }
  12039. }
  12040. } catch (RuntimeException re) {
  12041. LogUtil.errorLogInfo("", TAG, re);
  12042. } catch (Exception e1) {
  12043. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  12044. //e1.printStackTrace();
  12045. LogUtil.errorLogInfo("", TAG, e1);
  12046. }
  12047. } else if (msg.what == 1) {
  12048. try {
  12049. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  12050. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  12051. LightOnCount = 0;
  12052. } catch (RuntimeException re) {
  12053. LogUtil.errorLogInfo("", TAG, re);
  12054. } catch (Exception e1) {
  12055. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  12056. //e1.printStackTrace();
  12057. LogUtil.errorLogInfo("", TAG, e1);
  12058. }
  12059. } else if (msg.what == 2) {
  12060. // Do Nothing
  12061. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  12062. WelcomeLightHandler.removeMessages(0);
  12063. }
  12064. }
  12065. };
  12066. //방범 및 알람 상태 확인 Resume 시 처리
  12067. private void CheckMainStatus() {
  12068. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  12069. try {
  12070. final String packageName = "com.artncore.apps.ic_wallpad";
  12071. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  12072. //CallAppRun = getForegroundAPK().equals(packageName);
  12073. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  12074. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12075. int alarmstate = SetData.GetAlarmStatus();
  12076. SetData.closeDB();
  12077. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
  12078. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  12079. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
  12080. return;
  12081. } else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  12082. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  12083. int base = 7000;
  12084. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
  12085. int Menu_Start_Id = 0;
  12086. SetData = new WallpadStatusData(getApplicationContext());
  12087. int alarmtype = SetData.GetAlarmType();
  12088. SetData.closeDB();
  12089. switch (alarmtype) {
  12090. case WallpadStatusData.ALARM_ALERT:
  12091. Menu_Start_Id = Menu_Id_List[1];
  12092. break;
  12093. case WallpadStatusData.ALARM_EMM:
  12094. Menu_Start_Id = Menu_Id_List[0];
  12095. break;
  12096. case WallpadStatusData.ALARM_EVAC:
  12097. Menu_Start_Id = Menu_Id_List[3];
  12098. break;
  12099. case WallpadStatusData.ALARM_INVADE:
  12100. Menu_Start_Id = Menu_Id_List[2];
  12101. break;
  12102. case WallpadStatusData.ALARM_HEATING_LEAK:
  12103. Menu_Start_Id = Menu_Id_List[4];
  12104. break;
  12105. default:
  12106. Menu_Start_Id = Menu_Id_List[1];
  12107. break;
  12108. }
  12109. if (Menu_Start_Id > 0) {
  12110. /*
  12111. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  12112. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  12113. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  12114. * "RESUME"을 전달한다.
  12115. */
  12116. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12117. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12118. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12119. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  12120. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  12121. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12122. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12123. startActivity(newintent);
  12124. return;
  12125. }
  12126. } else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  12127. if (OutModeRunAppRun == true) {
  12128. Log.d(TAG, "already outmoderun app running !!!!");
  12129. return;
  12130. }
  12131. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12132. int sensor = devset.Get_Sensor_Set();
  12133. devset.closeDB();
  12134. int base = 7000;
  12135. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12136. int Menu_Start_Id = 0;
  12137. int Menu_Start_Option = 1;
  12138. if (sensor > 0) {
  12139. WallPadInterface wpifc = new WallPadInterface();
  12140. int[] SensorInfoDB;
  12141. int inSen = 0;
  12142. int outSen = 0;
  12143. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12144. if (SensorInfoDB[0] == 1) {
  12145. // 내부동체가 사용함이면 상태 검사
  12146. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12147. }
  12148. if (SensorInfoDB[1] == 1) {
  12149. // 외부동체가 사용함이면 상태 검사
  12150. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12151. }
  12152. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12153. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12154. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
  12155. ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  12156. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12157. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12158. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12159. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12160. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12161. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
  12162. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12163. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12164. startActivity(newintent);
  12165. return;
  12166. }
  12167. }
  12168. base = 8000;
  12169. Menu_Id_List = new int[]{base + 11};
  12170. Menu_Start_Id = base + 11;
  12171. Menu_Start_Option = -1;
  12172. Intent intent = new Intent(Intent.ACTION_MAIN);
  12173. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12174. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12175. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12176. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  12177. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12178. startActivity(intent);
  12179. } else if (alarmstate == WallpadStatusData.GUARD_IN) {
  12180. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12181. int sensor = devset.Get_Sensor_Set();
  12182. devset.closeDB();
  12183. int base = 7000;
  12184. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12185. int Menu_Start_Option = 1;
  12186. if (sensor > 0) {
  12187. WallPadInterface wpifc = new WallPadInterface();
  12188. int[] SensorInfoDB;
  12189. int outSen = 0;
  12190. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12191. if (SensorInfoDB[1] == 1) {
  12192. // 외부동체가 사용함이면 상태 검사
  12193. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12194. }
  12195. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12196. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
  12197. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12198. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12199. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12200. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12201. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12202. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  12203. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12204. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12205. startActivity(newintent);
  12206. return;
  12207. }
  12208. }
  12209. } else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  12210. WallPadInterface wpifc = new WallPadInterface();
  12211. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  12212. return;
  12213. } else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  12214. int base = 4000;
  12215. int Menu_Start_Id = 0;
  12216. int[] Menu_Id_List = new int[]{base + 11, base + 21};
  12217. Menu_Start_Id = base + 11;
  12218. Intent intent = new Intent(Intent.ACTION_MAIN);
  12219. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12220. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12221. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  12222. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  12223. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12224. startActivity(intent);
  12225. return;
  12226. }
  12227. } catch (RuntimeException re) {
  12228. LogUtil.errorLogInfo("", TAG, re);
  12229. } catch (Exception e) {
  12230. Log.e(TAG, "[Exception] CheckMainStatus()");
  12231. //e.printStackTrace();
  12232. LogUtil.errorLogInfo("", TAG, e);
  12233. }
  12234. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12235. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  12236. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12237. // {
  12238. // WallPadInterface wpifc = new WallPadInterface();
  12239. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  12240. //
  12241. // if (fleeSensor > 0)
  12242. // {
  12243. // int base = 7000;
  12244. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12245. // int Menu_Start_Option = 1;
  12246. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12247. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12248. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  12249. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12250. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  12251. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12252. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12253. // startActivity(newintent);
  12254. // devset.closeDB();
  12255. // return;
  12256. // }
  12257. // }
  12258. //
  12259. // StatusVal = devset.GetDeviceSetted("알람발생");
  12260. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12261. // {
  12262. // WallPadInterface wpifc = new WallPadInterface();
  12263. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  12264. //
  12265. // if (AlarmSensor > 0)
  12266. // {
  12267. // int base = 7000;
  12268. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12269. // int Menu_Start_Option = 1;
  12270. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12271. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12272. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  12273. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12274. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  12275. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12276. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12277. // startActivity(newintent);
  12278. // devset.closeDB();
  12279. // return;
  12280. // }
  12281. //
  12282. // }
  12283. // devset.closeDB();
  12284. }
  12285. /**
  12286. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  12287. *
  12288. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  12289. */
  12290. public boolean GetUseIlgalControlForAdmin() {
  12291. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12292. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  12293. devSet.closeDB();
  12294. boolean result = false;
  12295. if (MetringDB != null) {
  12296. try {
  12297. String devInfo = MetringDB[1];
  12298. devInfo = devInfo.replace('(', '_');
  12299. devInfo = devInfo.replace(':', '_');
  12300. devInfo = devInfo.replace(')', '_');
  12301. String[] MetringInfo = devInfo.split("_");
  12302. if (MetringInfo[3].equals("사용함") == true) {
  12303. result = true;
  12304. }
  12305. } catch (RuntimeException re) {
  12306. LogUtil.errorLogInfo("", TAG, re);
  12307. } catch (Exception e) {
  12308. //e.printStackTrace();
  12309. LogUtil.errorLogInfo("", TAG, e);
  12310. }
  12311. }
  12312. return result;
  12313. }
  12314. class SendLHGWCheck extends Thread {
  12315. private iMAP_hn_config_read m_HnGWConfigRead = null;
  12316. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  12317. private boolean retSucces = false;
  12318. private int retryCount = 0;
  12319. public SendLHGWCheck() {
  12320. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  12321. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  12322. retryCount = 0;
  12323. }
  12324. public void run() {
  12325. try {
  12326. try {
  12327. Thread.sleep(2000);
  12328. } catch (RuntimeException re) {
  12329. LogUtil.errorLogInfo("", TAG, re);
  12330. } catch (Exception e) {
  12331. LogUtil.errorLogInfo("", TAG, e);
  12332. }
  12333. for (int i = 0; i < 10; i++) {
  12334. m_HnGWConfigRead.DoWork();
  12335. m_HnGWConfigRead.SetRetCtr(new RetProci() {
  12336. @Override
  12337. public void ProcSuccess() {
  12338. retSucces = true;
  12339. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
  12340. }
  12341. @Override
  12342. public void ProcError() {
  12343. }
  12344. @Override
  12345. public void ProcDoing() {
  12346. // TODO Auto-generated method stub
  12347. }
  12348. });
  12349. if (retSucces == true)
  12350. break;
  12351. retryCount++;
  12352. try {
  12353. Thread.sleep(3000);
  12354. } catch (RuntimeException re) {
  12355. LogUtil.errorLogInfo("", TAG, re);
  12356. } catch (Exception e) {
  12357. LogUtil.errorLogInfo("", TAG, e);
  12358. }
  12359. }
  12360. m_HnGWEmptyMsg.DoWork();
  12361. m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
  12362. @Override
  12363. public void ProcSuccess() {
  12364. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
  12365. }
  12366. @Override
  12367. public void ProcError() {
  12368. Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
  12369. }
  12370. @Override
  12371. public void ProcDoing() {
  12372. // TODO Auto-generated method stub
  12373. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
  12374. }
  12375. });
  12376. } catch (RuntimeException re) {
  12377. LogUtil.errorLogInfo("", TAG, re);
  12378. } catch (Exception e) {
  12379. //e.printStackTrace();
  12380. LogUtil.errorLogInfo("", TAG, e);
  12381. }
  12382. }
  12383. }
  12384. //Reset Handler
  12385. private Handler mResetHandler = new Handler() {
  12386. @Override
  12387. public void handleMessage(Message msg) {
  12388. if (msg.what == 0) {
  12389. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  12390. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  12391. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  12392. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  12393. if (NowMainStatus == false) {
  12394. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12395. ResetCount = 1;
  12396. }
  12397. ResetCount++;
  12398. NowMainStatus = true;
  12399. if (ResetCount == 30) {
  12400. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12401. } else {
  12402. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12403. }
  12404. } else {
  12405. if (NowMainStatus == true) {
  12406. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12407. ResetCount = 1;
  12408. }
  12409. ResetCount++;
  12410. NowMainStatus = false;
  12411. if (ResetCount == 180) {
  12412. // 3분
  12413. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12414. } else {
  12415. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12416. }
  12417. }
  12418. } else if (msg.what == 1) {
  12419. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  12420. setDefaultLauncher();
  12421. Intent intent = new Intent();
  12422. intent.setAction(define.NOTIFY_ACNAME);
  12423. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12424. getApplicationContext().sendBroadcast(intent);
  12425. }
  12426. }
  12427. };
  12428. // 통화주체를 다루는 enum
  12429. public enum CALLOWNER {
  12430. NONE,
  12431. WALLPAD,
  12432. SUB_WALLPAD,
  12433. KITCHEN_TV,
  12434. BATH_PHONE,
  12435. BATH_TV,
  12436. UNIVERSAL_DEVICE,
  12437. ERROR;
  12438. }
  12439. public enum CALLEVENTTYPE {
  12440. RECEIVE_CALL, // 호출 수신 (호출 수신)
  12441. TRYING_CALL, // 호출 시도중 (호출 발신)
  12442. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  12443. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  12444. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  12445. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  12446. CONNECT_CALL, // 통화 시작
  12447. TERMINATE_CALL, // 통화 종료
  12448. CANCEL_CALL, // 호출 취소
  12449. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  12450. REJECT_CALL, // 호출수신 거절
  12451. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  12452. FORWARD_CALL, // 착신전환 설정
  12453. CALLERID, // Caller ID
  12454. TIMEOUT_1STCALL, // 1st Call Timeout
  12455. TIMEOUT_2NDCALL, // 2nd Call Timeout
  12456. TIMEOUT_3RDCALL, // 3rd Call Timeout
  12457. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  12458. DOOR_OPEN, // 문열림 설정
  12459. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  12460. PSTN_DTMF, // PSTN DTMF 수신
  12461. DETECT_STRANGER, // 거동수상자 발생
  12462. NONE;
  12463. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  12464. try {
  12465. if (value.equals(RECEIVE_CALL.toString())) {
  12466. return RECEIVE_CALL;
  12467. } else if (value.equals(TRYING_CALL.toString())) {
  12468. return TRYING_CALL;
  12469. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  12470. return RECEIVE_CALL_2ND;
  12471. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  12472. return RECEIVE_CALL_ACK;
  12473. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  12474. return REQUEST_FRONT_MONITORING;
  12475. } else if (value.equals(CONNECT_CALL.toString())) {
  12476. return CONNECT_CALL;
  12477. } else if (value.equals(TERMINATE_CALL.toString())) {
  12478. return TERMINATE_CALL;
  12479. } else if (value.equals(CANCEL_CALL.toString())) {
  12480. return CANCEL_CALL;
  12481. } else if (value.equals(REJECT_CALL.toString())) {
  12482. return REJECT_CALL;
  12483. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  12484. return REJECT_BUSY_CALL;
  12485. } else if (value.equals(FORWARD_CALL.toString())) {
  12486. return FORWARD_CALL;
  12487. } else if (value.equals(CALLERID.toString())) {
  12488. return CALLERID;
  12489. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  12490. return TIMEOUT_1STCALL;
  12491. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  12492. return TIMEOUT_2NDCALL;
  12493. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  12494. return TIMEOUT_3RDCALL;
  12495. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  12496. return MOIP_VIDEO_SET;
  12497. } else if (value.equals(DOOR_OPEN.toString())) {
  12498. return DOOR_OPEN;
  12499. } else if (value.equals(PSTN_RING.toString())) {
  12500. return PSTN_RING;
  12501. } else if (value.equals(PSTN_DTMF.toString())) {
  12502. return PSTN_DTMF;
  12503. } else if (value.equals(DETECT_STRANGER.toString())) {
  12504. return DETECT_STRANGER;
  12505. } else if (value.equals(NONE.toString())) {
  12506. return NONE;
  12507. } else {
  12508. return null;
  12509. }
  12510. } catch (RuntimeException re) {
  12511. LogUtil.errorLogInfo("", "", re);
  12512. return null;
  12513. } catch (Exception e) {
  12514. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  12515. //e.printStackTrace();
  12516. LogUtil.errorLogInfo("", "", e);
  12517. return null;
  12518. }
  12519. }
  12520. }
  12521. public enum CALLTYPE {
  12522. NONE,
  12523. FRONT,
  12524. RESIDENCE,
  12525. LOBBY,
  12526. GUARD,
  12527. PSTN,
  12528. IHUB,
  12529. ERROR,
  12530. }
  12531. public static class CALLTRIGGER {
  12532. public static String CALLOWNER = "CALLOWNER";
  12533. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  12534. public static String CALLTYPE = "CALLTYPE";
  12535. public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
  12536. public enum SOURCE {
  12537. USER,
  12538. CALL_RECEIVE,
  12539. SUBPHONE
  12540. }
  12541. public enum TYPE {
  12542. MENU,
  12543. FRONT,
  12544. LOBBY,
  12545. GUARD,
  12546. RESIDENCE,
  12547. PSTN
  12548. }
  12549. }
  12550. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  12551. int TAB_TALKFRONT = 130011;
  12552. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  12553. try {
  12554. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
  12555. if (!bWallPadCallLive) {
  12556. sendLCDBacklightStatus(true);
  12557. // 통화어플을 실행시킨다.
  12558. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12559. Common.SendAppFinishReqBR(getApplicationContext());
  12560. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12561. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12562. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  12563. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12564. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12565. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12566. mIntent.setComponent(mComponentName);
  12567. startActivity(mIntent);
  12568. playFrontBell(eCallOwner, eEventType, eCallType);
  12569. } else {
  12570. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  12571. // if (getUseSmartDoorCam()) {
  12572. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  12573. // }
  12574. }
  12575. } catch (RuntimeException re) {
  12576. LogUtil.errorLogInfo("", TAG, re);
  12577. } catch (Exception e) {
  12578. Log.e(TAG, "[Exception] runCallMainActivity()");
  12579. //e.printStackTrace();
  12580. LogUtil.errorLogInfo("", TAG, e);
  12581. }
  12582. }
  12583. //add KSJ 2021.11.02
  12584. public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
  12585. try {
  12586. if (!bWallPadCallLive || m_bWallpadCallScreen) {
  12587. // 통화어플을 실행시킨다.
  12588. Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
  12589. sendLCDBacklightStatus(true);
  12590. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  12591. int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
  12592. mWallpadStatusData.closeDB();
  12593. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12594. Common.SendAppFinishReqBR(getApplicationContext());
  12595. if(m_bWallpadCallScreen)
  12596. Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  12597. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12598. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12599. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  12600. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12601. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12602. mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
  12603. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12604. mIntent.setComponent(mComponentName);
  12605. startActivity(mIntent);
  12606. Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  12607. } else {
  12608. Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
  12609. }
  12610. } catch (RuntimeException re) {
  12611. LogUtil.errorLogInfo("", TAG, re);
  12612. } catch (Exception e) {
  12613. Log.e(TAG, "[Exception] runCallMainActivity()");
  12614. //e.printStackTrace();
  12615. LogUtil.errorLogInfo("", TAG, e);
  12616. }
  12617. }
  12618. //~add KSJ
  12619. private String getTopActivity() {
  12620. try {
  12621. ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  12622. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  12623. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  12624. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  12625. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  12626. return mComponentName.getPackageName();
  12627. } catch (RuntimeException re) {
  12628. LogUtil.errorLogInfo("", TAG, re);
  12629. return null;
  12630. } catch (Exception e) {
  12631. Log.e(TAG, "[Exception] getTopActivity()");
  12632. //e.printStackTrace();
  12633. LogUtil.errorLogInfo("", TAG, e);
  12634. return null;
  12635. }
  12636. }
  12637. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  12638. try {
  12639. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  12640. WallPadInterface Wiface = new WallPadInterface();
  12641. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  12642. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  12643. }
  12644. } catch (RuntimeException re) {
  12645. LogUtil.errorLogInfo("", TAG, re);
  12646. } catch (Exception e) {
  12647. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  12648. //e.printStackTrace();
  12649. LogUtil.errorLogInfo("", TAG, e);
  12650. }
  12651. }
  12652. private class AfterTransactionTodoListData {
  12653. String Title;
  12654. int Valueint;
  12655. String ValueString;
  12656. private AfterTransactionTodoListData(String title, int valueint, String valueString) {
  12657. Title = title;
  12658. Valueint = valueint;
  12659. ValueString = valueString;
  12660. }
  12661. }
  12662. /**
  12663. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  12664. **/
  12665. public void SendGetParkingInfoIntent() {
  12666. Intent iIntent = new Intent();
  12667. iIntent.setAction(define.NOTIFY_ACNAME);
  12668. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  12669. this.sendBroadcast(iIntent);
  12670. }
  12671. /**
  12672. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  12673. **/
  12674. public Handler SendParkingInfoIntentAfter20min = new Handler() {
  12675. @SuppressLint("HandlerLeak")
  12676. @Override
  12677. public void handleMessage(Message msg) {
  12678. if (msg.what == 0) {
  12679. SendGetParkingInfoIntent();
  12680. }
  12681. }
  12682. };
  12683. /**
  12684. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  12685. **/
  12686. public Handler mWallPadOutmodeSleepHandler = new Handler() {
  12687. @SuppressLint("HandlerLeak")
  12688. @Override
  12689. public void handleMessage(Message msg) {
  12690. if (msg.what == 0) {
  12691. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  12692. }
  12693. }
  12694. };
  12695. // Handler
  12696. public final class HANDLERMSG {
  12697. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  12698. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  12699. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  12700. public final static int CALLAPP_FINISHING_END = 300;
  12701. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  12702. }
  12703. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  12704. public void handleMessage(Message msg) {
  12705. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  12706. switch (msg.what) {
  12707. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  12708. bGlobalScreenRun = true;
  12709. break;
  12710. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  12711. bGlobalScreenRun = false;
  12712. break;
  12713. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  12714. break;
  12715. case HANDLERMSG.CALLAPP_FINISHING_END:
  12716. // bBlockCallEvent = false;
  12717. break;
  12718. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  12719. int time = Sound().PlayMent(SND.call.DINGDONG);
  12720. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  12721. if (time < 0) time = 2088;
  12722. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  12723. break;
  12724. default:
  12725. Log.v(TAG, "iMAPServerHandler : " + msg.what);
  12726. break;
  12727. }
  12728. }
  12729. };
  12730. public void sendHandlerMsg(int what, int arg1, int arg2) {
  12731. try {
  12732. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  12733. Message HandleMsg = iMAPServerHandler.obtainMessage();
  12734. HandleMsg.what = what;
  12735. HandleMsg.arg1 = arg1;
  12736. HandleMsg.arg2 = arg2;
  12737. iMAPServerHandler.sendMessage(HandleMsg);
  12738. } catch (RuntimeException re) {
  12739. LogUtil.errorLogInfo("", TAG, re);
  12740. } catch (Exception e) {
  12741. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  12742. //e.printStackTrace();
  12743. LogUtil.errorLogInfo("", TAG, e);
  12744. }
  12745. }
  12746. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  12747. try {
  12748. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  12749. Message HandleMsg = iMAPServerHandler.obtainMessage();
  12750. HandleMsg.what = what;
  12751. HandleMsg.arg1 = arg1;
  12752. HandleMsg.arg2 = arg2;
  12753. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  12754. } catch (RuntimeException re) {
  12755. LogUtil.errorLogInfo("", TAG, re);
  12756. } catch (Exception e) {
  12757. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  12758. //e.printStackTrace();
  12759. LogUtil.errorLogInfo("", TAG, e);
  12760. }
  12761. }
  12762. int mSensitivity = 0, mDuration = 0;
  12763. int MIN_SENSOR_SENSITIVITY = 1;
  12764. int MAX_SENSOR_SENSITIVITY = 5;
  12765. int MIN_SENSOR_DURATION = 30;
  12766. int MAX_SENSOR_DURATION = 250;
  12767. int DEFAULT_SENSOR_SENSITIVITY = 3;
  12768. int DEFAULT_SENSOR_DURATION = 60;
  12769. private final int COMPONENT_USE = 1;
  12770. /**
  12771. * 스마트현관카메라 사용여부 판별
  12772. */
  12773. private boolean getUseSmartDoorCam() {
  12774. try {
  12775. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12776. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  12777. mWallpadDeviceSet.closeDB();
  12778. if (nFrontCam[0] == COMPONENT_USE) {
  12779. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  12780. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  12781. return true;
  12782. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  12783. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  12784. return true;
  12785. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  12786. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  12787. return true;
  12788. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  12789. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  12790. return true;
  12791. } else {
  12792. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  12793. return false;
  12794. }
  12795. } else {
  12796. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  12797. return false;
  12798. }
  12799. } catch (RuntimeException re) {
  12800. LogUtil.errorLogInfo("", TAG, re);
  12801. return false;
  12802. } catch (Exception e) {
  12803. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  12804. //e.printStackTrace();
  12805. LogUtil.errorLogInfo("", TAG, e);
  12806. return false;
  12807. }
  12808. }
  12809. private int getSmartDoorCamType() {
  12810. try {
  12811. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12812. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  12813. mWallpadDeviceSet.closeDB();
  12814. if (nFrontCam[0] == COMPONENT_USE) {
  12815. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  12816. return nFrontCam[1];
  12817. }
  12818. }
  12819. } catch (RuntimeException re) {
  12820. LogUtil.errorLogInfo("", TAG, re);
  12821. } catch (Exception e) {
  12822. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  12823. //e.printStackTrace();
  12824. LogUtil.errorLogInfo("", TAG, e);
  12825. }
  12826. return -1;
  12827. }
  12828. /**
  12829. * 방문객원격통화 솔루션 사용여부 판별
  12830. */
  12831. private boolean getRemoteCallUseInfo() {
  12832. try {
  12833. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  12834. if (mWallpadDeviceSet != null) {
  12835. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  12836. if (astrRemoteCall != null) {
  12837. if (astrRemoteCall[1].contains("사용함")) return true;
  12838. } else {
  12839. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  12840. }
  12841. }
  12842. mWallpadDeviceSet.closeDB();
  12843. } catch (RuntimeException re) {
  12844. LogUtil.errorLogInfo("", TAG, re);
  12845. } catch (Exception e) {
  12846. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  12847. //e.printStackTrace();
  12848. LogUtil.errorLogInfo("", TAG, e);
  12849. }
  12850. return false;
  12851. }
  12852. /*
  12853. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  12854. */
  12855. private RealTimeMeterAPI mRealTimeMeterAPI;
  12856. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  12857. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  12858. public Thread saveRealmeterDataThread = null;
  12859. private void startRealtimemeterInfo() {
  12860. try {
  12861. // 영업샘플 모드 판단
  12862. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  12863. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  12864. } else {
  12865. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  12866. // 실시간 검침기 사용유무 판단
  12867. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12868. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  12869. mWallpadDeviceSet.closeDB();
  12870. boolean bRealtimemeterUsage = false;
  12871. int nRealtimemeterCntDB = -99;
  12872. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  12873. // 실시간 검침 사용함
  12874. bRealtimemeterUsage = true;
  12875. nRealtimemeterCntDB = naRealtimemtInfo[1];
  12876. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  12877. } else {
  12878. // 실시간 검침 사용하지 않음
  12879. bRealtimemeterUsage = false;
  12880. }
  12881. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
  12882. }
  12883. } catch (RuntimeException re) {
  12884. LogUtil.errorLogInfo("", TAG, re);
  12885. } catch (Exception e) {
  12886. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  12887. //e.printStackTrace();
  12888. LogUtil.errorLogInfo("", TAG, e);
  12889. }
  12890. }
  12891. private void startSmartIoTCamInfo() {
  12892. try {
  12893. // 영업샘플 모드 판단
  12894. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  12895. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  12896. } else {
  12897. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  12898. if (getUseSmartDoorCam()) {
  12899. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  12900. } else {
  12901. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  12902. }
  12903. }
  12904. } catch (RuntimeException re) {
  12905. LogUtil.errorLogInfo("", TAG, re);
  12906. } catch (Exception e) {
  12907. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  12908. //e.printStackTrace();
  12909. LogUtil.errorLogInfo("", TAG, e);
  12910. }
  12911. }
  12912. private void startDistributionPanel() {
  12913. try {
  12914. // 영업샘플 모드 판단
  12915. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  12916. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  12917. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  12918. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  12919. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12920. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  12921. mWallpadDeviceSet.closeDB();
  12922. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
  12923. initSmartDistributionPanelHandler.sendEmptyMessage(0);
  12924. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
  12925. initKNXDistributionPanelHandler.sendEmptyMessage(0);
  12926. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  12927. } else {
  12928. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  12929. }
  12930. } catch (RuntimeException re) {
  12931. LogUtil.errorLogInfo("", TAG, re);
  12932. } catch (Exception e) {
  12933. Log.e(TAG, "[Exception] startDistributionPanel()");
  12934. //e.printStackTrace();
  12935. LogUtil.errorLogInfo("", TAG, e);
  12936. }
  12937. }
  12938. // =================================================================================================
  12939. // [[ Device ]] region
  12940. // =================================================================================================
  12941. /**
  12942. * 디바이스 API 를 Load 한다.
  12943. *
  12944. * @param wpapi - 생성시 전달받은 WallPadAPI
  12945. * @return (int) - >=0 : 성공, <0 : 실패
  12946. */
  12947. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  12948. // 1. Mode Check
  12949. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  12950. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  12951. return -1;
  12952. }
  12953. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  12954. // 2. wpapi Check
  12955. if (wpapi == null) {
  12956. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  12957. return -2;
  12958. }
  12959. // 3. Load API
  12960. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  12961. try {
  12962. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  12963. } catch (RuntimeException re) {
  12964. LogUtil.errorLogInfo("", TAG, re);
  12965. return -100;
  12966. } catch (Exception e) {
  12967. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  12968. //e.printStackTrace();
  12969. LogUtil.errorLogInfo("", TAG, e);
  12970. return -100;
  12971. }
  12972. if (mRealTimeMeterAPI == null) {
  12973. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  12974. return -4;
  12975. }
  12976. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  12977. return 0;
  12978. }
  12979. /**
  12980. * 제어기 상태를 가져온다.
  12981. *
  12982. * @param real - (boolean) true : 실시간 , false : 가장최근
  12983. * @return (int) - >=0 : 성공, <0 : 실패
  12984. */
  12985. @SuppressWarnings("unused")
  12986. private int updateRealtimemeterData(boolean real) {
  12987. try {
  12988. // 1. Api Load Check
  12989. if (mRealTimeMeterAPI == null) {
  12990. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  12991. return -1;
  12992. }
  12993. // 2. reflash
  12994. try {
  12995. int ret = mRealTimeMeterAPI.Refresh(real);
  12996. if (ret < 0) {
  12997. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  12998. return -2;
  12999. }
  13000. } catch (RuntimeException re) {
  13001. LogUtil.errorLogInfo("", TAG, re);
  13002. return -100;
  13003. } catch (Exception e) {
  13004. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  13005. //e.printStackTrace();
  13006. LogUtil.errorLogInfo("", TAG, e);
  13007. return -100;
  13008. }
  13009. // 3. Range Check
  13010. if (mRealTimeMeterAPI.data == null) {
  13011. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  13012. return -9;
  13013. }
  13014. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  13015. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  13016. return -10;
  13017. }
  13018. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  13019. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  13020. return -11;
  13021. }
  13022. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  13023. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  13024. return -12;
  13025. }
  13026. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  13027. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  13028. return -13;
  13029. }
  13030. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  13031. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  13032. return -14;
  13033. }
  13034. // 4. Data Copy
  13035. mRealTimeMeterData = mRealTimeMeterAPI.data;
  13036. // 5. Debug msg
  13037. if (DEBUG_REALMETER_DATA_LOG_ON) {
  13038. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  13039. Log.i(TAG, "[updateRealtimemeterData] - OK");
  13040. }
  13041. return 0;
  13042. } catch (RuntimeException re) {
  13043. LogUtil.errorLogInfo("", TAG, re);
  13044. return -99;
  13045. } catch (Exception e) {
  13046. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  13047. //e.printStackTrace();
  13048. LogUtil.errorLogInfo("", TAG, e);
  13049. return -99;
  13050. }
  13051. }
  13052. /**
  13053. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  13054. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  13055. * 본 딜레이 코드를 임시로 적용한다.
  13056. */
  13057. @SuppressLint("HandlerLeak")
  13058. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  13059. @SuppressLint("HandlerLeak")
  13060. @Override
  13061. public void handleMessage(Message msg) {
  13062. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  13063. if (msg.what == 0) {
  13064. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  13065. if (updateRealtimemeterData(false) == 0) {
  13066. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13067. } else {
  13068. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13069. }
  13070. } else {
  13071. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  13072. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13073. }
  13074. } else if (msg.what == 1) {
  13075. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  13076. if (mRealTimeMeterAPI != null) {
  13077. // Device_BrRegistration(true);
  13078. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13079. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13080. mWallpadDeviceSet.closeDB();
  13081. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  13082. saveRealmeterDataThread = new saveRealmeterData();
  13083. saveRealmeterDataThread.start();
  13084. }
  13085. // RemoveUsedData();
  13086. // ShowUsedDataGraph();
  13087. }
  13088. }
  13089. }
  13090. };
  13091. protected Handler initSmartDistributionPanelHandler = new Handler() {
  13092. @SuppressLint("HandlerLeak")
  13093. @Override
  13094. public void handleMessage(Message msg) {
  13095. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  13096. if (msg.what == 0) {
  13097. if (mWallPadAPI.Check_Connect())
  13098. initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13099. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13100. } else if (msg.what == 1) {
  13101. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  13102. mSdbAPI = mWallPadAPI.Get_SdbController();
  13103. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  13104. mSdb_LivingRoomLightAPI.Refresh();
  13105. }
  13106. }
  13107. };
  13108. protected Handler initKNXDistributionPanelHandler = new Handler() {
  13109. @SuppressLint("HandlerLeak")
  13110. @Override
  13111. public void handleMessage(Message msg) {
  13112. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  13113. if (msg.what == 0) {
  13114. if (mWallPadAPI.Check_Connect())
  13115. initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13116. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13117. } else if (msg.what == 1) {
  13118. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  13119. mKnxAPI = mWallPadAPI.Get_KnxController();
  13120. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  13121. mKnx_LivingRoomLightAPI.Refresh();
  13122. }
  13123. }
  13124. };
  13125. protected Handler initSmartIoTFunctionHandler = new Handler() {
  13126. @SuppressLint("HandlerLeak")
  13127. @Override
  13128. public void handleMessage(Message msg) {
  13129. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  13130. if (msg.what == 0) {
  13131. if (mWallPadAPI.Check_Connect())
  13132. initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13133. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  13134. } else if (msg.what == 1) {
  13135. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  13136. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  13137. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
  13138. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
  13139. Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
  13140. // 거동수상자 녹화를 위한 자동 On 기능 비활성화
  13141. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  13142. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  13143. }
  13144. }
  13145. };
  13146. // 스마트현관카메라 MODE 제어
  13147. private void ctrlSmartIOTCamStatusMode(byte mode) {
  13148. try {
  13149. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  13150. if (mSmartKeyRfDoorAPI != null) {
  13151. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  13152. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  13153. } else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  13154. } catch (RuntimeException re) {
  13155. LogUtil.errorLogInfo("", TAG, re);
  13156. } catch (Exception e) {
  13157. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  13158. //e.printStackTrace();
  13159. LogUtil.errorLogInfo("", TAG, e);
  13160. }
  13161. }
  13162. // 스마트현관카메라 LED 상태 제어
  13163. private void ctrlSmartIOTCamLEDMode(byte mode) {
  13164. try {
  13165. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  13166. if (mSmartKeyRfDoorAPI != null) {
  13167. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  13168. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  13169. } else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  13170. } catch (RuntimeException re) {
  13171. LogUtil.errorLogInfo("", TAG, re);
  13172. } catch (Exception e) {
  13173. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  13174. //e.printStackTrace();
  13175. LogUtil.errorLogInfo("", TAG, e);
  13176. }
  13177. }
  13178. // 현관카메라 거동수상자 감지시간
  13179. private byte getSmartDoorCamDuration() {
  13180. try {
  13181. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
  13182. byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
  13183. wallpadDeviceSet.closeDB();
  13184. Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
  13185. return duration;
  13186. } catch (RuntimeException re) {
  13187. LogUtil.errorLogInfo("", TAG, re);
  13188. } catch (Exception e) {
  13189. Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
  13190. //e.printStackTrace();
  13191. LogUtil.errorLogInfo("", TAG, e);
  13192. }
  13193. return (byte) 0x05;
  13194. }
  13195. // =================================================================================================
  13196. // [[ Thread ]] region
  13197. // =================================================================================================
  13198. /**
  13199. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  13200. * 10분에 한번씩 저장
  13201. */
  13202. @SuppressLint("UseValueOf")
  13203. class saveRealmeterData extends Thread {
  13204. @Override
  13205. public void run() {
  13206. super.run();
  13207. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  13208. int ret;
  13209. wallpaddbmgr WallpadDBMGRforThread = null;
  13210. while (true) {
  13211. try {
  13212. Thread.sleep(1000 * 60 * 3); //3분마다
  13213. if (mRealTimeMeterAPI != null) {
  13214. ret = mRealTimeMeterAPI.Refresh(false);
  13215. if (ret == 0) {
  13216. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  13217. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
  13218. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  13219. WallpadDBMGRforThread.InsertRealTimeMeterData(
  13220. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  13221. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  13222. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  13223. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  13224. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  13225. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  13226. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  13227. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  13228. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  13229. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  13230. );
  13231. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  13232. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
  13233. if (tempInt > 6000) {
  13234. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  13235. }
  13236. WallpadDBMGRforThread.closeDB();
  13237. } else {
  13238. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  13239. }
  13240. } else {
  13241. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  13242. }
  13243. } catch (InterruptedException e1) {
  13244. // TODO Auto-generated catch block
  13245. if (WallpadDBMGRforThread != null) {
  13246. WallpadDBMGRforThread.closeDB();
  13247. }
  13248. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  13249. //e1.printStackTrace();
  13250. LogUtil.errorLogInfo("", TAG, e1);
  13251. }
  13252. }
  13253. }
  13254. }
  13255. /**
  13256. * 단지서버 2.0 사용여부
  13257. *
  13258. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  13259. **/
  13260. public boolean NewServerUse() {
  13261. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  13262. if (SetData != null) {
  13263. String serverVesionInfo = SetData.GetServerVer();
  13264. SetData.closeDB();
  13265. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  13266. return true;
  13267. }
  13268. }
  13269. return false;
  13270. }
  13271. /**
  13272. * 단지서버2.0 적용시에만 사용한다.
  13273. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  13274. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  13275. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  13276. **/
  13277. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  13278. String REMOTETYPE_SVR2WEB = "danji_web_control";
  13279. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  13280. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  13281. try {
  13282. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13283. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13284. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13285. NodeList mNodeList = doc.getElementsByTagName("device_info");
  13286. Node mNode = mNodeList.item(0);
  13287. if (mNode != null) {
  13288. String alias = "null", twinid = "null";
  13289. NamedNodeMap attrsParam = mNode.getAttributes();
  13290. for (int j = 0; j < attrsParam.getLength(); j++) {
  13291. Node attr = attrsParam.item(j);
  13292. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13293. alias = attr.getNodeValue();
  13294. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13295. twinid = attr.getNodeValue();
  13296. }
  13297. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13298. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13299. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  13300. return MOBILE_USER_AUTH_PASSED;
  13301. }
  13302. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13303. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13304. mWallpadMobileDeviceData.closeDB();
  13305. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13306. else {
  13307. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  13308. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13309. return strReplyMsg;
  13310. }
  13311. } else {
  13312. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13313. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13314. return strReplyMsg;
  13315. }
  13316. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13317. NodeList mNodeList = doc.getElementsByTagName("password_info");
  13318. Node mNode = mNodeList.item(0);
  13319. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13320. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13321. mWallpadStatusData.closeDB();
  13322. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
  13323. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13324. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13325. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13326. return strReplyMsg;
  13327. }
  13328. if (mNode != null) {
  13329. String strReceivedPW = "000000";
  13330. NamedNodeMap attrsParam = mNode.getAttributes();
  13331. for (int j = 0; j < attrsParam.getLength(); j++) {
  13332. Node attr = attrsParam.item(j);
  13333. if (attr.getNodeName().equalsIgnoreCase("password"))
  13334. strReceivedPW = attr.getNodeValue();
  13335. }
  13336. if (!checkPWValidation(strReceivedPW)) {
  13337. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13338. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13339. return strReplyMsg;
  13340. }
  13341. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13342. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13343. return WEB_USER_AUTH_PASSED;
  13344. } else {
  13345. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13346. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13347. return strReplyMsg;
  13348. }
  13349. } else {
  13350. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13351. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13352. return strReplyMsg;
  13353. }
  13354. } else {
  13355. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13356. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13357. return strReplyMsg;
  13358. }
  13359. } catch (RuntimeException re) {
  13360. LogUtil.errorLogInfo("", TAG, re);
  13361. return null;
  13362. } catch (Exception e) {
  13363. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  13364. //e.printStackTrace();
  13365. LogUtil.errorLogInfo("", TAG, e);
  13366. return null;
  13367. }
  13368. }
  13369. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  13370. try {
  13371. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13372. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13373. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13374. NodeList mNodeList = ele.getElementsByTagName("device_info");
  13375. Node mNode = mNodeList.item(0);
  13376. if (mNode != null) {
  13377. String alias = "null", twinid = "null";
  13378. NamedNodeMap attrsParam = mNode.getAttributes();
  13379. for (int j = 0; j < attrsParam.getLength(); j++) {
  13380. Node attr = attrsParam.item(j);
  13381. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13382. alias = attr.getNodeValue();
  13383. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13384. twinid = attr.getNodeValue();
  13385. }
  13386. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13387. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13388. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  13389. return MOBILE_USER_AUTH_PASSED;
  13390. }
  13391. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13392. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13393. mWallpadMobileDeviceData.closeDB();
  13394. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13395. else {
  13396. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  13397. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  13398. return strReplyMsg;
  13399. }
  13400. } else {
  13401. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13402. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13403. return strReplyMsg;
  13404. }
  13405. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13406. NodeList mNodeList = ele.getElementsByTagName("password_info");
  13407. Node mNode = mNodeList.item(0);
  13408. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13409. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13410. mWallpadStatusData.closeDB();
  13411. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13412. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13413. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13414. return strReplyMsg;
  13415. }
  13416. if (mNode != null) {
  13417. String strReceivedPW = "000000";
  13418. NamedNodeMap attrsParam = mNode.getAttributes();
  13419. for (int j = 0; j < attrsParam.getLength(); j++) {
  13420. Node attr = attrsParam.item(j);
  13421. if (attr.getNodeName().equalsIgnoreCase("password"))
  13422. strReceivedPW = attr.getNodeValue();
  13423. }
  13424. if (!checkPWValidation(strReceivedPW)) {
  13425. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13426. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13427. return strReplyMsg;
  13428. }
  13429. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13430. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13431. return WEB_USER_AUTH_PASSED;
  13432. } else {
  13433. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13434. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13435. return strReplyMsg;
  13436. }
  13437. } else {
  13438. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13439. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13440. return strReplyMsg;
  13441. }
  13442. } else {
  13443. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13444. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13445. return strReplyMsg;
  13446. }
  13447. } catch (RuntimeException re) {
  13448. LogUtil.errorLogInfo("", TAG, re);
  13449. return null;
  13450. } catch (Exception e) {
  13451. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  13452. //e.printStackTrace();
  13453. LogUtil.errorLogInfo("", TAG, e);
  13454. return null;
  13455. }
  13456. }
  13457. String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
  13458. private boolean checkPWValidation(String strPW) {
  13459. try {
  13460. // null 확인
  13461. if (strPW == null) {
  13462. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  13463. return false;
  13464. }
  13465. // 입력된 비밀번호 길이 확인
  13466. if (strPW.length() != 6) {
  13467. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  13468. return false;
  13469. }
  13470. // 사전 금지된 비밀번호 확인
  13471. for (int i = 0; i < astrPreventedPWs.length; i++) {
  13472. if (strPW.contains(astrPreventedPWs[i])) {
  13473. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  13474. return false;
  13475. }
  13476. }
  13477. /*// 연속된 비밀번호 확인
  13478. int nSerialNoCnt = 0;
  13479. int nCompareNo = 0;
  13480. int[] naPW = new int[strPW.length()];
  13481. for (int i = 0; i < naPW.length; i++)
  13482. {
  13483. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  13484. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  13485. if (i ==0) {
  13486. nCompareNo = naPW[i];
  13487. nCompareNo++;
  13488. }
  13489. else if (0 < i && i < 6) {
  13490. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  13491. nCompareNo++;
  13492. }
  13493. else {
  13494. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  13495. }
  13496. }
  13497. if (nSerialNoCnt > 3) {
  13498. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  13499. return false;
  13500. }*/
  13501. // 동일한 번호 5회이상 입력 확인
  13502. int nSameNoCnt = 0;
  13503. for (int i = 0; i < strPW.length() - 1; i++) {
  13504. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  13505. nSameNoCnt++;
  13506. }
  13507. }
  13508. if (nSameNoCnt > 4) {
  13509. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  13510. return false;
  13511. }
  13512. // 동, 호정보 확인
  13513. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  13514. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  13515. DBMGR.closeDB();
  13516. String strDong = addr.Dong;
  13517. String strHo = addr.Ho;
  13518. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  13519. if (strPW.substring(0, 4).contains(strDong)) {
  13520. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  13521. return false;
  13522. }
  13523. if (strPW.substring(0, 4).contains(strHo)) {
  13524. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  13525. return false;
  13526. }
  13527. return true;
  13528. } catch (RuntimeException re) {
  13529. LogUtil.errorLogInfo("", TAG, re);
  13530. return false;
  13531. } catch (Exception e) {
  13532. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  13533. //e.printStackTrace();
  13534. LogUtil.errorLogInfo("", TAG, e);
  13535. return false;
  13536. }
  13537. }
  13538. public String iCMDProcOnePass(Element ele) {
  13539. String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
  13540. String[] strDeviceInfo = {"null", "null"}; // alias, twinid
  13541. String strAction = "null", strTargetLobbyIP = "null";
  13542. try {
  13543. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  13544. String retStr = CheckiCMDProc("remote_access_onepass");
  13545. if (retStr != null)
  13546. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13547. // 단지서버 2.0 사용여부 확인
  13548. if (!NewServerUse()) {
  13549. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13550. }
  13551. // 메시지 송신지 구분
  13552. NodeList items = ele.getElementsByTagName("target");
  13553. Node item = items.item(0);
  13554. if (item != null) {
  13555. NamedNodeMap attrs = item.getAttributes();
  13556. for (int j = 0; j < attrs.getLength(); j++) {
  13557. Node attr = attrs.item(j);
  13558. if (attr.getNodeName().equalsIgnoreCase("name"))
  13559. strTarget[0] = attr.getNodeValue();
  13560. else if (attr.getNodeName().equalsIgnoreCase("id"))
  13561. strTarget[1] = attr.getNodeValue();
  13562. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  13563. strTarget[2] = attr.getNodeValue();
  13564. }
  13565. }
  13566. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  13567. if (NewServerUse()) {
  13568. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  13569. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  13570. if (ServerCheckResult.contains("fail"))
  13571. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13572. else if (ServerCheckResult.contains("deny"))
  13573. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13574. else if (ServerCheckResult.contains("none"))
  13575. return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  13576. else
  13577. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13578. }
  13579. }
  13580. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  13581. Node itemDeviceParam = itemsDeviceParam.item(0);
  13582. if (itemDeviceParam != null) {
  13583. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  13584. for (int j = 0; j < attrsParam.getLength(); j++) {
  13585. Node attr = attrsParam.item(j);
  13586. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13587. strDeviceInfo[0] = attr.getNodeValue();
  13588. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13589. strDeviceInfo[1] = attr.getNodeValue();
  13590. }
  13591. } else {
  13592. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13593. }
  13594. // 명령어 구분
  13595. NodeList itemsaction = ele.getElementsByTagName("action");
  13596. Node itemaction = itemsaction.item(0);
  13597. Node text = itemaction.getFirstChild();
  13598. strAction = text.getNodeValue();
  13599. strAction = trimquotation(strAction);
  13600. // 문열림 타겟 로비폰 IP
  13601. NodeList itemsParam = ele.getElementsByTagName("params");
  13602. Node itemParam = itemsParam.item(0);
  13603. if (itemParam != null) {
  13604. NamedNodeMap attrsParam = itemParam.getAttributes();
  13605. for (int j = 0; j < attrsParam.getLength(); j++) {
  13606. Node attr = attrsParam.item(j);
  13607. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  13608. strTargetLobbyIP = attr.getNodeValue();
  13609. }
  13610. }
  13611. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  13612. if (strAction.equalsIgnoreCase("authorize_request")) {
  13613. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  13614. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  13615. } else {
  13616. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13617. }
  13618. } catch (RuntimeException re) {
  13619. LogUtil.errorLogInfo("", TAG, re);
  13620. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13621. } catch (Exception e) {
  13622. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  13623. //e.printStackTrace();
  13624. LogUtil.errorLogInfo("", TAG, e);
  13625. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13626. }
  13627. }
  13628. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  13629. try {
  13630. String strReplyXml = XMLHeader;
  13631. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  13632. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  13633. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  13634. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  13635. strReplyXml += " </service>\n";
  13636. strReplyXml += "</imap>";
  13637. return strReplyXml;
  13638. } catch (RuntimeException re) {
  13639. LogUtil.errorLogInfo("", TAG, re);
  13640. return "ERROR";
  13641. } catch (Exception e) {
  13642. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  13643. //e.printStackTrace();
  13644. LogUtil.errorLogInfo("", TAG, e);
  13645. return "ERROR";
  13646. }
  13647. }
  13648. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  13649. try {
  13650. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
  13651. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  13652. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  13653. miMAPLobbyOnePass.SetRetCtr(new RetProci() {
  13654. @Override
  13655. public void ProcSuccess() {
  13656. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  13657. }
  13658. @Override
  13659. public void ProcError() {
  13660. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  13661. }
  13662. @Override
  13663. public void ProcDoing() {
  13664. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  13665. }
  13666. });
  13667. } catch (RuntimeException re) {
  13668. LogUtil.errorLogInfo("", TAG, re);
  13669. } catch (Exception e) {
  13670. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  13671. //e.printStackTrace();
  13672. LogUtil.errorLogInfo("", TAG, e);
  13673. }
  13674. }
  13675. public String iCMDProcResidentSafety(Element ele) {
  13676. try {
  13677. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  13678. String retStr = CheckiCMDProc("check_resident_safety");
  13679. if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
  13680. // 단지서버 2.0 사용여부 확인
  13681. if (!NewServerUse()) {
  13682. return makeReply_check_resident_safety("deny", null, null, null);
  13683. }
  13684. // 거주자 안전 확인 사용 여부
  13685. if (!bEnableResidentSafetyCheck) {
  13686. return makeReply_check_resident_safety("deny", null, null, null);
  13687. }
  13688. String strSecurity = getSecurityMode();
  13689. String strTouch = getTimeStamp_ScreenTouched();
  13690. String strMagnetic = getTimeStamp_Magnetic();
  13691. return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
  13692. } catch (RuntimeException re) {
  13693. LogUtil.errorLogInfo("", TAG, re);
  13694. return makeReply_check_resident_safety("fail", null, null, null);
  13695. } catch (Exception e) {
  13696. Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
  13697. //e.printStackTrace();
  13698. LogUtil.errorLogInfo("", TAG, e);
  13699. return makeReply_check_resident_safety("fail", null, null, null);
  13700. }
  13701. }
  13702. public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
  13703. try {
  13704. String strReplyXml = XMLHeader;
  13705. strReplyXml += " <service type=\"reply\" name=\"check_resident_safety\" result=\"" + strResult + "\">\n";
  13706. if (strResult.equalsIgnoreCase("ok")) {
  13707. strReplyXml += " <security>\"" + strSecurity + "\"</security>\n";
  13708. strReplyXml += " <touch>\"" + strTouch + "\"</touch>\n";
  13709. strReplyXml += " <magnetic>\"" + magnetic + "\"</magnetic>\n";
  13710. }
  13711. strReplyXml += " <message>\"null\"</message>\n";
  13712. strReplyXml += " </service>\n";
  13713. strReplyXml += "</imap>";
  13714. return strReplyXml;
  13715. } catch (RuntimeException re) {
  13716. LogUtil.errorLogInfo("", TAG, re);
  13717. return "ERROR";
  13718. } catch (Exception e) {
  13719. Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
  13720. //e.printStackTrace();
  13721. LogUtil.errorLogInfo("", TAG, e);
  13722. return "ERROR";
  13723. }
  13724. }
  13725. private void saveBlackoutStatus(boolean bOccurred) {
  13726. try {
  13727. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  13728. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  13729. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  13730. mEditor.putBoolean("status", bOccurred);
  13731. mEditor.commit();
  13732. } catch (RuntimeException re) {
  13733. LogUtil.errorLogInfo("", TAG, re);
  13734. } catch (Exception e) {
  13735. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  13736. //e.printStackTrace();
  13737. LogUtil.errorLogInfo("", TAG, e);
  13738. }
  13739. }
  13740. private boolean getBlackoutStatus() {
  13741. try {
  13742. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  13743. return mSharedPreferences.getBoolean("status", false);
  13744. } catch (RuntimeException re) {
  13745. LogUtil.errorLogInfo("", TAG, re);
  13746. return false;
  13747. } catch (Exception e) {
  13748. Log.e(TAG, "[Exception] getBlackoutStatus()");
  13749. //e.printStackTrace();
  13750. LogUtil.errorLogInfo("", TAG, e);
  13751. return false;
  13752. }
  13753. }
  13754. /**
  13755. * JEFF, 2019.12.25
  13756. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  13757. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  13758. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  13759. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  13760. */
  13761. int MAX_WALLPADCALL_LIVE_CNT = 1;
  13762. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  13763. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  13764. public static boolean m_bWallpadCallScreen = false;
  13765. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  13766. Handler handlerCheckWallPadCallLive = new Handler() {
  13767. public void handleMessage(Message msg) {
  13768. super.handleMessage(msg);
  13769. sendWallPadCallLiveBR_Request();
  13770. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  13771. }
  13772. };
  13773. private void sendWallPadCallLiveBR_Request() {
  13774. try {
  13775. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  13776. Intent mIntent = new Intent();
  13777. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  13778. getApplicationContext().sendBroadcast(mIntent);
  13779. if (nWallPadCallACKCnt >= 0) {
  13780. nWallPadCallACKCnt--;
  13781. } else {
  13782. bWallPadCallLive = false;
  13783. Common.bWallPadCallLive = bWallPadCallLive;
  13784. }
  13785. if (bWallPadCallLive != getCallAppRunning()) {
  13786. setCallAppRunning(bWallPadCallLive);
  13787. }
  13788. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  13789. } catch (RuntimeException re) {
  13790. LogUtil.errorLogInfo("", TAG, re);
  13791. } catch (Exception e) {
  13792. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  13793. //e.printStackTrace();
  13794. LogUtil.errorLogInfo("", TAG, e);
  13795. }
  13796. }
  13797. public boolean getWallpadCallScrean(int iScreen)
  13798. {
  13799. boolean bRet = false;
  13800. try {
  13801. switch (iScreen) {
  13802. case API_Menu.SubMenuCall.Door:
  13803. bRet = false;
  13804. break;
  13805. case API_Menu.SubMenuCall.Lobby:
  13806. bRet = false;
  13807. break;
  13808. case API_Menu.SubMenuCall.Guard:
  13809. bRet = false;
  13810. break;
  13811. case API_Menu.SubMenuCall.Neighbor:
  13812. bRet = false;
  13813. break;
  13814. case API_Menu.SubMenuCall.PSTN:
  13815. bRet = false;
  13816. break;
  13817. case API_Menu.SubMenuCall.CallList:
  13818. bRet = true;
  13819. break;
  13820. case API_Menu.SubMenuCall.Visitor:
  13821. bRet = true;
  13822. break;
  13823. default:
  13824. bRet = false;
  13825. break;
  13826. }
  13827. } catch (RuntimeException re) {
  13828. LogUtil.errorLogInfo("", TAG, re);
  13829. return false;
  13830. } catch (Exception e) {
  13831. Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
  13832. //e.printStackTrace();
  13833. LogUtil.errorLogInfo("", TAG, e);
  13834. return false;
  13835. }
  13836. return bRet;
  13837. }
  13838. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  13839. @Override
  13840. public void onReceive(Context context, Intent intent) {
  13841. try {
  13842. String strActionName = intent.getAction();
  13843. int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
  13844. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  13845. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  13846. bWallPadCallLive = true;
  13847. Common.bWallPadCallLive = bWallPadCallLive;
  13848. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  13849. m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
  13850. Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
  13851. } else {
  13852. Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  13853. }
  13854. } catch (RuntimeException re) {
  13855. LogUtil.errorLogInfo("", TAG, re);
  13856. } catch (Exception e) {
  13857. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  13858. //e.printStackTrace();
  13859. LogUtil.errorLogInfo("", TAG, e);
  13860. }
  13861. }
  13862. };
  13863. static class CALLCTRLHANDLERMSG {
  13864. static final int RELEASE_BLOCK_FRONTCALL = 100;
  13865. }
  13866. boolean bBlockFrontCall = false;
  13867. Handler handlerCallCtrl = new Handler() {
  13868. public void handleMessage(Message msg) {
  13869. super.handleMessage(msg);
  13870. int nMSG = msg.what;
  13871. switch (nMSG) {
  13872. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  13873. bBlockFrontCall = false;
  13874. break;
  13875. }
  13876. }
  13877. };
  13878. /**
  13879. * JEFF, 2019.12.31
  13880. * WallPadCall 실행여부를 DB에 저장한다.
  13881. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  13882. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  13883. */
  13884. public void setCallAppRunning(boolean bRunning) {
  13885. try {
  13886. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13887. mWallpadStatusData.SetCallAPKStatus(bRunning);
  13888. mWallpadStatusData.closeDB();
  13889. } catch (RuntimeException re) {
  13890. LogUtil.errorLogInfo("", TAG, re);
  13891. } catch (Exception e) {
  13892. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  13893. //e.printStackTrace();
  13894. LogUtil.errorLogInfo("", TAG, e);
  13895. }
  13896. }
  13897. private boolean getCallAppRunning() {
  13898. boolean bRunning = false;
  13899. try {
  13900. WallpadStatusData WallpadStatusData = new WallpadStatusData(getApplicationContext());
  13901. bRunning = WallpadStatusData.GetCallAPKStatusRunning();
  13902. WallpadStatusData.closeDB();
  13903. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  13904. return bRunning;
  13905. } catch (RuntimeException re) {
  13906. LogUtil.errorLogInfo("", TAG, re);
  13907. return false;
  13908. } catch (Exception e) {
  13909. Log.d(TAG, "[Exception] getCallAppRunning()");
  13910. //e.printStackTrace();
  13911. LogUtil.errorLogInfo("", TAG, e);
  13912. return false;
  13913. }
  13914. }
  13915. /**
  13916. * 통화앱 종료코드
  13917. */
  13918. public void killWallPadCall() {
  13919. try {
  13920. Log.i(TAG, "[killWallPadCall] ===== START =====");
  13921. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  13922. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  13923. Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  13924. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  13925. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  13926. // android.os.Process.killProcess(nWallPadCallPID);
  13927. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  13928. // if(list != null){
  13929. // for(int i=0;i<list.size();++i){
  13930. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  13931. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  13932. // android.os.Process.killProcess(pid);
  13933. // }
  13934. // }
  13935. // }
  13936. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  13937. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  13938. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  13939. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  13940. // android.os.Process.killProcess(pid);
  13941. } catch (RuntimeException re) {
  13942. LogUtil.errorLogInfo("", TAG, re);
  13943. } catch (Exception e) {
  13944. Log.e(TAG, "[Exception] killWallPadCall()");
  13945. //e.printStackTrace();
  13946. LogUtil.errorLogInfo("", TAG, e);
  13947. }
  13948. }
  13949. private void checkForegroundActivity() {
  13950. try {
  13951. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  13952. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  13953. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  13954. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  13955. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  13956. } catch (RuntimeException re) {
  13957. LogUtil.errorLogInfo("", TAG, re);
  13958. } catch (Exception e) {
  13959. Log.e(TAG, "[Exception] checkForegroundActivity()");
  13960. //e.printStackTrace();
  13961. LogUtil.errorLogInfo("", TAG, e);
  13962. }
  13963. }
  13964. /**
  13965. * JEFF, 2020.01.04
  13966. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  13967. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  13968. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  13969. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  13970. */
  13971. static long lConnectionPeriod = 0;
  13972. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  13973. boolean bRingGeneratorRun = false;
  13974. private void startIGW300RingGenerator() {
  13975. try {
  13976. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  13977. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  13978. bRingGeneratorRun = true;
  13979. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  13980. mIGW300RingGeneratorThread.start();
  13981. } else
  13982. Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  13983. } catch (RuntimeException re) {
  13984. LogUtil.errorLogInfo("", TAG, re);
  13985. } catch (Exception e) {
  13986. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  13987. //e.printStackTrace();
  13988. LogUtil.errorLogInfo("", TAG, e);
  13989. }
  13990. }
  13991. private void stopIGW300RingGenerator() {
  13992. try {
  13993. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  13994. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  13995. lConnectionPeriod = -999;
  13996. bRingGeneratorRun = false;
  13997. mIGW300RingGeneratorThread = null;
  13998. } else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  13999. } catch (RuntimeException re) {
  14000. LogUtil.errorLogInfo("", TAG, re);
  14001. } catch (Exception e) {
  14002. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  14003. //e.printStackTrace();
  14004. LogUtil.errorLogInfo("", TAG, e);
  14005. }
  14006. }
  14007. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  14008. private class IGW300RingGeneratorThread extends Thread {
  14009. public IGW300RingGeneratorThread() {
  14010. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  14011. }
  14012. public void run() {
  14013. try {
  14014. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14015. if (bRingGeneratorRun)
  14016. Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  14017. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  14018. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  14019. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  14020. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  14021. try {
  14022. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  14023. } catch (InterruptedException e) {
  14024. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  14025. //e.printStackTrace();
  14026. LogUtil.errorLogInfo("", TAG, e);
  14027. }
  14028. }
  14029. bRingGeneratorRun = false;
  14030. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  14031. } catch (RuntimeException re) {
  14032. LogUtil.errorLogInfo("", TAG, re);
  14033. } catch (Exception e) {
  14034. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  14035. //e.printStackTrace();
  14036. LogUtil.errorLogInfo("", TAG, e);
  14037. }
  14038. }
  14039. }
  14040. private void sendPSTNRingEvent(int nKeyCode) {
  14041. try {
  14042. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  14043. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  14044. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  14045. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  14046. intent.putExtra("keycode", nKeyCode);
  14047. getApplicationContext().sendBroadcast(intent);
  14048. } catch (RuntimeException re) {
  14049. LogUtil.errorLogInfo("", TAG, re);
  14050. } catch (Exception e) {
  14051. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  14052. //e.printStackTrace();
  14053. LogUtil.errorLogInfo("", TAG, e);
  14054. }
  14055. }
  14056. /**
  14057. * 월패드 타입 판별
  14058. *
  14059. * @return bResult
  14060. * false: 메인월패드
  14061. * true: 서브월패드
  14062. */
  14063. public boolean getIsSubWallpad() {
  14064. boolean bResult = false;
  14065. try {
  14066. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14067. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  14068. mWallpadDeviceSet.closeDB();
  14069. if (DBinfo != null) {
  14070. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  14071. else bResult = false;
  14072. }
  14073. } catch (RuntimeException re) {
  14074. LogUtil.errorLogInfo("", TAG, re);
  14075. } catch (Exception e) {
  14076. Log.e(TAG, "[Exception] getIsSubWallpad()");
  14077. //e.printStackTrace();
  14078. LogUtil.errorLogInfo("", TAG, e);
  14079. }
  14080. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  14081. return bResult;
  14082. }
  14083. /**
  14084. * JEFF, 2020.02.05
  14085. * 월패드 비상접점 신호 사용 여부 확인
  14086. */
  14087. public boolean getEmergencyIOUsage() {
  14088. boolean bResult = false;
  14089. try {
  14090. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14091. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  14092. mWallpadDeviceSet.closeDB();
  14093. } catch (RuntimeException re) {
  14094. LogUtil.errorLogInfo("", TAG, re);
  14095. } catch (Exception e) {
  14096. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  14097. //e.printStackTrace();
  14098. LogUtil.errorLogInfo("", TAG, e);
  14099. }
  14100. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  14101. return bResult;
  14102. }
  14103. /**
  14104. * JEFF, 2020.02.05
  14105. * 거동수상자 녹화기능 활성화 확인
  14106. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  14107. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  14108. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  14109. */
  14110. public boolean getStrangerRecordingManagerSetting() {
  14111. boolean bResult = false;
  14112. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14113. try {
  14114. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14115. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  14116. mWallpadDeviceSet.closeDB();
  14117. if (nFrontCam[0] == COMPONENT_USE) {
  14118. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  14119. if (bRecord) bResult = true;
  14120. else bResult = false;
  14121. } else bResult = false;
  14122. } else bResult = false;
  14123. } catch (RuntimeException re) {
  14124. LogUtil.errorLogInfo("", TAG, re);
  14125. mWallpadDeviceSet.closeDB();
  14126. } catch (Exception e) {
  14127. mWallpadDeviceSet.closeDB();
  14128. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  14129. //e.printStackTrace();
  14130. LogUtil.errorLogInfo("", TAG, e);
  14131. }
  14132. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  14133. return bResult;
  14134. }
  14135. /**
  14136. * Edited by jeff (2020.06.22)
  14137. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  14138. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  14139. *
  14140. * @param bOn
  14141. */
  14142. private void sendLCDBacklightStatus(boolean bOn) {
  14143. try {
  14144. Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
  14145. Intent mIntent = new Intent();
  14146. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  14147. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  14148. getApplicationContext().sendBroadcast(mIntent);
  14149. } catch (RuntimeException re) {
  14150. LogUtil.errorLogInfo("", TAG, re);
  14151. } catch (Exception e) {
  14152. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  14153. //e.printStackTrace();
  14154. LogUtil.errorLogInfo("", TAG, e);
  14155. }
  14156. }
  14157. // 명칭 관련
  14158. boolean bRoomNameLog = true;
  14159. public static final int HEATING = 1;
  14160. public static final int LIGHT = 2;
  14161. private String[] mRoomNameList_Light = null; //조명 방 명칭
  14162. private String[] mRoomNameList_Heating = null; //난방 방 명칭
  14163. private String[] mDefaultRoomNameList = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14164. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  14165. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14166. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14167. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14168. /**
  14169. * DB 에서 룸이름 정보를 가져온다.
  14170. *
  14171. * @return (String []) null - 실패, not null
  14172. */
  14173. private String[] getDBRoomName() {
  14174. try {
  14175. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14176. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  14177. wallpadStatusData.closeDB();
  14178. if (strRoomNameList == null) {
  14179. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  14180. return null;
  14181. }
  14182. if (bRoomNameLog) {
  14183. for (int i = 0; i < strRoomNameList.length; i++)
  14184. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14185. }
  14186. return strRoomNameList;
  14187. } catch (RuntimeException re) {
  14188. LogUtil.errorLogInfo("", TAG, re);
  14189. } catch (Exception e) {
  14190. Log.e(TAG, "[Exception] getDBRoomName()");
  14191. //e.printStackTrace();
  14192. LogUtil.errorLogInfo("", TAG, e);
  14193. }
  14194. return null;
  14195. }
  14196. /**
  14197. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  14198. *
  14199. * @param nDeviceType - int
  14200. * @return (String []) null - 실패, not null
  14201. */
  14202. private String[] getDBRoomName(int nDeviceType) {
  14203. try {
  14204. String[] strRoomNameList = null;
  14205. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14206. if (nDeviceType == HEATING) {
  14207. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  14208. } else {
  14209. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  14210. }
  14211. wallpadStatusData.closeDB();
  14212. if (strRoomNameList == null) {
  14213. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  14214. return null;
  14215. }
  14216. if (bRoomNameLog) {
  14217. for (int i = 0; i < strRoomNameList.length; i++)
  14218. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14219. }
  14220. return strRoomNameList;
  14221. } catch (RuntimeException re) {
  14222. LogUtil.errorLogInfo("", TAG, re);
  14223. } catch (Exception e) {
  14224. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  14225. //e.printStackTrace();
  14226. LogUtil.errorLogInfo("", TAG, e);
  14227. }
  14228. return null;
  14229. }
  14230. /**
  14231. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  14232. **/
  14233. private void getRoomName() {
  14234. try {
  14235. Log.i(TAG, "[getRoomName] ====================");
  14236. // WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14237. // boolean bRoomNameEach = wallpadDeviceSet.GetEachRoomNameInfo();
  14238. // wallpadDeviceSet.closeDB();
  14239. // Log.i(TAG, "[getRoomName] bRoomNameEach [" + bRoomNameEach + "]");
  14240. //
  14241. // if (bRoomNameEach) {
  14242. // // 명칭 난방, 조명 분리 사용
  14243. // mRoomNameList_Light = getDBRoomName(LIGHT);
  14244. // if (mRoomNameList_Light == null) {
  14245. // mRoomNameList_Light = mDefaultRoomNameList_Light;
  14246. // }
  14247. //
  14248. // if (getEasyModeUXUsage()) {
  14249. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  14250. // }
  14251. // else {
  14252. // mRoomNameList_Heating = getDBRoomName(HEATING);
  14253. // if (mRoomNameList_Heating == null) {
  14254. // mRoomNameList_Heating = mDefaultRoomNameList_Heating;
  14255. // }
  14256. // }
  14257. // }
  14258. // else {
  14259. // // 명칭 통합사용
  14260. // mRoomNameList_Light = getDBRoomName();
  14261. // if (mRoomNameList_Light == null) {
  14262. // mRoomNameList_Light = mDefaultRoomNameList;
  14263. // }
  14264. //
  14265. // if (getEasyModeUXUsage()) {
  14266. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  14267. // }
  14268. // else {
  14269. // mRoomNameList_Heating = getDBRoomName();
  14270. // if (mRoomNameList_Heating == null) {
  14271. // mRoomNameList_Heating = mDefaultRoomNameList;
  14272. // }
  14273. // }
  14274. // }
  14275. //
  14276. // if (bRoomNameLog) {
  14277. // for (int i = 0; i < mRoomNameList_Light.length; i++) {
  14278. // Log.i(TAG, "[getRoomName] mRoomNameList_Light[" + i + "] " + mRoomNameList_Light[i]);
  14279. // }
  14280. //
  14281. // for (int i = 0; i < mRoomNameList_Heating.length; i++) {
  14282. // Log.i(TAG, "[getRoomName] mRoomNameList_Heating[" + i + "] " + mRoomNameList_Heating[i]);
  14283. // }
  14284. // }
  14285. } catch (RuntimeException re) {
  14286. LogUtil.errorLogInfo("", TAG, re);
  14287. } catch (Exception e) {
  14288. Log.e(TAG, "[Exception] getRoomName()");
  14289. //e.printStackTrace();
  14290. LogUtil.errorLogInfo("", TAG, e);
  14291. }
  14292. }
  14293. public boolean getEasyModeUXUsage() {
  14294. try {
  14295. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  14296. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  14297. deviceSet.closeDB();
  14298. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  14299. boolean bUse = data.GetEasyModeUxUse();
  14300. data.closeDB();
  14301. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  14302. return bSupport & bUse;
  14303. } catch (RuntimeException re) {
  14304. LogUtil.errorLogInfo("", TAG, re);
  14305. } catch (Exception e) {
  14306. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  14307. //e.printStackTrace();
  14308. LogUtil.errorLogInfo("", TAG, e);
  14309. }
  14310. return false;
  14311. }
  14312. /**
  14313. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  14314. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  14315. * 재설정 5초 후 월패드 재부팅을 실행한다.
  14316. * 2020.11.18 SEULKI
  14317. */
  14318. public void checkDoorCamConfig() {
  14319. try {
  14320. if (Build.VERSION.SDK_INT > 23) {
  14321. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  14322. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  14323. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  14324. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  14325. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  14326. if (!checkAvailableBSPDoorCamConfig()) {
  14327. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  14328. return;
  14329. }
  14330. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  14331. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  14332. if (mIOInterface != null)
  14333. mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  14334. // 재부팅
  14335. setDefaultLauncher();
  14336. Intent intent = new Intent();
  14337. if (intent != null) {
  14338. intent.setAction(define.NOTIFY_ACNAME);
  14339. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  14340. getApplicationContext().sendBroadcast(intent);
  14341. }
  14342. }
  14343. }
  14344. }
  14345. } catch (RuntimeException re) {
  14346. LogUtil.errorLogInfo("", "", re);
  14347. } catch (Exception e) {
  14348. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  14349. LogUtil.errorLogInfo("", "", e);
  14350. }
  14351. }
  14352. /**
  14353. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  14354. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  14355. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  14356. *
  14357. * @return true: 지원, false: 미지원
  14358. */
  14359. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  14360. private boolean checkAvailableBSPDoorCamConfig() {
  14361. try {
  14362. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  14363. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  14364. if (nCurrentVer >= nCriterionVer) {
  14365. return true;
  14366. } else return false;
  14367. } catch (RuntimeException re) {
  14368. LogUtil.errorLogInfo("", TAG, re);
  14369. return false;
  14370. } catch (Exception e) {
  14371. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  14372. //e.printStackTrace();
  14373. LogUtil.errorLogInfo("", TAG, e);
  14374. return false;
  14375. }
  14376. }
  14377. /**
  14378. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14379. *
  14380. * @return 0 - 스마트현관카메라
  14381. * 2 - 스마트현관카메라 좌우반전
  14382. * 1 - 일반현관카메라
  14383. * 2020.11.18 SEULKI
  14384. */
  14385. public int getBSPDoorCamConfig() {
  14386. InputStreamReader is = null;
  14387. try {
  14388. Runtime mRuntime = Runtime.getRuntime();
  14389. String cmd = "getprop camera.setting.value";
  14390. if (mRuntime != null) {
  14391. Process mProcess = mRuntime.exec(cmd);
  14392. is = new InputStreamReader(mProcess.getInputStream());
  14393. BufferedReader br = new BufferedReader(is);
  14394. String line;
  14395. String strResult = null;
  14396. if (br != null) {
  14397. while ((line = br.readLine()) != null) {
  14398. strResult = line;
  14399. }
  14400. if (strResult != null) {
  14401. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  14402. if (strResult.equals("0")) {
  14403. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  14404. return 0;
  14405. } else if (strResult.equals("1")) {
  14406. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  14407. return 1;
  14408. } else if (strResult.equals("2")) {
  14409. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  14410. return 2;
  14411. } else {
  14412. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  14413. return -1;
  14414. }
  14415. }
  14416. }
  14417. }
  14418. return -1;
  14419. } catch (Exception e) {
  14420. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  14421. e.printStackTrace();
  14422. return -1;
  14423. } finally {
  14424. if (is != null) {
  14425. try {
  14426. is.close();
  14427. } catch (IOException e) {
  14428. LogUtil.errorLogInfo("", TAG, e);
  14429. }
  14430. is = null;
  14431. }
  14432. }
  14433. }
  14434. /**
  14435. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14436. *
  14437. * @return 0 - 스마트현관카메라
  14438. * 2 - 스마트현관카메라 좌우반전
  14439. * 1 - 일반현관카메라
  14440. * 2020.11.18 SEULKI
  14441. */
  14442. public int getDBDoorCamConfig() {
  14443. try {
  14444. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14445. if (mWallpadDeviceSet != null) {
  14446. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14447. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  14448. mWallpadDeviceSet.closeDB();
  14449. if (nType != null) {
  14450. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  14451. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
  14452. // Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14453. if (bFlip) {
  14454. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14455. return 0;
  14456. } else {
  14457. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
  14458. return 2;
  14459. }
  14460. } else {
  14461. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  14462. return 1;
  14463. }
  14464. }
  14465. }
  14466. return -1;
  14467. } catch (Exception e) {
  14468. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  14469. e.printStackTrace();
  14470. return -1;
  14471. }
  14472. }
  14473. /**
  14474. * 공기질 센서 사용여부 확인
  14475. *
  14476. * @return true - 사용함, false: 사용안함
  14477. */
  14478. boolean bAirQualityEnable = false;
  14479. private boolean getAirQualityUsage() {
  14480. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14481. try {
  14482. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  14483. mWallpadDeviceSet.closeDB();
  14484. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  14485. bAirQualityEnable = true;
  14486. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14487. } else {
  14488. bAirQualityEnable = false;
  14489. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14490. }
  14491. return bAirQualityEnable;
  14492. } catch (RuntimeException re) {
  14493. LogUtil.errorLogInfo("", TAG, re);
  14494. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14495. return false;
  14496. } catch (Exception e) {
  14497. Log.e(TAG, "[Exception] getAirQualityUsage()");
  14498. //e.printStackTrace();
  14499. LogUtil.errorLogInfo("", TAG, e);
  14500. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14501. return false;
  14502. }
  14503. }
  14504. String strAirQualityFWVer = "";
  14505. String strAirQualityProtocolVer = "";
  14506. String strAirQualityInfo = "";
  14507. private String getAirQualityInfo() {
  14508. try {
  14509. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  14510. if (mAirQualitySensorAPI != null) {
  14511. int nRet = mAirQualitySensorAPI.Refresh(false);
  14512. if (nRet >= 0) {
  14513. Log.i(TAG, "[getAirQualityInfo] ");
  14514. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  14515. strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  14516. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  14517. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  14518. return strAirQualityInfo;
  14519. } else return "FAIL";
  14520. } else return "NULL";
  14521. } catch (RuntimeException re) {
  14522. LogUtil.errorLogInfo("", TAG, re);
  14523. return "ERROR";
  14524. } catch (Exception e) {
  14525. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14526. //e.printStackTrace();
  14527. LogUtil.errorLogInfo("", TAG, e);
  14528. return "ERROR";
  14529. }
  14530. }
  14531. private String getAOSVerCode() {
  14532. try {
  14533. int nOSVer = Build.VERSION.SDK_INT;
  14534. switch (nOSVer) {
  14535. case Build.VERSION_CODES.BASE:
  14536. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  14537. case Build.VERSION_CODES.BASE_1_1:
  14538. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  14539. case Build.VERSION_CODES.CUPCAKE:
  14540. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  14541. case Build.VERSION_CODES.DONUT:
  14542. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  14543. case Build.VERSION_CODES.ECLAIR:
  14544. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  14545. case Build.VERSION_CODES.ECLAIR_0_1:
  14546. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  14547. case Build.VERSION_CODES.ECLAIR_MR1:
  14548. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  14549. case Build.VERSION_CODES.FROYO:
  14550. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  14551. case Build.VERSION_CODES.GINGERBREAD:
  14552. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  14553. case Build.VERSION_CODES.GINGERBREAD_MR1:
  14554. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  14555. case Build.VERSION_CODES.HONEYCOMB:
  14556. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  14557. case Build.VERSION_CODES.HONEYCOMB_MR1:
  14558. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  14559. case Build.VERSION_CODES.HONEYCOMB_MR2:
  14560. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  14561. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  14562. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  14563. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  14564. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  14565. case Build.VERSION_CODES.JELLY_BEAN:
  14566. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  14567. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  14568. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  14569. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  14570. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  14571. case Build.VERSION_CODES.KITKAT:
  14572. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  14573. case Build.VERSION_CODES.KITKAT_WATCH:
  14574. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  14575. case Build.VERSION_CODES.LOLLIPOP:
  14576. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  14577. case Build.VERSION_CODES.LOLLIPOP_MR1:
  14578. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  14579. case Build.VERSION_CODES.M:
  14580. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  14581. case Build.VERSION_CODES.N:
  14582. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  14583. case Build.VERSION_CODES.N_MR1:
  14584. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  14585. case Build.VERSION_CODES.O:
  14586. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  14587. case Build.VERSION_CODES.O_MR1:
  14588. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  14589. case Build.VERSION_CODES.P:
  14590. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  14591. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  14592. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  14593. default:
  14594. return "SDK(" + nOSVer + ")/UNKNOWN";
  14595. }
  14596. } catch (RuntimeException re) {
  14597. LogUtil.errorLogInfo("", TAG, re);
  14598. return "ERROR";
  14599. } catch (Exception e) {
  14600. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14601. //e.printStackTrace();
  14602. LogUtil.errorLogInfo("", TAG, e);
  14603. return "ERROR";
  14604. }
  14605. }
  14606. /**
  14607. * 조명 ON/OFF 상태
  14608. */
  14609. public static class LIGHT_ONOFF {
  14610. /**
  14611. * ON
  14612. */
  14613. public static byte ON = (byte) 0x01;
  14614. /**
  14615. * OFF
  14616. */
  14617. public static byte OFF = (byte) 0x02;
  14618. /**
  14619. * OFF
  14620. */
  14621. public static byte DONTCARE = (byte) 0xFF;
  14622. }
  14623. private byte convertSmartLightPowerValue(String cmd) {
  14624. try {
  14625. if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
  14626. else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
  14627. else return LIGHT_ONOFF.DONTCARE;
  14628. } catch (RuntimeException re) {
  14629. LogUtil.errorLogInfo("", TAG, re);
  14630. return -1;
  14631. } catch (Exception e) {
  14632. Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
  14633. //e.printStackTrace();
  14634. LogUtil.errorLogInfo("", TAG, e);
  14635. return -1;
  14636. }
  14637. }
  14638. /** 거주자 안정 확인 서비스용 코드 시작 */
  14639. /**
  14640. * Edited by Jeff, 2021.06.15
  14641. */
  14642. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  14643. public boolean bEnableResidentSafetyCheck = false;
  14644. private void getResidentSafetyCheckSetting() {
  14645. try {
  14646. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14647. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  14648. mWallpadDeviceSet.closeDB();
  14649. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  14650. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
  14651. bEnableResidentSafetyCheck = true;
  14652. else bEnableResidentSafetyCheck = false;
  14653. } catch (RuntimeException re) {
  14654. LogUtil.errorLogInfo("", TAG, re);
  14655. } catch (Exception e) {
  14656. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  14657. //e.printStackTrace();
  14658. LogUtil.errorLogInfo("", TAG, e);
  14659. }
  14660. }
  14661. private String getSecurityMode() {
  14662. try {
  14663. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14664. int nStatus = mWallpadStatusData.GetAlarmStatus();
  14665. mWallpadStatusData.closeDB();
  14666. String strSecurity = "null";
  14667. if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
  14668. else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
  14669. else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
  14670. else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
  14671. else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
  14672. else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
  14673. return strSecurity;
  14674. } catch (Exception e) {
  14675. Log.e(TAG, "[Exception] getSecurityMode()");
  14676. //e.printStackTrace();
  14677. LogUtil.errorLogInfo("", TAG, e);
  14678. return null;
  14679. }
  14680. }
  14681. String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
  14682. String Touch = "Touch";
  14683. String Magnetic = "Magnetic";
  14684. private void setTimeStamp_ScreenTouched() {
  14685. try {
  14686. Calendar mCal = Calendar.getInstance();
  14687. String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  14688. // Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
  14689. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14690. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14691. mEditor.putString(Touch, strTouchTime);
  14692. mEditor.apply();
  14693. } catch (Exception e) {
  14694. Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
  14695. //e.printStackTrace();
  14696. LogUtil.errorLogInfo("", TAG, e);
  14697. }
  14698. }
  14699. private String getTimeStamp_ScreenTouched() {
  14700. try {
  14701. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14702. String strTouchTime = mSharedPreferences.getString(Touch, null);
  14703. // Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
  14704. return strTouchTime;
  14705. } catch (Exception e) {
  14706. Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
  14707. //e.printStackTrace();
  14708. LogUtil.errorLogInfo("", TAG, e);
  14709. return null;
  14710. }
  14711. }
  14712. private void setTimeStamp_Magnetic() {
  14713. try {
  14714. Calendar mCal = Calendar.getInstance();
  14715. String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  14716. // Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
  14717. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14718. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14719. mEditor.putString(Magnetic, strMagneticTime);
  14720. mEditor.apply();
  14721. } catch (Exception e) {
  14722. Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
  14723. //e.printStackTrace();
  14724. LogUtil.errorLogInfo("", TAG, e);
  14725. }
  14726. }
  14727. private String getTimeStamp_Magnetic() {
  14728. try {
  14729. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14730. String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
  14731. // Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
  14732. return strMagneticTime;
  14733. } catch (Exception e) {
  14734. Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
  14735. //e.printStackTrace();
  14736. LogUtil.errorLogInfo("", TAG, e);
  14737. return null;
  14738. }
  14739. }
  14740. /** 거주자 안정 확인 서비스용 코드 종료 */
  14741. /**
  14742. * 가스밸브를 쿡탑콘센트로 사용
  14743. */
  14744. private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
  14745. /** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
  14746. /** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
  14747. /**
  14748. * false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
  14749. */
  14750. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  14751. private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
  14752. /**
  14753. * 기기 연동 제어 옵션 설정 확인
  14754. */
  14755. // 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
  14756. // 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
  14757. private void getDeviceCtrlOption() {
  14758. int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
  14759. boolean bUserSetting_SmartLightEnable = false;
  14760. int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
  14761. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14762. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14763. try {
  14764. bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
  14765. nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
  14766. nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
  14767. mWallpadDeviceSet.closeDB();
  14768. bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
  14769. mWallpadStatusData.closeDB();
  14770. if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  14771. // 스마트 분전반을 사용하는 경우에만
  14772. // 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
  14773. if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
  14774. // 사용자선택인 경우
  14775. if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
  14776. else bLightCMDUseAsSmartLight = true;
  14777. } else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
  14778. // 스마트조명을 사용하는 경우
  14779. bLightCMDUseAsSmartLight = false;
  14780. } else {
  14781. // 스마트조명을 사용하지 않는 경우
  14782. bLightCMDUseAsSmartLight = true;
  14783. }
  14784. } else {
  14785. // 스마트분전반을 사용하지 않는 경우
  14786. bLightCMDUseAsSmartLight = true;
  14787. }
  14788. Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
  14789. } catch (Exception e) {
  14790. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14791. if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
  14792. Log.e(TAG, "[Exception] getDeviceCtrlOption()");
  14793. //e.printStackTrace();
  14794. LogUtil.errorLogInfo("", TAG, e);
  14795. }
  14796. }
  14797. // private void demoPushMsg()
  14798. // {
  14799. // String urlStr1 = "";
  14800. //
  14801. // if(android.os.Build.VERSION.SDK_INT > 9 )
  14802. // {
  14803. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  14804. // StrictMode.setThreadPolicy(policy);
  14805. // }
  14806. //
  14807. // String Msg ="";
  14808. // try {
  14809. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  14810. // } catch (UnsupportedEncodingException e1) {
  14811. // // TODO Auto-generated catch block
  14812. // e1.printStackTrace();
  14813. // }
  14814. //
  14815. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  14816. // Log.d(TAG , "################ : " + urlStr1);
  14817. // try
  14818. // {
  14819. // //URLEncoder.encode(s)
  14820. // HttpClient client = new DefaultHttpClient();
  14821. //
  14822. // HttpGet get = new HttpGet();
  14823. // //get.setURI(new URI("http://www.google.com/"));
  14824. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  14825. // HttpResponse resp = client.execute(get);
  14826. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  14827. // String str = null;
  14828. // StringBuilder sb = new StringBuilder();
  14829. // while((str = br.readLine()) != null)
  14830. // {
  14831. // sb.append(str).append("\n");
  14832. // }
  14833. // br.close();
  14834. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  14835. // //txt.setText(sb.toString());
  14836. // }catch(Exception e)
  14837. // {
  14838. //
  14839. // e.printStackTrace();
  14840. //
  14841. // }
  14842. //
  14843. //
  14844. // }
  14845. //
  14846. //
  14847. // public static boolean checkForExternal(String str) {
  14848. // int length = str.length();
  14849. // for (int i = 0; i < length; i++) {
  14850. // if (str.charAt(i) > 0x7F) {
  14851. // return true;
  14852. // }
  14853. // }
  14854. // return false;
  14855. // }
  14856. //
  14857. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  14858. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  14859. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  14860. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  14861. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  14862. //
  14863. // public static String encodeUrl(String url) {
  14864. // if (checkForExternal(url)) {
  14865. // try {
  14866. // String value = URLEncoder.encode(url, "UTF-8");
  14867. // value = COLON.matcher(value).replaceAll(":");
  14868. // value = SLASH.matcher(value).replaceAll("/");
  14869. // value = QUEST_MARK.matcher(value).replaceAll("?");
  14870. // value = EQUAL.matcher(value).replaceAll("=");
  14871. // return AMP.matcher(value).replaceAll("&");
  14872. // } catch (UnsupportedEncodingException e) {
  14873. // //throw LOGGER.getIllegalStateException(e);
  14874. // return null;
  14875. // }
  14876. // } else {
  14877. // return url;
  14878. // }
  14879. // }
  14880. }