iMapServer.java 731 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677
  1. package kr.co.icontrols.wallpadmain.util;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningTaskInfo;
  5. import android.app.Service;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.media.AudioManager;
  15. import android.os.Build;
  16. import android.os.Bundle;
  17. import android.os.CountDownTimer;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Looper;
  21. import android.os.Message;
  22. import android.os.PowerManager;
  23. import android.util.Log;
  24. import android.view.KeyEvent;
  25. import android.widget.Toast;
  26. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  27. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  28. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  29. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  30. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  31. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  32. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  33. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  34. import com.artncore.WallPadDataMgr.WallpadStatusData;
  35. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  36. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  37. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  38. import com.artncore.WallPadKNXSystem.WallPadKNX;
  39. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  40. import com.artncore.commons.APIErrorCode;
  41. import com.artncore.commons.API_Menu;
  42. import com.artncore.commons.DataClasses;
  43. import com.artncore.commons.DataClasses.HeatingV1;
  44. import com.artncore.commons.DataClasses.HeatingV2;
  45. import com.artncore.commons.DataClasses.MultiSwitch;
  46. import com.artncore.commons.define;
  47. import com.artncore.deviceinterface.WallPadInterface;
  48. import com.artncore.wallpadapi.AirQualitySensorAPI;
  49. import com.artncore.wallpadapi.DLockAPI;
  50. import com.artncore.wallpadapi.EnergyMeterAPI;
  51. import com.artncore.wallpadapi.GasAPI;
  52. import com.artncore.wallpadapi.HeatingV1API;
  53. import com.artncore.wallpadapi.HeatingV2API;
  54. import com.artncore.wallpadapi.IGW200dAPI;
  55. import com.artncore.wallpadapi.IGW300API;
  56. import com.artncore.wallpadapi.IntLightAPI;
  57. import com.artncore.wallpadapi.KnxAPI;
  58. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  59. import com.artncore.wallpadapi.LightAPI;
  60. import com.artncore.wallpadapi.MultiSwitchAPI;
  61. import com.artncore.wallpadapi.PhonNRemocon;
  62. import com.artncore.wallpadapi.RealTimeMeterAPI;
  63. import com.artncore.wallpadapi.SdbAPI;
  64. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  65. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  66. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  67. import com.artncore.wallpadapi.VentiAPI;
  68. import com.artncore.wallpadapi.WallPadAPI;
  69. import com.artncore.wallpadimap.RetProci;
  70. import com.artncore.wallpadimap.WallPadFTPUploader;
  71. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  72. import com.artncore.wallpadimap.WallpadiCMDParser;
  73. import com.util.LogUtil;
  74. import org.apache.commons.net.ftp.FTP;
  75. import org.w3c.dom.Document;
  76. import org.w3c.dom.Element;
  77. import org.w3c.dom.NamedNodeMap;
  78. import org.w3c.dom.Node;
  79. import org.w3c.dom.NodeList;
  80. import java.io.BufferedReader;
  81. import java.io.ByteArrayInputStream;
  82. import java.io.DataOutputStream;
  83. import java.io.File;
  84. import java.io.FilenameFilter;
  85. import java.io.IOException;
  86. import java.io.InputStream;
  87. import java.io.InputStreamReader;
  88. import java.net.ServerSocket;
  89. import java.net.Socket;
  90. import java.text.SimpleDateFormat;
  91. import java.util.ArrayList;
  92. import java.util.Calendar;
  93. import java.util.Date;
  94. import java.util.GregorianCalendar;
  95. import java.util.LinkedList;
  96. import java.util.List;
  97. import java.util.Queue;
  98. import javax.net.ssl.SSLServerSocket;
  99. import javax.xml.parsers.DocumentBuilder;
  100. import javax.xml.parsers.DocumentBuilderFactory;
  101. import kr.co.icontrols.gledeviceinterface.jni;
  102. import kr.co.icontrols.hdcftp.HDCFTPManager;
  103. import kr.co.icontrols.sslapi.SSLClient;
  104. import kr.co.icontrols.sslapi.SSLServer;
  105. import kr.co.icontrols.wallpadmain.IOInterface;
  106. import kr.co.icontrols.wallpadmain.MainActivity;
  107. import kr.co.icontrols.wallpadmain.R;
  108. import kr.co.icontrols.wallpadmain.declare.Common;
  109. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  110. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  111. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  112. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  113. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  114. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  115. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  116. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  117. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  118. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  119. import kr.co.icontrols.wallpadsupport.Version;
  120. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  121. import kr.co.icontrols.wallpadsupport.WpadSound;
  122. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  123. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  124. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  125. public class iMapServer extends Service {
  126. private String TAG = "iMapServer";
  127. static final int EVENTTIMELIMITE = 2000;
  128. iMapSverSocket SvrSock;
  129. int port =10000;
  130. String StrAddr ="";
  131. String IPaddr;
  132. String AddrDong;
  133. String AddrHo;
  134. boolean log_sw = true;
  135. String SVRIP = "";
  136. static WallPadAPI mWallPadAPI;
  137. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  138. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  139. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  140. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  141. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  142. private IGW200 mIGW200;
  143. private IGW300 mIGW300;
  144. PhonNRemocon PnRCtr;
  145. boolean CallConnected = false;
  146. long ALERTTIME = 0;
  147. long CALLTIME = 0;
  148. long OPENDOORTIME = 0;
  149. long currentTime = 0;
  150. long DoorDelayTime = 0;
  151. static Handler ScheDulerHandler;
  152. static final boolean iMAPDOORCTR = true;
  153. private jni mGleInterface = null;
  154. IOInterface mIOInterface = null;
  155. private boolean ResetFlag = false;
  156. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  157. private int ResetCount = 0;
  158. private boolean NowMainStatus = false;
  159. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  160. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  161. public iMapServer() {
  162. Log.i(TAG, "[iMapServer] ========== START ==========");
  163. }
  164. public static final int SENSOR_MAG = 0x01;
  165. public static final int SENSOR_IN = 0x02;
  166. public static final int SENSOR_OUT = 0x04;
  167. static int PORT_NUM_iMAP = 10000;
  168. static int SOCKET_WAIT_TIME = 40;
  169. static long lSocketConnectionPeriod = 0;
  170. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  171. static int SOCKET_BUFFER_SIZE_READ = 50;
  172. public static final String ITEM_MENU_TYPE = "call_menu";
  173. static final int DOOR_DELAY_TIME = 3000;
  174. static final String MULTISW_CTR = "remote_access_electric";
  175. String XMLHeader;
  176. SchedulerThread ScheServer;
  177. int OutGoingSensorWaiting = 0;
  178. private int ModelType = Version.getModelType();
  179. private WpadSound mSound;
  180. private WpadSound Sound() {
  181. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  182. return mSound;
  183. }
  184. /** 신형 단지서버 사용 유무*/
  185. private boolean mNewDanjiServer = false;
  186. /**
  187. * JEFF, 2019.12.31
  188. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  189. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  190. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  191. * 통화앱 종료 BR을 삭제하면 안됨
  192. */
  193. // 통화어플이 종료중인 경우에는 호출 무시
  194. // private boolean bBlockCallEvent = false;
  195. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  196. // true : smartlight 제어
  197. // false: 기존 livinglight/light로 smartlight 제어
  198. private boolean bSmartLightAsNormalLight = true;
  199. ////////////////////////////////////////////////////////////////////////////////
  200. // 엘리베이터관련
  201. ////////////////////////////////////////////////////////////////////////////////
  202. /**
  203. * 엘리베이터 호출관련 class
  204. *
  205. * shkang
  206. */
  207. private class ElevatorClass {
  208. /** 엘리베이터 호출 타임아웃 (단위:초) */
  209. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int)(5 * 60); // 5분
  210. /** 상향/하향 플레그 true:상향UP, false:하향DN */
  211. private boolean mUpDn = false;
  212. /** 엘리베이터 호출중 */
  213. private boolean mCallElevator = false;
  214. /** 엘리베이터 호출 API */
  215. private WallPadiMAPNotifyAPI mElevatorAPI;
  216. /** 엘리베이터 호출 타이머 */
  217. private CountDownTimer mElevatorTimer;
  218. /** 엘리베이터 호출중 상태 가져오기 */
  219. public boolean getElevatorCalling()
  220. {
  221. return mCallElevator;
  222. }
  223. /** 엘리베이터 호출 상태 클리어 */
  224. public void ClearElevator()
  225. {
  226. mCallElevator = false;
  227. }
  228. /**
  229. * 생성자
  230. *
  231. * @param Up - (boolean) true:상향, false:하향
  232. */
  233. private ElevatorClass(boolean Up) {
  234. try {
  235. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true?"UP" : "DOWN") + ")");
  236. // 1. Input Param
  237. mUpDn = Up;
  238. mCallElevator = false;
  239. // 2. Create API
  240. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  241. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  242. @Override
  243. public void ProcDoing() {
  244. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  245. }
  246. @Override
  247. public void ProcError() {
  248. Log.i(TAG, "[ElevatorClass] ProcError()");
  249. mCallElevator = false;
  250. // 엘리베이터 호출 에러 알림
  251. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  252. }
  253. @Override
  254. public void ProcSuccess() {
  255. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  256. mCallElevator = true;
  257. // 엘리베이터 호출 성공 알림
  258. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  259. // "엘리베이터를 호출하였습니다" 멘트출력
  260. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  261. if (!MainActivity.bKakaoiEnable) Sound().PlayMent(WpadSound.SND.elevator.CALL);
  262. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  263. // 타임아웃 시작
  264. TimeOutStart();
  265. }
  266. });
  267. // 3. Create Timer
  268. mElevatorTimer = new CountDownTimer( (long)(ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  269. @Override
  270. public void onFinish() {
  271. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  272. mCallElevator = false;
  273. // 호출 타임아웃 알림
  274. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  275. }
  276. @Override
  277. public void onTick(long arg0) {
  278. int RemainingTime = (int) (arg0 / 1000);
  279. if (RemainingTime <= 10) {
  280. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  281. }
  282. }
  283. };
  284. } catch (RuntimeException re) {
  285. LogUtil.errorLogInfo("", TAG, re);
  286. }
  287. catch (Exception e) {
  288. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  289. //e.printStackTrace();
  290. LogUtil.errorLogInfo("", TAG, e);
  291. }
  292. }
  293. /**
  294. * 엘리베이터 호출을 한다.
  295. */
  296. public void CallElevator() {
  297. try {
  298. if (mElevatorAPI == null) return;
  299. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  300. mCallElevator = true;
  301. } catch (RuntimeException re) {
  302. LogUtil.errorLogInfo("", TAG, re);
  303. }
  304. catch (Exception e) {
  305. Log.e(TAG, "[Exception] CallElevator()");
  306. //e.printStackTrace();
  307. LogUtil.errorLogInfo("", TAG, e);
  308. }
  309. }
  310. /**
  311. * 엘리베이터 상향호출 타임아웃을 취소한다.
  312. */
  313. public void TimeOutCancel() {
  314. try {
  315. if (mElevatorTimer == null) return;
  316. mElevatorTimer.cancel();
  317. } catch (RuntimeException re) {
  318. LogUtil.errorLogInfo("", TAG, re);
  319. }
  320. catch (Exception e) {
  321. Log.e(TAG, "[Exception] TimeOutCancel()");
  322. //e.printStackTrace();
  323. LogUtil.errorLogInfo("", TAG, e);
  324. }
  325. }
  326. /**
  327. * 엘리베이터 상향호출 타임아웃을 시작한다.
  328. */
  329. private void TimeOutStart() {
  330. try {
  331. if (mElevatorTimer == null) return;
  332. mElevatorTimer.cancel();
  333. mElevatorTimer.start();
  334. } catch (RuntimeException re) {
  335. LogUtil.errorLogInfo("", TAG, re);
  336. }
  337. catch (Exception e) {
  338. Log.e(TAG, "[Exception] TimeOutStart()");
  339. //e.printStackTrace();
  340. LogUtil.errorLogInfo("", TAG, e);
  341. }
  342. }
  343. /**
  344. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  345. *
  346. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  347. */
  348. private void SendNotifyKindBR(int kind) {
  349. try {
  350. Intent notiIntent = new Intent();
  351. notiIntent.setAction(define.NOTIFY_ACNAME);
  352. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  353. getApplicationContext().sendBroadcast(notiIntent);
  354. } catch (RuntimeException re) {
  355. LogUtil.errorLogInfo("", TAG, re);
  356. }
  357. catch (Exception e) {
  358. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  359. //e.printStackTrace();
  360. LogUtil.errorLogInfo("", TAG, e);
  361. }
  362. }
  363. }
  364. /** 엘리베이터 상향호출 Class */
  365. private ElevatorClass ElevatorUp;
  366. /** 엘리베이터 하향호출 Class */
  367. private ElevatorClass ElevatorDown;
  368. /**
  369. * 엘리베이터 호출한다.
  370. *
  371. * @param Up (boolean) true : 상향, false : 하향
  372. */
  373. private void CallElevatorBtn(boolean Up) {
  374. try {
  375. Log.i(TAG, "[CallElevatorBtn] Up [" + Up +"]");
  376. if (Up) {
  377. // 상향호출
  378. if (ElevatorUp == null) {
  379. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  380. return;
  381. }
  382. ElevatorUp.CallElevator();
  383. }
  384. else {
  385. // 하향호출
  386. if (ElevatorDown == null) {
  387. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  388. return;
  389. }
  390. ElevatorDown.CallElevator();
  391. }
  392. } catch (RuntimeException re) {
  393. LogUtil.errorLogInfo("", TAG, re);
  394. }
  395. catch (Exception e) {
  396. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  397. //e.printStackTrace();
  398. LogUtil.errorLogInfo("", TAG, e);
  399. }
  400. }
  401. ////////////////////////////////////////////////////////////////////////////////
  402. ////////////////////////////////////////////////////////////////////////////////
  403. @Override
  404. public void onCreate() {
  405. try {
  406. super.onCreate();
  407. Log.i(TAG, "[onCreate] ========== START ==========");
  408. setGlobalScreenAppRunningStatus(false);
  409. ModelType = Version.getModelType();
  410. mSound = new WpadSound(getApplicationContext());
  411. ElevatorUp = new ElevatorClass(true);
  412. ElevatorDown = new ElevatorClass(false);
  413. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  414. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  415. bSmartLightAsNormalLight = true;
  416. }
  417. else bSmartLightAsNormalLight = false;
  418. }
  419. catch (RuntimeException re)
  420. {
  421. Log.e(TAG, "[Exception] onCreate()");
  422. //e.printStackTrace();
  423. LogUtil.errorLogInfo("", TAG, re);
  424. }
  425. catch (Exception e) {
  426. Log.e(TAG, "[Exception] onCreate()");
  427. //e.printStackTrace();
  428. LogUtil.errorLogInfo("", TAG, e);
  429. }
  430. }
  431. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  432. try {
  433. Intent notiIntent = new Intent();
  434. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  435. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  436. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  437. getApplicationContext().sendBroadcast(notiIntent);
  438. } catch (RuntimeException re) {
  439. LogUtil.errorLogInfo("", TAG, re);
  440. }
  441. catch (Exception e) {
  442. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  443. //e.printStackTrace();
  444. LogUtil.errorLogInfo("", TAG, e);
  445. }
  446. }
  447. protected String GetForegroundAPP() {
  448. try {
  449. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  450. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  451. ComponentName topActivity=taskInfo.get(0).topActivity;
  452. String str=topActivity.getPackageName();
  453. return str;
  454. } catch (RuntimeException re) {
  455. LogUtil.errorLogInfo("", TAG, re);
  456. return " ";
  457. }
  458. catch (Exception e) {
  459. Log.e(TAG, "[Exception] GetForegroundAPP()");
  460. //e.printStackTrace();
  461. LogUtil.errorLogInfo("", TAG, e);
  462. return " ";
  463. }
  464. }
  465. long lSavedTimestamp = 0;
  466. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  467. public void onReceive(Context context, Intent intent) {
  468. try {
  469. String strActionName = intent.getAction();
  470. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName+ "]");
  471. if (strActionName.equals(define.NOTIFY_DAIL)) {
  472. long lTimestamp = System.currentTimeMillis();
  473. long lInterval = lTimestamp - lSavedTimestamp;
  474. if (lInterval <1000) return;
  475. else Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval+ "]");
  476. lSavedTimestamp = lTimestamp;
  477. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  478. if (mSdb_LivingRoomLightAPI == null) {
  479. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  480. return;
  481. }
  482. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  483. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  484. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  485. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  486. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  487. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  488. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  489. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  490. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  491. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  492. mSdb_LivingRoomLightAPI.SetControlMode(false);
  493. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  494. }
  495. return;
  496. }
  497. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  498. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  499. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  500. return;
  501. }
  502. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  503. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  504. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  505. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  506. }
  507. else {
  508. setGlobalScreenAppRunningStatus(false);
  509. }
  510. }
  511. else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  512. if (mKnx_LivingRoomLightAPI == null) {
  513. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  514. return;
  515. }
  516. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  517. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  518. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  519. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  520. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  521. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  522. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  523. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  524. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  525. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  526. mKnx_LivingRoomLightAPI.SetControlMode(false);
  527. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  528. }
  529. return;
  530. }
  531. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  532. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  533. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  534. return;
  535. }
  536. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  537. 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 + "]");
  538. }
  539. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  540. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  541. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  542. }
  543. else {
  544. setGlobalScreenAppRunningStatus(false);
  545. }
  546. }
  547. else {
  548. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  549. }
  550. }
  551. else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  552. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  553. }
  554. else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  555. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  556. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind+ "]");
  557. switch (kind) {
  558. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  559. procUploadMissedVisitorPic(intent);
  560. break;
  561. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  562. // bBlockCallEvent = true;
  563. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  564. break;
  565. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  566. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  567. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  568. break;
  569. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE :
  570. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  571. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  572. break;
  573. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK :
  574. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  575. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  576. break;
  577. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  578. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  579. CallElevatorBtn(false);
  580. break;
  581. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  582. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  583. CallElevatorBtn(true);
  584. break;
  585. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING :
  586. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  587. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  588. int CalledWallPadUI = intent.getIntExtra("Called",0);
  589. if (CalledWallPadUI == 1) {
  590. ModeRunCtrlWorking(true , false);
  591. }
  592. else {
  593. ModeRunCtrlWorking(false, false);
  594. }
  595. break;
  596. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING :
  597. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  598. ModeReleaseCtrlWorking(false);
  599. break;
  600. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK :
  601. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  602. CheckMainStatus();
  603. break;
  604. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING :
  605. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  606. ModeRunCtrlWorking(false, false);
  607. break;
  608. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING :
  609. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  610. ModeReleaseCtrlWorking(false);
  611. break;
  612. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE :
  613. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  614. if (ElevatorUp != null && ElevatorDown != null) {
  615. boolean UpCalling = ElevatorUp.getElevatorCalling();
  616. boolean DownCalling = ElevatorDown.getElevatorCalling();
  617. Log.d( TAG , "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling );
  618. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  619. if (UpCalling && DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  620. else if (UpCalling && !DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  621. else if (!UpCalling && DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  622. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  623. Log.d(TAG , " ElvCallState : " + ElvCallState );
  624. SendBRElevatorCallState(ElvCallState);
  625. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  626. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  627. // sendIntent.putExtra("ELV", ElvCallState);
  628. // getApplicationContext().sendBroadcast(sendIntent);
  629. }
  630. break;
  631. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  632. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  633. try {
  634. if (ScheServer != null) {
  635. ScheServer.SetLive();
  636. }
  637. } catch (RuntimeException re) {
  638. LogUtil.errorLogInfo("", TAG, re);
  639. }
  640. catch (Exception e) {
  641. //e.printStackTrace();
  642. LogUtil.errorLogInfo("", TAG, e);
  643. }
  644. break;
  645. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  646. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  647. stopIGW300RingGenerator();
  648. break;
  649. }
  650. }
  651. else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  652. int kind = intent.getIntExtra("KIND",0);
  653. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind+ "]");
  654. switch (kind) {
  655. case define.NOTIFY_SERVER_VERSION:
  656. try {
  657. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  658. iMapSverReload tSock = new iMapSverReload();
  659. tSock.start();
  660. } catch (IOException e) {
  661. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  662. //e.printStackTrace();
  663. LogUtil.errorLogInfo("", TAG, e);
  664. }
  665. break;
  666. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  667. // 제어기기 엘리베이터 상향 호출 요청
  668. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  669. CallElevatorBtn(true);
  670. break;
  671. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  672. // 제어기기에서 엘리베이터 하향 호출 요청
  673. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  674. CallElevatorBtn(false);
  675. break;
  676. case define.NOTIFY_SUBDEVCALLBUSY:
  677. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  678. CallConnected = true;
  679. break;
  680. case define.NOTIFY_SUBDEVCALLEND:
  681. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  682. CallConnected = false;
  683. break;
  684. case define.NOTIFY_STARTHEARTBEAT:
  685. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  686. {
  687. Message msg = ScheDulerHandler.obtainMessage();
  688. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  689. ScheDulerHandler.sendMessage(msg);
  690. }
  691. break;
  692. case define.NOTIFY_STARTSTATUSBEAT:
  693. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  694. {
  695. Message msg = ScheDulerHandler.obtainMessage();
  696. msg.what = SCHEDULE_START_STATUSBEAT;
  697. ScheDulerHandler.sendMessage(msg);
  698. }
  699. break;
  700. case define.NOTIFY_OUTGOINGSETTED:
  701. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  702. OutGoingSensorWaiting = 0;
  703. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  704. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  705. sdata.closeDB();
  706. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  707. WallPadInterface wpifc = new WallPadInterface();
  708. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0 )
  709. OutGoingSensorWaiting |= SENSOR_MAG;
  710. int[] SensorInfoDB;
  711. int sensorIn = 0;
  712. int sensorOut = 0;
  713. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  714. if (SensorInfoDB[0] == 1) {
  715. // 내부동체가 사용함이면 상태 검사
  716. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  717. }
  718. if (SensorInfoDB[1] == 1) {
  719. // 외부동체가 사용함이면 상태 검사
  720. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  721. }
  722. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  723. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  724. if (OutGoingSensorWaiting > 0) {
  725. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  726. SensorThread.start();
  727. }
  728. break;
  729. case define.NOTIFY_DOOR_SET_DELAY:
  730. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  731. DoorDelayTime = System.currentTimeMillis();
  732. imapsvrlog("Receive "+define.NOTIFY_DOOR_SET_DELAY+" Set : " +DoorDelayTime);
  733. break;
  734. case define.NOTIFY_DEVICE_INIT_COMPLETION :
  735. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  736. Common.setDeviceServeiceLoadComplite();
  737. startRealtimemeterInfo(); // 실시간 검침기 확인
  738. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  739. startDistributionPanel(); // 분전반 확인
  740. getRoomName();
  741. break;
  742. case define.NOTIFY_DLOCK_SET_OUTING:
  743. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  744. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  745. try {
  746. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  747. int AlarmStatus = DBMGR.GetAlarmStatus();
  748. DBMGR.closeDB();
  749. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  750. // 센서 체크하고
  751. // 현관폰으로 사운드 출력하고
  752. boolean bSensorOk = false;
  753. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  754. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  755. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  756. bSensorOk = mIGW300.checkSensorforOutmode();
  757. }
  758. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  759. bSensorOk = mIGW200.checkSensorforOutmode();
  760. }
  761. else {
  762. bSensorOk = checkSensorforOutmode();
  763. }
  764. if (bSensorOk) {
  765. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  766. CallOutModeRunActivity();
  767. }
  768. else {
  769. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  770. }
  771. }
  772. } catch (RuntimeException re) {
  773. LogUtil.errorLogInfo("", TAG, re);
  774. }
  775. catch (Exception e) {
  776. //e.printStackTrace();
  777. LogUtil.errorLogInfo("", TAG, e);
  778. }
  779. break;
  780. case define.NOTIFY_DLOCK_FREE_OUTING:
  781. // 도어락 외출모드 해제
  782. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  783. try {
  784. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  785. int AlarmStatus = DBMGR.GetAlarmStatus();
  786. DBMGR.closeDB();
  787. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  788. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK );
  789. Common.SendAppFinishReqBR(getApplicationContext());
  790. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  791. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  792. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  793. devDB.closeDB();
  794. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  795. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  796. }
  797. }
  798. } catch (RuntimeException re) {
  799. LogUtil.errorLogInfo("", TAG, re);
  800. }
  801. catch (Exception e) {
  802. //e.printStackTrace();
  803. LogUtil.errorLogInfo("", TAG, e);
  804. }
  805. break;
  806. case define.NOTIFY_SMARTSW_SET_OUTING:
  807. // 485 대외향 스마트스위치 외출모드
  808. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  809. setUnoccupiedModeByNotHDCSmartSwitch();
  810. break;
  811. case define.NOTIFY_SMARTSW_FREE_OUTING:
  812. //대외향 485 스마트스위치 외출모드 해제
  813. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  814. releaseUnoccupiedModeByNotHDCSmartSwitch();
  815. break;
  816. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  817. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  818. String Type = intent.getStringExtra("TYPE");
  819. String Device = intent.getStringExtra("DEVICE");
  820. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  821. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  822. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  823. iMAPSmartLightEvent imapSmartLightEvent;
  824. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  825. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  826. imapSmartLightEvent.SetRetCtr(new RetProci() {
  827. @Override
  828. public void ProcSuccess() {
  829. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  830. }
  831. @Override
  832. public void ProcError() {
  833. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  834. }
  835. @Override
  836. public void ProcDoing() {
  837. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  838. }
  839. });
  840. break;
  841. case define.NOTIFY_KNX_DEVICE_EVENT:
  842. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  843. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  844. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  845. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  846. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  847. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  848. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  849. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  850. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  851. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  852. @Override
  853. public void ProcSuccess() {
  854. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  855. }
  856. @Override
  857. public void ProcError() {
  858. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  859. }
  860. @Override
  861. public void ProcDoing() {
  862. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  863. }
  864. });
  865. break;
  866. case define.NOTIFY_SMART_DCAM_DETECT:
  867. // 스마트현관카메라 거동수상자 발생
  868. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  869. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  870. if (!bWallPadCallLive && !bBlockFrontCall) {
  871. if (getStrangerRecordingManagerSetting()) {
  872. if (getStrangerRecordingUserSetting()) {
  873. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  874. Intent Newintent = new Intent();
  875. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  876. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  877. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  878. getApplicationContext().sendBroadcast(Newintent);
  879. }
  880. else {
  881. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  882. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  883. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  884. }
  885. }
  886. else {
  887. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  888. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  889. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  890. }
  891. }
  892. else {
  893. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  894. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  895. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  896. }
  897. break;
  898. case define.NOTIFY_SMART_DCAM_RELEASE:
  899. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  900. break;
  901. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  902. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  903. if (getStrangerRecordingManagerSetting()) {
  904. if (getStrangerRecordingUserSetting()) {
  905. // 알람 상태 확인
  906. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  907. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  908. mWallpadStatusData.closeDB();
  909. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  910. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  911. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  912. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  913. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  914. }
  915. else {
  916. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  917. Intent Newintent = new Intent();
  918. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  919. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  920. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  921. getApplicationContext().sendBroadcast(Newintent);
  922. }
  923. }
  924. else {
  925. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  926. }
  927. }
  928. else {
  929. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  930. }
  931. break;
  932. case define.NOTIFY_ACCEPT_TAKEPIC_STRANGER:
  933. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_TAKEPIC_STRANGER");
  934. if (getUseSmartDoorCam()) {
  935. if (getStrangerTakePic()) {
  936. // 알람 상태 확인
  937. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  938. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  939. mWallpadStatusData.closeDB();
  940. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  941. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  942. // 외출 대기중 (설정진행중)일 경우 촬영안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  943. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  944. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  945. } else {
  946. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_TAKEPIC");
  947. Intent Newintent = new Intent();
  948. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  949. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_TAKEPIC);
  950. getApplicationContext().sendBroadcast(Newintent);
  951. }
  952. }
  953. }
  954. break;
  955. case define.NOTIFY_REJECT_RECORD_STRANGER:
  956. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  957. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  958. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  959. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  960. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  961. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  962. }
  963. break;
  964. case define.NOTIFY_ROOMNAME_CHANGED:
  965. getRoomName();
  966. break;
  967. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  968. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  969. break;
  970. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  971. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  972. break;
  973. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  974. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  975. break;
  976. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  977. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  978. break;
  979. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  980. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  981. break;
  982. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  983. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  984. break;
  985. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  986. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  987. break;
  988. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  989. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  990. break;
  991. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  992. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  993. break;
  994. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  995. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  996. break;
  997. default:
  998. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  999. break;
  1000. }
  1001. }
  1002. } catch (RuntimeException re) {
  1003. LogUtil.errorLogInfo("", TAG, re);
  1004. }
  1005. catch (Exception e) {
  1006. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1007. //e.printStackTrace();
  1008. LogUtil.errorLogInfo("", TAG, e);
  1009. }
  1010. }
  1011. };
  1012. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1013. try {
  1014. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1015. // 485 대외향 스마트스위치 외출모드
  1016. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1017. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1018. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1019. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1020. mWallpadStatusData.closeDB();
  1021. if (UseGuardSensorCheck == false) {
  1022. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1023. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1024. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1025. mWallpadStatusData.SetAlarmStatus (WallpadStatusData.OUT_MODE);
  1026. mWallpadStatusData.closeDB();
  1027. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1028. //메인화면 업데이트
  1029. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1030. getApplicationContext().sendBroadcast(newIntent);
  1031. ModeRunCtrlWorking(false , false);
  1032. }
  1033. }
  1034. else {
  1035. // 실제 외출 방범 모드를 설정하도록 한다.
  1036. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1037. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1038. // 센서 체크하고
  1039. // 센서 체크하는 부분이 들어가야 함
  1040. Common.SendAppFinishReqBR(getApplicationContext());
  1041. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1042. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1043. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  1044. if (mIGW300.checkSensorforOutmode()) {
  1045. CallOutModeWaitingActivity(AlarmStatus);
  1046. }
  1047. else {
  1048. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  1049. }
  1050. }
  1051. else {
  1052. if (checkSensorforOutmode()) {
  1053. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1054. CallOutModeWaitingActivity(AlarmStatus);
  1055. }
  1056. else {
  1057. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  1058. }
  1059. }
  1060. }
  1061. }
  1062. } catch (RuntimeException re) {
  1063. LogUtil.errorLogInfo("", TAG, re);
  1064. }
  1065. catch (Exception e) {
  1066. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1067. //e.printStackTrace();
  1068. LogUtil.errorLogInfo("", TAG, e);
  1069. }
  1070. }
  1071. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1072. try {
  1073. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1074. //대외향 485 스마트스위치 외출모드 해제
  1075. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1076. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1077. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1078. mWallpadStatusData.closeDB();
  1079. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease +"]");
  1080. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1081. if (OutModePwRelease) {
  1082. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1083. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1084. // 요청하여도 해제 되지 않으며
  1085. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1086. Intent notiIntent = new Intent();
  1087. notiIntent.setAction(define.NOTIFY_ACNAME);
  1088. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1089. getApplicationContext().sendBroadcast(notiIntent);
  1090. }
  1091. else {
  1092. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1093. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1094. // 처리하고.
  1095. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1096. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1097. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1098. mWallpadStatusData.closeDB();
  1099. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1100. Common.SendAppFinishReqBR(getApplicationContext());
  1101. }
  1102. }
  1103. else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1104. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1105. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1106. ModeReleaseCtrlWorking(false);
  1107. bSmartSwitch485ComebackMode = true;
  1108. Intent notiIntent = new Intent();
  1109. notiIntent.setAction(define.NOTIFY_ACNAME);
  1110. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1111. getApplicationContext().sendBroadcast(notiIntent);
  1112. }
  1113. else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1114. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1115. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1116. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1117. mWallpadStatusData.SetAlarmStatus (WallpadStatusData.ALARM_NONE);
  1118. mWallpadStatusData.closeDB();
  1119. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK );
  1120. //메인화면 업데이트
  1121. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1122. getApplicationContext().sendBroadcast(newIntent);
  1123. ModeReleaseCtrlWorking(false);
  1124. }
  1125. } catch (RuntimeException re) {
  1126. LogUtil.errorLogInfo("", TAG, re);
  1127. }
  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. }
  1150. catch (Exception e) {
  1151. DBMGR.closeDB();
  1152. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1153. //e.printStackTrace();
  1154. LogUtil.errorLogInfo("", TAG, e);
  1155. bResult = false;
  1156. }
  1157. return bResult;
  1158. }
  1159. private boolean getStrangerTakePic() {
  1160. try {
  1161. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1162. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1163. DBMGR.closeDB();
  1164. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1165. return bResult;
  1166. } catch (RuntimeException re) {
  1167. LogUtil.errorLogInfo("", TAG, re);
  1168. return false;
  1169. }
  1170. catch (Exception e) {
  1171. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1172. //e.printStackTrace();
  1173. LogUtil.errorLogInfo("", TAG, e);
  1174. return false;
  1175. }
  1176. }
  1177. // 관리자 설정 항목에 있음
  1178. private boolean getStrangerRecordUsage() {
  1179. try {
  1180. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1181. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1182. mWallpadDeviceSet .closeDB();
  1183. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1184. return bResult;
  1185. } catch (RuntimeException re) {
  1186. LogUtil.errorLogInfo("", TAG, re);
  1187. return false;
  1188. }
  1189. catch (Exception e) {
  1190. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1191. //e.printStackTrace();
  1192. LogUtil.errorLogInfo("", TAG, e);
  1193. return false;
  1194. }
  1195. }
  1196. private boolean checkSensorforOutmode() {
  1197. try {
  1198. WallPadInterface wallPadInterface = new WallPadInterface();
  1199. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1200. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1201. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1202. int[] SensorInfoDB;
  1203. int sensorIn = 0;
  1204. int sensorOut = 0;
  1205. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1206. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1207. if (SensorInfoDB[0] == 1) {
  1208. // 내부동체가 사용함이면 상태 검사
  1209. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1210. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1211. }
  1212. if (SensorInfoDB[1] == 1) {
  1213. // 외부동체가 사용함이면 상태 검사
  1214. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1215. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1216. }
  1217. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1218. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1219. // 동체 사용 설정 체크..
  1220. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1221. int sensor = devSet.Get_Sensor_Set();
  1222. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1223. devSet.closeDB();
  1224. int OtherInSensor = 0;
  1225. // 내부동체 사용안함 이면
  1226. if ((sensor&WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1227. // 외부동체 사용안함 이면
  1228. if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1229. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1230. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1231. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1232. return true;
  1233. }
  1234. else {
  1235. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1236. return false;
  1237. }
  1238. } catch (RuntimeException re) {
  1239. LogUtil.errorLogInfo("", TAG, re);
  1240. return false;
  1241. }
  1242. catch (Exception e) {
  1243. //e.printStackTrace();
  1244. LogUtil.errorLogInfo("", TAG, e);
  1245. return false;
  1246. }
  1247. }
  1248. private boolean checkSensorforInmode() {
  1249. try {
  1250. WallPadInterface wallPadInterface = new WallPadInterface();
  1251. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1252. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1253. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1254. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1255. if (sensorMag == 0) {
  1256. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1257. return true;
  1258. }
  1259. else {
  1260. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1261. return false;
  1262. }
  1263. } catch (RuntimeException re) {
  1264. LogUtil.errorLogInfo("", TAG, re);
  1265. return false;
  1266. }
  1267. catch (Exception e) {
  1268. Log.e(TAG, e.toString());
  1269. //e.printStackTrace();
  1270. LogUtil.errorLogInfo("", TAG, e);
  1271. return false;
  1272. }
  1273. }
  1274. /////////////////////
  1275. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1276. //////////////
  1277. /////////////////////
  1278. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1279. //////////////
  1280. public void playSoundthroughDoorphone(int SoundIdx) {
  1281. try
  1282. {
  1283. WallPadInterface Wiface = new WallPadInterface();
  1284. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1285. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1286. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1287. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  1288. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1289. if (getUseSmartDoorCam()) {
  1290. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1291. }
  1292. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1293. /*
  1294. JEFF (2019.01.14)
  1295. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1296. 강신구입니다.
  1297. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1298. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1299. 내용 공유합니다.
  1300. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1301. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1302. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1303. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1304. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1305. 문제 없습니다.
  1306. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1307. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1308. 문의사항은 하기 연락바랍니다.
  1309. 감사합니다.
  1310. */
  1311. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1312. }
  1313. else {
  1314. // 대외향 모델 처리
  1315. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1316. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1317. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1318. }
  1319. try{Thread.sleep(100);}
  1320. catch (RuntimeException re) {
  1321. LogUtil.errorLogInfo("", TAG, re);
  1322. }
  1323. catch (Exception e){
  1324. LogUtil.errorLogInfo("", TAG, e);
  1325. }
  1326. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1327. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1328. try{Thread.sleep(1500);}
  1329. catch (RuntimeException re) {
  1330. LogUtil.errorLogInfo("", TAG, re);
  1331. }
  1332. catch (Exception e){
  1333. LogUtil.errorLogInfo("", TAG, e);
  1334. }
  1335. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1336. int SLevel = Wdb.GetDoorSoundLevel();
  1337. Wdb.closeDB();
  1338. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1339. if (SLevel != -1) {
  1340. /**
  1341. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1342. * **/
  1343. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1344. }
  1345. else {
  1346. // 사용안함이면
  1347. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1348. }
  1349. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1350. int time = Sound().PlayMent(SoundIdx);
  1351. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1352. if (0 > time) {
  1353. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1354. time = 1000;
  1355. }
  1356. try{Thread.sleep(time + 1000);}
  1357. catch (RuntimeException re) {
  1358. LogUtil.errorLogInfo("", TAG, re);
  1359. }
  1360. catch (Exception e){
  1361. LogUtil.errorLogInfo("", TAG, e);
  1362. }
  1363. amanager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1364. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1365. try{Thread.sleep(100);}
  1366. catch (RuntimeException re) {
  1367. LogUtil.errorLogInfo("", TAG, re);
  1368. }
  1369. catch (Exception e){
  1370. LogUtil.errorLogInfo("", TAG, e);
  1371. }
  1372. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1373. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1374. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  1375. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1376. if (getUseSmartDoorCam()) {
  1377. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1378. }
  1379. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1380. /*
  1381. JEFF (2019.01.14)
  1382. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1383. 강신구입니다.
  1384. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1385. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1386. 내용 공유합니다.
  1387. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1388. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1389. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1390. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1391. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1392. 문제 없습니다.
  1393. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1394. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1395. 문의사항은 하기 연락바랍니다.
  1396. 감사합니다.
  1397. */
  1398. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1399. }
  1400. else {
  1401. // 대외향 모델 처리
  1402. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1403. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1404. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1405. }
  1406. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1407. } catch (RuntimeException re) {
  1408. LogUtil.errorLogInfo("", TAG, re);
  1409. }
  1410. catch (Exception e) {
  1411. //e.printStackTrace();
  1412. LogUtil.errorLogInfo("", TAG, e);
  1413. }
  1414. }
  1415. public void CallOutModeRunActivity() {
  1416. int base = 8000;
  1417. int [] Menu_Id_List = { base + 11 };
  1418. int Menu_StartId = base + 11;
  1419. int Menu_Option = -1;
  1420. Intent intent = new Intent(Intent.ACTION_MAIN);
  1421. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1422. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1423. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1424. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1425. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1426. startActivity(intent);
  1427. }
  1428. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1429. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1430. int base = 4000;
  1431. int [] Menu_Id_List = { base + 11 , base + 21};
  1432. int Menu_StartId = base + 11;
  1433. int Menu_Option = 1000;
  1434. Intent intent = new Intent(Intent.ACTION_MAIN);
  1435. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1436. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1437. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1438. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1439. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity","kr.co.icontrols.wallpadsecurity.MainActivity"));
  1440. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1441. startActivity(intent);
  1442. }
  1443. private boolean getGlobalScreenAppRunningStatus() {
  1444. boolean bRunning = false;
  1445. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1446. try {
  1447. bRunning = DBMGR.getGlobalScreenAPKRun();
  1448. DBMGR.closeDB();
  1449. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1450. return bRunning;
  1451. } catch (RuntimeException re) {
  1452. LogUtil.errorLogInfo("", TAG, re);
  1453. DBMGR.closeDB();
  1454. }
  1455. catch (Exception e) {
  1456. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1457. //e.printStackTrace();
  1458. LogUtil.errorLogInfo("", TAG, e);
  1459. DBMGR.closeDB();
  1460. }
  1461. return bRunning;
  1462. }
  1463. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1464. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1465. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1466. try {
  1467. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1468. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1469. DBMGR.closeDB();
  1470. } catch (RuntimeException re) {
  1471. LogUtil.errorLogInfo("", TAG, re);
  1472. DBMGR.closeDB();
  1473. }
  1474. catch (Exception e) {
  1475. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1476. //e.printStackTrace();
  1477. LogUtil.errorLogInfo("", TAG, e);
  1478. DBMGR.closeDB();
  1479. }
  1480. }
  1481. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1482. boolean bGlobalScreenRun = false;
  1483. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1484. try {
  1485. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel +"], hColor [" + hColor +"], hControl [" + hControl +"]");
  1486. wakeupLCD();
  1487. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1488. setGlobalScreenAppRunningStatus(true);
  1489. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1490. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1491. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1492. mIntent.putExtra("ONOFF", hOnOff);
  1493. mIntent.putExtra("DIAL", hDial);
  1494. mIntent.putExtra("LEVEL", hLevel);
  1495. mIntent.putExtra("COLOR", hColor);
  1496. mIntent.putExtra("CONTROL", hControl);
  1497. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1498. mIntent.setComponent(mComponentName);
  1499. startActivity(mIntent);
  1500. }
  1501. else {
  1502. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1503. }
  1504. } catch (RuntimeException re) {
  1505. LogUtil.errorLogInfo("", TAG, re);
  1506. }
  1507. catch (Exception e) {
  1508. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1509. //e.printStackTrace();
  1510. LogUtil.errorLogInfo("", TAG, e);
  1511. }
  1512. }
  1513. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1514. try {
  1515. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel +"], hColor [" + hColor +"], hControl [" + hControl +"]");
  1516. wakeupLCD();
  1517. if (!getGlobalScreenAppRunningStatus()) {
  1518. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1519. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1520. return;
  1521. }
  1522. setGlobalScreenAppRunningStatus(true);
  1523. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1524. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1525. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1526. mIntent.putExtra("SCREENID", nScreenID);
  1527. mIntent.putExtra("ONOFF", hOnOff);
  1528. mIntent.putExtra("DIAL", hDial);
  1529. mIntent.putExtra("LEVEL", hLevel);
  1530. mIntent.putExtra("COLOR", hColor);
  1531. mIntent.putExtra("CONTROL", hControl);
  1532. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1533. mIntent.setComponent(mComponentName);
  1534. startActivity(mIntent);
  1535. }
  1536. else {
  1537. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1538. }
  1539. } catch (RuntimeException re) {
  1540. LogUtil.errorLogInfo("", TAG, re);
  1541. }
  1542. catch (Exception e) {
  1543. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1544. //e.printStackTrace();
  1545. LogUtil.errorLogInfo("", TAG, e);
  1546. }
  1547. }
  1548. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1549. public void sendBlackoutReleasedBR() {
  1550. try {
  1551. Intent notiIntent = new Intent();
  1552. notiIntent.setAction(strBLACKOUT_RELEASED);
  1553. getApplicationContext().sendBroadcast(notiIntent);
  1554. } catch (RuntimeException re) {
  1555. LogUtil.errorLogInfo("", TAG, re);
  1556. }
  1557. catch (Exception e) {
  1558. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1559. //e.printStackTrace();
  1560. LogUtil.errorLogInfo("", TAG, e);
  1561. }
  1562. }
  1563. private int getCurrentScreen() {
  1564. int nScreenID = 0;
  1565. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1566. try {
  1567. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1568. DBMGR.closeDB();
  1569. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1570. return nScreenID;
  1571. } catch (RuntimeException re) {
  1572. LogUtil.errorLogInfo("", TAG, re);
  1573. DBMGR.closeDB();
  1574. }
  1575. catch (Exception e) {
  1576. Log.e(TAG, "[Exception] getCurrentScreen()");
  1577. //e.printStackTrace();
  1578. LogUtil.errorLogInfo("", TAG, e);
  1579. DBMGR.closeDB();
  1580. }
  1581. return nScreenID;
  1582. }
  1583. private void setCurrentScreen(int nScreenID) {
  1584. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1585. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1586. try {
  1587. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1588. DBMGR.closeDB();
  1589. } catch (RuntimeException re) {
  1590. LogUtil.errorLogInfo("", TAG, re);
  1591. DBMGR.closeDB();
  1592. }
  1593. catch (Exception e) {
  1594. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1595. //e.printStackTrace();
  1596. LogUtil.errorLogInfo("", TAG, e);
  1597. DBMGR.closeDB();
  1598. }
  1599. }
  1600. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1601. private void procUploadMissedVisitorPic(Intent intent) {
  1602. try {
  1603. String strDong = intent.getStringExtra("DONG");
  1604. String strHo = intent.getStringExtra("HO");
  1605. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1606. int nCnt = intent.getIntExtra("CNT", 0);
  1607. String[] strMissedPicURI = new String[nCnt];
  1608. strArrayMissedPicURI.clear();
  1609. for (int i = 0; i < nCnt; i++) {
  1610. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1611. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1612. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1613. }
  1614. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1615. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1616. }
  1617. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1618. } catch (RuntimeException re) {
  1619. LogUtil.errorLogInfo("", TAG, re);
  1620. }
  1621. catch (Exception e) {
  1622. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1623. //e.printStackTrace();
  1624. LogUtil.errorLogInfo("", TAG, e);
  1625. }
  1626. }
  1627. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1628. try {
  1629. String strURI = "", strFileName = "", strTime = "", strType = "";
  1630. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1631. // strURI = strArrayMissedPicURI.get(i).toString();
  1632. // strFileName = extractFileName(strURI);
  1633. // strTime = extractFileTime(strURI);
  1634. // strType = extractCallType(strFileName);
  1635. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1636. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1637. // }
  1638. if (strArrayMissedPicURI.size() > 0) {
  1639. strURI = strArrayMissedPicURI.get(0).toString();
  1640. strFileName = extractFileName(strURI);
  1641. strTime = extractFileTime(strFileName);
  1642. strType = extractCallType(strFileName);
  1643. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1644. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1645. }
  1646. else {
  1647. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1648. }
  1649. } catch (RuntimeException re) {
  1650. LogUtil.errorLogInfo("", TAG, re);
  1651. }
  1652. catch (Exception e) {
  1653. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1654. //e.printStackTrace();
  1655. LogUtil.errorLogInfo("", TAG, e);
  1656. }
  1657. }
  1658. public class uploadVisitorPicture extends Thread {
  1659. HDCFTPManager mFTPManager;
  1660. boolean bMainServer2dot0 = false;
  1661. String strRemoteIP = "10.0.1.1";
  1662. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1663. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1664. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1665. try {
  1666. strDong = dong;
  1667. strHo = ho;
  1668. strType = type;
  1669. strTime = time;
  1670. strFileName = filename;
  1671. strUploadFile = uploadfile;
  1672. // bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1673. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  1674. if(danjiserverType == 1)
  1675. {
  1676. bMainServer2dot0 = false;
  1677. }
  1678. else if(danjiserverType == 2)
  1679. {
  1680. bMainServer2dot0 = true;
  1681. }
  1682. else
  1683. {
  1684. bMainServer2dot0 = true;
  1685. }
  1686. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1687. wallpadDeviceSet.closeDB();
  1688. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile +"], strFileName [" + strFileName +"], strTime [" + strTime +"]");
  1689. } catch (RuntimeException re) {
  1690. LogUtil.errorLogInfo("", TAG, re);
  1691. }
  1692. catch (Exception e) {
  1693. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1694. //e.printStackTrace();
  1695. LogUtil.errorLogInfo("", TAG, e);
  1696. }
  1697. }
  1698. public void run() {
  1699. try {
  1700. mFTPManager = new HDCFTPManager();
  1701. if (!mFTPManager.isFTPConnected()) {
  1702. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1703. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1704. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1705. return;
  1706. }
  1707. }
  1708. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1709. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1710. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1711. return;
  1712. }
  1713. if (!bMainServer2dot0) {
  1714. if (!mFTPManager.setPassiveMode()) {
  1715. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1716. disconnectFTP();
  1717. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1718. return;
  1719. }
  1720. }
  1721. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1722. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1723. disconnectFTP();
  1724. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1725. return;
  1726. }
  1727. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1728. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1729. disconnectFTP();
  1730. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1731. return;
  1732. }
  1733. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1734. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1735. disconnectFTP();
  1736. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1737. return;
  1738. }
  1739. disconnectFTP();
  1740. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1741. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1742. sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1743. } catch (RuntimeException re) {
  1744. LogUtil.errorLogInfo("", TAG, re);
  1745. }
  1746. catch (Exception e) {
  1747. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1748. //e.printStackTrace();
  1749. LogUtil.errorLogInfo("", TAG, e);
  1750. }
  1751. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1752. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1753. }
  1754. public boolean disconnectFTP() {
  1755. try {
  1756. if (mFTPManager.logoutFTP()) {
  1757. if (mFTPManager.disconnectFTP()) {
  1758. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1759. return true;
  1760. }
  1761. }
  1762. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1763. return false;
  1764. } catch (RuntimeException re) {
  1765. LogUtil.errorLogInfo("", TAG, re);
  1766. return false;
  1767. }
  1768. catch (Exception e) {
  1769. Log.e(TAG, "[Exception] disconnectFTP()");
  1770. //e.printStackTrace();
  1771. LogUtil.errorLogInfo("", TAG, e);
  1772. return false;
  1773. }
  1774. }
  1775. }
  1776. private String extractCallType(String strFileName) {
  1777. try {
  1778. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1779. String[] strParse_01 = strFileName.split("_");
  1780. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1781. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1782. else return "none";
  1783. } catch (RuntimeException re) {
  1784. LogUtil.errorLogInfo("", TAG, re);
  1785. return null;
  1786. }
  1787. catch (Exception e) {
  1788. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1789. //e.printStackTrace();
  1790. LogUtil.errorLogInfo("", TAG, e);
  1791. return null;
  1792. }
  1793. }
  1794. private String extractFileName(String strTargetFile) {
  1795. try {
  1796. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1797. String[] strParse_01 = strTargetFile.split("/");
  1798. return strParse_01[strParse_01.length - 1];
  1799. } catch (RuntimeException re) {
  1800. LogUtil.errorLogInfo("", TAG, re);
  1801. return null;
  1802. }
  1803. catch (Exception e) {
  1804. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1805. //e.printStackTrace();
  1806. LogUtil.errorLogInfo("", TAG, e);
  1807. return null;
  1808. }
  1809. }
  1810. private String extractFileTime(String strFileName) {
  1811. try {
  1812. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1813. String[] strParse_01 = strFileName.split("\\.");
  1814. String[] strParse_02 = strParse_01[0].split("_");
  1815. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1816. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1817. // 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);
  1818. return strParse_02[5] + "_" + strParse_02[6];
  1819. } catch (RuntimeException re) {
  1820. LogUtil.errorLogInfo("", TAG, re);
  1821. return null;
  1822. }
  1823. catch (Exception e) {
  1824. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1825. //e.printStackTrace();
  1826. LogUtil.errorLogInfo("", TAG, e);
  1827. return null;
  1828. }
  1829. }
  1830. String strRemoteURI, strUserID, strPW, strPath;
  1831. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1832. String strKey_Pass = "passwd";
  1833. 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) {
  1834. try {
  1835. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1836. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1837. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1838. visitor_access_info.setResultCtrl(new RetProci() {
  1839. @Override
  1840. public void ProcSuccess() {
  1841. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1842. visitor_access_info.SetItem("ftp_info");
  1843. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1844. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1845. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1846. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1847. strUserID = strReply_User;
  1848. strPW = strReply_PW;
  1849. strPath = strReply_Path;
  1850. strRemoteURI = strPath + "/" + strFileName;
  1851. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1852. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1853. mUploadVisitorPicture.start();
  1854. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1855. // mUploadVisitorPicture.start();
  1856. }
  1857. @Override
  1858. public void ProcError() {
  1859. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1860. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1861. sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1862. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1863. }
  1864. @Override
  1865. public void ProcDoing() {
  1866. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1867. }
  1868. });
  1869. return true;
  1870. }
  1871. } catch (RuntimeException re) {
  1872. LogUtil.errorLogInfo("", TAG, re);
  1873. }
  1874. catch (Exception e) {
  1875. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1876. //e.printStackTrace();
  1877. LogUtil.errorLogInfo("", TAG, e);
  1878. }
  1879. return false;
  1880. }
  1881. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1882. try {
  1883. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1884. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1885. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1886. visitor_upload_complete.setResultCtrl(new RetProci() {
  1887. @Override
  1888. public void ProcSuccess() {
  1889. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1890. }
  1891. @Override
  1892. public void ProcError() {
  1893. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1894. }
  1895. @Override
  1896. public void ProcDoing() {
  1897. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1898. }
  1899. });
  1900. return true;
  1901. }
  1902. } catch (RuntimeException re) {
  1903. LogUtil.errorLogInfo("", TAG, re);
  1904. }
  1905. catch (Exception e) {
  1906. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1907. //e.printStackTrace();
  1908. LogUtil.errorLogInfo("", TAG, e);
  1909. }
  1910. return false;
  1911. }
  1912. /**
  1913. * 이통사 연동 서비스를 위한 BR
  1914. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1915. * @param kind (String) "lobby" or "home"
  1916. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1917. */
  1918. public void sendVisitorEventBRtoMobileVendorSKT(String kind , String datetime) {
  1919. try {
  1920. Log.i(TAG, "[sendVisitorEventBRtoMobileVendorSKT] kind [" + kind + "], datetime [" + datetime + "]");
  1921. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1922. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1923. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1924. Intent mIntent = new Intent();
  1925. mIntent.setAction(BR_VISITOR_EVENT);
  1926. mIntent.putExtra("KIND", kind);
  1927. mIntent.putExtra("TIME", datetime);
  1928. getApplicationContext().sendBroadcast(mIntent);
  1929. } catch (RuntimeException re) {
  1930. LogUtil.errorLogInfo("", TAG, re);
  1931. }
  1932. catch (Exception e) {
  1933. Log.e(TAG, "[Exception] sendVisitorEventBRtoMobileVendorSKT(String kind , String datetime)");
  1934. //e.printStackTrace();
  1935. LogUtil.errorLogInfo("", TAG, e);
  1936. }
  1937. }
  1938. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1939. public void onReceive(Context context, Intent intent) {
  1940. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1941. Bundle bundle;
  1942. WallpadDeviceSet devset;
  1943. Intent newintent;
  1944. boolean CallAppRun = false;
  1945. boolean MgrAppRun = false;
  1946. final String packageName = "com.artncore.apps.ic_wallpad";
  1947. final String packageNameMgr = "com.artncore.managersetting";
  1948. //CallAppRun = getForegroundAPK().equals(packageName);
  1949. // CallAppRun = getCallAppRunning();
  1950. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1951. int base = 7000;
  1952. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  1953. int Menu_Start_Option = 1;
  1954. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1955. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1956. int keyevt = ReceiveEvt.getKeyCode();
  1957. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY -1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1958. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1959. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1960. sdata.closeDB();
  1961. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1962. return;
  1963. }
  1964. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1965. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1966. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1967. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1968. mWallpadStatusData.closeDB();
  1969. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1970. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1971. sdata.closeDB();
  1972. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1973. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1974. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1975. int nModelType = Version.getModelType();
  1976. switch (ReceiveEvt.getKeyCode()) {
  1977. case 251: // 현산향 비상버튼 다운 업 처리
  1978. try {
  1979. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1980. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1981. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1982. }
  1983. else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1984. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1985. }
  1986. }
  1987. } catch (RuntimeException re) {
  1988. LogUtil.errorLogInfo("", TAG, re);
  1989. }
  1990. catch (Exception e) {
  1991. //e.printStackTrace();
  1992. LogUtil.errorLogInfo("", TAG, e);
  1993. }
  1994. break;
  1995. case WallPadInterface.EVT_RING:
  1996. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1997. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1998. // 전화 수신 링 수신
  1999. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  2000. if (Version.getGatewayUsage()) {
  2001. // 국선 시작만 올라온다.
  2002. startIGW300RingGenerator();
  2003. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  2004. }
  2005. else {
  2006. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  2007. }
  2008. break;
  2009. case WallPadInterface.EVT_END_RING:
  2010. // 전화 수신 링 종료
  2011. // Jeff added below codes for call app (2018.01.25)
  2012. // This event is managed by WallPadCall
  2013. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  2014. if (Version.getGatewayUsage()) {
  2015. stopIGW300RingGenerator();
  2016. }
  2017. break;
  2018. case WallPadInterface.BTN_EMR:
  2019. case WallPadInterface.BTN_EMR_IHN1010:
  2020. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2021. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2022. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2023. if (MgrAppRun) return;
  2024. if (Common.DIAGNOSTIC_MODE) return;
  2025. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  2026. //currentTime = System.currentTimeMillis();
  2027. //if (ALERTTIME > currentTime) break;
  2028. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2029. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2030. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2031. devset = new WallpadDeviceSet(getApplicationContext());
  2032. int StatusVal = devset.GetDeviceSetted("알람발생");
  2033. devset.closeDB();
  2034. Log.d("imap", "StatusVal : " + StatusVal);
  2035. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2036. // 보안 처리가 필요함..
  2037. // 지속적으로 이벤트가 들어올 경우 대비
  2038. Common.SendAppFinishReqBR(getApplicationContext());
  2039. newintent = new Intent(Intent.ACTION_MAIN);
  2040. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2041. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2042. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2043. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2044. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2045. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2046. iMAPstartActivity(newintent);
  2047. }
  2048. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2049. if (getIsSubWallpad()) {
  2050. Intent notiIntent = new Intent();
  2051. notiIntent.setAction(define.NOTIFY_ACNAME);
  2052. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2053. getApplicationContext().sendBroadcast(notiIntent);
  2054. }
  2055. break;
  2056. case WallPadInterface.BTN_CALL:
  2057. case WallPadInterface.BTN_CALL_IHN1010:
  2058. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2059. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2060. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2061. // Jeff added below codes for call app (2018.01.25)
  2062. try {
  2063. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2064. if (getIsSubWallpad()) {
  2065. // 서브월패드
  2066. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2067. }
  2068. else {
  2069. // 메인월패드
  2070. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2071. }
  2072. } catch (RuntimeException re) {
  2073. LogUtil.errorLogInfo("", TAG, re);
  2074. }
  2075. catch (Exception e) {
  2076. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2077. //e.printStackTrace();
  2078. LogUtil.errorLogInfo("", TAG, e);
  2079. }
  2080. break;
  2081. case WallPadInterface.BTN_OPEN:
  2082. // 월패드 문여림 버튼 입력 상태 SA
  2083. break;
  2084. case WallPadInterface.BTN_DOOR:
  2085. case WallPadInterface.BTN_DOOR_IHN1010:
  2086. // 현관 도어폰 벨 눌림 입력 상태
  2087. // Jeff added below codes for call app (2018.01.25)
  2088. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2089. if (!bWallPadCallLive && !bBlockFrontCall) {
  2090. bBlockFrontCall = true;
  2091. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2092. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2093. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2094. try {
  2095. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2096. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2097. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2098. }
  2099. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2100. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2101. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  2102. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2103. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2104. }
  2105. if (!Version.getGatewayUsage()) {
  2106. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2107. }
  2108. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2109. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2110. } catch (RuntimeException re) {
  2111. LogUtil.errorLogInfo("", TAG, re);
  2112. }
  2113. catch (Exception e) {
  2114. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2115. //e.printStackTrace();
  2116. LogUtil.errorLogInfo("", TAG, e);
  2117. }
  2118. }
  2119. else {
  2120. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2121. }
  2122. break;
  2123. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2124. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN101GL:
  2125. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN101GL)) {
  2126. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2127. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2128. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2129. if (MgrAppRun) return;
  2130. if (Common.DIAGNOSTIC_MODE) return;
  2131. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  2132. //currentTime = System.currentTimeMillis();
  2133. //if (ALERTTIME > currentTime) break;
  2134. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2135. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2136. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2137. devset = new WallpadDeviceSet(getApplicationContext());
  2138. StatusVal = devset.GetDeviceSetted("알람발생");
  2139. devset.closeDB();
  2140. Log.d("imap", "StatusVal : " + StatusVal);
  2141. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2142. // 보안 처리가 필요함..
  2143. // 지속적으로 이벤트가 들어올 경우 대비
  2144. Common.SendAppFinishReqBR(getApplicationContext());
  2145. newintent = new Intent(Intent.ACTION_MAIN);
  2146. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2147. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2148. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2149. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2150. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2151. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2152. iMAPstartActivity(newintent);
  2153. }
  2154. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2155. if (getIsSubWallpad()) {
  2156. Intent notiIntent = new Intent();
  2157. notiIntent.setAction(define.NOTIFY_ACNAME);
  2158. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2159. getApplicationContext().sendBroadcast(notiIntent);
  2160. }
  2161. }
  2162. else {
  2163. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2164. if (!getEmergencyIOUsage()) {
  2165. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2166. return;
  2167. }
  2168. if (MgrAppRun) {
  2169. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2170. return;
  2171. }
  2172. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2173. devset = new WallpadDeviceSet(getApplicationContext());
  2174. StatusVal = devset.GetDeviceSetted("알람발생");
  2175. devset.closeDB();
  2176. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2177. Common.SendAppFinishReqBR(getApplicationContext());
  2178. newintent = new Intent(Intent.ACTION_MAIN);
  2179. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2180. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2181. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2182. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2183. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2184. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2185. iMAPstartActivity(newintent);
  2186. }
  2187. }
  2188. break;
  2189. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2190. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2191. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2192. if (MgrAppRun) return;
  2193. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
  2194. WallPadInterface mWallPadInterface = new WallPadInterface();
  2195. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2196. if (sensorMag == 0) return;
  2197. }
  2198. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2199. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT ) break;
  2200. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2201. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2202. if (OutGoingSensorWaiting == 0) {
  2203. wakeupLCD();
  2204. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2205. SensorThread.start();
  2206. }
  2207. OutGoingSensorWaiting |= SENSOR_MAG;
  2208. }
  2209. else {
  2210. Common.SendAppFinishReqBR(getApplicationContext());
  2211. newintent = new Intent(Intent.ACTION_MAIN);
  2212. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2213. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2214. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2215. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2216. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2217. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2218. iMAPstartActivity(newintent);
  2219. }
  2220. break;
  2221. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2222. saveBlackoutStatus(true);
  2223. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2224. break;
  2225. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2226. saveBlackoutStatus(false);
  2227. sendBlackoutReleasedBR();
  2228. break;
  2229. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2230. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2231. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2232. if (MgrAppRun) return;
  2233. if (AlarmStatus == WallpadStatusData.ALARM_ARISE ||AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2234. devset = new WallpadDeviceSet(getApplicationContext());
  2235. StatusVal = devset.GetDeviceSetted("피난사다리");
  2236. int LadderSend = devset.getEscapeLadderDownSend();
  2237. devset.closeDB();
  2238. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2239. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2240. Common.SendAppFinishReqBR(getApplicationContext());
  2241. newintent = new Intent(Intent.ACTION_MAIN);
  2242. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2243. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2244. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2245. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER) newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2246. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW) newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2247. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2248. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2249. iMAPstartActivity(newintent);
  2250. }
  2251. break;
  2252. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2253. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2254. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2255. {
  2256. // 내부동체가 상태가 변경된 경우
  2257. int[] SensorInfoDB;
  2258. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2259. if (SensorInfoDB[0] != 1) {
  2260. //내부동체가 사용함이면 상태 검사
  2261. return;
  2262. }
  2263. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
  2264. WallPadInterface mWallPadInterface = new WallPadInterface();
  2265. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2266. if (sensorMag == 0) return;
  2267. }
  2268. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2269. int sensor = devSet.Get_Sensor_Set();
  2270. devSet.closeDB();
  2271. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2272. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2273. break;
  2274. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2275. if (OutGoingSensorWaiting == 0) {
  2276. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2277. SensorThread.start();
  2278. }
  2279. OutGoingSensorWaiting |= SENSOR_IN;
  2280. }
  2281. break;
  2282. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2283. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2284. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2285. {
  2286. // 외부동체가 상태가 변경된 경우
  2287. int[] SensorInfoDB;
  2288. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2289. if (SensorInfoDB[1] != 1) {
  2290. // 외부동체가 사용함이면 상태 검사
  2291. return;
  2292. }
  2293. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
  2294. WallPadInterface mWallPadInterface = new WallPadInterface();
  2295. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2296. if (sensorMag == 0) return;
  2297. }
  2298. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2299. int sensor = devSet.Get_Sensor_Set();
  2300. devSet.closeDB();
  2301. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2302. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2303. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2304. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) break;
  2305. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2306. {
  2307. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2308. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2309. break;
  2310. }*/
  2311. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2312. if (OutGoingSensorWaiting == 0) {
  2313. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2314. SensorThread.start();
  2315. }
  2316. OutGoingSensorWaiting |= SENSOR_OUT;
  2317. }
  2318. else {
  2319. Common.SendAppFinishReqBR(getApplicationContext());
  2320. newintent = new Intent(Intent.ACTION_MAIN);
  2321. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2322. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2323. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2324. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2325. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2326. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2327. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2328. iMAPstartActivity(newintent);
  2329. }
  2330. }
  2331. break;
  2332. }
  2333. }
  2334. else {
  2335. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2336. }
  2337. }
  2338. };
  2339. protected void iMAPstartActivity(Intent intent) {
  2340. try {
  2341. startActivity(intent);
  2342. } catch (RuntimeException re) {
  2343. LogUtil.errorLogInfo("", TAG, re);
  2344. }
  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) nVolume = 12;
  2372. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2373. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2374. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2375. mDingDongHandler.sendEmptyMessage(1);
  2376. } else if (msg.what == 1) {
  2377. // 띵똥 패스 체크
  2378. check1++;
  2379. if (check1 > 200) {
  2380. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2381. finishDingDongHandler();
  2382. check1 = 0;
  2383. return;
  2384. } else {
  2385. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2386. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2387. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2388. }
  2389. } else if (msg.what == 2) {
  2390. // 띵똥 음원 재생
  2391. mIOInterface.ctrlSetTalkPathDoor();
  2392. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2393. } else if (msg.what == 3) {
  2394. mIOInterface.ctrlSetTalkPathNormal();
  2395. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2396. mDingDongHandler.sendEmptyMessage(4);
  2397. } else if (msg.what == 4) {
  2398. // Normal 패스 체크
  2399. check2++;
  2400. if (check2 > 200) {
  2401. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2402. finishDingDongHandler();
  2403. check2 = 0;
  2404. return;
  2405. } else {
  2406. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2407. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2408. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2409. }
  2410. } else if (msg.what == 5) {
  2411. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2412. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2413. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2414. wdb.closeDB();
  2415. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2416. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2417. intent.setAction(define.NOTIFY_ACNAME);
  2418. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2419. sendBroadcast(intent);
  2420. }
  2421. } catch (RuntimeException re) {
  2422. LogUtil.errorLogInfo("", TAG, re);
  2423. finishDingDongHandler();
  2424. }
  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. }
  2453. catch (Exception e) {
  2454. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2455. //e.printStackTrace();
  2456. LogUtil.errorLogInfo("", TAG, e);
  2457. }
  2458. }
  2459. // 외출방범 대기 모드 중 사운드와 센서 체크
  2460. class OutgoingCheckSensor extends Thread {
  2461. public OutgoingCheckSensor() {
  2462. }
  2463. public void run() {
  2464. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2465. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2466. WallPadInterface wpifc = new WallPadInterface();
  2467. mWallpadStatusData.closeDB();
  2468. int checkcount = timedata / 5;
  2469. int i;
  2470. for (i = checkcount; i > 0; i--) {
  2471. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2472. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2473. mWallpadStatusData.closeDB();
  2474. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2475. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2476. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2477. try{Thread.sleep(5000);}
  2478. catch (RuntimeException re) {
  2479. LogUtil.errorLogInfo("", TAG, re);
  2480. }
  2481. catch (Exception e){
  2482. LogUtil.errorLogInfo("", TAG, e);
  2483. }
  2484. }
  2485. if (i==0) {
  2486. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2487. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2488. mWallpadStatusData.closeDB();
  2489. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2490. Common.SendAppFinishReqBR(getApplicationContext());
  2491. int base = 7000;
  2492. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  2493. int Menu_Start_Option = 1;
  2494. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2495. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2496. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2497. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2498. String Cuase = (OutGoingSensorWaiting&SENSOR_OUT)>0?"bugout":"bugin";
  2499. if ((OutGoingSensorWaiting&SENSOR_OUT)>0) Cuase = "bugout";
  2500. else if ((OutGoingSensorWaiting&SENSOR_MAG)>0) Cuase = "magnetic";
  2501. else if ((OutGoingSensorWaiting&SENSOR_IN)>0) Cuase = "bugin";
  2502. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2503. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2504. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2505. iMAPstartActivity(mIntent);
  2506. }
  2507. }
  2508. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2509. OutGoingSensorWaiting = 0;
  2510. }
  2511. }
  2512. @Override
  2513. public IBinder onBind(Intent arg0) {
  2514. return null;
  2515. }
  2516. public void imapsvrlog(String msg)
  2517. {
  2518. if (!log_sw) return;
  2519. Log.d(TAG, APIErrorCode.GetLogPrefix()+" IMAPSVR:"+msg);
  2520. }
  2521. public int onStartCommand(Intent intent, int flags, int startID) {
  2522. try {
  2523. try {
  2524. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2525. } catch (RuntimeException re) {
  2526. LogUtil.errorLogInfo("", TAG, re);
  2527. }
  2528. catch (Exception e) {
  2529. //e.printStackTrace();
  2530. LogUtil.errorLogInfo("", TAG, e);
  2531. }
  2532. SvrSock = new iMapSverSocket();
  2533. SvrSock.start();
  2534. } catch (IOException e) {
  2535. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2536. //e.printStackTrace();
  2537. LogUtil.errorLogInfo("", TAG, e);
  2538. }
  2539. try {
  2540. mGleInterface = new jni();
  2541. } catch (RuntimeException re) {
  2542. LogUtil.errorLogInfo("", TAG, re);
  2543. }
  2544. catch (Exception e) {
  2545. Log.e(TAG,"[Exception] mGleInterface init...");
  2546. //e.printStackTrace();
  2547. LogUtil.errorLogInfo("", TAG, e);
  2548. }
  2549. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2550. AddressSet addr = DBMGR.getAddressMGR();
  2551. DBMGR.closeDB();
  2552. String AddressStr = addr.Dong+"동 "+addr.Ho+"호";
  2553. AddrDong = addr.Dong;
  2554. AddrHo = addr.Ho;
  2555. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  2556. "<imap ver=\"1.0\" address=\""+addr.IPAddress+"\" sender=\""+AddressStr+"\">\r\n";
  2557. Log.d(TAG, "*****************************************");
  2558. Log.d(TAG, "****************SchedulerThread**********");
  2559. Log.d(TAG, "*****************************************");
  2560. ScheServer = new SchedulerThread();
  2561. ScheServer.start();
  2562. // BR 등록 시작
  2563. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2564. IntentFilter mIntentFilter = new IntentFilter();
  2565. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2566. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2567. mIntentFilter = new IntentFilter();
  2568. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2569. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2570. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2571. mIntentFilter = new IntentFilter();
  2572. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2573. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2574. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2575. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  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) IGW200APICheckHandler.sendEmptyMessage(0);
  2581. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2582. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2583. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  2584. IGW300APICheckHandler.sendEmptyMessage(0);
  2585. }
  2586. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2587. mIOInterface.setEmergencyType();
  2588. Intent notiIntent = new Intent();
  2589. notiIntent.setAction(define.NOTIFY_ACNAME);
  2590. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2591. getApplicationContext().sendBroadcast(notiIntent);
  2592. CheckMainStatus();
  2593. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2594. getAirQualityUsage();
  2595. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2596. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2597. GwCheckThread.start();
  2598. }
  2599. return START_STICKY;
  2600. }
  2601. // 메인 서버 소켓 클래스
  2602. public class iMapSverSocket extends Thread
  2603. {
  2604. ServerSocket svr;
  2605. private SSLServerSocket sslsvr;
  2606. boolean receiveSocketRun = true;
  2607. public iMapSverSocket() throws IOException
  2608. {
  2609. /////////////////////////////////////////////////////////////////////
  2610. // 신형 단지서버 사용 유무를 가져온다.
  2611. /////////////////////////////////////////////////////////////////////
  2612. try {
  2613. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2614. // mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2615. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  2616. if(danjiserverType == 1)
  2617. {
  2618. mNewDanjiServer = false;
  2619. }
  2620. else if(danjiserverType == 2)
  2621. {
  2622. mNewDanjiServer = true;
  2623. }
  2624. else
  2625. {
  2626. mNewDanjiServer = true;
  2627. }
  2628. wallpadDeviceSet.closeDB();
  2629. } catch (RuntimeException re) {
  2630. LogUtil.errorLogInfo("", TAG, re);
  2631. mNewDanjiServer = false;
  2632. }
  2633. catch (Exception e) {
  2634. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2635. //e.printStackTrace();
  2636. LogUtil.errorLogInfo("", TAG, e);
  2637. mNewDanjiServer = false;
  2638. }
  2639. //////////////////////////////////////////////////
  2640. /////////////////////////////////////////////////////////////////////
  2641. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2642. /////////////////////////////////////////////////////////////////////
  2643. if(!mNewDanjiServer)
  2644. {
  2645. svr = new ServerSocket(port);
  2646. }
  2647. else
  2648. {
  2649. int svrport = port + 1000;
  2650. Log.i(TAG, "============================================");
  2651. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2652. Log.i(TAG, "============================================");
  2653. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2654. sslsvr = sslServerSocket.getServerSocket();
  2655. }
  2656. }
  2657. public void run()
  2658. {
  2659. while(receiveSocketRun)
  2660. {
  2661. try {
  2662. Socket sock = null;
  2663. /////////////////////////////////////////////////////////////////////
  2664. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2665. /////////////////////////////////////////////////////////////////////
  2666. if(!mNewDanjiServer)
  2667. {
  2668. sock = svr.accept();
  2669. }
  2670. else
  2671. {
  2672. sock = sslsvr.accept();
  2673. }
  2674. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2675. ProciMap.start();
  2676. } catch (IOException e) {
  2677. //e.printStackTrace();
  2678. LogUtil.errorLogInfo("", TAG, e);
  2679. }
  2680. }
  2681. }
  2682. public void destoryThread()
  2683. {
  2684. receiveSocketRun = false;
  2685. try
  2686. {
  2687. if( svr != null )
  2688. {
  2689. svr.close();
  2690. svr = null;
  2691. }
  2692. if( sslsvr != null )
  2693. {
  2694. sslsvr.close();
  2695. sslsvr = null;
  2696. }
  2697. }
  2698. catch (RuntimeException re) {
  2699. LogUtil.errorLogInfo("", TAG, re);
  2700. }
  2701. catch (Exception e)
  2702. {
  2703. //e.printStackTrace();
  2704. LogUtil.errorLogInfo("", TAG, e);
  2705. }
  2706. }
  2707. }
  2708. // iMAP 서버 소켓 처리
  2709. public class iMapSverSocketThread extends Thread {
  2710. private final Socket iMAPSock;
  2711. String strRcvMSG;
  2712. WallPadiMAPUpgrade upgradeProc;
  2713. Document doc;
  2714. public iMapSverSocketThread(Socket sock) {
  2715. iMAPSock = sock;
  2716. }
  2717. public void run() {
  2718. try {
  2719. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2720. InputStream InStm = iMAPSock.getInputStream();
  2721. iMAPSock.setSoLinger(true, 3000);
  2722. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2723. strRcvMSG = "";
  2724. String InBuffer;
  2725. int i = 0;
  2726. boolean bRcvOK = false;
  2727. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2728. /////////////////////////////////////////////////////////////////////
  2729. // 신형단지서버 미사용중일 경우 기존 코드로,
  2730. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2731. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2732. /////////////////////////////////////////////////////////////////////
  2733. if (!mNewDanjiServer) {
  2734. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2735. try {
  2736. if (MsgReader.ready()) {
  2737. try {
  2738. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2739. InBuffer = "";
  2740. while (MsgReader.ready()) {
  2741. long charCnt = MsgReader.read(ReadData);
  2742. InBuffer += new String(ReadData, 0, (int)charCnt);
  2743. }
  2744. if (InBuffer != null) strRcvMSG += InBuffer;
  2745. if (0 < InBuffer.indexOf("</imap>")) {
  2746. bRcvOK = true;
  2747. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2748. break;
  2749. }
  2750. } catch (RuntimeException re) {
  2751. LogUtil.errorLogInfo("", TAG, re);
  2752. return;
  2753. }
  2754. catch (Exception e) {
  2755. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2756. //e.printStackTrace();
  2757. LogUtil.errorLogInfo("", TAG, e);
  2758. return;
  2759. }
  2760. }
  2761. else {
  2762. Thread.sleep(100);
  2763. }
  2764. } catch (RuntimeException re) {
  2765. LogUtil.errorLogInfo("", TAG, re);
  2766. iMAPSock.close();
  2767. return;
  2768. }
  2769. catch (Exception e) {
  2770. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  2771. iMAPSock.close();
  2772. //e.printStackTrace();
  2773. LogUtil.errorLogInfo("", TAG, e);
  2774. return;
  2775. }
  2776. }
  2777. }
  2778. else {
  2779. // SSL 암호화 데이터 수신부
  2780. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  2781. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2782. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2783. try {
  2784. InBuffer = "";
  2785. long charCnt = MsgReader.read(ReadData);
  2786. if (charCnt > 0) {
  2787. InBuffer += new String(ReadData, 0, (int)charCnt);
  2788. strRcvMSG += InBuffer;
  2789. if (-1 < InBuffer.indexOf("</imap>")) {
  2790. bRcvOK = true;
  2791. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  2792. break;
  2793. }
  2794. }
  2795. else {
  2796. Thread.sleep(100);
  2797. }
  2798. } catch (RuntimeException re) {
  2799. LogUtil.errorLogInfo("", TAG, re);
  2800. iMAPSock.close();
  2801. return;
  2802. }
  2803. catch (Exception e) {
  2804. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  2805. iMAPSock.close();
  2806. //e.printStackTrace();
  2807. LogUtil.errorLogInfo("", TAG, e);
  2808. return;
  2809. }
  2810. }
  2811. }
  2812. if (!bRcvOK) {
  2813. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  2814. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  2815. Log.i(TAG, strRcvMSG);
  2816. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  2817. iMAPSock.close();
  2818. return;
  2819. }
  2820. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  2821. imapsvrlog( "Socket read end accept </imap>\n"+strRcvMSG);
  2822. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2823. DocumentBuilder builder = factory.newDocumentBuilder();
  2824. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  2825. doc = builder.parse(istream);
  2826. Element elelist = doc.getDocumentElement();
  2827. NodeList items = elelist.getElementsByTagName("service");
  2828. Node item = items.item(0);
  2829. NamedNodeMap attrs = item.getAttributes();
  2830. String retXML="";
  2831. for (int j=0; j< attrs.getLength(); j++) {
  2832. Node attr = attrs.item(j);
  2833. String cmd;
  2834. if (attr.getNodeName().equalsIgnoreCase("type")) {
  2835. cmd = attr.getNodeValue();
  2836. if (cmd.equalsIgnoreCase("notice")) {
  2837. iMAPSock.close();
  2838. }
  2839. }
  2840. else if (attr.getNodeName().equalsIgnoreCase("name")) {
  2841. cmd = attr.getNodeValue();
  2842. if (cmd.equalsIgnoreCase("event_notify")) {
  2843. retXML = ProcEventNotify(elelist);
  2844. }
  2845. else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  2846. ProcElevatorinfo(elelist);
  2847. retXML = null;
  2848. }
  2849. else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  2850. retXML = ProcCheckEpiceUpload(doc);
  2851. }
  2852. else if (cmd.equalsIgnoreCase("update_news")) {
  2853. retXML = ProcUpdateNews(doc);
  2854. }
  2855. else if (cmd.equalsIgnoreCase("update_weather")) {
  2856. retXML = ProcUpdateWeather(doc);
  2857. }
  2858. else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  2859. retXML = ProcSchduleInquiry(doc);
  2860. }
  2861. else if (cmd.equalsIgnoreCase("schedule_renew")) {
  2862. retXML = ProcSchduleRenew(doc);
  2863. }
  2864. else if (cmd.equalsIgnoreCase("schdule")) {
  2865. String SvcType="";
  2866. int k;
  2867. for (k = j + 1; k < attrs.getLength(); k++) {
  2868. Node attr1 = attrs.item(k);
  2869. SvcType = attr1.getNodeName();
  2870. if (SvcType.equalsIgnoreCase("shc_type")) {
  2871. SvcType = attr1.getNodeValue();
  2872. break;
  2873. }
  2874. }
  2875. retXML = ProcUpdateSchedule(elelist,SvcType);
  2876. }
  2877. else if (cmd.equalsIgnoreCase("device_reset")) {
  2878. retXML = ProcDeviceReset(elelist);
  2879. }
  2880. else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  2881. retXML = ProcNotifyparcel(doc);
  2882. }
  2883. else if (cmd.equalsIgnoreCase("notify_post_info")) {
  2884. // 스마트우편함 연동 여부
  2885. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  2886. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  2887. DevSet.closeDB();
  2888. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  2889. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  2890. }
  2891. else if (cmd.equalsIgnoreCase("get_security_mode")) {
  2892. String Dong = null;
  2893. String Ho = null;
  2894. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  2895. String result;
  2896. String modeStr = null;
  2897. int status = statusDB.GetAlarmStatus();
  2898. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  2899. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  2900. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  2901. else if (status == WallpadStatusData.GUARD_OUT) modeStr = "unoccupied";
  2902. else if (status == WallpadStatusData.GUARD_OUT_WAIT) modeStr = "waitunoccupied";
  2903. result = "ok";
  2904. }
  2905. else {
  2906. modeStr = "null";
  2907. result = "fail";
  2908. }
  2909. try {
  2910. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  2911. Node GSM_item = GSM_items.item(0);
  2912. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  2913. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  2914. Node GSM_attr = GSM_attrsParam.item(k);
  2915. if (GSM_attr.getNodeName().equalsIgnoreCase("dong")) Dong = trimquotation(GSM_attr.getNodeValue());
  2916. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho")) Ho = trimquotation(GSM_attr.getNodeValue());
  2917. }
  2918. WallpadStatusData DBMGR = null;
  2919. DBMGR = new WallpadStatusData(getApplicationContext());
  2920. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  2921. DBMGR.closeDB();
  2922. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  2923. result = "fail";
  2924. }
  2925. } catch (RuntimeException re) {
  2926. LogUtil.errorLogInfo("", TAG, re);
  2927. result = "fail";
  2928. }
  2929. catch (Exception e) {
  2930. result = "fail";
  2931. }
  2932. retXML = XMLHeader +
  2933. " <service type=\"reply\" name=\"get_security_mode\" result=\""+result+"\">\r\n"+
  2934. " <home_info dong=\""+AddrDong+"\" ho=\""+AddrHo+"\" mode=\""+modeStr+"\"/>\r\n"+
  2935. " </service>\r\n"+
  2936. "</imap>\r\n";
  2937. statusDB.closeDB();
  2938. }
  2939. else if (cmd.equalsIgnoreCase("set_setup_info")) {
  2940. retXML = ProcSetsetup(doc);
  2941. }
  2942. else if (cmd.equalsIgnoreCase("get_setup_info")) {
  2943. retXML = ProcGetsetup(doc);
  2944. }
  2945. else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  2946. retXML = CheckPassword(doc);
  2947. }
  2948. else if (cmd.equalsIgnoreCase("device_live_check")) {
  2949. retXML = ProcDeviceLiveCheck();
  2950. }
  2951. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  2952. retXML = ProcPairingHdevSyncAlarm(elelist);
  2953. }
  2954. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  2955. retXML = ProcPairingHdevSyncSecurity(elelist);
  2956. }
  2957. else if (cmd.equalsIgnoreCase("notify_car_event")) {
  2958. retXML = ProcParkInformation(elelist);
  2959. }
  2960. else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2961. retXML = ProcSmartKeyEvent(elelist);
  2962. }
  2963. else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  2964. retXML = ProcParkInformation_cham_upis(elelist);
  2965. }
  2966. else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  2967. retXML = ProcauscultateReq(doc);
  2968. }
  2969. else if (cmd.equalsIgnoreCase("upgrade")) {
  2970. imapsvrlog( "Enter Upgrade");
  2971. procUpgrade();
  2972. retXML = null;
  2973. }
  2974. else if (cmd.equals("check_sip_activation")) {
  2975. String sip_result = "fail";
  2976. ActivityManager manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  2977. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  2978. // Jeff added below codes for call app (2018.01.25)
  2979. String strSIPPackageName = "kr.co.icontrols.callengine.sip.CeresSIPService";
  2980. for (int k = 0; k < rsi.size(); k++) {
  2981. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  2982. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  2983. sip_result = "ok";
  2984. break;
  2985. }
  2986. }
  2987. 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";
  2988. }
  2989. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  2990. retXML = iCMDProcDevList(doc);
  2991. }
  2992. else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  2993. retXML = iCMDProcGASControl(elelist);
  2994. }
  2995. else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  2996. retXML = iCMDProcSDPSmartLightControl(doc);
  2997. }
  2998. else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  2999. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  3000. retXML = iCMDProc_I_LightControl(doc);
  3001. }
  3002. else {
  3003. retXML = iCMDProcLivingLightControl(doc);
  3004. }
  3005. }
  3006. else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3007. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I
  3008. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I) {
  3009. retXML = iCMDProcSDPConcentControl(doc);
  3010. }
  3011. else if (ModelType == MODEL_TYPE.IHN_1020GL) {
  3012. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3013. }
  3014. else {
  3015. retXML = iCMDProcMultiSWControl(doc);
  3016. }
  3017. }
  3018. else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3019. retXML = iCMDProcDoorlockControl(doc);
  3020. }
  3021. else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3022. retXML = iCMDProcTemperControl(doc);
  3023. }
  3024. else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3025. retXML = iCMDProcModeControl(doc);
  3026. }
  3027. else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3028. retXML = iCMDProcVentilControl(doc);
  3029. }
  3030. else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3031. retXML = iCMDProcCurtainControl(doc);
  3032. }
  3033. else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3034. if (ModelType == Version.MODEL_TYPE.IHN_1020GL) {
  3035. retXML = iCMDProcEnergyMeterLightControl(doc);
  3036. }
  3037. else {
  3038. retXML = iCMDProcLightControl(doc);
  3039. }
  3040. }
  3041. else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3042. retXML = iCMDProcLightBatchControl(elelist);
  3043. }
  3044. //모바일 사용자 인증 관련 메시지
  3045. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3046. ProcMobileDevice_AuthNumber(elelist);
  3047. }
  3048. else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3049. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3050. }
  3051. else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3052. ProcMobileDevice_Delete(elelist);
  3053. }
  3054. else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3055. retXML = ProcGetSmartKeyInfo(elelist);
  3056. }
  3057. else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3058. retXML = ProcGetAppVersionInfo();
  3059. }
  3060. else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3061. retXML = ProcIgateInitInfo(elelist);
  3062. }
  3063. else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3064. retXML = ProcElecCarChargeEventInfo(elelist);
  3065. }
  3066. else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3067. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3068. }
  3069. else if (cmd.equalsIgnoreCase("check_call_option")) {
  3070. retXML = ProcCheckCallOption();
  3071. }
  3072. else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3073. retXML = ProcChatSequence(elelist);
  3074. }
  3075. else if (cmd.equalsIgnoreCase("chat_message")) {
  3076. retXML = ProcChatMessage(elelist);
  3077. }
  3078. else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3079. retXML = ProcEvacuationLadderOpen(elelist);
  3080. }
  3081. else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3082. retXML = SmartLightDetailInfo(elelist);
  3083. }
  3084. else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3085. retXML = KNXDeviceDetailInfo(elelist);
  3086. }
  3087. else if( cmd.equalsIgnoreCase("set_server_version")) {
  3088. retXML = ProcSetServerChange(elelist);
  3089. }
  3090. else if( cmd.equalsIgnoreCase("remote_access_onepass")) {
  3091. retXML = iCMDProcOnePass(elelist);
  3092. }
  3093. else if( cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3094. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3095. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  3096. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3097. }
  3098. }
  3099. break;
  3100. }
  3101. }
  3102. if (retXML != null) {
  3103. imapsvrlog( "Socket write line\n"+retXML+"\r\n SO :"+iMAPSock.getSoLinger());
  3104. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3105. byte[] outBF = retXML.getBytes("euc-kr");
  3106. outstream.write(outBF);
  3107. outstream.flush();
  3108. try { Thread.sleep(3000);}
  3109. catch (RuntimeException re) {
  3110. LogUtil.errorLogInfo("", TAG, re);
  3111. }
  3112. catch (Exception e){
  3113. LogUtil.errorLogInfo("", TAG, e);
  3114. }
  3115. iMAPSock.close();
  3116. }
  3117. else {
  3118. try {iMAPSock.close();}
  3119. catch (RuntimeException re) {
  3120. LogUtil.errorLogInfo("", TAG, re);
  3121. }
  3122. catch (Exception e){
  3123. LogUtil.errorLogInfo("", TAG, e);
  3124. }
  3125. }
  3126. }
  3127. catch (RuntimeException re) {
  3128. LogUtil.errorLogInfo("", TAG, re);
  3129. }
  3130. catch (Exception e) {
  3131. try {iMAPSock.close();}
  3132. catch (RuntimeException re) {
  3133. LogUtil.errorLogInfo("", TAG, re);
  3134. }
  3135. catch (Exception E){
  3136. LogUtil.errorLogInfo("", TAG, E);
  3137. }
  3138. LogUtil.errorLogInfo("", TAG, e);
  3139. }
  3140. }
  3141. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3142. private void procUpgrade() {
  3143. imapsvrlog( "upgrade Start \n"+" "+WallPadiMAPUpgrade.active);
  3144. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3145. String[] getstate = sdb.GetSystemUpdateStatus();
  3146. sdb.closeDB();
  3147. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3148. for (int i = 0; i < getstate.length; i++) {
  3149. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3150. }
  3151. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3152. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3153. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3154. }
  3155. }
  3156. // " 제거
  3157. private String trimquotation(String sen) {
  3158. sen = sen.replaceAll("\"", "");
  3159. return sen.trim();
  3160. }
  3161. //remote_auscultate 처리
  3162. public String ProcauscultateReq(Document Doc) {
  3163. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3164. NodeList items = Doc.getElementsByTagName("group");
  3165. Node item;
  3166. String itemname=null;
  3167. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3168. SettManager.DeleteSettingData();
  3169. SettManager.DropTable();
  3170. try
  3171. {
  3172. for( int i = 0; i<items.getLength();i++)
  3173. {
  3174. item = items.item(i);
  3175. itemname = GetAttributeVal(item, "type");
  3176. String GetCNT = GetAttributeVal(item, "count");
  3177. if (Integer.parseInt(GetCNT)<=0)
  3178. continue;
  3179. Element SettingItem = (Element) item;
  3180. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3181. for(int j=0;j<SettingList.getLength();j++)
  3182. {
  3183. Node subdevListitem = SettingList.item(j);
  3184. String devname = trimquotation(subdevListitem.getTextContent());
  3185. SettManager.InsertSettingData(itemname, devname, j);
  3186. }
  3187. }
  3188. }
  3189. catch (RuntimeException re) {
  3190. LogUtil.errorLogInfo("", TAG, re);
  3191. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3192. SettManager.closeDB();
  3193. return RetVal;
  3194. }
  3195. catch (Exception e)
  3196. {
  3197. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3198. //e.printStackTrace();
  3199. LogUtil.errorLogInfo("", TAG, e);
  3200. SettManager.closeDB();
  3201. return RetVal;
  3202. }
  3203. SettManager.closeDB();
  3204. RetVal+="\"ok\" >\r\n </service>\r\n</imap>";
  3205. StatusBeatRequested = true;
  3206. Intent intent = new Intent();
  3207. intent.setAction(define.NOTIFY_ACNAME);
  3208. intent.putExtra(define.NOTIBR_KIND,define.NOTIFY_STARTSTATUSBEAT);
  3209. sendBroadcast(intent);
  3210. return RetVal;
  3211. }
  3212. public void DefaultProcauscultateReq(WallpadDevStatus SettManager)
  3213. {
  3214. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  3215. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n"+
  3216. "<service type=\"request\" name=\"remote_auscultate\">\r\n"+
  3217. " <guidemap devtype=\"homedev\" count=\"4\">\r\n"+
  3218. " <group type=\"ctrl_device\" count=\"5\">\r\n"+
  3219. " <unit>\"light\"</unit>\r\n"+
  3220. " <unit>\"thermostat\"</unit>\r\n"+
  3221. " <unit>\"gas\"</unit>\r\n"+
  3222. " <unit>\"doorlock\"</unit>\r\n"+
  3223. " <unit>\"ventil\"</unit>\r\n"+
  3224. " </group>\r\n"+
  3225. " <group type=\"talk_device\" count=\"4\">\r\n"+
  3226. " <unit>\"sub_homedev\"</unit>\r\n"+
  3227. " <unit>\"kitchen_tv\"</unit>\r\n"+
  3228. " <unit>\"bath_tv\"</unit>\r\n"+
  3229. " <unit>\"bath_phone\"</unit>\r\n"+
  3230. " </group>\r\n"+
  3231. " <group type=\"sensor\" count=\"6\">\r\n"+
  3232. " <unit>\"magnetic\"</unit>\r\n"+
  3233. " <unit>\"bugout\"</unit>\r\n"+
  3234. " <unit>\"bugin\"</unit>\r\n"+
  3235. " <unit>\"fire\"</unit>\r\n"+
  3236. " <unit>\"gas\"</unit>\r\n"+
  3237. " <unit>\"emergency\"</unit>\r\n"+
  3238. " </group>\r\n"+
  3239. " <group type=\"extended\" count=\"4\">\r\n"+
  3240. " <unit>\"gateway\"</unit>\r\n"+
  3241. " <unit>\"smartswitch\"</unit>\r\n"+
  3242. " <unit>\"handy\"</unit>\r\n"+
  3243. " <unit>\"energymeter\"</unit>\r\n"+
  3244. " </group>\r\n"+
  3245. " </guidemap>\r\n"+
  3246. "</service>\r\n"+
  3247. "</imap>\r\n";
  3248. try
  3249. {
  3250. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3251. DocumentBuilder builder = factory.newDocumentBuilder();
  3252. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3253. Document doc = builder.parse(istream);
  3254. NodeList items = doc.getElementsByTagName("group");
  3255. Node item;
  3256. String itemname=null;
  3257. SettManager.DeleteSettingData();
  3258. SettManager.DropTable();
  3259. for( int i = 0; i<items.getLength();i++)
  3260. {
  3261. item = items.item(i);
  3262. itemname = GetAttributeVal(item, "type");
  3263. String GetCNT = GetAttributeVal(item, "count");
  3264. if (Integer.parseInt(GetCNT)<=0)
  3265. continue;
  3266. Element SettingItem = (Element) item;
  3267. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3268. for(int j=0;j<SettingList.getLength();j++)
  3269. {
  3270. Node subdevListitem = SettingList.item(j);
  3271. String devname = trimquotation(subdevListitem.getTextContent());
  3272. SettManager.InsertSettingData(itemname, devname, j);
  3273. }
  3274. }
  3275. }
  3276. catch (RuntimeException re) {
  3277. LogUtil.errorLogInfo("", TAG, re);
  3278. }
  3279. catch (Exception e)
  3280. {
  3281. //e.printStackTrace();
  3282. LogUtil.errorLogInfo("", TAG, e);
  3283. }
  3284. }
  3285. String MakeFailMessage(String msg)
  3286. {
  3287. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\""+msg+"\"</first_failed>\r\n</service>\r\n</imap>";
  3288. }
  3289. //SetInfo의 각 항목들의 무결성 확인
  3290. final String isUse = "사용함";
  3291. final String isNotUse = "사용안함";
  3292. boolean CheckSubdevData(String devName, String devData) {
  3293. String[] SplitedMSG;
  3294. try {
  3295. if (devName.equals("가스밸브")) {
  3296. SplitedMSG = devData.split("[(]");
  3297. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3298. String UseStr = SplitedMSG[2].split("[)]")[0];
  3299. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3300. }
  3301. else if (devName.equals("디지털도어락")) {
  3302. SplitedMSG = devData.split("[(]");
  3303. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3304. String[] UseStr = SplitedMSG[2].split("[)]");
  3305. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3306. if (!UseStr[1].equals("종류")) return false;
  3307. UseStr = SplitedMSG[3].split("[)]");
  3308. if (!UseStr[0].equals("무선")&&!UseStr[0].equals("유선")) return false;
  3309. }
  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. }
  3316. else if (devName.equals("조명제어기")) {
  3317. SplitedMSG = devData.split("[(]");
  3318. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3319. String[] UseStr = SplitedMSG[2].split("[)]");
  3320. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3321. /*
  3322. if (!UseStr[1].equals("종류"))
  3323. return false;
  3324. UseStr = SplitedMSG[3].split("[)]");
  3325. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3326. return false;
  3327. */
  3328. }
  3329. else if (devName.equals("환기시스템")) {
  3330. SplitedMSG = devData.split("[(]");
  3331. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3332. String[] UseStr = SplitedMSG[2].split("[)]");
  3333. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3334. /*
  3335. if (!UseStr[1].equals("종류"))
  3336. return false;
  3337. UseStr = SplitedMSG[3].split("[)]");
  3338. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  3339. return false;
  3340. */
  3341. }
  3342. else if (devName.equals("시스템에어컨")) {
  3343. SplitedMSG = devData.split("[(]");
  3344. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3345. String[] UseStr = SplitedMSG[2].split("[)]");
  3346. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3347. }
  3348. else if (devName.equals("전동커튼")) {
  3349. SplitedMSG = devData.split("[(]");
  3350. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3351. String[] UseStr = SplitedMSG[2].split("[)]");
  3352. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3353. /*
  3354. if (!UseStr[1].equals("종류"))
  3355. return false;
  3356. UseStr = SplitedMSG[3].split("[)]");
  3357. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  3358. return false;
  3359. */
  3360. }
  3361. else if (devName.equals("실시간검침기")) {
  3362. SplitedMSG = devData.split("[(]");
  3363. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3364. String[] UseStr = SplitedMSG[2].split("[)]");
  3365. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3366. }
  3367. else if (devName.equals("스마트스위치&일괄소등")) {
  3368. SplitedMSG = devData.split("[(]");
  3369. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3370. String[] UseStr = SplitedMSG[2].split("[)]");
  3371. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3372. /*
  3373. if (!UseStr[1].equals("종류"))
  3374. return false;
  3375. UseStr = SplitedMSG[3].split("[)]");
  3376. if (!UseStr[0].equals("대외향스마트스위치")&&
  3377. !UseStr[0].equals("대외향일괄소등제어기")&&
  3378. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  3379. !UseStr[0].equals("현산향스마트스위치")&&
  3380. !UseStr[0].equals("현산향LCD스마트스위치"))
  3381. return false;
  3382. */
  3383. }
  3384. else if (devName.equals("무선리모컨")) {
  3385. SplitedMSG = devData.split("[(]");
  3386. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3387. String[] UseStr = SplitedMSG[2].split("[)]");
  3388. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3389. }
  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. }
  3403. else if (devName.equals("공지사항")) {
  3404. SplitedMSG = devData.split("[(]");
  3405. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3406. String[] UseStr = SplitedMSG[2].split("[)]");
  3407. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3408. }
  3409. else if (devName.equals("날씨")) {
  3410. SplitedMSG = devData.split("[(]");
  3411. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3412. String[] UseStr = SplitedMSG[2].split("[)]");
  3413. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3414. }
  3415. else if (devName.equals("메모")) {
  3416. SplitedMSG = devData.split("[(]");
  3417. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3418. String[] UseStr = SplitedMSG[2].split("[)]");
  3419. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3420. }
  3421. else if (devName.equals("전자액자")) {
  3422. SplitedMSG = devData.split("[(]");
  3423. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3424. String[] UseStr = SplitedMSG[2].split("[)]");
  3425. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3426. }
  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. else if (devName.equals("주차확인")) {
  3434. SplitedMSG = devData.split("[(]");
  3435. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3436. String[] UseStr = SplitedMSG[2].split("[)]");
  3437. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3438. /*
  3439. UseStr = SplitedMSG[3].split("[)]");
  3440. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3441. return false;
  3442. */
  3443. }
  3444. else if (devName.equals("시간설정")) {
  3445. SplitedMSG = devData.split("[(]");
  3446. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3447. String[] UseStr = SplitedMSG[2].split("[)]");
  3448. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3449. }
  3450. else if (devName.equals("원격검침")) {
  3451. SplitedMSG = devData.split("[(]");
  3452. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3453. String[] UseStr = SplitedMSG[2].split("[)]");
  3454. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3455. }
  3456. else if (devName.equals("뮤직")) {
  3457. SplitedMSG = devData.split("[(]");
  3458. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3459. String[] UseStr = SplitedMSG[2].split("[)]");
  3460. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3461. }
  3462. else if (devName.equals("영상재생")) {
  3463. SplitedMSG = devData.split("[(]");
  3464. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3465. String[] UseStr = SplitedMSG[2].split("[)]");
  3466. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3467. }
  3468. else if (devName.equals("CCTV")) {
  3469. SplitedMSG = devData.split("[(]");
  3470. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3471. String[] UseStr = SplitedMSG[2].split("[)]");
  3472. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3473. /*
  3474. UseStr = SplitedMSG[3].split("[)]");
  3475. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3476. return false;
  3477. */
  3478. }
  3479. else if (devName.equals("명칭설정")) {
  3480. SplitedMSG = devData.split("[(]");
  3481. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3482. String[] UseStr = SplitedMSG[2].split("[)]");
  3483. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3484. }
  3485. else if (devName.equals("출동경비")) {
  3486. SplitedMSG = devData.split("[(]");
  3487. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3488. String[] UseStr = SplitedMSG[2].split("[)]");
  3489. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3490. }
  3491. else if (devName.equals("경비실영상통화")) {
  3492. SplitedMSG = devData.split("[(]");
  3493. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3494. String[] UseStr = SplitedMSG[2].split("[)]");
  3495. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3496. }
  3497. else if (devName.equals("엘리베이터")) {
  3498. SplitedMSG = devData.split("[(]");
  3499. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3500. String[] UseStr = SplitedMSG[2].split("[)]");
  3501. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3502. /*
  3503. UseStr = SplitedMSG[3].split("[)]");
  3504. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3505. return false;
  3506. */
  3507. }
  3508. else if (devName.equals("현장특화기능")) {
  3509. SplitedMSG = devData.split("[(]");
  3510. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3511. String[] UseStr = SplitedMSG[2].split("[)]");
  3512. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3513. /*
  3514. UseStr = SplitedMSG[3].split("[)]");
  3515. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3516. return false;
  3517. */
  3518. }
  3519. else if (devName.equals("월패드카메라")) {
  3520. SplitedMSG = devData.split("[(]");
  3521. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3522. String[] UseStr = SplitedMSG[2].split("[)]");
  3523. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3524. }
  3525. else if (devName.equals("무드등")) {
  3526. SplitedMSG = devData.split("[(]");
  3527. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3528. String[] UseStr = SplitedMSG[2].split("[)]");
  3529. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3530. /*
  3531. UseStr = SplitedMSG[3].split("[)]");
  3532. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3533. return false;
  3534. */
  3535. }
  3536. else if (devName.equals("피난사다리")) {
  3537. SplitedMSG = devData.split("[(]");
  3538. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3539. String[] UseStr = SplitedMSG[2].split("[)]");
  3540. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3541. }
  3542. else if (devName.equals("동체설정")) {
  3543. return true;
  3544. /*
  3545. SplitedMSG = devData.split("[(]");
  3546. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3547. return false;
  3548. String[] UseStr = SplitedMSG[2].split("[)]");
  3549. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3550. return false;
  3551. if (UseStr[0].equals(isNotUse)) return true;
  3552. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3553. return false;
  3554. for (int i=3; i < SplitedMSG.length; i++)
  3555. {
  3556. UseStr = SplitedMSG[i].split("[)]");
  3557. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3558. return false;
  3559. if (i != SplitedMSG.length-1)
  3560. {
  3561. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3562. return false;
  3563. }
  3564. }
  3565. */
  3566. }
  3567. else if (devName.equals("알람발생")) {
  3568. SplitedMSG = devData.split("[(]");
  3569. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3570. String[] UseStr = SplitedMSG[2].split("[)]");
  3571. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3572. }
  3573. else {
  3574. Log.w("iMAP", "No Such Name, Set Setup devName ="+ devName + ", devData ="+devData);
  3575. Log.w("iMAP", "Return true");
  3576. return true;
  3577. }
  3578. }
  3579. catch (RuntimeException re) {
  3580. LogUtil.errorLogInfo("", TAG, re);
  3581. return false;
  3582. }
  3583. catch (Exception e)
  3584. {
  3585. //e.printStackTrace();
  3586. LogUtil.errorLogInfo("", TAG, e);
  3587. return false;
  3588. }
  3589. return true;
  3590. }
  3591. public String ProcSetsetup(Document ele) {
  3592. Common.DebugLog("ProcSetsetup------------------------->");
  3593. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3594. NodeList items = ele.getElementsByTagName("setting");
  3595. Node item;
  3596. String itemname=null;
  3597. String dateData=null;
  3598. String heartbeatP=null;
  3599. String Versions = null;
  3600. String SdbAccInit_Str = null;
  3601. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3602. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3603. if (!SettManager.StartTransaction()) {
  3604. ResetFlag = false;
  3605. RetVal+="\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3606. SettManager.EndTransaction(false);
  3607. SettManager.closeDB();
  3608. return RetVal;
  3609. }
  3610. try {
  3611. for (int i = 0; i < items.getLength(); i++) {
  3612. item = items.item(i);
  3613. itemname = GetAttributeVal(item, "name");
  3614. if(itemname!=null)
  3615. {
  3616. if (itemname.equals("beat_time")) {
  3617. heartbeatP = GetAttributeVal(item, "value");
  3618. }
  3619. else if (itemname.equals("ver_setting")) {
  3620. Versions = GetAttributeVal(item, "value");
  3621. }
  3622. else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3623. Element guardlist = (Element) item;
  3624. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3625. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3626. else continue;
  3627. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3628. Node GuardListitem = GuardCTList.item(j);
  3629. String guardname = GetAttributeVal(GuardListitem, "name");
  3630. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3631. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3632. }
  3633. }
  3634. else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3635. Element subdevList = (Element) item;
  3636. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3637. for (int j = 0; j < SubDevList.getLength(); j++) {
  3638. Node subdevListitem = SubDevList.item(j);
  3639. String devname = GetAttributeVal(subdevListitem, "name");
  3640. String devval = GetAttributeVal(subdevListitem, "value");
  3641. if(devname!=null && devval!=null)
  3642. {
  3643. devname = devname.replaceAll("\\p{Z}", "");
  3644. devval = devval.replaceAll("\\p{Z}", "");
  3645. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  3646. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3647. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3648. }
  3649. if (CheckSubdevData(devname, devval)==false) {
  3650. ResetFlag = false;
  3651. Log.w("iMAP", "Set Setup Fail name : "+devname+ " Value : "+devval );
  3652. SettManager.EndTransaction(false);
  3653. SettManager.closeDB();
  3654. return MakeFailMessage(devname);
  3655. }
  3656. String[] SettingDBValue = SettManager.GetSettingData(devname);
  3657. if (SettingDBValue != null) {
  3658. String devInfo = SettingDBValue[1];
  3659. if (devInfo.equals(devval) == false) {
  3660. Log.w("iMAP", "Set Setup(imap) Name : "+devname+ " Value : "+devval );
  3661. Log.w("iMAP", "DB Setup Value : "+devInfo);
  3662. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3663. ResetFlag = true;
  3664. }
  3665. }
  3666. else {
  3667. Log.w("iMAP", "DB No Setup Name and Value");
  3668. Log.w("iMAP", "Set Setup(imap) Name : "+devname+ " Value : "+devval );
  3669. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3670. ResetFlag = true;
  3671. }
  3672. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3673. if (devname.equals("로고설정")) {
  3674. String devInfo = devval;
  3675. devInfo = devInfo.replace('(', '_');
  3676. devInfo = devInfo.replace(':', '_');
  3677. devInfo = devInfo.replace(')', '_');
  3678. String[] DetailInfo = devInfo.split("_");
  3679. int LogoType = 0;
  3680. if (DetailInfo[5].equals("표시안함") == true) {
  3681. LogoType = 0;
  3682. }
  3683. else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3684. LogoType = 1;
  3685. }
  3686. else if (DetailInfo[5].equals("양우내안애") == true) {
  3687. LogoType = 2;
  3688. }
  3689. else if (DetailInfo[5].equals("GSITM") == true) {
  3690. LogoType = 3;
  3691. }
  3692. else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3693. LogoType = 4;
  3694. }
  3695. else if (DetailInfo[5].equals("거실조명표시") == true) {
  3696. LogoType = 5;
  3697. }
  3698. else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3699. LogoType = 6;
  3700. }
  3701. else if (DetailInfo[5].equals("기타1") == true) {
  3702. LogoType = 7;
  3703. }
  3704. else if (DetailInfo[5].equals("기타2") == true) {
  3705. LogoType = 8;
  3706. }
  3707. if ((LogoType >= 0) && (LogoType <= 8)) {
  3708. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3709. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3710. }
  3711. }
  3712. else if (devname.equals("엘리베이터위젯복구")) {
  3713. String devInfo = devval;
  3714. devInfo = devInfo.replace('(', '_');
  3715. devInfo = devInfo.replace(':', '_');
  3716. devInfo = devInfo.replace(')', '_');
  3717. String[] DetailInfo = devInfo.split("_");
  3718. if (DetailInfo[3].equals("사용함") == true) {
  3719. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3720. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3721. }
  3722. }
  3723. else if (devname.equals("분전반알람설정")) {
  3724. try {
  3725. String devInfo = devval;
  3726. devInfo = devInfo.replace('(', '_');
  3727. devInfo = devInfo.replace(':', '_');
  3728. devInfo = devInfo.replace(')', '_');
  3729. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3730. //[0] - 기기번호
  3731. //[1] - 회로수
  3732. //[2] - 기기이름
  3733. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3734. //[4] - 명칭
  3735. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3736. String[] DetailInfo = devInfo.split("_");
  3737. for (int a = 0; a < DetailInfo.length; a++) {
  3738. if (DetailInfo[a].equals("누적전력초기화")) {
  3739. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3740. if ((a+1) <= DetailInfo.length) {
  3741. // 설정정보가 존재해야 인식하도록 함
  3742. if (DetailInfo[a+1].equals("1")) {
  3743. // 1(사용함) 일때
  3744. if (sdbAPI != null) {
  3745. if (sdbAPI.Set_AccPwReset() >= 0) {
  3746. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3747. }
  3748. else {
  3749. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3750. }
  3751. }
  3752. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3753. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3754. }
  3755. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3756. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3757. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3758. }
  3759. }
  3760. }
  3761. } catch (RuntimeException re) {
  3762. LogUtil.errorLogInfo("", TAG, re);
  3763. }
  3764. catch (Exception e) {
  3765. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3766. //e.printStackTrace();
  3767. LogUtil.errorLogInfo("", TAG, e);
  3768. }
  3769. }
  3770. else if (devname.equals("욕실폰통화음량값")) {
  3771. Intent Iintent = new Intent();
  3772. Iintent.setAction(define.NOTIFY_ACNAME);
  3773. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3774. sendBroadcast(Iintent);
  3775. }
  3776. else if (devname.equals("주방TV통화음량값")) {
  3777. Intent Iintent = new Intent();
  3778. Iintent.setAction(define.NOTIFY_ACNAME);
  3779. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3780. sendBroadcast(Iintent);
  3781. }
  3782. else if (devname.equals("현관카메라")) {
  3783. if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3784. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3785. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I)
  3786. {
  3787. String devInfo = devval;
  3788. if(devInfo!=null)
  3789. {
  3790. devInfo = devInfo.replace('(', '_');
  3791. devInfo = devInfo.replace(':', '_');
  3792. devInfo = devInfo.replace(')', '_');
  3793. String[] DetailInfo = devInfo.split("_");
  3794. if (DetailInfo!=null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3795. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  3796. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3797. if(mIOInterface!=null) mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3798. } else {
  3799. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  3800. if(mIOInterface!=null) mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3801. }
  3802. }
  3803. }
  3804. }
  3805. }
  3806. else if (devname.equals("거동수상자녹화")) {
  3807. String devInfo = devval;
  3808. devInfo = devInfo.replace('(', '_');
  3809. devInfo = devInfo.replace(':', '_');
  3810. devInfo = devInfo.replace(')', '_');
  3811. String[] DetailInfo = devInfo.split("_");
  3812. // for (int k = 0; k < DetailInfo.length; k++) {
  3813. // Log.e(TAG, "[ProcSetsetup] DetailInfo[" + k + "] -> " + DetailInfo[k]);
  3814. // }
  3815. if (devname.equalsIgnoreCase(DetailInfo[2])) {
  3816. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3817. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  3818. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  3819. }
  3820. else {
  3821. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  3822. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  3823. }
  3824. }
  3825. }
  3826. else if (devname.equals("스마트현관카메라좌우반전")) {
  3827. String devInfo = devval;
  3828. if(devInfo!=null)
  3829. {
  3830. devInfo = devInfo.replace('(', '_');
  3831. devInfo = devInfo.replace(':', '_');
  3832. devInfo = devInfo.replace(')', '_');
  3833. }
  3834. String[] DetailInfo = devInfo.split("_");
  3835. if (DetailInfo!=null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3836. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3837. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  3838. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  3839. } else {
  3840. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3841. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3842. }
  3843. }
  3844. }
  3845. else {
  3846. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3847. }
  3848. }
  3849. }
  3850. }
  3851. else if (itemname.equals("datetime")) {
  3852. dateData = GetAttributeVal(item, "value");
  3853. }
  3854. else {
  3855. String GetVal = GetAttributeVal(item, "value");
  3856. if(GetVal!=null)
  3857. {
  3858. if (!GetVal.equals("list")) {
  3859. if (itemname.equals("site_code")) {
  3860. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3861. if (Existing_SiteCode_Array == null) {
  3862. ResetFlag = true;
  3863. }
  3864. else {
  3865. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3866. if (GetVal!=null && GetVal.equals(Existing_SiteCode) == false) {
  3867. ResetFlag = true;
  3868. }
  3869. }
  3870. }
  3871. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3872. }
  3873. else {
  3874. String GetCNT = GetAttributeVal(item, "count");
  3875. if (Integer.parseInt(GetCNT)<=0) continue;
  3876. Element SettingItem = (Element) item;
  3877. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3878. for (int j = 0; j < SettingList.getLength(); j++) {
  3879. Node subdevListitem = SettingList.item(j);
  3880. String devname = GetAttributeVal(subdevListitem, "name");
  3881. String devval = GetAttributeVal(subdevListitem, "value");
  3882. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3883. }
  3884. }
  3885. }
  3886. }
  3887. }
  3888. }
  3889. } catch (RuntimeException re) {
  3890. LogUtil.errorLogInfo("", TAG, re);
  3891. ResetFlag = false;
  3892. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3893. SettManager.EndTransaction(false);
  3894. SettManager.closeDB();
  3895. return RetVal;
  3896. }
  3897. catch (Exception e) {
  3898. ResetFlag = false;
  3899. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3900. //e.printStackTrace();
  3901. LogUtil.errorLogInfo("", TAG, e);
  3902. SettManager.EndTransaction(false);
  3903. SettManager.closeDB();
  3904. return RetVal;
  3905. }
  3906. SettManager.EndTransaction(true);
  3907. SettManager.closeDB();
  3908. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3909. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3910. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3911. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3912. }
  3913. if (AfterTransactionTodoList != null) {
  3914. if (AfterTransactionTodoList.size() > 0) {
  3915. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3916. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3917. if (afterTransactionTodoListData != null) {
  3918. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3919. WallpadSalesSampleData mWallpadSalesSampleData;
  3920. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3921. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3922. mWallpadSalesSampleData.closeDB();
  3923. }
  3924. else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3925. //ifdb에 있는지
  3926. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3927. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3928. int result = devSet.Get_Elevator_Info();
  3929. devSet.closeDB();
  3930. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3931. // 엘리베이터가 사용함이면
  3932. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3933. boolean result_get_restoreUseOrNot;
  3934. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3935. if (wdb != null) {
  3936. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3937. if (result_get_restoreUseOrNot == false) {
  3938. wdb.SetElevator_Widget_Restore(true);
  3939. //위젯 DB 초기화
  3940. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3941. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3942. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3943. devSet2.initWidgetData();
  3944. devSet2.closeDB();
  3945. }
  3946. }
  3947. wdb.closeDB();
  3948. }
  3949. }
  3950. }
  3951. }
  3952. }
  3953. }
  3954. }
  3955. if (dateData!=null) {
  3956. try {
  3957. int year = Integer.parseInt(dateData.substring(0,4));
  3958. int month = Integer.parseInt(dateData.substring(4,6));
  3959. int day = Integer.parseInt(dateData.substring(6,8));
  3960. int hour = Integer.parseInt(dateData.substring(8,10));
  3961. int min = Integer.parseInt(dateData.substring(10,12));
  3962. int sec = Integer.parseInt(dateData.substring(12,14));
  3963. Calendar nowdate = new GregorianCalendar();
  3964. long settedtime = nowdate.getTimeInMillis();
  3965. nowdate.set(Calendar.YEAR, year);
  3966. nowdate.set(Calendar.MONTH, month);
  3967. nowdate.set(Calendar.DAY_OF_MONTH, day);
  3968. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  3969. nowdate.set(Calendar.MINUTE, min);
  3970. nowdate.set(Calendar.SECOND, sec);
  3971. long bootupmil = nowdate.getTimeInMillis();
  3972. if (Math.abs(bootupmil-settedtime) > 5000) {
  3973. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3974. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  3975. DBMGR.closeDB();
  3976. Intent Iintent = new Intent();
  3977. Iintent.setAction(define.NOTIFY_ACNAME);
  3978. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  3979. sendBroadcast(Iintent);
  3980. }
  3981. } catch (RuntimeException re) {
  3982. LogUtil.errorLogInfo("", TAG, re);
  3983. }
  3984. catch (Exception e) {
  3985. //e.printStackTrace();
  3986. LogUtil.errorLogInfo("", TAG, e);
  3987. }
  3988. }
  3989. if (heartbeatP != null) {
  3990. try {
  3991. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3992. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  3993. DBMGR.closeDB();
  3994. } catch (RuntimeException re) {
  3995. LogUtil.errorLogInfo("", TAG, re);
  3996. RetVal +="\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3997. SettManager.closeDB();
  3998. return RetVal;
  3999. }
  4000. catch (Exception e) {
  4001. //e.printStackTrace();
  4002. LogUtil.errorLogInfo("", TAG, e);
  4003. RetVal +="\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  4004. SettManager.closeDB();
  4005. return RetVal;
  4006. }
  4007. }
  4008. if (Versions != null) {
  4009. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4010. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  4011. DBMGR.SetSettingVer(Versions);
  4012. DBMGR.closeDB();
  4013. }
  4014. Intent intent = new Intent();
  4015. intent.setAction(define.NOTIFY_ACNAME);
  4016. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  4017. getApplicationContext().sendBroadcast(intent);
  4018. RetVal+="\"ok\" >\r\n </service>\r\n</imap>";
  4019. return RetVal;
  4020. }
  4021. public String ProcNotifyparcel(Document doc) {
  4022. NodeList param = doc.getElementsByTagName("move_info");
  4023. Node item = param.item(0);
  4024. String aa = item.getTextContent();
  4025. aa = trimquotation(aa);
  4026. param = doc.getElementsByTagName("params");
  4027. item = param.item(0);
  4028. if (item != null) {
  4029. String devname = GetAttributeVal(item, "message");
  4030. if (devname != null) {
  4031. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4032. if (msgList[0].equalsIgnoreCase("remains")) {
  4033. int itemCount = Integer.parseInt(msgList[1]);
  4034. if (itemCount > 0) {
  4035. wakeupLCD();
  4036. Intent intent = new Intent();
  4037. intent.setAction(define.NOTIFY_ACNAME);
  4038. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  4039. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4040. intent.putExtra("ITEM",itemCount);
  4041. getApplicationContext().sendBroadcast(intent);
  4042. }
  4043. }
  4044. }
  4045. }
  4046. String retVal = XMLHeader +
  4047. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n"+
  4048. "</imap>\r\n";
  4049. return retVal;
  4050. }
  4051. public String ProcNotiPostInfo(Document doc) {
  4052. NodeList param = doc.getElementsByTagName("move_info");
  4053. Node item = param.item(0);
  4054. String aa = item.getTextContent();
  4055. aa = trimquotation(aa);
  4056. if (item != null) {
  4057. String info = item.getTextContent();
  4058. if (info != null) {
  4059. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4060. if (info.contains("post_in")) { // 우편물 보관
  4061. wakeupLCD();
  4062. int itemCount = -1;
  4063. param = doc.getElementsByTagName("params");
  4064. item = param.item(0);
  4065. if (item != null) {
  4066. String devname = GetAttributeVal(item, "message");
  4067. if (devname != null) {
  4068. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4069. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4070. if (msgList[0].equalsIgnoreCase("remains")) {
  4071. itemCount = Integer.parseInt(msgList[1]);
  4072. }
  4073. }
  4074. }
  4075. }
  4076. if (itemCount > 0) {
  4077. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4078. Intent intent = new Intent();
  4079. intent.setAction(define.NOTIFY_ACNAME);
  4080. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4081. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4082. intent.putExtra("ITEM", itemCount);
  4083. getApplicationContext().sendBroadcast(intent);
  4084. }
  4085. }
  4086. }
  4087. }
  4088. String retVal = XMLHeader +
  4089. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n"+
  4090. "</imap>\r\n";
  4091. return retVal;
  4092. }
  4093. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4094. public String ProcNotifypark(Document doc)
  4095. {
  4096. String MoveInfo = "none";
  4097. NodeList param = doc.getElementsByTagName("destination");
  4098. Node item = param.item(0);
  4099. if (item != null)
  4100. {
  4101. String dong = GetAttributeVal(item, "id_high").trim();
  4102. String ho = GetAttributeVal(item, "id_low").trim();
  4103. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4104. return (XMLHeader +
  4105. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4106. "</imap>\r\n");
  4107. }
  4108. param = doc.getElementsByTagName("move_info");
  4109. item = param.item(0);
  4110. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4111. param = doc.getElementsByTagName("params");
  4112. item = param.item(0);
  4113. if (item != null)
  4114. {
  4115. String carnum = GetAttributeVal(item, "car_num");
  4116. String locinfo = GetAttributeVal(item, "loc_info");
  4117. String msg = GetAttributeVal(item, "message");
  4118. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4119. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4120. parkdb.closeDB();Intent intent = new Intent();
  4121. intent.setAction(define.NOTIFY_ACNAME);
  4122. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4123. getApplicationContext().sendBroadcast(intent);
  4124. }
  4125. String retVal = XMLHeader +
  4126. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4127. "</imap>\r\n";
  4128. return retVal;
  4129. }
  4130. */
  4131. public String ProcGetsetup(Document doc) {
  4132. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4133. NodeList items = doc.getElementsByTagName("variable");
  4134. String RetVal = XMLHeader+"<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n"+
  4135. " <guidemap devtype=\"homedev\" count=\""+items.getLength()+"\">\r\n";
  4136. Node item;
  4137. try {
  4138. for (int i = 0; i < items.getLength(); i++) {
  4139. item = items.item(i);
  4140. //String mRealTimeMeterData = item.getNodeValue();
  4141. String data = trimquotation(item.getTextContent());
  4142. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4143. if (gData.size() == 1) {
  4144. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+gData.get(0)[1]+"\" />\r\n";
  4145. }
  4146. else if (gData.size() > 1) {
  4147. RetVal+=" <setting name=\""+data+"\" count=\""+gData.size()+"\" value=\"list\" >\r\n";
  4148. RetVal+=" <list name=\"DeviceInfo\" value=\""+ Build.MODEL + "/" + getAOSVerCode() +"\" />\r\n";
  4149. for (int k = 0 ; k <gData.size();k++) {
  4150. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4151. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4152. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4153. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4154. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4155. }
  4156. RetVal+=" <list name=\""+gData.get(k)[0]+"\" value=\""+gData.get(k)[1]+"\" />\r\n";
  4157. }
  4158. if (bAirQualityEnable) {
  4159. RetVal+=" <list name=\"공기질센서버전\" value=\""+ getAirQualityInfo() +"\" />\r\n";
  4160. }
  4161. RetVal+=" </setting>\r\n";
  4162. }
  4163. else {
  4164. if (data.equals("beat_time")) {
  4165. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4166. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4167. DBMGR.closeDB();
  4168. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+heartbeatP+"\" />\r\n";
  4169. }
  4170. else if (data.equals("ver_setting")) {
  4171. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4172. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+DBMGR.GetSettingVer()+"\" />\r\n";
  4173. DBMGR.closeDB();
  4174. }
  4175. else if (data.equals("datetime")) {
  4176. Calendar cal = new GregorianCalendar();
  4177. 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";
  4178. }
  4179. else if (data.equals("security_state")) {
  4180. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4181. int alarmST = DBMGR.GetAlarmStatus();
  4182. String SEC_ST;
  4183. if (alarmST == WallpadStatusData.GUARD_OUT ) SEC_ST = "out";
  4184. else if (alarmST == WallpadStatusData.GUARD_IN ) SEC_ST = "in";
  4185. else SEC_ST = "normal";
  4186. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+SEC_ST+"\" />\r\n";
  4187. DBMGR.closeDB();
  4188. }
  4189. else if (data.equals("sensor_state")) {
  4190. int senIDX = 0;
  4191. String resultStr = "";
  4192. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4193. int BugSensor = DBMGR.Get_Sensor_Set();
  4194. WallPadInterface wpifc = new WallPadInterface();
  4195. if (BugSensor > 0) {
  4196. if ((BugSensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4197. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4198. String Senret;
  4199. if (outSen>0) Senret = "detect";
  4200. else Senret = "undetect";
  4201. resultStr+=" <list name=\"in_move\" count=\"0\" value=\""+Senret+"\" />\r\n";
  4202. senIDX++;
  4203. }
  4204. else {
  4205. if ((BugSensor&WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4206. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4207. String Senret;
  4208. if (outSen>0) Senret = "detect";
  4209. else Senret = "undetect";
  4210. resultStr+=" <list name=\"in_move\" value=\""+Senret+"\" />\r\n";
  4211. senIDX++;
  4212. }
  4213. if ((BugSensor&WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4214. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4215. String Senret;
  4216. if (outSen>0) Senret = "detect";
  4217. else Senret = "undetect";
  4218. resultStr+=" <list name=\"out_move\" value=\""+Senret+"\" />\r\n";
  4219. senIDX++;
  4220. }
  4221. }
  4222. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4223. String Senret;
  4224. if (outSen>0) Senret = "detect";
  4225. else Senret = "undetect";
  4226. resultStr+=" <list name=\"magnetic\" value=\""+Senret+"\" />\r\n";
  4227. senIDX++;
  4228. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4229. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4230. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4231. if (outSen>0) Senret = "detect";
  4232. else Senret = "undetect";
  4233. resultStr+=" <list name=\"emergency\" value=\""+Senret+"\" />\r\n";
  4234. senIDX++;
  4235. }
  4236. DBMGR.closeDB();
  4237. }
  4238. if (senIDX > 0) {
  4239. RetVal += " <setting name = \"sensor_state\" count = \""+senIDX+"\" value = \"list\" >\r\n";
  4240. RetVal += resultStr;
  4241. RetVal += " </setting>\r\n";
  4242. }
  4243. }
  4244. else if (data.equals("statusbeat_time")) {
  4245. }
  4246. else {
  4247. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\"\" />\r\n";
  4248. }
  4249. }
  4250. }
  4251. } catch (RuntimeException re) {
  4252. LogUtil.errorLogInfo("", TAG, re);
  4253. }
  4254. catch (Exception e) {
  4255. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4256. //e.printStackTrace();
  4257. LogUtil.errorLogInfo("", TAG, e);
  4258. }
  4259. SettManager.closeDB();
  4260. RetVal+=" </guidemap>\r\n </service>\r\n</imap>";
  4261. return RetVal;
  4262. }
  4263. public void ProcElevatorinfo(Element ele) {
  4264. try {
  4265. String floor;
  4266. String move_dir;
  4267. /*
  4268. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4269. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4270. Node info = evinfo.item(0);
  4271. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4272. if (info != null)
  4273. {
  4274. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4275. }
  4276. */
  4277. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4278. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength() );
  4279. Node iinfo = ievinfo.item(0);
  4280. if (iinfo == null) {
  4281. Log.d("iMapServer" , "func ProcElevatorinfo info == null");
  4282. return;
  4283. }
  4284. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4285. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4286. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4287. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4288. if(move_dir!=null)
  4289. {
  4290. if (move_dir.equalsIgnoreCase("up")) {
  4291. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4292. }
  4293. else if (move_dir.equalsIgnoreCase("down")) {
  4294. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4295. }
  4296. else if (move_dir.equalsIgnoreCase("stop")) {
  4297. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4298. }
  4299. else if (move_dir.equalsIgnoreCase("wrong")) {
  4300. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4301. }
  4302. else if (move_dir.equalsIgnoreCase("finish")) {
  4303. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4304. }
  4305. Log.d("iMapServer" , "MoveDirForIntent: "+MoveDirForIntent);
  4306. }
  4307. byte updown = 0x00;
  4308. if (ievinfo != null) {
  4309. boolean downCall = false;
  4310. boolean upCall = false;
  4311. for (int i = 0; i < ievinfo.getLength(); i++ ) {
  4312. Node valItem = ievinfo.item(i);
  4313. if (valItem != null) {
  4314. if (downCall == false)
  4315. {
  4316. String val =GetAttributeVal(valItem, "ev_call_dir");
  4317. if(val!=null)
  4318. downCall = val.equalsIgnoreCase("down");
  4319. }
  4320. if (upCall == false) {
  4321. String val = GetAttributeVal(valItem, "ev_call_dir");
  4322. if(val!=null)
  4323. {
  4324. upCall = val.equalsIgnoreCase("up");
  4325. }
  4326. }
  4327. }
  4328. }
  4329. Log.d("iMapServer" , "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall );
  4330. if (downCall == true && upCall == true) updown = 0x02;
  4331. else if (downCall == false && upCall == true) updown = 0x01;
  4332. }
  4333. Log.d(TAG , "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  4334. Intent intent = new Intent();
  4335. intent.setAction(define.NOTIFY_ACNAME);
  4336. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  4337. intent.putExtra(define.NOTIBR_FLOOR, floor);
  4338. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  4339. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  4340. getApplicationContext().sendBroadcast(intent);
  4341. } catch (RuntimeException re) {
  4342. LogUtil.errorLogInfo("", TAG, re);
  4343. }
  4344. catch (Exception e) {
  4345. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  4346. //e.printStackTrace();
  4347. LogUtil.errorLogInfo("", TAG, e);
  4348. }
  4349. }
  4350. private String MakeTargetStr(WallpadiCMDParser data) {
  4351. return " <target name=\""+data.target+"\" id = \""+data.tid+"\" msg_no=\""+data.msgno+"\"/>\r\n";
  4352. }
  4353. public String iCMDProcVentilControl(Document doc) {
  4354. try {
  4355. String unit_status = "null", mode = "null", unit_mode = "null";
  4356. String retStr = CheckiCMDProc("remote_access_ventil");
  4357. if (retStr != null) return retStr;
  4358. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  4359. String target= "null", tid= "null", msgno= "null";
  4360. NodeList items = doc.getElementsByTagName("target");
  4361. Node item = items.item(0);
  4362. if (item != null) {
  4363. NamedNodeMap attrs = item.getAttributes();
  4364. for (int j = 0; j< attrs.getLength(); j++) {
  4365. Node attr = attrs.item(j);
  4366. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4367. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4368. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4369. }
  4370. }
  4371. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4372. if (NewServerUse()) {
  4373. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4374. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4375. }
  4376. boolean procSucc = true;
  4377. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  4378. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  4379. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  4380. if (VentilCTR!=null && VentilCTR.Refresh(false) == 0) {
  4381. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  4382. boolean OnOff = false;
  4383. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  4384. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  4385. else procSucc = false;
  4386. }
  4387. else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  4388. byte strength = 0;
  4389. if (ventilParser.ctraction.equalsIgnoreCase("low")) strength = VentiAPI.WIND.LOW;
  4390. else if (ventilParser.ctraction.equalsIgnoreCase("mid")) strength = VentiAPI.WIND.MID;
  4391. else strength = VentiAPI.WIND.HI;
  4392. if (VentilCTR.data.OnOff) {
  4393. // 환기가 On인 경우
  4394. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4395. else procSucc = false;
  4396. }
  4397. else {
  4398. // 환기가 Off인 경우
  4399. if (VentilCTR.SetOnOff(true) >= 0) {
  4400. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4401. else procSucc = false;
  4402. }
  4403. else {
  4404. procSucc = false;
  4405. }
  4406. }
  4407. }
  4408. if (VentilCTR.Refresh(true) == 0) {
  4409. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4410. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4411. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4412. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4413. else unit_status = "unknown";
  4414. if (VentilCTR.data.Support.AutoDriving) {
  4415. mode = "normal/auto";
  4416. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4417. else unit_mode = "normal";
  4418. }
  4419. else {
  4420. mode = "normal";
  4421. unit_mode = "normal";
  4422. }
  4423. }
  4424. else {
  4425. procSucc = false;
  4426. }
  4427. }
  4428. else {
  4429. procSucc = false;
  4430. }
  4431. }
  4432. else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4433. if (VentilCTR!=null && VentilCTR.Refresh(false) == 0) {
  4434. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4435. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4436. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4437. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4438. else unit_status = "unknown";
  4439. if (VentilCTR.data.Support.AutoDriving) {
  4440. mode = "normal/auto";
  4441. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4442. else unit_mode = "normal";
  4443. }
  4444. else {
  4445. mode = "normal";
  4446. unit_mode = "normal";
  4447. }
  4448. }
  4449. else {
  4450. procSucc = false;
  4451. }
  4452. }
  4453. else {
  4454. procSucc = false;
  4455. }
  4456. if (procSucc == false) {
  4457. retStr+=(" result=\"fail\" >\r\n");
  4458. unit_status = "unknown";
  4459. }
  4460. else {
  4461. retStr+=(" result=\"ok\" >\r\n");
  4462. }
  4463. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4464. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4465. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4466. retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4467. return retStr;
  4468. } catch (RuntimeException re) {
  4469. LogUtil.errorLogInfo("", TAG, re);
  4470. return null;
  4471. }
  4472. catch (Exception e) {
  4473. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4474. //e.printStackTrace();
  4475. LogUtil.errorLogInfo("", TAG, e);
  4476. return null;
  4477. }
  4478. }
  4479. public String iCMDProcTemperControl(Document doc) {
  4480. try {
  4481. String retStr = CheckiCMDProc("remote_access_temper");
  4482. if (retStr != null) return retStr;
  4483. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4484. String target= "null", tid= "null", msgno= "null";
  4485. NodeList items = doc.getElementsByTagName("target");
  4486. Node item = items.item(0);
  4487. if (item != null) {
  4488. NamedNodeMap attrs = item.getAttributes();
  4489. for (int j = 0; j< attrs.getLength(); j++) {
  4490. Node attr = attrs.item(j);
  4491. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4492. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4493. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4494. }
  4495. }
  4496. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4497. if (NewServerUse()) {
  4498. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4499. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4500. }
  4501. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4502. String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4503. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4504. // 난방 종류를 얻어온다.
  4505. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4506. HeatingV1API heatingV1API = null;
  4507. HeatingV2API heatingV2API = null;
  4508. // 종류별 API를 로딩한다.
  4509. if(HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4510. else if(HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4511. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4512. if (tempercmd.actionTXT.equals("control")) {
  4513. String[] CtrList;
  4514. byte ctrl = 0;
  4515. byte roomNum = (byte)0xFF;
  4516. double temp = 0;
  4517. if (tempercmd.unitnum.equals("all")) {
  4518. if (tempercmd.ctraction.equals("on")) {
  4519. ctrl = 1;
  4520. }
  4521. else if (tempercmd.ctraction.equals("off")) {
  4522. ctrl = 0;
  4523. }
  4524. else {
  4525. retStr+="\"fail\">\r\n <target name=\""+tempercmd.target+"\" id=\""+tempercmd.tid+"\" msg_no=\""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap> ";
  4526. return retStr;
  4527. }
  4528. }
  4529. else {
  4530. CtrList = tempercmd.ctraction.split("/");
  4531. if (CtrList[0].equals("on")) ctrl = 1;
  4532. else ctrl = 0;
  4533. roomNum = (byte)0xFF;
  4534. temp = Double.parseDouble(CtrList[1]);
  4535. }
  4536. if (HeatingKind == 1) {
  4537. boolean OnOff = false;
  4538. if (ctrl == 1) OnOff = true;
  4539. if (tempercmd.unitnum.equals("all") && heatingV1API!=null) {
  4540. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4541. if (ret != APIErrorCode.C_SUCCESS) {
  4542. retStr+="\"fail\">\r\n <target name=\""+tempercmd.target+"\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4543. return retStr;
  4544. }
  4545. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4546. }
  4547. else {
  4548. for (byte i = 0; i < RoomList.length; i++) {
  4549. if (tempercmd.unitnum.equals(RoomList[i])) {
  4550. roomNum = i;
  4551. break;
  4552. }
  4553. }
  4554. if (roomNum == (byte) 0xFF) {
  4555. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\""+tempercmd.msgno+"\"/>\r\n </service>\r\n</imap>";
  4556. return retStr;
  4557. }
  4558. if(heatingV1API!=null)
  4559. {
  4560. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff)?(byte)1:(byte)2, temp);
  4561. if (ret != APIErrorCode.C_SUCCESS) {
  4562. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4563. return retStr;
  4564. }
  4565. heatingV1API.Refresh(roomNum, false);
  4566. }
  4567. }
  4568. }
  4569. else if (HeatingKind == 2) {
  4570. byte Mode = HeatingV2.MODE.HeatingOFF;
  4571. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4572. if (tempercmd.unitnum.equals("all")) {
  4573. if(heatingV2API!=null)
  4574. {
  4575. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4576. if (ret != APIErrorCode.C_SUCCESS) {
  4577. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4578. return retStr;
  4579. }
  4580. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4581. }
  4582. }
  4583. else {
  4584. for (byte i = 0; i < RoomList.length; i++) {
  4585. if (tempercmd.unitnum.equals(RoomList[i])) {
  4586. roomNum = i;
  4587. break;
  4588. }
  4589. }
  4590. if (roomNum == (byte) 0xFF) {
  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. if(heatingV2API!=null)
  4595. {
  4596. int ret = heatingV2API.SetEachRoomStatus(roomNum, Mode, temp);
  4597. if (ret != APIErrorCode.C_SUCCESS) {
  4598. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4599. return retStr;
  4600. }
  4601. heatingV2API.Refresh(roomNum, false);
  4602. }
  4603. }
  4604. }
  4605. else {
  4606. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4607. return retStr;
  4608. }
  4609. }
  4610. String resultStr=" <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4611. if (HeatingKind == 1) {
  4612. try {
  4613. if(heatingV1API == null)
  4614. {
  4615. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4616. return retStr;
  4617. }
  4618. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4619. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4620. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount +"\"/>\r\n";
  4621. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4622. String drvmode = "off";
  4623. for (byte i = 0; i < RoomCount ; i++) {
  4624. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4625. if (roomData.bOnOff) drvmode = "on";
  4626. else drvmode = "off";
  4627. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4628. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4629. }
  4630. resultStr += " </service>\r\n</imap>\r\n";
  4631. retStr+=("\"ok\">\r\n"+resultStr);
  4632. return retStr;
  4633. }
  4634. else {
  4635. String drvmode = "off";
  4636. byte roomNum = (byte) 0xFF;
  4637. for (byte i = 0; i < RoomList.length; i++) {
  4638. if (tempercmd.unitnum.equals(RoomList[i])) {
  4639. roomNum = i;
  4640. break;
  4641. }
  4642. }
  4643. if (roomNum == (byte) 0xFF) {
  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. }
  4647. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4648. if (roomData.bOnOff) drvmode = "on";
  4649. else drvmode = "off";
  4650. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4651. resultStr += " <status_info unit_num=\""+RoomList[roomNum]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4652. resultStr += " </service>\r\n</imap>\r\n";
  4653. retStr+=("\"ok\">\r\n"+resultStr);
  4654. return retStr;
  4655. }
  4656. } catch (RuntimeException re) {
  4657. LogUtil.errorLogInfo("", TAG, re);
  4658. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4659. return retStr;
  4660. }
  4661. catch (Exception e) {
  4662. //e.printStackTrace();
  4663. LogUtil.errorLogInfo("", TAG, e);
  4664. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4665. return retStr;
  4666. }
  4667. }
  4668. else if (HeatingKind == 2) {
  4669. try {
  4670. if(heatingV2API == null)
  4671. {
  4672. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4673. return retStr;
  4674. }
  4675. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4676. resultStr += " <action> \""+tempercmd.actionTXT+"\"</action>\r\n";
  4677. resultStr += " <status_map dev_num=\"1\" unit_cnt = \""+RoomCount+"\" />\r\n";
  4678. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4679. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount );
  4680. String drvmode = "off";
  4681. for (byte i = 0; i < RoomCount; i++) {
  4682. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4683. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4684. else drvmode = "off";
  4685. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4686. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4687. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\" room_name=\"" + mDefaultRoomNameList_Heating[i] + "\"/>\r\n";
  4688. }
  4689. else {
  4690. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4691. }
  4692. }
  4693. resultStr += " </service>\r\n</imap>\r\n";
  4694. retStr+=("\"ok\">\r\n"+resultStr);
  4695. return retStr;
  4696. }
  4697. else {
  4698. String drvmode = "off";
  4699. byte roomNum = (byte) 0xFF;
  4700. for (byte i = 0; i < RoomList.length; i++) {
  4701. if (tempercmd.unitnum.equals(RoomList[i])) {
  4702. roomNum = i;
  4703. break;
  4704. }
  4705. }
  4706. if (roomNum == (byte) 0xFF) {
  4707. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4708. return retStr;
  4709. }
  4710. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[roomNum];
  4711. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4712. else drvmode = "off";
  4713. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  4714. resultStr += " <status_info unit_num=\""+RoomList[roomNum]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  4715. resultStr += " </service>\r\n</imap>\r\n";
  4716. retStr+=("\"ok\">\r\n"+resultStr);
  4717. return retStr;
  4718. }
  4719. } catch (RuntimeException re) {
  4720. LogUtil.errorLogInfo("", TAG, re);
  4721. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4722. return retStr;
  4723. }
  4724. catch (Exception e) {
  4725. //e.printStackTrace();
  4726. LogUtil.errorLogInfo("", TAG, e);
  4727. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4728. return retStr;
  4729. }
  4730. }
  4731. else {
  4732. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^" );
  4733. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4734. return retStr;
  4735. }
  4736. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4737. // return retStr;
  4738. } catch (RuntimeException re) {
  4739. LogUtil.errorLogInfo("", TAG, re);
  4740. return null;
  4741. }
  4742. catch (Exception e) {
  4743. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4744. //e.printStackTrace();
  4745. LogUtil.errorLogInfo("", TAG, e);
  4746. return null;
  4747. }
  4748. }
  4749. public String iCMDProcDoorlockControl(Document doc) {
  4750. try {
  4751. String DLStatus = "none";
  4752. String strResult = CheckiCMDProc("remote_access_doorlock");
  4753. if (strResult != null) return strResult;
  4754. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4755. String target= "null", tid= "null", msgno= "null";
  4756. NodeList items = doc.getElementsByTagName("target");
  4757. Node item = items.item(0);
  4758. if (item != null) {
  4759. NamedNodeMap attrs = item.getAttributes();
  4760. for (int j = 0; j< attrs.getLength(); j++) {
  4761. Node attr = attrs.item(j);
  4762. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4763. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4764. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4765. }
  4766. }
  4767. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4768. if (NewServerUse()) {
  4769. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4770. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  4771. }
  4772. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4773. try {
  4774. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4775. if(doorStatus!=null)
  4776. {
  4777. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4778. DLStatus = "unknown";
  4779. }
  4780. else {
  4781. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce) DLStatus = "close";
  4782. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open|| doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce) DLStatus = "open";
  4783. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation) DLStatus = "ing";
  4784. else DLStatus="unknown";
  4785. }
  4786. }
  4787. }
  4788. catch (RuntimeException re) {
  4789. LogUtil.errorLogInfo("", TAG, re);
  4790. DLStatus="unknown";
  4791. }
  4792. catch (Exception e) {
  4793. //e.printStackTrace();
  4794. LogUtil.errorLogInfo("", TAG, e);
  4795. DLStatus="unknown";
  4796. }
  4797. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n"+
  4798. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n"+
  4799. " <action>\"status\"</action>\r\n"+
  4800. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n"+
  4801. " <status_info unit_num=\"doorlock1\" unit_status=\""+DLStatus+"\"/>\r\n </service>\r\n</imap>";
  4802. return retXML;
  4803. } catch (RuntimeException re) {
  4804. LogUtil.errorLogInfo("", TAG, re);
  4805. return null;
  4806. }
  4807. catch (Exception e) {
  4808. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4809. //e.printStackTrace();
  4810. LogUtil.errorLogInfo("", TAG, e);
  4811. return null;
  4812. }
  4813. }
  4814. /*
  4815. protected String iCMDProcsavelog(Document doc)
  4816. {
  4817. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4818. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4819. NodeList items = doc.getElementsByTagName("guidemap");
  4820. Node item = items.item(0);
  4821. NamedNodeMap attrsParam = item.getAttributes();
  4822. for(int j=0; j< attrsParam.getLength();j++)
  4823. {
  4824. Node attr = attrsParam.item(j);
  4825. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4826. {
  4827. String enable = attr.getNodeValue();
  4828. if (enable == null) return FailretStr;
  4829. if (enable.equals("false"))
  4830. {
  4831. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4832. logSet.SetLogDoing(0);
  4833. logSet.closeDB();
  4834. return SucretStr;
  4835. }
  4836. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4837. logSet.SetLogDoing(1);
  4838. logSet.closeDB();
  4839. }
  4840. }
  4841. items = doc.getElementsByTagName("setting");
  4842. item = items.item(0);
  4843. attrsParam = item.getAttributes();
  4844. String SaveType = "";
  4845. String FtpLoc = "";
  4846. String Ftpuser = "";
  4847. String FtpPW= "";
  4848. String period = "";
  4849. String FileSize = "";
  4850. for(int j=0; j< attrsParam.getLength();j++)
  4851. {
  4852. Node attr = attrsParam.item(j);
  4853. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4854. SaveType = attr.getNodeValue();
  4855. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4856. FtpLoc = attr.getNodeValue();
  4857. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4858. Ftpuser = attr.getNodeValue();
  4859. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4860. FtpPW = attr.getNodeValue();
  4861. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4862. period = attr.getNodeValue();
  4863. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4864. FileSize = attr.getNodeValue();
  4865. }
  4866. if (SaveType.equalsIgnoreCase("now"))
  4867. {
  4868. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4869. LogUpThread.start();
  4870. return SucretStr;
  4871. }
  4872. else if (SaveType.equalsIgnoreCase("periodic"))
  4873. {
  4874. try
  4875. {
  4876. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4877. period = period.trim();
  4878. String[] logperiod = period.split("[-]");
  4879. String StartDate = logperiod[0].replace(".", "_");
  4880. String EndDate = logperiod[1].replace(".", "_");
  4881. logSet.SetLogDoing(1);
  4882. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4883. if (FileSize.equalsIgnoreCase("null"))
  4884. logSet.SetLogLogFileSize(0);
  4885. else
  4886. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4887. logSet.SetLogStartDate(StartDate);
  4888. logSet.SetLogEndDate(EndDate);
  4889. logSet.closeDB();
  4890. return SucretStr;
  4891. }
  4892. catch (RuntimeException re) {
  4893. LogUtil.errorLogInfo("", TAG, re);
  4894. }
  4895. catch (Exception e)
  4896. {
  4897. e.printStackTrace();
  4898. return FailretStr;
  4899. }
  4900. }
  4901. else
  4902. {
  4903. return FailretStr;
  4904. }
  4905. }
  4906. */
  4907. protected void SendLogSaved(String ftploc, String fname, String size)
  4908. {
  4909. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n"+
  4910. " <device_info devtype=\"homedev\" id_high=\""+AddrDong+"\" id_low=\""+AddrHo+"\"/>\r\n"+
  4911. " <file_info path=\""+ftploc+"\" name=\""+fname+"\" size=\""+size+"\"/>\r\n</service>\r\n</imap>";
  4912. SendToServer(SendMsg);
  4913. }
  4914. public final static int FTPLOGTRSUCC = 1110;
  4915. public final static int FTPLOGTRFAIL = 1120;
  4916. Handler FileTrHandler = new Handler(){
  4917. public void handleMessage(Message msg)
  4918. {
  4919. switch (msg.what)
  4920. {
  4921. case FTPLOGTRSUCC:
  4922. String[] getMSG = ((String)(msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4923. File fileinfo = new File(define.LOG_FILE_LOCATION+"/"+getMSG[1]);
  4924. int size = (int)(fileinfo.length()/1024);
  4925. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4926. imapsvrlog("FTPLOGTRSUCC");
  4927. break;
  4928. case FTPLOGTRFAIL:
  4929. imapsvrlog("FTPLOGTRFAIL");
  4930. break;
  4931. }
  4932. }
  4933. };
  4934. class LogUploader extends Thread
  4935. {
  4936. int fileidx = 0;
  4937. boolean TRing = false;
  4938. String FtpLoc;
  4939. String FtpID;
  4940. String FtpPasswd;
  4941. class ftpuploader extends WallPadFTPUploader
  4942. {
  4943. String filename;
  4944. public ftpuploader(Context ctx, String ftpPath, String User,String Passwd, String LocalFile)
  4945. {
  4946. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION+"/"+LocalFile);
  4947. filename = LocalFile;
  4948. }
  4949. protected void ProcUploadFail()
  4950. {
  4951. Message TrResult = FileTrHandler.obtainMessage();
  4952. TrResult.obj = ftpPATH+define.DEVCTR_CMD_SPLITER+filename+define.DEVCTR_CMD_SPLITER+id+define.DEVCTR_CMD_SPLITER+passwd;
  4953. TrResult.what = FTPLOGTRFAIL;
  4954. TRing = false;
  4955. imapsvrlog("Send Log Fail Message");
  4956. FileTrHandler.sendMessage(TrResult);
  4957. }
  4958. protected void ProcUploadSuccess()
  4959. {
  4960. Message TrResult = FileTrHandler.obtainMessage();
  4961. TrResult.obj = ftpPATH+define.DEVCTR_CMD_SPLITER+filename+define.DEVCTR_CMD_SPLITER+id+define.DEVCTR_CMD_SPLITER+passwd;
  4962. TrResult.what = FTPLOGTRSUCC;
  4963. TRing = false;
  4964. imapsvrlog("Send Log success Message");
  4965. FileTrHandler.sendMessage(TrResult);
  4966. }
  4967. }
  4968. public LogUploader(String loc, String user, String pw)
  4969. {
  4970. FtpLoc = loc;
  4971. FtpID = user;
  4972. FtpPasswd = pw;
  4973. }
  4974. public void run()
  4975. {
  4976. File LogLoc = new File(define.LOG_FILE_LOCATION);
  4977. String[] LogFileList = LogLoc.list();
  4978. while(true)
  4979. {
  4980. if (TRing == false)
  4981. {
  4982. if (LogFileList!=null && fileidx < LogFileList.length)
  4983. {
  4984. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx] );
  4985. fileidx++;
  4986. TRing = true;
  4987. uploader.start();
  4988. }
  4989. else
  4990. return;
  4991. }
  4992. try {Thread.sleep(500); }
  4993. catch (RuntimeException re) {
  4994. LogUtil.errorLogInfo("", TAG, re);
  4995. }
  4996. catch (Exception e) {
  4997. LogUtil.errorLogInfo("", TAG, e);
  4998. }
  4999. }
  5000. }
  5001. }
  5002. public String iCMDProcDevList(Document ele) {
  5003. try {
  5004. String strResult = CheckiCMDProc("remote_get_home_devices");
  5005. if (strResult != null) return strResult;
  5006. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" result=";
  5007. String target= "null", tid= "null", msgno= "null";
  5008. NodeList items = ele.getElementsByTagName("target");
  5009. Node item = items.item(0);
  5010. if (item != null) {
  5011. NamedNodeMap attrs = item.getAttributes();
  5012. for (int j = 0; j< attrs.getLength(); j++) {
  5013. Node attr = attrs.item(j);
  5014. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5015. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5016. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5017. }
  5018. }
  5019. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5020. if (NewServerUse()) {
  5021. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  5022. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5023. }
  5024. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  5025. String[] devlist = {"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop"};
  5026. strResult += "\"ok\">\r\n";
  5027. strResult +=" <target name=\""+DevListCMD.target+"\" id=\""+DevListCMD.tid+"\" msg_no=\""+DevListCMD.msgno+"\"/>\r\n";
  5028. strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  5029. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  5030. for (int i = 0; i < devlist.length; i++) {
  5031. if (devlist[i].equals("gas")) {
  5032. try {
  5033. int Gasinfo = devSet.Get_GAS_Info();
  5034. if (Gasinfo == 0) strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  5035. else strResult +=" <devinfo name=\"gas\" value=\"1\"/>\r\n";
  5036. } catch (RuntimeException re) {
  5037. LogUtil.errorLogInfo("", TAG, re);
  5038. strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  5039. }
  5040. catch (Exception e) {
  5041. //e.printStackTrace();
  5042. LogUtil.errorLogInfo("", TAG, e);
  5043. strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  5044. }
  5045. }
  5046. else if (devlist[i].equals("cooktop")) {
  5047. try {
  5048. //int Gooktopinfo = devSet.Get_Cooktop_Info();
  5049. int Gooktopinfo = devSet.Get_GAS_Info();
  5050. if (Gooktopinfo == 0) strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  5051. else strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5052. } catch (RuntimeException re) {
  5053. LogUtil.errorLogInfo("", TAG, re);
  5054. strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  5055. }
  5056. catch (Exception e) {
  5057. //e.printStackTrace();
  5058. LogUtil.errorLogInfo("", TAG, e);
  5059. strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  5060. }
  5061. }
  5062. else if (devlist[i].equals("doorlock")) {
  5063. try {
  5064. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5065. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5066. strResult +=" <devinfo name=\"doorlock\" value=\"1\"/>\r\n";
  5067. }
  5068. else {
  5069. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  5070. }
  5071. } catch (RuntimeException re) {
  5072. LogUtil.errorLogInfo("", TAG, re);
  5073. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  5074. }
  5075. catch (Exception e) {
  5076. //e.printStackTrace();
  5077. LogUtil.errorLogInfo("", TAG, e);
  5078. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  5079. }
  5080. }
  5081. else if (devlist[i].equals("light")) {
  5082. try {
  5083. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5084. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  5085. if (bSmartLightAsNormalLight) {
  5086. if (mSdbAPI != null) {
  5087. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\"/>\r\n";
  5088. }
  5089. else {
  5090. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  5091. }
  5092. }
  5093. else {
  5094. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5095. }
  5096. }
  5097. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5098. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5099. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5100. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\"/>\r\n";
  5101. }
  5102. else {
  5103. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  5104. }
  5105. }
  5106. else {
  5107. int[] lightinfo = devSet.Get_Light_info();
  5108. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5109. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  5110. }
  5111. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5112. strResult += " <devinfo name=\"light\" value=\"1\"/>\r\n";
  5113. }
  5114. else {
  5115. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5116. int ret = multisw.Refresh((byte)0xFF, false);
  5117. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  5118. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\"/>\r\n";
  5119. }
  5120. }
  5121. } catch (RuntimeException re) {
  5122. LogUtil.errorLogInfo("", TAG, re);
  5123. strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  5124. }
  5125. catch (Exception e) {
  5126. //e.printStackTrace();
  5127. LogUtil.errorLogInfo("", TAG, e);
  5128. strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  5129. }
  5130. }
  5131. else if (devlist[i].equals("livinglight")) {
  5132. try {
  5133. int[] lightinfo = devSet.Get_Light_info();
  5134. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5135. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  5136. if (bSmartLightAsNormalLight) {
  5137. if (mSdb_LivingRoomLightAPI != null) {
  5138. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\"/>\r\n";
  5139. }
  5140. else {
  5141. strResult += " <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5142. }
  5143. }
  5144. else {
  5145. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5146. }
  5147. }
  5148. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5149. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\"/>\r\n";
  5150. }
  5151. else {
  5152. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5153. strResult += " <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5154. }
  5155. else {
  5156. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\"/>\r\n";
  5157. }
  5158. }
  5159. } catch (RuntimeException re) {
  5160. LogUtil.errorLogInfo("", TAG, re);
  5161. strResult +=" <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5162. }
  5163. catch (Exception e) {
  5164. //e.printStackTrace();
  5165. LogUtil.errorLogInfo("", TAG, e);
  5166. strResult +=" <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5167. }
  5168. }
  5169. else if (devlist[i].equals("ventil")) {
  5170. try {
  5171. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5172. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  5173. else strResult +=" <devinfo name=\"ventil\" value=\"1\"/>\r\n";
  5174. } catch (RuntimeException re) {
  5175. LogUtil.errorLogInfo("", TAG, re);
  5176. strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  5177. }
  5178. catch (Exception e) {
  5179. //e.printStackTrace();
  5180. LogUtil.errorLogInfo("", TAG, e);
  5181. strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  5182. }
  5183. }
  5184. else if (devlist[i].equals("thermostat")) {
  5185. try {
  5186. int Temperinfo = devSet.Get_Temper_Info();
  5187. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5188. HeatingV1API heatingV1API = null;
  5189. HeatingV2API heatingV2API = null;
  5190. byte RoomCount = 0;
  5191. // 종류별 API를 로딩한다.
  5192. if (HeatingKind == 1) {
  5193. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5194. if (heatingV1API != null) {
  5195. RoomCount = heatingV1API.data.Device.RoomCount;
  5196. }
  5197. }
  5198. else if (HeatingKind == 2) {
  5199. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5200. if (heatingV2API != null) {
  5201. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5202. }
  5203. }
  5204. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  5205. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\"/>\r\n";
  5206. } catch (RuntimeException re) {
  5207. LogUtil.errorLogInfo("", TAG, re);
  5208. strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  5209. }
  5210. catch (Exception e) {
  5211. //e.printStackTrace();
  5212. LogUtil.errorLogInfo("", TAG, e);
  5213. strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  5214. }
  5215. }
  5216. else if (devlist[i].equals("curtain")) {
  5217. try {
  5218. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5219. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  5220. else strResult += " <devinfo name=\"curtain\" value=\"1\"/>\r\n";
  5221. } catch (RuntimeException re) {
  5222. LogUtil.errorLogInfo("", TAG, re);
  5223. strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  5224. }
  5225. catch (Exception e) {
  5226. //e.printStackTrace();
  5227. LogUtil.errorLogInfo("", TAG, e);
  5228. strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  5229. }
  5230. }
  5231. else if (devlist[i].equals("electric")) {
  5232. try {
  5233. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5234. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  5235. int nOutlet = 0;
  5236. if (mSdb_LivingRoomLightAPI != null) {
  5237. if (mSdbAPI != null) {
  5238. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5239. }
  5240. else {
  5241. nOutlet = 1;
  5242. }
  5243. }
  5244. else {
  5245. if (mSdbAPI != null) {
  5246. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5247. }
  5248. else {
  5249. nOutlet = 0;
  5250. }
  5251. }
  5252. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\"/>\r\n";
  5253. }
  5254. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5255. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5256. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5257. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\"/>\r\n";
  5258. }
  5259. else {
  5260. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5261. }
  5262. }
  5263. else {
  5264. int[] lightinfo = devSet.Get_Light_info();
  5265. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5266. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5267. }
  5268. else {
  5269. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5270. int ret = multisw.Refresh((byte)0xFF, false);
  5271. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5272. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5273. }
  5274. else {
  5275. int DeviceCount = 0;
  5276. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5277. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5278. DeviceCount++;
  5279. }
  5280. }
  5281. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\"/>\r\n";
  5282. }
  5283. }
  5284. }
  5285. } catch (RuntimeException re) {
  5286. LogUtil.errorLogInfo("", TAG, re);
  5287. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5288. }
  5289. catch (Exception e) {
  5290. //e.printStackTrace();
  5291. LogUtil.errorLogInfo("", TAG, e);
  5292. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5293. }
  5294. }
  5295. else if (devlist[i].equals("smartlight")) {
  5296. if (!bSmartLightAsNormalLight) {
  5297. int nSmartLight = 0;
  5298. if (mSdb_LivingRoomLightAPI != null) {
  5299. if (mSdbAPI != null) {
  5300. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5301. }
  5302. else {
  5303. nSmartLight = 1;
  5304. }
  5305. }
  5306. else {
  5307. if (mSdbAPI != null) {
  5308. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5309. }
  5310. else {
  5311. nSmartLight = 0;
  5312. }
  5313. }
  5314. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\"/>\r\n";
  5315. }
  5316. }
  5317. }
  5318. strResult += " </service>\r\n</imap>\r\n";
  5319. devSet.closeDB();
  5320. return strResult;
  5321. } catch (RuntimeException re) {
  5322. LogUtil.errorLogInfo("", TAG, re);
  5323. return null;
  5324. }
  5325. catch (Exception e) {
  5326. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  5327. //e.printStackTrace();
  5328. LogUtil.errorLogInfo("", TAG, e);
  5329. return null;
  5330. }
  5331. }
  5332. public String iCMDProcMultiSWControl(Document ele) {
  5333. try {
  5334. String retStr = CheckiCMDProc(MULTISW_CTR);
  5335. if (retStr != null) return retStr;
  5336. else retStr = XMLHeader + " <service type=\"reply\" name=\""+MULTISW_CTR+"\"";
  5337. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  5338. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5339. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  5340. int devNum = Integer.parseInt(multiswcmd.devnum);
  5341. if(multisw!=null)
  5342. {
  5343. int ret = multisw.Refresh((byte)0xFF, false);
  5344. String result;
  5345. if (ret==APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  5346. else result = "fail";
  5347. retStr+=(" result=\""+result+"\" >\r\n");
  5348. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5349. retStr += MakeTargetStr(multiswcmd);
  5350. retStr += " <action>\"status\"</action>\r\n";
  5351. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum-1].device.hOutletCnt + "\"/>\r\n";
  5352. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5353. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  5354. 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";
  5355. }
  5356. else {
  5357. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.hOutletCnt +"\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  5358. }
  5359. }
  5360. else {
  5361. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.hOutletCnt +"\"/>\r\n";
  5362. }
  5363. String unitStr;
  5364. for (int i = 0;i < multisw.data.Device[devNum-1].device.hOutletCnt;i++) {
  5365. Log.e(TAG, multisw.data.Device[devNum-1].device.ToDebugString((byte) i));
  5366. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5367. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5368. unitStr = (multisw.data.Device[devNum-1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5369. unitStr += (multisw.data.Device[devNum-1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  5370. retStr += " <status_info unit_num=\"switch"+(i+1)+"\" unit_status=\""+unitStr+"\" />\r\n";
  5371. }
  5372. }
  5373. retStr+=" </service>\r\n</imap>\r\n";
  5374. }
  5375. }
  5376. else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  5377. int devNum = Integer.parseInt(multiswcmd.devnum);
  5378. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  5379. {
  5380. if(multisw!=null)
  5381. {
  5382. multisw.Refresh((byte)0xFF, false);
  5383. String result;
  5384. int ret = -1;
  5385. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  5386. ret = multisw.SetConcentMode((byte)(devNum-1), (byte)(swNum-1), true);
  5387. }
  5388. else if(multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  5389. ret = multisw.SetConcentMode((byte)(devNum-1), (byte)(swNum-1), false);
  5390. }
  5391. else if(multiswcmd.ctraction.equalsIgnoreCase("on")) {
  5392. ret = multisw.SetConcentOnOff((byte)(devNum-1), (byte)(swNum-1), true);
  5393. }
  5394. else if(multiswcmd.ctraction.equalsIgnoreCase("off")) {
  5395. ret = multisw.SetConcentOnOff((byte)(devNum-1), (byte)(swNum-1), false);
  5396. }
  5397. if (ret==APIErrorCode.C_SUCCESS) result = "ok";
  5398. else result = "fail";
  5399. if (ret == APIErrorCode.C_SUCCESS) {
  5400. ret = multisw.Refresh((byte)0xFF, false);
  5401. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5402. retStr+=(" result=\""+result+"\" > \r\n");
  5403. retStr += MakeTargetStr(multiswcmd);
  5404. retStr += " <action>\"control\"</action>\r\n";
  5405. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+multisw.data.Device[devNum-1].device.hOutletCnt+"\"/>\r\n";
  5406. String unitStr;
  5407. for (int i = 0; i < multisw.data.Device[devNum-1].device.hOutletCnt; i++) {
  5408. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5409. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5410. unitStr = (multisw.data.Device[devNum-1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto)?"set/":"unset/";
  5411. unitStr += (multisw.data.Device[devNum-1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off)?"off":"on";
  5412. retStr += " <status_info unit_num=\"switch"+(i + 1)+"\" unit_status=\"" + unitStr + "\" />\r\n";
  5413. }
  5414. }
  5415. else {
  5416. retStr+=(" result=\"fail\"> \r\n");
  5417. }
  5418. }
  5419. else {
  5420. retStr+=(" result=\"fail\"> \r\n");
  5421. }
  5422. retStr+=" </service>\r\n</imap>\r\n";
  5423. }
  5424. }
  5425. }
  5426. return retStr;
  5427. } catch (RuntimeException re) {
  5428. LogUtil.errorLogInfo("", TAG, re);
  5429. return null;
  5430. }
  5431. catch (Exception e) {
  5432. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  5433. //e.printStackTrace();
  5434. LogUtil.errorLogInfo("", TAG, e);
  5435. return null;
  5436. }
  5437. }
  5438. public String iCMDProcSDPConcentControl(Document ele) {
  5439. try {
  5440. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  5441. String retStr = CheckiCMDProc("remote_access_electric");
  5442. if (retStr != null) return retStr;
  5443. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  5444. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5445. if (NewServerUse()) {
  5446. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  5447. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5448. }
  5449. if (mSdbAPI == null) {
  5450. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5451. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  5452. return retStr;
  5453. }
  5454. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  5455. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5456. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  5457. return retStr;
  5458. }
  5459. int nTotalLightCnt = 0;
  5460. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  5461. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  5462. }
  5463. else {
  5464. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  5465. }
  5466. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  5467. int nDevNo = 0;
  5468. try {
  5469. nDevNo = Integer.parseInt(concentcmd.devnum);
  5470. } catch (RuntimeException re) {
  5471. LogUtil.errorLogInfo("", TAG, re);
  5472. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5473. return retStr;
  5474. }
  5475. catch (Exception e) {
  5476. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  5477. //e.printStackTrace();
  5478. LogUtil.errorLogInfo("", TAG, e);
  5479. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5480. return retStr;
  5481. }
  5482. if (nDevNo < 1 && 12 < nDevNo) {
  5483. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5484. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  5485. return retStr;
  5486. }
  5487. String strAction = trimquotation(concentcmd.actionTXT);
  5488. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  5489. String dev_num = "null",unit_num = "null", ctrl_action = "null";
  5490. int nRet_Mode = -99, nRet_OnOff = -99;
  5491. boolean Set = false, OnOff = false; // 제어요청 상태
  5492. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  5493. if (strAction.equalsIgnoreCase("status")) {
  5494. retStr += " result=\"ok\">\r\n";
  5495. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  5496. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  5497. if (nDevNo == 1) {
  5498. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5499. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount +"\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  5500. }
  5501. else {
  5502. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount +"\"/>\r\n";
  5503. }
  5504. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  5505. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  5506. else status_mode = "set";
  5507. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  5508. else status_onoff = "off";
  5509. unit_status = status_mode + "/" + status_onoff;
  5510. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  5511. }
  5512. // retStr += " </status_map>\r\n";
  5513. retStr += " </service>\r\n</imap>\r\n";
  5514. }
  5515. else if (nDevNo > 1) {
  5516. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5517. 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";
  5518. }
  5519. else {
  5520. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  5521. }
  5522. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  5523. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  5524. else status_mode = "set";
  5525. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  5526. else status_onoff = "off";
  5527. unit_status = status_mode + "/" + status_onoff;
  5528. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  5529. }
  5530. // retStr += " </status_map>\r\n";
  5531. retStr += " </service>\r\n</imap>\r\n";
  5532. }
  5533. }
  5534. else if (strAction.equalsIgnoreCase("control")) {
  5535. NodeList items = ele.getElementsByTagName("params");
  5536. Node item = items.item(0);
  5537. if (item != null) {
  5538. NamedNodeMap attrs = item.getAttributes();
  5539. for (int i = 0; i< attrs.getLength(); i++) {
  5540. Node attr = attrs.item(i);
  5541. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  5542. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  5543. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) ctrl_action = attr.getNodeValue();
  5544. }
  5545. }
  5546. else {
  5547. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  5548. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5549. return retStr;
  5550. }
  5551. try {
  5552. nDevNo = Integer.parseInt(dev_num);
  5553. } catch (RuntimeException re) {
  5554. LogUtil.errorLogInfo("", TAG, re);
  5555. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5556. return retStr;
  5557. }
  5558. catch (Exception e) {
  5559. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  5560. //e.printStackTrace();
  5561. LogUtil.errorLogInfo("", TAG, e);
  5562. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5563. return retStr;
  5564. }
  5565. if (nDevNo < 1 && 12 < nDevNo) {
  5566. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5567. return retStr;
  5568. }
  5569. int nUnitNo = 0;
  5570. if (!unit_num.equalsIgnoreCase("all")) {
  5571. try {
  5572. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  5573. } catch (RuntimeException re) {
  5574. LogUtil.errorLogInfo("", TAG, re);
  5575. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5576. return retStr;
  5577. }
  5578. catch (Exception e) {
  5579. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  5580. //e.printStackTrace();
  5581. LogUtil.errorLogInfo("", TAG, e);
  5582. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5583. return retStr;
  5584. }
  5585. }
  5586. if (ctrl_action.contains("/")) {
  5587. String[] strParsed = ctrl_action.split("/");
  5588. if (strParsed[0].equals("set")) {
  5589. Set = true;
  5590. bCtrl_Set = true;
  5591. }
  5592. else if (strParsed[0].equals("unset")) {
  5593. Set = false;
  5594. bCtrl_Set = true;
  5595. }
  5596. if (strParsed[1].equals("on")) {
  5597. OnOff = true;
  5598. bCtrl_OnOff = true;
  5599. }
  5600. else if (strParsed[1].equals("off")) {
  5601. OnOff = false;
  5602. bCtrl_OnOff = true;
  5603. }
  5604. }
  5605. else {
  5606. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  5607. if (ctrl_action.equalsIgnoreCase("set")) {
  5608. Set = true;
  5609. bCtrl_Set = true;
  5610. }
  5611. else if (ctrl_action.equalsIgnoreCase("unset")) {
  5612. Set = false;
  5613. bCtrl_Set = true;
  5614. }
  5615. }
  5616. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  5617. if (ctrl_action.equalsIgnoreCase("on")) {
  5618. OnOff = true;
  5619. bCtrl_OnOff = true;
  5620. }
  5621. else if (ctrl_action.equalsIgnoreCase("off")) {
  5622. OnOff = false;
  5623. bCtrl_OnOff = true;
  5624. }
  5625. }
  5626. }
  5627. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  5628. if (nDevNo == 1) {
  5629. if (unit_num.equalsIgnoreCase("all")) {
  5630. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  5631. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  5632. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  5633. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5634. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5635. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5636. return retStr;
  5637. }
  5638. }
  5639. }
  5640. else {
  5641. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  5642. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  5643. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5644. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5645. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5646. return retStr;
  5647. }
  5648. }
  5649. }
  5650. else {
  5651. if (unit_num.equalsIgnoreCase("all")) {
  5652. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  5653. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  5654. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  5655. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5656. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5657. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5658. return retStr;
  5659. }
  5660. }
  5661. }
  5662. else {
  5663. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  5664. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  5665. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  5666. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  5667. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5668. return retStr;
  5669. }
  5670. }
  5671. }
  5672. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  5673. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  5674. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  5675. return retStr;
  5676. }
  5677. retStr += " result=\"ok\">\r\n";
  5678. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  5679. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  5680. if (nDevNo == 1) {
  5681. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  5682. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  5683. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  5684. else status_mode = "set";
  5685. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  5686. else status_onoff = "off";
  5687. unit_status = status_mode + "/" + status_onoff;
  5688. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  5689. }
  5690. // retStr += " </status_map>\r\n";
  5691. retStr += " </service>\r\n</imap>\r\n";
  5692. }
  5693. else if (nDevNo > 1) {
  5694. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  5695. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  5696. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  5697. else status_mode = "set";
  5698. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  5699. else status_onoff = "off";
  5700. unit_status = status_mode + "/" + status_onoff;
  5701. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  5702. }
  5703. // retStr += " </status_map>\r\n";
  5704. retStr += " </service>\r\n</imap>\r\n";
  5705. }
  5706. }
  5707. else {
  5708. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  5709. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  5710. }
  5711. return retStr;
  5712. } catch (RuntimeException re) {
  5713. LogUtil.errorLogInfo("", TAG, re);
  5714. return null;
  5715. }
  5716. catch (Exception e) {
  5717. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  5718. //e.printStackTrace();
  5719. LogUtil.errorLogInfo("", TAG, e);
  5720. return null;
  5721. }
  5722. }
  5723. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  5724. try {
  5725. String retStr = CheckiCMDProc(MULTISW_CTR);
  5726. if (retStr != null) return retStr;
  5727. else retStr = XMLHeader + " <service type=\"reply\" name=\""+MULTISW_CTR+"\" ";
  5728. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  5729. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5730. if(energymetercmd == null) return null;
  5731. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  5732. if(energymeter == null )return null;
  5733. int devNum = Integer.parseInt(energymetercmd.devnum)-1;
  5734. int ret = energymeter.Refresh((byte)0xFF, false);
  5735. String result;
  5736. if (ret==APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  5737. else result = "fail";
  5738. retStr+=(" result=\""+result+"\" >\r\n");
  5739. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  5740. retStr += MakeTargetStr(energymetercmd);
  5741. retStr += " <action>\"status\"</action>\r\n";
  5742. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  5743. String unitStr;
  5744. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  5745. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  5746. if (i == 2) {
  5747. unitStr += "on";
  5748. }
  5749. else {
  5750. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  5751. }
  5752. retStr += " <status_info unit_num=\"switch"+(i + 1)+"\" unit_status=\"" + unitStr + "\"/>\r\n";
  5753. }
  5754. }
  5755. retStr+=" </service>\r\n</imap>\r\n";
  5756. }
  5757. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  5758. int devNum = Integer.parseInt(energymetercmd.devnum)-1;
  5759. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) -1;
  5760. byte cmd = 0;
  5761. int ret = 0;
  5762. String result;
  5763. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  5764. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  5765. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  5766. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  5767. if (cmd>0) {
  5768. if(energymeter!=null)
  5769. {
  5770. energymeter.Refresh((byte)0xFF, false);
  5771. if (cmd == 1) {
  5772. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  5773. }
  5774. else if (cmd == 2) {
  5775. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  5776. }
  5777. else if (cmd == 3) {
  5778. ret = energymeter.SetConcentOnOff((byte) devNum, (byte)swNum, true);
  5779. }
  5780. else if (cmd == 4) {
  5781. ret = energymeter.SetConcentOnOff((byte) devNum, (byte)swNum, false);
  5782. }
  5783. if (ret==APIErrorCode.C_SUCCESS) result = "ok";
  5784. else result = "fail";
  5785. retStr+=(" result=\""+result+"\" >\r\n");
  5786. if (ret == APIErrorCode.C_SUCCESS) {
  5787. ret = energymeter.Refresh((byte)0xFF, false);
  5788. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  5789. retStr += MakeTargetStr(energymetercmd);
  5790. retStr += " <action>\"control\"</action>\r\n";
  5791. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  5792. String unitStr;
  5793. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  5794. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  5795. if (i == 2) {
  5796. unitStr += "on";
  5797. }
  5798. else {
  5799. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  5800. }
  5801. retStr += " <status_info unit_num=\"switch"+(i+1)+"\" unit_status=\""+unitStr+"\"/>\r\n";
  5802. }
  5803. }
  5804. else {
  5805. retStr+=(" result=\"fail\"> \r\n");
  5806. }
  5807. }
  5808. else {
  5809. retStr+=(" result=\"fail\"> \r\n");
  5810. }
  5811. retStr+=" </service>\r\n</imap>\r\n";
  5812. }
  5813. }
  5814. }
  5815. return retStr;
  5816. } catch (RuntimeException re) {
  5817. LogUtil.errorLogInfo("", TAG, re);
  5818. return null;
  5819. }
  5820. catch (Exception e) {
  5821. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  5822. //e.printStackTrace();
  5823. LogUtil.errorLogInfo("", TAG, e);
  5824. return null;
  5825. }
  5826. }
  5827. public String iCMDProcModeControl(Document doc) {
  5828. try {
  5829. String status = "unknown";
  5830. boolean SendBR = false;
  5831. String retStr = CheckiCMDProc("remote_access_mode");
  5832. if (retStr != null) return retStr;
  5833. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  5834. String target= "null", tid= "null", msgno= "null";
  5835. NodeList items = doc.getElementsByTagName("target");
  5836. Node item = items.item(0);
  5837. if (item != null) {
  5838. NamedNodeMap attrs = item.getAttributes();
  5839. for (int j = 0; j< attrs.getLength(); j++) {
  5840. Node attr = attrs.item(j);
  5841. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5842. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5843. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5844. }
  5845. }
  5846. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5847. if (NewServerUse()) {
  5848. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  5849. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5850. }
  5851. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  5852. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5853. int curState = SetData.GetAlarmStatus();
  5854. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  5855. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  5856. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  5857. switch (curState) {
  5858. case WallpadStatusData.GUARD_IN:
  5859. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  5860. Intent intent = new Intent();
  5861. intent.setAction(define.NOTIFY_ACNAME);
  5862. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5863. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  5864. getApplicationContext().sendBroadcast(intent);
  5865. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  5866. SendBR = true;
  5867. break;
  5868. case WallpadStatusData.GUARD_OUT:
  5869. break;
  5870. }
  5871. }
  5872. else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  5873. switch (curState) {
  5874. case WallpadStatusData.ALARM_NONE:
  5875. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5876. if (mIGW200.checkSensorforInmode()) {
  5877. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  5878. Intent intent = new Intent();
  5879. intent.setAction(define.NOTIFY_ACNAME);
  5880. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5881. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  5882. getApplicationContext().sendBroadcast(intent);
  5883. SendBR = true;
  5884. }
  5885. else {
  5886. SendBR = false;
  5887. }
  5888. }
  5889. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5890. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5891. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  5892. if (mIGW300.checkSensorforInmode()) {
  5893. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  5894. Intent intent = new Intent();
  5895. intent.setAction(define.NOTIFY_ACNAME);
  5896. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5897. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  5898. getApplicationContext().sendBroadcast(intent);
  5899. SendBR = true;
  5900. }
  5901. else {
  5902. SendBR = false;
  5903. }
  5904. }
  5905. else {
  5906. if (checkSensorforInmode()) {
  5907. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  5908. Intent intent = new Intent();
  5909. intent.setAction(define.NOTIFY_ACNAME);
  5910. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5911. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  5912. getApplicationContext().sendBroadcast(intent);
  5913. Sound().PlayMent(SND.mode.INMODE_SETTING);
  5914. SendBR = true;
  5915. }
  5916. else {
  5917. SendBR = false;
  5918. }
  5919. }
  5920. break;
  5921. default:
  5922. break;
  5923. }
  5924. }
  5925. else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  5926. if (GetUseIlgalControlForAdmin() == false) {
  5927. // 관리자용 일괄소등 원격제어 사용안할 시
  5928. switch (curState) {
  5929. case WallpadStatusData.ALARM_NONE:
  5930. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5931. if (mIGW200.checkSensorforOutmode()) {
  5932. Common.SendAppFinishReqBR(getApplicationContext());
  5933. Intent intent = new Intent();
  5934. intent.setAction(define.NOTIFY_ACNAME);
  5935. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5936. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  5937. getApplicationContext().sendBroadcast(intent);
  5938. SendBR = true;
  5939. }
  5940. else {
  5941. SendBR = false;
  5942. }
  5943. }
  5944. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5945. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5946. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  5947. if (mIGW300.checkSensorforOutmode()) {
  5948. Common.SendAppFinishReqBR(getApplicationContext());
  5949. Intent intent = new Intent();
  5950. intent.setAction(define.NOTIFY_ACNAME);
  5951. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5952. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  5953. getApplicationContext().sendBroadcast(intent);
  5954. SendBR = true;
  5955. }
  5956. else {
  5957. SendBR = false;
  5958. }
  5959. }
  5960. else {
  5961. if (checkSensorforOutmode()) {
  5962. Common.SendAppFinishReqBR(getApplicationContext());
  5963. Intent intent = new Intent();
  5964. intent.setAction(define.NOTIFY_ACNAME);
  5965. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  5966. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  5967. getApplicationContext().sendBroadcast(intent);
  5968. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  5969. SendBR = true;
  5970. }
  5971. else {
  5972. SendBR = false;
  5973. }
  5974. }
  5975. break;
  5976. default:
  5977. break;
  5978. }
  5979. }
  5980. else {
  5981. // 관리자용 일괄소등 원격제어 사용 시
  5982. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  5983. SendBR = true;
  5984. }
  5985. }
  5986. }
  5987. else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  5988. int getStatus = SetData.GetAlarmStatus();
  5989. switch (getStatus) {
  5990. case WallpadStatusData.GUARD_IN:
  5991. status = "occupied";
  5992. break;
  5993. case WallpadStatusData.GUARD_OUT:
  5994. status = "unoccupied";
  5995. break;
  5996. case WallpadStatusData.ALARM_NONE:
  5997. status = "normal";
  5998. break;
  5999. case WallpadStatusData.ALARM_ARISE:
  6000. status = "emergency";
  6001. break;
  6002. default:
  6003. break;
  6004. }
  6005. retStr+=("\"ok\">\r\n ");
  6006. retStr+=" <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6007. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6008. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6009. retStr += " <status_info unit_num=\"null\" unit_status=\""+status+"\" />\r\n </service>\r\n</imap>\r\n";
  6010. return retStr;
  6011. }
  6012. if (!SendBR) {
  6013. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6014. SetData.closeDB();
  6015. return retStr;
  6016. }
  6017. else {
  6018. try { Thread.sleep(1000); }
  6019. catch (RuntimeException re) {
  6020. LogUtil.errorLogInfo("", TAG, re);
  6021. }
  6022. catch (Exception e){
  6023. LogUtil.errorLogInfo("", TAG, e);
  6024. }
  6025. int getStatus = SetData.GetAlarmStatus();
  6026. switch (getStatus) {
  6027. case WallpadStatusData.GUARD_IN:
  6028. status = "occupied";
  6029. break;
  6030. case WallpadStatusData.GUARD_OUT:
  6031. status = "unoccupied";
  6032. break;
  6033. case WallpadStatusData.ALARM_NONE:
  6034. status = "normal";
  6035. break;
  6036. case WallpadStatusData.ALARM_ARISE:
  6037. status = "emergency";
  6038. break;
  6039. }
  6040. }
  6041. retStr+="\"ok\">\r\n";
  6042. retStr+=" <target name=\"" + accmode.target+"\" id=\""+accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6043. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6044. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6045. retStr += " <status_info unit_num=\"null\" unit_status=\""+status+"\" />\r\n </service>\r\n</imap>\r\n";
  6046. SetData.closeDB();
  6047. return retStr;
  6048. } catch (RuntimeException re) {
  6049. LogUtil.errorLogInfo("", TAG, re);
  6050. return null;
  6051. }
  6052. catch (Exception e) {
  6053. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6054. //e.printStackTrace();
  6055. LogUtil.errorLogInfo("", TAG, e);
  6056. return null;
  6057. }
  6058. }
  6059. public String iCMDProcCurtainControl(Document ele) {
  6060. return " ";
  6061. }
  6062. public String iCMDProcSDPLightControl(Document ele) {
  6063. try {
  6064. String retStr = CheckiCMDProc("remote_access_light");
  6065. if (retStr != null) return retStr;
  6066. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6067. String target= "null", tid= "null", msgno= "null";
  6068. NodeList items = ele.getElementsByTagName("target");
  6069. Node item = items.item(0);
  6070. if (item != null) {
  6071. NamedNodeMap attrs = item.getAttributes();
  6072. for (int j = 0; j< attrs.getLength(); j++) {
  6073. Node attr = attrs.item(j);
  6074. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6075. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6076. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6077. }
  6078. }
  6079. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6080. if (NewServerUse()) {
  6081. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6082. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6083. }
  6084. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6085. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6086. if(energymetercmd==null) return null;
  6087. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6088. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6089. if(energymeter == null) return null;
  6090. if (energymeter!=null && (energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6091. retStr += "result=\"ok\">\r\n" +
  6092. " <action>\"status\"</action>\r\n" +
  6093. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6094. for (int i=0 ; i< energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6095. 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");
  6096. }
  6097. retStr+="\r\n</service>\r\n</imap>";
  6098. }
  6099. else {
  6100. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6101. }
  6102. }
  6103. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6104. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6105. num--;
  6106. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6107. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6108. if(energymeter == null) return null;
  6109. if (energymeter!=null && energymeter.SetLightOnOff( (byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6110. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6111. retStr += "result=\"ok\">\r\n" +
  6112. " <action>\"control\"</action>\r\n" +
  6113. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6114. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6115. 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");
  6116. }
  6117. retStr+="\r\n</service>\r\n</imap>";
  6118. }
  6119. else {
  6120. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6121. }
  6122. }
  6123. else {
  6124. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6125. }
  6126. }
  6127. else {
  6128. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6129. }
  6130. energymetercmd = null;
  6131. return retStr;
  6132. } catch (RuntimeException re) {
  6133. LogUtil.errorLogInfo("", TAG, re);
  6134. return null;
  6135. }
  6136. catch (Exception e) {
  6137. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6138. //e.printStackTrace();
  6139. LogUtil.errorLogInfo("", TAG, e);
  6140. return null;
  6141. }
  6142. }
  6143. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6144. try {
  6145. String retStr = CheckiCMDProc("remote_access_light");
  6146. if (retStr != null) return retStr;
  6147. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6148. String target= "null", tid= "null", msgno= "null";
  6149. NodeList items = ele.getElementsByTagName("target");
  6150. Node item = items.item(0);
  6151. if (item != null) {
  6152. NamedNodeMap attrs = item.getAttributes();
  6153. for (int j = 0; j< attrs.getLength(); j++) {
  6154. Node attr = attrs.item(j);
  6155. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6156. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6157. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6158. }
  6159. }
  6160. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6161. if (NewServerUse()) {
  6162. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6163. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6164. }
  6165. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6166. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6167. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6168. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6169. if (energymeter!=null&& (energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6170. retStr += "result=\"ok\">\r\n" +
  6171. " <action>\"status\"</action>\r\n" +
  6172. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6173. for (int i=0 ; i< energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6174. 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");
  6175. }
  6176. retStr+="\r\n</service>\r\n</imap>";
  6177. }
  6178. else {
  6179. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6180. }
  6181. }
  6182. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6183. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6184. num--;
  6185. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6186. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6187. if (energymeter!=null && energymeter.SetLightOnOff( (byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6188. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6189. retStr += "result=\"ok\">\r\n" +
  6190. " <action>\"control\"</action>\r\n" +
  6191. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6192. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6193. 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");
  6194. }
  6195. retStr+="\r\n</service>\r\n</imap>";
  6196. }
  6197. else {
  6198. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6199. }
  6200. }
  6201. else {
  6202. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6203. }
  6204. }
  6205. else {
  6206. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6207. }
  6208. energymetercmd = null;
  6209. return retStr;
  6210. } catch (RuntimeException re) {
  6211. LogUtil.errorLogInfo("", TAG, re);
  6212. return null;
  6213. }
  6214. catch (Exception e) {
  6215. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6216. //e.printStackTrace();
  6217. LogUtil.errorLogInfo("", TAG, e);
  6218. return null;
  6219. }
  6220. }
  6221. public String iCMDProcLightControl(Document ele) {
  6222. try {
  6223. String retStr = CheckiCMDProc("remote_access_light");
  6224. if (retStr != null) return retStr;
  6225. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6226. String target= "null", tid= "null", msgno= "null";
  6227. NodeList items = ele.getElementsByTagName("target");
  6228. Node item = items.item(0);
  6229. if (item != null) {
  6230. NamedNodeMap attrs = item.getAttributes();
  6231. for (int j = 0; j< attrs.getLength(); j++) {
  6232. Node attr = attrs.item(j);
  6233. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6234. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6235. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6236. }
  6237. }
  6238. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6239. if (NewServerUse()) {
  6240. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6241. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6242. }
  6243. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6244. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6245. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6246. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6247. if (bSmartLightAsNormalLight) {
  6248. if (mSdbAPI != null) {
  6249. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6250. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6251. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6252. retStr += "result=\"ok\">\r\n" +
  6253. " <action>\"status\"</action>\r\n";
  6254. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6255. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount +"\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6256. }
  6257. else {
  6258. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount +"\"/>\r\n";
  6259. }
  6260. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6261. 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");
  6262. }
  6263. retStr+=" </service>\r\n</imap>";
  6264. }
  6265. else {
  6266. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6267. }
  6268. }
  6269. else {
  6270. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6271. }
  6272. }
  6273. else {
  6274. if (mMultiSwitchAPI != null) {
  6275. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  6276. if (nResult == 0) {
  6277. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6278. retStr += "result=\"ok\">\r\n" +
  6279. " <action>\"status\"</action>\r\n";
  6280. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6281. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6282. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt +"\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6283. }
  6284. else {
  6285. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt +"\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6286. }
  6287. }
  6288. else {
  6289. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt +"\"/>\r\n";
  6290. }
  6291. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6292. 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");
  6293. }
  6294. retStr+=" </service>\r\n</imap>";
  6295. }
  6296. else {
  6297. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6298. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6299. }
  6300. }
  6301. else {
  6302. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6303. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6304. }
  6305. }
  6306. else {
  6307. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  6308. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6309. }
  6310. }
  6311. }
  6312. else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  6313. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6314. boolean OnOff = false;
  6315. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6316. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  6317. if (bSmartLightAsNormalLight) {
  6318. if (mSdbAPI != null) {
  6319. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6320. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  6321. if (ret >= 0) {
  6322. retStr += "result=\"ok\">\r\n" +
  6323. " <action>\"status\"</action>\r\n" +
  6324. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6325. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6326. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6327. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6328. 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");
  6329. }
  6330. retStr += " </service>\r\n</imap>";
  6331. }
  6332. else {
  6333. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6334. }
  6335. }
  6336. else {
  6337. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6338. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  6339. if (ret >= 0) {
  6340. retStr += "result=\"ok\">\r\n" +
  6341. " <action>\"status\"</action>\r\n" +
  6342. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6343. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6344. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6345. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6346. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  6347. 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");
  6348. }
  6349. retStr += " </service>\r\n</imap>";
  6350. }
  6351. else {
  6352. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6353. }
  6354. }
  6355. }
  6356. else {
  6357. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6358. }
  6359. }
  6360. else {
  6361. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6362. if(mMultiSwitchAPI!=null)
  6363. {
  6364. int nResultRefresh = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  6365. if (nResultRefresh == 0) {
  6366. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6367. if (nCtrlResult == 0) {
  6368. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  6369. if (nResult == 0) {
  6370. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6371. retStr += "result=\"ok\">\r\n" +
  6372. " <action>\"status\"</action>\r\n" +
  6373. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6374. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  6375. 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");
  6376. }
  6377. retStr += " </service>\r\n</imap>";
  6378. }
  6379. else {
  6380. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6381. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6382. }
  6383. }
  6384. else {
  6385. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6386. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6387. }
  6388. }
  6389. else {
  6390. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6391. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6392. }
  6393. }
  6394. else {
  6395. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6396. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6397. }
  6398. }
  6399. }
  6400. else {
  6401. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6402. if(mMultiSwitchAPI!=null)
  6403. {
  6404. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6405. if (nCtrlResult == 0) {
  6406. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  6407. if (nResult == 0) {
  6408. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6409. retStr += "result=\"ok\">\r\n" +
  6410. " <action>\"status\"</action>\r\n" +
  6411. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6412. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6413. 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");
  6414. }
  6415. retStr += " </service>\r\n</imap>";
  6416. }
  6417. else {
  6418. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6419. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6420. }
  6421. }
  6422. else {
  6423. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6424. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6425. }
  6426. }
  6427. else {
  6428. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6429. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6430. }
  6431. }
  6432. }
  6433. }
  6434. }
  6435. else {
  6436. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6437. }
  6438. }
  6439. else {
  6440. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6441. }
  6442. MSlightcmd = null;
  6443. return retStr;
  6444. } catch (RuntimeException re) {
  6445. LogUtil.errorLogInfo("", TAG, re);
  6446. return null;
  6447. }
  6448. catch (Exception e) {
  6449. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  6450. //e.printStackTrace();
  6451. LogUtil.errorLogInfo("", TAG, e);
  6452. return null;
  6453. }
  6454. }
  6455. public String iCMDProcSDPSmartLightControl(Document ele) {
  6456. try {
  6457. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6458. String retStr = CheckiCMDProc("remote_access_smartlight");
  6459. if (retStr != null) return retStr;
  6460. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  6461. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6462. if (NewServerUse()) {
  6463. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  6464. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6465. }
  6466. if (mSdb_LivingRoomLightAPI == null) {
  6467. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6468. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  6469. return retStr;
  6470. }
  6471. if (mSdbAPI == null) {
  6472. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6473. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  6474. return retStr;
  6475. }
  6476. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  6477. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6478. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  6479. return retStr;
  6480. }
  6481. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  6482. if (mSdbAPI.Refresh((byte)0x00, (byte)i) != 0) {
  6483. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6484. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  6485. return retStr;
  6486. }
  6487. }
  6488. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6489. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  6490. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  6491. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  6492. retStr += " result=\"ok\">\r\n";
  6493. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6494. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6495. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  6496. for (int i = 0; i < nTotalLightCnt; i++) {
  6497. if (i == 0) {
  6498. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6499. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  6500. String status_power = "off", status_dim = "null", status_color = "null";
  6501. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  6502. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6503. }
  6504. else {
  6505. status_power = "null";
  6506. }
  6507. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  6508. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  6509. }
  6510. else {
  6511. status_dim = "null";
  6512. }
  6513. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  6514. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  6515. }
  6516. else {
  6517. status_color = "null";
  6518. }
  6519. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6520. }
  6521. retStr += " </status_map>\r\n";
  6522. }
  6523. else {
  6524. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  6525. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  6526. String status_power = "off", status_dim = "null", status_color = "null";
  6527. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  6528. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6529. }
  6530. else {
  6531. status_power = "null";
  6532. }
  6533. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  6534. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  6535. }
  6536. else {
  6537. status_dim = "null";
  6538. }
  6539. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  6540. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  6541. }
  6542. else {
  6543. status_color = "null";
  6544. }
  6545. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6546. }
  6547. retStr += " </status_map>\r\n";
  6548. }
  6549. }
  6550. retStr += " </service>\r\n</imap>\r\n";
  6551. }
  6552. else {
  6553. int nDevNo = 0;
  6554. try {
  6555. nDevNo = Integer.parseInt(lightcmd.devnum);
  6556. } catch (RuntimeException re) {
  6557. LogUtil.errorLogInfo("", TAG, re);
  6558. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6559. return retStr;
  6560. }
  6561. catch (Exception e) {
  6562. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  6563. //e.printStackTrace();
  6564. LogUtil.errorLogInfo("", TAG, e);
  6565. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6566. return retStr;
  6567. }
  6568. if ((nDevNo - 1) > nTotalLightCnt) {
  6569. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  6570. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6571. return retStr;
  6572. }
  6573. retStr += " result=\"ok\">\r\n";
  6574. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6575. retStr += " <action>\"status\"</action>\r\n";
  6576. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6577. if (nDevNo == 1) {
  6578. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6579. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  6580. String status_power = "off", status_dim = "null", status_color = "null";
  6581. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  6582. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6583. }
  6584. else {
  6585. status_power = "null";
  6586. }
  6587. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  6588. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  6589. }
  6590. else {
  6591. status_dim = "null";
  6592. }
  6593. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  6594. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  6595. }
  6596. else {
  6597. status_color = "null";
  6598. }
  6599. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6600. }
  6601. retStr += " </status_map>\r\n";
  6602. }
  6603. else {
  6604. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\"null\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  6605. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  6606. String status_power = "off", status_dim = "null", status_color = "null";
  6607. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  6608. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6609. }
  6610. else {
  6611. status_power = "null";
  6612. }
  6613. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  6614. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  6615. }
  6616. else {
  6617. status_dim = "null";
  6618. }
  6619. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  6620. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  6621. }
  6622. else {
  6623. status_color = "null";
  6624. }
  6625. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6626. }
  6627. retStr += " </status_map>\r\n";
  6628. }
  6629. retStr += " </service>\r\n</imap>\r\n";
  6630. }
  6631. }
  6632. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  6633. int nResult = 0;
  6634. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  6635. NodeList items = ele.getElementsByTagName("params");
  6636. Node item = items.item(0);
  6637. if (item != null) {
  6638. NamedNodeMap attrs = item.getAttributes();
  6639. for (int j = 0; j< attrs.getLength(); j++) {
  6640. Node attr = attrs.item(j);
  6641. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  6642. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  6643. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  6644. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  6645. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  6646. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  6647. }
  6648. }
  6649. if (dev_num.equalsIgnoreCase("all")) {
  6650. retStr += " result=\"ok\">\r\n";
  6651. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6652. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6653. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  6654. for (int i = 0; i < nTotalLightCnt; i++) {
  6655. if (i == 0) {
  6656. mSdb_LivingRoomLightAPI.SetLight((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6657. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6658. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6659. // if (!unit_status.equalsIgnoreCase("null")) {
  6660. // mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6661. // }
  6662. //
  6663. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6664. // mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6665. // }
  6666. //
  6667. // if (!unit_color.equalsIgnoreCase("null")) {
  6668. // mSdb_LivingRoomLightAPI.SetLightColor((byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6669. // }
  6670. }
  6671. else {
  6672. mSdbAPI.SetLight((byte) (i - 1), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6673. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6674. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6675. // if (!unit_status.equalsIgnoreCase("null")) {
  6676. // mSdbAPI.SetLightOnOff((byte) (i - 1), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6677. // }
  6678. //
  6679. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6680. // mSdbAPI.SetLightDimming((byte) (i - 1), (byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6681. // }
  6682. //
  6683. // if (!unit_color.equalsIgnoreCase("null")) {
  6684. // mSdbAPI.SetLightColor((byte) (i - 1), (byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6685. // }
  6686. }
  6687. }
  6688. mSdb_LivingRoomLightAPI.Refresh();
  6689. mSdbAPI.Refresh((byte) 0xFF, (byte) 0xFF);
  6690. for (int i = 0; i < nTotalLightCnt; i++) {
  6691. if (i == 0) {
  6692. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6693. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  6694. String status_power = "off", status_dim = "null", status_color = "null";
  6695. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  6696. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6697. }
  6698. else {
  6699. status_power = "null";
  6700. }
  6701. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  6702. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  6703. }
  6704. else {
  6705. status_dim = "null";
  6706. }
  6707. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  6708. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  6709. }
  6710. else {
  6711. status_color = "null";
  6712. }
  6713. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6714. }
  6715. retStr += " </status_map>\r\n";
  6716. }
  6717. else {
  6718. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ (i + 1) + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  6719. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  6720. String status_power = "off", status_dim = "null", status_color = "null";
  6721. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  6722. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6723. }
  6724. else {
  6725. status_power = "null";
  6726. }
  6727. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  6728. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  6729. }
  6730. else {
  6731. status_dim = "null";
  6732. }
  6733. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  6734. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  6735. }
  6736. else {
  6737. status_color = "null";
  6738. }
  6739. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6740. }
  6741. retStr += " </status_map>\r\n";
  6742. }
  6743. }
  6744. retStr += " </service>\r\n</imap>\r\n";
  6745. }
  6746. else {
  6747. int nDevNo = 0;
  6748. int nUnitNo = 0;
  6749. try {
  6750. nDevNo = Integer.parseInt(dev_num);
  6751. } catch (RuntimeException re) {
  6752. LogUtil.errorLogInfo("", TAG, re);
  6753. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6754. return retStr;
  6755. }
  6756. catch (Exception e) {
  6757. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  6758. //e.printStackTrace();
  6759. LogUtil.errorLogInfo("", TAG, e);
  6760. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6761. return retStr;
  6762. }
  6763. if ((nDevNo - 1) > nTotalLightCnt) {
  6764. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  6765. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6766. return retStr;
  6767. }
  6768. retStr += " result=\"ok\">\r\n";
  6769. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6770. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6771. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6772. if (unit_num.equalsIgnoreCase("all")) {
  6773. if (nDevNo == 1) {
  6774. mSdb_LivingRoomLightAPI.SetLight((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6775. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6776. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6777. // if (!unit_status.equalsIgnoreCase("null")) {
  6778. // mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6779. // }
  6780. //
  6781. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6782. // mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6783. // }
  6784. //
  6785. // if (!unit_color.equalsIgnoreCase("null")) {
  6786. // mSdb_LivingRoomLightAPI.SetLightColor((byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6787. // }
  6788. }
  6789. else {
  6790. mSdbAPI.SetLight((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false,
  6791. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6792. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6793. // if (!unit_status.equalsIgnoreCase("null")) {
  6794. // mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  6795. // }
  6796. //
  6797. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6798. // mSdbAPI.SetLightDimming((byte) (nDevNo -2), (byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  6799. // }
  6800. //
  6801. // if (!unit_color.equalsIgnoreCase("null")) {
  6802. // mSdbAPI.SetLightColor((byte) (nDevNo -2), (byte) 0xFF, (byte) Integer.parseInt(unit_color));
  6803. // }
  6804. }
  6805. }
  6806. else {
  6807. try {
  6808. nUnitNo = Integer.parseInt(unit_num);
  6809. } catch (RuntimeException re) {
  6810. LogUtil.errorLogInfo("", TAG, re);
  6811. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6812. return retStr;
  6813. }
  6814. catch (Exception e) {
  6815. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  6816. //e.printStackTrace();
  6817. LogUtil.errorLogInfo("", TAG, e);
  6818. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6819. return retStr;
  6820. }
  6821. if (nDevNo == 1) {
  6822. mSdb_LivingRoomLightAPI.SetLight((byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false,
  6823. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6824. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6825. // if (!unit_status.equalsIgnoreCase("null")) {
  6826. // mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  6827. // }
  6828. //
  6829. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6830. // mSdb_LivingRoomLightAPI.SetLightDimming((byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_dimming));
  6831. // }
  6832. //
  6833. // if (!unit_color.equalsIgnoreCase("null")) {
  6834. // mSdb_LivingRoomLightAPI.SetLightColor((byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_color));
  6835. // }
  6836. }
  6837. else {
  6838. mSdbAPI.SetLight((byte) (nDevNo -2), (byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false,
  6839. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  6840. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  6841. // if (!unit_status.equalsIgnoreCase("null")) {
  6842. // mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) (nUnitNo - 1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  6843. // }
  6844. //
  6845. // if (!unit_dimming.equalsIgnoreCase("null")) {
  6846. // mSdbAPI.SetLightDimming((byte) (nDevNo -2), (byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_dimming));
  6847. // }
  6848. //
  6849. // if (!unit_color.equalsIgnoreCase("null")) {
  6850. // mSdbAPI.SetLightColor((byte) (nDevNo -2), (byte) (nUnitNo - 1), (byte) Integer.parseInt(unit_color));
  6851. // }
  6852. }
  6853. }
  6854. if (nDevNo == 1) {
  6855. mSdb_LivingRoomLightAPI.Refresh();
  6856. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6857. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  6858. String status_power = "off", status_dim = "null", status_color = "null";
  6859. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  6860. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6861. }
  6862. else {
  6863. status_power = "null";
  6864. }
  6865. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  6866. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  6867. }
  6868. else {
  6869. status_dim = "null";
  6870. }
  6871. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  6872. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  6873. }
  6874. else {
  6875. status_color = "null";
  6876. }
  6877. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6878. }
  6879. retStr += " </status_map>\r\n";
  6880. }
  6881. else {
  6882. mSdbAPI.Refresh((byte) 0xFF, (byte) 0xFF);
  6883. retStr += " <status_map dev_num=\""+ nDevNo + "\" dev_mode=\"null\" dev_name=\""+ nDevNo + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  6884. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  6885. String status_power = "off", status_dim = "null", status_color = "null";
  6886. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  6887. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  6888. }
  6889. else {
  6890. status_power = "null";
  6891. }
  6892. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  6893. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  6894. }
  6895. else {
  6896. status_dim = "null";
  6897. }
  6898. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  6899. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  6900. }
  6901. else {
  6902. status_color = "null";
  6903. }
  6904. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  6905. }
  6906. retStr += " </status_map>\r\n";
  6907. }
  6908. retStr += " </service>\r\n</imap>\r\n";
  6909. }
  6910. }
  6911. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  6912. int nResult = 0;
  6913. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  6914. NodeList items = ele.getElementsByTagName("params");
  6915. Node item = items.item(0);
  6916. if (item != null) {
  6917. NamedNodeMap attrs = item.getAttributes();
  6918. for (int j = 0; j< attrs.getLength(); j++) {
  6919. Node attr = attrs.item(j);
  6920. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  6921. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  6922. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  6923. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  6924. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  6925. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  6926. }
  6927. }
  6928. if (dev_num.equalsIgnoreCase("all")) {
  6929. retStr += " result=\"ok\">\r\n";
  6930. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6931. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6932. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6933. if (!dev_mode.equals("null")) mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  6934. retStr += " <status_map dev_num=\"1\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"1\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6935. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  6936. retStr += " </service>\r\n</imap>\r\n";
  6937. }
  6938. else {
  6939. int nDevNo = 0;
  6940. try {
  6941. nDevNo = Integer.parseInt(dev_num);
  6942. } catch (RuntimeException re) {
  6943. LogUtil.errorLogInfo("", TAG, re);
  6944. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6945. return retStr;
  6946. }
  6947. catch (Exception e) {
  6948. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  6949. //e.printStackTrace();
  6950. LogUtil.errorLogInfo("", TAG, e);
  6951. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6952. return retStr;
  6953. }
  6954. if (nDevNo != 1) {
  6955. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  6956. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6957. return retStr;
  6958. }
  6959. retStr += " result=\"ok\">\r\n";
  6960. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  6961. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  6962. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  6963. if (!dev_mode.equals("null")) mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  6964. retStr += " <status_map dev_num=\"1\" dev_mode=\""+ mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"1\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  6965. retStr += " </service>\r\n</imap>\r\n";
  6966. }
  6967. }
  6968. else {
  6969. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6970. }
  6971. lightcmd = null;
  6972. return retStr;
  6973. } catch (RuntimeException re) {
  6974. LogUtil.errorLogInfo("", TAG, re);
  6975. return null;
  6976. }
  6977. catch (Exception e) {
  6978. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  6979. //e.printStackTrace();
  6980. LogUtil.errorLogInfo("", TAG, e);
  6981. return null;
  6982. }
  6983. }
  6984. public String iCMDProcLivingLightControl(Document ele) {
  6985. try {
  6986. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6987. String retStr = CheckiCMDProc("remote_access_livinglight");
  6988. if (retStr != null) return retStr;
  6989. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  6990. String target= "null", tid= "null", msgno= "null";
  6991. NodeList items = ele.getElementsByTagName("target");
  6992. Node item = items.item(0);
  6993. if (item != null) {
  6994. NamedNodeMap attrs = item.getAttributes();
  6995. for (int j = 0; j< attrs.getLength(); j++) {
  6996. Node attr = attrs.item(j);
  6997. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6998. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6999. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7000. }
  7001. }
  7002. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7003. if (NewServerUse()) {
  7004. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7005. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7006. }
  7007. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7008. if (bSmartLightAsNormalLight) {
  7009. if (mSdb_LivingRoomLightAPI != null) {
  7010. mSdb_LivingRoomLightAPI.Refresh();
  7011. 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";
  7012. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7013. 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");
  7014. }
  7015. retStr+=" </service>\r\n</imap>\r\n";
  7016. }
  7017. else {
  7018. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7019. }
  7020. }
  7021. else {
  7022. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  7023. if(lightCTR!=null)
  7024. {
  7025. if (lightCTR.Refresh(false)==0) {
  7026. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+ lightcmd.devnum +"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7027. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7028. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7029. }
  7030. retStr+=" </service>\r\n</imap>\r\n";
  7031. }
  7032. else {
  7033. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7034. }
  7035. }
  7036. }
  7037. }
  7038. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7039. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  7040. boolean OnOff = false;
  7041. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  7042. if (bSmartLightAsNormalLight) {
  7043. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  7044. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  7045. if (ret >= 0) {
  7046. ret = mSdb_LivingRoomLightAPI.Refresh();
  7047. if (ret >= 0) {
  7048. 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";
  7049. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7050. 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");
  7051. }
  7052. retStr += " </service>\r\n</imap>\r\n";
  7053. } else {
  7054. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7055. }
  7056. }
  7057. else {
  7058. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7059. }
  7060. }
  7061. else {
  7062. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  7063. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  7064. if (ret >= 0) {
  7065. ret = mSdb_LivingRoomLightAPI.Refresh();
  7066. if (ret >= 0) {
  7067. 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";
  7068. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7069. 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");
  7070. }
  7071. retStr += " </service>\r\n</imap>\r\n";
  7072. } else {
  7073. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7074. }
  7075. }
  7076. else {
  7077. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7078. }
  7079. }
  7080. }
  7081. else {
  7082. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  7083. if(lightCTR!=null)
  7084. {
  7085. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  7086. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  7087. if (ret >= 0) {
  7088. ret = lightCTR.Refresh(false);
  7089. if (ret >= 0) {
  7090. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  7091. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  7092. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7093. }
  7094. retStr += " </service>\r\n</imap>\r\n";
  7095. }
  7096. else {
  7097. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7098. }
  7099. }
  7100. else {
  7101. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7102. }
  7103. }
  7104. else {
  7105. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  7106. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  7107. if (ret >= 0) {
  7108. ret = lightCTR.Refresh(false);
  7109. if (ret >= 0) {
  7110. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  7111. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  7112. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7113. }
  7114. retStr += " </service>\r\n</imap>\r\n";
  7115. }
  7116. else {
  7117. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7118. }
  7119. }
  7120. else {
  7121. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7122. }
  7123. }
  7124. }
  7125. }
  7126. }
  7127. else {
  7128. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7129. }
  7130. }
  7131. else {
  7132. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7133. }
  7134. lightcmd = null;
  7135. return retStr;
  7136. } catch (RuntimeException re) {
  7137. LogUtil.errorLogInfo("", TAG, re);
  7138. return null;
  7139. }
  7140. catch (Exception e) {
  7141. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  7142. //e.printStackTrace();
  7143. LogUtil.errorLogInfo("", TAG, e);
  7144. return null;
  7145. }
  7146. }
  7147. public String iCMDProc_I_LightControl(Document ele) {
  7148. try {
  7149. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7150. String retStr = CheckiCMDProc("remote_access_livinglight");
  7151. if (retStr != null) return retStr;
  7152. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  7153. String target= "null", tid= "null", msgno= "null";
  7154. NodeList items = ele.getElementsByTagName("target");
  7155. Node item = items.item(0);
  7156. if (item != null) {
  7157. NamedNodeMap attrs = item.getAttributes();
  7158. for (int j = 0; j< attrs.getLength(); j++) {
  7159. Node attr = attrs.item(j);
  7160. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7161. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7162. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7163. }
  7164. }
  7165. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7166. if (NewServerUse()) {
  7167. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7168. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7169. }
  7170. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  7171. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7172. if (lightCTR!=null && lightCTR.Refresh(false)==0) {
  7173. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7174. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7175. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7176. }
  7177. retStr+=" </service>\r\n</imap>\r\n";
  7178. }
  7179. else {
  7180. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7181. }
  7182. }
  7183. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7184. if((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  7185. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  7186. int result = -999;
  7187. if(lightCTR!=null)
  7188. {
  7189. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  7190. result = lightCTR.LightProgramControl((byte)num, (byte)1);
  7191. }
  7192. else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  7193. result = lightCTR.LightProgramControl((byte)num, (byte)0);
  7194. }
  7195. if (result >= 0) {
  7196. // 제어 성공
  7197. try { Thread.sleep(1000);}
  7198. catch (RuntimeException re) {
  7199. LogUtil.errorLogInfo("", TAG, re);
  7200. }
  7201. catch (Exception e) {
  7202. LogUtil.errorLogInfo("", TAG, e);
  7203. }
  7204. lightCTR.Refresh(false);
  7205. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7206. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7207. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7208. }
  7209. retStr+=" </service>\r\n</imap>";
  7210. }
  7211. else {
  7212. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7213. }
  7214. }
  7215. else {
  7216. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7217. }
  7218. }
  7219. else {
  7220. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  7221. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  7222. if (lightCTR!=null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on")?true:false)==0) {
  7223. try { Thread.sleep(1000);}
  7224. catch (RuntimeException re) {
  7225. LogUtil.errorLogInfo("", TAG, re);
  7226. }
  7227. catch (Exception e) {
  7228. LogUtil.errorLogInfo("", TAG, e);
  7229. }
  7230. lightCTR.Refresh(false);
  7231. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7232. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7233. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7234. }
  7235. retStr+=" </service>\r\n</imap>\r\n";
  7236. }
  7237. else {
  7238. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7239. }
  7240. }
  7241. }
  7242. else {
  7243. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  7244. }
  7245. lightcmd = null;
  7246. return retStr;
  7247. } catch (RuntimeException re) {
  7248. LogUtil.errorLogInfo("", TAG, re);
  7249. return null;
  7250. }
  7251. catch (Exception e) {
  7252. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  7253. //e.printStackTrace();
  7254. LogUtil.errorLogInfo("", TAG, e);
  7255. return null;
  7256. }
  7257. }
  7258. public String iCMDProcGASControl(Element ele) {
  7259. try {
  7260. String target= "null", tid= "null", msgno= "null", devnum = "null", ctraction = "null", valvestatus = "null";
  7261. String strResult = CheckiCMDProc("remote_access_gas");
  7262. if (strResult != null) return strResult;
  7263. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  7264. NodeList items = ele.getElementsByTagName("target");
  7265. Node item = items.item(0);
  7266. if (item != null) {
  7267. NamedNodeMap attrs = item.getAttributes();
  7268. for (int j = 0; j< attrs.getLength(); j++) {
  7269. Node attr = attrs.item(j);
  7270. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7271. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7272. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7273. }
  7274. }
  7275. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7276. if (NewServerUse()) {
  7277. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  7278. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7279. }
  7280. NodeList itemsParam = ele.getElementsByTagName("params");
  7281. Node itemParam = itemsParam.item(0);
  7282. if (itemParam != null) {
  7283. NamedNodeMap attrsParam = itemParam.getAttributes();
  7284. for (int j = 0; j < attrsParam.getLength(); j++) {
  7285. Node attr = attrsParam.item(j);
  7286. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  7287. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7288. //unitnum = attr.getNodeValue();
  7289. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) ctraction = attr.getNodeValue();
  7290. }
  7291. }
  7292. NodeList itemsaction = ele.getElementsByTagName("action");
  7293. Node itemaction = itemsaction.item(0);
  7294. Node text = itemaction.getFirstChild();
  7295. String actionTXT = text.getNodeValue();
  7296. GasAPI GasValveCTR = mWallPadAPI.Get_GasController();
  7297. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  7298. actionTXT = trimquotation(actionTXT);
  7299. if (actionTXT.equalsIgnoreCase("status")) {
  7300. // 가스밸브 상태 조회
  7301. if(GasValveCTR!=null)
  7302. {
  7303. int ret = GasValveCTR.Refresh((byte)0, false);
  7304. if (ret < 0) {
  7305. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  7306. return strResult;
  7307. }
  7308. if (GasValveCTR.data.DeviceCnt == 2) {
  7309. GasValveCTR.Refresh((byte)1, false);
  7310. }
  7311. byte GasStatus = GasAPI.GASSTATUS.Close;
  7312. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  7313. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  7314. GasStatus = GasAPI.GASSTATUS.Operation;
  7315. break;
  7316. }
  7317. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  7318. GasStatus = GasAPI.GASSTATUS.Open;
  7319. break;
  7320. }
  7321. }
  7322. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  7323. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  7324. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  7325. else valvestatus = "unknown";
  7326. }
  7327. }
  7328. else if (actionTXT.equalsIgnoreCase("control")) {
  7329. // 가스밸브 콘트롤
  7330. if(GasValveCTR!=null)
  7331. {
  7332. int ret = GasValveCTR.SetClose((byte)0xFF);
  7333. if (ret < 0) {
  7334. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  7335. return strResult;
  7336. }
  7337. ret = GasValveCTR.Refresh((byte)0, false);
  7338. if (ret < 0) {
  7339. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  7340. return strResult;
  7341. }
  7342. if (GasValveCTR.data.DeviceCnt == 2) {
  7343. GasValveCTR.Refresh((byte)1, false);
  7344. }
  7345. byte GasStatus = GasAPI.GASSTATUS.Close;
  7346. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  7347. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  7348. GasStatus = GasAPI.GASSTATUS.Operation;
  7349. break;
  7350. }
  7351. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  7352. GasStatus = GasAPI.GASSTATUS.Open;
  7353. break;
  7354. }
  7355. }
  7356. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  7357. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  7358. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  7359. else valvestatus = "unknown";
  7360. }
  7361. }
  7362. else {
  7363. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  7364. return strResult;
  7365. }
  7366. strResult += "\"ok\" >\r\n";
  7367. strResult += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  7368. strResult += " <action>\""+actionTXT+"\"</action>\r\n";
  7369. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  7370. strResult += " <status_info unit_num=\"gas1\" unit_status=\""+valvestatus+"\"/>\r\n";
  7371. strResult += " </service>\r\n";
  7372. strResult += "</imap> ";
  7373. return strResult;
  7374. } catch (RuntimeException re) {
  7375. LogUtil.errorLogInfo("", TAG, re);
  7376. return null;
  7377. }
  7378. catch (Exception e) {
  7379. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  7380. //e.printStackTrace();
  7381. LogUtil.errorLogInfo("", TAG, e);
  7382. return null;
  7383. }
  7384. }
  7385. private String iCMDProcLightBatchControl(Element ele) {
  7386. try {
  7387. String target= "null", tid= "null", msgno= "null", ctraction = "null", ilgalstatus = "null";
  7388. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  7389. if (retStr != null) return retStr;
  7390. NodeList items = ele.getElementsByTagName("target");
  7391. Node item = items.item(0);
  7392. if (item != null) {
  7393. NamedNodeMap attrs = item.getAttributes();
  7394. for (int j = 0; j < attrs.getLength(); j++) {
  7395. Node attr = attrs.item(j);
  7396. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7397. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7398. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7399. }
  7400. }
  7401. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7402. if (NewServerUse()) {
  7403. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7404. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7405. }
  7406. NodeList itemsParam = ele.getElementsByTagName("params");
  7407. Node itemParam = itemsParam.item(0);
  7408. if (itemParam != null) {
  7409. NamedNodeMap attrsParam = itemParam.getAttributes();
  7410. for (int j = 0; j < attrsParam.getLength(); j++) {
  7411. Node attr = attrsParam.item(j);
  7412. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  7413. ctraction = attr.getNodeValue();
  7414. }
  7415. }
  7416. }
  7417. NodeList itemsaction = ele.getElementsByTagName("action");
  7418. Node itemaction = itemsaction.item(0);
  7419. Node text = itemaction.getFirstChild();
  7420. String actionTXT = text.getNodeValue();
  7421. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  7422. actionTXT = trimquotation(actionTXT);
  7423. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  7424. if (actionTXT.equalsIgnoreCase("status")) {
  7425. // 일괄소등 상태 조회
  7426. int ret = mWallPadAPI.GetBatchSwitchStatus();
  7427. if (ret > 1) {
  7428. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  7429. return retStr;
  7430. }
  7431. if (ret == 0) {
  7432. ilgalstatus = "on";
  7433. }
  7434. else if (ret == 1) {
  7435. ilgalstatus = "off";
  7436. }
  7437. else {
  7438. ilgalstatus = "error";
  7439. }
  7440. }
  7441. else if (actionTXT.equalsIgnoreCase("control")) {
  7442. // 일괄소등 제어
  7443. int ret = -1;
  7444. int status = -1;
  7445. if(ctraction.equals("on") == true) {
  7446. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  7447. status = 0;
  7448. }
  7449. else if(ctraction.equals("off") == true) {
  7450. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  7451. status = 1;
  7452. }
  7453. if (ret < 0) {
  7454. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  7455. return retStr;
  7456. }
  7457. if (status == 0) {
  7458. ilgalstatus = "on";
  7459. }
  7460. else if (status == 1) {
  7461. ilgalstatus = "off";
  7462. }
  7463. else {
  7464. ilgalstatus = "error";
  7465. }
  7466. }
  7467. else {
  7468. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  7469. return retStr;
  7470. }
  7471. retStr += "\"ok\" >\r\n";
  7472. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  7473. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  7474. retStr += " <status_info unit_status=\""+ilgalstatus+"\"/>\r\n </service>\r\n</imap> ";
  7475. return retStr;
  7476. } catch (RuntimeException re) {
  7477. LogUtil.errorLogInfo("", TAG, re);
  7478. return null;
  7479. }
  7480. catch (Exception e) {
  7481. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  7482. //e.printStackTrace();
  7483. LogUtil.errorLogInfo("", TAG, e);
  7484. return null;
  7485. }
  7486. }
  7487. private String iCMDProcEntireLightControl(Document ele) {
  7488. try {
  7489. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  7490. if (retStr != null) return retStr;
  7491. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  7492. String sDong = null;
  7493. String sHo = null;
  7494. String sDevice_Num = null;
  7495. String sSelCtrl_Action = null;
  7496. String sUnselCtrl_Action = null;
  7497. NodeList items = ele.getElementsByTagName("home_info");
  7498. Node item = items.item(0);
  7499. NamedNodeMap attrsParam = item.getAttributes();
  7500. for (int i = 0; i < attrsParam.getLength(); i++) {
  7501. Node attr = attrsParam.item(i);
  7502. if (attr.getNodeName().equalsIgnoreCase("dong"))
  7503. sDong = trimquotation(attr.getNodeValue());
  7504. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  7505. sHo = trimquotation(attr.getNodeValue());
  7506. }
  7507. WallpadStatusData DBMGR = null;
  7508. DBMGR = new WallpadStatusData(getApplicationContext());
  7509. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  7510. DBMGR.closeDB();
  7511. if (mSdb_LivingRoomLightAPI == null) {
  7512. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  7513. retStr += " result=\"fail\" >\r\n";
  7514. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7515. retStr += " </service>\r\n</imap>";
  7516. return retStr;
  7517. }
  7518. if (mSdbAPI == null) {
  7519. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  7520. retStr += " result=\"fail\" >\r\n";
  7521. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7522. retStr += " </service>\r\n</imap>";
  7523. return retStr;
  7524. }
  7525. if ((sDong!=null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo!=null && sHo.equalsIgnoreCase(addc.Ho))) {
  7526. items = ele.getElementsByTagName("sel_ctrlinfo");
  7527. item = items.item(0);
  7528. attrsParam = item.getAttributes();
  7529. for (int i = 0; i < attrsParam.getLength(); i++) {
  7530. Node attr = attrsParam.item(i);
  7531. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7532. sDevice_Num = trimquotation(attr.getNodeValue());
  7533. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  7534. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  7535. }
  7536. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  7537. int result = -1; // 조명 제어 결과
  7538. boolean bLivingLightSel = false; // 거실조명 선택 여부
  7539. // ============================== 선택된 조명 ==============================
  7540. String[] sel_devNum = null;
  7541. if (sDevice_Num!=null && sDevice_Num.contains("light")) {
  7542. if (sDevice_Num.contains("/")) sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  7543. else {
  7544. sel_devNum = new String[1];
  7545. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  7546. }
  7547. }
  7548. if (sel_devNum == null) sel_devNum = new String[0];
  7549. for (int i = 0; i < sel_devNum.length; i++) {
  7550. if (sel_devNum[i].equals("1")) {
  7551. bLivingLightSel = true;
  7552. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  7553. if(sSelCtrl_Action!=null)
  7554. {
  7555. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  7556. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  7557. } else {
  7558. int nColor = 0;
  7559. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  7560. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  7561. if (nColor > 0) {
  7562. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  7563. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  7564. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  7565. }
  7566. }
  7567. // 거실조명 제어 결과
  7568. if (result < 0) {
  7569. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  7570. retStr += " result=\"fail\" >\r\n";
  7571. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7572. retStr += " </service>\r\n</imap>";
  7573. return retStr;
  7574. }
  7575. }
  7576. } else {
  7577. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  7578. if(sSelCtrl_Action!=null)
  7579. {
  7580. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  7581. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  7582. } else {
  7583. int nColor = 0;
  7584. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  7585. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  7586. if (nColor > 0) {
  7587. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  7588. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  7589. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  7590. }
  7591. }
  7592. }
  7593. // 그 외 방 조명 제어 결과
  7594. if (result < 0) {
  7595. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  7596. retStr += " result=\"fail\" >\r\n";
  7597. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7598. retStr += " </service>\r\n</imap>";
  7599. return retStr;
  7600. }
  7601. }
  7602. }
  7603. // ============================== 선택안된 조명 ==============================
  7604. items = ele.getElementsByTagName("unsel_ctrlinfo");
  7605. item = items.item(0);
  7606. attrsParam = item.getAttributes();
  7607. for (int i = 0; i < attrsParam.getLength(); i++) {
  7608. Node attr = attrsParam.item(i);
  7609. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  7610. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  7611. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  7612. }
  7613. if (!bLivingLightSel) {
  7614. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  7615. if(sUnselCtrl_Action!=null)
  7616. {
  7617. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  7618. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  7619. } else {
  7620. int nColor = 0;
  7621. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  7622. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  7623. if (nColor > 0) {
  7624. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  7625. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  7626. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  7627. }
  7628. }
  7629. }
  7630. if (result < 0) {
  7631. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  7632. retStr += " result=\"fail\" >\r\n";
  7633. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7634. retStr += " </service>\r\n</imap>";
  7635. return retStr;
  7636. }
  7637. }
  7638. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  7639. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  7640. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7641. unsel_devNum.add(i + 1);
  7642. }
  7643. for (int i = 0; i < unsel_devNum.size(); i++) {
  7644. for (int j = 0; j < sel_devNum.length; j++) {
  7645. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1) unsel_devNum.remove(i);
  7646. }
  7647. }
  7648. for (int i = 0; i < unsel_devNum.size(); i++) {
  7649. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) -1) + "]");
  7650. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  7651. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  7652. } else {
  7653. int nColor = 0;
  7654. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  7655. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  7656. if (nColor > 0) {
  7657. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  7658. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  7659. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  7660. }
  7661. }
  7662. if (result < 0) {
  7663. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  7664. retStr += " result=\"fail\" >\r\n";
  7665. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7666. retStr += " </service>\r\n</imap>";
  7667. return retStr;
  7668. }
  7669. }
  7670. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  7671. retStr += " result=\"ok\">\r\n";
  7672. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7673. retStr += " </service>\r\n</imap>";
  7674. return retStr;
  7675. } else {
  7676. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  7677. retStr += " result=\"fail\" >\r\n";
  7678. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  7679. retStr += " </service>\r\n</imap>";
  7680. return retStr;
  7681. }
  7682. } catch (RuntimeException re) {
  7683. LogUtil.errorLogInfo("", TAG, re);
  7684. return null;
  7685. }
  7686. catch (Exception e) {
  7687. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  7688. //e.printStackTrace();
  7689. LogUtil.errorLogInfo("", TAG, e);
  7690. return null;
  7691. }
  7692. }
  7693. // 월패드에 원격제어 사용 여부를 확인하다.
  7694. private String CheckiCMDProc(String CMDStr) {
  7695. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  7696. try {
  7697. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  7698. mWallpadStatusData.closeDB();
  7699. if (!bRemoteCtrlEnabled) {
  7700. String retXML = XMLHeader +"<service type=\"reply\" name=\""+CMDStr+"\" result=\"deny\">\r\n"+
  7701. " </service>\r\n</imap>";
  7702. return retXML;
  7703. }
  7704. return null;
  7705. } catch (RuntimeException re) {
  7706. LogUtil.errorLogInfo("", TAG, re);
  7707. mWallpadStatusData.closeDB();
  7708. return null;
  7709. }
  7710. catch (Exception e) {
  7711. mWallpadStatusData.closeDB();
  7712. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  7713. //e.printStackTrace();
  7714. LogUtil.errorLogInfo("", TAG, e);
  7715. return null;
  7716. }
  7717. }
  7718. //메인으로 공지 해야 할 노티 사항을 처리
  7719. public String ProcEventNotify(Element ele) {
  7720. try {
  7721. NodeList items = ele.getElementsByTagName("event");
  7722. Node item = items.item(0);
  7723. Node text = item.getFirstChild();
  7724. String eventTXT = trimquotation(text.getNodeValue());
  7725. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  7726. // 새로운 공지사항 존재
  7727. wakeupLCD();
  7728. Intent intent = new Intent();
  7729. intent.setAction(define.NOTIFY_ACNAME);
  7730. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  7731. getApplicationContext().sendBroadcast(intent);
  7732. }
  7733. else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  7734. // 택배 도착
  7735. wakeupLCD();
  7736. Intent intent = new Intent();
  7737. intent.setAction(define.NOTIFY_ACNAME);
  7738. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  7739. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  7740. intent.putExtra("ITEM",1);
  7741. getApplicationContext().sendBroadcast(intent);
  7742. }
  7743. else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  7744. // 택배 반출
  7745. wakeupLCD();
  7746. Intent intent = new Intent();
  7747. intent.setAction(define.NOTIFY_ACNAME);
  7748. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  7749. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  7750. intent.putExtra("ITEM",0);
  7751. getApplicationContext().sendBroadcast(intent);
  7752. }
  7753. else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  7754. // 등록된 차량 도착
  7755. wakeupLCD();
  7756. // 팝업을 띄우도록 하자
  7757. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  7758. Common.CarInOoutEventBR(getApplicationContext(),"car_in", "");
  7759. }
  7760. else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  7761. // 내려가는 방향의 엘리베이터가 도착함
  7762. if (ElevatorDown != null) {
  7763. ElevatorDown.TimeOutCancel();
  7764. ElevatorDown.ClearElevator();
  7765. }
  7766. Intent intent = new Intent();
  7767. intent.setAction(define.NOTIFY_ACNAME);
  7768. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  7769. getApplicationContext().sendBroadcast(intent);
  7770. }
  7771. else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  7772. // 올라가는 방향의 엘리베이터가 도착함
  7773. if (ElevatorUp != null) {
  7774. ElevatorUp.TimeOutCancel();
  7775. ElevatorUp.ClearElevator();
  7776. }
  7777. Intent intent = new Intent();
  7778. intent.setAction(define.NOTIFY_ACNAME);
  7779. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  7780. getApplicationContext().sendBroadcast(intent);
  7781. }
  7782. else {
  7783. }
  7784. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  7785. "<event> \""+eventTXT+"\" </event>\r\n" + " </service>\r\n </imap> ";
  7786. return returnStr;
  7787. } catch (RuntimeException re) {
  7788. LogUtil.errorLogInfo("", TAG, re);
  7789. return null;
  7790. }
  7791. catch (Exception e) {
  7792. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  7793. //e.printStackTrace();
  7794. LogUtil.errorLogInfo("", TAG, e);
  7795. return null;
  7796. }
  7797. }
  7798. public String GetAttributeVal(Node node, String attname) {
  7799. NamedNodeMap attrs = node.getAttributes();
  7800. for (int j = 0; j < attrs.getLength(); j++) {
  7801. Node attr = attrs.item(j);
  7802. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  7803. }
  7804. return null;
  7805. }
  7806. public class imageFileFilter implements FilenameFilter {
  7807. public boolean accept(File dir, String name ) {
  7808. if (name.endsWith(".jpg") || name.endsWith(".JPG") || name.endsWith(".jpeg") || name.endsWith(".JPEG")||name.endsWith(".png")||name.endsWith(".PNG")||name.endsWith(".gif")||name.endsWith(".GIF")) return true;
  7809. else return false;
  7810. }
  7811. }
  7812. public String ProcCheckEpiceUpload(Document ele) {
  7813. try {
  7814. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  7815. NodeList items = ele.getElementsByTagName("filename");
  7816. Node item = items.item(0);
  7817. Node text = item.getFirstChild();
  7818. String filename = trimquotation(text.getNodeValue());
  7819. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  7820. String duplicate = null;
  7821. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  7822. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  7823. if (!dirInternal.exists()) dirInternal.mkdir();
  7824. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  7825. AddressSet addr = SetData.getAddressMGR();
  7826. if (!dirInternal.exists()) {
  7827. returnStr+=" <homeaddr dong=\""+addr.Dong+"\" ho=\""+addr.Ho+"\"/>\r\n"+
  7828. " <pics space=\""+define.MAX_ALBUM_PICTURE+"\" total=\""+define.MAX_ALBUM_PICTURE+"\" available=\"0\" duplicate=\"new\"/>\r\n"+
  7829. " </service>\r\n</imap>";
  7830. return returnStr;
  7831. }
  7832. imageFileFilter jpegfilter = new imageFileFilter();
  7833. String[] subfile = dirInternal.list(jpegfilter);
  7834. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  7835. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  7836. if (checkFile.exists()) duplicate = "exist";
  7837. else duplicate = "new";
  7838. if(subfile!=null)
  7839. {
  7840. returnStr+=" <homeaddr dong=\""+addr.Dong+"\" ho=\""+addr.Ho+"\"/>\r\n"+
  7841. " <pics space=\""+define.MAX_ALBUM_PICTURE+"\" total=\""+subfile.length+"\" available=\""+(define.MAX_ALBUM_PICTURE-subfile.length)+"\" duplicate=\""+duplicate+"\"/>\r\n"+
  7842. " </service>\r\n</imap>";
  7843. }
  7844. SetData.closeDB();
  7845. return returnStr;
  7846. } catch (RuntimeException re) {
  7847. LogUtil.errorLogInfo("", TAG, re);
  7848. return null;
  7849. }
  7850. catch (Exception e) {
  7851. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  7852. //e.printStackTrace();
  7853. LogUtil.errorLogInfo("", TAG, e);
  7854. return null;
  7855. }
  7856. }
  7857. private void playNotifySound(int nSoundID) {
  7858. try {
  7859. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  7860. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  7861. if (getCompareBSPVersion()) {
  7862. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  7863. }
  7864. else {
  7865. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  7866. }
  7867. boolean NeedPlay = false;
  7868. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  7869. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  7870. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  7871. }
  7872. else {
  7873. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  7874. }
  7875. SetData.closeDB();
  7876. if (NeedPlay) Sound().PlayMent(nSoundID);
  7877. } catch (RuntimeException re) {
  7878. LogUtil.errorLogInfo("", TAG, re);
  7879. }
  7880. catch (Exception e) {
  7881. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  7882. //e.printStackTrace();
  7883. LogUtil.errorLogInfo("", TAG, e);
  7884. }
  7885. }
  7886. private void wakeupLCD() {
  7887. try {
  7888. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  7889. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  7890. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  7891. mIOInterface.ctrlLcdWakeUp();
  7892. } catch (RuntimeException re) {
  7893. LogUtil.errorLogInfo("", TAG, re);
  7894. }
  7895. catch (Exception e) {
  7896. Log.e(TAG, "[Exception] wakeupLCD()");
  7897. //e.printStackTrace();
  7898. LogUtil.errorLogInfo("", TAG, e);
  7899. }
  7900. }
  7901. /**
  7902. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  7903. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  7904. * Jeff, 2020.09.07
  7905. * @return true: LCD backlight On, false: LCD backlight Off
  7906. */
  7907. public boolean checkLCDOnByCMD() {
  7908. try {
  7909. Runtime mRuntime = Runtime.getRuntime();
  7910. Process mProcess;
  7911. String cmd = "getprop persist.sys.lcdcon";
  7912. mProcess = mRuntime.exec(cmd);
  7913. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  7914. String line;
  7915. String strResult = null;
  7916. while ((line = br.readLine()) != null) {
  7917. strResult = line;
  7918. }
  7919. if(strResult!=null)
  7920. {
  7921. if (strResult.equals("0")) {
  7922. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  7923. return true;
  7924. }
  7925. else if (strResult.equals("1")) {
  7926. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  7927. return false;
  7928. }
  7929. else {
  7930. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  7931. return false;
  7932. }
  7933. }
  7934. else
  7935. return false;
  7936. } catch (RuntimeException re) {
  7937. LogUtil.errorLogInfo("", TAG, re);
  7938. return false;
  7939. }
  7940. catch (Exception e) {
  7941. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  7942. //e.printStackTrace();
  7943. LogUtil.errorLogInfo("", TAG, e);
  7944. return false;
  7945. }
  7946. }
  7947. /**
  7948. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  7949. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  7950. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  7951. */
  7952. public boolean getCompareBSPVersion() {
  7953. try {
  7954. StringBuilder strBSPVersion = new StringBuilder();
  7955. StringBuffer sysInfoBuffer = new StringBuffer();
  7956. sysInfoBuffer.append(Build.DISPLAY);
  7957. strBSPVersion.append(sysInfoBuffer.toString());
  7958. String result = strBSPVersion.toString();
  7959. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  7960. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  7961. Date date = simpleDateFormat.parse(result);
  7962. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  7963. if (date.compareTo(standardDate) >= 0) {
  7964. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  7965. return true;
  7966. }
  7967. } catch (RuntimeException re) {
  7968. LogUtil.errorLogInfo("", TAG, re);
  7969. }
  7970. catch (Exception e) {
  7971. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  7972. //e.printStackTrace();
  7973. LogUtil.errorLogInfo("", TAG, e);
  7974. }
  7975. return false;
  7976. }
  7977. public String ProcUpdateWeather(Document ele) {
  7978. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  7979. String nowloc ="";
  7980. String nowlcode="";
  7981. String nowdate="";
  7982. String nowtext="";
  7983. String nowcode="";
  7984. String nowtemp="";
  7985. String nowlo = "", nowhigh = "";
  7986. NodeList items = ele.getElementsByTagName("now");
  7987. Node item = items.item(0);
  7988. if (item == null)
  7989. return resultstr += "\"fail\"/> \r\n </imap>";
  7990. NamedNodeMap attrsParam = item.getAttributes();
  7991. for (int j = 0; j < attrsParam.getLength(); j++) {
  7992. Node attr = attrsParam.item(j);
  7993. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  7994. else if (attr.getNodeName().equalsIgnoreCase("loc_code")) nowlcode = attr.getNodeValue();
  7995. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  7996. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  7997. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  7998. else if (attr.getNodeName().equalsIgnoreCase("temperature")) nowtemp = attr.getNodeValue();
  7999. }
  8000. items = ele.getElementsByTagName("week");
  8001. String weekdate="", weektext="", weekcode="", weeklow="", weekhigh="", weekam="", weekpm = "";
  8002. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8003. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  8004. Weathertbl.InitWeatherTable();
  8005. for (int i = 0; i < items.getLength(); i++) {
  8006. item = items.item(i);
  8007. attrsParam = item.getAttributes();
  8008. for (int j = 0; j < attrsParam.getLength(); j++) {
  8009. Node attr = attrsParam.item(j);
  8010. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  8011. else if (attr.getNodeName().equalsIgnoreCase("text")) weektext = attr.getNodeValue();
  8012. else if (attr.getNodeName().equalsIgnoreCase("code")) weekcode = attr.getNodeValue();
  8013. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  8014. else if (attr.getNodeName().equalsIgnoreCase("high")) weekhigh = attr.getNodeValue();
  8015. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  8016. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  8017. }
  8018. if ( i == 0) {
  8019. nowlo = weeklow;
  8020. nowhigh = weekhigh;
  8021. }
  8022. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  8023. }
  8024. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  8025. Intent intent = new Intent();
  8026. intent.setAction(define.NOTIFY_ACNAME);
  8027. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  8028. intent.putExtra(define.NOTIBR_CONTENT, nowcode+define.DEVCTR_DATA_SPLITER+nowlo+define.DEVCTR_DATA_SPLITER+nowhigh);
  8029. getApplicationContext().sendBroadcast(intent);
  8030. String WeatherVer = nowdate.substring(0,4)+"."+nowdate.substring(4,6)+"."+nowdate.substring(6,8)+"."+nowdate.substring(8,10);
  8031. 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);
  8032. DBMGR.closeDB();
  8033. return resultstr += "\"ok\"/> \r\n </imap>";
  8034. }
  8035. //iMAP update_news 처리
  8036. public String ProcUpdateNews(Document ele) {
  8037. NodeList items = ele.getElementsByTagName("ver_news");
  8038. Node item = items.item(0);
  8039. String strNewsVer = item.getTextContent();
  8040. strNewsVer = trimquotation(strNewsVer);
  8041. String retXML = XMLHeader+"<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n"+
  8042. " <ver_news>\""+strNewsVer+"\"</ver_news>\r\n<service/>\r\n</imap>";
  8043. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8044. String NotiVer = DBMGR.GetNoticeVer();
  8045. int noticeCNT = DBMGR.GetNoticeCNT();
  8046. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  8047. String[] spdt = strNewsVer.split("[.]");
  8048. noticeCNT+=Integer.parseInt(spdt[spdt.length-1]);
  8049. }
  8050. else {
  8051. String[] spdt = strNewsVer.split("[.]");
  8052. int newcnt = Integer.parseInt(spdt[spdt.length-1]);
  8053. spdt = NotiVer.split("[.]");
  8054. newcnt-=Integer.parseInt(spdt[spdt.length-1]);
  8055. noticeCNT+=newcnt;
  8056. }
  8057. Log.d(TAG, "[ProcUpdateNews] News Version : " + strNewsVer);
  8058. DBMGR.SetNoticeVer(strNewsVer);
  8059. DBMGR.SetNoticeCNT(noticeCNT);
  8060. DBMGR.closeDB();
  8061. if (NotiVer.compareTo(strNewsVer) != 0) {
  8062. Intent intent = new Intent();
  8063. intent.setAction(define.NOTIFY_ACNAME);
  8064. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  8065. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  8066. getApplicationContext().sendBroadcast(intent);
  8067. }
  8068. return retXML;
  8069. }
  8070. //iMAP check_lobby_passwd 처리
  8071. public String CheckPassword(Document doc)
  8072. {
  8073. NodeList items = doc.getElementsByTagName("inpasswd");
  8074. Node item = items.item(0);
  8075. Node text = item.getFirstChild();
  8076. String passwd = trimquotation(text.getNodeValue());
  8077. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8078. String settedpasswd = DBMGR.GetUserPW();
  8079. DBMGR.closeDB();
  8080. String retString = XMLHeader;
  8081. Common.DebugLog("================ CheckPassword ================ ");
  8082. Common.DebugLog("Saved Password :"+ settedpasswd);
  8083. Common.DebugLog("Input Password :"+ passwd);
  8084. Common.DebugLog("================ CheckPassword ================ ");
  8085. if (settedpasswd.equals(passwd))
  8086. {
  8087. retString+="<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  8088. }
  8089. else
  8090. {
  8091. retString+="<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>"+passwd+"</wrongpasswd>\r\n</service>";
  8092. }
  8093. retString+="</imap>";
  8094. return retString;
  8095. }
  8096. //schedule_renew 처리
  8097. protected String ProcSchduleRenew(Document doc)
  8098. {
  8099. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n "+
  8100. "<homeaddr dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" /> \r\n </service> \r\n </imap>";
  8101. WallpadScheduleData schedulDB=null;
  8102. try {
  8103. NodeList items = doc.getElementsByTagName("renew_info");
  8104. schedulDB = new WallpadScheduleData(getApplicationContext());
  8105. for(int i= 0 ;i < items.getLength();i++)
  8106. {
  8107. Node item = items.item(i);
  8108. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  8109. NamedNodeMap attrsParam = item.getAttributes();
  8110. String Type="none";
  8111. for(int j=0; j< attrsParam.getLength();j++)
  8112. {
  8113. Node attr = attrsParam.item(j);
  8114. String name = attr.getNodeName();
  8115. String Val = attr.getNodeValue();
  8116. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  8117. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  8118. else if (name.equalsIgnoreCase("rn_type"))
  8119. Type = Val;
  8120. else if (name.equalsIgnoreCase("rn_t_type"))
  8121. SCdata.inqttype = Val;
  8122. else if (name.equalsIgnoreCase("rn_c_type"))
  8123. SCdata.inqctype = Val;
  8124. else if (name.equalsIgnoreCase("rn_a_type"))
  8125. SCdata.inqatype = Val;
  8126. else if (name.equalsIgnoreCase("rn_i_type"))
  8127. SCdata.inqitype = Val;
  8128. else if (name.equalsIgnoreCase("rn_year"))
  8129. SCdata.inqyear = Integer.parseInt(Val);
  8130. else if (name.equalsIgnoreCase("rn_month"))
  8131. SCdata.inqmonth = Integer.parseInt(Val);
  8132. else if (name.equalsIgnoreCase("rn_day"))
  8133. SCdata.inqday = Integer.parseInt(Val);
  8134. else if (name.equalsIgnoreCase("rn_hour"))
  8135. SCdata.inqhour = Integer.parseInt(Val);
  8136. else if (name.equalsIgnoreCase("rn_message"))
  8137. SCdata.inqmsg = Val;
  8138. }
  8139. if (Type.equals("delete"))
  8140. {
  8141. schedulDB.DeleteSchedule(SCdata);
  8142. }
  8143. else if (Type.equals("add"))
  8144. {
  8145. schedulDB.AddSchedule(SCdata);
  8146. }
  8147. else if (Type.equals("change"))
  8148. {
  8149. schedulDB.UpdateSchedule(SCdata);
  8150. }
  8151. }
  8152. schedulDB.closeDB();
  8153. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  8154. // Intent intent = new Intent();
  8155. // intent.setAction(define.NOTIFY_ACNAME);
  8156. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  8157. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  8158. // getApplicationContext().sendBroadcast(intent);
  8159. }
  8160. catch (RuntimeException re) {
  8161. LogUtil.errorLogInfo("", TAG, re);
  8162. if (schedulDB != null) schedulDB.closeDB();
  8163. }
  8164. catch (Exception e)
  8165. {
  8166. //e.printStackTrace();
  8167. LogUtil.errorLogInfo("", TAG, e);
  8168. if (schedulDB != null) schedulDB.closeDB();
  8169. }
  8170. return retXML;
  8171. }
  8172. //schedule_inquiry 처리
  8173. @SuppressWarnings("unused")
  8174. public String ProcSchduleInquiry(Document doc)
  8175. {
  8176. WallpadScheduleData schedulDB=null;
  8177. String retXML;
  8178. int QYear = 0;
  8179. int QMonth = 0;
  8180. try {
  8181. NodeList items = doc.getElementsByTagName("inquiry_time");
  8182. schedulDB = new WallpadScheduleData(getApplicationContext());
  8183. Node item = items.item(0);
  8184. NamedNodeMap attrsParam = item.getAttributes();
  8185. for(int j=0; j< attrsParam.getLength();j++)
  8186. {
  8187. Node attr = attrsParam.item(j);
  8188. if (attr.getNodeName().equalsIgnoreCase("year"))
  8189. QYear = Integer.parseInt(attr.getNodeValue());
  8190. else if (attr.getNodeName().equalsIgnoreCase("month"))
  8191. QMonth = Integer.parseInt(attr.getNodeValue());
  8192. }
  8193. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  8194. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  8195. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  8196. " <inquiry_time year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  8197. " <inquiry_count>"+SCData.size()+"</inquiry_count>\r\n";
  8198. if(SCData != null)
  8199. {
  8200. if (SCData.size()>0)
  8201. {
  8202. for(int i = 0; i<SCData.size(); i++)
  8203. {
  8204. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  8205. 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=\""+
  8206. SCINQDATA.inqyear+"\" inq_month=\""+SCINQDATA.inqmonth+"\" inq_day=\""+SCINQDATA.inqday+"\" inq_hour=\""+SCINQDATA.inqhour+"\" inq_message=\""+SCINQDATA.inqmsg+"\"/>\r\n";
  8207. }
  8208. }
  8209. retXML+="</service>\r\n</imap>";
  8210. }
  8211. else
  8212. {
  8213. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  8214. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  8215. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  8216. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  8217. }
  8218. }
  8219. catch (RuntimeException re) {
  8220. LogUtil.errorLogInfo("", TAG, re);
  8221. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  8222. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  8223. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  8224. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  8225. }
  8226. catch (Exception e)
  8227. {
  8228. //e.printStackTrace();
  8229. LogUtil.errorLogInfo("", TAG, e);
  8230. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  8231. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  8232. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  8233. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  8234. }
  8235. schedulDB.closeDB();
  8236. return retXML;
  8237. }
  8238. public String ProcUpdateSchedule(Element ele, String type)
  8239. {
  8240. String retXML = "";
  8241. return retXML;
  8242. }
  8243. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  8244. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  8245. private void setDefaultLauncher() {
  8246. try
  8247. {
  8248. PackageManager pm = getPackageManager();
  8249. IntentFilter filter = new IntentFilter();
  8250. filter.addAction(Intent.ACTION_MAIN);
  8251. filter.addCategory(Intent.CATEGORY_HOME);
  8252. filter.addCategory(Intent.CATEGORY_DEFAULT);
  8253. Context context = getApplicationContext();
  8254. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  8255. ComponentName[] components = new ComponentName[] {new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  8256. pm.clearPackagePreferredActivities("com.android.launcher");
  8257. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  8258. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  8259. try{Thread.sleep(300);}
  8260. catch (RuntimeException re) {
  8261. LogUtil.errorLogInfo("", TAG, re);
  8262. }
  8263. catch (Exception e){
  8264. LogUtil.errorLogInfo("", TAG, e);
  8265. }
  8266. // 리셋코드 추가
  8267. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  8268. try {
  8269. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  8270. powerMg.reboot(null);
  8271. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  8272. } catch (RuntimeException re) {
  8273. LogUtil.errorLogInfo("", TAG, re);
  8274. }
  8275. catch (Exception e) {
  8276. //e.printStackTrace();
  8277. LogUtil.errorLogInfo("", TAG, e);
  8278. }
  8279. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  8280. } catch (RuntimeException re) {
  8281. LogUtil.errorLogInfo("", TAG, re);
  8282. }
  8283. catch (Exception e) {
  8284. //e.printStackTrace();
  8285. LogUtil.errorLogInfo("", TAG, e);
  8286. }
  8287. }
  8288. public String ProcDeviceReset(Element ele)
  8289. {
  8290. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  8291. "</imap>\r\n";
  8292. NodeList resettype = ele.getElementsByTagName("guidemap");
  8293. Node resettypeItem = resettype.item(0);
  8294. String type = GetAttributeVal(resettypeItem, "type");
  8295. if(type!=null)
  8296. {
  8297. if (type.equals("now"))
  8298. {
  8299. setDefaultLauncher();
  8300. Intent intent = new Intent();
  8301. intent.setAction(define.NOTIFY_ACNAME);
  8302. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  8303. getApplicationContext().sendBroadcast(intent);
  8304. }
  8305. else if (type.equals("disable"))
  8306. {
  8307. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  8308. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE,0,0 );
  8309. SetReset.closeDB();
  8310. }
  8311. else if (type.equals("week") || type.equals("month"))
  8312. {
  8313. int Resettype = type.equals("week")?WallpadStatusData.RESET_WEEK:WallpadStatusData.RESET_MONTH;
  8314. NodeList periodList = ele.getElementsByTagName("period");
  8315. Node perioditem = periodList.item(0);
  8316. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  8317. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  8318. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  8319. SetReset.SetResetSchedule(Resettype,cycle,time );
  8320. SetReset.closeDB();
  8321. }
  8322. }
  8323. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  8324. // Intent intent = new Intent();
  8325. // intent.setAction(define.NOTIFY_ACNAME);
  8326. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  8327. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  8328. // getApplicationContext().sendBroadcast(intent);
  8329. return retXML;
  8330. }
  8331. public String ProcDeviceLiveCheck()
  8332. {
  8333. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  8334. return retXML;
  8335. }
  8336. public String ProcPairingHdevSyncAlarm(Element ele) {
  8337. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  8338. return retXML;
  8339. }
  8340. public String ProcPairingHdevSyncSecurity(Element ele) {
  8341. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  8342. return retXML;
  8343. }
  8344. public String ProcParkInformation(Element ele) {
  8345. try {
  8346. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  8347. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  8348. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  8349. NodeList items = ele.getElementsByTagName("destination");
  8350. Node item = items.item(0);
  8351. Node text;
  8352. NamedNodeMap attrsParam = item.getAttributes();
  8353. for (int j = 0; j < attrsParam.getLength(); j++) {
  8354. Node attr = attrsParam.item(j);
  8355. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  8356. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  8357. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  8358. }
  8359. items = ele.getElementsByTagName("move_info");
  8360. item = items.item(0);
  8361. text = item.getFirstChild();
  8362. strCarMove = trimquotation(text.getNodeValue());
  8363. items = ele.getElementsByTagName("params");
  8364. item = items.item(0);
  8365. attrsParam = item.getAttributes();
  8366. for (int j = 0; j < attrsParam.getLength(); j++) {
  8367. Node attr = attrsParam.item(j);
  8368. if (attr.getNodeName().equalsIgnoreCase("car_num")) strCarNo = trimquotation(attr.getNodeValue());
  8369. else if (attr.getNodeName().equalsIgnoreCase("loc_info")) strCarLocation = trimquotation(attr.getNodeValue());
  8370. else if (attr.getNodeName().equalsIgnoreCase("message")) strMsg = trimquotation(attr.getNodeValue());
  8371. }
  8372. if(strName!=null && strDong!=null && strHo!=null && strCarMove!=null && strCarNo!=null && strCarLocation!=null && strMsg!=null)
  8373. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  8374. try {
  8375. int iTempDong = Integer.parseInt(AddrDong);
  8376. String sTempDong = Integer.toString(iTempDong);
  8377. int iTempHo = Integer.parseInt(AddrHo);
  8378. String sTempHo = Integer.toString(iTempHo);
  8379. if ((strName!=null && strName.equalsIgnoreCase("homedev") == true) && (strDong!=null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo!=null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  8380. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  8381. }
  8382. else {
  8383. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  8384. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  8385. return retXML;
  8386. }
  8387. } catch (RuntimeException re) {
  8388. LogUtil.errorLogInfo("", TAG, re);
  8389. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  8390. return retXML;
  8391. }
  8392. catch (Exception e) {
  8393. //e.printStackTrace();
  8394. LogUtil.errorLogInfo("", TAG, e);
  8395. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  8396. return retXML;
  8397. }
  8398. //DB정보 업데이트!
  8399. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  8400. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  8401. CarDB.closeDB();
  8402. //DB정보 업데이트!
  8403. if (strCarMove.equalsIgnoreCase("in")) {
  8404. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  8405. // 팝업을 띄우도록 하자
  8406. wakeupLCD();
  8407. if (strMsg!=null && strMsg.equalsIgnoreCase("guest")) {
  8408. Intent iIntent = new Intent();
  8409. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  8410. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  8411. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  8412. getApplicationContext().sendBroadcast(iIntent);
  8413. }
  8414. else {
  8415. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  8416. }
  8417. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  8418. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  8419. }
  8420. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  8421. if (strCarMove.equalsIgnoreCase("park")) {
  8422. //주차정보 얻어오도록 intent 알림
  8423. SendGetParkingInfoIntent();
  8424. }
  8425. }
  8426. else {
  8427. //주차정보 얻어오도록 intent 알림
  8428. SendGetParkingInfoIntent();
  8429. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  8430. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  8431. }
  8432. return retXML;
  8433. } catch (RuntimeException re) {
  8434. LogUtil.errorLogInfo("", TAG, re);
  8435. return null;
  8436. }
  8437. catch (Exception e) {
  8438. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  8439. //e.printStackTrace();
  8440. LogUtil.errorLogInfo("", TAG, e);
  8441. return null;
  8442. }
  8443. }
  8444. /**
  8445. * 스마트키 이벤트 수신시 처리
  8446. * **/
  8447. public String ProcSmartKeyEvent(Element ele) {
  8448. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  8449. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  8450. String strName = null, strDong = null, strHo = null, strCnt = null;
  8451. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  8452. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  8453. NodeList items = ele.getElementsByTagName("destination");
  8454. Node item = items.item(0);
  8455. NamedNodeMap attrsParam = item.getAttributes();
  8456. for (int j = 0; j < attrsParam.getLength(); j++) {
  8457. Node attr = attrsParam.item(j);
  8458. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  8459. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  8460. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  8461. }
  8462. items = ele.getElementsByTagName("event_info");
  8463. item = items.item(0);
  8464. attrsParam = item.getAttributes();
  8465. for (int j = 0; j < attrsParam.getLength(); j++) {
  8466. Node attr = attrsParam.item(j);
  8467. if (attr.getNodeName().equalsIgnoreCase("info_cnt")) strCnt = trimquotation(attr.getNodeValue());
  8468. }
  8469. items = ele.getElementsByTagName("event");
  8470. item = items.item(0);
  8471. attrsParam = item.getAttributes();
  8472. for (int j = 0; j < attrsParam.getLength(); j++) {
  8473. Node attr = attrsParam.item(j);
  8474. if (attr.getNodeName().equalsIgnoreCase("event_type")) strEventType = trimquotation(attr.getNodeValue());
  8475. else if (attr.getNodeName().equalsIgnoreCase("trigger_type")) strEventTriggerType = trimquotation(attr.getNodeValue());
  8476. else if (attr.getNodeName().equalsIgnoreCase("uid")) strEventUID = trimquotation(attr.getNodeValue());
  8477. else if (attr.getNodeName().equalsIgnoreCase("sn")) strEventSN = trimquotation(attr.getNodeValue());
  8478. else if (attr.getNodeName().equalsIgnoreCase("sitecode")) strEventSitecode = trimquotation(attr.getNodeValue());
  8479. else if (attr.getNodeName().equalsIgnoreCase("dong")) strEventDong = trimquotation(attr.getNodeValue());
  8480. else if (attr.getNodeName().equalsIgnoreCase("ho")) strEventHo = trimquotation(attr.getNodeValue());
  8481. else if (attr.getNodeName().equalsIgnoreCase("card_num")) strEventCardNo = trimquotation(attr.getNodeValue());
  8482. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt")) strEventIssueCnt = trimquotation(attr.getNodeValue());
  8483. else if (attr.getNodeName().equalsIgnoreCase("card_type")) strEventCardType = trimquotation(attr.getNodeValue());
  8484. else if (attr.getNodeName().equalsIgnoreCase("location")) strEventLocation = trimquotation(attr.getNodeValue());
  8485. }
  8486. if(strName!=null && strDong!=null && strHo!=null && strCnt!=null)
  8487. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  8488. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  8489. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  8490. if ((strName!=null && strName.equalsIgnoreCase("homedev")) && (strDong!=null && strDong.equalsIgnoreCase(AddrDong)) && (strHo!=null && strHo.equalsIgnoreCase(AddrHo))) {
  8491. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  8492. }
  8493. else {
  8494. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  8495. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  8496. return retXML;
  8497. }
  8498. //데이터가 null인지 확인
  8499. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  8500. return retXML;
  8501. }
  8502. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  8503. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  8504. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  8505. wakeupLCD();
  8506. // 팝업을 띄우도록 하자
  8507. String CardNum = "";
  8508. try {
  8509. int iEvent_Dong = Integer.parseInt(strEventDong);
  8510. CardNum += String.format("%04d", iEvent_Dong);
  8511. int iEvent_Ho = Integer.parseInt(strEventHo);
  8512. CardNum += String.format("%04d", iEvent_Ho);
  8513. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  8514. CardNum += String.format("%03d", iEvent_CardNum);
  8515. } catch (RuntimeException re) {
  8516. LogUtil.errorLogInfo("", TAG, re);
  8517. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  8518. return retXML;
  8519. }
  8520. catch (Exception e) {
  8521. //e.printStackTrace();
  8522. LogUtil.errorLogInfo("", TAG, e);
  8523. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  8524. return retXML;
  8525. }
  8526. Intent iIntent = new Intent();
  8527. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  8528. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  8529. iIntent.putExtra("LOCATION", strEventLocation);
  8530. iIntent.putExtra("CARD_NO", CardNum);
  8531. getApplicationContext().sendBroadcast(iIntent);
  8532. }
  8533. }
  8534. }
  8535. else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  8536. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  8537. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  8538. int nCardNum;
  8539. try {
  8540. nCardNum = Integer.parseInt(strEventCardNo);
  8541. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  8542. } catch (RuntimeException re) {
  8543. LogUtil.errorLogInfo("", TAG, re);
  8544. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  8545. return retXML;
  8546. }
  8547. catch (Exception e) {
  8548. //e.printStackTrace();
  8549. LogUtil.errorLogInfo("", TAG, e);
  8550. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  8551. return retXML;
  8552. }
  8553. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  8554. boolean bBandUse = deviceSet.getBandLocationUsage();
  8555. deviceSet.closeDB();
  8556. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  8557. wakeupLCD();
  8558. Intent iIntent = new Intent();
  8559. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  8560. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  8561. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  8562. getApplicationContext().sendBroadcast(iIntent);
  8563. }
  8564. }
  8565. }
  8566. }
  8567. return retXML;
  8568. }
  8569. public String ProcParkInformation_cham_upis(Element ele)
  8570. {
  8571. Log.d(TAG, "ProcParkInformation_cham_upis START");
  8572. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  8573. String infoName = null;
  8574. String infoDong = null;
  8575. String infoHo = null;
  8576. String infoCarMove = null;
  8577. String infoCarnum = null;
  8578. String infoCarLocation = null;
  8579. String infoMessage = null;
  8580. NodeList items = ele.getElementsByTagName("home_info");
  8581. Node item = items.item(0);
  8582. Node text;
  8583. NamedNodeMap attrsParam = item.getAttributes();
  8584. for(int j=0; j< attrsParam.getLength();j++)
  8585. {
  8586. Node attr = attrsParam.item(j);
  8587. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8588. infoDong = trimquotation(attr.getNodeValue());
  8589. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8590. infoHo = trimquotation(attr.getNodeValue());
  8591. }
  8592. items = ele.getElementsByTagName("park_info");
  8593. item = items.item(0);
  8594. attrsParam = item.getAttributes();
  8595. for(int j=0; j< attrsParam.getLength();j++)
  8596. {
  8597. Node attr = attrsParam.item(j);
  8598. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  8599. infoCarnum = trimquotation(attr.getNodeValue());
  8600. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  8601. infoCarLocation = trimquotation(attr.getNodeValue());
  8602. else if (attr.getNodeName().equalsIgnoreCase("message"))
  8603. infoMessage = trimquotation(attr.getNodeValue());
  8604. }
  8605. Log.d(TAG, "ProcParkInformation infoName :"+infoName);
  8606. if(infoDong!=null)
  8607. Log.d(TAG, "ProcParkInformation infoDong :"+infoDong);
  8608. Log.d(TAG, "ProcParkInformation infoHo :"+infoHo);
  8609. Log.d(TAG, "ProcParkInformation infoCarMove :"+infoCarMove);
  8610. Log.d(TAG, "ProcParkInformation infoCarnum :"+infoCarnum);
  8611. Log.d(TAG, "ProcParkInformation infoCarLocation :"+infoCarLocation);
  8612. Log.d(TAG, "ProcParkInformation infoMessage :"+infoMessage);
  8613. if((infoDong!=null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  8614. (infoHo!=null && infoHo.equalsIgnoreCase(AddrHo) == true))
  8615. {
  8616. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  8617. }
  8618. else
  8619. {
  8620. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  8621. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  8622. return retXML;
  8623. }
  8624. infoCarMove = "park";
  8625. //DB정보 업데이트!
  8626. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  8627. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  8628. CarDB.closeDB();
  8629. //DB정보 업데이트!
  8630. Intent iIntent = new Intent();
  8631. iIntent.setAction(define.NOTIFY_ACNAME);
  8632. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  8633. this.sendBroadcast(iIntent);
  8634. /*
  8635. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  8636. {
  8637. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  8638. // 팝업을 띄우도록 하자
  8639. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  8640. }
  8641. */
  8642. return retXML;
  8643. }
  8644. public String ProcGetSmartKeyInfo(Element ele)
  8645. {
  8646. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  8647. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  8648. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  8649. NodeList items = ele.getElementsByTagName("info_type");
  8650. Node item = items.item(0);
  8651. Node text = item.getFirstChild();
  8652. String sInfo_type = trimquotation(text.getNodeValue());
  8653. String sCard_info = null;
  8654. String sMessage = null;
  8655. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  8656. {
  8657. items = ele.getElementsByTagName("uid_info");
  8658. item = items.item(0);
  8659. text = item.getFirstChild();
  8660. sCard_info = trimquotation(text.getNodeValue());
  8661. //==============================================//
  8662. items = ele.getElementsByTagName("message");
  8663. item = items.item(0);
  8664. text = item.getFirstChild();
  8665. sMessage = trimquotation(text.getNodeValue());
  8666. //==============================================//
  8667. //쿼리문 작성
  8668. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  8669. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  8670. for(int i=0; i<SyncData.size(); i++)
  8671. {
  8672. if(SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true)
  8673. {
  8674. NewData.add(SyncData.get(i));
  8675. }
  8676. }
  8677. wallpadSmartKeyRegData.closeDB();
  8678. }
  8679. else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  8680. {
  8681. items = ele.getElementsByTagName("sn_info");
  8682. item = items.item(0);
  8683. text = item.getFirstChild();
  8684. sCard_info = trimquotation(text.getNodeValue());
  8685. //==============================================//
  8686. items = ele.getElementsByTagName("message");
  8687. item = items.item(0);
  8688. text = item.getFirstChild();
  8689. sMessage = trimquotation(text.getNodeValue());
  8690. //==============================================//
  8691. //쿼리문 작성
  8692. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  8693. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  8694. for(int i=0; i<SyncData.size(); i++)
  8695. {
  8696. if(SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true)
  8697. {
  8698. NewData.add(SyncData.get(i));
  8699. }
  8700. }
  8701. wallpadSmartKeyRegData.closeDB();
  8702. }
  8703. else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  8704. {
  8705. items = ele.getElementsByTagName("uid_info");
  8706. item = items.item(0);
  8707. text = item.getFirstChild();
  8708. sCard_info = trimquotation(text.getNodeValue());
  8709. //==============================================//
  8710. items = ele.getElementsByTagName("message");
  8711. item = items.item(0);
  8712. text = item.getFirstChild();
  8713. sMessage = trimquotation(text.getNodeValue());
  8714. //==============================================//
  8715. //쿼리문 작성
  8716. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  8717. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  8718. for(int i=0; i<SyncData.size(); i++)
  8719. {
  8720. if(SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true)
  8721. {
  8722. NewData.add(SyncData.get(i));
  8723. }
  8724. }
  8725. if(NewData.size() > 0)
  8726. {
  8727. NewData = SyncData;
  8728. }
  8729. wallpadSmartKeyRegData.closeDB();
  8730. }
  8731. else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  8732. {
  8733. items = ele.getElementsByTagName("sn_info");
  8734. item = items.item(0);
  8735. text = item.getFirstChild();
  8736. sCard_info = trimquotation(text.getNodeValue());
  8737. //==============================================//
  8738. items = ele.getElementsByTagName("message");
  8739. item = items.item(0);
  8740. text = item.getFirstChild();
  8741. sMessage = trimquotation(text.getNodeValue());
  8742. //==============================================//
  8743. //쿼리문 작성
  8744. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  8745. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  8746. for(int i=0; i<SyncData.size(); i++)
  8747. {
  8748. if(SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true)
  8749. {
  8750. NewData.add(SyncData.get(i));
  8751. }
  8752. }
  8753. if(NewData.size() > 0)
  8754. {
  8755. NewData = SyncData;
  8756. }
  8757. wallpadSmartKeyRegData.closeDB();
  8758. }
  8759. else if (sInfo_type.equalsIgnoreCase("hkey"))
  8760. {
  8761. String dong = "";
  8762. String ho = "";
  8763. String Num = "all";
  8764. //==============================================//
  8765. items = ele.getElementsByTagName("message");
  8766. item = items.item(0);
  8767. text = item.getFirstChild();
  8768. sMessage = trimquotation(text.getNodeValue());
  8769. //==============================================//
  8770. items = ele.getElementsByTagName("hkey_info");
  8771. item = items.item(0);
  8772. if (item == null)
  8773. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  8774. NamedNodeMap attrsParam = item.getAttributes();
  8775. for(int j=0; j< attrsParam.getLength();j++)
  8776. {
  8777. Node attr = attrsParam.item(j);
  8778. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8779. dong = attr.getNodeValue();
  8780. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8781. ho = attr.getNodeValue();
  8782. else if (attr.getNodeName().equalsIgnoreCase("num"))
  8783. Num = attr.getNodeValue();
  8784. }
  8785. if(!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo))))
  8786. {
  8787. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :"+ dong+ "-" + ho);
  8788. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  8789. }
  8790. //쿼리문 작성
  8791. int intNum = 0;
  8792. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  8793. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  8794. for(int i=0; i<SyncData.size(); i++)
  8795. {
  8796. if(Num.equalsIgnoreCase("all") == true)
  8797. {
  8798. NewData.add(SyncData.get(i));
  8799. }
  8800. else
  8801. {
  8802. try
  8803. {
  8804. intNum = Integer.parseInt(Num);
  8805. }
  8806. catch (RuntimeException re) {
  8807. LogUtil.errorLogInfo("", TAG, re);
  8808. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  8809. }
  8810. catch (Exception e)
  8811. {
  8812. //e.printStackTrace();
  8813. LogUtil.errorLogInfo("", TAG, e);
  8814. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  8815. }
  8816. if(SyncData.get(i).id == intNum)
  8817. {
  8818. NewData.add(SyncData.get(i));
  8819. }
  8820. }
  8821. }
  8822. wallpadSmartKeyRegData.closeDB();
  8823. }
  8824. else if (sInfo_type.equalsIgnoreCase("dkey"))
  8825. {
  8826. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  8827. }
  8828. else if (sInfo_type.equalsIgnoreCase("mkey"))
  8829. {
  8830. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  8831. }
  8832. if(NewData.size() == 0)
  8833. {
  8834. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  8835. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  8836. retXML += " <hkey_info dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" count = \""+NewData.size()+"\" />\r\n";
  8837. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  8838. retXML += " </service>\r\n</imap>";
  8839. return retXML;
  8840. }
  8841. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  8842. retXML += " <hkey_info dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" count = \""+NewData.size()+"\" />\r\n";
  8843. for(int i = 0; i<NewData.size(); i++)
  8844. {
  8845. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  8846. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  8847. String strFormat = sFormat.format(date);
  8848. retXML += " <key_info index = \""+NewData.get(i).id+"\" "
  8849. + "sn = \""+NewData.get(i).SerialNumber+"\" "
  8850. + "uid = \""+NewData.get(i).Uid+"\" "
  8851. + "key_num = \""+NewData.get(i).id+"\" "
  8852. + "issue_cnt = \""+1+"\" "
  8853. + "issued_date = \""+strFormat+"\" "
  8854. + "message = \""+"null"+"\" "
  8855. + "/>\r\n";
  8856. }
  8857. retXML += " </service>\r\n</imap>";
  8858. return retXML;
  8859. }
  8860. public void ProcMobileDevice_AuthNumber(Element ele) {
  8861. String sDong = null;
  8862. String sHo = null;
  8863. String sIP = null;
  8864. String sType = null;
  8865. String sDevice_Name = null;
  8866. String sTwinID = null;
  8867. String sAuthNumber = null;
  8868. try {
  8869. NodeList items = ele.getElementsByTagName("home_info");
  8870. Node item = items.item(0);
  8871. NamedNodeMap attrsParam = item.getAttributes();
  8872. for (int i=0; i< attrsParam.getLength(); i++) {
  8873. Node attr = attrsParam.item(i);
  8874. if (attr.getNodeName().equalsIgnoreCase("dong")) sDong = trimquotation(attr.getNodeValue());
  8875. else if (attr.getNodeName().equalsIgnoreCase("ho")) sHo = trimquotation(attr.getNodeValue());
  8876. else if (attr.getNodeName().equalsIgnoreCase("ip")) sIP = trimquotation(attr.getNodeValue());
  8877. else if (attr.getNodeName().equalsIgnoreCase("type")) sType = trimquotation(attr.getNodeValue());
  8878. }
  8879. WallpadStatusData DBMGR = null;
  8880. DBMGR = new WallpadStatusData(getApplicationContext());
  8881. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8882. DBMGR.closeDB();
  8883. if((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo!=null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP!=null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  8884. items = ele.getElementsByTagName("device_info");
  8885. item = items.item(0);
  8886. attrsParam = item.getAttributes();
  8887. for (int i = 0; i < attrsParam.getLength(); i++) {
  8888. Node attr = attrsParam.item(i);
  8889. if (attr.getNodeName().equalsIgnoreCase("alias")) sDevice_Name = trimquotation(attr.getNodeValue());
  8890. else if (attr.getNodeName().equalsIgnoreCase("twinid")) sTwinID = trimquotation(attr.getNodeValue());
  8891. else if (attr.getNodeName().equalsIgnoreCase("auth_number")) sAuthNumber = trimquotation(attr.getNodeValue());
  8892. }
  8893. /**데이터 전달**/
  8894. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  8895. Log.d(TAG, "sTwinID :" + sTwinID);
  8896. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  8897. Intent intent = new Intent();
  8898. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  8899. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  8900. intent.putExtra("AuthNumber", sAuthNumber);
  8901. if (NewServerUse()) {
  8902. getApplicationContext().sendBroadcast(intent);
  8903. }
  8904. }
  8905. else {
  8906. }
  8907. } catch (RuntimeException re) {
  8908. LogUtil.errorLogInfo("", TAG, re);
  8909. }
  8910. catch (Exception e) {
  8911. //e.printStackTrace();
  8912. LogUtil.errorLogInfo("", TAG, e);
  8913. }
  8914. }
  8915. public String ProcMobileDevice_ADD_Finish(Element ele) {
  8916. String retXML = "";
  8917. String sDong = null;
  8918. String sHo = null;
  8919. String sIP = null;
  8920. String sType = null;
  8921. String sDevice_Name = null;
  8922. String sTwinID = null;
  8923. try
  8924. {
  8925. NodeList items = ele.getElementsByTagName("home_info");
  8926. Node item = items.item(0);
  8927. NamedNodeMap attrsParam = item.getAttributes();
  8928. for(int i=0; i< attrsParam.getLength(); i++)
  8929. {
  8930. Node attr = attrsParam.item(i);
  8931. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8932. sDong = trimquotation(attr.getNodeValue());
  8933. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8934. sHo = trimquotation(attr.getNodeValue());
  8935. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  8936. sIP = trimquotation(attr.getNodeValue());
  8937. else if (attr.getNodeName().equalsIgnoreCase("type"))
  8938. sType = trimquotation(attr.getNodeValue());
  8939. }
  8940. WallpadStatusData DBMGR = null;
  8941. DBMGR = new WallpadStatusData(getApplicationContext());
  8942. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8943. DBMGR.closeDB();
  8944. if((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  8945. (sHo!=null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  8946. (sIP!=null && sIP.equalsIgnoreCase(addc.IPAddress) == true))
  8947. {
  8948. items = ele.getElementsByTagName("device_info");
  8949. item = items.item(0);
  8950. attrsParam = item.getAttributes();
  8951. for(int i=0; i< attrsParam.getLength(); i++)
  8952. {
  8953. Node attr = attrsParam.item(i);
  8954. if (attr.getNodeName().equalsIgnoreCase("alias"))
  8955. sDevice_Name = trimquotation(attr.getNodeValue());
  8956. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  8957. sTwinID = trimquotation(attr.getNodeValue());
  8958. }
  8959. /**데이터 전달**/
  8960. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  8961. Log.d(TAG, "sTwinID :" + sTwinID);
  8962. Intent intent = new Intent();
  8963. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  8964. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  8965. if(NewServerUse())
  8966. {
  8967. getApplicationContext().sendBroadcast(intent);
  8968. }
  8969. else
  8970. {
  8971. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8972. retXML += " </service>\r\n</imap>";
  8973. return retXML;
  8974. }
  8975. String tempType = "main";
  8976. //DB에 저장 필요
  8977. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  8978. if(wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  8979. {
  8980. wallpadMobileDeviceData.closeDB();
  8981. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8982. retXML += " </service>\r\n</imap>";
  8983. return retXML;
  8984. }
  8985. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  8986. wallpadMobileDeviceData.closeDB();
  8987. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  8988. retXML += " <home_info dong=\""+addc.Dong+"\" ho=\""+ addc.Ho+"\" ip=\""+ addc.IPAddress+"\" type=\""+ tempType +"\"/>\r\n";
  8989. retXML += " <device_info alias=\""+sDevice_Name+"\" twinid=\""+sTwinID+"\" />\r\n";
  8990. retXML += " </service>\r\n</imap>";
  8991. return retXML;
  8992. }
  8993. else
  8994. {
  8995. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  8996. retXML += " </service>\r\n</imap>";
  8997. return retXML;
  8998. }
  8999. }
  9000. catch (RuntimeException re) {
  9001. LogUtil.errorLogInfo("", TAG, re);
  9002. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9003. retXML += " </service>\r\n</imap>";
  9004. return retXML;
  9005. }
  9006. catch (Exception e)
  9007. {
  9008. //e.printStackTrace();
  9009. LogUtil.errorLogInfo("", TAG, e);
  9010. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9011. retXML += " </service>\r\n</imap>";
  9012. return retXML;
  9013. }
  9014. }
  9015. public void ProcMobileDevice_Delete(Element ele)
  9016. {
  9017. String sDong = null;
  9018. String sHo = null;
  9019. String sIP = null;
  9020. String sType = null;
  9021. String sDevice_Name = null;
  9022. String sTwinID = null;
  9023. Log.d(TAG, "ProcMobileDevice_Delete");
  9024. try
  9025. {
  9026. NodeList items = ele.getElementsByTagName("home_info");
  9027. Node item = items.item(0);
  9028. NamedNodeMap attrsParam = item.getAttributes();
  9029. for(int i=0; i< attrsParam.getLength(); i++)
  9030. {
  9031. Node attr = attrsParam.item(i);
  9032. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9033. sDong = trimquotation(attr.getNodeValue());
  9034. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9035. sHo = trimquotation(attr.getNodeValue());
  9036. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  9037. sIP = trimquotation(attr.getNodeValue());
  9038. else if (attr.getNodeName().equalsIgnoreCase("type"))
  9039. sType = trimquotation(attr.getNodeValue());
  9040. }
  9041. WallpadStatusData DBMGR = null;
  9042. DBMGR = new WallpadStatusData(getApplicationContext());
  9043. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9044. DBMGR.closeDB();
  9045. if((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  9046. (sHo!=null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  9047. (sIP!=null && sIP.equalsIgnoreCase(addc.IPAddress) == true))
  9048. {
  9049. if(NewServerUse())
  9050. {
  9051. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  9052. items = ele.getElementsByTagName("device_info");
  9053. for(int i = 0; i< items.getLength(); i++)
  9054. {
  9055. item = items.item(i);
  9056. attrsParam = item.getAttributes();
  9057. for(int j=0; j < attrsParam.getLength(); j++)
  9058. {
  9059. Node attr = attrsParam.item(j);
  9060. if (attr.getNodeName().equalsIgnoreCase("alias"))
  9061. sDevice_Name = trimquotation(attr.getNodeValue());
  9062. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  9063. sTwinID = trimquotation(attr.getNodeValue());
  9064. }
  9065. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9066. Log.d(TAG, "sTwinID :" + sTwinID);
  9067. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  9068. }
  9069. wallpadMobileDeviceData.closeDB();
  9070. Intent intent = new Intent();
  9071. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  9072. getApplicationContext().sendBroadcast(intent);
  9073. }
  9074. }
  9075. else
  9076. {
  9077. }
  9078. }
  9079. catch (RuntimeException re) {
  9080. LogUtil.errorLogInfo("", TAG, re);
  9081. }
  9082. catch (Exception e)
  9083. {
  9084. //e.printStackTrace();
  9085. LogUtil.errorLogInfo("", TAG, e);
  9086. }
  9087. }
  9088. public String ProcGetAppVersionInfo()
  9089. {
  9090. String retXML = "";
  9091. MainDatabaseManager mDBM = new MainDatabaseManager( getApplicationContext() , null, null);
  9092. int AppCount;
  9093. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  9094. retXML= XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  9095. retXML += " <home_info dong = \""+AddrDong+"\" ho=\""+AddrHo+"\" platform=\"Android\" count=\""+AppCount+"\" />\r\n";
  9096. for(int i =0; i<AppCount; i++)
  9097. {
  9098. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE+i);
  9099. if(getString != null)
  9100. {
  9101. retXML += " <app_list name=\""+getString[0]+"\" version=\""+getString[1]+"\" />\r\n";
  9102. }
  9103. }
  9104. retXML += " </service>\r\n</imap>";
  9105. return retXML;
  9106. }
  9107. public String ProcIgateInitInfo(Element ele)
  9108. {
  9109. String retXML = "";
  9110. String ctrl_baudrate = "";
  9111. String ctrl_open = "";
  9112. String ctrl_framecheck = "";
  9113. String ctrl_message = "";
  9114. String eth_mode = "";
  9115. String eth_ip = "";
  9116. String eth_mac = "";
  9117. String eth_gw = "";
  9118. String eth_sm = "";
  9119. String noti_send = "";
  9120. String noti_level = "";
  9121. String noti_ip = "";
  9122. String noti_port= "";
  9123. try
  9124. {
  9125. NodeList items = ele.getElementsByTagName("ctrl_param");
  9126. Node item = items.item(0);
  9127. NamedNodeMap attrsParam = item.getAttributes();
  9128. for(int i=0; i< attrsParam.getLength(); i++)
  9129. {
  9130. Node attr = attrsParam.item(i);
  9131. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  9132. ctrl_baudrate = trimquotation(attr.getNodeValue());
  9133. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  9134. ctrl_open = trimquotation(attr.getNodeValue());
  9135. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  9136. ctrl_framecheck = trimquotation(attr.getNodeValue());
  9137. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  9138. ctrl_message = trimquotation(attr.getNodeValue());
  9139. }
  9140. items = ele.getElementsByTagName("eth_param");
  9141. item = items.item(0);
  9142. attrsParam = item.getAttributes();
  9143. for(int i=0; i< attrsParam.getLength(); i++)
  9144. {
  9145. Node attr = attrsParam.item(i);
  9146. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  9147. eth_mode = trimquotation(attr.getNodeValue());
  9148. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  9149. eth_ip = trimquotation(attr.getNodeValue());
  9150. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  9151. eth_mac = trimquotation(attr.getNodeValue());
  9152. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  9153. eth_gw = trimquotation(attr.getNodeValue());
  9154. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  9155. eth_sm = trimquotation(attr.getNodeValue());
  9156. }
  9157. items = ele.getElementsByTagName("noti_param");
  9158. item = items.item(0);
  9159. attrsParam = item.getAttributes();
  9160. for(int i=0; i< attrsParam.getLength(); i++)
  9161. {
  9162. Node attr = attrsParam.item(i);
  9163. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  9164. noti_send = trimquotation(attr.getNodeValue());
  9165. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  9166. noti_level = trimquotation(attr.getNodeValue());
  9167. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  9168. noti_ip = trimquotation(attr.getNodeValue());
  9169. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  9170. noti_port = trimquotation(attr.getNodeValue());
  9171. }
  9172. wallpaddbmgr WallpadDBMGR = null;
  9173. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  9174. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  9175. if(RowCount_GatewayData > 100)
  9176. {
  9177. WallpadDBMGR.DeleteLH_GatewayData("50");
  9178. }
  9179. 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);
  9180. WallpadDBMGR.closeDB();
  9181. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  9182. retXML += " </service>\r\n</imap>";
  9183. return retXML;
  9184. }
  9185. catch (RuntimeException re) {
  9186. LogUtil.errorLogInfo("", TAG, re);
  9187. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  9188. retXML += " </service>\r\n</imap>";
  9189. return retXML;
  9190. }
  9191. catch (Exception e)
  9192. {
  9193. //e.printStackTrace();
  9194. LogUtil.errorLogInfo("", TAG, e);
  9195. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  9196. retXML += " </service>\r\n</imap>";
  9197. return retXML;
  9198. }
  9199. }
  9200. public String ProcElecCarChargeEventInfo(Element ele) {
  9201. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  9202. String retXML = "";
  9203. String sName = "", sId_High = "", sId_Low = "", sCard_Num ="", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  9204. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  9205. try {
  9206. NodeList items = ele.getElementsByTagName("destination");
  9207. Node item = items.item(0);
  9208. NamedNodeMap attrsParam = item.getAttributes();
  9209. for (int i = 0; i < attrsParam.getLength(); i++) {
  9210. Node attr = attrsParam.item(i);
  9211. if (attr.getNodeName().equalsIgnoreCase("name")) sName = trimquotation(attr.getNodeValue());
  9212. else if (attr.getNodeName().equalsIgnoreCase("id_high")) sId_High = trimquotation(attr.getNodeValue());
  9213. else if (attr.getNodeName().equalsIgnoreCase("id_low")) sId_Low = trimquotation(attr.getNodeValue());
  9214. }
  9215. WallpadStatusData DBMGR = null;
  9216. DBMGR = new WallpadStatusData(getApplicationContext());
  9217. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9218. DBMGR.closeDB();
  9219. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  9220. items = ele.getElementsByTagName("charging_info");
  9221. item = items.item(0);
  9222. attrsParam = item.getAttributes();
  9223. for (int i = 0; i < attrsParam.getLength(); i++) {
  9224. Node attr = attrsParam.item(i);
  9225. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  9226. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  9227. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  9228. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  9229. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  9230. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  9231. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  9232. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  9233. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  9234. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  9235. ))
  9236. {
  9237. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  9238. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  9239. retXML += " </service>\r\n</imap>";
  9240. return retXML;
  9241. }
  9242. if (attr.getNodeName().equalsIgnoreCase("card_num")) sCard_Num = trimquotation(attr.getNodeValue());
  9243. else if (attr.getNodeName().equalsIgnoreCase("car_num")) sCar_Num = trimquotation(attr.getNodeValue());
  9244. else if (attr.getNodeName().equalsIgnoreCase("charger_num")) sCharger_Num = trimquotation(attr.getNodeValue());
  9245. else if (attr.getNodeName().equalsIgnoreCase("charger_loc")) sCharger_Loc = trimquotation(attr.getNodeValue());
  9246. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  9247. sCharging_Status = trimquotation(attr.getNodeValue());
  9248. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  9249. (sCharging_Status.equalsIgnoreCase("charging")) ||
  9250. (sCharging_Status.equalsIgnoreCase("full")) ||
  9251. (sCharging_Status.equalsIgnoreCase("charged")) ||
  9252. (sCharging_Status.equalsIgnoreCase("stop")) ||
  9253. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  9254. (sCharging_Status.equalsIgnoreCase("check")) ||
  9255. (sCharging_Status.equalsIgnoreCase("commerror"))
  9256. ))
  9257. {
  9258. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  9259. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  9260. retXML += " </service>\r\n</imap>";
  9261. return retXML;
  9262. }
  9263. }
  9264. else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  9265. sCharger_sort = trimquotation(attr.getNodeValue());
  9266. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  9267. (sCharger_sort.equalsIgnoreCase("fast")) ||
  9268. (sCharger_sort.equalsIgnoreCase("no_info"))
  9269. ))
  9270. {
  9271. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  9272. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  9273. retXML += " </service>\r\n</imap>";
  9274. return retXML;
  9275. }
  9276. }
  9277. else if (attr.getNodeName().equalsIgnoreCase("charging_ratio")) sCharging_Ratio = trimquotation(attr.getNodeValue());
  9278. else if (attr.getNodeName().equalsIgnoreCase("start_time")) sStart_Time = trimquotation(attr.getNodeValue());
  9279. else if (attr.getNodeName().equalsIgnoreCase("remain_time")) sRemain_Time = trimquotation(attr.getNodeValue());
  9280. }
  9281. items = ele.getElementsByTagName("message");
  9282. item = items.item(0);
  9283. Node text = item.getFirstChild();
  9284. sMessage = trimquotation(text.getNodeValue());
  9285. /**데이터 전달**/
  9286. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  9287. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  9288. Intent intent = new Intent();
  9289. intent.setAction(define.NOTIFY_ACNAME);
  9290. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  9291. intent.putExtra("sCard_Num", sCard_Num);
  9292. intent.putExtra("sCar_Num", sCar_Num);
  9293. intent.putExtra("sCharger_Num", sCharger_Num);
  9294. intent.putExtra("sCharger_Loc", sCharger_Loc);
  9295. intent.putExtra("sCharging_Status", sCharging_Status);
  9296. intent.putExtra("sCharger_sort", sCharger_sort);
  9297. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  9298. intent.putExtra("sStart_Time", sStart_Time);
  9299. intent.putExtra("sRemain_Time", sRemain_Time);
  9300. intent.putExtra("sMessage", sMessage);
  9301. WallpadDeviceSet devDB = null;
  9302. devDB = new WallpadDeviceSet(getApplicationContext());
  9303. int retInt = -1;
  9304. retInt = devDB.GetDeviceSetted("전기차충전");
  9305. devDB.closeDB();
  9306. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  9307. getApplicationContext().sendBroadcast(intent);
  9308. }
  9309. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  9310. retXML += " <source name=\"homedev\" id_high=\""+sId_High+"\" id_low=\""+ sId_Low+"\" />\r\n";
  9311. retXML += " </service>\r\n</imap>";
  9312. return retXML;
  9313. }
  9314. else {
  9315. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  9316. retXML += " </service>\r\n</imap>";
  9317. return retXML;
  9318. }
  9319. } catch (RuntimeException re) {
  9320. LogUtil.errorLogInfo("", TAG, re);
  9321. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  9322. retXML += " </service>\r\n</imap>";
  9323. return retXML;
  9324. }
  9325. catch (Exception e) {
  9326. //e.printStackTrace();
  9327. LogUtil.errorLogInfo("", TAG, e);
  9328. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  9329. retXML += " </service>\r\n</imap>";
  9330. return retXML;
  9331. }
  9332. }
  9333. public String ProcEnergyTargetInfoAlarm(Element ele) {
  9334. String retXML = "";
  9335. String sName = "";
  9336. String sId_High = "";
  9337. String sId_Low = "";
  9338. String vName[];
  9339. String vTarget[];
  9340. String vTarget_Cost[];
  9341. String vUsed[];
  9342. String vUsed_Cost[];
  9343. String vPredict[];
  9344. String vPredict_Cost[];
  9345. String vAlarm_info[];
  9346. String vRead_Date[];
  9347. String vRead_Day[];
  9348. String vV_Msg[];
  9349. String sMessage = "";
  9350. try
  9351. {
  9352. NodeList items = ele.getElementsByTagName("source");
  9353. Node item = items.item(0);
  9354. NamedNodeMap attrsParam = item.getAttributes();
  9355. for(int i=0; i< attrsParam.getLength(); i++)
  9356. {
  9357. Node attr = attrsParam.item(i);
  9358. if (attr.getNodeName().equalsIgnoreCase("name"))
  9359. sName = trimquotation(attr.getNodeValue());
  9360. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9361. sId_High = trimquotation(attr.getNodeValue());
  9362. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9363. sId_Low = trimquotation(attr.getNodeValue());
  9364. }
  9365. WallpadStatusData DBMGR = null;
  9366. DBMGR = new WallpadStatusData(getApplicationContext());
  9367. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9368. DBMGR.closeDB();
  9369. if((sName.equalsIgnoreCase("home") == true) &&
  9370. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  9371. (sId_Low.equalsIgnoreCase(addc.Ho) == true))
  9372. {
  9373. items = ele.getElementsByTagName("valuelist");
  9374. Log.d(TAG, "items.getLength() :" + items.getLength());
  9375. vName = new String[items.getLength()];
  9376. vTarget = new String[items.getLength()];
  9377. vTarget_Cost = new String[items.getLength()];
  9378. vUsed = new String[items.getLength()];
  9379. vUsed_Cost = new String[items.getLength()];
  9380. vPredict = new String[items.getLength()];
  9381. vPredict_Cost = new String[items.getLength()];
  9382. vAlarm_info = new String[items.getLength()];
  9383. vRead_Date = new String[items.getLength()];
  9384. vRead_Day = new String[items.getLength()];
  9385. vV_Msg = new String[items.getLength()];
  9386. for (int j = 0; j < items.getLength(); j++)
  9387. {
  9388. Log.d(TAG, "j :" + j);
  9389. item = items.item(j);
  9390. attrsParam = item.getAttributes();
  9391. Log.d(TAG, "attrsParam :" + attrsParam);
  9392. for(int i=0; i< attrsParam.getLength(); i++)
  9393. {
  9394. Node attr = attrsParam.item(i);
  9395. if(!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  9396. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  9397. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  9398. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  9399. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  9400. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  9401. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  9402. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  9403. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  9404. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  9405. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  9406. ))
  9407. {
  9408. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  9409. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9410. retXML += " </service>\r\n</imap>";
  9411. return retXML;
  9412. }
  9413. if (attr.getNodeName().equalsIgnoreCase("name"))
  9414. {
  9415. vName[j] = trimquotation(attr.getNodeValue());
  9416. if(!((vName[j].equalsIgnoreCase("elect") == true) ||
  9417. (vName[j].equalsIgnoreCase("water") == true) ||
  9418. (vName[j].equalsIgnoreCase("gas") == true) ||
  9419. (vName[j].equalsIgnoreCase("heating") == true) ||
  9420. (vName[j].equalsIgnoreCase("hotwater") == true)
  9421. ))
  9422. {
  9423. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  9424. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9425. retXML += " </service>\r\n</imap>";
  9426. return retXML;
  9427. }
  9428. }
  9429. else if (attr.getNodeName().equalsIgnoreCase("target"))
  9430. vTarget[j] = trimquotation(attr.getNodeValue());
  9431. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  9432. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  9433. else if (attr.getNodeName().equalsIgnoreCase("used"))
  9434. vUsed[j] = trimquotation(attr.getNodeValue());
  9435. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  9436. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  9437. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  9438. vPredict[j] = trimquotation(attr.getNodeValue());
  9439. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  9440. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  9441. else if (attr.getNodeName().equalsIgnoreCase("alarm_info"))
  9442. {
  9443. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  9444. if(!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  9445. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  9446. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  9447. ))
  9448. {
  9449. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  9450. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9451. retXML += " </service>\r\n</imap>";
  9452. return retXML;
  9453. }
  9454. }
  9455. else if (attr.getNodeName().equalsIgnoreCase("read_date"))
  9456. {
  9457. vRead_Date[j] = trimquotation(attr.getNodeValue());
  9458. if(!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  9459. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  9460. ))
  9461. {
  9462. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  9463. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9464. retXML += " </service>\r\n</imap>";
  9465. return retXML;
  9466. }
  9467. }
  9468. else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  9469. vRead_Day[j] = trimquotation(attr.getNodeValue());
  9470. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  9471. vV_Msg[j] = trimquotation(attr.getNodeValue());
  9472. }
  9473. }
  9474. items = ele.getElementsByTagName("message");
  9475. item = items.item(0);
  9476. Node text = item.getFirstChild();
  9477. sMessage = trimquotation(text.getNodeValue());
  9478. /**데이터 전달**/
  9479. for(int i = 0; i<vName.length; i++)
  9480. {
  9481. Log.d(TAG, "vName["+i+"]: " + vName[i]);
  9482. Log.d(TAG, "vTarget"+i+"]: " + vTarget[i]);
  9483. Log.d(TAG, "vTarget_Cost["+i+"]: " + vTarget_Cost[i]);
  9484. Log.d(TAG, "vUsed["+i+"]: " + vUsed[i]);
  9485. Log.d(TAG, "vUsed_Cost["+i+"]: " + vUsed_Cost[i]);
  9486. Log.d(TAG, "vPredict["+i+"]: " + vPredict[i]);
  9487. Log.d(TAG, "vPredict_Cost["+i+"]: " + vPredict_Cost[i]);
  9488. Log.d(TAG, "vAlarm_info["+i+"]: " + vAlarm_info[i]);
  9489. Log.d(TAG, "vRead_Date["+i+"]: " + vRead_Date[i]);
  9490. Log.d(TAG, "vRead_Day["+i+"]: " + vRead_Day[i]);
  9491. Log.d(TAG, "vV_Msg["+i+"]: " + vV_Msg[i]);
  9492. }
  9493. Intent intent = new Intent();
  9494. intent.setAction(define.NOTIFY_ACNAME);
  9495. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  9496. for(int i = 0; i<vName.length; i++)
  9497. {
  9498. if(vName[i].equals("elect"))
  9499. {
  9500. intent.putExtra("elect_target", vTarget[i]);
  9501. intent.putExtra("elect_used", vUsed[i]);
  9502. intent.putExtra("elect_info", vAlarm_info[i]);
  9503. }
  9504. else if(vName[i].equals("water"))
  9505. {
  9506. intent.putExtra("water_target", vTarget[i]);
  9507. intent.putExtra("water_used", vUsed[i]);
  9508. intent.putExtra("water_info", vAlarm_info[i]);
  9509. }
  9510. else if(vName[i].equals("gas"))
  9511. {
  9512. intent.putExtra("gas_target", vTarget[i]);
  9513. intent.putExtra("gas_used", vUsed[i]);
  9514. intent.putExtra("gas_info", vAlarm_info[i]);
  9515. }
  9516. else if(vName[i].equals("heating"))
  9517. {
  9518. intent.putExtra("heating_target", vTarget[i]);
  9519. intent.putExtra("heating_used", vUsed[i]);
  9520. intent.putExtra("heating_info", vAlarm_info[i]);
  9521. }
  9522. else if(vName[i].equals("hotwater"))
  9523. {
  9524. intent.putExtra("hotwater_target", vTarget[i]);
  9525. intent.putExtra("hotwater_used", vUsed[i]);
  9526. intent.putExtra("hotwater_info", vAlarm_info[i]);
  9527. }
  9528. }
  9529. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  9530. retXML += " <source name=\"home\" id_high=\""+sId_High+"\" id_low=\""+ sId_Low+"\" count=\""+vName.length+"\""+" s_msg=\"null\" />\r\n";
  9531. for(int i = 0; i<vName.length; i++)
  9532. {
  9533. retXML += " <valuelist name=\""+vName[i]+"\" alarm_info=\""+vAlarm_info[i]+"\" v_msg=\"null\" />\r\n";
  9534. }
  9535. retXML += " <message>\"null\"</message>\r\n";
  9536. retXML += " </service>\r\n</imap>";
  9537. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9538. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  9539. devSet.closeDB();
  9540. if (MetringDB != null)
  9541. {
  9542. try
  9543. {
  9544. String devInfo = MetringDB[1];
  9545. devInfo = devInfo.replace('(', '_');
  9546. devInfo = devInfo.replace(':', '_');
  9547. devInfo = devInfo.replace(')', '_');
  9548. String[] MetringInfo = devInfo.split("_");
  9549. // MetringInfo[1] -> 회로수
  9550. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  9551. // MetringInfo[4] -> IP
  9552. // MetringInfo[5] -> IP정보
  9553. // MetringInfo[6] -> 검침일사용자설정
  9554. // MetringInfo[7] -> 사용함 또는 사용안함
  9555. if(MetringInfo[3].equals("사용함") == true)
  9556. {
  9557. getApplicationContext().sendBroadcast(intent);
  9558. }
  9559. }
  9560. catch (RuntimeException re) {
  9561. LogUtil.errorLogInfo("", TAG, re);
  9562. }
  9563. catch (Exception e)
  9564. {
  9565. //e.printStackTrace();
  9566. LogUtil.errorLogInfo("", TAG, e);
  9567. }
  9568. }
  9569. else
  9570. {
  9571. }
  9572. return retXML;
  9573. }
  9574. else
  9575. {
  9576. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9577. retXML += " </service>\r\n</imap>";
  9578. return retXML;
  9579. }
  9580. }
  9581. catch (RuntimeException re) {
  9582. LogUtil.errorLogInfo("", TAG, re);
  9583. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9584. retXML += " </service>\r\n</imap>";
  9585. return retXML;
  9586. }
  9587. catch (Exception e)
  9588. {
  9589. //e.printStackTrace();
  9590. LogUtil.errorLogInfo("", TAG, e);
  9591. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  9592. retXML += " </service>\r\n</imap>";
  9593. return retXML;
  9594. }
  9595. }
  9596. public String ProcCheckCallOption()
  9597. {
  9598. int[] resultDB = {0, 0};
  9599. String retXML = "";
  9600. String sOption = "sip";
  9601. String sMessage = "null";
  9602. try
  9603. {
  9604. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  9605. resultDB = devSet.Get_Handicapped_Mode();
  9606. devSet.closeDB();
  9607. if(resultDB[0] == 0)
  9608. {
  9609. //장애인모드 사용 안함
  9610. }
  9611. else if (resultDB[0] == 1)
  9612. {
  9613. //장애인모드 사용함
  9614. }
  9615. switch(resultDB[1])
  9616. {
  9617. case 0: //일반모드
  9618. sOption = "sip";
  9619. break;
  9620. case 1: //청각장애인
  9621. sOption = "deaf";
  9622. break;
  9623. case 2: //시각장애인
  9624. sOption = "blind";
  9625. break;
  9626. default:
  9627. break;
  9628. }
  9629. if(resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  9630. {
  9631. //본 구문에 들어올수 없음
  9632. sOption = "none";
  9633. }
  9634. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  9635. retXML += " <option>\""+sOption+"\"</option>\r\n";
  9636. retXML += " <message>\""+sMessage+"\"</message>\r\n";
  9637. retXML += " </service>\r\n</imap>";
  9638. return retXML;
  9639. }
  9640. catch (RuntimeException re) {
  9641. LogUtil.errorLogInfo("", TAG, re);
  9642. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  9643. retXML += " </service>\r\n</imap>";
  9644. return retXML;
  9645. }
  9646. catch (Exception e)
  9647. {
  9648. //e.printStackTrace();
  9649. LogUtil.errorLogInfo("", TAG, e);
  9650. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  9651. retXML += " </service>\r\n</imap>";
  9652. return retXML;
  9653. }
  9654. }
  9655. public String ProcChatSequence(Element ele)
  9656. {
  9657. String retXML = "";
  9658. String sFrom = "error";
  9659. String sTo = "error";
  9660. String sContact = "error";
  9661. String sSequence = "error";
  9662. String sStatus = "error";
  9663. String sMessage = "error";
  9664. String reply_Sequence = "error";
  9665. String reply_Status = "error";
  9666. String reply_Message = "null";
  9667. try
  9668. {
  9669. NodeList items = ele.getElementsByTagName("sequence");
  9670. Node item = items.item(0);
  9671. NamedNodeMap attrsParam = item.getAttributes();
  9672. sSequence = trimquotation(item.getTextContent());
  9673. ///////////////////////////////////////////////
  9674. items = ele.getElementsByTagName("status");
  9675. item = items.item(0);
  9676. attrsParam = item.getAttributes();
  9677. sStatus = trimquotation(item.getTextContent());
  9678. ///////////////////////////////////////////////
  9679. items = ele.getElementsByTagName("message");
  9680. item = items.item(0);
  9681. attrsParam = item.getAttributes();
  9682. sMessage = trimquotation(item.getTextContent());
  9683. ///////////////////////////////////////////////
  9684. items = ele.getElementsByTagName("from");
  9685. item = items.item(0);
  9686. attrsParam = item.getAttributes();
  9687. sFrom = trimquotation(item.getTextContent());
  9688. ///////////////////////////////////////////////
  9689. items = ele.getElementsByTagName("to");
  9690. item = items.item(0);
  9691. attrsParam = item.getAttributes();
  9692. sTo = trimquotation(item.getTextContent());
  9693. ///////////////////////////////////////////////
  9694. items = ele.getElementsByTagName("contact");
  9695. item = items.item(0);
  9696. attrsParam = item.getAttributes();
  9697. sContact = trimquotation(item.getTextContent());
  9698. ///////////////////////////////////////////////
  9699. if(!((sSequence.equalsIgnoreCase("try") == true) ||
  9700. (sSequence.equalsIgnoreCase("start") == true) ||
  9701. (sSequence.equalsIgnoreCase("quit") == true) ||
  9702. (sSequence.equalsIgnoreCase("cancel") == true) ||
  9703. (sSequence.equalsIgnoreCase("ok") == true) ||
  9704. (sSequence.equalsIgnoreCase("busy") == true) ||
  9705. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  9706. (sSequence.equalsIgnoreCase("reject") == true)
  9707. ))
  9708. {
  9709. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  9710. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  9711. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  9712. retXML += " </service>\r\n</imap>";
  9713. return retXML;
  9714. }
  9715. if(!((sStatus.equalsIgnoreCase("idle") == true) ||
  9716. (sStatus.equalsIgnoreCase("ringing") == true) ||
  9717. (sStatus.equalsIgnoreCase("talking") == true)
  9718. ))
  9719. {
  9720. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  9721. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  9722. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  9723. retXML += " </service>\r\n</imap>";
  9724. return retXML;
  9725. }
  9726. //입력값 처리 필요!!
  9727. //김용성 과장님 작업필요
  9728. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  9729. //확인 하시고 위 정보 확인해주세요.
  9730. Log.d(TAG, "sFrom:" + sFrom);
  9731. Log.d(TAG, "sTo:" + sTo);
  9732. Log.d(TAG, "Contact:" + sContact);
  9733. Log.d(TAG, "sSequence:" + sSequence);
  9734. Log.d(TAG, "sStatus:" + sStatus);
  9735. if(sSequence.equalsIgnoreCase("try") == true)
  9736. {
  9737. //채팅 요청
  9738. }
  9739. else if(sSequence.equalsIgnoreCase("start") == true)
  9740. {
  9741. //채팅 시작
  9742. }
  9743. else if(sSequence.equalsIgnoreCase("quit") == true)
  9744. {
  9745. //채팅 종료
  9746. }
  9747. else if(sSequence.equalsIgnoreCase("cancel") == true)
  9748. {
  9749. //취소
  9750. }
  9751. else if(sSequence.equalsIgnoreCase("ok") == true)
  9752. {
  9753. //요청확인
  9754. }
  9755. else if(sSequence.equalsIgnoreCase("busy") == true)
  9756. {
  9757. //통화중
  9758. }
  9759. else if(sSequence.equalsIgnoreCase("busy_sip") == true)
  9760. {
  9761. //SIP 통화중
  9762. }
  9763. else if(sSequence.equalsIgnoreCase("reject") == true)
  9764. {
  9765. //거절
  9766. }
  9767. if(sStatus.equalsIgnoreCase("idle") == true)
  9768. {
  9769. //대기
  9770. }
  9771. else if(sStatus.equalsIgnoreCase("ringing") == true)
  9772. {
  9773. //연결중
  9774. }
  9775. else if(sStatus.equalsIgnoreCase("talking") == true)
  9776. {
  9777. //통화중
  9778. }
  9779. //응답값 입력 필요!!
  9780. //김용성 과장님 작업필요
  9781. reply_Message = "null";
  9782. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  9783. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  9784. retXML += " </service>\r\n</imap>";
  9785. return retXML;
  9786. }
  9787. catch (RuntimeException re) {
  9788. LogUtil.errorLogInfo("", TAG, re);
  9789. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  9790. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  9791. retXML += " </service>\r\n</imap>";
  9792. return retXML;
  9793. }
  9794. catch (Exception e)
  9795. {
  9796. //e.printStackTrace();
  9797. LogUtil.errorLogInfo("", TAG, e);
  9798. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  9799. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  9800. retXML += " </service>\r\n</imap>";
  9801. return retXML;
  9802. }
  9803. }
  9804. public String ProcChatMessage(Element ele)
  9805. {
  9806. String retXML = "";
  9807. String sChatMessage = "error";
  9808. String sMessage = "error";
  9809. try
  9810. {
  9811. NodeList items = ele.getElementsByTagName("chat");
  9812. Node item = items.item(0);
  9813. NamedNodeMap attrsParam = item.getAttributes();
  9814. sChatMessage = trimquotation(item.getTextContent());
  9815. ///////////////////////////////////////////////
  9816. items = ele.getElementsByTagName("message");
  9817. item = items.item(0);
  9818. attrsParam = item.getAttributes();
  9819. sMessage = trimquotation(item.getTextContent());
  9820. ///////////////////////////////////////////////
  9821. //test
  9822. Log.d(TAG, "sChatMessage is " + sChatMessage);
  9823. Log.d(TAG, "sMessage is " + sMessage);
  9824. //test
  9825. Intent intent = new Intent();
  9826. intent.setAction(define.NOTIFY_ACNAME);
  9827. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  9828. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  9829. intent.putExtra("ADD_MESSAGE", sMessage);
  9830. getApplicationContext().sendBroadcast(intent);
  9831. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  9832. retXML += " <message>\""+"null"+"\"</message>\r\n";
  9833. retXML += " </service>\r\n</imap>";
  9834. return retXML;
  9835. }
  9836. catch (RuntimeException re) {
  9837. LogUtil.errorLogInfo("", TAG, re);
  9838. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  9839. retXML += " </service>\r\n</imap>";
  9840. return retXML;
  9841. }
  9842. catch (Exception e)
  9843. {
  9844. //e.printStackTrace();
  9845. LogUtil.errorLogInfo("", TAG, e);
  9846. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  9847. retXML += " </service>\r\n</imap>";
  9848. return retXML;
  9849. }
  9850. }
  9851. public String ProcEvacuationLadderOpen(Element ele)
  9852. {
  9853. String retXML = "";
  9854. try
  9855. {
  9856. String sDong = null;
  9857. String sHo = null;
  9858. NodeList items = ele.getElementsByTagName("home_info");
  9859. Node item = items.item(0);
  9860. NamedNodeMap attrsParam = item.getAttributes();
  9861. for(int i=0; i< attrsParam.getLength(); i++)
  9862. {
  9863. Node attr = attrsParam.item(i);
  9864. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9865. sDong = trimquotation(attr.getNodeValue());
  9866. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9867. sHo = trimquotation(attr.getNodeValue());
  9868. }
  9869. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9870. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  9871. deviceSet.closeDB();
  9872. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  9873. WallpadStatusData DBMGR = null;
  9874. DBMGR = new WallpadStatusData(getApplicationContext());
  9875. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9876. DBMGR.closeDB();
  9877. String myIP =addc.IPAddress;
  9878. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  9879. String[] SplitedString = myIP.split("\\.");
  9880. if(SplitedString != null)
  9881. {
  9882. if(SplitedString.length == 4)
  9883. {
  9884. int temp = Integer.parseInt(SplitedString[2]);
  9885. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER) temp = temp - 1;
  9886. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW) temp = temp + 1;
  9887. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  9888. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  9889. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  9890. DestStair = String.valueOf(temp);
  9891. }
  9892. }
  9893. if ((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo!=null && sHo.equalsIgnoreCase(DestStair) == true))
  9894. {
  9895. /**
  9896. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  9897. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  9898. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  9899. * **/
  9900. WallpadDeviceSet devset;
  9901. devset = new WallpadDeviceSet(getApplicationContext());
  9902. int StatusVal = devset.GetDeviceSetted("피난사다리");
  9903. devset.closeDB();
  9904. if ( StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  9905. {
  9906. /**
  9907. * 피난사다리 알림!!!
  9908. * **/
  9909. ReceiveNetworkLadderBr(ladderDownSend);
  9910. }
  9911. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  9912. retXML += " </service>\r\n</imap>";
  9913. return retXML;
  9914. }
  9915. else
  9916. {
  9917. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  9918. retXML += " </service>\r\n</imap>";
  9919. return retXML;
  9920. }
  9921. }
  9922. catch (RuntimeException re) {
  9923. LogUtil.errorLogInfo("", TAG, re);
  9924. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  9925. retXML += " </service>\r\n</imap>";
  9926. return retXML;
  9927. }
  9928. catch (Exception e)
  9929. {
  9930. //e.printStackTrace();
  9931. LogUtil.errorLogInfo("", TAG, e);
  9932. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  9933. retXML += " </service>\r\n</imap>";
  9934. return retXML;
  9935. }
  9936. }
  9937. private void ReceiveNetworkLadderBr(int val)
  9938. {
  9939. int base = 7000;
  9940. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  9941. int Menu_Start_Option = 1;
  9942. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  9943. int AlarmStatus = wdb.GetAlarmStatus();
  9944. wdb.closeDB();
  9945. boolean MgrAppRun = false;
  9946. final String packageNameMgr = "com.artncore.managersetting";
  9947. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  9948. if( MgrAppRun )
  9949. return;
  9950. if (AlarmStatus == WallpadStatusData.ALARM_ARISE ||AlarmStatus == WallpadStatusData.ALARM_STOP) return;
  9951. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  9952. int StatusVal = devset.GetDeviceSetted("피난사다리");
  9953. devset.closeDB();
  9954. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  9955. Common.SendAppFinishReqBR(getApplicationContext());
  9956. Intent newintent = new Intent(Intent.ACTION_MAIN);
  9957. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  9958. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  9959. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  9960. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER) newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  9961. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW) newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  9962. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  9963. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  9964. getApplicationContext().startActivity(newintent);
  9965. }
  9966. }
  9967. /**
  9968. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  9969. * @param ele Element Xml 데이터
  9970. * @return String 타입의 응답 메시지 생성
  9971. * **/
  9972. public String SmartLightDetailInfo(Element ele)
  9973. {
  9974. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  9975. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  9976. }
  9977. /**
  9978. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  9979. * @param ele Element Xml 데이터
  9980. * @return String 타입의 응답 메시지 생성
  9981. * **/
  9982. public String KNXDeviceDetailInfo(Element ele) {
  9983. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  9984. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  9985. }
  9986. public String ProcSetServerChange(Element ele) {
  9987. String retXML = "";
  9988. String versionTXT = null;
  9989. try {
  9990. boolean bRet = false;
  9991. NodeList items = ele.getElementsByTagName("ver_server");
  9992. Node item = items.item(0);
  9993. Node text = item.getFirstChild();
  9994. versionTXT = trimquotation(text.getNodeValue());
  9995. if (versionTXT.equalsIgnoreCase("1.0")) {
  9996. bRet = true;
  9997. }
  9998. else if ( versionTXT.indexOf("2.") >= 0) {
  9999. bRet = true;
  10000. }
  10001. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10002. if (SetData != null && bRet == true) {
  10003. SetData.SetServerVer(versionTXT);
  10004. SetData.closeDB();
  10005. }
  10006. if (bRet == true) {
  10007. try {
  10008. iMapSverReload tSock = new iMapSverReload();
  10009. tSock.start();
  10010. } catch (IOException e) {
  10011. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  10012. //e.printStackTrace();
  10013. LogUtil.errorLogInfo("", TAG, e);
  10014. }
  10015. }
  10016. // 버전 체크해서
  10017. // 응답하고 나서
  10018. // 수신부 쓰레드 재 로딩..
  10019. if (versionTXT != null && bRet == true) {
  10020. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  10021. retXML += " </service>\r\n</imap>";
  10022. return retXML;
  10023. }
  10024. else {
  10025. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10026. retXML += " </service>\r\n</imap>";
  10027. return retXML;
  10028. }
  10029. } catch (RuntimeException re) {
  10030. LogUtil.errorLogInfo("", TAG, re);
  10031. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10032. retXML += " </service>\r\n</imap>";
  10033. return retXML;
  10034. }
  10035. catch (Exception e) {
  10036. //e.printStackTrace();
  10037. LogUtil.errorLogInfo("", TAG, e);
  10038. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10039. retXML += " </service>\r\n</imap>";
  10040. return retXML;
  10041. }
  10042. }
  10043. // 메인 서버 소켓 클래스
  10044. public class iMapSverReload extends Thread {
  10045. ServerSocket svr;
  10046. public iMapSverReload() throws IOException {
  10047. /////////////////////////////////////////////////////////////////////
  10048. // 신형 단지서버 사용 유무를 가져온다.
  10049. /////////////////////////////////////////////////////////////////////
  10050. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10051. if (SetData != null) {
  10052. String serverVesionInfo = SetData.GetServerVer();
  10053. SetData.closeDB();
  10054. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  10055. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10056. boolean retValue = devset.SetSubDevListItem( false , define.DEVICE_ID_NEW_DANJI_SERVER);
  10057. devset.closeDB();
  10058. }
  10059. else {
  10060. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10061. boolean retValue = devset.SetSubDevListItem( true , define.DEVICE_ID_NEW_DANJI_SERVER);
  10062. devset.closeDB();
  10063. }
  10064. }
  10065. try {
  10066. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  10067. // mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  10068. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  10069. if(danjiserverType == 1)
  10070. {
  10071. mNewDanjiServer = false;
  10072. }
  10073. else if(danjiserverType == 2)
  10074. {
  10075. mNewDanjiServer = true;
  10076. }
  10077. else
  10078. {
  10079. mNewDanjiServer = true;
  10080. }
  10081. wallpadDeviceSet.closeDB();
  10082. } catch (RuntimeException re) {
  10083. LogUtil.errorLogInfo("", TAG, re);
  10084. mNewDanjiServer = false;
  10085. }
  10086. catch (Exception e) {
  10087. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  10088. //e.printStackTrace();
  10089. LogUtil.errorLogInfo("", TAG, e);
  10090. mNewDanjiServer = false;
  10091. }
  10092. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer );
  10093. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  10094. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  10095. // 관리 PC IP도 변경하도록 한다.
  10096. if (mNewDanjiServer == true) {
  10097. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  10098. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  10099. wallpadStatusData.closeDB();
  10100. }
  10101. else {
  10102. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  10103. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  10104. wallpadStatusData.closeDB();
  10105. }
  10106. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  10107. }
  10108. public void run() {
  10109. try {
  10110. try{ Thread.sleep(400); }
  10111. catch (RuntimeException re) {
  10112. LogUtil.errorLogInfo("", TAG, re);
  10113. }
  10114. catch (Exception e){
  10115. LogUtil.errorLogInfo("", TAG, e);
  10116. }
  10117. SvrSock.destoryThread();
  10118. for( int i = 0 ; i < 20 ; i++ )
  10119. {
  10120. if( SvrSock.isAlive() == false )
  10121. {
  10122. Log.d(TAG, " Receive Socket Reload i = : " + i );
  10123. break;
  10124. }
  10125. else
  10126. {
  10127. Log.d(TAG, " is Live Socket Reload i = : " + i );
  10128. }
  10129. try{ Thread.sleep(100); }
  10130. catch (RuntimeException re) {
  10131. LogUtil.errorLogInfo("", TAG, re);
  10132. }
  10133. catch (Exception e){
  10134. LogUtil.errorLogInfo("", TAG, e);
  10135. }
  10136. }
  10137. SvrSock = new iMapSverSocket();
  10138. SvrSock.start();
  10139. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  10140. try{ Thread.sleep(3000); }
  10141. catch (RuntimeException re) {
  10142. LogUtil.errorLogInfo("", TAG, re);
  10143. }
  10144. catch (Exception e){
  10145. LogUtil.errorLogInfo("", TAG, e);
  10146. }
  10147. try
  10148. {
  10149. Intent intent = new Intent();
  10150. intent.setAction(define.NOTIFY_ACNAME);
  10151. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  10152. getApplicationContext().sendBroadcast(intent);
  10153. }
  10154. catch (RuntimeException re) {
  10155. LogUtil.errorLogInfo("", TAG, re);
  10156. }
  10157. catch (Exception e)
  10158. {
  10159. //e.printStackTrace();
  10160. LogUtil.errorLogInfo("", TAG, e);
  10161. }
  10162. } catch (IOException e) {
  10163. //e.printStackTrace();
  10164. LogUtil.errorLogInfo("", TAG, e);
  10165. }
  10166. }
  10167. }
  10168. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  10169. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  10170. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  10171. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  10172. public static final int SCHEDULE_START_CALLAPP = 30004;
  10173. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  10174. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  10175. public class SchedulerThread extends Thread
  10176. {
  10177. boolean doRun;
  10178. AddressSet addr;
  10179. String AddressStr;
  10180. String IPaddr;
  10181. String VerBSP = "";
  10182. String VerAPP;
  10183. String VerSetting;
  10184. String VerNews;
  10185. String VerWeather;
  10186. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  10187. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  10188. private jni mGleInterface = null;
  10189. private final int LIVE_SIGNAL_TIME = 20;
  10190. private int m_LiveSignalCount = 0;
  10191. private int m_MainAppLiveCount = 0;
  10192. Handler ScheDuleHandler = new Handler(){
  10193. public void handleMessage(Message msg) {
  10194. switch (msg.what) {
  10195. case SCHEDULE_START_HEARTBEAT:
  10196. {
  10197. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  10198. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10199. heartbeatP = DBMGR.GetHeartbeatPeriod();
  10200. DBMGR.closeDB();
  10201. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  10202. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  10203. }
  10204. break;
  10205. case SCHEDULE_CHANGE_HEARTBEAT:
  10206. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  10207. synchronized (ScheduleList) {
  10208. ScheduleData CheckData;
  10209. for (int i = 0; i < ScheduleList.size(); i++) {
  10210. CheckData = ScheduleList.get(i);
  10211. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  10212. Calendar cal = new GregorianCalendar();
  10213. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10214. heartbeatP = DBMGR.GetHeartbeatPeriod();
  10215. DBMGR.closeDB();
  10216. cal.add(Calendar.MINUTE,heartbeatP);
  10217. CheckData.TData = cal;
  10218. ScheduleList.set(i, CheckData);
  10219. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  10220. return;
  10221. }
  10222. }
  10223. }
  10224. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  10225. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  10226. break;
  10227. case SCHEDULE_START_STATUSBEAT:
  10228. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  10229. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  10230. break;
  10231. case SCHEDULE_CHANGE_STATUSBEAT:
  10232. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  10233. synchronized(ScheduleList) {
  10234. ScheduleData CheckData;
  10235. for (int i = 0; i < ScheduleList.size(); i++) {
  10236. CheckData = ScheduleList.get(i);
  10237. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  10238. Calendar cal = new GregorianCalendar();
  10239. cal.add(Calendar.MINUTE,heartbeatP);
  10240. CheckData.TData = cal;
  10241. ScheduleList.set(i, CheckData);
  10242. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  10243. return;
  10244. }
  10245. }
  10246. }
  10247. break;
  10248. case SCHEDULE_START_CALLAPP:
  10249. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  10250. // Bundle bundle = new Bundle();
  10251. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  10252. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  10253. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  10254. // .putExtra(ITEM_CALL_DATA, bundle);
  10255. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10256. // iMAPstartActivity(intent);
  10257. break;
  10258. }
  10259. }
  10260. };
  10261. Handler GetHandler(){
  10262. return ScheDuleHandler;
  10263. }
  10264. public class ScheduleData
  10265. {
  10266. Calendar TData;
  10267. String ActionSTR;
  10268. public ScheduleData(Calendar tdata, String ActionStr)
  10269. {
  10270. TData = tdata;
  10271. ActionSTR = ActionStr;
  10272. }
  10273. }
  10274. public SchedulerThread()
  10275. {
  10276. doRun = true;
  10277. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10278. addr = DBMGR.getAddressMGR();
  10279. VerAPP = DBMGR.GetAPPVer();
  10280. VerSetting = DBMGR.GetSettingVer();
  10281. VerNews = DBMGR.GetNoticeVer();
  10282. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  10283. DBMGR.closeDB();
  10284. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  10285. {
  10286. try { mGleInterface = new jni(); }
  10287. catch (RuntimeException re) {
  10288. LogUtil.errorLogInfo("", TAG, re);
  10289. }
  10290. catch (Exception e) {
  10291. Log.e( "iMapServer" ,"[ExceptionError] - onCreate->mGleInterface Create : " + e);
  10292. }
  10293. }
  10294. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT))
  10295. {
  10296. VerAPP = GetAppVersion();
  10297. }
  10298. AddressStr = addr.Dong+"동"+addr.Ho+"호";
  10299. IPaddr = addr.IPAddress;
  10300. ScheDulerHandler = ScheDuleHandler;
  10301. }
  10302. public void reg_schedule(int min, String Action)
  10303. {
  10304. for (int i = 0; i <ScheduleList.size();i++)
  10305. {
  10306. ScheduleData scdata = ScheduleList.get(i);
  10307. if (scdata.ActionSTR.equals(Action))
  10308. {
  10309. ScheduleList.remove(i);
  10310. break;
  10311. }
  10312. }
  10313. Calendar cal = new GregorianCalendar();
  10314. cal.add(Calendar.MINUTE,min);
  10315. ScheduleData regData = new ScheduleData(cal,Action );
  10316. synchronized(ScheduleList)
  10317. {
  10318. ScheduleList.add(regData);
  10319. }
  10320. }
  10321. private void doSchedule(String doing)
  10322. {
  10323. String[] doingData = doing.split(";");
  10324. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT))
  10325. {
  10326. try{
  10327. String SendingStr = MakeHeartbeat();
  10328. SendToServer(SendingStr);
  10329. Calendar cal = new GregorianCalendar();
  10330. 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));
  10331. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10332. DBMGR.SetLastHeartbeat(timedata);
  10333. heartbeatP = DBMGR.GetHeartbeatPeriod();
  10334. DBMGR.closeDB();
  10335. }
  10336. catch (RuntimeException re) {
  10337. LogUtil.errorLogInfo("", TAG, re);
  10338. }
  10339. catch (Exception e)
  10340. {
  10341. //e.printStackTrace();
  10342. LogUtil.errorLogInfo("", TAG, e);
  10343. }
  10344. }
  10345. else if (doingData[0].equals("UPDATETIME"))
  10346. {
  10347. }
  10348. else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT))
  10349. {
  10350. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  10351. if (!Common.getDeviceServeiceLoadComplite()) return;
  10352. String SendingStr = MakeStatusReport();
  10353. if (SendingStr == null) return;
  10354. SendToServer(SendingStr);
  10355. Calendar cal = new GregorianCalendar();
  10356. 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));
  10357. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10358. DBMGR.SetLastStatusbeat(timedata);
  10359. DBMGR.closeDB();
  10360. int StatusP = 720;
  10361. try {
  10362. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10363. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  10364. devset.closeDB();
  10365. if (StatusVal == null) StatusP = 720;
  10366. else StatusP = Integer.parseInt(StatusVal[1]);
  10367. }
  10368. catch (RuntimeException re) {
  10369. LogUtil.errorLogInfo("", TAG, re);
  10370. }
  10371. catch (Exception e)
  10372. {
  10373. //e.printStackTrace();
  10374. LogUtil.errorLogInfo("", TAG, e);
  10375. }
  10376. reg_schedule(StatusP,SCHEDULE_ACTION_STATUSBEAT);
  10377. }
  10378. }
  10379. private String MakeHeartbeat() {
  10380. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10381. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  10382. VerNews = DBMGR.GetNoticeVer();
  10383. VerSetting = DBMGR.GetSettingVer();
  10384. String VerServer = DBMGR.GetServerVer();
  10385. DBMGR.closeDB();
  10386. if (VerServer == null) {
  10387. Log.d(TAG, "VerServer null");
  10388. VerServer = "1.0";
  10389. }
  10390. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  10391. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  10392. wallpadDeviceSet.closeDB();
  10393. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  10394. // 스마트 분전반
  10395. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  10396. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  10397. String retStr = XMLHeader+
  10398. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  10399. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  10400. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  10401. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  10402. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  10403. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  10404. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  10405. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  10406. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  10407. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  10408. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  10409. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n"+
  10410. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n"+
  10411. "</service>\r\n</imap>";
  10412. return retStr;
  10413. }
  10414. else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  10415. // TODO KNX 분전반
  10416. // String retStr = XMLHeader+
  10417. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  10418. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  10419. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  10420. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  10421. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  10422. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  10423. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  10424. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  10425. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  10426. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  10427. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  10428. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  10429. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  10430. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  10431. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  10432. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  10433. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  10434. // "</service>\r\n</imap>";
  10435. String retStr = XMLHeader+
  10436. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  10437. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  10438. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  10439. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  10440. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  10441. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  10442. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  10443. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  10444. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  10445. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  10446. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  10447. "</service>\r\n</imap>";
  10448. return retStr;
  10449. }
  10450. else {
  10451. String retStr = XMLHeader+
  10452. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  10453. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  10454. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  10455. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  10456. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  10457. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  10458. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  10459. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  10460. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  10461. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  10462. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  10463. "</service>\r\n</imap>";
  10464. return retStr;
  10465. }
  10466. }
  10467. public String GetAppVersion() {
  10468. PackageInfo pi = null;
  10469. try {
  10470. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  10471. }
  10472. catch (RuntimeException re) {
  10473. LogUtil.errorLogInfo("", TAG, re);
  10474. }
  10475. catch (Exception e) {
  10476. LogUtil.errorLogInfo("", TAG, e);
  10477. }
  10478. return pi.versionName;
  10479. }
  10480. boolean isAlawaysrun = true;
  10481. public void run()
  10482. {
  10483. while(/*doRun*/ isAlawaysrun)
  10484. {
  10485. //Common.DebugLog("SchedulerThread ------ 10Sec");
  10486. CheckHeartBeat();
  10487. CheckStatusBeat();
  10488. CheckWallPadLiveSignal();
  10489. LiveCheckRebooting();
  10490. try { Thread.sleep(10000);}
  10491. catch (RuntimeException re) {
  10492. LogUtil.errorLogInfo("", TAG, re);
  10493. }
  10494. catch (Exception e) {
  10495. LogUtil.errorLogInfo("", TAG, e);
  10496. }
  10497. }
  10498. }
  10499. public void SetLive() {
  10500. m_MainAppLiveCount++;
  10501. }
  10502. private int CheckTime30Sec = 0 ;
  10503. private void LiveCheckRebooting() {
  10504. try {
  10505. CheckTime30Sec++;
  10506. if (CheckTime30Sec%20 == 0) {
  10507. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  10508. // // 10초마다 수행되는 함수이니....
  10509. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  10510. // if (m_MainAppLiveCount == 0) {
  10511. // //리셋
  10512. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  10513. // {
  10514. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  10515. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  10516. // pm.userActivity(8, true);
  10517. // }
  10518. // else
  10519. // {
  10520. // Log.d(TAG, "Main App Down Reset IHN_750");
  10521. // WallPadInterface wpdifc = new WallPadInterface();
  10522. // wpdifc.WachdogSystemReset();
  10523. // }
  10524. // }
  10525. // }
  10526. CheckTime30Sec = 0;
  10527. }
  10528. if( CheckTime30Sec >= 30000)
  10529. {
  10530. CheckTime30Sec = 0;
  10531. }
  10532. }
  10533. catch (RuntimeException re) {
  10534. LogUtil.errorLogInfo("", TAG, re);
  10535. }
  10536. catch (Exception e )
  10537. {
  10538. //e.printStackTrace();
  10539. LogUtil.errorLogInfo("", TAG, e);
  10540. }
  10541. }
  10542. private void CheckWallPadLiveSignal()
  10543. {
  10544. try
  10545. {
  10546. int nTime = LIVE_SIGNAL_TIME / 10;
  10547. m_LiveSignalCount++;
  10548. if( m_LiveSignalCount >= nTime )
  10549. {
  10550. m_LiveSignalCount = 0;
  10551. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  10552. }
  10553. }
  10554. catch (RuntimeException re) {
  10555. LogUtil.errorLogInfo("", TAG, re);
  10556. }
  10557. catch (Exception e )
  10558. {
  10559. Log.e("imapServer" , "CheckWallPadLiveSignal Exeption :" + e);
  10560. }
  10561. }
  10562. protected void CheckStatusBeat()
  10563. {
  10564. try {
  10565. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  10566. String statusbeatdata = WPD.GetLastStatusbeat();
  10567. WPD.closeDB();
  10568. int StatusP = 720;
  10569. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10570. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  10571. if (StatusVal == null) StatusP = 720;
  10572. else
  10573. StatusP = Integer.parseInt(StatusVal[1]);
  10574. devset.closeDB();
  10575. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  10576. }
  10577. catch (RuntimeException re) {
  10578. LogUtil.errorLogInfo("", TAG, re);
  10579. }
  10580. catch (Exception e)
  10581. {
  10582. //e.printStackTrace();
  10583. LogUtil.errorLogInfo("", TAG, e);
  10584. }
  10585. }
  10586. protected void CheckHeartBeat()
  10587. {
  10588. try {
  10589. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  10590. String heartbeatdata = WPD.GetLastHeartbeat();
  10591. int heartbeatPer = WPD.GetHeartbeatPeriod();
  10592. WPD.closeDB();
  10593. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  10594. }
  10595. catch (RuntimeException re) {
  10596. LogUtil.errorLogInfo("", TAG, re);
  10597. }
  10598. catch (Exception e)
  10599. {
  10600. //e.printStackTrace();
  10601. LogUtil.errorLogInfo("", TAG, e);
  10602. }
  10603. }
  10604. protected boolean CheckTime(String CheckT, int period)
  10605. {
  10606. Calendar last = new GregorianCalendar();
  10607. String[] timedata = CheckT.split("[.]");
  10608. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  10609. last.set(Calendar.MONTH, Integer.parseInt(timedata[1])-1);
  10610. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  10611. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  10612. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  10613. last.add(Calendar.MINUTE, period);
  10614. Calendar checkCal = new GregorianCalendar();
  10615. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  10616. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  10617. return true;
  10618. return false;
  10619. }
  10620. }
  10621. class SendMSGToSVR extends Thread
  10622. {
  10623. String sendmsg;
  10624. public SendMSGToSVR(String msg)
  10625. {
  10626. sendmsg = msg;
  10627. }
  10628. public void run()
  10629. {
  10630. Socket sock = null;
  10631. DataOutputStream outstream = null;
  10632. try {
  10633. // 신형 단지서버 사용 유무를 가져온다.
  10634. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  10635. // boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  10636. boolean bNewDanjiServer = false;
  10637. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  10638. if(danjiserverType == 1)
  10639. {
  10640. bNewDanjiServer = false;
  10641. }
  10642. else if(danjiserverType == 2)
  10643. {
  10644. bNewDanjiServer = true;
  10645. }
  10646. else
  10647. {
  10648. bNewDanjiServer = true;
  10649. }
  10650. wallpadDeviceSet.closeDB();
  10651. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  10652. SVRIP = DBMGR.GetServerIP();
  10653. port = DBMGR.GetServerPort();
  10654. DBMGR.closeDB();
  10655. /////////////////////////////////////////////////////////////////////
  10656. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  10657. // 사용중일 경우 암호화 소켓을 생성한다.
  10658. /////////////////////////////////////////////////////////////////////
  10659. if(!bNewDanjiServer)
  10660. {
  10661. sock = new Socket(SVRIP,port);
  10662. }
  10663. else
  10664. {
  10665. int setport = port + 1000;
  10666. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  10667. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  10668. sock = sslClientSocket.getSocket();
  10669. }
  10670. /////////////////////////////////////////////////////////////////////
  10671. if(sock!=null)
  10672. {
  10673. sock.setSoLinger(true, 1000);
  10674. outstream = new DataOutputStream(sock.getOutputStream());
  10675. byte[] outBF = sendmsg.getBytes("euc-kr");
  10676. outstream.write(outBF);
  10677. outstream.flush();
  10678. }
  10679. }
  10680. catch (RuntimeException re) {
  10681. LogUtil.errorLogInfo("", TAG, re);
  10682. }
  10683. catch (Exception e) {
  10684. //e.printStackTrace();
  10685. LogUtil.errorLogInfo("", TAG, e);
  10686. }
  10687. finally {
  10688. if(outstream!=null) {
  10689. try {
  10690. outstream.close();
  10691. } catch (IOException e) {
  10692. LogUtil.errorLogInfo("", TAG, e);
  10693. }
  10694. }
  10695. outstream = null;
  10696. if(sock!=null) {
  10697. try {
  10698. sock.close();
  10699. } catch (IOException e) {
  10700. LogUtil.errorLogInfo("", TAG, e);
  10701. }
  10702. }
  10703. sock = null;
  10704. }
  10705. }
  10706. }
  10707. private void SendToServer(String msg)
  10708. {
  10709. SendMSGToSVR msan = new SendMSGToSVR(msg);
  10710. msan.start();
  10711. }
  10712. boolean StatusBeatRequested = false;
  10713. private String MakeStatusReport()
  10714. {
  10715. try
  10716. {
  10717. String ServiceType = StatusBeatRequested?"requested":"notice";
  10718. StatusBeatRequested = false;
  10719. String RetData = XMLHeader+"<service type=\""+ServiceType+"\" name=\"statusbeat\"> \r\n";
  10720. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  10721. String[] typeList = SettManager.GetTypeList();
  10722. if (typeList == null || typeList.length == 0) {
  10723. DefaultProcauscultateReq(SettManager);
  10724. typeList = SettManager.GetTypeList();
  10725. }
  10726. SettManager.closeDB();
  10727. String[] ControlList;
  10728. String Vender = "null";
  10729. String devid = "null";
  10730. String Model = "null";
  10731. String subunitcnt = "null";
  10732. String statusRate = "null";
  10733. String statusType = "null";
  10734. String message = "null";
  10735. int itemCNT = 0;
  10736. int totalGroup = 0;
  10737. int totalItem = 0;
  10738. String ControlDEVList;
  10739. String ContentList = " ";
  10740. if(typeList!=null)
  10741. {
  10742. for (int i = 0; i < typeList.length; i++)
  10743. {
  10744. if (typeList[i].equals("ctrl_device"))
  10745. {
  10746. SettManager = new WallpadDevStatus(getApplicationContext());
  10747. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  10748. SettManager.closeDB();
  10749. ControlDEVList = "";
  10750. if(ControlList!=null)
  10751. {
  10752. for (int k = 0; k < ControlList.length; k++)
  10753. {
  10754. if (ControlList[k].equals("light"))
  10755. {
  10756. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10757. int[] lightinfo = devSet.Get_Light_info();
  10758. devSet.closeDB();
  10759. if (lightinfo[0]==1)
  10760. {
  10761. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)
  10762. {
  10763. subunitcnt = String.valueOf(lightinfo[2]);
  10764. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  10765. devid = "0x11";
  10766. Vender = "null";
  10767. Model = "null";
  10768. if(lightCTR!=null)
  10769. {
  10770. lightCTR.TRInfo.GetTransactionList(0);
  10771. statusRate = String.format("%d/%d",lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess+lightCTR.TRInfo.RecentFail));
  10772. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  10773. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10774. message = "null";
  10775. ControlDEVList+=" <unit type=\"light\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10776. itemCNT++;
  10777. }
  10778. }
  10779. else
  10780. {
  10781. subunitcnt = String.valueOf(lightinfo[2]);
  10782. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  10783. if(MultiSW!=null)
  10784. {
  10785. MultiSW.Refresh((byte)0xFF, false);
  10786. byte Bdevid = 0x51;
  10787. for(int j = 0; j <MultiSW.data.DeviceCnt;j++ )
  10788. {
  10789. devid = String.format("0x%02X",Bdevid+j);
  10790. Vender = "null";
  10791. Model = "null";
  10792. MultiSW.TRInfo.GetTransactionList(j);
  10793. statusRate = String.format("%d/%d",MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess+MultiSW.TRInfo.RecentFail));
  10794. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  10795. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10796. ControlDEVList+=" <unit type=\"light\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10797. itemCNT++;
  10798. }
  10799. }
  10800. }
  10801. }
  10802. else
  10803. {
  10804. Vender = "null";
  10805. devid = "null";
  10806. Model = "null";
  10807. subunitcnt = "null";
  10808. statusRate = "null";
  10809. message = "null";
  10810. }
  10811. }
  10812. else if (ControlList[k].equals("thermostat"))
  10813. {
  10814. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10815. int ret = devSet.Get_Temper_Info();
  10816. devSet.closeDB();
  10817. if (ret == 1)
  10818. {
  10819. // 난방 종류를 얻어온다.
  10820. int HeatingKind = mWallPadAPI.GetHeatingKind();
  10821. HeatingV1API heatingV1API = null;
  10822. HeatingV2API heatingV2API = null;
  10823. // 종류별 API를 로딩한다.
  10824. if(HeatingKind == 1)
  10825. {
  10826. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  10827. if(heatingV1API!=null)
  10828. {
  10829. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  10830. devid = "0x21";
  10831. Vender = "null";
  10832. Model = "null";
  10833. heatingV1API.TRInfo.GetTransactionList(0);
  10834. statusRate = String.format("%d/%d",heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess+heatingV1API.TRInfo.RecentFail));
  10835. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  10836. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10837. message = "null";
  10838. }
  10839. }
  10840. else if(HeatingKind == 2)
  10841. {
  10842. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  10843. if(heatingV2API!=null)
  10844. {
  10845. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  10846. devid = "0x28";
  10847. Vender = "null";
  10848. Model = "null";
  10849. heatingV2API.TRInfo.GetTransactionList(0);
  10850. statusRate = String.format("%d/%d",heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess+heatingV2API.TRInfo.RecentFail));
  10851. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  10852. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10853. message = "null";
  10854. }
  10855. }
  10856. else
  10857. {
  10858. subunitcnt = "null";
  10859. devid = "null";
  10860. Vender = "null";
  10861. Model = "null";
  10862. statusRate = "0/0";
  10863. statusType = "bad";
  10864. message = "null";
  10865. }
  10866. ControlDEVList+=" <unit type=\"thermostat\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10867. itemCNT++;
  10868. }
  10869. else
  10870. {
  10871. }
  10872. }
  10873. else if (ControlList[k].equals("gas"))
  10874. {
  10875. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10876. if (devSet.Get_GAS_Info() == 1)
  10877. {
  10878. GasAPI GasCTR = mWallPadAPI.Get_GasController();
  10879. subunitcnt = "1";
  10880. devid = "0x31";
  10881. Vender = "null";
  10882. Model = "null";
  10883. if(GasCTR!=null)
  10884. {
  10885. GasCTR.TRInfo.GetTransactionList(0);
  10886. statusRate = String.format("%d/%d",GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess+GasCTR.TRInfo.RecentFail));
  10887. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  10888. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10889. message = "null";
  10890. ControlDEVList+=" <unit type=\"gas\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10891. itemCNT++;
  10892. }
  10893. }
  10894. else
  10895. {
  10896. }
  10897. devSet.closeDB();
  10898. }
  10899. else if (ControlList[k].equals("doorlock"))
  10900. {
  10901. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10902. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  10903. if (doorlockInfo[0] == 1)
  10904. {
  10905. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  10906. subunitcnt = "1";
  10907. devid = "0x41";
  10908. Vender = "null";
  10909. Model = "null";
  10910. if(DoorCTR!=null)
  10911. {
  10912. DoorCTR.TRInfo.GetTransactionList(0);
  10913. statusRate = String.format("%d/%d",DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess+DoorCTR.TRInfo.RecentFail));
  10914. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  10915. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10916. message = "null";
  10917. ControlDEVList+=" <unit type=\"doorlock\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10918. itemCNT++;
  10919. }
  10920. }
  10921. else
  10922. {
  10923. }
  10924. devSet.closeDB();
  10925. }
  10926. else if (ControlList[k].equals("ventil"))
  10927. {
  10928. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10929. int[] ventilInfo = devSet.Get_Ventil_Info();
  10930. if (ventilInfo[0] == 1)
  10931. {
  10932. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  10933. subunitcnt = "1";
  10934. devid = "0x61";
  10935. Vender = "null";
  10936. Model = "null";
  10937. if(VentilCTR!=null)
  10938. {
  10939. VentilCTR.TRInfo.GetTransactionList(0);
  10940. statusRate = String.format("%d/%d",VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess+VentilCTR.TRInfo.RecentFail));
  10941. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  10942. statusType = surate>70?"good":surate>30?"notgood":"bad";
  10943. message = "null";
  10944. ControlDEVList+=" <unit type=\"ventil\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  10945. itemCNT++;
  10946. }
  10947. }
  10948. else
  10949. {
  10950. }
  10951. devSet.closeDB();
  10952. }
  10953. else if (ControlList[k].equals("aircon"))
  10954. {
  10955. }
  10956. else if (ControlList[k].equals("curtain"))
  10957. {
  10958. }
  10959. }
  10960. if (itemCNT > 0)
  10961. {
  10962. ContentList+="<group type=\"ctrl_device\" count=\""+itemCNT+"\">\r\n";
  10963. ContentList+=ControlDEVList;
  10964. ContentList+="</group>\r\n";
  10965. totalGroup++;
  10966. totalItem+=itemCNT;
  10967. }
  10968. }
  10969. }
  10970. else if (typeList[i].equals("talk_device"))
  10971. {
  10972. SettManager = new WallpadDevStatus(getApplicationContext());
  10973. ControlList = SettManager.GetSettingGroupData("talk_device");
  10974. SettManager.closeDB();
  10975. itemCNT = 0;
  10976. ControlDEVList = "";
  10977. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  10978. if(testAPI!=null)
  10979. testAPI.GetVersion();
  10980. if(ControlList!=null)
  10981. {
  10982. for (int k = 0; k < ControlList.length; k++)
  10983. {
  10984. if (ControlList[k].equals("kitchen_tv") && testAPI!=null)
  10985. {
  10986. 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";
  10987. itemCNT++;
  10988. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  10989. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  10990. }
  10991. else if (ControlList[k].equals("bath_phone") && testAPI!=null)
  10992. {
  10993. 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";
  10994. itemCNT++;
  10995. }
  10996. else if (ControlList[k].equals("subhome_dev"))
  10997. {
  10998. }
  10999. }
  11000. if (itemCNT > 0)
  11001. {
  11002. ContentList+="<group type=\"talk_device\" count=\""+itemCNT+"\">\r\n";
  11003. ContentList+=ControlDEVList;
  11004. ContentList+="</group>\r\n";
  11005. totalGroup++;
  11006. totalItem+=itemCNT;
  11007. }
  11008. }
  11009. }
  11010. else if (typeList[i].equals("sensor"))
  11011. {
  11012. SettManager = new WallpadDevStatus(getApplicationContext());
  11013. ControlList = SettManager.GetSettingGroupData("sensor");
  11014. SettManager.closeDB();
  11015. itemCNT = 0;
  11016. ControlDEVList = "";
  11017. if(ControlList!=null)
  11018. {
  11019. for (int k = 0; k < ControlList.length; k++)
  11020. {
  11021. if (ControlList[k].equals("magnetic"))
  11022. {
  11023. WallPadInterface wpifc = new WallPadInterface();
  11024. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  11025. String SenStateCom;
  11026. String SenStateType;
  11027. if (MagSen==1)
  11028. {
  11029. SenStateCom = "1/1";
  11030. SenStateType = "";
  11031. }
  11032. else
  11033. {
  11034. SenStateCom = "0/1";
  11035. SenStateType = "perfect";
  11036. }
  11037. ControlDEVList+= " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  11038. itemCNT++;
  11039. }
  11040. else if (ControlList[k].equals("bugout"))
  11041. {
  11042. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11043. int sensor = devSet.Get_Sensor_Set();
  11044. devSet.closeDB();
  11045. if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0)
  11046. {
  11047. WallPadInterface wpifc = new WallPadInterface();
  11048. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11049. String SenStateCom;
  11050. String SenStateType;
  11051. if (outSen==1)
  11052. {
  11053. SenStateCom = "1/1";
  11054. SenStateType = "bad";
  11055. }
  11056. else
  11057. {
  11058. SenStateCom = "0/1";
  11059. SenStateType = "perfect";
  11060. }
  11061. ControlDEVList+= " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  11062. itemCNT++;
  11063. }
  11064. }
  11065. else if (ControlList[k].equals("bugin"))
  11066. {
  11067. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11068. int sensor = devSet.Get_Sensor_Set();
  11069. devSet.closeDB();
  11070. if ((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0)
  11071. {
  11072. WallPadInterface wpifc = new WallPadInterface();
  11073. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  11074. String SenStateCom;
  11075. String SenStateType;
  11076. if (InSen==1)
  11077. {
  11078. SenStateCom = "1/1";
  11079. SenStateType = "bad";
  11080. }
  11081. else
  11082. {
  11083. SenStateCom = "0/1";
  11084. SenStateType = "perfect";
  11085. }
  11086. ControlDEVList+= " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  11087. itemCNT++;
  11088. }
  11089. }
  11090. else if (ControlList[k].equals("fire"))
  11091. {
  11092. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  11093. }
  11094. else if (ControlList[k].equals("gas"))
  11095. {
  11096. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  11097. }
  11098. }
  11099. if (itemCNT > 0)
  11100. {
  11101. ContentList+="<group type=\"sensor\" count=\""+itemCNT+"\">\r\n";
  11102. ContentList+=ControlDEVList;
  11103. ContentList+="</group>\r\n";
  11104. totalGroup++;
  11105. totalItem+=itemCNT;
  11106. }
  11107. }
  11108. }
  11109. else if (typeList[i].equals("extended"))
  11110. {
  11111. SettManager = new WallpadDevStatus(getApplicationContext());
  11112. ControlList = SettManager.GetSettingGroupData("extended");
  11113. SettManager.closeDB();
  11114. itemCNT=0;
  11115. ControlDEVList = "";
  11116. if(ControlList!=null)
  11117. {
  11118. for (int k = 0; k < ControlList.length; k++)
  11119. {
  11120. if (ControlList[k].equals("gateway"))
  11121. {
  11122. }
  11123. else if (ControlList[k].equals("handy"))
  11124. {
  11125. }
  11126. else if (ControlList[k].equals("smartswitch"))
  11127. {
  11128. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11129. int[] BatchInfo = devSet.Get_BatchSW_Info();
  11130. devSet.closeDB();
  11131. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART )
  11132. {
  11133. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  11134. SmartSWCTR.TRInfo.GetTransactionList(0);
  11135. subunitcnt = "1";
  11136. statusRate = String.format("%d/%d",SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess+SmartSWCTR.TRInfo.RecentFail));
  11137. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  11138. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11139. message = "null";
  11140. ControlDEVList+=" <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11141. itemCNT++;
  11142. }
  11143. else
  11144. {
  11145. }
  11146. }
  11147. else if (ControlList[k].equals("energymeter"))
  11148. {
  11149. }
  11150. }
  11151. if (itemCNT > 0)
  11152. {
  11153. ContentList+="<group type=\"extended\" count=\""+itemCNT+"\">\r\n";
  11154. ContentList+=ControlDEVList;
  11155. ContentList+="</group>\r\n";
  11156. totalGroup++;
  11157. totalItem+=itemCNT;
  11158. }
  11159. }
  11160. }
  11161. }
  11162. SettManager.closeDB();
  11163. ContentList+="</guidemap> \r\n";
  11164. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\""+totalGroup+"\" device_cnt=\""+totalItem+"\">\r\n";
  11165. RetData += ContentList;
  11166. String LogSet;
  11167. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  11168. RetData+=LogSet;
  11169. try {
  11170. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  11171. String[] ResetData = WsDB.GetResetSchedule();
  11172. WsDB.closeDB();
  11173. if (!ResetData[0].equals("NONE"))
  11174. {
  11175. int type = Integer.parseInt(ResetData[0]);
  11176. if (type == WallpadStatusData.RESET_MONTH)
  11177. LogSet="<reset_info enable=\"true\" type=\"month\" cycle=\""+ResetData[1]+"\" time=\""+ResetData[2]+"\"/>\r\n";
  11178. else if (type == WallpadStatusData.RESET_WEEK)
  11179. LogSet="<reset_info enable=\"true\" type=\"week\" cycle=\""+ResetData[1]+"\" time=\""+ResetData[2]+"\"/>\r\n";
  11180. else
  11181. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11182. }
  11183. else
  11184. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11185. }
  11186. catch (RuntimeException re) {
  11187. LogUtil.errorLogInfo("", TAG, re);
  11188. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11189. } catch (Exception e)
  11190. {
  11191. //e.printStackTrace();
  11192. LogUtil.errorLogInfo("", TAG, e);
  11193. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  11194. }
  11195. RetData+=LogSet;
  11196. RetData+="</service>\r\n</imap>\r\n";
  11197. }
  11198. return RetData;
  11199. }
  11200. catch (RuntimeException re) {
  11201. LogUtil.errorLogInfo("", TAG, re);
  11202. return null;
  11203. }
  11204. catch (Exception e )
  11205. {
  11206. //e.printStackTrace();
  11207. LogUtil.errorLogInfo("", TAG, e);
  11208. return null;
  11209. }
  11210. }
  11211. private String getKNXDeviceStatus(int device) {
  11212. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  11213. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  11214. String status = knxHeartbeat.getStatus();
  11215. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  11216. return status;
  11217. }
  11218. private String getKNXDeviceCause(int device) {
  11219. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  11220. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  11221. String cause = knxHeartbeat.getCause();
  11222. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  11223. return cause;
  11224. }
  11225. //mWallPadAPI
  11226. // private String TAG = "*yskim*";
  11227. //private IGW200dAPI iGW200dAPI = null;
  11228. /**
  11229. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  11230. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  11231. * 본 딜레이 코드를 임시로 적용한다.
  11232. */
  11233. @SuppressLint("HandlerLeak")
  11234. protected Handler IGW200APICheckHandler = new Handler() {
  11235. @SuppressLint("HandlerLeak")
  11236. @Override
  11237. public void handleMessage(Message msg) {
  11238. if (msg.what == 0) {
  11239. if (mWallPadAPI != null) {
  11240. Common.DebugLog("handleMessage what 0 ");
  11241. if (mWallPadAPI.Check_Connect()) IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  11242. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  11243. }
  11244. }
  11245. else if(msg.what == 1) {
  11246. Common.DebugLog("handleMessage what 1 ");
  11247. setIGE200Interface();
  11248. }
  11249. }
  11250. };
  11251. public void setIGE200Interface() {
  11252. try {
  11253. Common.DebugLog("setIGE200Interface");
  11254. mIGW200 = new IGW200(this, mWallPadAPI);
  11255. } catch (RuntimeException re) {
  11256. LogUtil.errorLogInfo("", TAG, re);
  11257. }
  11258. catch (Exception e) {
  11259. Log.e(TAG, "[Exception] setIGE200Interface()");
  11260. //e.printStackTrace();
  11261. LogUtil.errorLogInfo("", TAG, e);
  11262. }
  11263. }
  11264. /**
  11265. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  11266. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  11267. * 본 딜레이 코드를 임시로 적용한다.
  11268. */
  11269. @SuppressLint("HandlerLeak")
  11270. protected Handler IGW300APICheckHandler = new Handler() {
  11271. @SuppressLint("HandlerLeak")
  11272. @Override
  11273. public void handleMessage(Message msg) {
  11274. if (msg.what == 0) {
  11275. if (mWallPadAPI != null) {
  11276. Common.DebugLog("handleMessage what 0 ");
  11277. if (mWallPadAPI.Check_Connect()) IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  11278. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  11279. }
  11280. }
  11281. else if(msg.what == 1) {
  11282. Common.DebugLog("handleMessage what 1 ");
  11283. setIGE300Interface();
  11284. }
  11285. }
  11286. };
  11287. public void setIGE300Interface() {
  11288. try {
  11289. Common.DebugLog("setIGE300Interface");
  11290. mIGW300 = new IGW300(this, mWallPadAPI);
  11291. } catch (RuntimeException re) {
  11292. LogUtil.errorLogInfo("", TAG, re);
  11293. }
  11294. catch (Exception e) {
  11295. Log.e(TAG, "[Exception] setIGE300Interface()");
  11296. //e.printStackTrace();
  11297. LogUtil.errorLogInfo("", TAG, e);
  11298. }
  11299. }
  11300. // 외출모드 연동
  11301. private void ModeRunCtrlWorking( boolean WallpadUI , boolean BedMode )
  11302. {
  11303. try
  11304. {
  11305. bSmartSwitch485ComebackMode = false;
  11306. String [] mOutModeTextContents = { "엘리베이터호출" , "일괄소등" , "가스닫기", "난방외출모드" , "환기끄기", "쿡탑콘센트차단"};
  11307. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  11308. String outLinkCtrl = wd.GetOutModeLinkDevice();
  11309. if( BedMode == true )
  11310. outLinkCtrl = wd.GetInBedLinkDevice();
  11311. wd.closeDB();
  11312. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  11313. if( WallpadUI == false )
  11314. {
  11315. if( outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0 ) // 엘리베이터 호출
  11316. {
  11317. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0] );
  11318. CallElevatorBtn(false);
  11319. }
  11320. }
  11321. if( outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0 ) // 일괄소등 처리
  11322. {
  11323. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1] );
  11324. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  11325. }
  11326. if( (outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  11327. {
  11328. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2] );
  11329. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  11330. }
  11331. if( outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  11332. {
  11333. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3] );
  11334. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  11335. }
  11336. if( outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0 ) // 환기끄기
  11337. {
  11338. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4] );
  11339. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  11340. }
  11341. }
  11342. catch (RuntimeException re) {
  11343. LogUtil.errorLogInfo("", TAG, re);
  11344. }
  11345. catch (Exception e )
  11346. {
  11347. Log.e("YSKIM", e.toString());
  11348. }
  11349. }
  11350. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  11351. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  11352. private boolean bSmartSwitch485ComebackMode = false ;
  11353. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  11354. try {
  11355. if (bSmartSwitch485ComebackMode == true) return;
  11356. String [] mCombackHomeTextContents = { "일괄소등해제" , "환기동작" , "난방외출모드해제", "웰컴조명" };
  11357. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  11358. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  11359. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  11360. wd.closeDB();
  11361. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  11362. // 일괄소등 해제
  11363. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0] );
  11364. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  11365. }
  11366. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0 ) {
  11367. // 환기동작
  11368. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1] );
  11369. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  11370. }
  11371. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  11372. // 난방 외출모드 해제
  11373. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2] );
  11374. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  11375. }
  11376. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  11377. // 웰컴조명 켜기
  11378. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3] );
  11379. // 웰컴조명 Handler 실행
  11380. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  11381. }
  11382. } catch (RuntimeException re) {
  11383. LogUtil.errorLogInfo("", TAG, re);
  11384. }
  11385. catch (Exception e) {
  11386. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  11387. //e.printStackTrace();
  11388. LogUtil.errorLogInfo("", TAG, e);
  11389. }
  11390. }
  11391. private Handler WelcomeLightHandler = new Handler()
  11392. {
  11393. int LightOnCount = 0;
  11394. @Override
  11395. public void handleMessage(Message msg)
  11396. {
  11397. if(msg.what == 0)
  11398. {
  11399. try
  11400. {
  11401. if(LightOnCount == 0)
  11402. {
  11403. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  11404. }
  11405. // 일괄소등 해제이면
  11406. if(mWallPadAPI.GetBatchSwitchStatus() == 1)
  11407. {
  11408. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  11409. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  11410. }
  11411. else
  11412. {
  11413. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  11414. LightOnCount++;
  11415. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  11416. if(LightOnCount > 10)
  11417. {
  11418. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  11419. LightOnCount = 0;
  11420. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  11421. }
  11422. }
  11423. }
  11424. catch (RuntimeException re) {
  11425. LogUtil.errorLogInfo("", TAG, re);
  11426. }
  11427. catch (Exception e1)
  11428. {
  11429. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  11430. //e1.printStackTrace();
  11431. LogUtil.errorLogInfo("", TAG, e1);
  11432. }
  11433. }
  11434. else if(msg.what == 1)
  11435. {
  11436. try
  11437. {
  11438. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  11439. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  11440. LightOnCount = 0;
  11441. }
  11442. catch (RuntimeException re) {
  11443. LogUtil.errorLogInfo("", TAG, re);
  11444. }
  11445. catch (Exception e1)
  11446. {
  11447. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  11448. //e1.printStackTrace();
  11449. LogUtil.errorLogInfo("", TAG, e1);
  11450. }
  11451. }
  11452. else if(msg.what == 2)
  11453. {
  11454. // Do Nothing
  11455. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  11456. WelcomeLightHandler.removeMessages(0);
  11457. }
  11458. }
  11459. };
  11460. //방범 및 알람 상태 확인 Resume 시 처리
  11461. private void CheckMainStatus() {
  11462. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  11463. try {
  11464. final String packageName = "com.artncore.apps.ic_wallpad";
  11465. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  11466. //CallAppRun = getForegroundAPK().equals(packageName);
  11467. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  11468. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11469. int alarmstate = SetData.GetAlarmStatus();
  11470. SetData.closeDB();
  11471. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate );
  11472. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  11473. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE" );
  11474. return;
  11475. }
  11476. else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  11477. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  11478. int base = 7000;
  11479. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  11480. int Menu_Start_Id = 0;
  11481. SetData = new WallpadStatusData(getApplicationContext());
  11482. int alarmtype = SetData.GetAlarmType();
  11483. SetData.closeDB();
  11484. switch (alarmtype) {
  11485. case WallpadStatusData.ALARM_ALERT:
  11486. Menu_Start_Id = Menu_Id_List[1];
  11487. break;
  11488. case WallpadStatusData.ALARM_EMM:
  11489. Menu_Start_Id = Menu_Id_List[0];
  11490. break;
  11491. case WallpadStatusData.ALARM_EVAC:
  11492. Menu_Start_Id = Menu_Id_List[3];
  11493. break;
  11494. case WallpadStatusData.ALARM_INVADE:
  11495. Menu_Start_Id =Menu_Id_List[2];
  11496. break;
  11497. case WallpadStatusData.ALARM_HEATING_LEAK:
  11498. Menu_Start_Id =Menu_Id_List[4];
  11499. break;
  11500. default:
  11501. Menu_Start_Id = Menu_Id_List[1];
  11502. break;
  11503. }
  11504. if (Menu_Start_Id > 0) {
  11505. /*
  11506. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  11507. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  11508. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  11509. * "RESUME"을 전달한다.
  11510. */
  11511. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11512. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11513. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  11514. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  11515. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  11516. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11517. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11518. startActivity(newintent);
  11519. return;
  11520. }
  11521. }
  11522. else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  11523. if (OutModeRunAppRun == true) {
  11524. Log.d(TAG, "already outmoderun app running !!!!");
  11525. return;
  11526. }
  11527. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11528. int sensor = devset.Get_Sensor_Set();
  11529. devset.closeDB();
  11530. int base = 7000;
  11531. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  11532. int Menu_Start_Id = 0;
  11533. int Menu_Start_Option = 1;
  11534. if (sensor > 0) {
  11535. WallPadInterface wpifc = new WallPadInterface();
  11536. int[] SensorInfoDB;
  11537. int inSen = 0;
  11538. int outSen = 0;
  11539. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  11540. if (SensorInfoDB[0] == 1) {
  11541. // 내부동체가 사용함이면 상태 검사
  11542. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  11543. }
  11544. if (SensorInfoDB[1] == 1) {
  11545. // 외부동체가 사용함이면 상태 검사
  11546. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11547. }
  11548. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  11549. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11550. if (((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0 &&( outSen > 0 || inSen > 0)) ||
  11551. ((sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  11552. ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  11553. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11554. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11555. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  11556. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11557. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0)?"bugout":"bugin");
  11558. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11559. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11560. startActivity(newintent);
  11561. return;
  11562. }
  11563. }
  11564. base = 8000;
  11565. Menu_Id_List = new int[]{ base+11};
  11566. Menu_Start_Id = base+11;
  11567. Menu_Start_Option = -1;
  11568. Intent intent = new Intent(Intent.ACTION_MAIN);
  11569. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11570. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  11571. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11572. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  11573. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11574. startActivity(intent);
  11575. }
  11576. else if (alarmstate == WallpadStatusData.GUARD_IN) {
  11577. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11578. int sensor = devset.Get_Sensor_Set();
  11579. devset.closeDB();
  11580. int base = 7000;
  11581. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  11582. int Menu_Start_Option = 1;
  11583. if (sensor > 0) {
  11584. WallPadInterface wpifc = new WallPadInterface();
  11585. int[] SensorInfoDB;
  11586. int outSen = 0;SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  11587. if (SensorInfoDB[1] == 1) {
  11588. // 외부동체가 사용함이면 상태 검사
  11589. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11590. }
  11591. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11592. if (((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0 &&( outSen > 0 )) ||
  11593. ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  11594. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11595. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11596. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  11597. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11598. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  11599. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11600. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11601. startActivity(newintent);
  11602. return;
  11603. }
  11604. }
  11605. }
  11606. else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  11607. WallPadInterface wpifc = new WallPadInterface();
  11608. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  11609. return;
  11610. }
  11611. else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  11612. int base = 4000;
  11613. int Menu_Start_Id = 0;
  11614. int[] Menu_Id_List = new int[]{ base+11, base+21};
  11615. Menu_Start_Id = base+11;
  11616. Intent intent = new Intent(Intent.ACTION_MAIN);
  11617. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11618. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  11619. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  11620. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity","kr.co.icontrols.wallpadsecurity.MainActivity"));
  11621. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11622. startActivity(intent);
  11623. return;
  11624. }
  11625. } catch (RuntimeException re) {
  11626. LogUtil.errorLogInfo("", TAG, re);
  11627. }
  11628. catch (Exception e) {
  11629. Log.e(TAG, "[Exception] CheckMainStatus()");
  11630. //e.printStackTrace();
  11631. LogUtil.errorLogInfo("", TAG, e);
  11632. }
  11633. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11634. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  11635. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  11636. // {
  11637. // WallPadInterface wpifc = new WallPadInterface();
  11638. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  11639. //
  11640. // if (fleeSensor > 0)
  11641. // {
  11642. // int base = 7000;
  11643. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  11644. // int Menu_Start_Option = 1;
  11645. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  11646. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11647. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  11648. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11649. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  11650. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11651. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  11652. // startActivity(newintent);
  11653. // devset.closeDB();
  11654. // return;
  11655. // }
  11656. // }
  11657. //
  11658. // StatusVal = devset.GetDeviceSetted("알람발생");
  11659. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  11660. // {
  11661. // WallPadInterface wpifc = new WallPadInterface();
  11662. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  11663. //
  11664. // if (AlarmSensor > 0)
  11665. // {
  11666. // int base = 7000;
  11667. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  11668. // int Menu_Start_Option = 1;
  11669. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  11670. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11671. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  11672. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11673. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  11674. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11675. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  11676. // startActivity(newintent);
  11677. // devset.closeDB();
  11678. // return;
  11679. // }
  11680. //
  11681. // }
  11682. // devset.closeDB();
  11683. }
  11684. /**
  11685. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  11686. *
  11687. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  11688. */
  11689. public boolean GetUseIlgalControlForAdmin()
  11690. {
  11691. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11692. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  11693. devSet.closeDB();
  11694. boolean result = false;
  11695. if (MetringDB != null)
  11696. {
  11697. try
  11698. {
  11699. String devInfo = MetringDB[1];
  11700. devInfo = devInfo.replace('(', '_');
  11701. devInfo = devInfo.replace(':', '_');
  11702. devInfo = devInfo.replace(')', '_');
  11703. String[] MetringInfo = devInfo.split("_");
  11704. if (MetringInfo[3].equals("사용함") == true)
  11705. {
  11706. result = true;
  11707. }
  11708. }
  11709. catch (RuntimeException re) {
  11710. LogUtil.errorLogInfo("", TAG, re);
  11711. }
  11712. catch (Exception e)
  11713. {
  11714. //e.printStackTrace();
  11715. LogUtil.errorLogInfo("", TAG, e);
  11716. }
  11717. }
  11718. return result;
  11719. }
  11720. class SendLHGWCheck extends Thread
  11721. {
  11722. private iMAP_hn_config_read m_HnGWConfigRead = null;
  11723. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  11724. private boolean retSucces = false;
  11725. private int retryCount = 0;
  11726. public SendLHGWCheck()
  11727. {
  11728. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  11729. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  11730. retryCount = 0;
  11731. }
  11732. public void run()
  11733. {
  11734. try {
  11735. try{Thread.sleep(2000);}
  11736. catch (RuntimeException re) {
  11737. LogUtil.errorLogInfo("", TAG, re);
  11738. }
  11739. catch (Exception e){
  11740. LogUtil.errorLogInfo("", TAG, e);
  11741. }
  11742. for( int i = 0 ; i < 10 ; i++ )
  11743. {
  11744. m_HnGWConfigRead.DoWork();
  11745. m_HnGWConfigRead.SetRetCtr(new RetProci()
  11746. {
  11747. @Override
  11748. public void ProcSuccess()
  11749. {
  11750. retSucces = true;
  11751. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount );
  11752. }
  11753. @Override
  11754. public void ProcError()
  11755. {
  11756. }
  11757. @Override
  11758. public void ProcDoing()
  11759. {
  11760. // TODO Auto-generated method stub
  11761. }
  11762. });
  11763. if( retSucces == true )
  11764. break;
  11765. retryCount++;
  11766. try{Thread.sleep(3000);}
  11767. catch (RuntimeException re) {
  11768. LogUtil.errorLogInfo("", TAG, re);
  11769. }
  11770. catch (Exception e){
  11771. LogUtil.errorLogInfo("", TAG, e);
  11772. }
  11773. }
  11774. m_HnGWEmptyMsg.DoWork();
  11775. m_HnGWEmptyMsg.SetRetCtr(new RetProci()
  11776. {
  11777. @Override
  11778. public void ProcSuccess()
  11779. {
  11780. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess " );
  11781. }
  11782. @Override
  11783. public void ProcError()
  11784. {
  11785. Log.d(TAG, "HN GW EmptyMsg Send ProcError " );
  11786. }
  11787. @Override
  11788. public void ProcDoing()
  11789. {
  11790. // TODO Auto-generated method stub
  11791. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing " );
  11792. }
  11793. });
  11794. } catch (RuntimeException re) {
  11795. LogUtil.errorLogInfo("", TAG, re);
  11796. }
  11797. catch (Exception e) {
  11798. //e.printStackTrace();
  11799. LogUtil.errorLogInfo("", TAG, e);
  11800. }
  11801. }
  11802. }
  11803. //Reset Handler
  11804. private Handler mResetHandler = new Handler() {
  11805. @Override
  11806. public void handleMessage(Message msg) {
  11807. if (msg.what == 0) {
  11808. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  11809. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  11810. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  11811. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  11812. if (NowMainStatus == false) {
  11813. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  11814. ResetCount = 1;
  11815. }
  11816. ResetCount++;
  11817. NowMainStatus = true;
  11818. if (ResetCount == 30) {
  11819. mResetHandler.sendEmptyMessageDelayed(1, 10);
  11820. }
  11821. else {
  11822. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  11823. }
  11824. }
  11825. else {
  11826. if (NowMainStatus == true) {
  11827. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  11828. ResetCount = 1;
  11829. }
  11830. ResetCount++;
  11831. NowMainStatus = false;
  11832. if (ResetCount == 180) {
  11833. // 3분
  11834. mResetHandler.sendEmptyMessageDelayed(1, 10);
  11835. }
  11836. else {
  11837. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  11838. }
  11839. }
  11840. }
  11841. else if (msg.what == 1) {
  11842. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  11843. setDefaultLauncher();
  11844. Intent intent = new Intent();
  11845. intent.setAction(define.NOTIFY_ACNAME);
  11846. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  11847. getApplicationContext().sendBroadcast(intent);
  11848. }
  11849. }
  11850. };
  11851. // 통화주체를 다루는 enum
  11852. public enum CALLOWNER {
  11853. NONE,
  11854. WALLPAD,
  11855. SUB_WALLPAD,
  11856. KITCHEN_TV,
  11857. BATH_PHONE,
  11858. BATH_TV,
  11859. UNIVERSAL_DEVICE,
  11860. ERROR;
  11861. }
  11862. public enum CALLEVENTTYPE {
  11863. RECEIVE_CALL, // 호출 수신 (호출 수신)
  11864. TRYING_CALL, // 호출 시도중 (호출 발신)
  11865. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  11866. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  11867. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  11868. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  11869. CONNECT_CALL, // 통화 시작
  11870. TERMINATE_CALL, // 통화 종료
  11871. CANCEL_CALL, // 호출 취소
  11872. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  11873. REJECT_CALL, // 호출수신 거절
  11874. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  11875. FORWARD_CALL, // 착신전환 설정
  11876. CALLERID, // Caller ID
  11877. TIMEOUT_1STCALL, // 1st Call Timeout
  11878. TIMEOUT_2NDCALL, // 2nd Call Timeout
  11879. TIMEOUT_3RDCALL, // 3rd Call Timeout
  11880. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  11881. DOOR_OPEN, // 문열림 설정
  11882. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  11883. PSTN_DTMF, // PSTN DTMF 수신
  11884. DETECT_STRANGER, // 거동수상자 발생
  11885. NONE;
  11886. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  11887. try {
  11888. if (value.equals(RECEIVE_CALL.toString())) {
  11889. return RECEIVE_CALL;
  11890. } else if (value.equals(TRYING_CALL.toString())) {
  11891. return TRYING_CALL;
  11892. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  11893. return RECEIVE_CALL_2ND;
  11894. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  11895. return RECEIVE_CALL_ACK;
  11896. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  11897. return REQUEST_FRONT_MONITORING;
  11898. } else if (value.equals(CONNECT_CALL.toString())) {
  11899. return CONNECT_CALL;
  11900. } else if (value.equals(TERMINATE_CALL.toString())) {
  11901. return TERMINATE_CALL;
  11902. } else if (value.equals(CANCEL_CALL.toString())) {
  11903. return CANCEL_CALL;
  11904. } else if (value.equals(REJECT_CALL.toString())) {
  11905. return REJECT_CALL;
  11906. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  11907. return REJECT_BUSY_CALL;
  11908. } else if (value.equals(FORWARD_CALL.toString())) {
  11909. return FORWARD_CALL;
  11910. } else if (value.equals(CALLERID.toString())) {
  11911. return CALLERID;
  11912. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  11913. return TIMEOUT_1STCALL;
  11914. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  11915. return TIMEOUT_2NDCALL;
  11916. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  11917. return TIMEOUT_3RDCALL;
  11918. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  11919. return MOIP_VIDEO_SET;
  11920. } else if (value.equals(DOOR_OPEN.toString())) {
  11921. return DOOR_OPEN;
  11922. } else if (value.equals(PSTN_RING.toString())) {
  11923. return PSTN_RING;
  11924. } else if (value.equals(PSTN_DTMF.toString())) {
  11925. return PSTN_DTMF;
  11926. } else if (value.equals(DETECT_STRANGER.toString())) {
  11927. return DETECT_STRANGER;
  11928. } else if (value.equals(NONE.toString())) {
  11929. return NONE;
  11930. } else {
  11931. return null;
  11932. }
  11933. } catch (RuntimeException re) {
  11934. LogUtil.errorLogInfo("", "", re);
  11935. return null;
  11936. }
  11937. catch (Exception e) {
  11938. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  11939. //e.printStackTrace();
  11940. LogUtil.errorLogInfo("", "", e);
  11941. return null;
  11942. }
  11943. }
  11944. }
  11945. public enum CALLTYPE {
  11946. NONE,
  11947. FRONT,
  11948. RESIDENCE,
  11949. LOBBY,
  11950. GUARD,
  11951. PSTN,
  11952. IHUB,
  11953. ERROR,
  11954. }
  11955. public static class CALLTRIGGER {
  11956. public static String CALLOWNER = "CALLOWNER";
  11957. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  11958. public static String CALLTYPE = "CALLTYPE";
  11959. public enum SOURCE {
  11960. USER,
  11961. CALL_RECEIVE,
  11962. SUBPHONE
  11963. }
  11964. public enum TYPE {
  11965. MENU,
  11966. FRONT,
  11967. LOBBY,
  11968. GUARD,
  11969. RESIDENCE,
  11970. PSTN
  11971. }
  11972. }
  11973. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  11974. int TAB_TALKFRONT = 130011;
  11975. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  11976. try {
  11977. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType +"], nAlramStatus [" + nAlramStatus +"]");
  11978. if (!bWallPadCallLive) {
  11979. sendLCDBacklightStatus(true);
  11980. // 통화어플을 실행시킨다.
  11981. if (nAlramStatus != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  11982. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  11983. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  11984. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  11985. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  11986. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  11987. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11988. mIntent.setComponent(mComponentName);
  11989. startActivity(mIntent);
  11990. playFrontBell(eCallOwner, eEventType, eCallType);
  11991. }
  11992. else {
  11993. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  11994. // if (getUseSmartDoorCam()) {
  11995. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  11996. // }
  11997. }
  11998. } catch (RuntimeException re) {
  11999. LogUtil.errorLogInfo("", TAG, re);
  12000. }
  12001. catch (Exception e) {
  12002. Log.e(TAG, "[Exception] runCallMainActivity()");
  12003. //e.printStackTrace();
  12004. LogUtil.errorLogInfo("", TAG, e);
  12005. }
  12006. }
  12007. private String getTopActivity() {
  12008. try {
  12009. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  12010. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  12011. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  12012. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  12013. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  12014. return mComponentName.getPackageName();
  12015. } catch (RuntimeException re) {
  12016. LogUtil.errorLogInfo("", TAG, re);
  12017. return null;
  12018. }
  12019. catch (Exception e) {
  12020. Log.e(TAG, "[Exception] getTopActivity()");
  12021. //e.printStackTrace();
  12022. LogUtil.errorLogInfo("", TAG, e);
  12023. return null;
  12024. }
  12025. }
  12026. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  12027. try {
  12028. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  12029. WallPadInterface Wiface = new WallPadInterface();
  12030. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  12031. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  12032. }
  12033. } catch (RuntimeException re) {
  12034. LogUtil.errorLogInfo("", TAG, re);
  12035. }
  12036. catch (Exception e) {
  12037. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  12038. //e.printStackTrace();
  12039. LogUtil.errorLogInfo("", TAG, e);
  12040. }
  12041. }
  12042. private class AfterTransactionTodoListData
  12043. {
  12044. String Title;
  12045. int Valueint;
  12046. String ValueString;
  12047. private AfterTransactionTodoListData(String title, int valueint, String valueString)
  12048. {
  12049. Title = title;
  12050. Valueint = valueint;
  12051. ValueString = valueString;
  12052. }
  12053. }
  12054. /**
  12055. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  12056. * **/
  12057. public void SendGetParkingInfoIntent()
  12058. {
  12059. Intent iIntent = new Intent();
  12060. iIntent.setAction(define.NOTIFY_ACNAME);
  12061. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  12062. this.sendBroadcast(iIntent);
  12063. }
  12064. /**
  12065. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  12066. * **/
  12067. public Handler SendParkingInfoIntentAfter20min = new Handler()
  12068. {
  12069. @SuppressLint("HandlerLeak")
  12070. @Override
  12071. public void handleMessage(Message msg)
  12072. {
  12073. if (msg.what == 0)
  12074. {
  12075. SendGetParkingInfoIntent();
  12076. }
  12077. }
  12078. };
  12079. /**
  12080. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  12081. * **/
  12082. public Handler mWallPadOutmodeSleepHandler = new Handler()
  12083. {
  12084. @SuppressLint("HandlerLeak")
  12085. @Override
  12086. public void handleMessage(Message msg)
  12087. {
  12088. if(msg.what == 0)
  12089. {
  12090. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  12091. }
  12092. }
  12093. };
  12094. // Handler
  12095. public final class HANDLERMSG {
  12096. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  12097. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  12098. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  12099. public final static int CALLAPP_FINISHING_END = 300;
  12100. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  12101. }
  12102. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  12103. public void handleMessage(Message msg) {
  12104. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 +"]");
  12105. switch (msg.what) {
  12106. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  12107. bGlobalScreenRun = true;
  12108. break;
  12109. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  12110. bGlobalScreenRun = false;
  12111. break;
  12112. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  12113. break;
  12114. case HANDLERMSG.CALLAPP_FINISHING_END:
  12115. // bBlockCallEvent = false;
  12116. break;
  12117. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  12118. int time = Sound().PlayMent(SND.call.DINGDONG);
  12119. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  12120. if (time < 0) time = 2088;
  12121. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  12122. break;
  12123. default:
  12124. Log.v(TAG, "iMAPServerHandler : "+ msg.what);
  12125. break;
  12126. }
  12127. }
  12128. };
  12129. public void sendHandlerMsg(int what, int arg1, int arg2) {
  12130. try {
  12131. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 +"]");
  12132. Message HandleMsg = iMAPServerHandler.obtainMessage();
  12133. HandleMsg.what = what;
  12134. HandleMsg.arg1 = arg1;
  12135. HandleMsg.arg2 = arg2;
  12136. iMAPServerHandler.sendMessage(HandleMsg);
  12137. } catch (RuntimeException re) {
  12138. LogUtil.errorLogInfo("", TAG, re);
  12139. }
  12140. catch (Exception e) {
  12141. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  12142. //e.printStackTrace();
  12143. LogUtil.errorLogInfo("", TAG, e);
  12144. }
  12145. }
  12146. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  12147. try {
  12148. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 +"], delay [" + delay +"]");
  12149. Message HandleMsg = iMAPServerHandler.obtainMessage();
  12150. HandleMsg.what = what;
  12151. HandleMsg.arg1 = arg1;
  12152. HandleMsg.arg2 = arg2;
  12153. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  12154. } catch (RuntimeException re) {
  12155. LogUtil.errorLogInfo("", TAG, re);
  12156. }
  12157. catch (Exception e) {
  12158. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  12159. //e.printStackTrace();
  12160. LogUtil.errorLogInfo("", TAG, e);
  12161. }
  12162. }
  12163. int mSensitivity = 0, mDuration = 0;
  12164. int MIN_SENSOR_SENSITIVITY = 1;
  12165. int MAX_SENSOR_SENSITIVITY = 5;
  12166. int MIN_SENSOR_DURATION = 30;
  12167. int MAX_SENSOR_DURATION = 250;
  12168. int DEFAULT_SENSOR_SENSITIVITY = 3;
  12169. int DEFAULT_SENSOR_DURATION = 60;
  12170. private final int COMPONENT_USE = 1;
  12171. /**
  12172. * 스마트현관카메라 사용여부 판별
  12173. */
  12174. private boolean getUseSmartDoorCam() {
  12175. try {
  12176. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12177. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  12178. mWallpadDeviceSet.closeDB();
  12179. if (nFrontCam[0] == COMPONENT_USE) {
  12180. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  12181. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  12182. return true;
  12183. }
  12184. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  12185. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  12186. return true;
  12187. }
  12188. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  12189. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  12190. return true;
  12191. }
  12192. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  12193. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  12194. return true;
  12195. }
  12196. else {
  12197. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  12198. return false;
  12199. }
  12200. }
  12201. else {
  12202. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  12203. return false;
  12204. }
  12205. } catch (RuntimeException re) {
  12206. LogUtil.errorLogInfo("", TAG, re);
  12207. return false;
  12208. }
  12209. catch (Exception e) {
  12210. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  12211. //e.printStackTrace();
  12212. LogUtil.errorLogInfo("", TAG, e);
  12213. return false;
  12214. }
  12215. }
  12216. private int getSmartDoorCamType() {
  12217. try {
  12218. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12219. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  12220. mWallpadDeviceSet.closeDB();
  12221. if (nFrontCam[0] == COMPONENT_USE) {
  12222. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  12223. return nFrontCam[1];
  12224. }
  12225. }
  12226. } catch (RuntimeException re) {
  12227. LogUtil.errorLogInfo("", TAG, re);
  12228. }
  12229. catch (Exception e) {
  12230. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  12231. //e.printStackTrace();
  12232. LogUtil.errorLogInfo("", TAG, e);
  12233. }
  12234. return -1;
  12235. }
  12236. /**
  12237. * 방문객원격통화 솔루션 사용여부 판별
  12238. */
  12239. private boolean getRemoteCallUseInfo() {
  12240. try {
  12241. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  12242. if (mWallpadDeviceSet != null) {
  12243. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  12244. if (astrRemoteCall != null) {
  12245. if (astrRemoteCall[1].contains("사용함")) return true;
  12246. } else {
  12247. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  12248. }
  12249. }
  12250. mWallpadDeviceSet.closeDB();
  12251. } catch (RuntimeException re) {
  12252. LogUtil.errorLogInfo("", TAG, re);
  12253. }
  12254. catch (Exception e) {
  12255. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  12256. //e.printStackTrace();
  12257. LogUtil.errorLogInfo("", TAG, e);
  12258. }
  12259. return false;
  12260. }
  12261. /*
  12262. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  12263. */
  12264. private RealTimeMeterAPI mRealTimeMeterAPI;
  12265. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  12266. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  12267. public Thread saveRealmeterDataThread = null;
  12268. private void startRealtimemeterInfo() {
  12269. try {
  12270. // 영업샘플 모드 판단
  12271. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  12272. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  12273. }
  12274. else {
  12275. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  12276. // 실시간 검침기 사용유무 판단
  12277. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12278. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  12279. mWallpadDeviceSet.closeDB();
  12280. boolean bRealtimemeterUsage = false;
  12281. int nRealtimemeterCntDB = -99;
  12282. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  12283. // 실시간 검침 사용함
  12284. bRealtimemeterUsage = true;
  12285. nRealtimemeterCntDB = naRealtimemtInfo[1];
  12286. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  12287. }
  12288. else {
  12289. // 실시간 검침 사용하지 않음
  12290. bRealtimemeterUsage = false;
  12291. }
  12292. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB +"]");
  12293. }
  12294. } catch (RuntimeException re) {
  12295. LogUtil.errorLogInfo("", TAG, re);
  12296. }
  12297. catch (Exception e) {
  12298. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  12299. //e.printStackTrace();
  12300. LogUtil.errorLogInfo("", TAG, e);
  12301. }
  12302. }
  12303. private void startSmartIoTCamInfo() {
  12304. try {
  12305. // 영업샘플 모드 판단
  12306. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  12307. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  12308. }
  12309. else {
  12310. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  12311. if (getUseSmartDoorCam()) {
  12312. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  12313. }
  12314. else {
  12315. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  12316. }
  12317. }
  12318. } catch (RuntimeException re) {
  12319. LogUtil.errorLogInfo("", TAG, re);
  12320. }
  12321. catch (Exception e) {
  12322. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  12323. //e.printStackTrace();
  12324. LogUtil.errorLogInfo("", TAG, e);
  12325. }
  12326. }
  12327. private void startDistributionPanel() {
  12328. try {
  12329. // 영업샘플 모드 판단
  12330. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  12331. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I) {
  12332. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  12333. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12334. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  12335. mWallpadDeviceSet.closeDB();
  12336. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST) initSmartDistributionPanelHandler.sendEmptyMessage(0);
  12337. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) initKNXDistributionPanelHandler.sendEmptyMessage(0);
  12338. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  12339. }
  12340. else {
  12341. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  12342. }
  12343. } catch (RuntimeException re) {
  12344. LogUtil.errorLogInfo("", TAG, re);
  12345. }
  12346. catch (Exception e) {
  12347. Log.e(TAG, "[Exception] startDistributionPanel()");
  12348. //e.printStackTrace();
  12349. LogUtil.errorLogInfo("", TAG, e);
  12350. }
  12351. }
  12352. // =================================================================================================
  12353. // [[ Device ]] region
  12354. // =================================================================================================
  12355. /**
  12356. * 디바이스 API 를 Load 한다.
  12357. *
  12358. * @param wpapi - 생성시 전달받은 WallPadAPI
  12359. * @return (int) - >=0 : 성공, <0 : 실패
  12360. */
  12361. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  12362. // 1. Mode Check
  12363. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  12364. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  12365. return -1;
  12366. }
  12367. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  12368. // 2. wpapi Check
  12369. if (wpapi == null) {
  12370. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  12371. return -2;
  12372. }
  12373. // 3. Load API
  12374. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  12375. try {
  12376. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  12377. } catch (RuntimeException re) {
  12378. LogUtil.errorLogInfo("", TAG, re);
  12379. return -100;
  12380. }
  12381. catch (Exception e) {
  12382. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  12383. //e.printStackTrace();
  12384. LogUtil.errorLogInfo("", TAG, e);
  12385. return -100;
  12386. }
  12387. if (mRealTimeMeterAPI == null) {
  12388. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  12389. return -4;
  12390. }
  12391. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  12392. return 0;
  12393. }
  12394. /**
  12395. * 제어기 상태를 가져온다.
  12396. *
  12397. * @param real - (boolean) true : 실시간 , false : 가장최근
  12398. * @return (int) - >=0 : 성공, <0 : 실패
  12399. */
  12400. @SuppressWarnings("unused")
  12401. private int updateRealtimemeterData(boolean real) {
  12402. try {
  12403. // 1. Api Load Check
  12404. if (mRealTimeMeterAPI == null) {
  12405. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  12406. return -1;
  12407. }
  12408. // 2. reflash
  12409. try {
  12410. int ret = mRealTimeMeterAPI.Refresh(real);
  12411. if (ret < 0) {
  12412. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  12413. return -2;
  12414. }
  12415. } catch (RuntimeException re) {
  12416. LogUtil.errorLogInfo("", TAG, re);
  12417. return -100;
  12418. }
  12419. catch (Exception e) {
  12420. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  12421. //e.printStackTrace();
  12422. LogUtil.errorLogInfo("", TAG, e);
  12423. return -100;
  12424. }
  12425. // 3. Range Check
  12426. if (mRealTimeMeterAPI.data == null) {
  12427. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  12428. return -9;
  12429. }
  12430. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  12431. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  12432. return -10;
  12433. }
  12434. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  12435. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  12436. return -11;
  12437. }
  12438. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  12439. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  12440. return -12;
  12441. }
  12442. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  12443. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  12444. return -13;
  12445. }
  12446. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  12447. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  12448. return -14;
  12449. }
  12450. // 4. Data Copy
  12451. mRealTimeMeterData = mRealTimeMeterAPI.data;
  12452. // 5. Debug msg
  12453. if (DEBUG_REALMETER_DATA_LOG_ON) {
  12454. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  12455. Log.i(TAG, "[updateRealtimemeterData] - OK");
  12456. }
  12457. return 0;
  12458. } catch (RuntimeException re) {
  12459. LogUtil.errorLogInfo("", TAG, re);
  12460. return -99;
  12461. }
  12462. catch (Exception e) {
  12463. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  12464. //e.printStackTrace();
  12465. LogUtil.errorLogInfo("", TAG, e);
  12466. return -99;
  12467. }
  12468. }
  12469. /**
  12470. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  12471. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  12472. * 본 딜레이 코드를 임시로 적용한다.
  12473. */
  12474. @SuppressLint("HandlerLeak")
  12475. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  12476. @SuppressLint("HandlerLeak")
  12477. @Override
  12478. public void handleMessage(Message msg) {
  12479. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  12480. if (msg.what == 0) {
  12481. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  12482. if (updateRealtimemeterData(false) == 0) {
  12483. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  12484. }
  12485. else {
  12486. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  12487. }
  12488. }
  12489. else {
  12490. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  12491. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  12492. }
  12493. }
  12494. else if (msg.what == 1) {
  12495. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  12496. if (mRealTimeMeterAPI != null) {
  12497. // Device_BrRegistration(true);
  12498. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  12499. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  12500. mWallpadDeviceSet.closeDB();
  12501. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  12502. saveRealmeterDataThread = new saveRealmeterData();
  12503. saveRealmeterDataThread.start();
  12504. }
  12505. // RemoveUsedData();
  12506. // ShowUsedDataGraph();
  12507. }
  12508. }
  12509. }
  12510. };
  12511. protected Handler initSmartDistributionPanelHandler = new Handler() {
  12512. @SuppressLint("HandlerLeak")
  12513. @Override
  12514. public void handleMessage(Message msg) {
  12515. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  12516. if (msg.what == 0) {
  12517. if (mWallPadAPI.Check_Connect()) initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  12518. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  12519. } else if (msg.what == 1) {
  12520. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  12521. mSdbAPI = mWallPadAPI.Get_SdbController();
  12522. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  12523. mSdb_LivingRoomLightAPI.Refresh();
  12524. }
  12525. }
  12526. };
  12527. protected Handler initKNXDistributionPanelHandler = new Handler() {
  12528. @SuppressLint("HandlerLeak")
  12529. @Override
  12530. public void handleMessage(Message msg) {
  12531. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  12532. if (msg.what == 0) {
  12533. if (mWallPadAPI.Check_Connect()) initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  12534. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  12535. } else if (msg.what == 1) {
  12536. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  12537. mKnxAPI = mWallPadAPI.Get_KnxController();
  12538. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  12539. mKnx_LivingRoomLightAPI.Refresh();
  12540. }
  12541. }
  12542. };
  12543. protected Handler initSmartIoTFunctionHandler = new Handler() {
  12544. @SuppressLint("HandlerLeak")
  12545. @Override
  12546. public void handleMessage(Message msg) {
  12547. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  12548. if (msg.what == 0) {
  12549. if (mWallPadAPI.Check_Connect()) initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  12550. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  12551. } else if (msg.what == 1) {
  12552. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  12553. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  12554. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (상태 Off, LED Off)
  12555. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  12556. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  12557. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  12558. // 설정값을 확인하여 스마트 IoT 현관카메라의 상태를 전송한다. (거동수상자 녹화를 위한 자동 On 기능 활성화)
  12559. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  12560. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  12561. }
  12562. else {
  12563. // 설정값을 확인하여 스마트 IoT 현관카메라의 상태를 전송한다. (거동수상자 녹화를 위한 자동 On 기능 비활성화)
  12564. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  12565. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  12566. }
  12567. }
  12568. }
  12569. };
  12570. // 스마트현관카메라 MODE 제어
  12571. private void ctrlSmartIOTCamStatusMode(byte mode) {
  12572. try {
  12573. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  12574. if (mSmartKeyRfDoorAPI != null) {
  12575. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  12576. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  12577. }
  12578. else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  12579. } catch (RuntimeException re) {
  12580. LogUtil.errorLogInfo("", TAG, re);
  12581. }
  12582. catch (Exception e) {
  12583. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  12584. //e.printStackTrace();
  12585. LogUtil.errorLogInfo("", TAG, e);
  12586. }
  12587. }
  12588. // 스마트현관카메라 LED 상태 제어
  12589. private void ctrlSmartIOTCamLEDMode(byte mode) {
  12590. try {
  12591. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  12592. if (mSmartKeyRfDoorAPI != null) {
  12593. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  12594. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  12595. }
  12596. else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  12597. } catch (RuntimeException re) {
  12598. LogUtil.errorLogInfo("", TAG, re);
  12599. }
  12600. catch (Exception e) {
  12601. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  12602. //e.printStackTrace();
  12603. LogUtil.errorLogInfo("", TAG, e);
  12604. }
  12605. }
  12606. // =================================================================================================
  12607. // [[ Thread ]] region
  12608. // =================================================================================================
  12609. /**
  12610. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  12611. * 10분에 한번씩 저장
  12612. */
  12613. @SuppressLint("UseValueOf")
  12614. class saveRealmeterData extends Thread {
  12615. @Override
  12616. public void run() {
  12617. super.run();
  12618. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  12619. int ret;
  12620. wallpaddbmgr WallpadDBMGRforThread = null;
  12621. while(true) {
  12622. try {
  12623. Thread.sleep(1000 * 60 * 3); //3분마다
  12624. if (mRealTimeMeterAPI != null) {
  12625. ret = mRealTimeMeterAPI.Refresh(false);
  12626. if (ret == 0) {
  12627. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  12628. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :"+ mRealTimeMeterAPI.data.Elec.Acc);
  12629. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  12630. WallpadDBMGRforThread.InsertRealTimeMeterData(
  12631. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  12632. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  12633. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  12634. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  12635. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  12636. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  12637. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  12638. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  12639. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  12640. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  12641. );
  12642. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  12643. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :"+ tempInt);
  12644. if (tempInt > 6000) {
  12645. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  12646. }
  12647. WallpadDBMGRforThread.closeDB();
  12648. }
  12649. else {
  12650. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  12651. }
  12652. }
  12653. else {
  12654. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  12655. }
  12656. } catch (InterruptedException e1) {
  12657. // TODO Auto-generated catch block
  12658. if (WallpadDBMGRforThread != null) {
  12659. WallpadDBMGRforThread.closeDB();
  12660. }
  12661. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  12662. //e1.printStackTrace();
  12663. LogUtil.errorLogInfo("", TAG, e1);
  12664. }
  12665. }
  12666. }
  12667. }
  12668. /**
  12669. * 단지서버 2.0 사용여부
  12670. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  12671. * **/
  12672. public boolean NewServerUse() {
  12673. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12674. if (SetData != null) {
  12675. String serverVesionInfo = SetData.GetServerVer();
  12676. SetData.closeDB();
  12677. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  12678. return true;
  12679. }
  12680. }
  12681. return false;
  12682. }
  12683. /**
  12684. * 단지서버2.0 적용시에만 사용한다.
  12685. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  12686. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  12687. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  12688. **/
  12689. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  12690. String REMOTETYPE_SVR2WEB = "danji_web_control";
  12691. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  12692. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  12693. try {
  12694. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  12695. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  12696. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  12697. NodeList mNodeList = doc.getElementsByTagName("device_info");
  12698. Node mNode = mNodeList.item(0);
  12699. if (mNode != null) {
  12700. String alias = "null", twinid = "null";
  12701. NamedNodeMap attrsParam = mNode.getAttributes();
  12702. for (int j=0; j< attrsParam.getLength(); j++) {
  12703. Node attr = attrsParam.item(j);
  12704. if (attr.getNodeName().equalsIgnoreCase("alias")) alias = attr.getNodeValue();
  12705. else if (attr.getNodeName().equalsIgnoreCase("twinid")) twinid = attr.getNodeValue();
  12706. }
  12707. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  12708. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  12709. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  12710. return MOBILE_USER_AUTH_PASSED;
  12711. }
  12712. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  12713. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  12714. mWallpadMobileDeviceData.closeDB();
  12715. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  12716. else {
  12717. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  12718. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12719. return strReplyMsg;
  12720. }
  12721. }
  12722. else {
  12723. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  12724. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  12725. return strReplyMsg;
  12726. }
  12727. }
  12728. else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  12729. NodeList mNodeList = doc.getElementsByTagName("password_info");
  12730. Node mNode = mNodeList.item(0);
  12731. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  12732. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  12733. mWallpadStatusData.closeDB();
  12734. if (!checkPWValidation(strSavedWebCtrlPW)) {
  12735. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  12736. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12737. return strReplyMsg;
  12738. }
  12739. if (mNode != null) {
  12740. String strReceivedPW = "000000";
  12741. NamedNodeMap attrsParam = mNode.getAttributes();
  12742. for (int j=0; j< attrsParam.getLength(); j++) {
  12743. Node attr = attrsParam.item(j);
  12744. if (attr.getNodeName().equalsIgnoreCase("password")) strReceivedPW = attr.getNodeValue();
  12745. }
  12746. if (!checkPWValidation(strReceivedPW)) {
  12747. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  12748. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12749. return strReplyMsg;
  12750. }
  12751. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  12752. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  12753. return WEB_USER_AUTH_PASSED;
  12754. }
  12755. else {
  12756. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  12757. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12758. return strReplyMsg;
  12759. }
  12760. }
  12761. else {
  12762. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  12763. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  12764. return strReplyMsg;
  12765. }
  12766. }
  12767. else {
  12768. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  12769. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12770. return strReplyMsg;
  12771. }
  12772. } catch (RuntimeException re) {
  12773. LogUtil.errorLogInfo("", TAG, re);
  12774. return null;
  12775. }
  12776. catch (Exception e) {
  12777. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  12778. //e.printStackTrace();
  12779. LogUtil.errorLogInfo("", TAG, e);
  12780. return null;
  12781. }
  12782. }
  12783. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  12784. try {
  12785. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  12786. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  12787. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  12788. NodeList mNodeList = ele.getElementsByTagName("device_info");
  12789. Node mNode = mNodeList.item(0);
  12790. if (mNode != null) {
  12791. String alias = "null", twinid = "null";
  12792. NamedNodeMap attrsParam = mNode.getAttributes();
  12793. for (int j=0; j< attrsParam.getLength(); j++) {
  12794. Node attr = attrsParam.item(j);
  12795. if (attr.getNodeName().equalsIgnoreCase("alias")) alias = attr.getNodeValue();
  12796. else if (attr.getNodeName().equalsIgnoreCase("twinid")) twinid = attr.getNodeValue();
  12797. }
  12798. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  12799. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  12800. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  12801. return MOBILE_USER_AUTH_PASSED;
  12802. }
  12803. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  12804. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  12805. mWallpadMobileDeviceData.closeDB();
  12806. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  12807. else {
  12808. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  12809. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  12810. return strReplyMsg;
  12811. }
  12812. }
  12813. else {
  12814. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  12815. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  12816. return strReplyMsg;
  12817. }
  12818. }
  12819. else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  12820. NodeList mNodeList = ele.getElementsByTagName("password_info");
  12821. Node mNode = mNodeList.item(0);
  12822. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  12823. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  12824. mWallpadStatusData.closeDB();
  12825. if (!checkPWValidation(strSavedWebCtrlPW)) {
  12826. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  12827. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12828. return strReplyMsg;
  12829. }
  12830. if (mNode != null) {
  12831. String strReceivedPW = "000000";
  12832. NamedNodeMap attrsParam = mNode.getAttributes();
  12833. for (int j=0; j< attrsParam.getLength(); j++) {
  12834. Node attr = attrsParam.item(j);
  12835. if (attr.getNodeName().equalsIgnoreCase("password")) strReceivedPW = attr.getNodeValue();
  12836. }
  12837. if (!checkPWValidation(strReceivedPW)) {
  12838. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  12839. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12840. return strReplyMsg;
  12841. }
  12842. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  12843. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  12844. return WEB_USER_AUTH_PASSED;
  12845. }
  12846. else {
  12847. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  12848. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12849. return strReplyMsg;
  12850. }
  12851. }
  12852. else {
  12853. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  12854. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  12855. return strReplyMsg;
  12856. }
  12857. }
  12858. else {
  12859. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  12860. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  12861. return strReplyMsg;
  12862. }
  12863. } catch (RuntimeException re) {
  12864. LogUtil.errorLogInfo("", TAG, re);
  12865. return null;
  12866. }
  12867. catch (Exception e) {
  12868. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  12869. //e.printStackTrace();
  12870. LogUtil.errorLogInfo("", TAG, e);
  12871. return null;
  12872. }
  12873. }
  12874. String[] astrPreventedPWs = { "000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852" };
  12875. private boolean checkPWValidation(String strPW) {
  12876. try {
  12877. // null 확인
  12878. if (strPW == null) {
  12879. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  12880. return false;
  12881. }
  12882. // 입력된 비밀번호 길이 확인
  12883. if (strPW.length() != 6) {
  12884. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  12885. return false;
  12886. }
  12887. // 사전 금지된 비밀번호 확인
  12888. for (int i = 0; i < astrPreventedPWs.length; i++) {
  12889. if (strPW.contains(astrPreventedPWs[i])) {
  12890. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  12891. return false;
  12892. }
  12893. }
  12894. /*// 연속된 비밀번호 확인
  12895. int nSerialNoCnt = 0;
  12896. int nCompareNo = 0;
  12897. int[] naPW = new int[strPW.length()];
  12898. for (int i = 0; i < naPW.length; i++)
  12899. {
  12900. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  12901. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  12902. if (i ==0) {
  12903. nCompareNo = naPW[i];
  12904. nCompareNo++;
  12905. }
  12906. else if (0 < i && i < 6) {
  12907. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  12908. nCompareNo++;
  12909. }
  12910. else {
  12911. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  12912. }
  12913. }
  12914. if (nSerialNoCnt > 3) {
  12915. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  12916. return false;
  12917. }*/
  12918. // 동일한 번호 5회이상 입력 확인
  12919. int nSameNoCnt = 0;
  12920. for (int i = 0; i < strPW.length() - 1; i++) {
  12921. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  12922. nSameNoCnt++;
  12923. }
  12924. }
  12925. if (nSameNoCnt > 4) {
  12926. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  12927. return false;
  12928. }
  12929. // 동, 호정보 확인
  12930. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  12931. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  12932. DBMGR.closeDB();
  12933. String strDong = addr.Dong;
  12934. String strHo = addr.Ho;
  12935. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  12936. if (strPW.substring(0,4).contains(strDong)) {
  12937. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  12938. return false;
  12939. }
  12940. if (strPW.substring(0,4).contains(strHo)) {
  12941. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  12942. return false;
  12943. }
  12944. return true;
  12945. } catch (RuntimeException re) {
  12946. LogUtil.errorLogInfo("", TAG, re);
  12947. return false;
  12948. }
  12949. catch (Exception e) {
  12950. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  12951. //e.printStackTrace();
  12952. LogUtil.errorLogInfo("", TAG, e);
  12953. return false;
  12954. }
  12955. }
  12956. public String iCMDProcOnePass(Element ele) {
  12957. String[] strTarget = { "null", "null", "null" }; // name, id, msg_no
  12958. String[] strDeviceInfo = { "null", "null" }; // alias, twinid
  12959. String strAction = "null", strTargetLobbyIP = "null";
  12960. try {
  12961. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  12962. String retStr = CheckiCMDProc("remote_access_onepass");
  12963. if (retStr != null) return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  12964. // 단지서버 2.0 사용여부 확인
  12965. if (!NewServerUse()) {
  12966. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  12967. }
  12968. // 메시지 송신지 구분
  12969. NodeList items = ele.getElementsByTagName("target");
  12970. Node item = items.item(0);
  12971. if (item != null) {
  12972. NamedNodeMap attrs = item.getAttributes();
  12973. for (int j = 0; j< attrs.getLength(); j++) {
  12974. Node attr = attrs.item(j);
  12975. if (attr.getNodeName().equalsIgnoreCase("name")) strTarget[0] = attr.getNodeValue();
  12976. else if (attr.getNodeName().equalsIgnoreCase("id")) strTarget[1] = attr.getNodeValue();
  12977. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) strTarget[2] = attr.getNodeValue();
  12978. }
  12979. }
  12980. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  12981. if (NewServerUse()) {
  12982. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  12983. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  12984. if (ServerCheckResult.contains("fail")) return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  12985. else if (ServerCheckResult.contains("deny")) return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  12986. else if (ServerCheckResult.contains("none")) return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  12987. else return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  12988. }
  12989. }
  12990. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  12991. Node itemDeviceParam = itemsDeviceParam.item(0);
  12992. if (itemDeviceParam != null) {
  12993. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  12994. for (int j=0; j< attrsParam.getLength(); j++) {
  12995. Node attr = attrsParam.item(j);
  12996. if (attr.getNodeName().equalsIgnoreCase("alias")) strDeviceInfo[0] = attr.getNodeValue();
  12997. else if (attr.getNodeName().equalsIgnoreCase("twinid")) strDeviceInfo[1] = attr.getNodeValue();
  12998. }
  12999. }
  13000. else {
  13001. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13002. }
  13003. // 명령어 구분
  13004. NodeList itemsaction = ele.getElementsByTagName("action");
  13005. Node itemaction = itemsaction.item(0);
  13006. Node text = itemaction.getFirstChild();
  13007. strAction = text.getNodeValue();
  13008. strAction = trimquotation(strAction);
  13009. // 문열림 타겟 로비폰 IP
  13010. NodeList itemsParam = ele.getElementsByTagName("params");
  13011. Node itemParam = itemsParam.item(0);
  13012. if (itemParam != null) {
  13013. NamedNodeMap attrsParam = itemParam.getAttributes();
  13014. for (int j = 0; j < attrsParam.getLength(); j++) {
  13015. Node attr = attrsParam.item(j);
  13016. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) strTargetLobbyIP = attr.getNodeValue();
  13017. }
  13018. }
  13019. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  13020. if (strAction.equalsIgnoreCase("authorize_request")) {
  13021. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  13022. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  13023. }
  13024. else {
  13025. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13026. }
  13027. } catch (RuntimeException re) {
  13028. LogUtil.errorLogInfo("", TAG, re);
  13029. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13030. }
  13031. catch (Exception e) {
  13032. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  13033. //e.printStackTrace();
  13034. LogUtil.errorLogInfo("", TAG, e);
  13035. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13036. }
  13037. }
  13038. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  13039. try {
  13040. String strReplyXml = XMLHeader;
  13041. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  13042. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  13043. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  13044. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  13045. strReplyXml += " </service>\n";
  13046. strReplyXml += "</imap>";
  13047. return strReplyXml;
  13048. } catch (RuntimeException re) {
  13049. LogUtil.errorLogInfo("", TAG, re);
  13050. return "ERROR";
  13051. }
  13052. catch (Exception e) {
  13053. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  13054. //e.printStackTrace();
  13055. LogUtil.errorLogInfo("", TAG, e);
  13056. return "ERROR";
  13057. }
  13058. }
  13059. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  13060. try {
  13061. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName +"]");
  13062. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  13063. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  13064. miMAPLobbyOnePass.SetRetCtr(new RetProci(){
  13065. @Override
  13066. public void ProcSuccess() {
  13067. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  13068. }
  13069. @Override
  13070. public void ProcError() {
  13071. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  13072. }
  13073. @Override
  13074. public void ProcDoing() {
  13075. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  13076. }
  13077. });
  13078. } catch (RuntimeException re) {
  13079. LogUtil.errorLogInfo("", TAG, re);
  13080. }
  13081. catch (Exception e) {
  13082. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  13083. //e.printStackTrace();
  13084. LogUtil.errorLogInfo("", TAG, e);
  13085. }
  13086. }
  13087. private void saveBlackoutStatus(boolean bOccurred) {
  13088. try {
  13089. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  13090. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  13091. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  13092. mEditor.putBoolean("status", bOccurred);
  13093. mEditor.commit();
  13094. } catch (RuntimeException re) {
  13095. LogUtil.errorLogInfo("", TAG, re);
  13096. }
  13097. catch (Exception e) {
  13098. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  13099. //e.printStackTrace();
  13100. LogUtil.errorLogInfo("", TAG, e);
  13101. }
  13102. }
  13103. private boolean getBlackoutStatus() {
  13104. try {
  13105. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  13106. return mSharedPreferences.getBoolean("status", false);
  13107. } catch (RuntimeException re) {
  13108. LogUtil.errorLogInfo("", TAG, re);
  13109. return false;
  13110. }
  13111. catch (Exception e) {
  13112. Log.e(TAG, "[Exception] getBlackoutStatus()");
  13113. //e.printStackTrace();
  13114. LogUtil.errorLogInfo("", TAG, e);
  13115. return false;
  13116. }
  13117. }
  13118. /**
  13119. * JEFF, 2019.12.25
  13120. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  13121. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  13122. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  13123. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  13124. */
  13125. int MAX_WALLPADCALL_LIVE_CNT = 2;
  13126. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  13127. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  13128. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  13129. Handler handlerCheckWallPadCallLive = new Handler() {
  13130. public void handleMessage(Message msg) {
  13131. super.handleMessage(msg);
  13132. sendWallPadCallLiveBR_Request();
  13133. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  13134. }
  13135. };
  13136. private void sendWallPadCallLiveBR_Request() {
  13137. try {
  13138. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  13139. Intent mIntent = new Intent();
  13140. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  13141. getApplicationContext().sendBroadcast(mIntent);
  13142. if (nWallPadCallACKCnt >= 0) {
  13143. nWallPadCallACKCnt--;
  13144. }
  13145. else {
  13146. bWallPadCallLive = false;
  13147. Common.bWallPadCallLive = bWallPadCallLive;
  13148. }
  13149. if (bWallPadCallLive != getCallAppRunning()) {
  13150. setCallAppRunning(bWallPadCallLive);
  13151. }
  13152. Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  13153. } catch (RuntimeException re) {
  13154. LogUtil.errorLogInfo("", TAG, re);
  13155. }
  13156. catch (Exception e) {
  13157. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  13158. //e.printStackTrace();
  13159. LogUtil.errorLogInfo("", TAG, e);
  13160. }
  13161. }
  13162. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  13163. @Override
  13164. public void onReceive(Context context, Intent intent) {
  13165. try {
  13166. String strActionName = intent.getAction();
  13167. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  13168. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  13169. bWallPadCallLive = true;
  13170. Common.bWallPadCallLive = bWallPadCallLive;
  13171. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  13172. Log.w(TAG,"[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "]");
  13173. }
  13174. else {
  13175. Log.w(TAG,"[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  13176. }
  13177. } catch (RuntimeException re) {
  13178. LogUtil.errorLogInfo("", TAG, re);
  13179. }
  13180. catch (Exception e) {
  13181. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  13182. //e.printStackTrace();
  13183. LogUtil.errorLogInfo("", TAG, e);
  13184. }
  13185. }
  13186. };
  13187. static class CALLCTRLHANDLERMSG {
  13188. static final int RELEASE_BLOCK_FRONTCALL = 100;
  13189. }
  13190. boolean bBlockFrontCall = false;
  13191. Handler handlerCallCtrl = new Handler() {
  13192. public void handleMessage(Message msg) {
  13193. super.handleMessage(msg);
  13194. int nMSG = msg.what;
  13195. switch (nMSG) {
  13196. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  13197. bBlockFrontCall = false;
  13198. break;
  13199. }
  13200. }
  13201. };
  13202. /**
  13203. * JEFF, 2019.12.31
  13204. * WallPadCall 실행여부를 DB에 저장한다.
  13205. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  13206. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  13207. */
  13208. public void setCallAppRunning(boolean bRunning) {
  13209. try {
  13210. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13211. mWallpadStatusData.SetCallAPKStatus(bRunning);
  13212. mWallpadStatusData.closeDB();
  13213. } catch (RuntimeException re) {
  13214. LogUtil.errorLogInfo("", TAG, re);
  13215. }
  13216. catch (Exception e) {
  13217. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  13218. //e.printStackTrace();
  13219. LogUtil.errorLogInfo("", TAG, e);
  13220. }
  13221. }
  13222. private boolean getCallAppRunning() {
  13223. boolean bRunning = false;
  13224. try {
  13225. WallpadStatusData WallpadStatusData = new WallpadStatusData(getApplicationContext());
  13226. bRunning = WallpadStatusData.GetCallAPKStatusRunning();
  13227. WallpadStatusData.closeDB();
  13228. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  13229. return bRunning;
  13230. } catch (RuntimeException re) {
  13231. LogUtil.errorLogInfo("", TAG, re);
  13232. return false;
  13233. }
  13234. catch (Exception e) {
  13235. Log.d(TAG, "[Exception] getCallAppRunning()");
  13236. //e.printStackTrace();
  13237. LogUtil.errorLogInfo("", TAG, e);
  13238. return false;
  13239. }
  13240. }
  13241. /**
  13242. * 통화앱 종료코드
  13243. */
  13244. public void killWallPadCall() {
  13245. try {
  13246. Log.i(TAG, "[killWallPadCall] ===== START =====");
  13247. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  13248. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  13249. Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  13250. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  13251. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  13252. // android.os.Process.killProcess(nWallPadCallPID);
  13253. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  13254. // if(list != null){
  13255. // for(int i=0;i<list.size();++i){
  13256. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  13257. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  13258. // android.os.Process.killProcess(pid);
  13259. // }
  13260. // }
  13261. // }
  13262. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  13263. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  13264. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  13265. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  13266. // android.os.Process.killProcess(pid);
  13267. } catch (RuntimeException re) {
  13268. LogUtil.errorLogInfo("", TAG, re);
  13269. }
  13270. catch (Exception e) {
  13271. Log.e(TAG, "[Exception] killWallPadCall()");
  13272. //e.printStackTrace();
  13273. LogUtil.errorLogInfo("", TAG, e);
  13274. }
  13275. }
  13276. private void checkForegroundActivity() {
  13277. try {
  13278. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  13279. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  13280. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  13281. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  13282. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  13283. } catch (RuntimeException re) {
  13284. LogUtil.errorLogInfo("", TAG, re);
  13285. }
  13286. catch (Exception e) {
  13287. Log.e(TAG, "[Exception] checkForegroundActivity()");
  13288. //e.printStackTrace();
  13289. LogUtil.errorLogInfo("", TAG, e);
  13290. }
  13291. }
  13292. /**
  13293. * JEFF, 2020.01.04
  13294. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  13295. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  13296. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  13297. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  13298. */
  13299. static long lConnectionPeriod = 0;
  13300. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  13301. boolean bRingGeneratorRun = false;
  13302. private void startIGW300RingGenerator() {
  13303. try {
  13304. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  13305. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  13306. bRingGeneratorRun = true;
  13307. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  13308. mIGW300RingGeneratorThread.start();
  13309. }
  13310. else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  13311. } catch (RuntimeException re) {
  13312. LogUtil.errorLogInfo("", TAG, re);
  13313. }
  13314. catch (Exception e) {
  13315. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  13316. //e.printStackTrace();
  13317. LogUtil.errorLogInfo("", TAG, e);
  13318. }
  13319. }
  13320. private void stopIGW300RingGenerator() {
  13321. try {
  13322. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  13323. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  13324. lConnectionPeriod = -999;
  13325. bRingGeneratorRun = false;
  13326. mIGW300RingGeneratorThread = null;
  13327. }
  13328. else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  13329. } catch (RuntimeException re) {
  13330. LogUtil.errorLogInfo("", TAG, re);
  13331. }
  13332. catch (Exception e) {
  13333. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  13334. //e.printStackTrace();
  13335. LogUtil.errorLogInfo("", TAG, e);
  13336. }
  13337. }
  13338. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  13339. private class IGW300RingGeneratorThread extends Thread {
  13340. public IGW300RingGeneratorThread() {
  13341. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  13342. }
  13343. public void run() {
  13344. try {
  13345. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  13346. if (bRingGeneratorRun) Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  13347. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  13348. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  13349. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  13350. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  13351. try {
  13352. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  13353. } catch (InterruptedException e) {
  13354. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  13355. //e.printStackTrace();
  13356. LogUtil.errorLogInfo("", TAG, e);
  13357. }
  13358. }
  13359. bRingGeneratorRun = false;
  13360. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  13361. } catch (RuntimeException re) {
  13362. LogUtil.errorLogInfo("", TAG, re);
  13363. }
  13364. catch (Exception e) {
  13365. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  13366. //e.printStackTrace();
  13367. LogUtil.errorLogInfo("", TAG, e);
  13368. }
  13369. }
  13370. }
  13371. private void sendPSTNRingEvent(int nKeyCode) {
  13372. try {
  13373. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  13374. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  13375. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  13376. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  13377. intent.putExtra("keycode",nKeyCode);
  13378. getApplicationContext().sendBroadcast(intent);
  13379. } catch (RuntimeException re) {
  13380. LogUtil.errorLogInfo("", TAG, re);
  13381. }
  13382. catch (Exception e) {
  13383. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  13384. //e.printStackTrace();
  13385. LogUtil.errorLogInfo("", TAG, e);
  13386. }
  13387. }
  13388. /**
  13389. * 월패드 타입 판별
  13390. * @return bResult
  13391. * false: 메인월패드
  13392. * true: 서브월패드
  13393. */
  13394. public boolean getIsSubWallpad() {
  13395. boolean bResult = false;
  13396. try {
  13397. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13398. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  13399. mWallpadDeviceSet.closeDB();
  13400. if(DBinfo != null) {
  13401. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  13402. else bResult = false;
  13403. }
  13404. } catch (RuntimeException re) {
  13405. LogUtil.errorLogInfo("", TAG, re);
  13406. }
  13407. catch (Exception e) {
  13408. Log.e(TAG, "[Exception] getIsSubWallpad()");
  13409. //e.printStackTrace();
  13410. LogUtil.errorLogInfo("", TAG, e);
  13411. }
  13412. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  13413. return bResult;
  13414. }
  13415. /**
  13416. * JEFF, 2020.02.05
  13417. * 월패드 비상접점 신호 사용 여부 확인
  13418. */
  13419. public boolean getEmergencyIOUsage() {
  13420. boolean bResult = false;
  13421. try {
  13422. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13423. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  13424. mWallpadDeviceSet.closeDB();
  13425. } catch (RuntimeException re) {
  13426. LogUtil.errorLogInfo("", TAG, re);
  13427. }
  13428. catch (Exception e) {
  13429. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  13430. //e.printStackTrace();
  13431. LogUtil.errorLogInfo("", TAG, e);
  13432. }
  13433. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  13434. return bResult;
  13435. }
  13436. /**
  13437. * JEFF, 2020.02.05
  13438. * 거동수상자 녹화기능 활성화 확인
  13439. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  13440. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  13441. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  13442. */
  13443. public boolean getStrangerRecordingManagerSetting() {
  13444. boolean bResult = false;
  13445. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13446. try {
  13447. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13448. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  13449. mWallpadDeviceSet.closeDB();
  13450. if (nFrontCam[0] == COMPONENT_USE) {
  13451. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13452. if (bRecord) bResult = true;
  13453. else bResult = false;
  13454. }
  13455. else bResult = false;
  13456. }
  13457. else bResult = false;
  13458. } catch (RuntimeException re) {
  13459. LogUtil.errorLogInfo("", TAG, re);
  13460. mWallpadDeviceSet.closeDB();
  13461. }
  13462. catch (Exception e) {
  13463. mWallpadDeviceSet.closeDB();
  13464. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  13465. //e.printStackTrace();
  13466. LogUtil.errorLogInfo("", TAG, e);
  13467. }
  13468. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  13469. return bResult;
  13470. }
  13471. /**
  13472. * Edited by jeff (2020.06.22)
  13473. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  13474. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  13475. * @param bOn
  13476. */
  13477. private void sendLCDBacklightStatus(boolean bOn) {
  13478. try {
  13479. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  13480. Intent mIntent = new Intent();
  13481. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  13482. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  13483. getApplicationContext().sendBroadcast(mIntent);
  13484. } catch (RuntimeException re) {
  13485. LogUtil.errorLogInfo("", TAG, re);
  13486. }
  13487. catch (Exception e) {
  13488. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  13489. //e.printStackTrace();
  13490. LogUtil.errorLogInfo("", TAG, e);
  13491. }
  13492. }
  13493. // 명칭 관련
  13494. boolean bRoomNameLog = true;
  13495. public static final int HEATING = 1;
  13496. public static final int LIGHT = 2;
  13497. private String[] mRoomNameList_Light = null; //조명 방 명칭
  13498. private String[] mRoomNameList_Heating = null; //난방 방 명칭
  13499. private String[] mDefaultRoomNameList = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  13500. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  13501. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  13502. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  13503. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  13504. /**
  13505. * DB 에서 룸이름 정보를 가져온다.
  13506. *
  13507. * @return (String []) null - 실패, not null
  13508. */
  13509. private String[] getDBRoomName() {
  13510. try {
  13511. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  13512. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  13513. wallpadStatusData.closeDB();
  13514. if (strRoomNameList == null) {
  13515. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  13516. return null;
  13517. }
  13518. if (bRoomNameLog) {
  13519. for (int i = 0; i < strRoomNameList.length; i++)
  13520. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  13521. }
  13522. return strRoomNameList;
  13523. } catch (RuntimeException re) {
  13524. LogUtil.errorLogInfo("", TAG, re);
  13525. }
  13526. catch (Exception e) {
  13527. Log.e(TAG, "[Exception] getDBRoomName()");
  13528. //e.printStackTrace();
  13529. LogUtil.errorLogInfo("", TAG, e);
  13530. }
  13531. return null;
  13532. }
  13533. /**
  13534. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  13535. *
  13536. * @param nDeviceType - int
  13537. * @return (String []) null - 실패, not null
  13538. */
  13539. private String[] getDBRoomName(int nDeviceType) {
  13540. try {
  13541. String[] strRoomNameList = null;
  13542. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  13543. if (nDeviceType == HEATING) {
  13544. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  13545. }
  13546. else {
  13547. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  13548. }
  13549. wallpadStatusData.closeDB();
  13550. if (strRoomNameList == null) {
  13551. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  13552. return null;
  13553. }
  13554. if (bRoomNameLog) {
  13555. for (int i = 0; i < strRoomNameList.length; i++)
  13556. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  13557. }
  13558. return strRoomNameList;
  13559. } catch (RuntimeException re) {
  13560. LogUtil.errorLogInfo("", TAG, re);
  13561. }
  13562. catch (Exception e) {
  13563. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  13564. //e.printStackTrace();
  13565. LogUtil.errorLogInfo("", TAG, e);
  13566. }
  13567. return null;
  13568. }
  13569. /**
  13570. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  13571. **/
  13572. private void getRoomName() {
  13573. try {
  13574. Log.i(TAG, "[getRoomName] ====================");
  13575. // WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13576. // boolean bRoomNameEach = wallpadDeviceSet.GetEachRoomNameInfo();
  13577. // wallpadDeviceSet.closeDB();
  13578. // Log.i(TAG, "[getRoomName] bRoomNameEach [" + bRoomNameEach + "]");
  13579. //
  13580. // if (bRoomNameEach) {
  13581. // // 명칭 난방, 조명 분리 사용
  13582. // mRoomNameList_Light = getDBRoomName(LIGHT);
  13583. // if (mRoomNameList_Light == null) {
  13584. // mRoomNameList_Light = mDefaultRoomNameList_Light;
  13585. // }
  13586. //
  13587. // if (getEasyModeUXUsage()) {
  13588. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  13589. // }
  13590. // else {
  13591. // mRoomNameList_Heating = getDBRoomName(HEATING);
  13592. // if (mRoomNameList_Heating == null) {
  13593. // mRoomNameList_Heating = mDefaultRoomNameList_Heating;
  13594. // }
  13595. // }
  13596. // }
  13597. // else {
  13598. // // 명칭 통합사용
  13599. // mRoomNameList_Light = getDBRoomName();
  13600. // if (mRoomNameList_Light == null) {
  13601. // mRoomNameList_Light = mDefaultRoomNameList;
  13602. // }
  13603. //
  13604. // if (getEasyModeUXUsage()) {
  13605. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  13606. // }
  13607. // else {
  13608. // mRoomNameList_Heating = getDBRoomName();
  13609. // if (mRoomNameList_Heating == null) {
  13610. // mRoomNameList_Heating = mDefaultRoomNameList;
  13611. // }
  13612. // }
  13613. // }
  13614. //
  13615. // if (bRoomNameLog) {
  13616. // for (int i = 0; i < mRoomNameList_Light.length; i++) {
  13617. // Log.i(TAG, "[getRoomName] mRoomNameList_Light[" + i + "] " + mRoomNameList_Light[i]);
  13618. // }
  13619. //
  13620. // for (int i = 0; i < mRoomNameList_Heating.length; i++) {
  13621. // Log.i(TAG, "[getRoomName] mRoomNameList_Heating[" + i + "] " + mRoomNameList_Heating[i]);
  13622. // }
  13623. // }
  13624. } catch (RuntimeException re) {
  13625. LogUtil.errorLogInfo("", TAG, re);
  13626. }
  13627. catch (Exception e) {
  13628. Log.e(TAG, "[Exception] getRoomName()");
  13629. //e.printStackTrace();
  13630. LogUtil.errorLogInfo("", TAG, e);
  13631. }
  13632. }
  13633. public boolean getEasyModeUXUsage() {
  13634. try {
  13635. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  13636. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  13637. deviceSet.closeDB();
  13638. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  13639. boolean bUse = data.GetEasyModeUxUse();
  13640. data.closeDB();
  13641. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  13642. return bSupport & bUse;
  13643. } catch (RuntimeException re) {
  13644. LogUtil.errorLogInfo("", TAG, re);
  13645. }
  13646. catch (Exception e) {
  13647. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  13648. //e.printStackTrace();
  13649. LogUtil.errorLogInfo("", TAG, e);
  13650. }
  13651. return false;
  13652. }
  13653. /**
  13654. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  13655. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  13656. * 재설정 5초 후 월패드 재부팅을 실행한다.
  13657. * 2020.11.18 SEULKI
  13658. */
  13659. public void checkDoorCamConfig() {
  13660. try {
  13661. if (Build.VERSION.SDK_INT > 23) {
  13662. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  13663. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  13664. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I) {
  13665. if (!checkAvailableBSPDoorCamConfig()) {
  13666. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  13667. return;
  13668. }
  13669. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  13670. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  13671. if(mIOInterface!=null) mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  13672. // 재부팅
  13673. setDefaultLauncher();
  13674. Intent intent = new Intent();
  13675. if(intent!=null)
  13676. {
  13677. intent.setAction(define.NOTIFY_ACNAME);
  13678. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  13679. getApplicationContext().sendBroadcast(intent);
  13680. }
  13681. }
  13682. }
  13683. }
  13684. }
  13685. catch (RuntimeException re)
  13686. {
  13687. LogUtil.errorLogInfo("", "", re);
  13688. }
  13689. catch (Exception e) {
  13690. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  13691. LogUtil.errorLogInfo("", "", e);
  13692. }
  13693. }
  13694. /**
  13695. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  13696. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  13697. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  13698. * @return true: 지원, false: 미지원
  13699. */
  13700. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  13701. private boolean checkAvailableBSPDoorCamConfig() {
  13702. try {
  13703. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  13704. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  13705. if (nCurrentVer >= nCriterionVer) {
  13706. return true;
  13707. }
  13708. else return false;
  13709. } catch (RuntimeException re) {
  13710. LogUtil.errorLogInfo("", TAG, re);
  13711. return false;
  13712. }
  13713. catch (Exception e) {
  13714. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  13715. //e.printStackTrace();
  13716. LogUtil.errorLogInfo("", TAG, e);
  13717. return false;
  13718. }
  13719. }
  13720. /**
  13721. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  13722. * @return 1 - 스마트현관카메라
  13723. * 0 - 일반현관카메라
  13724. * @return 0 - 스마트현관카메라
  13725. * 2 - 스마트현관카메라 좌우반전
  13726. * 1 - 일반현관카메라
  13727. * 2020.11.18 SEULKI
  13728. */
  13729. public int getBSPDoorCamConfig() {
  13730. InputStreamReader is = null;
  13731. try {
  13732. Runtime mRuntime = Runtime.getRuntime();
  13733. String cmd = "getprop camera.setting.value";
  13734. if(mRuntime!=null)
  13735. {
  13736. Process mProcess = mRuntime.exec(cmd);
  13737. is = new InputStreamReader(mProcess.getInputStream());
  13738. BufferedReader br = new BufferedReader(is);
  13739. String line;
  13740. String strResult = null;
  13741. if(br!=null)
  13742. {
  13743. while ((line = br.readLine()) != null) {
  13744. strResult = line;
  13745. }
  13746. if(strResult!=null)
  13747. {
  13748. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  13749. if (strResult.equals("0")) {
  13750. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  13751. return 0;
  13752. } else if (strResult.equals("1")) {
  13753. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  13754. return 1;
  13755. } else if (strResult.equals("2")) {
  13756. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  13757. return 2;
  13758. } else {
  13759. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  13760. return -1;
  13761. }
  13762. }
  13763. }
  13764. }
  13765. return -1;
  13766. } catch (Exception e) {
  13767. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  13768. e.printStackTrace();
  13769. return -1;
  13770. }
  13771. finally {
  13772. if(is!=null)
  13773. {
  13774. try {
  13775. is.close();
  13776. } catch (IOException e) {
  13777. LogUtil.errorLogInfo("", TAG, e);
  13778. }
  13779. is =null;
  13780. }
  13781. }
  13782. }
  13783. /**
  13784. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  13785. * @return 0 - 스마트현관카메라
  13786. * 2 - 스마트현관카메라 좌우반전
  13787. * 1 - 일반현관카메라
  13788. * 2020.11.18 SEULKI
  13789. */
  13790. public int getDBDoorCamConfig() {
  13791. try {
  13792. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13793. if(mWallpadDeviceSet!=null)
  13794. {
  13795. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13796. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  13797. mWallpadDeviceSet.closeDB();
  13798. if(nType!=null)
  13799. {
  13800. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  13801. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  13802. Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA");
  13803. if (bFlip) {
  13804. Log.d(TAG, "[getDBDoorCamConfig] BSP - SMART IOT FLIP CAMERA");
  13805. return 2;
  13806. } else {
  13807. Log.d(TAG, "[getDBDoorCamConfig] BSP - SMART IOT CAMERA");
  13808. return 0;
  13809. }
  13810. } else {
  13811. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  13812. return 1;
  13813. }
  13814. }
  13815. }
  13816. return -1;
  13817. } catch (Exception e) {
  13818. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  13819. e.printStackTrace();
  13820. return -1;
  13821. }
  13822. }
  13823. /**
  13824. * 공기질 센서 사용여부 확인
  13825. * @return true - 사용함, false: 사용안함
  13826. */
  13827. boolean bAirQualityEnable = false;
  13828. private boolean getAirQualityUsage() {
  13829. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13830. try {
  13831. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  13832. mWallpadDeviceSet.closeDB();
  13833. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  13834. bAirQualityEnable = true;
  13835. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable +"]");
  13836. }
  13837. else {
  13838. bAirQualityEnable = false;
  13839. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable +"]");
  13840. }
  13841. return bAirQualityEnable;
  13842. } catch (RuntimeException re) {
  13843. LogUtil.errorLogInfo("", TAG, re);
  13844. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  13845. return false;
  13846. }
  13847. catch (Exception e) {
  13848. Log.e(TAG, "[Exception] getAirQualityUsage()");
  13849. //e.printStackTrace();
  13850. LogUtil.errorLogInfo("", TAG, e);
  13851. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  13852. return false;
  13853. }
  13854. }
  13855. String strAirQualityFWVer = "";
  13856. String strAirQualityProtocolVer = "";
  13857. String strAirQualityInfo = "";
  13858. private String getAirQualityInfo() {
  13859. try {
  13860. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  13861. if (mAirQualitySensorAPI != null) {
  13862. int nRet = mAirQualitySensorAPI.Refresh(false);
  13863. if (nRet >= 0) {
  13864. Log.i(TAG, "[getAirQualityInfo] ");
  13865. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  13866. strAirQualityFWVer = "FW" + (int)(mAirQualityInfo.FWVer_Year +2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  13867. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  13868. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  13869. return strAirQualityInfo;
  13870. }
  13871. else return "FAIL";
  13872. }
  13873. else return "NULL";
  13874. } catch (RuntimeException re) {
  13875. LogUtil.errorLogInfo("", TAG, re);
  13876. return "ERROR";
  13877. }
  13878. catch (Exception e) {
  13879. Log.e(TAG, "[Exception] getAirQualityInfo()");
  13880. //e.printStackTrace();
  13881. LogUtil.errorLogInfo("", TAG, e);
  13882. return "ERROR";
  13883. }
  13884. }
  13885. private String getAOSVerCode() {
  13886. try {
  13887. int nOSVer = Build.VERSION.SDK_INT;
  13888. switch (nOSVer) {
  13889. case Build.VERSION_CODES.BASE:
  13890. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  13891. case Build.VERSION_CODES.BASE_1_1:
  13892. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  13893. case Build.VERSION_CODES.CUPCAKE:
  13894. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  13895. case Build.VERSION_CODES.DONUT:
  13896. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  13897. case Build.VERSION_CODES.ECLAIR:
  13898. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  13899. case Build.VERSION_CODES.ECLAIR_0_1:
  13900. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  13901. case Build.VERSION_CODES.ECLAIR_MR1:
  13902. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  13903. case Build.VERSION_CODES.FROYO:
  13904. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  13905. case Build.VERSION_CODES.GINGERBREAD:
  13906. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  13907. case Build.VERSION_CODES.GINGERBREAD_MR1:
  13908. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  13909. case Build.VERSION_CODES.HONEYCOMB:
  13910. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  13911. case Build.VERSION_CODES.HONEYCOMB_MR1:
  13912. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  13913. case Build.VERSION_CODES.HONEYCOMB_MR2:
  13914. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  13915. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  13916. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  13917. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  13918. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  13919. case Build.VERSION_CODES.JELLY_BEAN:
  13920. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  13921. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  13922. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  13923. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  13924. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  13925. case Build.VERSION_CODES.KITKAT:
  13926. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  13927. case Build.VERSION_CODES.KITKAT_WATCH:
  13928. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  13929. case Build.VERSION_CODES.LOLLIPOP:
  13930. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  13931. case Build.VERSION_CODES.LOLLIPOP_MR1:
  13932. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  13933. case Build.VERSION_CODES.M:
  13934. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  13935. case Build.VERSION_CODES.N:
  13936. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  13937. case Build.VERSION_CODES.N_MR1:
  13938. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  13939. case Build.VERSION_CODES.O:
  13940. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  13941. case Build.VERSION_CODES.O_MR1:
  13942. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  13943. case Build.VERSION_CODES.P:
  13944. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  13945. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  13946. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  13947. default:
  13948. return "SDK(" + nOSVer + ")/UNKNOWN";
  13949. }
  13950. } catch (RuntimeException re) {
  13951. LogUtil.errorLogInfo("", TAG, re);
  13952. return "ERROR";
  13953. }
  13954. catch (Exception e) {
  13955. Log.e(TAG, "[Exception] getAirQualityInfo()");
  13956. //e.printStackTrace();
  13957. LogUtil.errorLogInfo("", TAG, e);
  13958. return "ERROR";
  13959. }
  13960. }
  13961. // private void demoPushMsg()
  13962. // {
  13963. // String urlStr1 = "";
  13964. //
  13965. // if(android.os.Build.VERSION.SDK_INT > 9 )
  13966. // {
  13967. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  13968. // StrictMode.setThreadPolicy(policy);
  13969. // }
  13970. //
  13971. // String Msg ="";
  13972. // try {
  13973. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  13974. // } catch (UnsupportedEncodingException e1) {
  13975. // // TODO Auto-generated catch block
  13976. // e1.printStackTrace();
  13977. // }
  13978. //
  13979. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  13980. // Log.d(TAG , "################ : " + urlStr1);
  13981. // try
  13982. // {
  13983. // //URLEncoder.encode(s)
  13984. // HttpClient client = new DefaultHttpClient();
  13985. //
  13986. // HttpGet get = new HttpGet();
  13987. // //get.setURI(new URI("http://www.google.com/"));
  13988. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  13989. // HttpResponse resp = client.execute(get);
  13990. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  13991. // String str = null;
  13992. // StringBuilder sb = new StringBuilder();
  13993. // while((str = br.readLine()) != null)
  13994. // {
  13995. // sb.append(str).append("\n");
  13996. // }
  13997. // br.close();
  13998. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  13999. // //txt.setText(sb.toString());
  14000. // }catch(Exception e)
  14001. // {
  14002. //
  14003. // e.printStackTrace();
  14004. //
  14005. // }
  14006. //
  14007. //
  14008. // }
  14009. //
  14010. //
  14011. // public static boolean checkForExternal(String str) {
  14012. // int length = str.length();
  14013. // for (int i = 0; i < length; i++) {
  14014. // if (str.charAt(i) > 0x7F) {
  14015. // return true;
  14016. // }
  14017. // }
  14018. // return false;
  14019. // }
  14020. //
  14021. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  14022. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  14023. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  14024. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  14025. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  14026. //
  14027. // public static String encodeUrl(String url) {
  14028. // if (checkForExternal(url)) {
  14029. // try {
  14030. // String value = URLEncoder.encode(url, "UTF-8");
  14031. // value = COLON.matcher(value).replaceAll(":");
  14032. // value = SLASH.matcher(value).replaceAll("/");
  14033. // value = QUEST_MARK.matcher(value).replaceAll("?");
  14034. // value = EQUAL.matcher(value).replaceAll("=");
  14035. // return AMP.matcher(value).replaceAll("&");
  14036. // } catch (UnsupportedEncodingException e) {
  14037. // //throw LOGGER.getIllegalStateException(e);
  14038. // return null;
  14039. // }
  14040. // } else {
  14041. // return url;
  14042. // }
  14043. // }
  14044. }