iMapServer.java 891 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165
  1. package kr.co.icontrols.wallpadmain.util;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningTaskInfo;
  5. import android.app.Service;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.media.AudioManager;
  15. import android.os.Build;
  16. import android.os.Bundle;
  17. import android.os.CountDownTimer;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Looper;
  21. import android.os.Message;
  22. import android.os.Messenger;
  23. import android.os.PowerManager;
  24. import android.os.RemoteException;
  25. import android.os.SystemClock;
  26. import android.provider.Settings;
  27. import android.util.Log;
  28. import android.view.KeyEvent;
  29. import android.view.View;
  30. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  31. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  32. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  33. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  34. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  35. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  36. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  37. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  38. import com.artncore.WallPadDataMgr.WallpadStatusData;
  39. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  40. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  41. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  42. import com.artncore.WallPadKNXSystem.WallPadKNX;
  43. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  44. import com.artncore.commons.APIErrorCode;
  45. import com.artncore.commons.API_Menu;
  46. import com.artncore.commons.DataClasses;
  47. import com.artncore.commons.DataClasses.HeatingV1;
  48. import com.artncore.commons.DataClasses.HeatingV2;
  49. import com.artncore.commons.DataClasses.MultiSwitch;
  50. import com.artncore.commons.KNX_DataClasses;
  51. import com.artncore.commons.define;
  52. import com.artncore.deviceinterface.WallPadInterface;
  53. import com.artncore.wallpadapi.AirQualitySensorAPI;
  54. import com.artncore.wallpadapi.CooktopAPI;
  55. import com.artncore.wallpadapi.DLockAPI;
  56. import com.artncore.wallpadapi.EnergyMeterAPI;
  57. import com.artncore.wallpadapi.GasAPI;
  58. import com.artncore.wallpadapi.HeatingV1API;
  59. import com.artncore.wallpadapi.HeatingV2API;
  60. import com.artncore.wallpadapi.IGW200dAPI;
  61. import com.artncore.wallpadapi.IGW300API;
  62. import com.artncore.wallpadapi.IntLightAPI;
  63. import com.artncore.wallpadapi.KnxAPI;
  64. import com.artncore.wallpadapi.KnxSystemAirconAPI;
  65. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  66. import com.artncore.wallpadapi.LightAPI;
  67. import com.artncore.wallpadapi.MultiSwitchAPI;
  68. import com.artncore.wallpadapi.PhonNRemocon;
  69. import com.artncore.wallpadapi.RealTimeMeterAPI;
  70. import com.artncore.wallpadapi.SdbAPI;
  71. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  72. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  73. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  74. import com.artncore.wallpadapi.VentiAPI;
  75. import com.artncore.wallpadapi.WallPadAPI;
  76. import com.artncore.wallpadimap.RetProci;
  77. import com.artncore.wallpadimap.WallPadFTPUploader;
  78. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  79. import com.artncore.wallpadimap.WallpadiCMDParser;
  80. import com.util.LogUtil;
  81. import org.apache.commons.net.ftp.FTP;
  82. import org.w3c.dom.Document;
  83. import org.w3c.dom.Element;
  84. import org.w3c.dom.NamedNodeMap;
  85. import org.w3c.dom.Node;
  86. import org.w3c.dom.NodeList;
  87. import java.io.BufferedReader;
  88. import java.io.ByteArrayInputStream;
  89. import java.io.DataOutputStream;
  90. import java.io.File;
  91. import java.io.FilenameFilter;
  92. import java.io.IOException;
  93. import java.io.InputStream;
  94. import java.io.InputStreamReader;
  95. import java.net.ServerSocket;
  96. import java.net.Socket;
  97. import java.text.SimpleDateFormat;
  98. import java.util.ArrayList;
  99. import java.util.Arrays;
  100. import java.util.Calendar;
  101. import java.util.Date;
  102. import java.util.GregorianCalendar;
  103. import java.util.LinkedList;
  104. import java.util.List;
  105. import java.util.Queue;
  106. import javax.net.ssl.SSLServerSocket;
  107. import javax.xml.parsers.DocumentBuilder;
  108. import javax.xml.parsers.DocumentBuilderFactory;
  109. import de.re.easymodbus.exceptions.ModbusException;
  110. import de.re.easymodbus.modbusclient.ModbusClient;
  111. import kr.co.icontrols.gledeviceinterface.jni;
  112. import kr.co.icontrols.hdcftp.HDCFTPManager;
  113. import kr.co.icontrols.sslapi.SSLClient;
  114. import kr.co.icontrols.sslapi.SSLServer;
  115. import kr.co.icontrols.wallpadmain.IOInterface;
  116. import kr.co.icontrols.wallpadmain.MainActivity;
  117. import kr.co.icontrols.wallpadmain.R;
  118. import kr.co.icontrols.wallpadmain.declare.Common;
  119. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  120. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  121. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  122. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  123. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  124. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  125. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  126. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  127. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  128. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  129. import kr.co.icontrols.wallpadsupport.Version;
  130. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  131. import kr.co.icontrols.wallpadsupport.WpadSound;
  132. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  133. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  134. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  135. public class iMapServer extends Service {
  136. private String TAG = "iMapServer";
  137. //
  138. static final int EVENTTIMELIMITE = 2000;
  139. iMapSverSocket SvrSock;
  140. int port = 10000;
  141. String StrAddr = "";
  142. String IPaddr;
  143. String AddrDong;
  144. String AddrHo;
  145. boolean m_CallAppRunDelay = false; //add KSJ
  146. int ho;
  147. boolean log_sw = true;
  148. String SVRIP = "";
  149. static WallPadAPI mWallPadAPI;
  150. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  151. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  152. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  153. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  154. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  155. private IGW200 mIGW200;
  156. private IGW300 mIGW300;
  157. PhonNRemocon PnRCtr;
  158. boolean CallConnected = false;
  159. long ALERTTIME = 0;
  160. long CALLTIME = 0;
  161. long OPENDOORTIME = 0;
  162. long currentTime = 0;
  163. long DoorDelayTime = 0;
  164. static Handler ScheDulerHandler;
  165. static final boolean iMAPDOORCTR = true;
  166. private jni mGleInterface = null;
  167. IOInterface mIOInterface = null;
  168. private boolean ResetFlag = false;
  169. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  170. private int ResetCount = 0;
  171. private boolean NowMainStatus = false;
  172. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  173. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  174. public iMapServer() {
  175. Log.i(TAG, "[iMapServer] ========== START ==========");
  176. }
  177. public static final int SENSOR_MAG = 0x01;
  178. public static final int SENSOR_IN = 0x02;
  179. public static final int SENSOR_OUT = 0x04;
  180. static int PORT_NUM_iMAP = 10000;
  181. static int SOCKET_WAIT_TIME = 40;
  182. static long lSocketConnectionPeriod = 0;
  183. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  184. static int SOCKET_BUFFER_SIZE_READ = 50;
  185. public static final String ITEM_MENU_TYPE = "call_menu";
  186. static final int DOOR_DELAY_TIME = 3000;
  187. static final String MULTISW_CTR = "remote_access_electric";
  188. String XMLHeader;
  189. SchedulerThread ScheServer;
  190. int OutGoingSensorWaiting = 0;
  191. private int ModelType = Version.getModelType();
  192. private WpadSound mSound;
  193. private WpadSound Sound() {
  194. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  195. return mSound;
  196. }
  197. /**
  198. * 신형 단지서버 사용 유무
  199. */
  200. private boolean mNewDanjiServer = false;
  201. /**
  202. * 방범 앱 재실행 여부
  203. */
  204. private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
  205. /**
  206. * JEFF, 2019.12.31
  207. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  208. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  209. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  210. * 통화앱 종료 BR을 삭제하면 안됨
  211. */
  212. // 통화어플이 종료중인 경우에는 호출 무시
  213. // private boolean bBlockCallEvent = false;
  214. ////////////////////////////////////////////////////////////////////////////////
  215. // 엘리베이터관련
  216. ////////////////////////////////////////////////////////////////////////////////
  217. /**
  218. * 엘리베이터 호출관련 class
  219. * <p>
  220. * shkang
  221. */
  222. private class ElevatorClass {
  223. /**
  224. * 엘리베이터 호출 타임아웃 (단위:초)
  225. */
  226. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
  227. /**
  228. * 상향/하향 플레그 true:상향UP, false:하향DN
  229. */
  230. private boolean mUpDn = false;
  231. /**
  232. * 엘리베이터 호출중
  233. */
  234. private boolean mCallElevator = false;
  235. /**
  236. * 엘리베이터 호출 API
  237. */
  238. private WallPadiMAPNotifyAPI mElevatorAPI;
  239. /**
  240. * 엘리베이터 호출 타이머
  241. */
  242. private CountDownTimer mElevatorTimer;
  243. /**
  244. * 엘리베이터 호출중 상태 가져오기
  245. */
  246. public boolean getElevatorCalling() {
  247. return mCallElevator;
  248. }
  249. /**
  250. * 엘리베이터 호출 상태 클리어
  251. */
  252. public void ClearElevator() {
  253. mCallElevator = false;
  254. }
  255. /**
  256. * 생성자
  257. *
  258. * @param Up - (boolean) true:상향, false:하향
  259. */
  260. private ElevatorClass(boolean Up) {
  261. try {
  262. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
  263. // 1. Input Param
  264. mUpDn = Up;
  265. mCallElevator = false;
  266. // 2. Create API
  267. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  268. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  269. @Override
  270. public void ProcDoing() {
  271. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  272. }
  273. @Override
  274. public void ProcError() {
  275. Log.i(TAG, "[ElevatorClass] ProcError()");
  276. mCallElevator = false;
  277. // 엘리베이터 호출 에러 알림
  278. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  279. }
  280. @Override
  281. public void ProcSuccess() {
  282. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  283. mCallElevator = true;
  284. // 엘리베이터 호출 성공 알림
  285. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  286. // "엘리베이터를 호출하였습니다" 멘트출력
  287. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  288. Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
  289. if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
  290. Sound().PlayMent(WpadSound.SND.elevator.CALL);
  291. bOutModeRestart = false;
  292. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  293. // 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
  294. // 타임아웃 시작
  295. TimeOutStart();
  296. }
  297. });
  298. // 3. Create Timer
  299. mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  300. @Override
  301. public void onFinish() {
  302. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  303. mCallElevator = false;
  304. // 호출 타임아웃 알림
  305. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  306. }
  307. @Override
  308. public void onTick(long arg0) {
  309. int RemainingTime = (int) (arg0 / 1000);
  310. if (RemainingTime <= 10) {
  311. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  312. }
  313. }
  314. };
  315. } catch (RuntimeException re) {
  316. LogUtil.errorLogInfo("", TAG, re);
  317. } catch (Exception e) {
  318. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  319. //e.printStackTrace();
  320. LogUtil.errorLogInfo("", TAG, e);
  321. }
  322. }
  323. /**
  324. * 엘리베이터 호출을 한다.
  325. */
  326. public void CallElevator() {
  327. try {
  328. if (mElevatorAPI == null) return;
  329. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  330. mCallElevator = true;
  331. } catch (RuntimeException re) {
  332. LogUtil.errorLogInfo("", TAG, re);
  333. } catch (Exception e) {
  334. Log.e(TAG, "[Exception] CallElevator()");
  335. //e.printStackTrace();
  336. LogUtil.errorLogInfo("", TAG, e);
  337. }
  338. }
  339. /**
  340. * 엘리베이터 상향호출 타임아웃을 취소한다.
  341. */
  342. public void TimeOutCancel() {
  343. try {
  344. if (mElevatorTimer == null) return;
  345. mElevatorTimer.cancel();
  346. } catch (RuntimeException re) {
  347. LogUtil.errorLogInfo("", TAG, re);
  348. } catch (Exception e) {
  349. Log.e(TAG, "[Exception] TimeOutCancel()");
  350. //e.printStackTrace();
  351. LogUtil.errorLogInfo("", TAG, e);
  352. }
  353. }
  354. /**
  355. * 엘리베이터 상향호출 타임아웃을 시작한다.
  356. */
  357. private void TimeOutStart() {
  358. try {
  359. if (mElevatorTimer == null) return;
  360. mElevatorTimer.cancel();
  361. mElevatorTimer.start();
  362. } catch (RuntimeException re) {
  363. LogUtil.errorLogInfo("", TAG, re);
  364. } catch (Exception e) {
  365. Log.e(TAG, "[Exception] TimeOutStart()");
  366. //e.printStackTrace();
  367. LogUtil.errorLogInfo("", TAG, e);
  368. }
  369. }
  370. /**
  371. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  372. *
  373. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  374. */
  375. private void SendNotifyKindBR(int kind) {
  376. try {
  377. Intent notiIntent = new Intent();
  378. notiIntent.setAction(define.NOTIFY_ACNAME);
  379. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  380. getApplicationContext().sendBroadcast(notiIntent);
  381. } catch (RuntimeException re) {
  382. LogUtil.errorLogInfo("", TAG, re);
  383. } catch (Exception e) {
  384. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  385. //e.printStackTrace();
  386. LogUtil.errorLogInfo("", TAG, e);
  387. }
  388. }
  389. }
  390. /**
  391. * 엘리베이터 상향호출 Class
  392. */
  393. private ElevatorClass ElevatorUp;
  394. /**
  395. * 엘리베이터 하향호출 Class
  396. */
  397. private ElevatorClass ElevatorDown;
  398. /**
  399. * 엘리베이터 호출한다.
  400. *
  401. * @param Up (boolean) true : 상향, false : 하향
  402. */
  403. private void CallElevatorBtn(boolean Up) {
  404. try {
  405. Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
  406. if (Up) {
  407. // 상향호출
  408. if (ElevatorUp == null) {
  409. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  410. return;
  411. }
  412. ElevatorUp.CallElevator();
  413. } else {
  414. // 하향호출
  415. if (ElevatorDown == null) {
  416. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  417. return;
  418. }
  419. ElevatorDown.CallElevator();
  420. }
  421. } catch (RuntimeException re) {
  422. LogUtil.errorLogInfo("", TAG, re);
  423. } catch (Exception e) {
  424. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  425. //e.printStackTrace();
  426. LogUtil.errorLogInfo("", TAG, e);
  427. }
  428. }
  429. ////////////////////////////////////////////////////////////////////////////////
  430. ////////////////////////////////////////////////////////////////////////////////
  431. @Override
  432. public void onCreate() {
  433. try {
  434. super.onCreate();
  435. Log.i(TAG, "[onCreate] ========== START ==========");
  436. setGlobalScreenAppRunningStatus(false);
  437. ModelType = Version.getModelType();
  438. mSound = new WpadSound(getApplicationContext());
  439. ElevatorUp = new ElevatorClass(true);
  440. ElevatorDown = new ElevatorClass(false);
  441. } catch (RuntimeException re) {
  442. Log.e(TAG, "[Exception] onCreate()");
  443. //e.printStackTrace();
  444. LogUtil.errorLogInfo("", TAG, re);
  445. } catch (Exception e) {
  446. Log.e(TAG, "[Exception] onCreate()");
  447. //e.printStackTrace();
  448. LogUtil.errorLogInfo("", TAG, e);
  449. }
  450. }
  451. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  452. try {
  453. Intent notiIntent = new Intent();
  454. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  455. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  456. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  457. getApplicationContext().sendBroadcast(notiIntent);
  458. } catch (RuntimeException re) {
  459. LogUtil.errorLogInfo("", TAG, re);
  460. } catch (Exception e) {
  461. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  462. //e.printStackTrace();
  463. LogUtil.errorLogInfo("", TAG, e);
  464. }
  465. }
  466. protected String GetForegroundAPP() {
  467. try {
  468. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  469. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  470. ComponentName topActivity = taskInfo.get(0).topActivity;
  471. String str = topActivity.getPackageName();
  472. return str;
  473. } catch (RuntimeException re) {
  474. LogUtil.errorLogInfo("", TAG, re);
  475. return " ";
  476. } catch (Exception e) {
  477. Log.e(TAG, "[Exception] GetForegroundAPP()");
  478. //e.printStackTrace();
  479. LogUtil.errorLogInfo("", TAG, e);
  480. return " ";
  481. }
  482. }
  483. long lSavedTimestamp = 0;
  484. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  485. public void onReceive(Context context, Intent intent) {
  486. try {
  487. String strActionName = intent.getAction();
  488. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
  489. if (strActionName.equals(define.NOTIFY_DAIL)) {
  490. long lTimestamp = System.currentTimeMillis();
  491. long lInterval = lTimestamp - lSavedTimestamp;
  492. if (lInterval < 1000) return;
  493. else
  494. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
  495. lSavedTimestamp = lTimestamp;
  496. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  497. if (mSdb_LivingRoomLightAPI == null) {
  498. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  499. return;
  500. }
  501. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  502. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  503. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  504. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  505. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  506. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  507. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  508. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  509. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  510. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  511. mSdb_LivingRoomLightAPI.SetControlMode(false);
  512. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  513. }
  514. return;
  515. }
  516. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  517. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  518. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  519. return;
  520. }
  521. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  522. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  523. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  524. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  525. } else {
  526. setGlobalScreenAppRunningStatus(false);
  527. }
  528. } else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  529. if (mKnx_LivingRoomLightAPI == null) {
  530. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  531. return;
  532. }
  533. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  534. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  535. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  536. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  537. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  538. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  539. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  540. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  541. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  542. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  543. mKnx_LivingRoomLightAPI.SetControlMode(false);
  544. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  545. }
  546. return;
  547. }
  548. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  549. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  550. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  551. return;
  552. }
  553. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  554. 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 + "]");
  555. }
  556. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  557. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  558. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  559. } else {
  560. setGlobalScreenAppRunningStatus(false);
  561. }
  562. } else {
  563. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  564. }
  565. } else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  566. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  567. } else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
  568. int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
  569. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
  570. switch (kind) {
  571. case define.NOTIFY_SCREEN_TOUCHED:
  572. setTimeStamp_ScreenTouched();
  573. break;
  574. case define.NOTIFY_DOOR_OPENED:
  575. setTimeStamp_Magnetic();
  576. break;
  577. }
  578. } else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  579. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
  580. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  581. switch (kind) {
  582. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  583. procUploadMissedVisitorPic(intent);
  584. break;
  585. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  586. // bBlockCallEvent = true;
  587. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  588. break;
  589. case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
  590. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
  591. Sound().Play(SND.mode.OUTMODE_SETTING);
  592. break;
  593. case Common.BR_MAIN_NOTI.SOUND_INMODE:
  594. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
  595. Sound().Play(SND.mode.INMODE_SETTING);
  596. break;
  597. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  598. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  599. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  600. break;
  601. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
  602. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  603. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  604. break;
  605. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
  606. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  607. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  608. break;
  609. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  610. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  611. CallElevatorBtn(false);
  612. break;
  613. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  614. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  615. CallElevatorBtn(true);
  616. break;
  617. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
  618. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  619. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  620. int CalledWallPadUI = intent.getIntExtra("Called", 0);
  621. if (CalledWallPadUI == 1) {
  622. ModeRunCtrlWorking(true, false);
  623. } else {
  624. ModeRunCtrlWorking(false, false);
  625. }
  626. break;
  627. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
  628. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  629. ModeReleaseCtrlWorking(false);
  630. break;
  631. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
  632. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  633. CheckMainStatus();
  634. break;
  635. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
  636. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  637. ModeRunCtrlWorking(false, false);
  638. break;
  639. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
  640. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  641. ModeReleaseCtrlWorking(false);
  642. break;
  643. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
  644. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  645. if (ElevatorUp != null && ElevatorDown != null) {
  646. boolean UpCalling = ElevatorUp.getElevatorCalling();
  647. boolean DownCalling = ElevatorDown.getElevatorCalling();
  648. Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
  649. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  650. if (UpCalling && DownCalling)
  651. Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  652. else if (UpCalling && !DownCalling)
  653. Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  654. else if (!UpCalling && DownCalling)
  655. Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  656. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  657. Log.d(TAG, " ElvCallState : " + ElvCallState);
  658. SendBRElevatorCallState(ElvCallState);
  659. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  660. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  661. // sendIntent.putExtra("ELV", ElvCallState);
  662. // getApplicationContext().sendBroadcast(sendIntent);
  663. }
  664. break;
  665. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  666. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  667. try {
  668. if (ScheServer != null) {
  669. ScheServer.SetLive();
  670. }
  671. } catch (RuntimeException re) {
  672. LogUtil.errorLogInfo("", TAG, re);
  673. } catch (Exception e) {
  674. //e.printStackTrace();
  675. LogUtil.errorLogInfo("", TAG, e);
  676. }
  677. break;
  678. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  679. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  680. stopIGW300RingGenerator();
  681. break;
  682. }
  683. } else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  684. int kind = intent.getIntExtra("KIND", 0);
  685. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  686. switch (kind) {
  687. case define.NOTIFY_SERVER_VERSION:
  688. try {
  689. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  690. iMapSverReload tSock = new iMapSverReload();
  691. tSock.start();
  692. } catch (IOException e) {
  693. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  694. //e.printStackTrace();
  695. LogUtil.errorLogInfo("", TAG, e);
  696. }
  697. break;
  698. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  699. // 제어기기 엘리베이터 상향 호출 요청
  700. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  701. CallElevatorBtn(true);
  702. break;
  703. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  704. // 제어기기에서 엘리베이터 하향 호출 요청
  705. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  706. CallElevatorBtn(false);
  707. break;
  708. case define.NOTIFY_SUBDEVCALLBUSY:
  709. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  710. CallConnected = true;
  711. break;
  712. case define.NOTIFY_SUBDEVCALLEND:
  713. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  714. CallConnected = false;
  715. break;
  716. case define.NOTIFY_STARTHEARTBEAT:
  717. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  718. {
  719. Message msg = ScheDulerHandler.obtainMessage();
  720. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  721. ScheDulerHandler.sendMessage(msg);
  722. }
  723. break;
  724. case define.NOTIFY_STARTSTATUSBEAT:
  725. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  726. {
  727. Message msg = ScheDulerHandler.obtainMessage();
  728. msg.what = SCHEDULE_START_STATUSBEAT;
  729. ScheDulerHandler.sendMessage(msg);
  730. }
  731. break;
  732. case define.NOTIFY_OUTGOINGSETTED:
  733. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  734. OutGoingSensorWaiting = 0;
  735. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  736. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  737. sdata.closeDB();
  738. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  739. return;
  740. WallPadInterface wpifc = new WallPadInterface();
  741. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
  742. OutGoingSensorWaiting |= SENSOR_MAG;
  743. int[] SensorInfoDB;
  744. int sensorIn = 0;
  745. int sensorOut = 0;
  746. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  747. if (SensorInfoDB[0] == 1) {
  748. // 내부동체가 사용함이면 상태 검사
  749. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
  750. OutGoingSensorWaiting |= SENSOR_IN;
  751. }
  752. if (SensorInfoDB[1] == 1) {
  753. // 외부동체가 사용함이면 상태 검사
  754. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
  755. OutGoingSensorWaiting |= SENSOR_OUT;
  756. }
  757. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  758. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  759. if (OutGoingSensorWaiting > 0) {
  760. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  761. SensorThread.start();
  762. }
  763. break;
  764. case define.NOTIFY_DOOR_SET_DELAY:
  765. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  766. DoorDelayTime = System.currentTimeMillis();
  767. imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
  768. break;
  769. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  770. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  771. Common.setDeviceServeiceLoadComplite();
  772. startRealtimemeterInfo(); // 실시간 검침기 확인
  773. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  774. startDistributionPanel(); // 분전반 확인
  775. getRoomName();
  776. break;
  777. case define.NOTIFY_DLOCK_SET_OUTING:
  778. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  779. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  780. try {
  781. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  782. int AlarmStatus = DBMGR.GetAlarmStatus();
  783. DBMGR.closeDB();
  784. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  785. // 센서 체크하고
  786. // 현관폰으로 사운드 출력하고
  787. boolean bSensorOk = false;
  788. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  789. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  790. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  791. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  792. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  793. bSensorOk = mIGW300.checkSensorforOutmode();
  794. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  795. bSensorOk = mIGW200.checkSensorforOutmode();
  796. } else {
  797. bSensorOk = checkSensorforOutmode();
  798. }
  799. if (bSensorOk) {
  800. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  801. CallOutModeRunActivity();
  802. } else {
  803. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  804. }
  805. }
  806. } catch (RuntimeException re) {
  807. LogUtil.errorLogInfo("", TAG, re);
  808. } catch (Exception e) {
  809. //e.printStackTrace();
  810. LogUtil.errorLogInfo("", TAG, e);
  811. }
  812. break;
  813. case define.NOTIFY_DLOCK_FREE_OUTING:
  814. // 도어락 외출모드 해제
  815. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  816. try {
  817. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  818. int AlarmStatus = DBMGR.GetAlarmStatus();
  819. DBMGR.closeDB();
  820. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  821. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  822. Common.SendAppFinishReqBR(getApplicationContext());
  823. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  824. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  825. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  826. devDB.closeDB();
  827. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  828. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  829. }
  830. }
  831. } catch (RuntimeException re) {
  832. LogUtil.errorLogInfo("", TAG, re);
  833. } catch (Exception e) {
  834. //e.printStackTrace();
  835. LogUtil.errorLogInfo("", TAG, e);
  836. }
  837. break;
  838. case define.NOTIFY_SMARTSW_SET_OUTING:
  839. // 485 대외향 스마트스위치 외출모드
  840. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  841. setUnoccupiedModeByNotHDCSmartSwitch();
  842. break;
  843. case define.NOTIFY_SMARTSW_FREE_OUTING:
  844. //대외향 485 스마트스위치 외출모드 해제
  845. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  846. releaseUnoccupiedModeByNotHDCSmartSwitch();
  847. break;
  848. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  849. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  850. String Type = intent.getStringExtra("TYPE");
  851. String Device = intent.getStringExtra("DEVICE");
  852. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  853. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  854. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  855. iMAPSmartLightEvent imapSmartLightEvent;
  856. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  857. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  858. imapSmartLightEvent.SetRetCtr(new RetProci() {
  859. @Override
  860. public void ProcSuccess() {
  861. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  862. }
  863. @Override
  864. public void ProcError() {
  865. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  866. }
  867. @Override
  868. public void ProcDoing() {
  869. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  870. }
  871. });
  872. break;
  873. case define.NOTIFY_KNX_DEVICE_EVENT:
  874. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  875. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  876. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  877. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  878. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  879. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  880. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  881. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  882. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  883. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  884. @Override
  885. public void ProcSuccess() {
  886. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  887. }
  888. @Override
  889. public void ProcError() {
  890. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  891. }
  892. @Override
  893. public void ProcDoing() {
  894. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  895. }
  896. });
  897. break;
  898. case define.NOTIFY_SMART_DCAM_DETECT:
  899. // 스마트현관카메라 거동수상자 발생
  900. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  901. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  902. if (!bWallPadCallLive && !bBlockFrontCall) {
  903. if (getStrangerRecordingManagerSetting()) {
  904. if (getStrangerRecordingUserSetting()) {
  905. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  906. Intent Newintent = new Intent();
  907. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  908. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  909. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  910. getApplicationContext().sendBroadcast(Newintent);
  911. } else {
  912. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  913. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  914. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  915. }
  916. } else {
  917. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  918. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  919. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  920. }
  921. } else {
  922. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  923. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  924. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  925. }
  926. break;
  927. case define.NOTIFY_SMART_DCAM_RELEASE:
  928. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  929. break;
  930. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  931. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  932. if (getStrangerRecordingManagerSetting()) {
  933. if (getStrangerRecordingUserSetting()) {
  934. // 알람 상태 확인
  935. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  936. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  937. mWallpadStatusData.closeDB();
  938. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  939. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  940. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  941. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  942. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  943. } else {
  944. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  945. Intent Newintent = new Intent();
  946. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  947. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  948. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  949. getApplicationContext().sendBroadcast(Newintent);
  950. }
  951. } else {
  952. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  953. }
  954. } else {
  955. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  956. }
  957. break;
  958. case define.NOTIFY_REJECT_RECORD_STRANGER:
  959. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  960. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  961. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  962. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  963. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  964. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  965. }
  966. break;
  967. case define.NOTIFY_ROOMNAME_CHANGED:
  968. getRoomName();
  969. break;
  970. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  971. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  972. break;
  973. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  974. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  975. break;
  976. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  977. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  978. break;
  979. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  980. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  981. break;
  982. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  983. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  984. break;
  985. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  986. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  987. break;
  988. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  989. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  990. break;
  991. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  992. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  993. break;
  994. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  995. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  996. break;
  997. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  998. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  999. break;
  1000. case define.NOTIFY_FINISH_RECORD_STRANGER:
  1001. // 녹화 종료 알림
  1002. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1003. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1004. mWallpadStatusData.closeDB();
  1005. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
  1006. if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
  1007. break;
  1008. case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
  1009. // 사용자 설정화면에서 원격제어시 조명제어 타입 변경
  1010. getDeviceCtrlOption();
  1011. break;
  1012. default:
  1013. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  1014. break;
  1015. }
  1016. }
  1017. } catch (RuntimeException re) {
  1018. LogUtil.errorLogInfo("", TAG, re);
  1019. } catch (Exception e) {
  1020. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1021. //e.printStackTrace();
  1022. LogUtil.errorLogInfo("", TAG, e);
  1023. }
  1024. }
  1025. };
  1026. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1027. try {
  1028. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1029. // 485 대외향 스마트스위치 외출모드
  1030. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1031. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1032. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1033. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1034. mWallpadStatusData.closeDB();
  1035. if (UseGuardSensorCheck == false) {
  1036. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1037. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1038. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1039. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
  1040. mWallpadStatusData.closeDB();
  1041. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1042. //메인화면 업데이트
  1043. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1044. getApplicationContext().sendBroadcast(newIntent);
  1045. ModeRunCtrlWorking(false, false);
  1046. }
  1047. } else {
  1048. // 실제 외출 방범 모드를 설정하도록 한다.
  1049. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1050. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1051. // 센서 체크하고
  1052. // 센서 체크하는 부분이 들어가야 함
  1053. Common.SendAppFinishReqBR(getApplicationContext());
  1054. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  1055. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1056. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1057. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1058. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1059. if (mIGW300.checkSensorforOutmode()) {
  1060. CallOutModeWaitingActivity(AlarmStatus);
  1061. } else {
  1062. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1063. }
  1064. } else {
  1065. if (checkSensorforOutmode()) {
  1066. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1067. CallOutModeWaitingActivity(AlarmStatus);
  1068. } else {
  1069. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1070. }
  1071. }
  1072. }
  1073. }
  1074. } catch (RuntimeException re) {
  1075. LogUtil.errorLogInfo("", TAG, re);
  1076. } catch (Exception e) {
  1077. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1078. //e.printStackTrace();
  1079. LogUtil.errorLogInfo("", TAG, e);
  1080. }
  1081. }
  1082. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1083. try {
  1084. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1085. //대외향 485 스마트스위치 외출모드 해제
  1086. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1087. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1088. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1089. mWallpadStatusData.closeDB();
  1090. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
  1091. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1092. if (OutModePwRelease) {
  1093. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1094. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1095. // 요청하여도 해제 되지 않으며
  1096. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1097. Intent notiIntent = new Intent();
  1098. notiIntent.setAction(define.NOTIFY_ACNAME);
  1099. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1100. getApplicationContext().sendBroadcast(notiIntent);
  1101. } else {
  1102. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1103. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1104. // 처리하고.
  1105. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1106. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1107. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1108. mWallpadStatusData.closeDB();
  1109. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1110. Common.SendAppFinishReqBR(getApplicationContext());
  1111. }
  1112. } else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1113. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1114. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1115. ModeReleaseCtrlWorking(false);
  1116. bSmartSwitch485ComebackMode = true;
  1117. Intent notiIntent = new Intent();
  1118. notiIntent.setAction(define.NOTIFY_ACNAME);
  1119. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1120. getApplicationContext().sendBroadcast(notiIntent);
  1121. } else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1122. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1123. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1124. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1125. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1126. mWallpadStatusData.closeDB();
  1127. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1128. //메인화면 업데이트
  1129. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1130. getApplicationContext().sendBroadcast(newIntent);
  1131. ModeReleaseCtrlWorking(false);
  1132. }
  1133. } catch (RuntimeException re) {
  1134. LogUtil.errorLogInfo("", TAG, re);
  1135. } catch (Exception e) {
  1136. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1137. //e.printStackTrace();
  1138. LogUtil.errorLogInfo("", TAG, e);
  1139. }
  1140. }
  1141. /**
  1142. * 스마트현관카메라 녹화 여부 판별
  1143. * 사용자 화면에서 설정
  1144. */
  1145. private boolean getStrangerRecordingUserSetting() {
  1146. boolean bResult = false;
  1147. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1148. try {
  1149. bResult = DBMGR.GetStrangerRecordingOnOff();
  1150. DBMGR.closeDB();
  1151. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1152. } catch (RuntimeException re) {
  1153. LogUtil.errorLogInfo("", TAG, re);
  1154. DBMGR.closeDB();
  1155. bResult = false;
  1156. } catch (Exception e) {
  1157. DBMGR.closeDB();
  1158. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1159. //e.printStackTrace();
  1160. LogUtil.errorLogInfo("", TAG, e);
  1161. bResult = false;
  1162. }
  1163. return bResult;
  1164. }
  1165. private boolean getStrangerTakePic() {
  1166. try {
  1167. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1168. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1169. DBMGR.closeDB();
  1170. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1171. return bResult;
  1172. } catch (RuntimeException re) {
  1173. LogUtil.errorLogInfo("", TAG, re);
  1174. return false;
  1175. } catch (Exception e) {
  1176. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1177. //e.printStackTrace();
  1178. LogUtil.errorLogInfo("", TAG, e);
  1179. return false;
  1180. }
  1181. }
  1182. // 관리자 설정 항목에 있음
  1183. private boolean getStrangerRecordUsage() {
  1184. try {
  1185. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1186. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1187. mWallpadDeviceSet.closeDB();
  1188. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1189. return bResult;
  1190. } catch (RuntimeException re) {
  1191. LogUtil.errorLogInfo("", TAG, re);
  1192. return false;
  1193. } catch (Exception e) {
  1194. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1195. //e.printStackTrace();
  1196. LogUtil.errorLogInfo("", TAG, e);
  1197. return false;
  1198. }
  1199. }
  1200. private boolean checkSensorforOutmode() {
  1201. try {
  1202. WallPadInterface wallPadInterface = new WallPadInterface();
  1203. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1204. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1205. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1206. int[] SensorInfoDB;
  1207. int sensorIn = 0;
  1208. int sensorOut = 0;
  1209. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1210. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1211. if (SensorInfoDB[0] == 1) {
  1212. // 내부동체가 사용함이면 상태 검사
  1213. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1214. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1215. }
  1216. if (SensorInfoDB[1] == 1) {
  1217. // 외부동체가 사용함이면 상태 검사
  1218. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1219. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1220. }
  1221. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1222. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1223. // 동체 사용 설정 체크..
  1224. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1225. int sensor = devSet.Get_Sensor_Set();
  1226. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1227. devSet.closeDB();
  1228. int OtherInSensor = 0;
  1229. // 내부동체 사용안함 이면
  1230. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1231. // 외부동체 사용안함 이면
  1232. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1233. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1234. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1235. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1236. return true;
  1237. } else {
  1238. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1239. return false;
  1240. }
  1241. } catch (RuntimeException re) {
  1242. LogUtil.errorLogInfo("", TAG, re);
  1243. return false;
  1244. } catch (Exception e) {
  1245. //e.printStackTrace();
  1246. LogUtil.errorLogInfo("", TAG, e);
  1247. return false;
  1248. }
  1249. }
  1250. private boolean checkSensorforInmode() {
  1251. try {
  1252. WallPadInterface wallPadInterface = new WallPadInterface();
  1253. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1254. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1255. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1256. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1257. if (sensorMag == 0) {
  1258. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1259. return true;
  1260. } else {
  1261. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1262. return false;
  1263. }
  1264. } catch (RuntimeException re) {
  1265. LogUtil.errorLogInfo("", TAG, re);
  1266. return false;
  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. WallPadInterface Wiface = new WallPadInterface();
  1283. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1284. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  1285. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1286. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1287. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1288. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1289. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1290. if (getUseSmartDoorCam()) {
  1291. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1292. }
  1293. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1294. /*
  1295. JEFF (2019.01.14)
  1296. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1297. 강신구입니다.
  1298. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1299. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1300. 내용 공유합니다.
  1301. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1302. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1303. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1304. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1305. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1306. 문제 없습니다.
  1307. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1308. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1309. 문의사항은 하기 연락바랍니다.
  1310. 감사합니다.
  1311. */
  1312. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1313. } else {
  1314. // 대외향 모델 처리
  1315. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
  1316. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1317. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1318. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1319. }
  1320. try {
  1321. Thread.sleep(100);
  1322. } catch (RuntimeException re) {
  1323. LogUtil.errorLogInfo("", TAG, re);
  1324. } catch (Exception e) {
  1325. LogUtil.errorLogInfo("", TAG, e);
  1326. }
  1327. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1328. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1329. try {
  1330. Thread.sleep(1500);
  1331. } catch (RuntimeException re) {
  1332. LogUtil.errorLogInfo("", TAG, re);
  1333. } catch (Exception e) {
  1334. LogUtil.errorLogInfo("", TAG, e);
  1335. }
  1336. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1337. int SLevel = Wdb.GetDoorSoundLevel();
  1338. Wdb.closeDB();
  1339. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1340. if (SLevel != -1) {
  1341. /**
  1342. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1343. * **/
  1344. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  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 {
  1357. Thread.sleep(time + 1000);
  1358. } catch (RuntimeException re) {
  1359. LogUtil.errorLogInfo("", TAG, re);
  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 {
  1366. Thread.sleep(100);
  1367. } catch (RuntimeException re) {
  1368. LogUtil.errorLogInfo("", TAG, re);
  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 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  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. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1376. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1377. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1378. if (getUseSmartDoorCam()) {
  1379. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1380. }
  1381. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1382. /*
  1383. JEFF (2019.01.14)
  1384. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1385. 강신구입니다.
  1386. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1387. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1388. 내용 공유합니다.
  1389. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1390. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1391. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1392. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1393. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1394. 문제 없습니다.
  1395. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1396. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1397. 문의사항은 하기 연락바랍니다.
  1398. 감사합니다.
  1399. */
  1400. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1401. } else {
  1402. // 대외향 모델 처리
  1403. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1404. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1405. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1406. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1407. }
  1408. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1409. } catch (RuntimeException re) {
  1410. LogUtil.errorLogInfo("", TAG, re);
  1411. } catch (Exception e) {
  1412. //e.printStackTrace();
  1413. LogUtil.errorLogInfo("", TAG, e);
  1414. }
  1415. }
  1416. public void CallOutModeRunActivity() {
  1417. int base = 8000;
  1418. int[] Menu_Id_List = {base + 11};
  1419. int Menu_StartId = base + 11;
  1420. int Menu_Option = -1;
  1421. Intent intent = new Intent(Intent.ACTION_MAIN);
  1422. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1423. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1424. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1425. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1426. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1427. startActivity(intent);
  1428. }
  1429. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1430. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1431. int base = 4000;
  1432. int[] Menu_Id_List = {base + 11, base + 21};
  1433. int Menu_StartId = base + 11;
  1434. int Menu_Option = 1000;
  1435. Intent intent = new Intent(Intent.ACTION_MAIN);
  1436. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1437. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1438. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1439. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1440. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  1441. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1442. startActivity(intent);
  1443. }
  1444. private boolean getGlobalScreenAppRunningStatus() {
  1445. boolean bRunning = false;
  1446. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1447. try {
  1448. bRunning = DBMGR.getGlobalScreenAPKRun();
  1449. DBMGR.closeDB();
  1450. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1451. return bRunning;
  1452. } catch (RuntimeException re) {
  1453. LogUtil.errorLogInfo("", TAG, re);
  1454. DBMGR.closeDB();
  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. } catch (Exception e) {
  1474. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1475. //e.printStackTrace();
  1476. LogUtil.errorLogInfo("", TAG, e);
  1477. DBMGR.closeDB();
  1478. }
  1479. }
  1480. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1481. boolean bGlobalScreenRun = false;
  1482. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1483. try {
  1484. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1485. wakeupLCD();
  1486. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1487. setGlobalScreenAppRunningStatus(true);
  1488. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1489. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1490. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1491. mIntent.putExtra("ONOFF", hOnOff);
  1492. mIntent.putExtra("DIAL", hDial);
  1493. mIntent.putExtra("LEVEL", hLevel);
  1494. mIntent.putExtra("COLOR", hColor);
  1495. mIntent.putExtra("CONTROL", hControl);
  1496. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1497. mIntent.setComponent(mComponentName);
  1498. startActivity(mIntent);
  1499. } else {
  1500. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1501. }
  1502. } catch (RuntimeException re) {
  1503. LogUtil.errorLogInfo("", TAG, re);
  1504. } catch (Exception e) {
  1505. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1506. //e.printStackTrace();
  1507. LogUtil.errorLogInfo("", TAG, e);
  1508. }
  1509. }
  1510. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1511. try {
  1512. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1513. wakeupLCD();
  1514. if (!getGlobalScreenAppRunningStatus()) {
  1515. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1516. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1517. return;
  1518. }
  1519. setGlobalScreenAppRunningStatus(true);
  1520. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1521. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1522. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1523. mIntent.putExtra("SCREENID", nScreenID);
  1524. mIntent.putExtra("ONOFF", hOnOff);
  1525. mIntent.putExtra("DIAL", hDial);
  1526. mIntent.putExtra("LEVEL", hLevel);
  1527. mIntent.putExtra("COLOR", hColor);
  1528. mIntent.putExtra("CONTROL", hControl);
  1529. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1530. mIntent.setComponent(mComponentName);
  1531. startActivity(mIntent);
  1532. } else {
  1533. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1534. }
  1535. } catch (RuntimeException re) {
  1536. LogUtil.errorLogInfo("", TAG, re);
  1537. } catch (Exception e) {
  1538. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1539. //e.printStackTrace();
  1540. LogUtil.errorLogInfo("", TAG, e);
  1541. }
  1542. }
  1543. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1544. public void sendBlackoutReleasedBR() {
  1545. try {
  1546. Intent notiIntent = new Intent();
  1547. notiIntent.setAction(strBLACKOUT_RELEASED);
  1548. getApplicationContext().sendBroadcast(notiIntent);
  1549. } catch (RuntimeException re) {
  1550. LogUtil.errorLogInfo("", TAG, re);
  1551. } catch (Exception e) {
  1552. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1553. //e.printStackTrace();
  1554. LogUtil.errorLogInfo("", TAG, e);
  1555. }
  1556. }
  1557. private int getCurrentScreen() {
  1558. int nScreenID = 0;
  1559. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1560. try {
  1561. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1562. DBMGR.closeDB();
  1563. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1564. return nScreenID;
  1565. } catch (RuntimeException re) {
  1566. LogUtil.errorLogInfo("", TAG, re);
  1567. DBMGR.closeDB();
  1568. } catch (Exception e) {
  1569. Log.e(TAG, "[Exception] getCurrentScreen()");
  1570. //e.printStackTrace();
  1571. LogUtil.errorLogInfo("", TAG, e);
  1572. DBMGR.closeDB();
  1573. }
  1574. return nScreenID;
  1575. }
  1576. private void setCurrentScreen(int nScreenID) {
  1577. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1578. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1579. try {
  1580. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1581. DBMGR.closeDB();
  1582. } catch (RuntimeException re) {
  1583. LogUtil.errorLogInfo("", TAG, re);
  1584. DBMGR.closeDB();
  1585. } catch (Exception e) {
  1586. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1587. //e.printStackTrace();
  1588. LogUtil.errorLogInfo("", TAG, e);
  1589. DBMGR.closeDB();
  1590. }
  1591. }
  1592. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1593. private void procUploadMissedVisitorPic(Intent intent) {
  1594. try {
  1595. String strDong = intent.getStringExtra("DONG");
  1596. String strHo = intent.getStringExtra("HO");
  1597. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1598. int nCnt = intent.getIntExtra("CNT", 0);
  1599. String[] strMissedPicURI = new String[nCnt];
  1600. strArrayMissedPicURI.clear();
  1601. for (int i = 0; i < nCnt; i++) {
  1602. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1603. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1604. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1605. }
  1606. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1607. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1608. }
  1609. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1610. } catch (RuntimeException re) {
  1611. LogUtil.errorLogInfo("", TAG, re);
  1612. } catch (Exception e) {
  1613. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1614. //e.printStackTrace();
  1615. LogUtil.errorLogInfo("", TAG, e);
  1616. }
  1617. }
  1618. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1619. try {
  1620. String strURI = "", strFileName = "", strTime = "", strType = "";
  1621. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1622. // strURI = strArrayMissedPicURI.get(i).toString();
  1623. // strFileName = extractFileName(strURI);
  1624. // strTime = extractFileTime(strURI);
  1625. // strType = extractCallType(strFileName);
  1626. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1627. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1628. // }
  1629. if (strArrayMissedPicURI.size() > 0) {
  1630. strURI = strArrayMissedPicURI.get(0).toString();
  1631. strFileName = extractFileName(strURI);
  1632. strTime = extractFileTime(strFileName);
  1633. strType = extractCallType(strFileName);
  1634. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1635. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1636. } else {
  1637. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1638. }
  1639. } catch (RuntimeException re) {
  1640. LogUtil.errorLogInfo("", TAG, re);
  1641. } catch (Exception e) {
  1642. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1643. //e.printStackTrace();
  1644. LogUtil.errorLogInfo("", TAG, e);
  1645. }
  1646. }
  1647. public class uploadVisitorPicture extends Thread {
  1648. HDCFTPManager mFTPManager;
  1649. boolean bMainServer2dot0 = false;
  1650. String strRemoteIP = "10.0.1.1";
  1651. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1652. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1653. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1654. try {
  1655. strDong = dong;
  1656. strHo = ho;
  1657. strType = type;
  1658. strTime = time;
  1659. strFileName = filename;
  1660. strUploadFile = uploadfile;
  1661. bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1662. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1663. wallpadDeviceSet.closeDB();
  1664. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
  1665. } catch (RuntimeException re) {
  1666. LogUtil.errorLogInfo("", TAG, re);
  1667. } catch (Exception e) {
  1668. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1669. //e.printStackTrace();
  1670. LogUtil.errorLogInfo("", TAG, e);
  1671. }
  1672. }
  1673. public void run() {
  1674. try {
  1675. mFTPManager = new HDCFTPManager();
  1676. if (!mFTPManager.isFTPConnected()) {
  1677. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1678. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1679. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1680. return;
  1681. }
  1682. }
  1683. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1684. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1685. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1686. return;
  1687. }
  1688. if (!bMainServer2dot0) {
  1689. if (!mFTPManager.setPassiveMode()) {
  1690. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1691. disconnectFTP();
  1692. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1693. return;
  1694. }
  1695. }
  1696. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1697. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1698. disconnectFTP();
  1699. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1700. return;
  1701. }
  1702. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1703. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1704. disconnectFTP();
  1705. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1706. return;
  1707. }
  1708. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1709. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1710. disconnectFTP();
  1711. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1712. return;
  1713. }
  1714. disconnectFTP();
  1715. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1716. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1717. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1718. } catch (RuntimeException re) {
  1719. LogUtil.errorLogInfo("", TAG, re);
  1720. } catch (Exception e) {
  1721. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1722. //e.printStackTrace();
  1723. LogUtil.errorLogInfo("", TAG, e);
  1724. }
  1725. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1726. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1727. }
  1728. public boolean disconnectFTP() {
  1729. try {
  1730. if (mFTPManager.logoutFTP()) {
  1731. if (mFTPManager.disconnectFTP()) {
  1732. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1733. return true;
  1734. }
  1735. }
  1736. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1737. return false;
  1738. } catch (RuntimeException re) {
  1739. LogUtil.errorLogInfo("", TAG, re);
  1740. return false;
  1741. } catch (Exception e) {
  1742. Log.e(TAG, "[Exception] disconnectFTP()");
  1743. //e.printStackTrace();
  1744. LogUtil.errorLogInfo("", TAG, e);
  1745. return false;
  1746. }
  1747. }
  1748. }
  1749. private String extractCallType(String strFileName) {
  1750. try {
  1751. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1752. String[] strParse_01 = strFileName.split("_");
  1753. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1754. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1755. else return "none";
  1756. } catch (RuntimeException re) {
  1757. LogUtil.errorLogInfo("", TAG, re);
  1758. return null;
  1759. } catch (Exception e) {
  1760. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1761. //e.printStackTrace();
  1762. LogUtil.errorLogInfo("", TAG, e);
  1763. return null;
  1764. }
  1765. }
  1766. private String extractFileName(String strTargetFile) {
  1767. try {
  1768. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1769. String[] strParse_01 = strTargetFile.split("/");
  1770. return strParse_01[strParse_01.length - 1];
  1771. } catch (RuntimeException re) {
  1772. LogUtil.errorLogInfo("", TAG, re);
  1773. return null;
  1774. } catch (Exception e) {
  1775. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1776. //e.printStackTrace();
  1777. LogUtil.errorLogInfo("", TAG, e);
  1778. return null;
  1779. }
  1780. }
  1781. private String extractFileTime(String strFileName) {
  1782. try {
  1783. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1784. String[] strParse_01 = strFileName.split("\\.");
  1785. String[] strParse_02 = strParse_01[0].split("_");
  1786. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1787. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1788. // 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);
  1789. return strParse_02[5] + "_" + strParse_02[6];
  1790. } catch (RuntimeException re) {
  1791. LogUtil.errorLogInfo("", TAG, re);
  1792. return null;
  1793. } catch (Exception e) {
  1794. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1795. //e.printStackTrace();
  1796. LogUtil.errorLogInfo("", TAG, e);
  1797. return null;
  1798. }
  1799. }
  1800. String strRemoteURI, strUserID, strPW, strPath;
  1801. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1802. String strKey_Pass = "passwd";
  1803. 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) {
  1804. try {
  1805. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1806. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1807. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1808. visitor_access_info.setResultCtrl(new RetProci() {
  1809. @Override
  1810. public void ProcSuccess() {
  1811. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1812. visitor_access_info.SetItem("ftp_info");
  1813. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1814. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1815. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1816. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1817. strUserID = strReply_User;
  1818. strPW = strReply_PW;
  1819. strPath = strReply_Path;
  1820. strRemoteURI = strPath + "/" + strFileName;
  1821. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1822. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1823. mUploadVisitorPicture.start();
  1824. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1825. // mUploadVisitorPicture.start();
  1826. }
  1827. @Override
  1828. public void ProcError() {
  1829. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1830. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1831. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1832. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1833. }
  1834. @Override
  1835. public void ProcDoing() {
  1836. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1837. }
  1838. });
  1839. return true;
  1840. }
  1841. } catch (RuntimeException re) {
  1842. LogUtil.errorLogInfo("", TAG, re);
  1843. } catch (Exception e) {
  1844. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1845. //e.printStackTrace();
  1846. LogUtil.errorLogInfo("", TAG, e);
  1847. }
  1848. return false;
  1849. }
  1850. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1851. try {
  1852. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1853. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1854. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1855. visitor_upload_complete.setResultCtrl(new RetProci() {
  1856. @Override
  1857. public void ProcSuccess() {
  1858. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1859. }
  1860. @Override
  1861. public void ProcError() {
  1862. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1863. }
  1864. @Override
  1865. public void ProcDoing() {
  1866. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1867. }
  1868. });
  1869. return true;
  1870. }
  1871. } catch (RuntimeException re) {
  1872. LogUtil.errorLogInfo("", TAG, re);
  1873. } catch (Exception e) {
  1874. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1875. //e.printStackTrace();
  1876. LogUtil.errorLogInfo("", TAG, e);
  1877. }
  1878. return false;
  1879. }
  1880. /**
  1881. * 이통사 연동 서비스를 위한 BR
  1882. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1883. *
  1884. * @param kind (String) "lobby" or "home"
  1885. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1886. */
  1887. public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
  1888. try {
  1889. Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
  1890. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1891. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1892. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1893. Intent mIntent = new Intent();
  1894. mIntent.setAction(BR_VISITOR_EVENT);
  1895. mIntent.putExtra("KIND", kind);
  1896. mIntent.putExtra("TIME", datetime);
  1897. mIntent.putExtra("FILENAME", filename);
  1898. getApplicationContext().sendBroadcast(mIntent);
  1899. } catch (RuntimeException re) {
  1900. LogUtil.errorLogInfo("", TAG, re);
  1901. } catch (Exception e) {
  1902. Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
  1903. //e.printStackTrace();
  1904. LogUtil.errorLogInfo("", TAG, e);
  1905. }
  1906. }
  1907. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1908. public void onReceive(Context context, Intent intent) {
  1909. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1910. Bundle bundle;
  1911. WallpadDeviceSet devset;
  1912. Intent newintent;
  1913. boolean CallAppRun = false;
  1914. boolean MgrAppRun = false;
  1915. final String packageName = "com.artncore.apps.ic_wallpad";
  1916. final String packageNameMgr = "com.artncore.managersetting";
  1917. //CallAppRun = getForegroundAPK().equals(packageName);
  1918. // CallAppRun = getCallAppRunning();
  1919. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1920. int base = 7000;
  1921. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  1922. int Menu_Start_Option = 1;
  1923. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1924. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1925. int keyevt = ReceiveEvt.getKeyCode();
  1926. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1927. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1928. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1929. sdata.closeDB();
  1930. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1931. return;
  1932. }
  1933. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1934. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1935. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1936. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1937. mWallpadStatusData.closeDB();
  1938. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1939. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1940. sdata.closeDB();
  1941. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1942. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1943. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1944. int nModelType = Version.getModelType();
  1945. switch (ReceiveEvt.getKeyCode()) {
  1946. case 251: // 현산향 비상버튼 다운 업 처리
  1947. try {
  1948. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1949. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1950. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1951. } else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1952. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1953. }
  1954. }
  1955. } catch (RuntimeException re) {
  1956. LogUtil.errorLogInfo("", TAG, re);
  1957. } catch (Exception e) {
  1958. //e.printStackTrace();
  1959. LogUtil.errorLogInfo("", TAG, e);
  1960. }
  1961. break;
  1962. case WallPadInterface.EVT_RING:
  1963. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1964. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1965. // 전화 수신 링 수신
  1966. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1967. if (Version.getGatewayUsage()) {
  1968. // 국선 시작만 올라온다.
  1969. startIGW300RingGenerator();
  1970. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1971. } else {
  1972. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1973. }
  1974. break;
  1975. case WallPadInterface.EVT_END_RING:
  1976. // 전화 수신 링 종료
  1977. // Jeff added below codes for call app (2018.01.25)
  1978. // This event is managed by WallPadCall
  1979. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  1980. if (Version.getGatewayUsage()) {
  1981. stopIGW300RingGenerator();
  1982. }
  1983. break;
  1984. case WallPadInterface.BTN_EMR:
  1985. case WallPadInterface.BTN_EMR_IHN1010:
  1986. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  1987. // 월패드 비상버튼 입력 SA 와 GLE 공통
  1988. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  1989. if (MgrAppRun) return;
  1990. if (Common.DIAGNOSTIC_MODE) return;
  1991. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1992. return;
  1993. //currentTime = System.currentTimeMillis();
  1994. //if (ALERTTIME > currentTime) break;
  1995. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  1996. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  1997. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  1998. break;
  1999. devset = new WallpadDeviceSet(getApplicationContext());
  2000. int StatusVal = devset.GetDeviceSetted("알람발생");
  2001. devset.closeDB();
  2002. Log.d("imap", "StatusVal : " + StatusVal);
  2003. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2004. // 보안 처리가 필요함..
  2005. // 지속적으로 이벤트가 들어올 경우 대비
  2006. Common.SendAppFinishReqBR(getApplicationContext());
  2007. newintent = new Intent(Intent.ACTION_MAIN);
  2008. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2009. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2010. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2011. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2012. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2013. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2014. iMAPstartActivity(newintent);
  2015. }
  2016. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2017. if (getIsSubWallpad()) {
  2018. Intent notiIntent = new Intent();
  2019. notiIntent.setAction(define.NOTIFY_ACNAME);
  2020. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2021. getApplicationContext().sendBroadcast(notiIntent);
  2022. }
  2023. break;
  2024. case WallPadInterface.BTN_CALL:
  2025. case WallPadInterface.BTN_CALL_IHN1010:
  2026. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2027. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2028. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2029. // Jeff added below codes for call app (2018.01.25)
  2030. try {
  2031. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2032. if (getIsSubWallpad()) {
  2033. // 서브월패드
  2034. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2035. } else {
  2036. // 메인월패드
  2037. if (MainActivity.bRecordStatus) {
  2038. // 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2039. Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2040. Intent iIntent = new Intent();
  2041. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2042. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
  2043. getApplicationContext().sendBroadcast(iIntent);
  2044. }
  2045. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2046. }
  2047. } catch (RuntimeException re) {
  2048. LogUtil.errorLogInfo("", TAG, re);
  2049. } catch (Exception e) {
  2050. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2051. //e.printStackTrace();
  2052. LogUtil.errorLogInfo("", TAG, e);
  2053. }
  2054. break;
  2055. case WallPadInterface.BTN_OPEN:
  2056. // 월패드 문여림 버튼 입력 상태 SA
  2057. break;
  2058. case WallPadInterface.BTN_DOOR:
  2059. case WallPadInterface.BTN_DOOR_IHN1010:
  2060. // 현관 도어폰 벨 눌림 입력 상태
  2061. // Jeff added below codes for call app (2018.01.25)
  2062. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2063. if (!bWallPadCallLive && !bBlockFrontCall) {
  2064. if (MainActivity.bRecordStatus) {
  2065. // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2066. Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2067. Intent iIntent = new Intent();
  2068. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2069. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
  2070. getApplicationContext().sendBroadcast(iIntent);
  2071. }
  2072. bBlockFrontCall = true;
  2073. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2074. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2075. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2076. try {
  2077. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2078. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2079. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2080. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  2081. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2082. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2083. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2084. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2085. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2086. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2087. }
  2088. if (!Version.getGatewayUsage()) {
  2089. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2090. }
  2091. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2092. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2093. } catch (RuntimeException re) {
  2094. LogUtil.errorLogInfo("", TAG, re);
  2095. } catch (Exception e) {
  2096. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2097. //e.printStackTrace();
  2098. LogUtil.errorLogInfo("", TAG, e);
  2099. }
  2100. } else {
  2101. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2102. }
  2103. break;
  2104. case WallPadInterface.BTN_CAMERA_SET:
  2105. Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
  2106. Intent iIntent = new Intent();
  2107. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2108. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
  2109. getApplicationContext().sendBroadcast(iIntent);
  2110. break;
  2111. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2112. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
  2113. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2114. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
  2115. && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
  2116. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2117. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2118. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2119. if (MgrAppRun) return;
  2120. if (Common.DIAGNOSTIC_MODE) return;
  2121. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  2122. return;
  2123. //currentTime = System.currentTimeMillis();
  2124. //if (ALERTTIME > currentTime) break;
  2125. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2126. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2127. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2128. break;
  2129. devset = new WallpadDeviceSet(getApplicationContext());
  2130. StatusVal = devset.GetDeviceSetted("알람발생");
  2131. devset.closeDB();
  2132. Log.d("imap", "StatusVal : " + StatusVal);
  2133. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2134. // 보안 처리가 필요함..
  2135. // 지속적으로 이벤트가 들어올 경우 대비
  2136. Common.SendAppFinishReqBR(getApplicationContext());
  2137. newintent = new Intent(Intent.ACTION_MAIN);
  2138. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2139. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2140. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2141. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2142. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2143. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2144. iMAPstartActivity(newintent);
  2145. }
  2146. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2147. if (getIsSubWallpad()) {
  2148. Intent notiIntent = new Intent();
  2149. notiIntent.setAction(define.NOTIFY_ACNAME);
  2150. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2151. getApplicationContext().sendBroadcast(notiIntent);
  2152. }
  2153. } else {
  2154. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2155. if (!getEmergencyIOUsage()) {
  2156. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2157. return;
  2158. }
  2159. if (MgrAppRun) {
  2160. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2161. return;
  2162. }
  2163. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2164. break;
  2165. devset = new WallpadDeviceSet(getApplicationContext());
  2166. StatusVal = devset.GetDeviceSetted("알람발생");
  2167. devset.closeDB();
  2168. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2169. Common.SendAppFinishReqBR(getApplicationContext());
  2170. newintent = new Intent(Intent.ACTION_MAIN);
  2171. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2172. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2173. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2174. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2175. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2176. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2177. iMAPstartActivity(newintent);
  2178. }
  2179. }
  2180. break;
  2181. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2182. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2183. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2184. // 대외향의 경우 여기에서 마그네틱이 감지된다.
  2185. if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
  2186. if (MgrAppRun) return;
  2187. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2188. WallPadInterface mWallPadInterface = new WallPadInterface();
  2189. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2190. if (sensorMag == 0) return;
  2191. }
  2192. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2193. break;
  2194. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2195. break;
  2196. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2197. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2198. if (OutGoingSensorWaiting == 0) {
  2199. // wakeupLCD();
  2200. mIOInterface.ctrlLcdWakeUp();
  2201. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2202. SensorThread.start();
  2203. }
  2204. OutGoingSensorWaiting |= SENSOR_MAG;
  2205. } else {
  2206. Common.SendAppFinishReqBR(getApplicationContext());
  2207. newintent = new Intent(Intent.ACTION_MAIN);
  2208. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2209. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2210. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2211. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2212. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2213. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2214. iMAPstartActivity(newintent);
  2215. }
  2216. break;
  2217. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2218. saveBlackoutStatus(true);
  2219. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2220. break;
  2221. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2222. saveBlackoutStatus(false);
  2223. sendBlackoutReleasedBR();
  2224. break;
  2225. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2226. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2227. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2228. if (MgrAppRun) return;
  2229. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2230. break;
  2231. devset = new WallpadDeviceSet(getApplicationContext());
  2232. StatusVal = devset.GetDeviceSetted("피난사다리");
  2233. int LadderSend = devset.getEscapeLadderDownSend();
  2234. String pentHouseHo = devset.getPentHouseHoEscapeLadder();
  2235. devset.closeDB();
  2236. Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
  2237. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2238. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2239. Common.SendAppFinishReqBR(getApplicationContext());
  2240. newintent = new Intent(Intent.ACTION_MAIN);
  2241. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2242. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2243. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2244. if (!pentHouseHo.equals("")) {
  2245. // 윗집이 펜트하우스인 경우
  2246. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2247. } else {
  2248. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  2249. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2250. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  2251. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2252. }
  2253. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2254. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2255. iMAPstartActivity(newintent);
  2256. }
  2257. break;
  2258. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2259. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2260. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2261. {
  2262. // 내부동체가 상태가 변경된 경우
  2263. int[] SensorInfoDB;
  2264. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2265. if (SensorInfoDB[0] != 1) {
  2266. //내부동체가 사용함이면 상태 검사
  2267. return;
  2268. }
  2269. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2270. WallPadInterface mWallPadInterface = new WallPadInterface();
  2271. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2272. if (sensorMag == 0) return;
  2273. }
  2274. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2275. int sensor = devSet.Get_Sensor_Set();
  2276. devSet.closeDB();
  2277. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2278. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2279. break;
  2280. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2281. if (OutGoingSensorWaiting == 0) {
  2282. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2283. SensorThread.start();
  2284. }
  2285. OutGoingSensorWaiting |= SENSOR_IN;
  2286. }
  2287. break;
  2288. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2289. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2290. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2291. {
  2292. // 외부동체가 상태가 변경된 경우
  2293. int[] SensorInfoDB;
  2294. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2295. if (SensorInfoDB[1] != 1) {
  2296. // 외부동체가 사용함이면 상태 검사
  2297. return;
  2298. }
  2299. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2300. WallPadInterface mWallPadInterface = new WallPadInterface();
  2301. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2302. if (sensorMag == 0) return;
  2303. }
  2304. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2305. int sensor = devSet.Get_Sensor_Set();
  2306. devSet.closeDB();
  2307. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2308. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2309. break;
  2310. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2311. break;
  2312. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2313. break;
  2314. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2315. {
  2316. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2317. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2318. break;
  2319. }*/
  2320. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2321. if (OutGoingSensorWaiting == 0) {
  2322. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2323. SensorThread.start();
  2324. }
  2325. OutGoingSensorWaiting |= SENSOR_OUT;
  2326. } else {
  2327. Common.SendAppFinishReqBR(getApplicationContext());
  2328. newintent = new Intent(Intent.ACTION_MAIN);
  2329. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2330. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2331. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2332. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2333. newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2334. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2335. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2336. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2337. iMAPstartActivity(newintent);
  2338. }
  2339. }
  2340. break;
  2341. }
  2342. } else {
  2343. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2344. }
  2345. }
  2346. };
  2347. protected void iMAPstartActivity(Intent intent) {
  2348. try {
  2349. startActivity(intent);
  2350. } catch (RuntimeException re) {
  2351. LogUtil.errorLogInfo("", TAG, re);
  2352. } catch (Exception e) {
  2353. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2354. //e.printStackTrace();
  2355. LogUtil.errorLogInfo("", TAG, e);
  2356. }
  2357. }
  2358. /**
  2359. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2360. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2361. * 1. 현관카메라 키이벤트 수신
  2362. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2363. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2364. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2365. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2366. * 6. 시스템 볼륨 원복
  2367. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2368. */
  2369. AudioManager mAudioManager;
  2370. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2371. Handler mDingDongHandler = new Handler() {
  2372. public void handleMessage(Message msg) {
  2373. try {
  2374. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2375. if (msg.what == 0) {
  2376. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2377. int nVolume = 10;
  2378. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
  2379. nVolume = 12;
  2380. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2381. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2382. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2383. mDingDongHandler.sendEmptyMessage(1);
  2384. } else if (msg.what == 1) {
  2385. // 띵똥 패스 체크
  2386. check1++;
  2387. if (check1 > 200) {
  2388. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2389. finishDingDongHandler();
  2390. check1 = 0;
  2391. return;
  2392. } else {
  2393. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2394. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2395. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2396. }
  2397. } else if (msg.what == 2) {
  2398. // 띵똥 음원 재생
  2399. mIOInterface.ctrlSetTalkPathDoor();
  2400. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2401. } else if (msg.what == 3) {
  2402. mIOInterface.ctrlSetTalkPathNormal();
  2403. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2404. mDingDongHandler.sendEmptyMessage(4);
  2405. } else if (msg.what == 4) {
  2406. // Normal 패스 체크
  2407. check2++;
  2408. if (check2 > 200) {
  2409. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2410. finishDingDongHandler();
  2411. check2 = 0;
  2412. return;
  2413. } else {
  2414. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2415. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2416. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2417. }
  2418. } else if (msg.what == 5) {
  2419. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2420. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2421. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2422. wdb.closeDB();
  2423. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2424. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2425. intent.setAction(define.NOTIFY_ACNAME);
  2426. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2427. sendBroadcast(intent);
  2428. }
  2429. } catch (RuntimeException re) {
  2430. LogUtil.errorLogInfo("", TAG, re);
  2431. finishDingDongHandler();
  2432. } catch (Exception e) {
  2433. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2434. //e.printStackTrace();
  2435. LogUtil.errorLogInfo("", TAG, e);
  2436. finishDingDongHandler();
  2437. }
  2438. }
  2439. };
  2440. private void finishDingDongHandler() {
  2441. try {
  2442. Log.d(TAG, "[finishDingDongHandler]");
  2443. if (mDingDongHandler != null) {
  2444. mDingDongHandler.removeMessages(0);
  2445. mDingDongHandler.removeMessages(1);
  2446. mDingDongHandler.removeMessages(2);
  2447. mDingDongHandler.removeMessages(3);
  2448. mDingDongHandler.removeMessages(4);
  2449. mDingDongHandler.removeMessages(5);
  2450. }
  2451. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2452. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2453. wdb.closeDB();
  2454. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2455. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2456. mIOInterface.ctrlSetTalkPathNormal();
  2457. } catch (RuntimeException re) {
  2458. LogUtil.errorLogInfo("", TAG, re);
  2459. } catch (Exception e) {
  2460. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2461. //e.printStackTrace();
  2462. LogUtil.errorLogInfo("", TAG, e);
  2463. }
  2464. }
  2465. // 외출방범 대기 모드 중 사운드와 센서 체크
  2466. class OutgoingCheckSensor extends Thread {
  2467. public OutgoingCheckSensor() {
  2468. }
  2469. public void run() {
  2470. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2471. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2472. WallPadInterface wpifc = new WallPadInterface();
  2473. mWallpadStatusData.closeDB();
  2474. int checkcount = timedata / 5;
  2475. int i;
  2476. for (i = checkcount; i > 0; i--) {
  2477. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2478. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2479. mWallpadStatusData.closeDB();
  2480. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2481. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2482. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2483. try {
  2484. Thread.sleep(5000);
  2485. } catch (RuntimeException re) {
  2486. LogUtil.errorLogInfo("", TAG, re);
  2487. } catch (Exception e) {
  2488. LogUtil.errorLogInfo("", TAG, e);
  2489. }
  2490. }
  2491. if (i == 0) {
  2492. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2493. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2494. mWallpadStatusData.closeDB();
  2495. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2496. Common.SendAppFinishReqBR(getApplicationContext());
  2497. int base = 7000;
  2498. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  2499. int Menu_Start_Option = 1;
  2500. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2501. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2502. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2503. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2504. String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
  2505. if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
  2506. else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
  2507. else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
  2508. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2509. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2510. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2511. iMAPstartActivity(mIntent);
  2512. }
  2513. }
  2514. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2515. OutGoingSensorWaiting = 0;
  2516. }
  2517. }
  2518. @Override
  2519. public IBinder onBind(Intent arg0) {
  2520. return mMessenger.getBinder();
  2521. //return null;
  2522. }
  2523. public void imapsvrlog(String msg) {
  2524. if (!log_sw) return;
  2525. Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
  2526. }
  2527. public int onStartCommand(Intent intent, int flags, int startID) {
  2528. try {
  2529. try {
  2530. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2531. } catch (RuntimeException re) {
  2532. LogUtil.errorLogInfo("", TAG, re);
  2533. } catch (Exception e) {
  2534. //e.printStackTrace();
  2535. LogUtil.errorLogInfo("", TAG, e);
  2536. }
  2537. getDeviceCtrlOption();
  2538. SvrSock = new iMapSverSocket();
  2539. SvrSock.start();
  2540. } catch (IOException e) {
  2541. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2542. //e.printStackTrace();
  2543. LogUtil.errorLogInfo("", TAG, e);
  2544. }
  2545. try {
  2546. mGleInterface = new jni();
  2547. } catch (RuntimeException re) {
  2548. LogUtil.errorLogInfo("", TAG, re);
  2549. } catch (Exception e) {
  2550. Log.e(TAG, "[Exception] mGleInterface init...");
  2551. //e.printStackTrace();
  2552. LogUtil.errorLogInfo("", TAG, e);
  2553. }
  2554. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2555. AddressSet addr = DBMGR.getAddressMGR();
  2556. DBMGR.closeDB();
  2557. String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
  2558. AddrDong = addr.Dong;
  2559. AddrHo = addr.Ho;
  2560. ho = Integer.valueOf(AddrHo.substring(0, 1));
  2561. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  2562. "<imap ver=\"1.0\" address=\"" + addr.IPAddress + "\" sender=\"" + AddressStr + "\">\r\n";
  2563. Log.d(TAG, "*****************************************");
  2564. Log.d(TAG, "****************SchedulerThread**********");
  2565. Log.d(TAG, "*****************************************");
  2566. ScheServer = new SchedulerThread();
  2567. ScheServer.start();
  2568. // BR 등록 시작
  2569. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2570. IntentFilter mIntentFilter = new IntentFilter();
  2571. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2572. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2573. mIntentFilter = new IntentFilter();
  2574. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2575. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2576. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2577. mIntentFilter = new IntentFilter();
  2578. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2579. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2580. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2581. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2582. mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
  2583. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2584. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2585. // BR 등록 완료
  2586. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2587. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
  2588. IGW200APICheckHandler.sendEmptyMessage(0);
  2589. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  2590. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2591. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2592. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2593. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2594. IGW300APICheckHandler.sendEmptyMessage(0);
  2595. }
  2596. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2597. mIOInterface.setEmergencyType();
  2598. Intent notiIntent = new Intent();
  2599. notiIntent.setAction(define.NOTIFY_ACNAME);
  2600. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2601. getApplicationContext().sendBroadcast(notiIntent);
  2602. CheckMainStatus();
  2603. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2604. getAirQualityUsage();
  2605. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2606. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2607. GwCheckThread.start();
  2608. }
  2609. getResidentSafetyCheckSetting();
  2610. return START_STICKY;
  2611. }
  2612. //멀티기기 정보 전송을 위한 추가
  2613. public static final int MSG_REGISTER_CLIENT = 1;
  2614. //public static final int MSG_UNREGISTER_CLIENT = 2;
  2615. public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
  2616. public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
  2617. public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
  2618. public static final int MSG_SEND_TO_ACTIVITY = 4;
  2619. private Messenger mClient = null; // Activity 에서 가져온 Messenger
  2620. String remote_get_home_devices1;
  2621. String remote_get_home_devices2;
  2622. String remote_get_home_devices3;
  2623. int skipCount = 0;
  2624. /**
  2625. * activity로부터 binding 된 Messenger
  2626. */
  2627. private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
  2628. @Override
  2629. public boolean handleMessage(Message msg) {
  2630. switch (msg.what) {
  2631. case MSG_REGISTER_CLIENT:
  2632. mClient = msg.replyTo; // activity로부터 가져온
  2633. break;
  2634. case MSG_SEND_TO_SERVICE_DEVICES1:
  2635. remote_get_home_devices1 = (String) msg.obj; // activity로부터 가져온
  2636. break;
  2637. case MSG_SEND_TO_SERVICE_DEVICES2:
  2638. remote_get_home_devices2 = (String) msg.obj; // activity로부터 가져온
  2639. break;
  2640. case MSG_SEND_TO_SERVICE_DEVICES3:
  2641. remote_get_home_devices3 = (String) msg.obj; // activity로부터 가져온
  2642. break;
  2643. default:
  2644. break;
  2645. }
  2646. return false;
  2647. }
  2648. }));
  2649. private void sendMsgToActivity(int sendValue) {
  2650. try {
  2651. Bundle bundle = new Bundle();
  2652. bundle.putInt("fromService", sendValue);
  2653. Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
  2654. msg.setData(bundle);
  2655. if(mClient!=null) {
  2656. mClient.send(msg); // msg 보내기
  2657. }
  2658. } catch (Exception e) {
  2659. }
  2660. }
  2661. // 메인 서버 소켓 클래스
  2662. public class iMapSverSocket extends Thread {
  2663. ServerSocket svr;
  2664. private SSLServerSocket sslsvr;
  2665. boolean receiveSocketRun = true;
  2666. public iMapSverSocket() throws IOException {
  2667. /////////////////////////////////////////////////////////////////////
  2668. // 신형 단지서버 사용 유무를 가져온다.
  2669. /////////////////////////////////////////////////////////////////////
  2670. try {
  2671. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2672. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2673. wallpadDeviceSet.closeDB();
  2674. } catch (RuntimeException re) {
  2675. LogUtil.errorLogInfo("", TAG, re);
  2676. mNewDanjiServer = false;
  2677. } catch (Exception e) {
  2678. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2679. //e.printStackTrace();
  2680. LogUtil.errorLogInfo("", TAG, e);
  2681. mNewDanjiServer = false;
  2682. }
  2683. //////////////////////////////////////////////////
  2684. /////////////////////////////////////////////////////////////////////
  2685. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2686. /////////////////////////////////////////////////////////////////////
  2687. if (!mNewDanjiServer) {
  2688. svr = new ServerSocket(port);
  2689. } else {
  2690. int svrport = port + 1000;
  2691. Log.i(TAG, "============================================");
  2692. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2693. Log.i(TAG, "============================================");
  2694. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2695. sslsvr = sslServerSocket.getServerSocket();
  2696. }
  2697. }
  2698. public void run() {
  2699. while (receiveSocketRun) {
  2700. try {
  2701. Socket sock = null;
  2702. /////////////////////////////////////////////////////////////////////
  2703. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2704. /////////////////////////////////////////////////////////////////////
  2705. if (!mNewDanjiServer) {
  2706. sock = svr.accept();
  2707. } else {
  2708. sock = sslsvr.accept();
  2709. }
  2710. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2711. ProciMap.start();
  2712. } catch (IOException e) {
  2713. //e.printStackTrace();
  2714. LogUtil.errorLogInfo("", TAG, e);
  2715. }
  2716. }
  2717. }
  2718. public void destoryThread() {
  2719. receiveSocketRun = false;
  2720. try {
  2721. if (svr != null) {
  2722. svr.close();
  2723. svr = null;
  2724. }
  2725. if (sslsvr != null) {
  2726. sslsvr.close();
  2727. sslsvr = null;
  2728. }
  2729. } catch (RuntimeException re) {
  2730. LogUtil.errorLogInfo("", TAG, re);
  2731. } catch (Exception e) {
  2732. //e.printStackTrace();
  2733. LogUtil.errorLogInfo("", TAG, e);
  2734. }
  2735. }
  2736. }
  2737. public String getRemoteIPAddress(Socket Sock) {
  2738. try {
  2739. // Log.i(TAG, "[getRemoteIPAddress] == START ==");
  2740. if (Sock == null) return "10.0.1.1";
  2741. String strRemoteIP = Sock.getRemoteSocketAddress().toString();
  2742. String[] strSplited_01 = strRemoteIP.split(":");
  2743. String[] strSplited_02 = strSplited_01[0].split("/");
  2744. strRemoteIP = strSplited_02[1];
  2745. return strRemoteIP;
  2746. } catch (Exception e) {
  2747. Log.e(TAG, "[Exception] getRemoteIPAddress(Sock)");
  2748. e.printStackTrace();
  2749. return "10.0.1.1";
  2750. }
  2751. }
  2752. // iMAP 서버 소켓 처리
  2753. public class iMapSverSocketThread extends Thread {
  2754. private final Socket iMAPSock;
  2755. String strRcvMSG;
  2756. WallPadiMAPUpgrade upgradeProc;
  2757. Document doc;
  2758. public iMapSverSocketThread(Socket sock) {
  2759. iMAPSock = sock;
  2760. }
  2761. public void run() {
  2762. try {
  2763. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2764. InputStream InStm = iMAPSock.getInputStream();
  2765. iMAPSock.setSoLinger(true, 3000);
  2766. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2767. strRcvMSG = "";
  2768. String InBuffer;
  2769. int i = 0;
  2770. boolean bRcvOK = false;
  2771. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2772. /////////////////////////////////////////////////////////////////////
  2773. // 신형단지서버 미사용중일 경우 기존 코드로,
  2774. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2775. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2776. /////////////////////////////////////////////////////////////////////
  2777. if (!mNewDanjiServer) {
  2778. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2779. try {
  2780. if (MsgReader.ready()) {
  2781. try {
  2782. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2783. InBuffer = "";
  2784. while (MsgReader.ready()) {
  2785. long charCnt = MsgReader.read(ReadData);
  2786. InBuffer += new String(ReadData, 0, (int) charCnt);
  2787. }
  2788. if (InBuffer != null) strRcvMSG += InBuffer;
  2789. if (0 < InBuffer.indexOf("</imap>")) {
  2790. bRcvOK = true;
  2791. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2792. break;
  2793. }
  2794. } catch (RuntimeException re) {
  2795. LogUtil.errorLogInfo("", TAG, re);
  2796. return;
  2797. } catch (Exception e) {
  2798. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2799. //e.printStackTrace();
  2800. LogUtil.errorLogInfo("", TAG, e);
  2801. return;
  2802. }
  2803. } else {
  2804. Thread.sleep(100);
  2805. }
  2806. } catch (RuntimeException re) {
  2807. LogUtil.errorLogInfo("", TAG, re);
  2808. iMAPSock.close();
  2809. return;
  2810. } catch (Exception e) {
  2811. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  2812. iMAPSock.close();
  2813. //e.printStackTrace();
  2814. LogUtil.errorLogInfo("", TAG, e);
  2815. return;
  2816. }
  2817. }
  2818. } else {
  2819. // SSL 암호화 데이터 수신부
  2820. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  2821. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2822. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2823. try {
  2824. InBuffer = "";
  2825. long charCnt = MsgReader.read(ReadData);
  2826. if (charCnt > 0) {
  2827. InBuffer += new String(ReadData, 0, (int) charCnt);
  2828. strRcvMSG += InBuffer;
  2829. if (-1 < InBuffer.indexOf("</imap>")) {
  2830. bRcvOK = true;
  2831. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  2832. break;
  2833. }
  2834. } else {
  2835. Thread.sleep(100);
  2836. }
  2837. } catch (RuntimeException re) {
  2838. LogUtil.errorLogInfo("", TAG, re);
  2839. iMAPSock.close();
  2840. return;
  2841. } catch (Exception e) {
  2842. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  2843. iMAPSock.close();
  2844. //e.printStackTrace();
  2845. LogUtil.errorLogInfo("", TAG, e);
  2846. return;
  2847. }
  2848. }
  2849. }
  2850. if (!bRcvOK) {
  2851. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  2852. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  2853. Log.i(TAG, strRcvMSG);
  2854. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  2855. iMAPSock.close();
  2856. return;
  2857. }
  2858. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  2859. imapsvrlog("Socket read end accept </imap>\n" + strRcvMSG);
  2860. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2861. DocumentBuilder builder = factory.newDocumentBuilder();
  2862. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  2863. doc = builder.parse(istream);
  2864. Element elelist = doc.getDocumentElement();
  2865. NodeList items = elelist.getElementsByTagName("service");
  2866. Node item = items.item(0);
  2867. NamedNodeMap attrs = item.getAttributes();
  2868. String retXML = "";
  2869. for (int j = 0; j < attrs.getLength(); j++) {
  2870. Node attr = attrs.item(j);
  2871. String cmd;
  2872. if (attr.getNodeName().equalsIgnoreCase("type")) {
  2873. cmd = attr.getNodeValue();
  2874. if (cmd.equalsIgnoreCase("notice")) {
  2875. iMAPSock.close();
  2876. }
  2877. } else if (attr.getNodeName().equalsIgnoreCase("name")) {
  2878. cmd = attr.getNodeValue();
  2879. if (cmd.equalsIgnoreCase("event_notify")) {
  2880. retXML = ProcEventNotify(elelist);
  2881. } else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  2882. ProcElevatorinfo(elelist);
  2883. retXML = null;
  2884. } else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  2885. retXML = ProcCheckEpiceUpload(doc);
  2886. } else if (cmd.equalsIgnoreCase("update_news")) {
  2887. retXML = ProcUpdateNews(doc);
  2888. } else if (cmd.equalsIgnoreCase("update_weather")) {
  2889. retXML = ProcUpdateWeather(doc);
  2890. } else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  2891. retXML = ProcSchduleInquiry(doc);
  2892. } else if (cmd.equalsIgnoreCase("schedule_renew")) {
  2893. retXML = ProcSchduleRenew(doc);
  2894. } else if (cmd.equalsIgnoreCase("schdule")) {
  2895. String SvcType = "";
  2896. int k;
  2897. for (k = j + 1; k < attrs.getLength(); k++) {
  2898. Node attr1 = attrs.item(k);
  2899. SvcType = attr1.getNodeName();
  2900. if (SvcType.equalsIgnoreCase("shc_type")) {
  2901. SvcType = attr1.getNodeValue();
  2902. break;
  2903. }
  2904. }
  2905. retXML = ProcUpdateSchedule(elelist, SvcType);
  2906. } else if (cmd.equalsIgnoreCase("device_reset")) {
  2907. retXML = ProcDeviceReset(elelist);
  2908. } else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  2909. retXML = ProcNotifyparcel(doc);
  2910. } else if (cmd.equalsIgnoreCase("notify_post_info")) {
  2911. // 스마트우편함 연동 여부
  2912. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  2913. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  2914. DevSet.closeDB();
  2915. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  2916. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  2917. } else if (cmd.equalsIgnoreCase("get_security_mode")) {
  2918. String Dong = null;
  2919. String Ho = null;
  2920. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  2921. String result;
  2922. String modeStr = null;
  2923. int status = statusDB.GetAlarmStatus();
  2924. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  2925. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  2926. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  2927. else if (status == WallpadStatusData.GUARD_OUT)
  2928. modeStr = "unoccupied";
  2929. else if (status == WallpadStatusData.GUARD_OUT_WAIT)
  2930. modeStr = "waitunoccupied";
  2931. result = "ok";
  2932. } else {
  2933. modeStr = "null";
  2934. result = "fail";
  2935. }
  2936. try {
  2937. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  2938. Node GSM_item = GSM_items.item(0);
  2939. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  2940. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  2941. Node GSM_attr = GSM_attrsParam.item(k);
  2942. if (GSM_attr.getNodeName().equalsIgnoreCase("dong"))
  2943. Dong = trimquotation(GSM_attr.getNodeValue());
  2944. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho"))
  2945. Ho = trimquotation(GSM_attr.getNodeValue());
  2946. }
  2947. WallpadStatusData DBMGR = null;
  2948. DBMGR = new WallpadStatusData(getApplicationContext());
  2949. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  2950. DBMGR.closeDB();
  2951. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  2952. result = "fail";
  2953. }
  2954. } catch (RuntimeException re) {
  2955. LogUtil.errorLogInfo("", TAG, re);
  2956. result = "fail";
  2957. } catch (Exception e) {
  2958. result = "fail";
  2959. }
  2960. retXML = XMLHeader +
  2961. " <service type=\"reply\" name=\"get_security_mode\" result=\"" + result + "\">\r\n" +
  2962. " <home_info dong=\"" + AddrDong + "\" ho=\"" + AddrHo + "\" mode=\"" + modeStr + "\"/>\r\n" +
  2963. " </service>\r\n" +
  2964. "</imap>\r\n";
  2965. statusDB.closeDB();
  2966. } else if (cmd.equalsIgnoreCase("set_setup_info")) {
  2967. retXML = ProcSetsetup(doc);
  2968. } else if (cmd.equalsIgnoreCase("get_setup_info")) {
  2969. retXML = ProcGetsetup(doc);
  2970. } else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  2971. retXML = CheckPassword(doc);
  2972. } else if (cmd.equalsIgnoreCase("device_live_check")) {
  2973. retXML = ProcDeviceLiveCheck();
  2974. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  2975. retXML = ProcPairingHdevSyncAlarm(elelist);
  2976. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  2977. retXML = ProcPairingHdevSyncSecurity(elelist);
  2978. } else if (cmd.equalsIgnoreCase("notify_car_event")) {
  2979. retXML = ProcParkInformation(elelist);
  2980. } else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2981. retXML = ProcSmartKeyEvent(elelist);
  2982. } else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  2983. retXML = ProcParkInformation_cham_upis(elelist);
  2984. } else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  2985. retXML = ProcauscultateReq(doc);
  2986. } else if (cmd.equalsIgnoreCase("upgrade")) {
  2987. imapsvrlog("Enter Upgrade");
  2988. procUpgrade();
  2989. retXML = null;
  2990. } else if (cmd.equals("check_sip_activation")) {
  2991. String sip_result = "fail";
  2992. ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  2993. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  2994. //add KSJ 2021.11.02 socket addr 가져오기 위해 추가
  2995. String strIP = getRemoteIPAddress(iMAPSock);
  2996. //~add KSJ
  2997. // Jeff added below codes for call app (2018.01.25)
  2998. String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
  2999. for (int k = 0; k < rsi.size(); k++) {
  3000. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  3001. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  3002. sip_result = "ok";
  3003. break;
  3004. }
  3005. }
  3006. if(bWallPadCallLive && m_bWallpadCallScreen == false)
  3007. {
  3008. sip_result = "fail";
  3009. }
  3010. if(m_CallAppRunDelay == false)
  3011. {
  3012. 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";
  3013. //add KSJ 2021.11.02 check_sip_activation msg recv 이후 wallpadcall app start
  3014. String[] IP_Parse = strIP.split("\\.");
  3015. Log.d(TAG, "1" + strIP);
  3016. //Log.d(TAG, "2" + strSplit[1]);
  3017. //Log.d(TAG, "3" + strSplit[2]);
  3018. //Log.d(TAG, "4" + strSplit[3]);
  3019. CALLTYPE eCallType = CALLTYPE.LOBBY;
  3020. if (IP_Parse[2].equals("0")) {
  3021. eCallType = CALLTYPE.LOBBY;
  3022. if (IP_Parse[3].equals("11"))
  3023. eCallType = CALLTYPE.FRONT;
  3024. } else if (IP_Parse[2].equals("129")) {
  3025. eCallType = CALLTYPE.FRONT;
  3026. } else {
  3027. eCallType = CALLTYPE.RESIDENCE;
  3028. }
  3029. if ((eCallType == CALLTYPE.LOBBY) || (eCallType == CALLTYPE.FRONT)) {
  3030. m_CallAppRunDelay = true;
  3031. runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
  3032. }
  3033. }
  3034. else
  3035. {
  3036. sip_result = "fail";
  3037. 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";
  3038. }
  3039. }
  3040. //add KSJ 2021.11.02 stop_talking msg 추가 (wallpadcall 종료)
  3041. else if (cmd.equals("stop_talking")) {
  3042. String sip_result = "ok";
  3043. //sip_result = "ok";
  3044. retXML = XMLHeader + "<service type=\"reply\" name=\"stop_talking\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  3045. Common.SendAppFinishReqBR(getApplicationContext());
  3046. }
  3047. //~add KSJ
  3048. //add 2022.03.02 front_open msg 추가 (현관에서 문열림 요청)
  3049. else if (cmd.equals("front_open")) {
  3050. retXML = ProcFrontOpen();
  3051. }
  3052. //~add
  3053. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3054. retXML = iCMDProcDevList(doc);
  3055. } else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3056. retXML = iCMDProcGASControl(elelist);
  3057. } else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3058. // 현대건설 더펜트하우스 와 구분하여 처리
  3059. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3060. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  3061. mWallpadDeviceSet.closeDB();
  3062. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  3063. retXML = iCMDProcChumDamSmartLightControl(doc);
  3064. }
  3065. else {
  3066. retXML = iCMDProcSDPSmartLightControl(doc);
  3067. }
  3068. } else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3069. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3070. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3071. retXML = iCMDProc_I_LightControl(doc);
  3072. } else {
  3073. retXML = iCMDProcLivingLightControl(doc);
  3074. }
  3075. } else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3076. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  3077. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
  3078. || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
  3079. retXML = iCMDProcSDPConcentControl(doc);
  3080. } else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3081. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3082. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3083. } else {
  3084. retXML = iCMDProcMultiSWControl(doc);
  3085. }
  3086. } else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3087. retXML = iCMDProcDoorlockControl(doc);
  3088. } else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3089. retXML = iCMDProcTemperControl(doc);
  3090. } else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3091. retXML = iCMDProcModeControl(doc);
  3092. } else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3093. retXML = iCMDProcVentilControl(doc);
  3094. } else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3095. retXML = iCMDProcCurtainControl(doc);
  3096. } else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3097. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3098. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3099. retXML = iCMDProcEnergyMeterLightControl(doc);
  3100. } else {
  3101. retXML = iCMDProcLightControl(doc);
  3102. }
  3103. } else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3104. retXML = iCMDProcLightBatchControl(elelist);
  3105. }
  3106. else if (cmd.equalsIgnoreCase("remote_access_sysaircon")) {
  3107. retXML = iCMDProcSysairconControl(elelist);
  3108. }
  3109. //모바일 사용자 인증 관련 메시지
  3110. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3111. ProcMobileDevice_AuthNumber(elelist);
  3112. } else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3113. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3114. } else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3115. ProcMobileDevice_Delete(elelist);
  3116. } else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3117. retXML = ProcGetSmartKeyInfo(elelist);
  3118. } else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3119. retXML = ProcGetAppVersionInfo();
  3120. } else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3121. retXML = ProcIgateInitInfo(elelist);
  3122. } else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3123. retXML = ProcElecCarChargeEventInfo(elelist);
  3124. } else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3125. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3126. } else if (cmd.equalsIgnoreCase("check_call_option")) {
  3127. retXML = ProcCheckCallOption();
  3128. } else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3129. retXML = ProcChatSequence(elelist);
  3130. } else if (cmd.equalsIgnoreCase("chat_message")) {
  3131. retXML = ProcChatMessage(elelist);
  3132. } else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3133. retXML = ProcEvacuationLadderOpen(elelist);
  3134. } else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3135. retXML = SmartLightDetailInfo(elelist);
  3136. } else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3137. retXML = KNXDeviceDetailInfo(elelist);
  3138. } else if (cmd.equalsIgnoreCase("set_server_version")) {
  3139. retXML = ProcSetServerChange(elelist);
  3140. } else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
  3141. retXML = iCMDProcOnePass(elelist);
  3142. } else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3143. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  3144. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3145. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3146. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3147. }
  3148. } else if (cmd.equalsIgnoreCase("check_resident_safety")) {
  3149. retXML = iCMDProcResidentSafety(elelist);
  3150. }
  3151. break;
  3152. }
  3153. }
  3154. if (retXML != null) {
  3155. imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
  3156. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3157. byte[] outBF = retXML.getBytes("euc-kr");
  3158. outstream.write(outBF);
  3159. outstream.flush();
  3160. try {
  3161. Thread.sleep(3000);
  3162. } catch (RuntimeException re) {
  3163. LogUtil.errorLogInfo("", TAG, re);
  3164. } catch (Exception e) {
  3165. LogUtil.errorLogInfo("", TAG, e);
  3166. }
  3167. iMAPSock.close();
  3168. } else {
  3169. try {
  3170. iMAPSock.close();
  3171. } catch (RuntimeException re) {
  3172. LogUtil.errorLogInfo("", TAG, re);
  3173. } catch (Exception e) {
  3174. LogUtil.errorLogInfo("", TAG, e);
  3175. }
  3176. }
  3177. } catch (RuntimeException re) {
  3178. LogUtil.errorLogInfo("", TAG, re);
  3179. } catch (Exception e) {
  3180. try {
  3181. iMAPSock.close();
  3182. } catch (RuntimeException re) {
  3183. LogUtil.errorLogInfo("", TAG, re);
  3184. } catch (Exception E) {
  3185. LogUtil.errorLogInfo("", TAG, E);
  3186. }
  3187. LogUtil.errorLogInfo("", TAG, e);
  3188. }
  3189. }
  3190. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3191. private void procUpgrade() {
  3192. imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
  3193. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3194. String[] getstate = sdb.GetSystemUpdateStatus();
  3195. sdb.closeDB();
  3196. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3197. for (int i = 0; i < getstate.length; i++) {
  3198. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3199. }
  3200. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3201. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3202. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3203. }
  3204. }
  3205. // " 제거
  3206. private String trimquotation(String sen) {
  3207. sen = sen.replaceAll("\"", "");
  3208. return sen.trim();
  3209. }
  3210. //remote_auscultate 처리
  3211. public String ProcauscultateReq(Document Doc) {
  3212. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3213. NodeList items = Doc.getElementsByTagName("group");
  3214. Node item;
  3215. String itemname = null;
  3216. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3217. SettManager.DeleteSettingData();
  3218. SettManager.DropTable();
  3219. try {
  3220. for (int i = 0; i < items.getLength(); i++) {
  3221. item = items.item(i);
  3222. itemname = GetAttributeVal(item, "type");
  3223. String GetCNT = GetAttributeVal(item, "count");
  3224. if (Integer.parseInt(GetCNT) <= 0)
  3225. continue;
  3226. Element SettingItem = (Element) item;
  3227. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3228. for (int j = 0; j < SettingList.getLength(); j++) {
  3229. Node subdevListitem = SettingList.item(j);
  3230. String devname = trimquotation(subdevListitem.getTextContent());
  3231. SettManager.InsertSettingData(itemname, devname, j);
  3232. }
  3233. }
  3234. } catch (RuntimeException re) {
  3235. LogUtil.errorLogInfo("", TAG, re);
  3236. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3237. SettManager.closeDB();
  3238. return RetVal;
  3239. } catch (Exception e) {
  3240. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3241. //e.printStackTrace();
  3242. LogUtil.errorLogInfo("", TAG, e);
  3243. SettManager.closeDB();
  3244. return RetVal;
  3245. }
  3246. SettManager.closeDB();
  3247. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3248. StatusBeatRequested = true;
  3249. Intent intent = new Intent();
  3250. intent.setAction(define.NOTIFY_ACNAME);
  3251. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
  3252. sendBroadcast(intent);
  3253. return RetVal;
  3254. }
  3255. public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
  3256. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  3257. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n" +
  3258. "<service type=\"request\" name=\"remote_auscultate\">\r\n" +
  3259. " <guidemap devtype=\"homedev\" count=\"4\">\r\n" +
  3260. " <group type=\"ctrl_device\" count=\"5\">\r\n" +
  3261. " <unit>\"light\"</unit>\r\n" +
  3262. " <unit>\"thermostat\"</unit>\r\n" +
  3263. " <unit>\"gas\"</unit>\r\n" +
  3264. " <unit>\"doorlock\"</unit>\r\n" +
  3265. " <unit>\"ventil\"</unit>\r\n" +
  3266. " </group>\r\n" +
  3267. " <group type=\"talk_device\" count=\"4\">\r\n" +
  3268. " <unit>\"sub_homedev\"</unit>\r\n" +
  3269. " <unit>\"kitchen_tv\"</unit>\r\n" +
  3270. " <unit>\"bath_tv\"</unit>\r\n" +
  3271. " <unit>\"bath_phone\"</unit>\r\n" +
  3272. " </group>\r\n" +
  3273. " <group type=\"sensor\" count=\"6\">\r\n" +
  3274. " <unit>\"magnetic\"</unit>\r\n" +
  3275. " <unit>\"bugout\"</unit>\r\n" +
  3276. " <unit>\"bugin\"</unit>\r\n" +
  3277. " <unit>\"fire\"</unit>\r\n" +
  3278. " <unit>\"gas\"</unit>\r\n" +
  3279. " <unit>\"emergency\"</unit>\r\n" +
  3280. " </group>\r\n" +
  3281. " <group type=\"extended\" count=\"4\">\r\n" +
  3282. " <unit>\"gateway\"</unit>\r\n" +
  3283. " <unit>\"smartswitch\"</unit>\r\n" +
  3284. " <unit>\"handy\"</unit>\r\n" +
  3285. " <unit>\"energymeter\"</unit>\r\n" +
  3286. " </group>\r\n" +
  3287. " </guidemap>\r\n" +
  3288. "</service>\r\n" +
  3289. "</imap>\r\n";
  3290. try {
  3291. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3292. DocumentBuilder builder = factory.newDocumentBuilder();
  3293. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3294. Document doc = builder.parse(istream);
  3295. NodeList items = doc.getElementsByTagName("group");
  3296. Node item;
  3297. String itemname = null;
  3298. SettManager.DeleteSettingData();
  3299. SettManager.DropTable();
  3300. for (int i = 0; i < items.getLength(); i++) {
  3301. item = items.item(i);
  3302. itemname = GetAttributeVal(item, "type");
  3303. String GetCNT = GetAttributeVal(item, "count");
  3304. if (Integer.parseInt(GetCNT) <= 0)
  3305. continue;
  3306. Element SettingItem = (Element) item;
  3307. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3308. for (int j = 0; j < SettingList.getLength(); j++) {
  3309. Node subdevListitem = SettingList.item(j);
  3310. String devname = trimquotation(subdevListitem.getTextContent());
  3311. SettManager.InsertSettingData(itemname, devname, j);
  3312. }
  3313. }
  3314. } catch (RuntimeException re) {
  3315. LogUtil.errorLogInfo("", TAG, re);
  3316. } catch (Exception e) {
  3317. //e.printStackTrace();
  3318. LogUtil.errorLogInfo("", TAG, e);
  3319. }
  3320. }
  3321. String MakeFailMessage(String msg) {
  3322. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\"" + msg + "\"</first_failed>\r\n</service>\r\n</imap>";
  3323. }
  3324. //SetInfo의 각 항목들의 무결성 확인
  3325. final String isUse = "사용함";
  3326. final String isNotUse = "사용안함";
  3327. boolean CheckSubdevData(String devName, String devData) {
  3328. String[] SplitedMSG;
  3329. try {
  3330. if (devName.equals("가스밸브")) {
  3331. SplitedMSG = devData.split("[(]");
  3332. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3333. String UseStr = SplitedMSG[2].split("[)]")[0];
  3334. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3335. } else if (devName.equals("디지털도어락")) {
  3336. SplitedMSG = devData.split("[(]");
  3337. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3338. String[] UseStr = SplitedMSG[2].split("[)]");
  3339. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3340. if (!UseStr[1].equals("종류")) return false;
  3341. UseStr = SplitedMSG[3].split("[)]");
  3342. if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
  3343. } else if (devName.equals("온도조절기")) {
  3344. SplitedMSG = devData.split("[(]");
  3345. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3346. String[] UseStr = SplitedMSG[2].split("[)]");
  3347. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  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("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3358. return false;
  3359. */
  3360. } else if (devName.equals("환기시스템")) {
  3361. SplitedMSG = devData.split("[(]");
  3362. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3363. String[] UseStr = SplitedMSG[2].split("[)]");
  3364. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3365. /*
  3366. if (!UseStr[1].equals("종류"))
  3367. return false;
  3368. UseStr = SplitedMSG[3].split("[)]");
  3369. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  3370. return false;
  3371. */
  3372. } else if (devName.equals("시스템에어컨")) {
  3373. SplitedMSG = devData.split("[(]");
  3374. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3375. String[] UseStr = SplitedMSG[2].split("[)]");
  3376. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3377. } else if (devName.equals("전동커튼")) {
  3378. SplitedMSG = devData.split("[(]");
  3379. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3380. String[] UseStr = SplitedMSG[2].split("[)]");
  3381. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3382. /*
  3383. if (!UseStr[1].equals("종류"))
  3384. return false;
  3385. UseStr = SplitedMSG[3].split("[)]");
  3386. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  3387. return false;
  3388. */
  3389. } else if (devName.equals("실시간검침기")) {
  3390. SplitedMSG = devData.split("[(]");
  3391. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3392. String[] UseStr = SplitedMSG[2].split("[)]");
  3393. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3394. } else if (devName.equals("스마트스위치&일괄소등")) {
  3395. SplitedMSG = devData.split("[(]");
  3396. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3397. String[] UseStr = SplitedMSG[2].split("[)]");
  3398. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3399. /*
  3400. if (!UseStr[1].equals("종류"))
  3401. return false;
  3402. UseStr = SplitedMSG[3].split("[)]");
  3403. if (!UseStr[0].equals("대외향스마트스위치")&&
  3404. !UseStr[0].equals("대외향일괄소등제어기")&&
  3405. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  3406. !UseStr[0].equals("현산향스마트스위치")&&
  3407. !UseStr[0].equals("현산향LCD스마트스위치"))
  3408. return false;
  3409. */
  3410. } else if (devName.equals("무선리모컨")) {
  3411. SplitedMSG = devData.split("[(]");
  3412. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3413. String[] UseStr = SplitedMSG[2].split("[)]");
  3414. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  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. if (!UseStr[1].equals("종류"))
  3422. return false;
  3423. UseStr = SplitedMSG[3].split("[)]");
  3424. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  3425. 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. } else if (devName.equals("날씨")) {
  3433. SplitedMSG = devData.split("[(]");
  3434. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3435. String[] UseStr = SplitedMSG[2].split("[)]");
  3436. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3437. } else if (devName.equals("메모")) {
  3438. SplitedMSG = devData.split("[(]");
  3439. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3440. String[] UseStr = SplitedMSG[2].split("[)]");
  3441. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3442. } else if (devName.equals("전자액자")) {
  3443. SplitedMSG = devData.split("[(]");
  3444. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3445. String[] UseStr = SplitedMSG[2].split("[)]");
  3446. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3447. } else if (devName.equals("일정표")) {
  3448. SplitedMSG = devData.split("[(]");
  3449. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3450. String[] UseStr = SplitedMSG[2].split("[)]");
  3451. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3452. } else if (devName.equals("주차확인")) {
  3453. SplitedMSG = devData.split("[(]");
  3454. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3455. String[] UseStr = SplitedMSG[2].split("[)]");
  3456. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3457. /*
  3458. UseStr = SplitedMSG[3].split("[)]");
  3459. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3460. 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. } else if (devName.equals("원격검침")) {
  3468. SplitedMSG = devData.split("[(]");
  3469. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3470. String[] UseStr = SplitedMSG[2].split("[)]");
  3471. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3472. } else if (devName.equals("뮤직")) {
  3473. SplitedMSG = devData.split("[(]");
  3474. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3475. String[] UseStr = SplitedMSG[2].split("[)]");
  3476. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3477. } else if (devName.equals("영상재생")) {
  3478. SplitedMSG = devData.split("[(]");
  3479. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3480. String[] UseStr = SplitedMSG[2].split("[)]");
  3481. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3482. } else if (devName.equals("CCTV")) {
  3483. SplitedMSG = devData.split("[(]");
  3484. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3485. String[] UseStr = SplitedMSG[2].split("[)]");
  3486. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3487. /*
  3488. UseStr = SplitedMSG[3].split("[)]");
  3489. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3490. return false;
  3491. */
  3492. } else if (devName.equals("명칭설정")) {
  3493. SplitedMSG = devData.split("[(]");
  3494. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3495. String[] UseStr = SplitedMSG[2].split("[)]");
  3496. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3497. } 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. } else if (devName.equals("경비실영상통화")) {
  3503. SplitedMSG = devData.split("[(]");
  3504. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3505. String[] UseStr = SplitedMSG[2].split("[)]");
  3506. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3507. } else if (devName.equals("엘리베이터")) {
  3508. SplitedMSG = devData.split("[(]");
  3509. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3510. String[] UseStr = SplitedMSG[2].split("[)]");
  3511. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3512. /*
  3513. UseStr = SplitedMSG[3].split("[)]");
  3514. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3515. return false;
  3516. */
  3517. } else if (devName.equals("현장특화기능")) {
  3518. SplitedMSG = devData.split("[(]");
  3519. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3520. String[] UseStr = SplitedMSG[2].split("[)]");
  3521. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3522. /*
  3523. UseStr = SplitedMSG[3].split("[)]");
  3524. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3525. return false;
  3526. */
  3527. } else if (devName.equals("월패드카메라")) {
  3528. SplitedMSG = devData.split("[(]");
  3529. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3530. String[] UseStr = SplitedMSG[2].split("[)]");
  3531. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3532. } else if (devName.equals("무드등")) {
  3533. SplitedMSG = devData.split("[(]");
  3534. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3535. String[] UseStr = SplitedMSG[2].split("[)]");
  3536. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3537. /*
  3538. UseStr = SplitedMSG[3].split("[)]");
  3539. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3540. return false;
  3541. */
  3542. } else if (devName.equals("피난사다리")) {
  3543. SplitedMSG = devData.split("[(]");
  3544. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3545. String[] UseStr = SplitedMSG[2].split("[)]");
  3546. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3547. } else if (devName.equals("동체설정")) {
  3548. return true;
  3549. /*
  3550. SplitedMSG = devData.split("[(]");
  3551. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3552. return false;
  3553. String[] UseStr = SplitedMSG[2].split("[)]");
  3554. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3555. return false;
  3556. if (UseStr[0].equals(isNotUse)) return true;
  3557. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3558. return false;
  3559. for (int i=3; i < SplitedMSG.length; i++)
  3560. {
  3561. UseStr = SplitedMSG[i].split("[)]");
  3562. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3563. return false;
  3564. if (i != SplitedMSG.length-1)
  3565. {
  3566. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3567. return false;
  3568. }
  3569. }
  3570. */
  3571. } else if (devName.equals("알람발생")) {
  3572. SplitedMSG = devData.split("[(]");
  3573. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3574. String[] UseStr = SplitedMSG[2].split("[)]");
  3575. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3576. } else if (devName.equals("UI순서")) {
  3577. SplitedMSG = devData.split("[(]");
  3578. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3579. String[] UseStr = SplitedMSG[2].split("[)]");
  3580. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3581. } else {
  3582. Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
  3583. Log.w("iMAP", "Return true");
  3584. return true;
  3585. }
  3586. } catch (RuntimeException re) {
  3587. LogUtil.errorLogInfo("", TAG, re);
  3588. return false;
  3589. } catch (Exception e) {
  3590. //e.printStackTrace();
  3591. LogUtil.errorLogInfo("", TAG, e);
  3592. return false;
  3593. }
  3594. return true;
  3595. }
  3596. public String ProcSetsetup(Document ele) {
  3597. Common.DebugLog("ProcSetsetup------------------------->");
  3598. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3599. NodeList items = ele.getElementsByTagName("setting");
  3600. Node item;
  3601. String itemname = null;
  3602. String dateData = null;
  3603. String heartbeatP = null;
  3604. String Versions = null;
  3605. String SdbAccInit_Str = null;
  3606. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3607. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3608. if (!SettManager.StartTransaction()) {
  3609. ResetFlag = false;
  3610. RetVal += "\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3611. SettManager.EndTransaction(false);
  3612. SettManager.closeDB();
  3613. return RetVal;
  3614. }
  3615. try {
  3616. for (int i = 0; i < items.getLength(); i++) {
  3617. item = items.item(i);
  3618. itemname = GetAttributeVal(item, "name");
  3619. if (itemname != null) {
  3620. if (itemname.equals("beat_time")) {
  3621. heartbeatP = GetAttributeVal(item, "value");
  3622. } else if (itemname.equals("ver_setting")) {
  3623. Versions = GetAttributeVal(item, "value");
  3624. } else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3625. Element guardlist = (Element) item;
  3626. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3627. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3628. else continue;
  3629. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3630. Node GuardListitem = GuardCTList.item(j);
  3631. String guardname = GetAttributeVal(GuardListitem, "name");
  3632. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3633. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3634. }
  3635. } else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3636. Element subdevList = (Element) item;
  3637. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3638. for (int j = 0; j < SubDevList.getLength(); j++) {
  3639. Node subdevListitem = SubDevList.item(j);
  3640. String devname = GetAttributeVal(subdevListitem, "name");
  3641. String devval = GetAttributeVal(subdevListitem, "value");
  3642. if (devname != null && devval != null) {
  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. } else {
  3666. Log.w("iMAP", "DB No Setup Name and Value");
  3667. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3668. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3669. ResetFlag = true;
  3670. }
  3671. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3672. if (devname.equals("로고설정")) {
  3673. String devInfo = devval;
  3674. devInfo = devInfo.replace('(', '_');
  3675. devInfo = devInfo.replace(':', '_');
  3676. devInfo = devInfo.replace(')', '_');
  3677. String[] DetailInfo = devInfo.split("_");
  3678. int LogoType = 0;
  3679. if (DetailInfo[5].equals("표시안함") == true) {
  3680. LogoType = 0;
  3681. } else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3682. LogoType = 1;
  3683. } else if (DetailInfo[5].equals("양우내안애") == true) {
  3684. LogoType = 2;
  3685. } else if (DetailInfo[5].equals("GSITM") == true) {
  3686. LogoType = 3;
  3687. } else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3688. LogoType = 4;
  3689. } else if (DetailInfo[5].equals("거실조명표시") == true) {
  3690. LogoType = 5;
  3691. } else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3692. LogoType = 6;
  3693. } else if (DetailInfo[5].equals("기타1") == true) {
  3694. LogoType = 7;
  3695. } else if (DetailInfo[5].equals("기타2") == true) {
  3696. LogoType = 8;
  3697. }
  3698. if ((LogoType >= 0) && (LogoType <= 8)) {
  3699. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3700. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3701. }
  3702. } else if (devname.equals("엘리베이터위젯복구")) {
  3703. String devInfo = devval;
  3704. devInfo = devInfo.replace('(', '_');
  3705. devInfo = devInfo.replace(':', '_');
  3706. devInfo = devInfo.replace(')', '_');
  3707. String[] DetailInfo = devInfo.split("_");
  3708. if (DetailInfo[3].equals("사용함") == true) {
  3709. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3710. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3711. }
  3712. } else if (devname.equals("분전반알람설정")) {
  3713. try {
  3714. String devInfo = devval;
  3715. devInfo = devInfo.replace('(', '_');
  3716. devInfo = devInfo.replace(':', '_');
  3717. devInfo = devInfo.replace(')', '_');
  3718. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3719. //[0] - 기기번호
  3720. //[1] - 회로수
  3721. //[2] - 기기이름
  3722. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3723. //[4] - 명칭
  3724. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3725. String[] DetailInfo = devInfo.split("_");
  3726. for (int a = 0; a < DetailInfo.length; a++) {
  3727. if (DetailInfo[a].equals("누적전력초기화")) {
  3728. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3729. if ((a + 1) <= DetailInfo.length) {
  3730. // 설정정보가 존재해야 인식하도록 함
  3731. if (DetailInfo[a + 1].equals("1")) {
  3732. // 1(사용함) 일때
  3733. if (sdbAPI != null) {
  3734. if (sdbAPI.Set_AccPwReset() >= 0) {
  3735. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3736. } else {
  3737. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3738. }
  3739. }
  3740. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3741. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3742. }
  3743. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3744. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3745. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3746. }
  3747. }
  3748. }
  3749. } catch (RuntimeException re) {
  3750. LogUtil.errorLogInfo("", TAG, re);
  3751. } catch (Exception e) {
  3752. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3753. //e.printStackTrace();
  3754. LogUtil.errorLogInfo("", TAG, e);
  3755. }
  3756. } else if (devname.equals("욕실폰통화음량값")) {
  3757. Intent Iintent = new Intent();
  3758. Iintent.setAction(define.NOTIFY_ACNAME);
  3759. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3760. sendBroadcast(Iintent);
  3761. } else if (devname.equals("주방TV통화음량값")) {
  3762. Intent Iintent = new Intent();
  3763. Iintent.setAction(define.NOTIFY_ACNAME);
  3764. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3765. sendBroadcast(Iintent);
  3766. } else if (devname.equals("현관카메라")) {
  3767. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  3768. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3769. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3770. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  3771. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3772. String devInfo = devval;
  3773. if (devInfo != null) {
  3774. devInfo = devInfo.replace('(', '_');
  3775. devInfo = devInfo.replace(':', '_');
  3776. devInfo = devInfo.replace(')', '_');
  3777. String[] DetailInfo = devInfo.split("_");
  3778. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3779. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  3780. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3781. if (mIOInterface != null)
  3782. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3783. } else {
  3784. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  3785. if (mIOInterface != null)
  3786. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3787. }
  3788. }
  3789. }
  3790. }
  3791. } else if (devname.equals("거동수상자녹화")) {
  3792. String devInfo = devval;
  3793. devInfo = devInfo.replace('(', '_');
  3794. devInfo = devInfo.replace(':', '_');
  3795. devInfo = devInfo.replace(')', '_');
  3796. String[] DetailInfo = devInfo.split("_");
  3797. } else if (devname.equals("스마트현관카메라좌우반전")) {
  3798. String devInfo = devval;
  3799. if (devInfo != null) {
  3800. devInfo = devInfo.replace('(', '_');
  3801. devInfo = devInfo.replace(':', '_');
  3802. devInfo = devInfo.replace(')', '_');
  3803. }
  3804. String[] DetailInfo = devInfo.split("_");
  3805. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3806. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3807. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3808. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3809. } else {
  3810. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  3811. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  3812. }
  3813. }
  3814. } else {
  3815. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3816. }
  3817. }
  3818. }
  3819. } else if (itemname.equals("datetime")) {
  3820. dateData = GetAttributeVal(item, "value");
  3821. } else {
  3822. String GetVal = GetAttributeVal(item, "value");
  3823. if (GetVal != null) {
  3824. if (!GetVal.equals("list")) {
  3825. if (itemname.equals("site_code")) {
  3826. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3827. if (Existing_SiteCode_Array == null) {
  3828. ResetFlag = true;
  3829. } else {
  3830. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3831. if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
  3832. ResetFlag = true;
  3833. }
  3834. }
  3835. }
  3836. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3837. } else {
  3838. String GetCNT = GetAttributeVal(item, "count");
  3839. if (Integer.parseInt(GetCNT) <= 0) continue;
  3840. Element SettingItem = (Element) item;
  3841. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3842. for (int j = 0; j < SettingList.getLength(); j++) {
  3843. Node subdevListitem = SettingList.item(j);
  3844. String devname = GetAttributeVal(subdevListitem, "name");
  3845. String devval = GetAttributeVal(subdevListitem, "value");
  3846. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3847. }
  3848. }
  3849. }
  3850. }
  3851. }
  3852. }
  3853. } catch (RuntimeException re) {
  3854. LogUtil.errorLogInfo("", TAG, re);
  3855. ResetFlag = false;
  3856. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3857. SettManager.EndTransaction(false);
  3858. SettManager.closeDB();
  3859. return RetVal;
  3860. } catch (Exception e) {
  3861. ResetFlag = false;
  3862. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3863. //e.printStackTrace();
  3864. LogUtil.errorLogInfo("", TAG, e);
  3865. SettManager.EndTransaction(false);
  3866. SettManager.closeDB();
  3867. return RetVal;
  3868. }
  3869. SettManager.EndTransaction(true);
  3870. SettManager.closeDB();
  3871. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3872. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3873. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3874. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3875. }
  3876. if (AfterTransactionTodoList != null) {
  3877. if (AfterTransactionTodoList.size() > 0) {
  3878. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3879. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3880. if (afterTransactionTodoListData != null) {
  3881. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3882. WallpadSalesSampleData mWallpadSalesSampleData;
  3883. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3884. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3885. mWallpadSalesSampleData.closeDB();
  3886. } else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3887. //ifdb에 있는지
  3888. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3889. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3890. int result = devSet.Get_Elevator_Info();
  3891. devSet.closeDB();
  3892. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3893. // 엘리베이터가 사용함이면
  3894. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3895. boolean result_get_restoreUseOrNot;
  3896. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3897. if (wdb != null) {
  3898. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3899. if (result_get_restoreUseOrNot == false) {
  3900. wdb.SetElevator_Widget_Restore(true);
  3901. //위젯 DB 초기화
  3902. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3903. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3904. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3905. devSet2.initWidgetData();
  3906. devSet2.closeDB();
  3907. }
  3908. }
  3909. wdb.closeDB();
  3910. }
  3911. }
  3912. }
  3913. }
  3914. }
  3915. }
  3916. }
  3917. if (dateData != null) {
  3918. try {
  3919. int year = Integer.parseInt(dateData.substring(0, 4));
  3920. int month = Integer.parseInt(dateData.substring(4, 6));
  3921. int day = Integer.parseInt(dateData.substring(6, 8));
  3922. int hour = Integer.parseInt(dateData.substring(8, 10));
  3923. int min = Integer.parseInt(dateData.substring(10, 12));
  3924. int sec = Integer.parseInt(dateData.substring(12, 14));
  3925. Calendar nowdate = new GregorianCalendar();
  3926. long settedtime = nowdate.getTimeInMillis();
  3927. nowdate.set(Calendar.YEAR, year);
  3928. nowdate.set(Calendar.MONTH, month);
  3929. nowdate.set(Calendar.DAY_OF_MONTH, day);
  3930. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  3931. nowdate.set(Calendar.MINUTE, min);
  3932. nowdate.set(Calendar.SECOND, sec);
  3933. long bootupmil = nowdate.getTimeInMillis();
  3934. if (Math.abs(bootupmil - settedtime) > 5000) {
  3935. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3936. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  3937. DBMGR.closeDB();
  3938. Intent Iintent = new Intent();
  3939. Iintent.setAction(define.NOTIFY_ACNAME);
  3940. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  3941. sendBroadcast(Iintent);
  3942. }
  3943. } catch (RuntimeException re) {
  3944. LogUtil.errorLogInfo("", TAG, re);
  3945. } catch (Exception e) {
  3946. //e.printStackTrace();
  3947. LogUtil.errorLogInfo("", TAG, e);
  3948. }
  3949. }
  3950. if (heartbeatP != null) {
  3951. try {
  3952. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3953. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  3954. DBMGR.closeDB();
  3955. } catch (RuntimeException re) {
  3956. LogUtil.errorLogInfo("", TAG, re);
  3957. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3958. SettManager.closeDB();
  3959. return RetVal;
  3960. } catch (Exception e) {
  3961. //e.printStackTrace();
  3962. LogUtil.errorLogInfo("", TAG, e);
  3963. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3964. SettManager.closeDB();
  3965. return RetVal;
  3966. }
  3967. }
  3968. if (Versions != null) {
  3969. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3970. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  3971. DBMGR.SetSettingVer(Versions);
  3972. DBMGR.closeDB();
  3973. }
  3974. Intent intent = new Intent();
  3975. intent.setAction(define.NOTIFY_ACNAME);
  3976. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  3977. getApplicationContext().sendBroadcast(intent);
  3978. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3979. return RetVal;
  3980. }
  3981. public String ProcNotifyparcel(Document doc) {
  3982. String moveInfo = "null";
  3983. String boxNo = "null";
  3984. String serviceInfo = "null";
  3985. String receiverInfo = "null";
  3986. String message = "null";
  3987. int remainCnt = 0;
  3988. try {
  3989. NodeList param = doc.getElementsByTagName("move_info");
  3990. Node item = param.item(0);
  3991. moveInfo = trimquotation(item.getTextContent());
  3992. param = doc.getElementsByTagName("params");
  3993. item = param.item(0);
  3994. if (item != null) {
  3995. boxNo = GetAttributeVal(item, "box_num");
  3996. serviceInfo = GetAttributeVal(item, "service_info");
  3997. receiverInfo = GetAttributeVal(item, "receiver_info");
  3998. message = GetAttributeVal(item, "message");
  3999. if (message != null) {
  4000. String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
  4001. if (msgList[0].equalsIgnoreCase("remains")) {
  4002. remainCnt = Integer.parseInt(msgList[1]);
  4003. if (remainCnt > 0) {
  4004. wakeupLCD();
  4005. Intent intent = new Intent();
  4006. intent.setAction(define.NOTIFY_ACNAME);
  4007. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  4008. intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
  4009. intent.putExtra("BOX_NO", boxNo);
  4010. intent.putExtra("SERVICE_INFO", serviceInfo);
  4011. intent.putExtra("RECEIVER_INFO", receiverInfo);
  4012. intent.putExtra("REMAIN_CNT", remainCnt);
  4013. getApplicationContext().sendBroadcast(intent);
  4014. }
  4015. }
  4016. }
  4017. }
  4018. String retVal = XMLHeader +
  4019. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n" +
  4020. "</imap>\r\n";
  4021. return retVal;
  4022. } catch (RuntimeException re) {
  4023. LogUtil.errorLogInfo("", TAG, re);
  4024. String retVal = XMLHeader +
  4025. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4026. "</imap>\r\n";
  4027. return retVal;
  4028. } catch (Exception e) {
  4029. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4030. //e.printStackTrace();
  4031. LogUtil.errorLogInfo("", TAG, e);
  4032. String retVal = XMLHeader +
  4033. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4034. "</imap>\r\n";
  4035. return retVal;
  4036. }
  4037. }
  4038. public String ProcNotiPostInfo(Document doc) {
  4039. NodeList param = doc.getElementsByTagName("move_info");
  4040. Node item = param.item(0);
  4041. String aa = item.getTextContent();
  4042. aa = trimquotation(aa);
  4043. if (item != null) {
  4044. String info = item.getTextContent();
  4045. if (info != null) {
  4046. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4047. if (info.contains("post_in")) { // 우편물 보관
  4048. wakeupLCD();
  4049. int itemCount = -1;
  4050. param = doc.getElementsByTagName("params");
  4051. item = param.item(0);
  4052. if (item != null) {
  4053. String devname = GetAttributeVal(item, "message");
  4054. if (devname != null) {
  4055. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4056. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4057. if (msgList[0].equalsIgnoreCase("remains")) {
  4058. itemCount = Integer.parseInt(msgList[1]);
  4059. }
  4060. }
  4061. }
  4062. }
  4063. if (itemCount > 0) {
  4064. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4065. Intent intent = new Intent();
  4066. intent.setAction(define.NOTIFY_ACNAME);
  4067. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4068. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4069. intent.putExtra("ITEM", itemCount);
  4070. getApplicationContext().sendBroadcast(intent);
  4071. }
  4072. }
  4073. }
  4074. }
  4075. String retVal = XMLHeader +
  4076. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n" +
  4077. "</imap>\r\n";
  4078. return retVal;
  4079. }
  4080. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4081. public String ProcNotifypark(Document doc)
  4082. {
  4083. String MoveInfo = "none";
  4084. NodeList param = doc.getElementsByTagName("destination");
  4085. Node item = param.item(0);
  4086. if (item != null)
  4087. {
  4088. String dong = GetAttributeVal(item, "id_high").trim();
  4089. String ho = GetAttributeVal(item, "id_low").trim();
  4090. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4091. return (XMLHeader +
  4092. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4093. "</imap>\r\n");
  4094. }
  4095. param = doc.getElementsByTagName("move_info");
  4096. item = param.item(0);
  4097. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4098. param = doc.getElementsByTagName("params");
  4099. item = param.item(0);
  4100. if (item != null)
  4101. {
  4102. String carnum = GetAttributeVal(item, "car_num");
  4103. String locinfo = GetAttributeVal(item, "loc_info");
  4104. String msg = GetAttributeVal(item, "message");
  4105. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4106. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4107. parkdb.closeDB();Intent intent = new Intent();
  4108. intent.setAction(define.NOTIFY_ACNAME);
  4109. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4110. getApplicationContext().sendBroadcast(intent);
  4111. }
  4112. String retVal = XMLHeader +
  4113. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4114. "</imap>\r\n";
  4115. return retVal;
  4116. }
  4117. */
  4118. public String ProcGetsetup(Document doc) {
  4119. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4120. NodeList items = doc.getElementsByTagName("variable");
  4121. String RetVal = XMLHeader + "<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n" +
  4122. " <guidemap devtype=\"homedev\" count=\"" + items.getLength() + "\">\r\n";
  4123. Node item;
  4124. try {
  4125. for (int i = 0; i < items.getLength(); i++) {
  4126. item = items.item(i);
  4127. //String mRealTimeMeterData = item.getNodeValue();
  4128. String data = trimquotation(item.getTextContent());
  4129. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4130. if (gData.size() == 1) {
  4131. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + gData.get(0)[1] + "\" />\r\n";
  4132. } else if (gData.size() > 1) {
  4133. RetVal += " <setting name=\"" + data + "\" count=\"" + gData.size() + "\" value=\"list\" >\r\n";
  4134. RetVal += " <list name=\"DeviceInfo\" value=\"" + Build.MODEL + "/" + getAOSVerCode() + "\" />\r\n";
  4135. for (int k = 0; k < gData.size(); k++) {
  4136. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4137. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4138. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4139. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4140. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4141. }
  4142. RetVal += " <list name=\"" + gData.get(k)[0] + "\" value=\"" + gData.get(k)[1] + "\" />\r\n";
  4143. }
  4144. if (bAirQualityEnable) {
  4145. RetVal += " <list name=\"공기질센서버전\" value=\"" + getAirQualityInfo() + "\" />\r\n";
  4146. }
  4147. RetVal += " </setting>\r\n";
  4148. } else {
  4149. if (data.equals("beat_time")) {
  4150. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4151. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4152. DBMGR.closeDB();
  4153. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + heartbeatP + "\" />\r\n";
  4154. } else if (data.equals("ver_setting")) {
  4155. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4156. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + DBMGR.GetSettingVer() + "\" />\r\n";
  4157. DBMGR.closeDB();
  4158. } else if (data.equals("datetime")) {
  4159. Calendar cal = new GregorianCalendar();
  4160. 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";
  4161. } else if (data.equals("security_state")) {
  4162. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4163. int alarmST = DBMGR.GetAlarmStatus();
  4164. String SEC_ST;
  4165. if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
  4166. else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
  4167. else SEC_ST = "normal";
  4168. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + SEC_ST + "\" />\r\n";
  4169. DBMGR.closeDB();
  4170. } else if (data.equals("sensor_state")) {
  4171. int senIDX = 0;
  4172. String resultStr = "";
  4173. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4174. int BugSensor = DBMGR.Get_Sensor_Set();
  4175. WallPadInterface wpifc = new WallPadInterface();
  4176. if (BugSensor > 0) {
  4177. if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4178. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4179. String Senret;
  4180. if (outSen > 0) Senret = "detect";
  4181. else Senret = "undetect";
  4182. resultStr += " <list name=\"in_move\" count=\"0\" value=\"" + Senret + "\" />\r\n";
  4183. senIDX++;
  4184. } else {
  4185. if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4186. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4187. String Senret;
  4188. if (outSen > 0) Senret = "detect";
  4189. else Senret = "undetect";
  4190. resultStr += " <list name=\"in_move\" value=\"" + Senret + "\" />\r\n";
  4191. senIDX++;
  4192. }
  4193. if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4194. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4195. String Senret;
  4196. if (outSen > 0) Senret = "detect";
  4197. else Senret = "undetect";
  4198. resultStr += " <list name=\"out_move\" value=\"" + Senret + "\" />\r\n";
  4199. senIDX++;
  4200. }
  4201. }
  4202. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4203. String Senret;
  4204. if (outSen > 0) Senret = "detect";
  4205. else Senret = "undetect";
  4206. resultStr += " <list name=\"magnetic\" value=\"" + Senret + "\" />\r\n";
  4207. senIDX++;
  4208. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4209. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4210. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4211. if (outSen > 0) Senret = "detect";
  4212. else Senret = "undetect";
  4213. resultStr += " <list name=\"emergency\" value=\"" + Senret + "\" />\r\n";
  4214. senIDX++;
  4215. }
  4216. DBMGR.closeDB();
  4217. }
  4218. if (senIDX > 0) {
  4219. RetVal += " <setting name = \"sensor_state\" count = \"" + senIDX + "\" value = \"list\" >\r\n";
  4220. RetVal += resultStr;
  4221. RetVal += " </setting>\r\n";
  4222. }
  4223. } else if (data.equals("statusbeat_time")) {
  4224. } else {
  4225. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"\" />\r\n";
  4226. }
  4227. }
  4228. }
  4229. } catch (RuntimeException re) {
  4230. LogUtil.errorLogInfo("", TAG, re);
  4231. } catch (Exception e) {
  4232. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4233. //e.printStackTrace();
  4234. LogUtil.errorLogInfo("", TAG, e);
  4235. }
  4236. SettManager.closeDB();
  4237. RetVal += " </guidemap>\r\n </service>\r\n</imap>";
  4238. return RetVal;
  4239. }
  4240. public void ProcElevatorinfo(Element ele) {
  4241. try {
  4242. String floor;
  4243. String move_dir;
  4244. /*
  4245. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4246. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4247. Node info = evinfo.item(0);
  4248. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4249. if (info != null)
  4250. {
  4251. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4252. }
  4253. */
  4254. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4255. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
  4256. Node iinfo = ievinfo.item(0);
  4257. if (iinfo == null) {
  4258. Log.d("iMapServer", "func ProcElevatorinfo info == null");
  4259. return;
  4260. }
  4261. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4262. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4263. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4264. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4265. if (move_dir != null) {
  4266. if (move_dir.equalsIgnoreCase("up")) {
  4267. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4268. } else if (move_dir.equalsIgnoreCase("down")) {
  4269. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4270. } else if (move_dir.equalsIgnoreCase("stop")) {
  4271. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4272. } else if (move_dir.equalsIgnoreCase("wrong")) {
  4273. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4274. } else if (move_dir.equalsIgnoreCase("finish")) {
  4275. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4276. }
  4277. Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
  4278. }
  4279. byte updown = 0x00;
  4280. if (ievinfo != null) {
  4281. boolean downCall = false;
  4282. boolean upCall = false;
  4283. for (int i = 0; i < ievinfo.getLength(); i++) {
  4284. Node valItem = ievinfo.item(i);
  4285. if (valItem != null) {
  4286. if (downCall == false) {
  4287. String val = GetAttributeVal(valItem, "ev_call_dir");
  4288. if (val != null)
  4289. downCall = val.equalsIgnoreCase("down");
  4290. }
  4291. if (upCall == false) {
  4292. String val = GetAttributeVal(valItem, "ev_call_dir");
  4293. if (val != null) {
  4294. upCall = val.equalsIgnoreCase("up");
  4295. }
  4296. }
  4297. }
  4298. }
  4299. Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
  4300. if (downCall == true && upCall == true) updown = 0x02;
  4301. else if (downCall == false && upCall == true) updown = 0x01;
  4302. }
  4303. Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  4304. Intent intent = new Intent();
  4305. intent.setAction(define.NOTIFY_ACNAME);
  4306. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  4307. intent.putExtra(define.NOTIBR_FLOOR, floor);
  4308. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  4309. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  4310. getApplicationContext().sendBroadcast(intent);
  4311. } catch (RuntimeException re) {
  4312. LogUtil.errorLogInfo("", TAG, re);
  4313. } catch (Exception e) {
  4314. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  4315. //e.printStackTrace();
  4316. LogUtil.errorLogInfo("", TAG, e);
  4317. }
  4318. }
  4319. private String MakeTargetStr(WallpadiCMDParser data) {
  4320. return " <target name=\"" + data.target + "\" id = \"" + data.tid + "\" msg_no=\"" + data.msgno + "\"/>\r\n";
  4321. }
  4322. public String iCMDProcVentilControl(Document doc) {
  4323. try {
  4324. String unit_status = "null", mode = "null", unit_mode = "null";
  4325. String retStr = CheckiCMDProc("remote_access_ventil");
  4326. if (retStr != null) return retStr;
  4327. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  4328. String target = "null", tid = "null", msgno = "null";
  4329. NodeList items = doc.getElementsByTagName("target");
  4330. Node item = items.item(0);
  4331. if (item != null) {
  4332. NamedNodeMap attrs = item.getAttributes();
  4333. for (int j = 0; j < attrs.getLength(); j++) {
  4334. Node attr = attrs.item(j);
  4335. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4336. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4337. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4338. msgno = attr.getNodeValue();
  4339. }
  4340. }
  4341. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4342. if (NewServerUse()) {
  4343. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4344. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4345. return ServerCheckResult;
  4346. }
  4347. boolean procSucc = true;
  4348. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  4349. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  4350. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  4351. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4352. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  4353. boolean OnOff = false;
  4354. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  4355. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  4356. else procSucc = false;
  4357. } else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  4358. byte strength = 0;
  4359. if (ventilParser.ctraction.equalsIgnoreCase("low"))
  4360. strength = VentiAPI.WIND.LOW;
  4361. else if (ventilParser.ctraction.equalsIgnoreCase("mid"))
  4362. strength = VentiAPI.WIND.MID;
  4363. else strength = VentiAPI.WIND.HI;
  4364. if (VentilCTR.data.OnOff) {
  4365. // 환기가 On인 경우
  4366. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4367. else procSucc = false;
  4368. } else {
  4369. // 환기가 Off인 경우
  4370. if (VentilCTR.SetOnOff(true) >= 0) {
  4371. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4372. else procSucc = false;
  4373. } else {
  4374. procSucc = false;
  4375. }
  4376. }
  4377. }
  4378. if (VentilCTR.Refresh(true) == 0) {
  4379. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4380. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4381. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4382. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4383. else unit_status = "unknown";
  4384. if (VentilCTR.data.Support.AutoDriving) {
  4385. mode = "normal/auto";
  4386. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4387. else unit_mode = "normal";
  4388. } else {
  4389. mode = "normal";
  4390. unit_mode = "normal";
  4391. }
  4392. } else {
  4393. procSucc = false;
  4394. }
  4395. } else {
  4396. procSucc = false;
  4397. }
  4398. } else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4399. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4400. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4401. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4402. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4403. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4404. else unit_status = "unknown";
  4405. if (VentilCTR.data.Support.AutoDriving) {
  4406. mode = "normal/auto";
  4407. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4408. else unit_mode = "normal";
  4409. } else {
  4410. mode = "normal";
  4411. unit_mode = "normal";
  4412. }
  4413. } else {
  4414. procSucc = false;
  4415. }
  4416. } else {
  4417. procSucc = false;
  4418. }
  4419. if (procSucc == false) {
  4420. retStr += (" result=\"fail\" >\r\n");
  4421. unit_status = "unknown";
  4422. } else {
  4423. retStr += (" result=\"ok\" >\r\n");
  4424. }
  4425. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4426. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4427. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4428. // retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4429. retStr += " <status_info unit_num=\"ventil\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4430. return retStr;
  4431. } catch (RuntimeException re) {
  4432. LogUtil.errorLogInfo("", TAG, re);
  4433. return null;
  4434. } catch (Exception e) {
  4435. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4436. //e.printStackTrace();
  4437. LogUtil.errorLogInfo("", TAG, e);
  4438. return null;
  4439. }
  4440. }
  4441. public String iCMDProcTemperControl(Document doc) {
  4442. try {
  4443. String target = "null", tid = "null", msgno = "null";
  4444. String retStr = CheckiCMDProc("remote_access_temper");
  4445. if (retStr != null) return retStr;
  4446. else
  4447. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4448. NodeList items = doc.getElementsByTagName("target");
  4449. Node item = items.item(0);
  4450. if (item != null) {
  4451. NamedNodeMap attrs = item.getAttributes();
  4452. for (int j = 0; j < attrs.getLength(); j++) {
  4453. Node attr = attrs.item(j);
  4454. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4455. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4456. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4457. }
  4458. }
  4459. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4460. if (NewServerUse()) {
  4461. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4462. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4463. return ServerCheckResult;
  4464. }
  4465. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4466. //String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4467. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4468. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_HEATING);
  4469. if(knxRoomNameList==null) knxRoomNameList = mDefaultRoomNameList_Heating;
  4470. // 난방 종류를 얻어온다.
  4471. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4472. HeatingV1API heatingV1API = null;
  4473. HeatingV2API heatingV2API = null;
  4474. // 종류별 API를 로딩한다.
  4475. if (HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4476. else if (HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4477. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4478. if (tempercmd.actionTXT.equals("control")) {
  4479. String[] CtrList;
  4480. byte ctrl = 0;
  4481. byte roomNum = (byte) 0xFF;
  4482. double temp = 0;
  4483. if (tempercmd.unitnum.equals("all")) {
  4484. if (tempercmd.ctraction.equals("on")) {
  4485. ctrl = 1;
  4486. } else if (tempercmd.ctraction.equals("off")) {
  4487. ctrl = 0;
  4488. } else {
  4489. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\" />\r\n </service>\r\n</imap> ";
  4490. return retStr;
  4491. }
  4492. } else {
  4493. CtrList = tempercmd.ctraction.split("/");
  4494. if (CtrList[0].equals("on")) ctrl = 1;
  4495. else ctrl = 0;
  4496. roomNum = (byte) 0xFF;
  4497. temp = Double.parseDouble(CtrList[1]);
  4498. }
  4499. if (HeatingKind == 1) {
  4500. boolean OnOff = false;
  4501. if (ctrl == 1) OnOff = true;
  4502. if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
  4503. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4504. if (ret != APIErrorCode.C_SUCCESS) {
  4505. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4506. return retStr;
  4507. }
  4508. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4509. } else {
  4510. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4511. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4512. roomNum = i;
  4513. break;
  4514. }
  4515. }
  4516. if (roomNum == (byte) 0xFF) {
  4517. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4518. return retStr;
  4519. }
  4520. if (heatingV1API != null) {
  4521. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
  4522. if (ret != APIErrorCode.C_SUCCESS) {
  4523. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4524. return retStr;
  4525. }
  4526. heatingV1API.Refresh(roomNum, false);
  4527. }
  4528. }
  4529. }
  4530. else if (HeatingKind == 2) {
  4531. byte Mode = HeatingV2.MODE.HeatingOFF;
  4532. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4533. if (tempercmd.unitnum.equals("all")) {
  4534. if (heatingV2API != null) {
  4535. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4536. if (ret != APIErrorCode.C_SUCCESS) {
  4537. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4538. return retStr;
  4539. }
  4540. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4541. }
  4542. } else {
  4543. int nDevNum = Integer.parseInt(tempercmd.devnum)-1;
  4544. if (heatingV2API != null) {
  4545. int ret = heatingV2API.SetEachRoomStatus((byte) nDevNum, Mode, temp);
  4546. if (ret != APIErrorCode.C_SUCCESS) {
  4547. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4548. return retStr;
  4549. }
  4550. heatingV2API.Refresh((byte) nDevNum, false);
  4551. }
  4552. }
  4553. }
  4554. else {
  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. }
  4559. String resultStr = " <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4560. if (HeatingKind == 1) {
  4561. try {
  4562. if (heatingV1API == null) {
  4563. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4564. return retStr;
  4565. }
  4566. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4567. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4568. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount + "\"/>\r\n";
  4569. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4570. String drvmode = "off";
  4571. for (byte i = 0; i < RoomCount; i++) {
  4572. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4573. if (roomData.bOnOff) drvmode = "on";
  4574. else drvmode = "off";
  4575. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4576. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4577. }
  4578. resultStr += " </service>\r\n</imap>\r\n";
  4579. retStr += ("\"ok\">\r\n" + resultStr);
  4580. return retStr;
  4581. } else {
  4582. String drvmode = "off";
  4583. byte roomNum = (byte) 0xFF;
  4584. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4585. if (tempercmd.unitnum.equals(knxRoomNameList[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. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4595. if (roomData.bOnOff) drvmode = "on";
  4596. else drvmode = "off";
  4597. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4598. resultStr += " <status_info unit_num=\"" + knxRoomNameList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4599. resultStr += " </service>\r\n</imap>\r\n";
  4600. retStr += ("\"ok\">\r\n" + resultStr);
  4601. return retStr;
  4602. }
  4603. } catch (RuntimeException re) {
  4604. LogUtil.errorLogInfo("", TAG, re);
  4605. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4606. return retStr;
  4607. } catch (Exception e) {
  4608. //e.printStackTrace();
  4609. LogUtil.errorLogInfo("", TAG, e);
  4610. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4611. return retStr;
  4612. }
  4613. }
  4614. else if (HeatingKind == 2) {
  4615. try {
  4616. if (heatingV2API == null) {
  4617. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4618. return retStr;
  4619. }
  4620. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4621. resultStr += " <action> \"" + tempercmd.actionTXT + "\"</action>\r\n";
  4622. //resultStr += " <status_map dev_num=\"1\" unit_cnt = \"" + RoomCount + "\" />\r\n";
  4623. if ((tempercmd.devnum.equals("all"))) {
  4624. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
  4625. String drvmode = "off";
  4626. for (byte i = 0; i < RoomCount; i++) {
  4627. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4628. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4629. else drvmode = "off";
  4630. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4631. resultStr += " <status_map dev_num=\"" + (i+1) + "\" unit_cnt = \"1\"/>\r\n";
  4632. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4633. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + knxRoomNameList[i] + "\"/>\r\n";
  4634. } else {
  4635. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4636. }
  4637. }
  4638. resultStr += " </service>\r\n</imap>\r\n";
  4639. retStr += ("\"ok\">\r\n" + resultStr);
  4640. return retStr;
  4641. }
  4642. else {
  4643. String drvmode = "off";
  4644. int nDevNum = Integer.parseInt(tempercmd.devnum);
  4645. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum-1];
  4646. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4647. else drvmode = "off";
  4648. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4649. resultStr += " <status_map dev_num=\"" + (nDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  4650. resultStr += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4651. resultStr += " </service>\r\n</imap>\r\n";
  4652. retStr += ("\"ok\">\r\n" + resultStr);
  4653. return retStr;
  4654. }
  4655. } catch (RuntimeException re) {
  4656. LogUtil.errorLogInfo("", TAG, re);
  4657. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4658. return retStr;
  4659. } catch (Exception e) {
  4660. //e.printStackTrace();
  4661. LogUtil.errorLogInfo("", TAG, e);
  4662. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4663. return retStr;
  4664. }
  4665. } else {
  4666. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
  4667. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4668. return retStr;
  4669. }
  4670. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4671. // return retStr;
  4672. } catch (RuntimeException re) {
  4673. LogUtil.errorLogInfo("", TAG, re);
  4674. return null;
  4675. } catch (Exception e) {
  4676. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4677. //e.printStackTrace();
  4678. LogUtil.errorLogInfo("", TAG, e);
  4679. return null;
  4680. }
  4681. }
  4682. public String iCMDProcDoorlockControl(Document doc) {
  4683. try {
  4684. String DLStatus = "none";
  4685. String strResult = CheckiCMDProc("remote_access_doorlock");
  4686. if (strResult != null) return strResult;
  4687. else
  4688. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4689. String target = "null", tid = "null", msgno = "null";
  4690. NodeList items = doc.getElementsByTagName("target");
  4691. Node item = items.item(0);
  4692. if (item != null) {
  4693. NamedNodeMap attrs = item.getAttributes();
  4694. for (int j = 0; j < attrs.getLength(); j++) {
  4695. Node attr = attrs.item(j);
  4696. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4697. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4698. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4699. msgno = attr.getNodeValue();
  4700. }
  4701. }
  4702. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4703. if (NewServerUse()) {
  4704. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4705. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4706. return ServerCheckResult;
  4707. }
  4708. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4709. try {
  4710. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4711. if (doorStatus != null) {
  4712. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4713. DLStatus = "unknown";
  4714. } else {
  4715. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce)
  4716. DLStatus = "close";
  4717. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce)
  4718. DLStatus = "open";
  4719. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation)
  4720. DLStatus = "ing";
  4721. else DLStatus = "unknown";
  4722. }
  4723. }
  4724. } catch (RuntimeException re) {
  4725. LogUtil.errorLogInfo("", TAG, re);
  4726. DLStatus = "unknown";
  4727. } catch (Exception e) {
  4728. //e.printStackTrace();
  4729. LogUtil.errorLogInfo("", TAG, e);
  4730. DLStatus = "unknown";
  4731. }
  4732. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n" +
  4733. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n" +
  4734. " <action>\"status\"</action>\r\n" +
  4735. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n" +
  4736. " <status_info unit_num=\"doorlock1\" unit_status=\"" + DLStatus + "\"/>\r\n </service>\r\n</imap>";
  4737. return retXML;
  4738. } catch (RuntimeException re) {
  4739. LogUtil.errorLogInfo("", TAG, re);
  4740. return null;
  4741. } catch (Exception e) {
  4742. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4743. //e.printStackTrace();
  4744. LogUtil.errorLogInfo("", TAG, e);
  4745. return null;
  4746. }
  4747. }
  4748. /*
  4749. protected String iCMDProcsavelog(Document doc)
  4750. {
  4751. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4752. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4753. NodeList items = doc.getElementsByTagName("guidemap");
  4754. Node item = items.item(0);
  4755. NamedNodeMap attrsParam = item.getAttributes();
  4756. for(int j=0; j< attrsParam.getLength();j++)
  4757. {
  4758. Node attr = attrsParam.item(j);
  4759. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4760. {
  4761. String enable = attr.getNodeValue();
  4762. if (enable == null) return FailretStr;
  4763. if (enable.equals("false"))
  4764. {
  4765. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4766. logSet.SetLogDoing(0);
  4767. logSet.closeDB();
  4768. return SucretStr;
  4769. }
  4770. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4771. logSet.SetLogDoing(1);
  4772. logSet.closeDB();
  4773. }
  4774. }
  4775. items = doc.getElementsByTagName("setting");
  4776. item = items.item(0);
  4777. attrsParam = item.getAttributes();
  4778. String SaveType = "";
  4779. String FtpLoc = "";
  4780. String Ftpuser = "";
  4781. String FtpPW= "";
  4782. String period = "";
  4783. String FileSize = "";
  4784. for(int j=0; j< attrsParam.getLength();j++)
  4785. {
  4786. Node attr = attrsParam.item(j);
  4787. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4788. SaveType = attr.getNodeValue();
  4789. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4790. FtpLoc = attr.getNodeValue();
  4791. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4792. Ftpuser = attr.getNodeValue();
  4793. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4794. FtpPW = attr.getNodeValue();
  4795. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4796. period = attr.getNodeValue();
  4797. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4798. FileSize = attr.getNodeValue();
  4799. }
  4800. if (SaveType.equalsIgnoreCase("now"))
  4801. {
  4802. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4803. LogUpThread.start();
  4804. return SucretStr;
  4805. }
  4806. else if (SaveType.equalsIgnoreCase("periodic"))
  4807. {
  4808. try
  4809. {
  4810. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4811. period = period.trim();
  4812. String[] logperiod = period.split("[-]");
  4813. String StartDate = logperiod[0].replace(".", "_");
  4814. String EndDate = logperiod[1].replace(".", "_");
  4815. logSet.SetLogDoing(1);
  4816. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4817. if (FileSize.equalsIgnoreCase("null"))
  4818. logSet.SetLogLogFileSize(0);
  4819. else
  4820. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4821. logSet.SetLogStartDate(StartDate);
  4822. logSet.SetLogEndDate(EndDate);
  4823. logSet.closeDB();
  4824. return SucretStr;
  4825. }
  4826. catch (RuntimeException re) {
  4827. LogUtil.errorLogInfo("", TAG, re);
  4828. }
  4829. catch (Exception e)
  4830. {
  4831. e.printStackTrace();
  4832. return FailretStr;
  4833. }
  4834. }
  4835. else
  4836. {
  4837. return FailretStr;
  4838. }
  4839. }
  4840. */
  4841. protected void SendLogSaved(String ftploc, String fname, String size) {
  4842. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n" +
  4843. " <device_info devtype=\"homedev\" id_high=\"" + AddrDong + "\" id_low=\"" + AddrHo + "\"/>\r\n" +
  4844. " <file_info path=\"" + ftploc + "\" name=\"" + fname + "\" size=\"" + size + "\"/>\r\n</service>\r\n</imap>";
  4845. SendToServer(SendMsg);
  4846. }
  4847. public final static int FTPLOGTRSUCC = 1110;
  4848. public final static int FTPLOGTRFAIL = 1120;
  4849. Handler FileTrHandler = new Handler() {
  4850. public void handleMessage(Message msg) {
  4851. switch (msg.what) {
  4852. case FTPLOGTRSUCC:
  4853. String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4854. File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
  4855. int size = (int) (fileinfo.length() / 1024);
  4856. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4857. imapsvrlog("FTPLOGTRSUCC");
  4858. break;
  4859. case FTPLOGTRFAIL:
  4860. imapsvrlog("FTPLOGTRFAIL");
  4861. break;
  4862. }
  4863. }
  4864. };
  4865. class LogUploader extends Thread {
  4866. int fileidx = 0;
  4867. boolean TRing = false;
  4868. String FtpLoc;
  4869. String FtpID;
  4870. String FtpPasswd;
  4871. class ftpuploader extends WallPadFTPUploader {
  4872. String filename;
  4873. public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
  4874. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
  4875. filename = LocalFile;
  4876. }
  4877. protected void ProcUploadFail() {
  4878. Message TrResult = FileTrHandler.obtainMessage();
  4879. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4880. TrResult.what = FTPLOGTRFAIL;
  4881. TRing = false;
  4882. imapsvrlog("Send Log Fail Message");
  4883. FileTrHandler.sendMessage(TrResult);
  4884. }
  4885. protected void ProcUploadSuccess() {
  4886. Message TrResult = FileTrHandler.obtainMessage();
  4887. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4888. TrResult.what = FTPLOGTRSUCC;
  4889. TRing = false;
  4890. imapsvrlog("Send Log success Message");
  4891. FileTrHandler.sendMessage(TrResult);
  4892. }
  4893. }
  4894. public LogUploader(String loc, String user, String pw) {
  4895. FtpLoc = loc;
  4896. FtpID = user;
  4897. FtpPasswd = pw;
  4898. }
  4899. public void run() {
  4900. File LogLoc = new File(define.LOG_FILE_LOCATION);
  4901. String[] LogFileList = LogLoc.list();
  4902. while (true) {
  4903. if (TRing == false) {
  4904. if (LogFileList != null && fileidx < LogFileList.length) {
  4905. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
  4906. fileidx++;
  4907. TRing = true;
  4908. uploader.start();
  4909. } else
  4910. return;
  4911. }
  4912. try {
  4913. Thread.sleep(500);
  4914. } catch (RuntimeException re) {
  4915. LogUtil.errorLogInfo("", TAG, re);
  4916. } catch (Exception e) {
  4917. LogUtil.errorLogInfo("", TAG, e);
  4918. }
  4919. }
  4920. }
  4921. }
  4922. public String iCMDProcDevList(Document ele) {
  4923. try {
  4924. String strResult = CheckiCMDProc("remote_get_home_devices");
  4925. if (strResult != null) return strResult;
  4926. else
  4927. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" ";
  4928. String target = "null", tid = "null", msgno = "null";
  4929. NodeList items = ele.getElementsByTagName("target");
  4930. Node item = items.item(0);
  4931. if (item != null) {
  4932. NamedNodeMap attrs = item.getAttributes();
  4933. for (int j = 0; j < attrs.getLength(); j++) {
  4934. Node attr = attrs.item(j);
  4935. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4936. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4937. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4938. msgno = attr.getNodeValue();
  4939. }
  4940. }
  4941. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4942. if (NewServerUse()) {
  4943. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  4944. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4945. return ServerCheckResult;
  4946. }
  4947. GasAPI mGasAPI = null;
  4948. CooktopAPI mCooktopAPI = null;
  4949. if (mWallPadAPI.GetGasKind() == 1) {
  4950. mGasAPI = mWallPadAPI.Get_GasController();
  4951. } else if (mWallPadAPI.GetGasKind() == 2) {
  4952. mCooktopAPI = mWallPadAPI.Get_CookTopController();
  4953. }
  4954. Log.i(TAG, "[iCMDProcDevList] bLightCMDUseAsSmartLight: " + bLightCMDUseAsSmartLight);
  4955. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  4956. int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  4957. String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
  4958. int nConcentEnable = mWallpadDeviceSet.Get_Concent_Info(); // 콘센트 사용 유무
  4959. mWallpadDeviceSet.closeDB();
  4960. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  4961. String[] devlist;
  4962. if(nConcentEnable==1){
  4963. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
  4964. } else {
  4965. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "smartlight", "cooktop", "sysaircon"};
  4966. }
  4967. strResult += "result=\"ok\">\r\n";
  4968. strResult += " <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
  4969. strResult += " <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
  4970. //strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  4971. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  4972. String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
  4973. String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
  4974. String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
  4975. strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
  4976. strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
  4977. strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
  4978. for (int i = 0; i < devlist.length; i++) {
  4979. if (devlist[i].equals("cooktop")) {
  4980. if (mWallPadAPI.GetGasKind() == 1) {
  4981. // 가스밸브
  4982. int Gasinfo = devSet.Get_GAS_Info();
  4983. if (Gasinfo == 1) {
  4984. // 사용함
  4985. if (bGasAsCooktopOutlet) {
  4986. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4987. strResult += " <devinfo name=\"cooktop\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4988. } else {
  4989. strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4990. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4991. }
  4992. } else {
  4993. // 사용안함
  4994. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4995. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4996. }
  4997. } else if (mWallPadAPI.GetGasKind() == 2) {
  4998. // 하이브리드 쿡탑
  4999. // 쿡탑 최대로 연동 안됨
  5000. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5001. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5002. /*
  5003. if (mCooktopAPI != null) {
  5004. int ret = mCooktopAPI.Refresh((byte) 0xFF, false);
  5005. int nGas = 0;
  5006. int nOutlet = 0;
  5007. if (ret >= 0) {
  5008. for (int k = 0; k < mCooktopAPI.data.Device[0].circuit.length; k++) {
  5009. if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
  5010. nGas++;
  5011. else if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
  5012. nOutlet++;
  5013. }
  5014. strResult += " <devinfo name=\"gas\" value=\"" + nGas + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5015. strResult += " <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5016. }
  5017. }
  5018. */
  5019. } else {
  5020. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5021. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5022. }
  5023. }
  5024. else if (devlist[i].equals("doorlock")) {
  5025. try {
  5026. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5027. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5028. strResult += " <devinfo name=\"doorlock\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5029. } else {
  5030. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5031. }
  5032. } catch (RuntimeException re) {
  5033. LogUtil.errorLogInfo("", TAG, re);
  5034. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5035. } catch (Exception e) {
  5036. //e.printStackTrace();
  5037. LogUtil.errorLogInfo("", TAG, e);
  5038. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5039. }
  5040. }
  5041. else if (devlist[i].equals("light")) {
  5042. try {
  5043. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5044. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5045. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5046. if (bLightCMDUseAsSmartLight) {
  5047. if (mSdbAPI != null) {
  5048. strResult += " <devinfo name=\"light\" value=\"" + mSdbAPI.data.BadRoom_Em_Count + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5049. } else {
  5050. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5051. }
  5052. } else {
  5053. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5054. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5055. }
  5056. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5057. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5058. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5059. strResult += " <devinfo name=\"light\" value=\"" + energymeter.data.RoomCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5060. } else {
  5061. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5062. }
  5063. } else {
  5064. int[] lightinfo = devSet.Get_Light_info();
  5065. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5066. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5067. } else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5068. strResult += " <devinfo name=\"light\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5069. } else {
  5070. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5071. int ret = multisw.Refresh((byte) 0xFF, false);
  5072. if (ret < 0 || multisw.data.DeviceCnt < 1)
  5073. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5074. else
  5075. strResult += " <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5076. }
  5077. }
  5078. } catch (RuntimeException re) {
  5079. LogUtil.errorLogInfo("", TAG, re);
  5080. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5081. } catch (Exception e) {
  5082. //e.printStackTrace();
  5083. LogUtil.errorLogInfo("", TAG, e);
  5084. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5085. }
  5086. }
  5087. else if (devlist[i].equals("livinglight")) {
  5088. try {
  5089. int[] lightinfo = devSet.Get_Light_info();
  5090. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5091. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5092. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5093. if (bLightCMDUseAsSmartLight) {
  5094. if (mSdb_LivingRoomLightAPI != null) {
  5095. strResult += " <devinfo name=\"livinglight\" value=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5096. } else {
  5097. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5098. }
  5099. } else {
  5100. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5101. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5102. }
  5103. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5104. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5105. } else {
  5106. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5107. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5108. } else {
  5109. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5110. }
  5111. }
  5112. } catch (RuntimeException re) {
  5113. LogUtil.errorLogInfo("", TAG, re);
  5114. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5115. } catch (Exception e) {
  5116. //e.printStackTrace();
  5117. LogUtil.errorLogInfo("", TAG, e);
  5118. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5119. }
  5120. }
  5121. else if (devlist[i].equals("ventil")) {
  5122. try {
  5123. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5124. if (Ventilinfo[0] == 0)
  5125. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5126. else
  5127. strResult += " <devinfo name=\"ventil\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5128. } catch (RuntimeException re) {
  5129. LogUtil.errorLogInfo("", TAG, re);
  5130. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5131. } catch (Exception e) {
  5132. //e.printStackTrace();
  5133. LogUtil.errorLogInfo("", TAG, e);
  5134. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5135. }
  5136. }
  5137. else if (devlist[i].equals("thermostat")) {
  5138. try {
  5139. int Temperinfo = devSet.Get_Temper_Info();
  5140. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5141. HeatingV1API heatingV1API = null;
  5142. HeatingV2API heatingV2API = null;
  5143. byte RoomCount = 0;
  5144. // 종류별 API를 로딩한다.
  5145. if (HeatingKind == 1) {
  5146. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5147. if (heatingV1API != null) {
  5148. RoomCount = heatingV1API.data.Device.RoomCount;
  5149. }
  5150. } else if (HeatingKind == 2) {
  5151. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5152. if (heatingV2API != null) {
  5153. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5154. }
  5155. }
  5156. if (Temperinfo == 0)
  5157. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5158. else
  5159. strResult += " <devinfo name=\"thermostat\" value=\"" + RoomCount + "\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5160. } catch (RuntimeException re) {
  5161. LogUtil.errorLogInfo("", TAG, re);
  5162. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5163. } catch (Exception e) {
  5164. //e.printStackTrace();
  5165. LogUtil.errorLogInfo("", TAG, e);
  5166. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5167. }
  5168. }
  5169. else if (devlist[i].equals("curtain")) {
  5170. try {
  5171. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5172. if (Curtaininfo[0] == 0)
  5173. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5174. else
  5175. strResult += " <devinfo name=\"curtain\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5176. } catch (RuntimeException re) {
  5177. LogUtil.errorLogInfo("", TAG, re);
  5178. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5179. } catch (Exception e) {
  5180. //e.printStackTrace();
  5181. LogUtil.errorLogInfo("", TAG, e);
  5182. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5183. }
  5184. }
  5185. else if (devlist[i].equals("electric")) {
  5186. try {
  5187. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5188. // 청담 콘센트 처리
  5189. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5190. int BadConcentCount = 0;
  5191. if (KnxApi != null) {
  5192. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5193. if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
  5194. BadConcentCount = 1;
  5195. }
  5196. int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  5197. for (int k = 0; k < BadConCount; k++) {
  5198. if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
  5199. BadConcentCount++;
  5200. }
  5201. Log.d(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
  5202. strResult += " <devinfo name=\"electric\" value=\"" + BadConcentCount + "\" floor=\"" + ho + "\"/>\r\n";
  5203. }
  5204. } else {
  5205. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5206. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5207. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5208. int nOutlet = 0;
  5209. if (mSdb_LivingRoomLightAPI != null) {
  5210. if (mSdbAPI != null) {
  5211. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5212. } else {
  5213. nOutlet = 1;
  5214. }
  5215. } else {
  5216. if (mSdbAPI != null) {
  5217. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5218. } else {
  5219. nOutlet = 0;
  5220. }
  5221. }
  5222. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"" + ho + "\"/>\r\n";
  5223. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5224. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5225. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5226. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"" + ho + "\"/>\r\n";
  5227. } else {
  5228. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5229. }
  5230. } else {
  5231. int[] lightinfo = devSet.Get_Light_info();
  5232. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5233. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5234. } else {
  5235. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5236. int ret = multisw.Refresh((byte) 0xFF, false);
  5237. if (ret < 0 || multisw.data.DeviceCnt < 1) {
  5238. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5239. } else {
  5240. int DeviceCount = 0;
  5241. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5242. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5243. DeviceCount++;
  5244. }
  5245. }
  5246. strResult += " <devinfo name=\"electric\" value=\"" + DeviceCount + "\" floor=\"" + ho + "\"/>\r\n";
  5247. }
  5248. }
  5249. }
  5250. }
  5251. } catch (RuntimeException re) {
  5252. LogUtil.errorLogInfo("", TAG, re);
  5253. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5254. } catch (Exception e) {
  5255. //e.printStackTrace();
  5256. LogUtil.errorLogInfo("", TAG, e);
  5257. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5258. }
  5259. }
  5260. else if (devlist[i].equals("smartlight")) {
  5261. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5262. // KNX 조명 처리
  5263. try {
  5264. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5265. if (KnxApi != null) {
  5266. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5267. if (KnxApi.data == null)
  5268. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
  5269. if (KnxApi.data.MasterController == null)
  5270. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
  5271. if (ret >= 0) {
  5272. int LivingLightCount = 0;
  5273. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  5274. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  5275. } else {
  5276. if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  5277. LivingLightCount = 1;
  5278. }
  5279. int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount + KnxApi.data.MasterController.Info.Light_SwitchCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
  5280. strResult += " <devinfo name=\"smartlight\" value=\"" + AllEMcount + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5281. }
  5282. }
  5283. } catch (Exception ek) {
  5284. strResult += " <devinfo name=\"smartlight\" value=\"" + 0 + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5285. }
  5286. } else {
  5287. if (!bLightCMDUseAsSmartLight) {
  5288. int nSmartLight = 0;
  5289. if (mSdb_LivingRoomLightAPI != null) {
  5290. if (mSdbAPI != null) {
  5291. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5292. } else {
  5293. nSmartLight = 1;
  5294. }
  5295. } else {
  5296. if (mSdbAPI != null) {
  5297. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5298. } else {
  5299. nSmartLight = 0;
  5300. }
  5301. }
  5302. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5303. }
  5304. }
  5305. }
  5306. else if (devlist[i].equals("sysaircon")) {
  5307. // 에어컨 처리
  5308. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5309. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  5310. if (airconAPI != null) {
  5311. int nCount = airconAPI.data.Device.info.InsideAirconCount;
  5312. Log.d(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
  5313. // 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
  5314. strResult += " <devinfo name=\"sysaircon\" value=\"" + nCount + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5315. } else {
  5316. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5317. }
  5318. } else {
  5319. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5320. }
  5321. }
  5322. }
  5323. //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
  5324. strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5325. strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5326. if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
  5327. strResult += remote_get_home_devices1;
  5328. }
  5329. if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
  5330. strResult += remote_get_home_devices2;
  5331. }
  5332. if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
  5333. strResult += remote_get_home_devices3;
  5334. }
  5335. /*
  5336. for (int i = 0; i < devlist.length; i++) {
  5337. if (devlist[i].equals("cooktop")) {
  5338. if (mWallPadAPI.GetGasKind() == 1) {
  5339. // 가스밸브
  5340. int Gasinfo = devSet.Get_GAS_Info();
  5341. if (Gasinfo == 1) {
  5342. // 사용함
  5343. if (bGasAsCooktopOutlet) {
  5344. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5345. strResult +=" <devinfo name=\"cooktop\" value=\"1\" floor=\"2\"/>\r\n";
  5346. }
  5347. else {
  5348. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n";
  5349. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5350. }
  5351. }
  5352. else {
  5353. // 사용안함
  5354. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5355. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5356. }
  5357. }
  5358. else if (mWallPadAPI.GetGasKind() == 2) {
  5359. // 하이브리드 쿡탑
  5360. if (mCooktopAPI != null) {
  5361. int nGas = 0; int nOutlet = 0;
  5362. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5363. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5364. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5365. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5366. }
  5367. }
  5368. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"2\"/>\r\n";
  5369. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5370. }
  5371. }
  5372. else {
  5373. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5374. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5375. }
  5376. }
  5377. else if (devlist[i].equals("doorlock")) {
  5378. try {
  5379. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5380. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5381. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"2\"/>\r\n";
  5382. }
  5383. else {
  5384. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5385. }
  5386. } catch (RuntimeException re) {
  5387. LogUtil.errorLogInfo("", TAG, re);
  5388. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5389. }
  5390. catch (Exception e) {
  5391. //e.printStackTrace();
  5392. LogUtil.errorLogInfo("", TAG, e);
  5393. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5394. }
  5395. }
  5396. else if (devlist[i].equals("light")) {
  5397. try {
  5398. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5399. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5400. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5401. if (bLightCMDUseAsSmartLight) {
  5402. if (mSdbAPI != null) {
  5403. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"2\"/>\r\n";
  5404. }
  5405. else {
  5406. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5407. }
  5408. }
  5409. else {
  5410. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5411. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5412. }
  5413. }
  5414. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5415. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5416. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5417. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"2\"/>\r\n";
  5418. }
  5419. else {
  5420. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5421. }
  5422. }
  5423. else {
  5424. int[] lightinfo = devSet.Get_Light_info();
  5425. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5426. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5427. }
  5428. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5429. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"2\"/>\r\n";
  5430. }
  5431. else {
  5432. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5433. int ret = multisw.Refresh((byte)0xFF, false);
  5434. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5435. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"2\"/>\r\n";
  5436. }
  5437. }
  5438. } catch (RuntimeException re) {
  5439. LogUtil.errorLogInfo("", TAG, re);
  5440. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5441. }
  5442. catch (Exception e) {
  5443. //e.printStackTrace();
  5444. LogUtil.errorLogInfo("", TAG, e);
  5445. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5446. }
  5447. }
  5448. else if (devlist[i].equals("livinglight")) {
  5449. try {
  5450. int[] lightinfo = devSet.Get_Light_info();
  5451. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5452. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5453. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5454. if (bLightCMDUseAsSmartLight) {
  5455. if (mSdb_LivingRoomLightAPI != null) {
  5456. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"2\"/>\r\n";
  5457. }
  5458. else {
  5459. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5460. }
  5461. }
  5462. else {
  5463. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5464. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5465. }
  5466. }
  5467. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5468. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5469. }
  5470. else {
  5471. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5472. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5473. }
  5474. else {
  5475. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5476. }
  5477. }
  5478. } catch (RuntimeException re) {
  5479. LogUtil.errorLogInfo("", TAG, re);
  5480. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5481. }
  5482. catch (Exception e) {
  5483. //e.printStackTrace();
  5484. LogUtil.errorLogInfo("", TAG, e);
  5485. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5486. }
  5487. }
  5488. else if (devlist[i].equals("ventil")) {
  5489. try {
  5490. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5491. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5492. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n";
  5493. } catch (RuntimeException re) {
  5494. LogUtil.errorLogInfo("", TAG, re);
  5495. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5496. }
  5497. catch (Exception e) {
  5498. //e.printStackTrace();
  5499. LogUtil.errorLogInfo("", TAG, e);
  5500. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5501. }
  5502. }
  5503. else if (devlist[i].equals("thermostat")) {
  5504. try {
  5505. int Temperinfo = devSet.Get_Temper_Info();
  5506. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5507. HeatingV1API heatingV1API = null;
  5508. HeatingV2API heatingV2API = null;
  5509. byte RoomCount = 0;
  5510. // 종류별 API를 로딩한다.
  5511. if (HeatingKind == 1) {
  5512. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5513. if (heatingV1API != null) {
  5514. RoomCount = heatingV1API.data.Device.RoomCount;
  5515. }
  5516. }
  5517. else if (HeatingKind == 2) {
  5518. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5519. if (heatingV2API != null) {
  5520. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5521. }
  5522. }
  5523. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5524. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"2\"/>\r\n";
  5525. } catch (RuntimeException re) {
  5526. LogUtil.errorLogInfo("", TAG, re);
  5527. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5528. }
  5529. catch (Exception e) {
  5530. //e.printStackTrace();
  5531. LogUtil.errorLogInfo("", TAG, e);
  5532. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5533. }
  5534. }
  5535. else if (devlist[i].equals("curtain")) {
  5536. try {
  5537. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5538. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5539. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"2\"/>\r\n";
  5540. } catch (RuntimeException re) {
  5541. LogUtil.errorLogInfo("", TAG, re);
  5542. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5543. }
  5544. catch (Exception e) {
  5545. //e.printStackTrace();
  5546. LogUtil.errorLogInfo("", TAG, e);
  5547. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5548. }
  5549. }
  5550. else if (devlist[i].equals("electric")) {
  5551. try {
  5552. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5553. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5554. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5555. int nOutlet = 0;
  5556. if (mSdb_LivingRoomLightAPI != null) {
  5557. if (mSdbAPI != null) {
  5558. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5559. }
  5560. else {
  5561. nOutlet = 1;
  5562. }
  5563. }
  5564. else {
  5565. if (mSdbAPI != null) {
  5566. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5567. }
  5568. else {
  5569. nOutlet = 0;
  5570. }
  5571. }
  5572. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5573. }
  5574. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5575. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5576. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5577. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"2\"/>\r\n";
  5578. }
  5579. else {
  5580. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5581. }
  5582. }
  5583. else {
  5584. int[] lightinfo = devSet.Get_Light_info();
  5585. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5586. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5587. }
  5588. else {
  5589. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5590. int ret = multisw.Refresh((byte)0xFF, false);
  5591. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5592. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5593. }
  5594. else {
  5595. int DeviceCount = 0;
  5596. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5597. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5598. DeviceCount++;
  5599. }
  5600. }
  5601. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"2\"/>\r\n";
  5602. }
  5603. }
  5604. }
  5605. } catch (RuntimeException re) {
  5606. LogUtil.errorLogInfo("", TAG, re);
  5607. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5608. }
  5609. catch (Exception e) {
  5610. //e.printStackTrace();
  5611. LogUtil.errorLogInfo("", TAG, e);
  5612. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5613. }
  5614. }
  5615. else if (devlist[i].equals("smartlight")) {
  5616. if (!bLightCMDUseAsSmartLight) {
  5617. int nSmartLight = 0;
  5618. if (mSdb_LivingRoomLightAPI != null) {
  5619. if (mSdbAPI != null) {
  5620. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5621. }
  5622. else {
  5623. nSmartLight = 1;
  5624. }
  5625. }
  5626. else {
  5627. if (mSdbAPI != null) {
  5628. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5629. }
  5630. else {
  5631. nSmartLight = 0;
  5632. }
  5633. }
  5634. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"2\"/>\r\n";
  5635. }
  5636. }
  5637. }
  5638. for (int i = 0; i < devlist.length; i++) {
  5639. if (devlist[i].equals("cooktop")) {
  5640. if (mWallPadAPI.GetGasKind() == 1) {
  5641. // 가스밸브
  5642. int Gasinfo = devSet.Get_GAS_Info();
  5643. if (Gasinfo == 1) {
  5644. // 사용함
  5645. if (bGasAsCooktopOutlet) {
  5646. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5647. strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5648. }
  5649. else {
  5650. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n";
  5651. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5652. }
  5653. }
  5654. else {
  5655. // 사용안함
  5656. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5657. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5658. }
  5659. }
  5660. else if (mWallPadAPI.GetGasKind() == 2) {
  5661. // 하이브리드 쿡탑
  5662. if (mCooktopAPI != null) {
  5663. int nGas = 0; int nOutlet = 0;
  5664. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5665. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5666. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5667. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5668. }
  5669. }
  5670. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"3\"/>\r\n";
  5671. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5672. }
  5673. }
  5674. else {
  5675. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5676. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5677. }
  5678. }
  5679. else if (devlist[i].equals("doorlock")) {
  5680. try {
  5681. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5682. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5683. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"3\"/>\r\n";
  5684. }
  5685. else {
  5686. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5687. }
  5688. } catch (RuntimeException re) {
  5689. LogUtil.errorLogInfo("", TAG, re);
  5690. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5691. }
  5692. catch (Exception e) {
  5693. //e.printStackTrace();
  5694. LogUtil.errorLogInfo("", TAG, e);
  5695. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5696. }
  5697. }
  5698. else if (devlist[i].equals("light")) {
  5699. try {
  5700. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5701. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5702. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5703. if (bLightCMDUseAsSmartLight) {
  5704. if (mSdbAPI != null) {
  5705. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"3\"/>\r\n";
  5706. }
  5707. else {
  5708. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5709. }
  5710. }
  5711. else {
  5712. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5713. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5714. }
  5715. }
  5716. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5717. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5718. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5719. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"3\"/>\r\n";
  5720. }
  5721. else {
  5722. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5723. }
  5724. }
  5725. else {
  5726. int[] lightinfo = devSet.Get_Light_info();
  5727. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5728. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5729. }
  5730. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5731. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"3\"/>\r\n";
  5732. }
  5733. else {
  5734. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5735. int ret = multisw.Refresh((byte)0xFF, false);
  5736. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5737. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"3\"/>\r\n";
  5738. }
  5739. }
  5740. } catch (RuntimeException re) {
  5741. LogUtil.errorLogInfo("", TAG, re);
  5742. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5743. }
  5744. catch (Exception e) {
  5745. //e.printStackTrace();
  5746. LogUtil.errorLogInfo("", TAG, e);
  5747. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5748. }
  5749. }
  5750. else if (devlist[i].equals("livinglight")) {
  5751. try {
  5752. int[] lightinfo = devSet.Get_Light_info();
  5753. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5754. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5755. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5756. if (bLightCMDUseAsSmartLight) {
  5757. if (mSdb_LivingRoomLightAPI != null) {
  5758. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"3\"/>\r\n";
  5759. }
  5760. else {
  5761. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5762. }
  5763. }
  5764. else {
  5765. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5766. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5767. }
  5768. }
  5769. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5770. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5771. }
  5772. else {
  5773. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5774. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5775. }
  5776. else {
  5777. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5778. }
  5779. }
  5780. } catch (RuntimeException re) {
  5781. LogUtil.errorLogInfo("", TAG, re);
  5782. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5783. }
  5784. catch (Exception e) {
  5785. //e.printStackTrace();
  5786. LogUtil.errorLogInfo("", TAG, e);
  5787. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5788. }
  5789. }
  5790. else if (devlist[i].equals("ventil")) {
  5791. try {
  5792. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5793. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5794. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n";
  5795. } catch (RuntimeException re) {
  5796. LogUtil.errorLogInfo("", TAG, re);
  5797. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5798. }
  5799. catch (Exception e) {
  5800. //e.printStackTrace();
  5801. LogUtil.errorLogInfo("", TAG, e);
  5802. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5803. }
  5804. }
  5805. else if (devlist[i].equals("thermostat")) {
  5806. try {
  5807. int Temperinfo = devSet.Get_Temper_Info();
  5808. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5809. HeatingV1API heatingV1API = null;
  5810. HeatingV2API heatingV2API = null;
  5811. byte RoomCount = 0;
  5812. // 종류별 API를 로딩한다.
  5813. if (HeatingKind == 1) {
  5814. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5815. if (heatingV1API != null) {
  5816. RoomCount = heatingV1API.data.Device.RoomCount;
  5817. }
  5818. }
  5819. else if (HeatingKind == 2) {
  5820. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5821. if (heatingV2API != null) {
  5822. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5823. }
  5824. }
  5825. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5826. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"3\"/>\r\n";
  5827. } catch (RuntimeException re) {
  5828. LogUtil.errorLogInfo("", TAG, re);
  5829. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5830. }
  5831. catch (Exception e) {
  5832. //e.printStackTrace();
  5833. LogUtil.errorLogInfo("", TAG, e);
  5834. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5835. }
  5836. }
  5837. else if (devlist[i].equals("curtain")) {
  5838. try {
  5839. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5840. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5841. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"3\"/>\r\n";
  5842. } catch (RuntimeException re) {
  5843. LogUtil.errorLogInfo("", TAG, re);
  5844. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5845. }
  5846. catch (Exception e) {
  5847. //e.printStackTrace();
  5848. LogUtil.errorLogInfo("", TAG, e);
  5849. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5850. }
  5851. }
  5852. else if (devlist[i].equals("electric")) {
  5853. try {
  5854. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5855. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5856. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5857. int nOutlet = 0;
  5858. if (mSdb_LivingRoomLightAPI != null) {
  5859. if (mSdbAPI != null) {
  5860. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5861. }
  5862. else {
  5863. nOutlet = 1;
  5864. }
  5865. }
  5866. else {
  5867. if (mSdbAPI != null) {
  5868. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5869. }
  5870. else {
  5871. nOutlet = 0;
  5872. }
  5873. }
  5874. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5875. }
  5876. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5877. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5878. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5879. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"3\"/>\r\n";
  5880. }
  5881. else {
  5882. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5883. }
  5884. }
  5885. else {
  5886. int[] lightinfo = devSet.Get_Light_info();
  5887. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5888. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5889. }
  5890. else {
  5891. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5892. int ret = multisw.Refresh((byte)0xFF, false);
  5893. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5894. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5895. }
  5896. else {
  5897. int DeviceCount = 0;
  5898. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5899. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5900. DeviceCount++;
  5901. }
  5902. }
  5903. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"3\"/>\r\n";
  5904. }
  5905. }
  5906. }
  5907. } catch (RuntimeException re) {
  5908. LogUtil.errorLogInfo("", TAG, re);
  5909. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5910. }
  5911. catch (Exception e) {
  5912. //e.printStackTrace();
  5913. LogUtil.errorLogInfo("", TAG, e);
  5914. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5915. }
  5916. }
  5917. else if (devlist[i].equals("smartlight")) {
  5918. if (!bLightCMDUseAsSmartLight) {
  5919. int nSmartLight = 0;
  5920. if (mSdb_LivingRoomLightAPI != null) {
  5921. if (mSdbAPI != null) {
  5922. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5923. }
  5924. else {
  5925. nSmartLight = 1;
  5926. }
  5927. }
  5928. else {
  5929. if (mSdbAPI != null) {
  5930. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5931. }
  5932. else {
  5933. nSmartLight = 0;
  5934. }
  5935. }
  5936. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"3\"/>\r\n";
  5937. }
  5938. }
  5939. }
  5940. */
  5941. strResult += " </service>\r\n</imap>\r\n";
  5942. devSet.closeDB();
  5943. return strResult;
  5944. } catch (RuntimeException re) {
  5945. LogUtil.errorLogInfo("", TAG, re);
  5946. return null;
  5947. } catch (Exception e) {
  5948. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  5949. //e.printStackTrace();
  5950. LogUtil.errorLogInfo("", TAG, e);
  5951. return null;
  5952. }
  5953. }
  5954. public String iCMDProcMultiSWControl(Document ele) {
  5955. try {
  5956. String retStr = CheckiCMDProc(MULTISW_CTR);
  5957. if (retStr != null) return retStr;
  5958. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\"";
  5959. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  5960. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5961. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  5962. int devNum = Integer.parseInt(multiswcmd.devnum);
  5963. if (multisw != null) {
  5964. int ret = multisw.Refresh((byte) 0xFF, false);
  5965. String result;
  5966. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  5967. else result = "fail";
  5968. retStr += (" result=\"" + result + "\" >\r\n");
  5969. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5970. retStr += MakeTargetStr(multiswcmd);
  5971. retStr += " <action>\"status\"</action>\r\n";
  5972. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5973. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5974. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  5975. 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";
  5976. } else {
  5977. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  5978. }
  5979. } else {
  5980. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5981. }
  5982. String unitStr;
  5983. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5984. Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
  5985. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5986. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5987. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5988. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  5989. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  5990. }
  5991. }
  5992. retStr += " </service>\r\n</imap>\r\n";
  5993. }
  5994. } else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  5995. int devNum = Integer.parseInt(multiswcmd.devnum);
  5996. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  5997. {
  5998. if (multisw != null) {
  5999. multisw.Refresh((byte) 0xFF, false);
  6000. String result;
  6001. int ret = -1;
  6002. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  6003. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
  6004. } else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  6005. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
  6006. } else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
  6007. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
  6008. } else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
  6009. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
  6010. }
  6011. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6012. else result = "fail";
  6013. if (ret == APIErrorCode.C_SUCCESS) {
  6014. ret = multisw.Refresh((byte) 0xFF, false);
  6015. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  6016. retStr += (" result=\"" + result + "\" > \r\n");
  6017. retStr += MakeTargetStr(multiswcmd);
  6018. retStr += " <action>\"control\"</action>\r\n";
  6019. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  6020. String unitStr;
  6021. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  6022. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  6023. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  6024. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  6025. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
  6026. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  6027. }
  6028. } else {
  6029. retStr += (" result=\"fail\"> \r\n");
  6030. }
  6031. } else {
  6032. retStr += (" result=\"fail\"> \r\n");
  6033. }
  6034. retStr += " </service>\r\n</imap>\r\n";
  6035. }
  6036. }
  6037. }
  6038. return retStr;
  6039. } catch (RuntimeException re) {
  6040. LogUtil.errorLogInfo("", TAG, re);
  6041. return null;
  6042. } catch (Exception e) {
  6043. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  6044. //e.printStackTrace();
  6045. LogUtil.errorLogInfo("", TAG, e);
  6046. return null;
  6047. }
  6048. }
  6049. public String iCMDProcSDPConcentControl(Document ele) {
  6050. try {
  6051. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  6052. String retStr = CheckiCMDProc("remote_access_electric");
  6053. if (retStr != null) return retStr;
  6054. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  6055. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6056. if (NewServerUse()) {
  6057. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  6058. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6059. return ServerCheckResult;
  6060. }
  6061. if (mSdbAPI == null) {
  6062. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6063. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  6064. return retStr;
  6065. }
  6066. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6067. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6068. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6069. return retStr;
  6070. }
  6071. int nTotalLightCnt = 0;
  6072. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  6073. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6074. } else {
  6075. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  6076. }
  6077. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  6078. int nDevNo = 0;
  6079. try {
  6080. nDevNo = Integer.parseInt(concentcmd.devnum);
  6081. } catch (RuntimeException re) {
  6082. LogUtil.errorLogInfo("", TAG, re);
  6083. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6084. return retStr;
  6085. } catch (Exception e) {
  6086. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  6087. //e.printStackTrace();
  6088. LogUtil.errorLogInfo("", TAG, e);
  6089. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6090. return retStr;
  6091. }
  6092. if (nDevNo < 1 && 12 < nDevNo) {
  6093. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6094. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  6095. return retStr;
  6096. }
  6097. String strAction = trimquotation(concentcmd.actionTXT);
  6098. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  6099. String dev_num = "null", unit_num = "null", ctrl_action = "null";
  6100. int nRet_Mode = -99, nRet_OnOff = -99;
  6101. boolean Set = false, OnOff = false; // 제어요청 상태
  6102. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  6103. if (strAction.equalsIgnoreCase("status")) {
  6104. retStr += " result=\"ok\">\r\n";
  6105. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6106. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6107. if (nDevNo == 1) {
  6108. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6109. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  6110. } else {
  6111. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6112. }
  6113. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6114. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6115. status_mode = "unset";
  6116. else status_mode = "set";
  6117. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6118. status_onoff = "on";
  6119. else status_onoff = "off";
  6120. unit_status = status_mode + "/" + status_onoff;
  6121. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6122. }
  6123. // retStr += " </status_map>\r\n";
  6124. retStr += " </service>\r\n</imap>\r\n";
  6125. } else if (nDevNo > 1) {
  6126. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6127. 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";
  6128. } else {
  6129. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6130. }
  6131. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6132. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6133. status_mode = "unset";
  6134. else status_mode = "set";
  6135. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6136. status_onoff = "on";
  6137. else status_onoff = "off";
  6138. unit_status = status_mode + "/" + status_onoff;
  6139. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6140. }
  6141. // retStr += " </status_map>\r\n";
  6142. retStr += " </service>\r\n</imap>\r\n";
  6143. }
  6144. } else if (strAction.equalsIgnoreCase("control")) {
  6145. NodeList items = ele.getElementsByTagName("params");
  6146. Node item = items.item(0);
  6147. if (item != null) {
  6148. NamedNodeMap attrs = item.getAttributes();
  6149. for (int i = 0; i < attrs.getLength(); i++) {
  6150. Node attr = attrs.item(i);
  6151. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  6152. dev_num = attr.getNodeValue();
  6153. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  6154. unit_num = attr.getNodeValue();
  6155. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6156. ctrl_action = attr.getNodeValue();
  6157. }
  6158. } else {
  6159. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  6160. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6161. return retStr;
  6162. }
  6163. try {
  6164. nDevNo = Integer.parseInt(dev_num);
  6165. } catch (RuntimeException re) {
  6166. LogUtil.errorLogInfo("", TAG, re);
  6167. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6168. return retStr;
  6169. } catch (Exception e) {
  6170. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  6171. //e.printStackTrace();
  6172. LogUtil.errorLogInfo("", TAG, e);
  6173. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6174. return retStr;
  6175. }
  6176. if (nDevNo < 1 && 12 < nDevNo) {
  6177. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6178. return retStr;
  6179. }
  6180. int nUnitNo = 0;
  6181. if (!unit_num.equalsIgnoreCase("all")) {
  6182. try {
  6183. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  6184. } catch (RuntimeException re) {
  6185. LogUtil.errorLogInfo("", TAG, re);
  6186. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6187. return retStr;
  6188. } catch (Exception e) {
  6189. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  6190. //e.printStackTrace();
  6191. LogUtil.errorLogInfo("", TAG, e);
  6192. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6193. return retStr;
  6194. }
  6195. }
  6196. if (ctrl_action.contains("/")) {
  6197. String[] strParsed = ctrl_action.split("/");
  6198. if (strParsed[0].equals("set")) {
  6199. Set = true;
  6200. bCtrl_Set = true;
  6201. } else if (strParsed[0].equals("unset")) {
  6202. Set = false;
  6203. bCtrl_Set = true;
  6204. }
  6205. if (strParsed[1].equals("on")) {
  6206. OnOff = true;
  6207. bCtrl_OnOff = true;
  6208. } else if (strParsed[1].equals("off")) {
  6209. OnOff = false;
  6210. bCtrl_OnOff = true;
  6211. }
  6212. } else {
  6213. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  6214. if (ctrl_action.equalsIgnoreCase("set")) {
  6215. Set = true;
  6216. bCtrl_Set = true;
  6217. } else if (ctrl_action.equalsIgnoreCase("unset")) {
  6218. Set = false;
  6219. bCtrl_Set = true;
  6220. }
  6221. }
  6222. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  6223. if (ctrl_action.equalsIgnoreCase("on")) {
  6224. OnOff = true;
  6225. bCtrl_OnOff = true;
  6226. } else if (ctrl_action.equalsIgnoreCase("off")) {
  6227. OnOff = false;
  6228. bCtrl_OnOff = true;
  6229. }
  6230. }
  6231. }
  6232. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  6233. if (nDevNo == 1) {
  6234. if (unit_num.equalsIgnoreCase("all")) {
  6235. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6236. if (bCtrl_Set)
  6237. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  6238. if (bCtrl_OnOff)
  6239. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  6240. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6241. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6242. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6243. return retStr;
  6244. }
  6245. }
  6246. } else {
  6247. if (bCtrl_Set)
  6248. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  6249. if (bCtrl_OnOff)
  6250. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  6251. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6252. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6253. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6254. return retStr;
  6255. }
  6256. }
  6257. } else {
  6258. if (unit_num.equalsIgnoreCase("all")) {
  6259. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6260. if (bCtrl_Set)
  6261. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  6262. if (bCtrl_OnOff)
  6263. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  6264. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6265. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6266. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6267. return retStr;
  6268. }
  6269. }
  6270. } else {
  6271. if (bCtrl_Set)
  6272. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  6273. if (bCtrl_OnOff)
  6274. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  6275. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6276. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6277. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6278. return retStr;
  6279. }
  6280. }
  6281. }
  6282. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6283. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6284. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6285. return retStr;
  6286. }
  6287. retStr += " result=\"ok\">\r\n";
  6288. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6289. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6290. if (nDevNo == 1) {
  6291. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6292. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6293. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6294. status_mode = "unset";
  6295. else status_mode = "set";
  6296. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6297. status_onoff = "on";
  6298. else status_onoff = "off";
  6299. unit_status = status_mode + "/" + status_onoff;
  6300. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6301. }
  6302. // retStr += " </status_map>\r\n";
  6303. retStr += " </service>\r\n</imap>\r\n";
  6304. } else if (nDevNo > 1) {
  6305. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6306. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6307. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6308. status_mode = "unset";
  6309. else status_mode = "set";
  6310. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6311. status_onoff = "on";
  6312. else status_onoff = "off";
  6313. unit_status = status_mode + "/" + status_onoff;
  6314. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6315. }
  6316. // retStr += " </status_map>\r\n";
  6317. retStr += " </service>\r\n</imap>\r\n";
  6318. }
  6319. } else {
  6320. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  6321. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6322. }
  6323. return retStr;
  6324. } catch (RuntimeException re) {
  6325. LogUtil.errorLogInfo("", TAG, re);
  6326. return null;
  6327. } catch (Exception e) {
  6328. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  6329. //e.printStackTrace();
  6330. LogUtil.errorLogInfo("", TAG, e);
  6331. return null;
  6332. }
  6333. }
  6334. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  6335. try {
  6336. String retStr = CheckiCMDProc(MULTISW_CTR);
  6337. if (retStr != null) return retStr;
  6338. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\" ";
  6339. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6340. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6341. if (energymetercmd == null) return null;
  6342. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6343. if (energymeter == null) return null;
  6344. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6345. int ret = energymeter.Refresh((byte) 0xFF, false);
  6346. String result;
  6347. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  6348. else result = "fail";
  6349. retStr += (" result=\"" + result + "\" >\r\n");
  6350. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6351. retStr += MakeTargetStr(energymetercmd);
  6352. retStr += " <action>\"status\"</action>\r\n";
  6353. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6354. String unitStr;
  6355. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6356. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6357. if (i == 2) {
  6358. unitStr += "on";
  6359. } else {
  6360. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6361. }
  6362. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6363. }
  6364. }
  6365. retStr += " </service>\r\n</imap>\r\n";
  6366. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6367. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6368. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
  6369. byte cmd = 0;
  6370. int ret = 0;
  6371. String result;
  6372. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  6373. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  6374. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  6375. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  6376. if (cmd > 0) {
  6377. if (energymeter != null) {
  6378. energymeter.Refresh((byte) 0xFF, false);
  6379. if (cmd == 1) {
  6380. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  6381. } else if (cmd == 2) {
  6382. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  6383. } else if (cmd == 3) {
  6384. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
  6385. } else if (cmd == 4) {
  6386. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
  6387. }
  6388. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6389. else result = "fail";
  6390. retStr += (" result=\"" + result + "\" >\r\n");
  6391. if (ret == APIErrorCode.C_SUCCESS) {
  6392. ret = energymeter.Refresh((byte) 0xFF, false);
  6393. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6394. retStr += MakeTargetStr(energymetercmd);
  6395. retStr += " <action>\"control\"</action>\r\n";
  6396. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6397. String unitStr;
  6398. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6399. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6400. if (i == 2) {
  6401. unitStr += "on";
  6402. } else {
  6403. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6404. }
  6405. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6406. }
  6407. } else {
  6408. retStr += (" result=\"fail\"> \r\n");
  6409. }
  6410. } else {
  6411. retStr += (" result=\"fail\"> \r\n");
  6412. }
  6413. retStr += " </service>\r\n</imap>\r\n";
  6414. }
  6415. }
  6416. }
  6417. return retStr;
  6418. } catch (RuntimeException re) {
  6419. LogUtil.errorLogInfo("", TAG, re);
  6420. return null;
  6421. } catch (Exception e) {
  6422. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  6423. //e.printStackTrace();
  6424. LogUtil.errorLogInfo("", TAG, e);
  6425. return null;
  6426. }
  6427. }
  6428. public String iCMDProcModeControl(Document doc) {
  6429. try {
  6430. String status = "unknown";
  6431. boolean SendBR = false;
  6432. String retStr = CheckiCMDProc("remote_access_mode");
  6433. if (retStr != null) return retStr;
  6434. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  6435. String target = "null", tid = "null", msgno = "null";
  6436. NodeList items = doc.getElementsByTagName("target");
  6437. Node item = items.item(0);
  6438. if (item != null) {
  6439. NamedNodeMap attrs = item.getAttributes();
  6440. for (int j = 0; j < attrs.getLength(); j++) {
  6441. Node attr = attrs.item(j);
  6442. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6443. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6444. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6445. msgno = attr.getNodeValue();
  6446. }
  6447. }
  6448. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6449. if (NewServerUse()) {
  6450. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  6451. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6452. return ServerCheckResult;
  6453. }
  6454. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  6455. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  6456. int curState = SetData.GetAlarmStatus();
  6457. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  6458. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  6459. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  6460. switch (curState) {
  6461. case WallpadStatusData.GUARD_IN:
  6462. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  6463. Intent intent = new Intent();
  6464. intent.setAction(define.NOTIFY_ACNAME);
  6465. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6466. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  6467. getApplicationContext().sendBroadcast(intent);
  6468. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  6469. SendBR = true;
  6470. break;
  6471. case WallpadStatusData.GUARD_OUT:
  6472. break;
  6473. }
  6474. } else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  6475. switch (curState) {
  6476. case WallpadStatusData.ALARM_NONE:
  6477. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6478. if (mIGW200.checkSensorforInmode()) {
  6479. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6480. Intent intent = new Intent();
  6481. intent.setAction(define.NOTIFY_ACNAME);
  6482. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6483. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6484. getApplicationContext().sendBroadcast(intent);
  6485. SendBR = true;
  6486. } else {
  6487. SendBR = false;
  6488. }
  6489. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  6490. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6491. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6492. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6493. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6494. if (mIGW300.checkSensorforInmode()) {
  6495. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6496. Intent intent = new Intent();
  6497. intent.setAction(define.NOTIFY_ACNAME);
  6498. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6499. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6500. getApplicationContext().sendBroadcast(intent);
  6501. SendBR = true;
  6502. } else {
  6503. SendBR = false;
  6504. }
  6505. } else {
  6506. if (checkSensorforInmode()) {
  6507. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6508. Intent intent = new Intent();
  6509. intent.setAction(define.NOTIFY_ACNAME);
  6510. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6511. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6512. getApplicationContext().sendBroadcast(intent);
  6513. Sound().PlayMent(SND.mode.INMODE_SETTING);
  6514. SendBR = true;
  6515. } else {
  6516. SendBR = false;
  6517. }
  6518. }
  6519. break;
  6520. default:
  6521. break;
  6522. }
  6523. } else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  6524. if (GetUseIlgalControlForAdmin() == false) {
  6525. // 관리자용 일괄소등 원격제어 사용안할 시
  6526. switch (curState) {
  6527. case WallpadStatusData.ALARM_NONE:
  6528. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6529. if (mIGW200.checkSensorforOutmode()) {
  6530. Common.SendAppFinishReqBR(getApplicationContext());
  6531. Intent intent = new Intent();
  6532. intent.setAction(define.NOTIFY_ACNAME);
  6533. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6534. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6535. getApplicationContext().sendBroadcast(intent);
  6536. SendBR = true;
  6537. } else {
  6538. SendBR = false;
  6539. }
  6540. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  6541. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6542. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6543. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6544. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6545. if (mIGW300.checkSensorforOutmode()) {
  6546. Common.SendAppFinishReqBR(getApplicationContext());
  6547. Intent intent = new Intent();
  6548. intent.setAction(define.NOTIFY_ACNAME);
  6549. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6550. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6551. getApplicationContext().sendBroadcast(intent);
  6552. SendBR = true;
  6553. } else {
  6554. SendBR = false;
  6555. }
  6556. } else {
  6557. if (checkSensorforOutmode()) {
  6558. Common.SendAppFinishReqBR(getApplicationContext());
  6559. Intent intent = new Intent();
  6560. intent.setAction(define.NOTIFY_ACNAME);
  6561. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6562. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6563. getApplicationContext().sendBroadcast(intent);
  6564. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  6565. SendBR = true;
  6566. } else {
  6567. SendBR = false;
  6568. }
  6569. }
  6570. break;
  6571. default:
  6572. break;
  6573. }
  6574. } else {
  6575. // 관리자용 일괄소등 원격제어 사용 시
  6576. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6577. SendBR = true;
  6578. }
  6579. }
  6580. } else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  6581. int getStatus = SetData.GetAlarmStatus();
  6582. switch (getStatus) {
  6583. case WallpadStatusData.GUARD_IN:
  6584. status = "occupied";
  6585. break;
  6586. case WallpadStatusData.GUARD_OUT:
  6587. status = "unoccupied";
  6588. break;
  6589. case WallpadStatusData.ALARM_NONE:
  6590. status = "normal";
  6591. break;
  6592. case WallpadStatusData.ALARM_ARISE:
  6593. status = "emergency";
  6594. break;
  6595. default:
  6596. break;
  6597. }
  6598. retStr += ("\"ok\">\r\n ");
  6599. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6600. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6601. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6602. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6603. return retStr;
  6604. }
  6605. if (!SendBR) {
  6606. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6607. SetData.closeDB();
  6608. return retStr;
  6609. } else {
  6610. try {
  6611. Thread.sleep(1000);
  6612. } catch (RuntimeException re) {
  6613. LogUtil.errorLogInfo("", TAG, re);
  6614. } catch (Exception e) {
  6615. LogUtil.errorLogInfo("", TAG, e);
  6616. }
  6617. int getStatus = SetData.GetAlarmStatus();
  6618. switch (getStatus) {
  6619. case WallpadStatusData.GUARD_IN:
  6620. status = "occupied";
  6621. break;
  6622. case WallpadStatusData.GUARD_OUT:
  6623. status = "unoccupied";
  6624. break;
  6625. case WallpadStatusData.ALARM_NONE:
  6626. status = "normal";
  6627. break;
  6628. case WallpadStatusData.ALARM_ARISE:
  6629. status = "emergency";
  6630. break;
  6631. }
  6632. }
  6633. retStr += "\"ok\">\r\n";
  6634. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6635. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6636. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6637. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6638. SetData.closeDB();
  6639. return retStr;
  6640. } catch (RuntimeException re) {
  6641. LogUtil.errorLogInfo("", TAG, re);
  6642. return null;
  6643. } catch (Exception e) {
  6644. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6645. //e.printStackTrace();
  6646. LogUtil.errorLogInfo("", TAG, e);
  6647. return null;
  6648. }
  6649. }
  6650. public String iCMDProcCurtainControl(Document ele) {
  6651. return " ";
  6652. }
  6653. public String iCMDProcSDPLightControl(Document ele) {
  6654. try {
  6655. String retStr = CheckiCMDProc("remote_access_light");
  6656. if (retStr != null) return retStr;
  6657. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6658. String target = "null", tid = "null", msgno = "null";
  6659. NodeList items = ele.getElementsByTagName("target");
  6660. Node item = items.item(0);
  6661. if (item != null) {
  6662. NamedNodeMap attrs = item.getAttributes();
  6663. for (int j = 0; j < attrs.getLength(); j++) {
  6664. Node attr = attrs.item(j);
  6665. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6666. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6667. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6668. msgno = attr.getNodeValue();
  6669. }
  6670. }
  6671. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6672. if (NewServerUse()) {
  6673. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6674. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6675. return ServerCheckResult;
  6676. }
  6677. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6678. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6679. if (energymetercmd == null) return null;
  6680. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6681. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6682. if (energymeter == null) return null;
  6683. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6684. retStr += "result=\"ok\">\r\n" +
  6685. " <action>\"status\"</action>\r\n" +
  6686. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6687. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6688. 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");
  6689. }
  6690. retStr += "\r\n</service>\r\n</imap>";
  6691. } else {
  6692. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6693. }
  6694. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6695. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6696. num--;
  6697. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6698. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6699. if (energymeter == null) return null;
  6700. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6701. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6702. retStr += "result=\"ok\">\r\n" +
  6703. " <action>\"control\"</action>\r\n" +
  6704. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6705. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6706. 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");
  6707. }
  6708. retStr += "\r\n</service>\r\n</imap>";
  6709. } else {
  6710. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6711. }
  6712. } else {
  6713. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6714. }
  6715. } else {
  6716. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6717. }
  6718. energymetercmd = null;
  6719. return retStr;
  6720. } catch (RuntimeException re) {
  6721. LogUtil.errorLogInfo("", TAG, re);
  6722. return null;
  6723. } catch (Exception e) {
  6724. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6725. //e.printStackTrace();
  6726. LogUtil.errorLogInfo("", TAG, e);
  6727. return null;
  6728. }
  6729. }
  6730. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6731. try {
  6732. String retStr = CheckiCMDProc("remote_access_light");
  6733. if (retStr != null) return retStr;
  6734. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6735. String target = "null", tid = "null", msgno = "null";
  6736. NodeList items = ele.getElementsByTagName("target");
  6737. Node item = items.item(0);
  6738. if (item != null) {
  6739. NamedNodeMap attrs = item.getAttributes();
  6740. for (int j = 0; j < attrs.getLength(); j++) {
  6741. Node attr = attrs.item(j);
  6742. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6743. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6744. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6745. msgno = attr.getNodeValue();
  6746. }
  6747. }
  6748. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6749. if (NewServerUse()) {
  6750. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6751. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6752. return ServerCheckResult;
  6753. }
  6754. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6755. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6756. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6757. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6758. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6759. retStr += "result=\"ok\">\r\n" +
  6760. " <action>\"status\"</action>\r\n" +
  6761. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6762. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6763. 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");
  6764. }
  6765. retStr += "\r\n</service>\r\n</imap>";
  6766. } else {
  6767. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6768. }
  6769. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6770. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6771. num--;
  6772. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6773. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6774. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6775. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6776. retStr += "result=\"ok\">\r\n" +
  6777. " <action>\"control\"</action>\r\n" +
  6778. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6779. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6780. 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");
  6781. }
  6782. retStr += "\r\n</service>\r\n</imap>";
  6783. } else {
  6784. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6785. }
  6786. } else {
  6787. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6788. }
  6789. } else {
  6790. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6791. }
  6792. energymetercmd = null;
  6793. return retStr;
  6794. } catch (RuntimeException re) {
  6795. LogUtil.errorLogInfo("", TAG, re);
  6796. return null;
  6797. } catch (Exception e) {
  6798. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6799. //e.printStackTrace();
  6800. LogUtil.errorLogInfo("", TAG, e);
  6801. return null;
  6802. }
  6803. }
  6804. public String iCMDProcLightControl(Document ele) {
  6805. try {
  6806. String retStr = CheckiCMDProc("remote_access_light");
  6807. if (retStr != null) return retStr;
  6808. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6809. String target = "null", tid = "null", msgno = "null";
  6810. NodeList items = ele.getElementsByTagName("target");
  6811. Node item = items.item(0);
  6812. if (item != null) {
  6813. NamedNodeMap attrs = item.getAttributes();
  6814. for (int j = 0; j < attrs.getLength(); j++) {
  6815. Node attr = attrs.item(j);
  6816. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6817. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6818. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6819. msgno = attr.getNodeValue();
  6820. }
  6821. }
  6822. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6823. if (NewServerUse()) {
  6824. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6825. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6826. return ServerCheckResult;
  6827. }
  6828. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6829. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6830. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6831. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6832. if (bLightCMDUseAsSmartLight) {
  6833. if (mSdbAPI != null) {
  6834. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6835. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6836. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6837. retStr += "result=\"ok\">\r\n" +
  6838. " <action>\"status\"</action>\r\n";
  6839. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6840. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6841. } else {
  6842. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6843. }
  6844. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6845. 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");
  6846. }
  6847. retStr += " </service>\r\n</imap>";
  6848. } else {
  6849. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6850. }
  6851. } else {
  6852. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6853. }
  6854. } else {
  6855. if (mMultiSwitchAPI != null) {
  6856. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6857. if (nResult == 0) {
  6858. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6859. retStr += "result=\"ok\">\r\n" +
  6860. " <action>\"status\"</action>\r\n";
  6861. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6862. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6863. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6864. } else {
  6865. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6866. }
  6867. } else {
  6868. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6869. }
  6870. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6871. 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");
  6872. }
  6873. retStr += " </service>\r\n</imap>";
  6874. } else {
  6875. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6876. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6877. }
  6878. } else {
  6879. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6880. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6881. }
  6882. } else {
  6883. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  6884. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6885. }
  6886. }
  6887. } else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  6888. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6889. boolean OnOff = false;
  6890. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6891. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  6892. if (bLightCMDUseAsSmartLight) {
  6893. if (mSdbAPI != null) {
  6894. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6895. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  6896. if (ret >= 0) {
  6897. retStr += "result=\"ok\">\r\n" +
  6898. " <action>\"status\"</action>\r\n" +
  6899. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6900. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6901. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6902. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6903. 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");
  6904. }
  6905. retStr += " </service>\r\n</imap>";
  6906. } else {
  6907. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6908. }
  6909. } else {
  6910. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6911. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  6912. if (ret >= 0) {
  6913. retStr += "result=\"ok\">\r\n" +
  6914. " <action>\"status\"</action>\r\n" +
  6915. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6916. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6917. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6918. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6919. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  6920. 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");
  6921. }
  6922. retStr += " </service>\r\n</imap>";
  6923. } else {
  6924. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6925. }
  6926. }
  6927. } else {
  6928. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6929. }
  6930. } else {
  6931. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6932. if (mMultiSwitchAPI != null) {
  6933. int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6934. if (nResultRefresh == 0) {
  6935. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6936. if (nCtrlResult == 0) {
  6937. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6938. if (nResult == 0) {
  6939. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6940. retStr += "result=\"ok\">\r\n" +
  6941. " <action>\"status\"</action>\r\n" +
  6942. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6943. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  6944. 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");
  6945. }
  6946. retStr += " </service>\r\n</imap>";
  6947. } else {
  6948. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6949. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6950. }
  6951. } else {
  6952. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6953. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6954. }
  6955. } else {
  6956. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6957. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6958. }
  6959. } else {
  6960. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6961. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6962. }
  6963. }
  6964. } else {
  6965. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6966. if (mMultiSwitchAPI != null) {
  6967. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6968. if (nCtrlResult == 0) {
  6969. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6970. if (nResult == 0) {
  6971. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6972. retStr += "result=\"ok\">\r\n" +
  6973. " <action>\"status\"</action>\r\n" +
  6974. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6975. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6976. 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");
  6977. }
  6978. retStr += " </service>\r\n</imap>";
  6979. } else {
  6980. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6981. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6982. }
  6983. } else {
  6984. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6985. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6986. }
  6987. } else {
  6988. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6989. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6990. }
  6991. }
  6992. }
  6993. }
  6994. } else {
  6995. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6996. }
  6997. } else {
  6998. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6999. }
  7000. MSlightcmd = null;
  7001. return retStr;
  7002. } catch (RuntimeException re) {
  7003. LogUtil.errorLogInfo("", TAG, re);
  7004. return null;
  7005. } catch (Exception e) {
  7006. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  7007. //e.printStackTrace();
  7008. LogUtil.errorLogInfo("", TAG, e);
  7009. return null;
  7010. }
  7011. }
  7012. public String iCMDProcSDPSmartLightControl(Document ele) {
  7013. try {
  7014. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7015. String retStr = CheckiCMDProc("remote_access_smartlight");
  7016. if (retStr != null) return retStr;
  7017. else
  7018. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7019. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7020. if (NewServerUse()) {
  7021. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7022. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  7023. return ServerCheckResult;
  7024. }
  7025. if (mSdb_LivingRoomLightAPI == null) {
  7026. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7027. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  7028. return retStr;
  7029. }
  7030. if (mSdbAPI == null) {
  7031. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7032. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  7033. return retStr;
  7034. }
  7035. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7036. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7037. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7038. return retStr;
  7039. }
  7040. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7041. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
  7042. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7043. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7044. return retStr;
  7045. }
  7046. }
  7047. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  7048. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7049. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7050. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7051. retStr += " result=\"ok\">\r\n";
  7052. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7053. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7054. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7055. for (int i = 0; i < nTotalLightCnt; i++) {
  7056. if (i == 0) {
  7057. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7058. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7059. String status_power = "off", status_dim = "null", status_color = "null";
  7060. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7061. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7062. } else {
  7063. status_power = "null";
  7064. }
  7065. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7066. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7067. } else {
  7068. status_dim = "null";
  7069. }
  7070. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7071. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7072. } else {
  7073. status_color = "null";
  7074. }
  7075. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7076. }
  7077. retStr += " </status_map>\r\n";
  7078. } else {
  7079. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7080. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7081. String status_power = "off", status_dim = "null", status_color = "null";
  7082. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7083. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7084. } else {
  7085. status_power = "null";
  7086. }
  7087. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7088. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7089. } else {
  7090. status_dim = "null";
  7091. }
  7092. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7093. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7094. } else {
  7095. status_color = "null";
  7096. }
  7097. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7098. }
  7099. retStr += " </status_map>\r\n";
  7100. }
  7101. }
  7102. retStr += " </service>\r\n</imap>\r\n";
  7103. } else {
  7104. int nDevNo = 0;
  7105. try {
  7106. nDevNo = Integer.parseInt(lightcmd.devnum);
  7107. } catch (RuntimeException re) {
  7108. LogUtil.errorLogInfo("", TAG, re);
  7109. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7110. return retStr;
  7111. } catch (Exception e) {
  7112. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  7113. //e.printStackTrace();
  7114. LogUtil.errorLogInfo("", TAG, e);
  7115. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7116. return retStr;
  7117. }
  7118. if ((nDevNo - 1) > nTotalLightCnt) {
  7119. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7120. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7121. return retStr;
  7122. }
  7123. retStr += " result=\"ok\">\r\n";
  7124. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7125. retStr += " <action>\"status\"</action>\r\n";
  7126. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7127. if (nDevNo == 1) {
  7128. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7129. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7130. String status_power = "off", status_dim = "null", status_color = "null";
  7131. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7132. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7133. } else {
  7134. status_power = "null";
  7135. }
  7136. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7137. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7138. } else {
  7139. status_dim = "null";
  7140. }
  7141. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7142. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7143. } else {
  7144. status_color = "null";
  7145. }
  7146. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7147. }
  7148. retStr += " </status_map>\r\n";
  7149. } else {
  7150. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  7151. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7152. String status_power = "off", status_dim = "null", status_color = "null";
  7153. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7154. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7155. } else {
  7156. status_power = "null";
  7157. }
  7158. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7159. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7160. } else {
  7161. status_dim = "null";
  7162. }
  7163. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7164. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7165. } else {
  7166. status_color = "null";
  7167. }
  7168. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7169. }
  7170. retStr += " </status_map>\r\n";
  7171. }
  7172. retStr += " </service>\r\n</imap>\r\n";
  7173. }
  7174. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7175. int nResult = -99;
  7176. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7177. NodeList items = ele.getElementsByTagName("params");
  7178. Node item = items.item(0);
  7179. if (item != null) {
  7180. NamedNodeMap attrs = item.getAttributes();
  7181. for (int j = 0; j < attrs.getLength(); j++) {
  7182. Node attr = attrs.item(j);
  7183. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7184. dev_num = attr.getNodeValue();
  7185. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7186. dev_mode = attr.getNodeValue();
  7187. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7188. unit_num = attr.getNodeValue();
  7189. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7190. unit_status = attr.getNodeValue();
  7191. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7192. unit_dimming = attr.getNodeValue();
  7193. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7194. unit_color = attr.getNodeValue();
  7195. }
  7196. }
  7197. if (dev_num.equalsIgnoreCase("all")) {
  7198. nResult = 0;
  7199. for (int i = 0; i < nTotalLightCnt; i++) {
  7200. if (i == 0) {
  7201. nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7202. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7203. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7204. } else {
  7205. nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7206. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7207. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7208. }
  7209. }
  7210. if (nResult != 0) {
  7211. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7212. Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
  7213. return retStr;
  7214. } else {
  7215. retStr += " result=\"ok\">\r\n";
  7216. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7217. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7218. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7219. }
  7220. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7221. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7222. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7223. return retStr;
  7224. }
  7225. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
  7226. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7227. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7228. return retStr;
  7229. }
  7230. for (int i = 0; i < nTotalLightCnt; i++) {
  7231. if (i == 0) {
  7232. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7233. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7234. String status_power = "off", status_dim = "null", status_color = "null";
  7235. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7236. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7237. } else {
  7238. status_power = "null";
  7239. }
  7240. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7241. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7242. } else {
  7243. status_dim = "null";
  7244. }
  7245. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7246. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7247. } else {
  7248. status_color = "null";
  7249. }
  7250. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7251. }
  7252. retStr += " </status_map>\r\n";
  7253. } else {
  7254. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[i] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7255. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7256. String status_power = "off", status_dim = "null", status_color = "null";
  7257. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7258. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7259. } else {
  7260. status_power = "null";
  7261. }
  7262. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7263. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7264. } else {
  7265. status_dim = "null";
  7266. }
  7267. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7268. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7269. } else {
  7270. status_color = "null";
  7271. }
  7272. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7273. }
  7274. retStr += " </status_map>\r\n";
  7275. }
  7276. }
  7277. retStr += " </service>\r\n</imap>\r\n";
  7278. } else {
  7279. int nDevNo = 0;
  7280. int nUnitNo = 0;
  7281. try {
  7282. nDevNo = Integer.parseInt(dev_num);
  7283. } catch (RuntimeException re) {
  7284. LogUtil.errorLogInfo("", TAG, re);
  7285. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7286. return retStr;
  7287. } catch (Exception e) {
  7288. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7289. //e.printStackTrace();
  7290. LogUtil.errorLogInfo("", TAG, e);
  7291. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7292. return retStr;
  7293. }
  7294. if ((nDevNo - 1) > nTotalLightCnt) {
  7295. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7296. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7297. return retStr;
  7298. }
  7299. nResult = -99;
  7300. if (unit_num.equalsIgnoreCase("all")) {
  7301. if (nDevNo == 1) {
  7302. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7303. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7304. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7305. } else {
  7306. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7307. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7308. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7309. }
  7310. if (nResult != 0) {
  7311. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7312. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7313. return retStr;
  7314. }
  7315. } else {
  7316. try {
  7317. nUnitNo = Integer.parseInt(unit_num);
  7318. } catch (RuntimeException re) {
  7319. LogUtil.errorLogInfo("", TAG, re);
  7320. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7321. return retStr;
  7322. } catch (Exception e) {
  7323. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7324. //e.printStackTrace();
  7325. LogUtil.errorLogInfo("", TAG, e);
  7326. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7327. return retStr;
  7328. }
  7329. nResult = -99;
  7330. if (nDevNo == 1) {
  7331. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7332. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7333. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7334. } else {
  7335. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7336. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7337. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7338. }
  7339. if (nResult != 0) {
  7340. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7341. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7342. return retStr;
  7343. }
  7344. }
  7345. if (nDevNo == 1) {
  7346. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7347. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7348. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7349. return retStr;
  7350. } else {
  7351. retStr += " result=\"ok\">\r\n";
  7352. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7353. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7354. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7355. }
  7356. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7357. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7358. String status_power = "off", status_dim = "null", status_color = "null";
  7359. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7360. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7361. } else {
  7362. status_power = "null";
  7363. }
  7364. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7365. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7366. } else {
  7367. status_dim = "null";
  7368. }
  7369. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7370. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7371. } else {
  7372. status_color = "null";
  7373. }
  7374. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7375. }
  7376. retStr += " </status_map>\r\n";
  7377. } else {
  7378. int nRealDevNo = (byte) (nDevNo - 2);
  7379. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
  7380. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7381. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7382. return retStr;
  7383. } else {
  7384. retStr += " result=\"ok\">\r\n";
  7385. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7386. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7387. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7388. }
  7389. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount + "\">\r\n";
  7390. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
  7391. String status_power = "off", status_dim = "null", status_color = "null";
  7392. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
  7393. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7394. } else {
  7395. status_power = "null";
  7396. }
  7397. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
  7398. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
  7399. } else {
  7400. status_dim = "null";
  7401. }
  7402. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
  7403. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
  7404. } else {
  7405. status_color = "null";
  7406. }
  7407. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7408. }
  7409. retStr += " </status_map>\r\n";
  7410. }
  7411. retStr += " </service>\r\n</imap>\r\n";
  7412. }
  7413. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  7414. int nResult = 0;
  7415. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7416. NodeList items = ele.getElementsByTagName("params");
  7417. Node item = items.item(0);
  7418. if (item != null) {
  7419. NamedNodeMap attrs = item.getAttributes();
  7420. for (int j = 0; j < attrs.getLength(); j++) {
  7421. Node attr = attrs.item(j);
  7422. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7423. dev_num = attr.getNodeValue();
  7424. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7425. dev_mode = attr.getNodeValue();
  7426. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7427. unit_num = attr.getNodeValue();
  7428. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7429. unit_status = attr.getNodeValue();
  7430. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7431. unit_dimming = attr.getNodeValue();
  7432. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7433. unit_color = attr.getNodeValue();
  7434. }
  7435. }
  7436. if (dev_num.equalsIgnoreCase("all")) {
  7437. if (!dev_mode.equals("null")) {
  7438. nResult = -99;
  7439. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7440. if (nResult != 0) {
  7441. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7442. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7443. return retStr;
  7444. }
  7445. } else {
  7446. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7447. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7448. return retStr;
  7449. }
  7450. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7451. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7452. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7453. return retStr;
  7454. } else {
  7455. retStr += " result=\"ok\">\r\n";
  7456. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7457. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7458. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7459. }
  7460. retStr += " <status_map dev_num=\"1\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[0] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\">\r\n";
  7461. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  7462. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7463. } else {
  7464. int nDevNo = 0;
  7465. try {
  7466. nDevNo = Integer.parseInt(dev_num);
  7467. } catch (RuntimeException re) {
  7468. LogUtil.errorLogInfo("", TAG, re);
  7469. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7470. return retStr;
  7471. } catch (Exception e) {
  7472. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7473. //e.printStackTrace();
  7474. LogUtil.errorLogInfo("", TAG, e);
  7475. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7476. return retStr;
  7477. }
  7478. if (nDevNo != 1) {
  7479. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  7480. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7481. return retStr;
  7482. }
  7483. if (!dev_mode.equals("null")) {
  7484. nResult = -99;
  7485. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7486. if (nResult != 0) {
  7487. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7488. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7489. return retStr;
  7490. }
  7491. } else {
  7492. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7493. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7494. return retStr;
  7495. }
  7496. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7497. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7498. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7499. return retStr;
  7500. } else {
  7501. retStr += " result=\"ok\">\r\n";
  7502. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7503. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7504. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7505. }
  7506. retStr += " <status_map dev_num=\"1\" dev_mode=\"" + mSdb_LivingRoomLightAPI.data.Data.LightMode + "\" dev_name=\"" + mDefaultRoomNameList_Light[0] + "\" unit_cnt=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[0] + "\">\r\n";
  7507. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7508. String status_power = "off", status_dim = "null", status_color = "null";
  7509. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7510. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7511. } else {
  7512. status_power = "null";
  7513. }
  7514. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7515. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7516. } else {
  7517. status_dim = "null";
  7518. }
  7519. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7520. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7521. } else {
  7522. status_color = "null";
  7523. }
  7524. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7525. }
  7526. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7527. }
  7528. } else {
  7529. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7530. }
  7531. lightcmd = null;
  7532. return retStr;
  7533. } catch (RuntimeException re) {
  7534. LogUtil.errorLogInfo("", TAG, re);
  7535. return null;
  7536. } catch (Exception e) {
  7537. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7538. //e.printStackTrace();
  7539. LogUtil.errorLogInfo("", TAG, e);
  7540. return null;
  7541. }
  7542. }
  7543. private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
  7544. byte type = 0;
  7545. //각 스위치 개수는 4개임
  7546. switch (lightIndex) {
  7547. case 0:
  7548. type = benEm.Info.LightType_1;
  7549. break;
  7550. case 1:
  7551. type = benEm.Info.LightType_2;
  7552. break;
  7553. case 2:
  7554. type = benEm.Info.LightType_3;
  7555. break;
  7556. case 3:
  7557. type = benEm.Info.LightType_4;
  7558. break;
  7559. default:
  7560. break;
  7561. }
  7562. return type;
  7563. }
  7564. public String iCMDProcChumDamSmartLightControl(Document ele) {
  7565. try {
  7566. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7567. String retStr = CheckiCMDProc("remote_access_smartlight");
  7568. if (retStr != null) return retStr;
  7569. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7570. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7571. if (NewServerUse()) {
  7572. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7573. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7574. }
  7575. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  7576. if (KnxApi == null) {
  7577. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7578. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
  7579. return retStr;
  7580. }
  7581. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7582. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7583. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7584. return retStr;
  7585. }
  7586. int LivingLightCount = 0;
  7587. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  7588. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  7589. } else {
  7590. if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  7591. LivingLightCount = 1;
  7592. }
  7593. //기준층 명칭
  7594. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  7595. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  7596. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_LIGHT);
  7597. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  7598. int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  7599. int SwitchCount = KnxApi.data.MasterController.Info.Light_SwitchCount;
  7600. int totalLightCount = LivingLightCount + BadLightCount + SwitchCount;
  7601. int emCount = LivingLightCount + BadLightCount;
  7602. //mData.MasterController.Info.Light_SwitchCount
  7603. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
  7604. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
  7605. {
  7606. retStr += " result=\"ok\">\r\n";
  7607. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7608. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7609. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7610. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7611. for (int i = 0; i < totalLightCount; i++) {
  7612. if (i == 0) {
  7613. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7614. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7615. String status_power = "off", status_dim = "null", status_color = "null";
  7616. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
  7617. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7618. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
  7619. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7620. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7621. }
  7622. retStr += " </status_map>\r\n";
  7623. } else if(i>0 && i<emCount){
  7624. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7625. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7626. String status_power = "off", status_dim = "null", status_color = "null";
  7627. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7628. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7629. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7630. status_dim ="null";
  7631. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7632. }
  7633. retStr += " </status_map>\r\n";
  7634. } else{
  7635. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[i - emCount].Info.LightCount + "\">\r\n";
  7636. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7637. String status_power = "off", status_dim = "null", status_color = "null";
  7638. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7639. status_dim ="null";
  7640. // zzz
  7641. //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
  7642. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7643. }
  7644. retStr += " </status_map>\r\n";
  7645. }
  7646. }
  7647. }
  7648. else
  7649. {
  7650. int nResult = 0;
  7651. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7652. NodeList items = ele.getElementsByTagName("params");
  7653. Node item = items.item(0);
  7654. if (item != null) {
  7655. NamedNodeMap attrs = item.getAttributes();
  7656. for (int j = 0; j< attrs.getLength(); j++) {
  7657. Node attr = attrs.item(j);
  7658. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7659. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7660. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7661. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7662. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7663. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7664. }
  7665. }
  7666. int nDevNo = Integer.parseInt(dev_num);
  7667. if (nDevNo == 1) {
  7668. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7669. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7670. String status_power = "off", status_dim = "null", status_color = "null";
  7671. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
  7672. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7673. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
  7674. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7675. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7676. }
  7677. retStr += " </status_map>\r\n";
  7678. } else if(nDevNo>1 && nDevNo<emCount+1){
  7679. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount + "\">\r\n";
  7680. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
  7681. String status_power = "off", status_dim = "null", status_color = "null";
  7682. status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7683. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
  7684. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
  7685. status_dim ="null";
  7686. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7687. }
  7688. retStr += " </status_map>\r\n";
  7689. } else{
  7690. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount + "\">\r\n";
  7691. for (int j = 0; j < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount; j++) {
  7692. String status_power = "off", status_dim = "null", status_color = "null";
  7693. status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7694. status_dim ="null";
  7695. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7696. }
  7697. retStr += " </status_map>\r\n";
  7698. }
  7699. }
  7700. retStr += " </service>\r\n</imap>\r\n";
  7701. }
  7702. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7703. int nResult = 0;
  7704. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7705. NodeList items = ele.getElementsByTagName("params");
  7706. Node item = items.item(0);
  7707. if (item != null) {
  7708. NamedNodeMap attrs = item.getAttributes();
  7709. for (int j = 0; j< attrs.getLength(); j++) {
  7710. Node attr = attrs.item(j);
  7711. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7712. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7713. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7714. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7715. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7716. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7717. }
  7718. }
  7719. if (dev_num.equalsIgnoreCase("ALL")) {
  7720. // 일괄소등 실행/해제
  7721. if (!unit_status.equalsIgnoreCase("null")) {
  7722. KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
  7723. }
  7724. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7725. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7726. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7727. return retStr;
  7728. }
  7729. retStr += " result=\"ok\">\r\n";
  7730. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7731. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7732. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7733. for (int i = 0; i < totalLightCount; i++) {
  7734. if (i == 0) {
  7735. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ "null" + "\" dev_name=\""+ knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7736. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7737. String status_power = "off", status_dim = "null", status_color = "null";
  7738. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
  7739. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7740. Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
  7741. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7742. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7743. }
  7744. retStr += " </status_map>\r\n";
  7745. }
  7746. else if(i>0 && i<emCount){
  7747. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
  7748. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7749. String status_power = "off", status_dim = "null", status_color = "null";
  7750. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7751. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7752. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7753. status_dim ="null";
  7754. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7755. }
  7756. retStr += " </status_map>\r\n";
  7757. } else {
  7758. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[i - emCount].Info.LightCount + "\">\r\n";
  7759. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7760. String status_power = "off", status_dim = "null", status_color = "null";
  7761. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7762. status_dim ="null";
  7763. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7764. }
  7765. retStr += " </status_map>\r\n";
  7766. }
  7767. }
  7768. retStr += " </service>\r\n</imap>\r\n";
  7769. }
  7770. else {
  7771. int nDevNo = 0;
  7772. int nUnitNo = 0;
  7773. try {
  7774. nDevNo = Integer.parseInt(dev_num);
  7775. } catch (Exception e) {
  7776. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7777. e.printStackTrace();
  7778. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7779. return retStr;
  7780. }
  7781. if ((nDevNo - 1) > totalLightCount) {
  7782. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
  7783. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7784. return retStr;
  7785. }
  7786. // retStr += " result=\"ok\">\r\n";
  7787. // retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7788. // retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7789. // retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7790. if (unit_num.equalsIgnoreCase("all")) {
  7791. if (nDevNo == 1) {
  7792. // 거실 조명 일괄제어일 경우
  7793. if (!unit_status.equalsIgnoreCase("null")) {
  7794. int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7795. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7796. }
  7797. if (!unit_dimming.equalsIgnoreCase("null")) {
  7798. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7799. }
  7800. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7801. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7802. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7803. return retStr;
  7804. }
  7805. retStr += " result=\"ok\">\r\n";
  7806. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7807. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7808. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7809. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7810. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7811. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7812. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7813. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7814. }
  7815. }
  7816. else if(nDevNo>1 && nDevNo<emCount+1){
  7817. // 각각 EM 조명 일괄제어일 경우
  7818. if (!unit_status.equalsIgnoreCase("null")) {
  7819. KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7820. }
  7821. if (!unit_dimming.equalsIgnoreCase("null")) {
  7822. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : ");
  7823. if( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_2 == 0x0F
  7824. || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_3 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_4 == 0x0F)
  7825. {
  7826. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] ==> Fan : " + nDevNo );
  7827. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7828. // 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
  7829. int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
  7830. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7831. }
  7832. }
  7833. else {
  7834. int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7835. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7836. }
  7837. //KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
  7838. }
  7839. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7840. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7841. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7842. return retStr;
  7843. }
  7844. retStr += " result=\"ok\">\r\n";
  7845. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7846. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7847. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7848. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  7849. nDevNo = Integer.parseInt(dev_num);
  7850. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7851. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7852. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7853. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7854. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7855. status_dim ="null";
  7856. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7857. }
  7858. } else {
  7859. // 각각 EM 스위치 일괄제어일 경우
  7860. if (!unit_status.equalsIgnoreCase("null")) {
  7861. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7862. }
  7863. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7864. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7865. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7866. return retStr;
  7867. }
  7868. retStr += " result=\"ok\">\r\n";
  7869. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7870. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7871. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7872. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-emCount-1] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount + "\">\r\n";
  7873. nDevNo = Integer.parseInt(dev_num);
  7874. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7875. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7876. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7877. String status_dim ="null";
  7878. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7879. }
  7880. }
  7881. // retStr += " </status_map>\r\n";
  7882. // retStr += " </service>\r\n</imap>\r\n";
  7883. }
  7884. else {
  7885. // 회로별 제어일경우
  7886. try {
  7887. nUnitNo = Integer.parseInt(unit_num);
  7888. } catch (Exception e) {
  7889. Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7890. e.printStackTrace();
  7891. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7892. return retStr;
  7893. }
  7894. if (nDevNo == 1) {
  7895. if (!unit_status.equalsIgnoreCase("null")) {
  7896. int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
  7897. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7898. }
  7899. if (!unit_dimming.equalsIgnoreCase("null")) {
  7900. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7901. //mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  7902. }
  7903. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7904. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7905. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7906. return retStr;
  7907. }
  7908. retStr += " result=\"ok\">\r\n";
  7909. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7910. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7911. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7912. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7913. nDevNo = Integer.parseInt(dev_num);
  7914. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7915. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7916. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7917. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7918. }
  7919. }
  7920. else if(nDevNo>1 && nDevNo<emCount+1){
  7921. if (!unit_status.equalsIgnoreCase("null")) {
  7922. KnxApi.SetLightOnOff((byte) (nDevNo -2), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7923. //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7924. //회로별 제어는 On/Off 만 가능함
  7925. }
  7926. if (!unit_dimming.equalsIgnoreCase("null")) {
  7927. KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)(nUnitNo-1),(byte) Integer.parseInt(unit_dimming));
  7928. //일괄제어라 회로별 제어기능은 없음
  7929. // 시험 2021.05.12
  7930. }
  7931. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7932. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7933. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7934. return retStr;
  7935. }
  7936. retStr += " result=\"ok\">\r\n";
  7937. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7938. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7939. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7940. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
  7941. nDevNo = Integer.parseInt(dev_num);
  7942. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7943. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7944. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7945. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7946. status_dim ="null";
  7947. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7948. }
  7949. } else{
  7950. if (!unit_status.equalsIgnoreCase("null")) {
  7951. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7952. }
  7953. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7954. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7955. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7956. return retStr;
  7957. }
  7958. retStr += " result=\"ok\">\r\n";
  7959. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7960. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7961. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7962. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-emCount-1] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount + "\">\r\n";
  7963. nDevNo = Integer.parseInt(dev_num);
  7964. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7965. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7966. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7967. String status_dim ="null";
  7968. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7969. }
  7970. }
  7971. }
  7972. retStr += " </status_map>\r\n";
  7973. retStr += " </service>\r\n</imap>\r\n";
  7974. }
  7975. }
  7976. else {
  7977. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7978. }
  7979. return retStr;
  7980. } catch (Exception e) {
  7981. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7982. e.printStackTrace();
  7983. return null;
  7984. }
  7985. }
  7986. public String iCMDProcLivingLightControl(Document ele) {
  7987. try {
  7988. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7989. String retStr = CheckiCMDProc("remote_access_livinglight");
  7990. if (retStr != null) return retStr;
  7991. else
  7992. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  7993. String target = "null", tid = "null", msgno = "null";
  7994. NodeList items = ele.getElementsByTagName("target");
  7995. Node item = items.item(0);
  7996. if (item != null) {
  7997. NamedNodeMap attrs = item.getAttributes();
  7998. for (int j = 0; j < attrs.getLength(); j++) {
  7999. Node attr = attrs.item(j);
  8000. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8001. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8002. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8003. msgno = attr.getNodeValue();
  8004. }
  8005. }
  8006. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8007. if (NewServerUse()) {
  8008. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8009. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8010. return ServerCheckResult;
  8011. }
  8012. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8013. if (bLightCMDUseAsSmartLight) {
  8014. if (mSdb_LivingRoomLightAPI != null) {
  8015. mSdb_LivingRoomLightAPI.Refresh();
  8016. 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";
  8017. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8018. 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");
  8019. }
  8020. retStr += " </service>\r\n</imap>\r\n";
  8021. } else {
  8022. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  8023. }
  8024. } else {
  8025. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8026. if (lightCTR != null) {
  8027. if (lightCTR.Refresh(false) == 0) {
  8028. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8029. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8030. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8031. }
  8032. retStr += " </service>\r\n</imap>\r\n";
  8033. } else {
  8034. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  8035. }
  8036. }
  8037. }
  8038. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8039. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  8040. boolean OnOff = false;
  8041. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  8042. if (bLightCMDUseAsSmartLight) {
  8043. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8044. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  8045. if (ret >= 0) {
  8046. ret = mSdb_LivingRoomLightAPI.Refresh();
  8047. if (ret >= 0) {
  8048. 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";
  8049. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8050. 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");
  8051. }
  8052. retStr += " </service>\r\n</imap>\r\n";
  8053. } else {
  8054. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8055. }
  8056. } else {
  8057. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8058. }
  8059. } else {
  8060. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8061. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  8062. if (ret >= 0) {
  8063. ret = mSdb_LivingRoomLightAPI.Refresh();
  8064. if (ret >= 0) {
  8065. 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";
  8066. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8067. 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");
  8068. }
  8069. retStr += " </service>\r\n</imap>\r\n";
  8070. } else {
  8071. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8072. }
  8073. } else {
  8074. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8075. }
  8076. }
  8077. } else {
  8078. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8079. if (lightCTR != null) {
  8080. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8081. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  8082. if (ret >= 0) {
  8083. ret = lightCTR.Refresh(false);
  8084. if (ret >= 0) {
  8085. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8086. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8087. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8088. }
  8089. retStr += " </service>\r\n</imap>\r\n";
  8090. } else {
  8091. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8092. }
  8093. } else {
  8094. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8095. }
  8096. } else {
  8097. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8098. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  8099. if (ret >= 0) {
  8100. ret = lightCTR.Refresh(false);
  8101. if (ret >= 0) {
  8102. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8103. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8104. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8105. }
  8106. retStr += " </service>\r\n</imap>\r\n";
  8107. } else {
  8108. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8109. }
  8110. } else {
  8111. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8112. }
  8113. }
  8114. }
  8115. }
  8116. } else {
  8117. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8118. }
  8119. } else {
  8120. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  8121. }
  8122. lightcmd = null;
  8123. return retStr;
  8124. } catch (RuntimeException re) {
  8125. LogUtil.errorLogInfo("", TAG, re);
  8126. return null;
  8127. } catch (Exception e) {
  8128. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  8129. //e.printStackTrace();
  8130. LogUtil.errorLogInfo("", TAG, e);
  8131. return null;
  8132. }
  8133. }
  8134. public String iCMDProc_I_LightControl(Document ele) {
  8135. try {
  8136. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  8137. String retStr = CheckiCMDProc("remote_access_livinglight");
  8138. if (retStr != null) return retStr;
  8139. else
  8140. retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  8141. String target = "null", tid = "null", msgno = "null";
  8142. NodeList items = ele.getElementsByTagName("target");
  8143. Node item = items.item(0);
  8144. if (item != null) {
  8145. NamedNodeMap attrs = item.getAttributes();
  8146. for (int j = 0; j < attrs.getLength(); j++) {
  8147. Node attr = attrs.item(j);
  8148. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8149. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8150. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8151. msgno = attr.getNodeValue();
  8152. }
  8153. }
  8154. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8155. if (NewServerUse()) {
  8156. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8157. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8158. return ServerCheckResult;
  8159. }
  8160. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  8161. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8162. if (lightCTR != null && lightCTR.Refresh(false) == 0) {
  8163. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8164. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8165. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8166. }
  8167. retStr += " </service>\r\n</imap>\r\n";
  8168. } else {
  8169. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  8170. }
  8171. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8172. if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  8173. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  8174. int result = -999;
  8175. if (lightCTR != null) {
  8176. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  8177. result = lightCTR.LightProgramControl((byte) num, (byte) 1);
  8178. } else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  8179. result = lightCTR.LightProgramControl((byte) num, (byte) 0);
  8180. }
  8181. if (result >= 0) {
  8182. // 제어 성공
  8183. try {
  8184. Thread.sleep(1000);
  8185. } catch (RuntimeException re) {
  8186. LogUtil.errorLogInfo("", TAG, re);
  8187. } catch (Exception e) {
  8188. LogUtil.errorLogInfo("", TAG, e);
  8189. }
  8190. lightCTR.Refresh(false);
  8191. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8192. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8193. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8194. }
  8195. retStr += " </service>\r\n</imap>";
  8196. } else {
  8197. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8198. }
  8199. } else {
  8200. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8201. }
  8202. } else {
  8203. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8204. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  8205. if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  8206. try {
  8207. Thread.sleep(1000);
  8208. } catch (RuntimeException re) {
  8209. LogUtil.errorLogInfo("", TAG, re);
  8210. } catch (Exception e) {
  8211. LogUtil.errorLogInfo("", TAG, e);
  8212. }
  8213. lightCTR.Refresh(false);
  8214. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8215. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8216. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8217. }
  8218. retStr += " </service>\r\n</imap>\r\n";
  8219. } else {
  8220. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8221. }
  8222. }
  8223. } else {
  8224. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  8225. }
  8226. lightcmd = null;
  8227. return retStr;
  8228. } catch (RuntimeException re) {
  8229. LogUtil.errorLogInfo("", TAG, re);
  8230. return null;
  8231. } catch (Exception e) {
  8232. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  8233. //e.printStackTrace();
  8234. LogUtil.errorLogInfo("", TAG, e);
  8235. return null;
  8236. }
  8237. }
  8238. public String iCMDProcGASControl(Element ele) {
  8239. try {
  8240. String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
  8241. String strResult = CheckiCMDProc("remote_access_gas");
  8242. if (strResult != null) return strResult;
  8243. else
  8244. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  8245. NodeList items = ele.getElementsByTagName("target");
  8246. Node item = items.item(0);
  8247. if (item != null) {
  8248. NamedNodeMap attrs = item.getAttributes();
  8249. for (int j = 0; j < attrs.getLength(); j++) {
  8250. Node attr = attrs.item(j);
  8251. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8252. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8253. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8254. msgno = attr.getNodeValue();
  8255. }
  8256. }
  8257. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8258. if (NewServerUse()) {
  8259. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  8260. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8261. return ServerCheckResult;
  8262. }
  8263. NodeList itemsParam = ele.getElementsByTagName("params");
  8264. Node itemParam = itemsParam.item(0);
  8265. if (itemParam != null) {
  8266. NamedNodeMap attrsParam = itemParam.getAttributes();
  8267. for (int j = 0; j < attrsParam.getLength(); j++) {
  8268. Node attr = attrsParam.item(j);
  8269. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8270. devnum = attr.getNodeValue();
  8271. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  8272. //unitnum = attr.getNodeValue();
  8273. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8274. ctraction = attr.getNodeValue();
  8275. }
  8276. }
  8277. NodeList itemsaction = ele.getElementsByTagName("action");
  8278. Node itemaction = itemsaction.item(0);
  8279. Node text = itemaction.getFirstChild();
  8280. String actionTXT = text.getNodeValue();
  8281. //수정
  8282. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  8283. actionTXT = trimquotation(actionTXT);
  8284. GasAPI GasValveCTR = null;
  8285. CooktopAPI HybridCookTopCTR = null;
  8286. if (mWallPadAPI.GetGasKind() == 2) {
  8287. //하이브리드
  8288. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  8289. } else {
  8290. GasValveCTR = mWallPadAPI.Get_GasController();
  8291. }
  8292. if (actionTXT.equalsIgnoreCase("status")) {
  8293. // 가스밸브 상태 조회
  8294. if (mWallPadAPI.GetGasKind() == 2) {
  8295. //하이브리드
  8296. if (HybridCookTopCTR != null) {
  8297. //전체 정보가져오기
  8298. int ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8299. if (ret < 0) {
  8300. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8301. return strResult;
  8302. }
  8303. int OnOpenCount = 0;
  8304. int OperationCount = 0;
  8305. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8306. // 콘센트 ON/OFF 업데이트
  8307. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8308. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8309. OnOpenCount++;
  8310. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8311. OperationCount++;
  8312. }
  8313. }
  8314. }
  8315. if (OperationCount > 0) {
  8316. valvestatus = "ing";
  8317. } else if (OnOpenCount > 0) {
  8318. valvestatus = "open";
  8319. } else {
  8320. valvestatus = "close";
  8321. }
  8322. }
  8323. } else {
  8324. if (GasValveCTR != null) {
  8325. int ret = GasValveCTR.Refresh((byte) 0, false);
  8326. if (ret < 0) {
  8327. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8328. return strResult;
  8329. }
  8330. if (GasValveCTR.data.DeviceCnt == 2) {
  8331. GasValveCTR.Refresh((byte) 1, false);
  8332. }
  8333. byte GasStatus = GasAPI.GASSTATUS.Close;
  8334. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8335. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8336. GasStatus = GasAPI.GASSTATUS.Operation;
  8337. break;
  8338. }
  8339. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8340. GasStatus = GasAPI.GASSTATUS.Open;
  8341. break;
  8342. }
  8343. }
  8344. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8345. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8346. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8347. else valvestatus = "unknown";
  8348. }
  8349. }
  8350. } else if (actionTXT.equalsIgnoreCase("control")) {
  8351. // 가스밸브 콘트롤
  8352. if (mWallPadAPI.GetGasKind() == 2) {
  8353. //하이브리드
  8354. if (HybridCookTopCTR != null) {
  8355. int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
  8356. if (ret < 0) {
  8357. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8358. return strResult;
  8359. }
  8360. ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8361. if (ret < 0) {
  8362. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8363. return strResult;
  8364. }
  8365. int OnOpenCount = 0;
  8366. int OperationCount = 0;
  8367. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8368. // 콘센트 ON/OFF 업데이트
  8369. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8370. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8371. OnOpenCount++;
  8372. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8373. OperationCount++;
  8374. }
  8375. }
  8376. }
  8377. if (OperationCount > 0) {
  8378. valvestatus = "ing";
  8379. } else if (OnOpenCount > 0) {
  8380. valvestatus = "open";
  8381. } else {
  8382. valvestatus = "close";
  8383. }
  8384. }
  8385. } else {
  8386. if (GasValveCTR != null) {
  8387. int ret = GasValveCTR.SetClose((byte) 0xFF);
  8388. if (ret < 0) {
  8389. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8390. return strResult;
  8391. }
  8392. ret = GasValveCTR.Refresh((byte) 0, false);
  8393. if (ret < 0) {
  8394. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8395. return strResult;
  8396. }
  8397. if (GasValveCTR.data.DeviceCnt == 2) {
  8398. GasValveCTR.Refresh((byte) 1, false);
  8399. }
  8400. byte GasStatus = GasAPI.GASSTATUS.Close;
  8401. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8402. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8403. GasStatus = GasAPI.GASSTATUS.Operation;
  8404. break;
  8405. }
  8406. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8407. GasStatus = GasAPI.GASSTATUS.Open;
  8408. break;
  8409. }
  8410. }
  8411. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8412. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8413. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8414. else valvestatus = "unknown";
  8415. }
  8416. }
  8417. } else {
  8418. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8419. return strResult;
  8420. }
  8421. strResult += "\"ok\" >\r\n";
  8422. strResult += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8423. strResult += " <action>\"" + actionTXT + "\"</action>\r\n";
  8424. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  8425. strResult += " <status_info unit_num=\"gas1\" unit_status=\"" + valvestatus + "\"/>\r\n";
  8426. strResult += " </service>\r\n";
  8427. strResult += "</imap> ";
  8428. return strResult;
  8429. } catch (RuntimeException re) {
  8430. LogUtil.errorLogInfo("", TAG, re);
  8431. return null;
  8432. } catch (Exception e) {
  8433. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  8434. //e.printStackTrace();
  8435. LogUtil.errorLogInfo("", TAG, e);
  8436. return null;
  8437. }
  8438. }
  8439. private String iCMDProcLightBatchControl(Element ele) {
  8440. try {
  8441. String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
  8442. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  8443. if (retStr != null) return retStr;
  8444. NodeList items = ele.getElementsByTagName("target");
  8445. Node item = items.item(0);
  8446. if (item != null) {
  8447. NamedNodeMap attrs = item.getAttributes();
  8448. for (int j = 0; j < attrs.getLength(); j++) {
  8449. Node attr = attrs.item(j);
  8450. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8451. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8452. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8453. msgno = attr.getNodeValue();
  8454. }
  8455. }
  8456. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8457. if (NewServerUse()) {
  8458. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8459. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8460. return ServerCheckResult;
  8461. }
  8462. NodeList itemsParam = ele.getElementsByTagName("params");
  8463. Node itemParam = itemsParam.item(0);
  8464. if (itemParam != null) {
  8465. NamedNodeMap attrsParam = itemParam.getAttributes();
  8466. for (int j = 0; j < attrsParam.getLength(); j++) {
  8467. Node attr = attrsParam.item(j);
  8468. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8469. ctraction = attr.getNodeValue();
  8470. }
  8471. }
  8472. }
  8473. NodeList itemsaction = ele.getElementsByTagName("action");
  8474. Node itemaction = itemsaction.item(0);
  8475. Node text = itemaction.getFirstChild();
  8476. String actionTXT = text.getNodeValue();
  8477. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  8478. actionTXT = trimquotation(actionTXT);
  8479. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8480. if (actionTXT.equalsIgnoreCase("status")) {
  8481. // 일괄소등 상태 조회
  8482. int ret = mWallPadAPI.GetBatchSwitchStatus();
  8483. if (ret > 1) {
  8484. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8485. return retStr;
  8486. }
  8487. if (ret == 0) {
  8488. ilgalstatus = "on";
  8489. } else if (ret == 1) {
  8490. ilgalstatus = "off";
  8491. } else {
  8492. ilgalstatus = "error";
  8493. }
  8494. } else if (actionTXT.equalsIgnoreCase("control")) {
  8495. // 일괄소등 제어
  8496. int ret = -1;
  8497. int status = -1;
  8498. if (ctraction.equals("on") == true) {
  8499. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  8500. status = 0;
  8501. } else if (ctraction.equals("off") == true) {
  8502. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  8503. status = 1;
  8504. }
  8505. if (ret < 0) {
  8506. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8507. return retStr;
  8508. }
  8509. if (status == 0) {
  8510. ilgalstatus = "on";
  8511. } else if (status == 1) {
  8512. ilgalstatus = "off";
  8513. } else {
  8514. ilgalstatus = "error";
  8515. }
  8516. } else {
  8517. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8518. return retStr;
  8519. }
  8520. retStr += "\"ok\" >\r\n";
  8521. retStr += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8522. retStr += " <action>\"" + actionTXT + "\"</action>\r\n";
  8523. retStr += " <status_info unit_status=\"" + ilgalstatus + "\"/>\r\n </service>\r\n</imap> ";
  8524. return retStr;
  8525. } catch (RuntimeException re) {
  8526. LogUtil.errorLogInfo("", TAG, re);
  8527. return null;
  8528. } catch (Exception e) {
  8529. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  8530. //e.printStackTrace();
  8531. LogUtil.errorLogInfo("", TAG, e);
  8532. return null;
  8533. }
  8534. }
  8535. private boolean airconTestMode = false;
  8536. private boolean [] airconTestModeOnOff = {false, true, false, true, false, true, false, true, false, true, false};
  8537. private String getTextSysAirconMode(byte in)
  8538. {
  8539. if( in == DataClasses.KnxSystemAircon.MODE.Auto)
  8540. return "auto";
  8541. else if( in == DataClasses.KnxSystemAircon.MODE.Cold)
  8542. return "cool";
  8543. else if( in == DataClasses.KnxSystemAircon.MODE.Dry)
  8544. return "dehum";
  8545. else if( in == DataClasses.KnxSystemAircon.MODE.Venti)
  8546. return "blow";
  8547. else if( in == DataClasses.KnxSystemAircon.MODE.Heat)
  8548. return "heat";
  8549. else
  8550. return "null";
  8551. }
  8552. private String iCMDProcSysairconControl(Element ele) {
  8553. try {
  8554. String target= "null", tid= "null", msgno= "null", devnum = "null",ctraction = "null", ilgalstatus = "null";
  8555. String retStr = CheckiCMDProc("remote_access_sysaircon");
  8556. if (retStr != null) return retStr;
  8557. NodeList items = ele.getElementsByTagName("target");
  8558. Node item = items.item(0);
  8559. if (item != null) {
  8560. NamedNodeMap attrs = item.getAttributes();
  8561. for (int j = 0; j < attrs.getLength(); j++) {
  8562. Node attr = attrs.item(j);
  8563. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8564. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8565. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  8566. }
  8567. }
  8568. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8569. if (NewServerUse()) {
  8570. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8571. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  8572. }
  8573. NodeList itemsParam = ele.getElementsByTagName("params");
  8574. Node itemParam = itemsParam.item(0);
  8575. if (itemParam != null) {
  8576. NamedNodeMap attrsParam = itemParam.getAttributes();
  8577. for (int j = 0; j < attrsParam.getLength(); j++) {
  8578. Node attr = attrsParam.item(j);
  8579. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  8580. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8581. ctraction = attr.getNodeValue();
  8582. }
  8583. }
  8584. }
  8585. NodeList itemsaction = ele.getElementsByTagName("action");
  8586. Node itemaction = itemsaction.item(0);
  8587. Node text = itemaction.getFirstChild();
  8588. String actionTXT = text.getNodeValue();
  8589. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_sysaircon\" result=";
  8590. actionTXT = trimquotation(actionTXT);
  8591. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8592. int ndeviceCount = 0;
  8593. String sMode = "auto/cool/dehum/blow/heat"; // 자동, 냉방, 제습, 송풍, 난방
  8594. String [] aMode = {"auto","cool","dehum","blow","heat"};
  8595. String strResultStatus = "";
  8596. //기준층 명칭
  8597. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  8598. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  8599. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_SYSTEMAIRCON);
  8600. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  8601. String [] mTextWindType = {"자동", "약", "중", "강"};
  8602. String m_TextWindRange = "자동/약/중/강";
  8603. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  8604. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  8605. mWallpadDeviceSet.closeDB();
  8606. if (nResult != Version.DISTRIBUTION_MODEL.KNX_DIST) {
  8607. String[] mAirconNmae = new String[]{"에어컨1", "에어컨2", "에어컨3", "에어컨4", "에어컨5", "에어컨6", "에어컨7", "에어컨8"};
  8608. knxRoomNameList = mAirconNmae;
  8609. }
  8610. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  8611. int nCount = 7;
  8612. if( airconAPI != null )
  8613. nCount = airconAPI.data.Device.info.InsideAirconCount;
  8614. if( airconTestMode == true )nCount = 7;
  8615. if( actionTXT.equalsIgnoreCase("status") ) {
  8616. // 에어컨 상태조회
  8617. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8618. if (devnum.equalsIgnoreCase("all")) {
  8619. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : airconTestMode : " + airconTestMode + " nCount : " + nCount );
  8620. if (airconTestMode == false && ret < 0) {
  8621. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8622. return retStr;
  8623. } else {
  8624. for (int i = 0; i < nCount; i++) {
  8625. String sOnOff = "off";
  8626. if( airconTestMode == true )
  8627. {
  8628. if( airconTestModeOnOff[i] == true )sOnOff = "on";
  8629. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8630. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8631. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8632. }
  8633. else {
  8634. if (airconAPI.data.Device.Aircon[i].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8635. sOnOff = "on";
  8636. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8637. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i]+ "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(airconAPI.data.Device.Aircon[i].Mode) + "/" + mTextWindType[airconAPI.data.Device.Aircon[i].Volume] + "/" + airconAPI.data.Device.Aircon[i].SetTemp + "/" + airconAPI.data.Device.Aircon[i].NowTemp + "\"/>\r\n";
  8638. }
  8639. }
  8640. }
  8641. }
  8642. else
  8643. {
  8644. // 개별 상태 조회
  8645. if (airconTestMode == false && ret < 0) {
  8646. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8647. return retStr;
  8648. } else {
  8649. int reqDevNum = Integer.parseInt(devnum);
  8650. String sOnOff = "off";
  8651. if( airconTestMode == true )
  8652. {
  8653. if( airconTestModeOnOff[reqDevNum-1] == true )sOnOff = "on";
  8654. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8655. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8656. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8657. }
  8658. else {
  8659. if (airconAPI.data.Device.Aircon[reqDevNum-1].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8660. sOnOff = "on";
  8661. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8662. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1]+ "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(airconAPI.data.Device.Aircon[reqDevNum-1].Mode) + "/" + mTextWindType[airconAPI.data.Device.Aircon[reqDevNum-1].Volume] + "/" + airconAPI.data.Device.Aircon[reqDevNum-1].SetTemp + "/" + airconAPI.data.Device.Aircon[reqDevNum-1].NowTemp + "\"/>\r\n";
  8663. }
  8664. }
  8665. }
  8666. }
  8667. else if (actionTXT.equalsIgnoreCase("control")) {
  8668. // 에어컨 제어
  8669. String[] CtrList;
  8670. CtrList = ctraction.split("/");
  8671. for( int k = 0 ; k < CtrList.length; k++)
  8672. {
  8673. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : CtrList[k] : " + k + " CtrList[k] : " + CtrList[k]);
  8674. }
  8675. strResultStatus = "";
  8676. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8677. if (devnum.equalsIgnoreCase("all")) {
  8678. // 일괄제어는 Off 밖에 없음
  8679. if( airconTestMode == true )
  8680. {
  8681. for (int i = 0; i < nCount; i++) {
  8682. String sOnOff = "off";
  8683. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8684. if(CtrList[0].equalsIgnoreCase("off"))
  8685. {
  8686. airconTestModeOnOff[i] = false;
  8687. }
  8688. else
  8689. {
  8690. airconTestModeOnOff[i] = true;
  8691. sOnOff = "on";
  8692. }
  8693. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8694. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8695. }
  8696. }
  8697. else
  8698. {
  8699. for (int i = 0; i < nCount; i++) {
  8700. String sOnOff = "off";
  8701. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8702. byte hOnOff = 0x00;
  8703. if(CtrList[0].equalsIgnoreCase("off"))
  8704. {
  8705. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8706. sOnOff = "off";
  8707. }
  8708. else
  8709. {
  8710. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8711. sOnOff = "on";
  8712. }
  8713. double setTemp = airconAPI.data.Device.Aircon[i].SetTemp;
  8714. byte volume = airconAPI.data.Device.Aircon[i].Volume;
  8715. byte mode = airconAPI.data.Device.Aircon[i].Mode;
  8716. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8717. ret = airconAPI.SetEachRoomStatus((byte)i, hMode, setTemp);
  8718. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8719. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i]+ "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume]+ "/" + setTemp + "/" + airconAPI.data.Device.Aircon[i].NowTemp + "\"/>\r\n";
  8720. }
  8721. }
  8722. }
  8723. else
  8724. {
  8725. // 개별 제어
  8726. int nDevNum = Integer.parseInt(devnum);
  8727. if( airconTestMode == true )
  8728. {
  8729. String sOnOff = "off";
  8730. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8731. if(CtrList[0].equalsIgnoreCase("off"))
  8732. {
  8733. airconTestModeOnOff[nDevNum-1] = false;
  8734. }
  8735. else
  8736. {
  8737. airconTestModeOnOff[nDevNum-1] = true;
  8738. sOnOff = "on";
  8739. }
  8740. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8741. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8742. }
  8743. else
  8744. {
  8745. String sOnOff = "off";
  8746. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8747. byte hOnOff = 0x00;
  8748. if(CtrList[0].equalsIgnoreCase("off"))
  8749. {
  8750. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8751. sOnOff = "off";
  8752. }
  8753. else
  8754. {
  8755. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8756. sOnOff = "on";
  8757. }
  8758. //String [] aMode = {"auto","cool","dehum","blow","heat"};
  8759. byte mode = 0x00;
  8760. if(CtrList[1].equalsIgnoreCase("auto"))
  8761. mode = DataClasses.KnxSystemAircon.MODE.Auto;
  8762. else if(CtrList[1].equalsIgnoreCase("cool"))
  8763. mode = DataClasses.KnxSystemAircon.MODE.Cold;
  8764. else if(CtrList[1].equalsIgnoreCase("dehum"))
  8765. mode = DataClasses.KnxSystemAircon.MODE.Dry;
  8766. else if(CtrList[1].equalsIgnoreCase("blow"))
  8767. mode = DataClasses.KnxSystemAircon.MODE.Venti;
  8768. else if(CtrList[1].equalsIgnoreCase("heat"))
  8769. mode = DataClasses.KnxSystemAircon.MODE.Heat;
  8770. else
  8771. mode = airconAPI.data.Device.Aircon[nDevNum-1].Mode;
  8772. byte volume = 0x00;
  8773. if(CtrList[2].equalsIgnoreCase(mTextWindType[0]))
  8774. volume = DataClasses.KnxSystemAircon.VOLUME.Auto;
  8775. else if(CtrList[2].equalsIgnoreCase(mTextWindType[1]))
  8776. volume = DataClasses.KnxSystemAircon.VOLUME.Weak;
  8777. else if(CtrList[2].equalsIgnoreCase(mTextWindType[2]))
  8778. volume = DataClasses.KnxSystemAircon.VOLUME.Medium;
  8779. else if(CtrList[2].equalsIgnoreCase(mTextWindType[3]))
  8780. volume = DataClasses.KnxSystemAircon.VOLUME.Strong;
  8781. else
  8782. volume = airconAPI.data.Device.Aircon[nDevNum-1].Volume;
  8783. double setTemp = 0;
  8784. if( CtrList[3].equalsIgnoreCase("null"))
  8785. setTemp = airconAPI.data.Device.Aircon[nDevNum-1].SetTemp;
  8786. else
  8787. setTemp = Double.parseDouble(CtrList[3]);
  8788. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8789. ret = airconAPI.SetEachRoomStatus((byte)(nDevNum-1), hMode, setTemp);
  8790. if( ret >= 0 ) {
  8791. ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8792. }
  8793. double curTemp = airconAPI.data.Device.Aircon[nDevNum-1].NowTemp;
  8794. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8795. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume] + "/" + setTemp + "/" + curTemp + "\"/>\r\n";
  8796. }
  8797. }
  8798. }
  8799. else {
  8800. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8801. return retStr;
  8802. }
  8803. retStr += "\"ok\" >\r\n";
  8804. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  8805. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  8806. retStr += strResultStatus;
  8807. retStr += " </service>\r\n";
  8808. retStr += "</imap> ";
  8809. return retStr;
  8810. } catch (Exception e) {
  8811. Log.e(TAG, "[Exception] iCMDProcSysairconControl(Document ele)");
  8812. e.printStackTrace();
  8813. return null;
  8814. }
  8815. }
  8816. private String iCMDProcEntireLightControl(Document ele) {
  8817. try {
  8818. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  8819. if (retStr != null) return retStr;
  8820. else
  8821. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  8822. String sDong = null;
  8823. String sHo = null;
  8824. String sDevice_Num = null;
  8825. String sSelCtrl_Action = null;
  8826. String sUnselCtrl_Action = null;
  8827. NodeList items = ele.getElementsByTagName("home_info");
  8828. Node item = items.item(0);
  8829. NamedNodeMap attrsParam = item.getAttributes();
  8830. for (int i = 0; i < attrsParam.getLength(); i++) {
  8831. Node attr = attrsParam.item(i);
  8832. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8833. sDong = trimquotation(attr.getNodeValue());
  8834. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8835. sHo = trimquotation(attr.getNodeValue());
  8836. }
  8837. WallpadStatusData DBMGR = null;
  8838. DBMGR = new WallpadStatusData(getApplicationContext());
  8839. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8840. DBMGR.closeDB();
  8841. if (mSdb_LivingRoomLightAPI == null) {
  8842. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  8843. retStr += " result=\"fail\" >\r\n";
  8844. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8845. retStr += " </service>\r\n</imap>";
  8846. return retStr;
  8847. }
  8848. if (mSdbAPI == null) {
  8849. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  8850. retStr += " result=\"fail\" >\r\n";
  8851. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8852. retStr += " </service>\r\n</imap>";
  8853. return retStr;
  8854. }
  8855. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
  8856. items = ele.getElementsByTagName("sel_ctrlinfo");
  8857. item = items.item(0);
  8858. attrsParam = item.getAttributes();
  8859. for (int i = 0; i < attrsParam.getLength(); i++) {
  8860. Node attr = attrsParam.item(i);
  8861. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8862. sDevice_Num = trimquotation(attr.getNodeValue());
  8863. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8864. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  8865. }
  8866. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  8867. int result = -1; // 조명 제어 결과
  8868. boolean bLivingLightSel = false; // 거실조명 선택 여부
  8869. // ============================== 선택된 조명 ==============================
  8870. String[] sel_devNum = null;
  8871. if (sDevice_Num != null && sDevice_Num.contains("light")) {
  8872. if (sDevice_Num.contains("/"))
  8873. sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  8874. else {
  8875. sel_devNum = new String[1];
  8876. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  8877. }
  8878. }
  8879. if (sel_devNum == null) sel_devNum = new String[0];
  8880. for (int i = 0; i < sel_devNum.length; i++) {
  8881. if (sel_devNum[i].equals("1")) {
  8882. bLivingLightSel = true;
  8883. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  8884. if (sSelCtrl_Action != null) {
  8885. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8886. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8887. } else {
  8888. int nColor = 0;
  8889. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8890. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8891. if (nColor > 0) {
  8892. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8893. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8894. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8895. }
  8896. }
  8897. // 거실조명 제어 결과
  8898. if (result < 0) {
  8899. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  8900. retStr += " result=\"fail\" >\r\n";
  8901. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8902. retStr += " </service>\r\n</imap>";
  8903. return retStr;
  8904. }
  8905. }
  8906. } else {
  8907. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  8908. if (sSelCtrl_Action != null) {
  8909. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8910. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  8911. } else {
  8912. int nColor = 0;
  8913. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8914. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8915. if (nColor > 0) {
  8916. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  8917. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  8918. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  8919. }
  8920. }
  8921. }
  8922. // 그 외 방 조명 제어 결과
  8923. if (result < 0) {
  8924. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  8925. retStr += " result=\"fail\" >\r\n";
  8926. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8927. retStr += " </service>\r\n</imap>";
  8928. return retStr;
  8929. }
  8930. }
  8931. }
  8932. // ============================== 선택안된 조명 ==============================
  8933. items = ele.getElementsByTagName("unsel_ctrlinfo");
  8934. item = items.item(0);
  8935. attrsParam = item.getAttributes();
  8936. for (int i = 0; i < attrsParam.getLength(); i++) {
  8937. Node attr = attrsParam.item(i);
  8938. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8939. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  8940. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  8941. }
  8942. if (!bLivingLightSel) {
  8943. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  8944. if (sUnselCtrl_Action != null) {
  8945. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8946. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8947. } else {
  8948. int nColor = 0;
  8949. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8950. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8951. if (nColor > 0) {
  8952. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8953. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8954. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8955. }
  8956. }
  8957. }
  8958. if (result < 0) {
  8959. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  8960. retStr += " result=\"fail\" >\r\n";
  8961. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8962. retStr += " </service>\r\n</imap>";
  8963. return retStr;
  8964. }
  8965. }
  8966. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  8967. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  8968. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  8969. unsel_devNum.add(i + 1);
  8970. }
  8971. for (int i = 0; i < unsel_devNum.size(); i++) {
  8972. for (int j = 0; j < sel_devNum.length; j++) {
  8973. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
  8974. unsel_devNum.remove(i);
  8975. }
  8976. }
  8977. for (int i = 0; i < unsel_devNum.size(); i++) {
  8978. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
  8979. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8980. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  8981. } else {
  8982. int nColor = 0;
  8983. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8984. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8985. if (nColor > 0) {
  8986. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  8987. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  8988. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  8989. }
  8990. }
  8991. if (result < 0) {
  8992. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  8993. retStr += " result=\"fail\" >\r\n";
  8994. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8995. retStr += " </service>\r\n</imap>";
  8996. return retStr;
  8997. }
  8998. }
  8999. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  9000. retStr += " result=\"ok\">\r\n";
  9001. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9002. retStr += " </service>\r\n</imap>";
  9003. return retStr;
  9004. } else {
  9005. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  9006. retStr += " result=\"fail\" >\r\n";
  9007. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9008. retStr += " </service>\r\n</imap>";
  9009. return retStr;
  9010. }
  9011. } catch (RuntimeException re) {
  9012. LogUtil.errorLogInfo("", TAG, re);
  9013. return null;
  9014. } catch (Exception e) {
  9015. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  9016. //e.printStackTrace();
  9017. LogUtil.errorLogInfo("", TAG, e);
  9018. return null;
  9019. }
  9020. }
  9021. // 월패드에 원격제어 사용 여부를 확인하다.
  9022. private String CheckiCMDProc(String CMDStr) {
  9023. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  9024. try {
  9025. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  9026. mWallpadStatusData.closeDB();
  9027. if (!bRemoteCtrlEnabled) {
  9028. String retXML = XMLHeader + "<service type=\"reply\" name=\"" + CMDStr + "\" result=\"deny\">\r\n" +
  9029. " </service>\r\n</imap>";
  9030. return retXML;
  9031. }
  9032. return null;
  9033. } catch (RuntimeException re) {
  9034. LogUtil.errorLogInfo("", TAG, re);
  9035. mWallpadStatusData.closeDB();
  9036. return null;
  9037. } catch (Exception e) {
  9038. mWallpadStatusData.closeDB();
  9039. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  9040. //e.printStackTrace();
  9041. LogUtil.errorLogInfo("", TAG, e);
  9042. return null;
  9043. }
  9044. }
  9045. //메인으로 공지 해야 할 노티 사항을 처리
  9046. public String ProcEventNotify(Element ele) {
  9047. try {
  9048. NodeList items = ele.getElementsByTagName("event");
  9049. Node item = items.item(0);
  9050. Node text = item.getFirstChild();
  9051. String eventTXT = trimquotation(text.getNodeValue());
  9052. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  9053. // 새로운 공지사항 존재
  9054. wakeupLCD();
  9055. Intent intent = new Intent();
  9056. intent.setAction(define.NOTIFY_ACNAME);
  9057. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9058. getApplicationContext().sendBroadcast(intent);
  9059. } else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  9060. // 택배 도착
  9061. wakeupLCD();
  9062. Intent intent = new Intent();
  9063. intent.setAction(define.NOTIFY_ACNAME);
  9064. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9065. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  9066. intent.putExtra("REMAIN_CNT", 1);
  9067. getApplicationContext().sendBroadcast(intent);
  9068. } else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  9069. // 택배 반출
  9070. wakeupLCD();
  9071. Intent intent = new Intent();
  9072. intent.setAction(define.NOTIFY_ACNAME);
  9073. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9074. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  9075. intent.putExtra("REMAIN_CNT", 0);
  9076. getApplicationContext().sendBroadcast(intent);
  9077. } else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  9078. // 등록된 차량 도착
  9079. wakeupLCD();
  9080. // 팝업을 띄우도록 하자
  9081. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9082. Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
  9083. } else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  9084. // 내려가는 방향의 엘리베이터가 도착함
  9085. if (ElevatorDown != null) {
  9086. ElevatorDown.TimeOutCancel();
  9087. ElevatorDown.ClearElevator();
  9088. }
  9089. Intent intent = new Intent();
  9090. intent.setAction(define.NOTIFY_ACNAME);
  9091. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  9092. getApplicationContext().sendBroadcast(intent);
  9093. } else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  9094. // 올라가는 방향의 엘리베이터가 도착함
  9095. if (ElevatorUp != null) {
  9096. ElevatorUp.TimeOutCancel();
  9097. ElevatorUp.ClearElevator();
  9098. }
  9099. Intent intent = new Intent();
  9100. intent.setAction(define.NOTIFY_ACNAME);
  9101. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  9102. getApplicationContext().sendBroadcast(intent);
  9103. } else {
  9104. }
  9105. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  9106. "<event> \"" + eventTXT + "\" </event>\r\n" + " </service>\r\n </imap> ";
  9107. return returnStr;
  9108. } catch (RuntimeException re) {
  9109. LogUtil.errorLogInfo("", TAG, re);
  9110. return null;
  9111. } catch (Exception e) {
  9112. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  9113. //e.printStackTrace();
  9114. LogUtil.errorLogInfo("", TAG, e);
  9115. return null;
  9116. }
  9117. }
  9118. public String GetAttributeVal(Node node, String attname) {
  9119. NamedNodeMap attrs = node.getAttributes();
  9120. for (int j = 0; j < attrs.getLength(); j++) {
  9121. Node attr = attrs.item(j);
  9122. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  9123. }
  9124. return null;
  9125. }
  9126. public class imageFileFilter implements FilenameFilter {
  9127. public boolean accept(File dir, String name) {
  9128. 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"))
  9129. return true;
  9130. else return false;
  9131. }
  9132. }
  9133. public String ProcCheckEpiceUpload(Document ele) {
  9134. try {
  9135. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  9136. NodeList items = ele.getElementsByTagName("filename");
  9137. Node item = items.item(0);
  9138. Node text = item.getFirstChild();
  9139. String filename = trimquotation(text.getNodeValue());
  9140. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  9141. String duplicate = null;
  9142. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  9143. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  9144. if (!dirInternal.exists()) dirInternal.mkdir();
  9145. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9146. AddressSet addr = SetData.getAddressMGR();
  9147. if (!dirInternal.exists()) {
  9148. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9149. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + define.MAX_ALBUM_PICTURE + "\" available=\"0\" duplicate=\"new\"/>\r\n" +
  9150. " </service>\r\n</imap>";
  9151. return returnStr;
  9152. }
  9153. imageFileFilter jpegfilter = new imageFileFilter();
  9154. String[] subfile = dirInternal.list(jpegfilter);
  9155. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  9156. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  9157. if (checkFile.exists()) duplicate = "exist";
  9158. else duplicate = "new";
  9159. if (subfile != null) {
  9160. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9161. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + subfile.length + "\" available=\"" + (define.MAX_ALBUM_PICTURE - subfile.length) + "\" duplicate=\"" + duplicate + "\"/>\r\n" +
  9162. " </service>\r\n</imap>";
  9163. }
  9164. SetData.closeDB();
  9165. return returnStr;
  9166. } catch (RuntimeException re) {
  9167. LogUtil.errorLogInfo("", TAG, re);
  9168. return null;
  9169. } catch (Exception e) {
  9170. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  9171. //e.printStackTrace();
  9172. LogUtil.errorLogInfo("", TAG, e);
  9173. return null;
  9174. }
  9175. }
  9176. private void playNotifySound(int nSoundID) {
  9177. try {
  9178. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9179. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9180. if (getCompareBSPVersion()) {
  9181. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  9182. } else {
  9183. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9184. }
  9185. boolean NeedPlay = false;
  9186. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9187. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  9188. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  9189. } else {
  9190. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  9191. }
  9192. SetData.closeDB();
  9193. if (NeedPlay) Sound().PlayMent(nSoundID);
  9194. } catch (RuntimeException re) {
  9195. LogUtil.errorLogInfo("", TAG, re);
  9196. } catch (Exception e) {
  9197. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  9198. //e.printStackTrace();
  9199. LogUtil.errorLogInfo("", TAG, e);
  9200. }
  9201. }
  9202. private void wakeupLCD() {
  9203. try {
  9204. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9205. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9206. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9207. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  9208. int AlarmStatus = WsDB.GetAlarmStatus();
  9209. WsDB.closeDB();
  9210. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  9211. Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
  9212. return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
  9213. } else {
  9214. Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
  9215. mIOInterface.ctrlLcdWakeUp();
  9216. }
  9217. } catch (RuntimeException re) {
  9218. LogUtil.errorLogInfo("", TAG, re);
  9219. } catch (Exception e) {
  9220. Log.e(TAG, "[Exception] wakeupLCD()");
  9221. //e.printStackTrace();
  9222. LogUtil.errorLogInfo("", TAG, e);
  9223. }
  9224. }
  9225. /**
  9226. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  9227. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  9228. * Jeff, 2020.09.07
  9229. *
  9230. * @return true: LCD backlight On, false: LCD backlight Off
  9231. */
  9232. public boolean checkLCDOnByCMD() {
  9233. try {
  9234. Runtime mRuntime = Runtime.getRuntime();
  9235. Process mProcess;
  9236. String cmd = "getprop persist.sys.lcdcon";
  9237. mProcess = mRuntime.exec(cmd);
  9238. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  9239. String line;
  9240. String strResult = null;
  9241. while ((line = br.readLine()) != null) {
  9242. strResult = line;
  9243. }
  9244. if (strResult != null) {
  9245. if (strResult.equals("0")) {
  9246. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  9247. return true;
  9248. } else if (strResult.equals("1")) {
  9249. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  9250. return false;
  9251. } else {
  9252. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  9253. return false;
  9254. }
  9255. } else
  9256. return false;
  9257. } catch (RuntimeException re) {
  9258. LogUtil.errorLogInfo("", TAG, re);
  9259. return false;
  9260. } catch (Exception e) {
  9261. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  9262. //e.printStackTrace();
  9263. LogUtil.errorLogInfo("", TAG, e);
  9264. return false;
  9265. }
  9266. }
  9267. /**
  9268. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  9269. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  9270. *
  9271. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  9272. */
  9273. public boolean getCompareBSPVersion() {
  9274. try {
  9275. StringBuilder strBSPVersion = new StringBuilder();
  9276. StringBuffer sysInfoBuffer = new StringBuffer();
  9277. sysInfoBuffer.append(Build.DISPLAY);
  9278. strBSPVersion.append(sysInfoBuffer.toString());
  9279. String result = strBSPVersion.toString();
  9280. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  9281. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  9282. Date date = simpleDateFormat.parse(result);
  9283. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  9284. if (date.compareTo(standardDate) >= 0) {
  9285. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  9286. return true;
  9287. }
  9288. } catch (RuntimeException re) {
  9289. LogUtil.errorLogInfo("", TAG, re);
  9290. } catch (Exception e) {
  9291. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  9292. //e.printStackTrace();
  9293. LogUtil.errorLogInfo("", TAG, e);
  9294. }
  9295. return false;
  9296. }
  9297. public String ProcUpdateWeather(Document ele) {
  9298. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  9299. String nowloc = "";
  9300. String nowlcode = "";
  9301. String nowdate = "";
  9302. String nowtext = "";
  9303. String nowcode = "";
  9304. String nowtemp = "";
  9305. String nowlo = "", nowhigh = "";
  9306. NodeList items = ele.getElementsByTagName("now");
  9307. Node item = items.item(0);
  9308. if (item == null)
  9309. return resultstr += "\"fail\"/> \r\n </imap>";
  9310. NamedNodeMap attrsParam = item.getAttributes();
  9311. for (int j = 0; j < attrsParam.getLength(); j++) {
  9312. Node attr = attrsParam.item(j);
  9313. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  9314. else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
  9315. nowlcode = attr.getNodeValue();
  9316. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  9317. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  9318. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  9319. else if (attr.getNodeName().equalsIgnoreCase("temperature"))
  9320. nowtemp = attr.getNodeValue();
  9321. }
  9322. items = ele.getElementsByTagName("week");
  9323. String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
  9324. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9325. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  9326. Weathertbl.InitWeatherTable();
  9327. for (int i = 0; i < items.getLength(); i++) {
  9328. item = items.item(i);
  9329. attrsParam = item.getAttributes();
  9330. for (int j = 0; j < attrsParam.getLength(); j++) {
  9331. Node attr = attrsParam.item(j);
  9332. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  9333. else if (attr.getNodeName().equalsIgnoreCase("text"))
  9334. weektext = attr.getNodeValue();
  9335. else if (attr.getNodeName().equalsIgnoreCase("code"))
  9336. weekcode = attr.getNodeValue();
  9337. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  9338. else if (attr.getNodeName().equalsIgnoreCase("high"))
  9339. weekhigh = attr.getNodeValue();
  9340. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  9341. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  9342. }
  9343. if (i == 0) {
  9344. nowlo = weeklow;
  9345. nowhigh = weekhigh;
  9346. }
  9347. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  9348. }
  9349. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  9350. Intent intent = new Intent();
  9351. intent.setAction(define.NOTIFY_ACNAME);
  9352. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  9353. intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
  9354. getApplicationContext().sendBroadcast(intent);
  9355. String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
  9356. 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);
  9357. //air
  9358. items = ele.getElementsByTagName("air");
  9359. String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
  9360. item = items.item(0);
  9361. if (item != null) {
  9362. attrsParam = item.getAttributes();
  9363. for (int j = 0; j < attrsParam.getLength(); j++) {
  9364. Node attr = attrsParam.item(j);
  9365. if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
  9366. else if (attr.getNodeName().equalsIgnoreCase("pm25"))
  9367. airpm25 = attr.getNodeValue();
  9368. else if (attr.getNodeName().equalsIgnoreCase("co2"))
  9369. airco2 = attr.getNodeValue();
  9370. else if (attr.getNodeName().equalsIgnoreCase("ozone"))
  9371. airozone = attr.getNodeValue();
  9372. else if (attr.getNodeName().equalsIgnoreCase("air_index"))
  9373. air_index = attr.getNodeValue();
  9374. }
  9375. Intent intentAir = new Intent();
  9376. intentAir.setAction(define.NOTIFY_ACNAME);
  9377. intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
  9378. getApplicationContext().sendBroadcast(intentAir);
  9379. DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
  9380. }
  9381. DBMGR.closeDB();
  9382. return resultstr += "\"ok\"/> \r\n </imap>";
  9383. }
  9384. //iMAP update_news 처리
  9385. public String ProcUpdateNews(Document ele) {
  9386. NodeList items = ele.getElementsByTagName("ver_news");
  9387. Node item = items.item(0);
  9388. String strNewsVer = item.getTextContent();
  9389. strNewsVer = trimquotation(strNewsVer);
  9390. String retXML = XMLHeader + "<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n" +
  9391. " <ver_news>\"" + strNewsVer + "\"</ver_news>\r\n<service/>\r\n</imap>";
  9392. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9393. String NotiVer = DBMGR.GetNoticeVer();
  9394. int noticeCNT = DBMGR.GetNoticeCNT();
  9395. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  9396. String[] spdt = strNewsVer.split("[.]");
  9397. noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
  9398. } else {
  9399. String[] spdt = strNewsVer.split("[.]");
  9400. int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
  9401. spdt = NotiVer.split("[.]");
  9402. newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
  9403. noticeCNT += newcnt;
  9404. }
  9405. Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
  9406. DBMGR.SetNoticeVer(strNewsVer);
  9407. DBMGR.SetNoticeCNT(noticeCNT);
  9408. DBMGR.closeDB();
  9409. if (NotiVer.compareTo(strNewsVer) != 0) {
  9410. Intent intent = new Intent();
  9411. intent.setAction(define.NOTIFY_ACNAME);
  9412. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9413. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  9414. getApplicationContext().sendBroadcast(intent);
  9415. }
  9416. return retXML;
  9417. }
  9418. //iMAP check_lobby_passwd 처리
  9419. public String CheckPassword(Document doc) {
  9420. NodeList items = doc.getElementsByTagName("inpasswd");
  9421. Node item = items.item(0);
  9422. Node text = item.getFirstChild();
  9423. String passwd = trimquotation(text.getNodeValue());
  9424. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9425. String settedpasswd = DBMGR.GetUserPW();
  9426. DBMGR.closeDB();
  9427. String retString = XMLHeader;
  9428. Common.DebugLog("================ CheckPassword ================ ");
  9429. Common.DebugLog("Saved Password :" + settedpasswd);
  9430. Common.DebugLog("Input Password :" + passwd);
  9431. Common.DebugLog("================ CheckPassword ================ ");
  9432. if (settedpasswd.equals(passwd)) {
  9433. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  9434. } else {
  9435. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>" + passwd + "</wrongpasswd>\r\n</service>";
  9436. }
  9437. retString += "</imap>";
  9438. return retString;
  9439. }
  9440. //schedule_renew 처리
  9441. protected String ProcSchduleRenew(Document doc) {
  9442. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n " +
  9443. "<homeaddr dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" /> \r\n </service> \r\n </imap>";
  9444. WallpadScheduleData schedulDB = null;
  9445. try {
  9446. NodeList items = doc.getElementsByTagName("renew_info");
  9447. schedulDB = new WallpadScheduleData(getApplicationContext());
  9448. for (int i = 0; i < items.getLength(); i++) {
  9449. Node item = items.item(i);
  9450. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  9451. NamedNodeMap attrsParam = item.getAttributes();
  9452. String Type = "none";
  9453. for (int j = 0; j < attrsParam.getLength(); j++) {
  9454. Node attr = attrsParam.item(j);
  9455. String name = attr.getNodeName();
  9456. String Val = attr.getNodeValue();
  9457. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  9458. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  9459. else if (name.equalsIgnoreCase("rn_type"))
  9460. Type = Val;
  9461. else if (name.equalsIgnoreCase("rn_t_type"))
  9462. SCdata.inqttype = Val;
  9463. else if (name.equalsIgnoreCase("rn_c_type"))
  9464. SCdata.inqctype = Val;
  9465. else if (name.equalsIgnoreCase("rn_a_type"))
  9466. SCdata.inqatype = Val;
  9467. else if (name.equalsIgnoreCase("rn_i_type"))
  9468. SCdata.inqitype = Val;
  9469. else if (name.equalsIgnoreCase("rn_year"))
  9470. SCdata.inqyear = Integer.parseInt(Val);
  9471. else if (name.equalsIgnoreCase("rn_month"))
  9472. SCdata.inqmonth = Integer.parseInt(Val);
  9473. else if (name.equalsIgnoreCase("rn_day"))
  9474. SCdata.inqday = Integer.parseInt(Val);
  9475. else if (name.equalsIgnoreCase("rn_hour"))
  9476. SCdata.inqhour = Integer.parseInt(Val);
  9477. else if (name.equalsIgnoreCase("rn_message"))
  9478. SCdata.inqmsg = Val;
  9479. }
  9480. if (Type.equals("delete")) {
  9481. schedulDB.DeleteSchedule(SCdata);
  9482. } else if (Type.equals("add")) {
  9483. schedulDB.AddSchedule(SCdata);
  9484. } else if (Type.equals("change")) {
  9485. schedulDB.UpdateSchedule(SCdata);
  9486. }
  9487. }
  9488. schedulDB.closeDB();
  9489. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  9490. // Intent intent = new Intent();
  9491. // intent.setAction(define.NOTIFY_ACNAME);
  9492. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9493. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  9494. // getApplicationContext().sendBroadcast(intent);
  9495. } catch (RuntimeException re) {
  9496. LogUtil.errorLogInfo("", TAG, re);
  9497. if (schedulDB != null) schedulDB.closeDB();
  9498. } catch (Exception e) {
  9499. //e.printStackTrace();
  9500. LogUtil.errorLogInfo("", TAG, e);
  9501. if (schedulDB != null) schedulDB.closeDB();
  9502. }
  9503. return retXML;
  9504. }
  9505. //schedule_inquiry 처리
  9506. @SuppressWarnings("unused")
  9507. public String ProcSchduleInquiry(Document doc) {
  9508. WallpadScheduleData schedulDB = null;
  9509. String retXML;
  9510. int QYear = 0;
  9511. int QMonth = 0;
  9512. try {
  9513. NodeList items = doc.getElementsByTagName("inquiry_time");
  9514. schedulDB = new WallpadScheduleData(getApplicationContext());
  9515. Node item = items.item(0);
  9516. NamedNodeMap attrsParam = item.getAttributes();
  9517. for (int j = 0; j < attrsParam.getLength(); j++) {
  9518. Node attr = attrsParam.item(j);
  9519. if (attr.getNodeName().equalsIgnoreCase("year"))
  9520. QYear = Integer.parseInt(attr.getNodeValue());
  9521. else if (attr.getNodeName().equalsIgnoreCase("month"))
  9522. QMonth = Integer.parseInt(attr.getNodeValue());
  9523. }
  9524. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  9525. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9526. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9527. " <inquiry_time year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9528. " <inquiry_count>" + SCData.size() + "</inquiry_count>\r\n";
  9529. if (SCData != null) {
  9530. if (SCData.size() > 0) {
  9531. for (int i = 0; i < SCData.size(); i++) {
  9532. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  9533. 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=\"" +
  9534. SCINQDATA.inqyear + "\" inq_month=\"" + SCINQDATA.inqmonth + "\" inq_day=\"" + SCINQDATA.inqday + "\" inq_hour=\"" + SCINQDATA.inqhour + "\" inq_message=\"" + SCINQDATA.inqmsg + "\"/>\r\n";
  9535. }
  9536. }
  9537. retXML += "</service>\r\n</imap>";
  9538. } else {
  9539. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9540. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9541. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9542. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9543. }
  9544. } catch (RuntimeException re) {
  9545. LogUtil.errorLogInfo("", TAG, re);
  9546. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9547. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9548. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9549. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9550. } catch (Exception e) {
  9551. //e.printStackTrace();
  9552. LogUtil.errorLogInfo("", TAG, e);
  9553. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9554. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9555. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9556. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9557. }
  9558. schedulDB.closeDB();
  9559. return retXML;
  9560. }
  9561. public String ProcUpdateSchedule(Element ele, String type) {
  9562. String retXML = "";
  9563. return retXML;
  9564. }
  9565. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  9566. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  9567. private void setDefaultLauncher() {
  9568. try {
  9569. PackageManager pm = getPackageManager();
  9570. IntentFilter filter = new IntentFilter();
  9571. filter.addAction(Intent.ACTION_MAIN);
  9572. filter.addCategory(Intent.CATEGORY_HOME);
  9573. filter.addCategory(Intent.CATEGORY_DEFAULT);
  9574. Context context = getApplicationContext();
  9575. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  9576. ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  9577. pm.clearPackagePreferredActivities("com.android.launcher");
  9578. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  9579. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  9580. try {
  9581. Thread.sleep(300);
  9582. } catch (RuntimeException re) {
  9583. LogUtil.errorLogInfo("", TAG, re);
  9584. } catch (Exception e) {
  9585. LogUtil.errorLogInfo("", TAG, e);
  9586. }
  9587. // 리셋코드 추가
  9588. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  9589. try {
  9590. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9591. powerMg.reboot(null);
  9592. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  9593. } catch (RuntimeException re) {
  9594. LogUtil.errorLogInfo("", TAG, re);
  9595. } catch (Exception e) {
  9596. //e.printStackTrace();
  9597. LogUtil.errorLogInfo("", TAG, e);
  9598. }
  9599. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  9600. } catch (RuntimeException re) {
  9601. LogUtil.errorLogInfo("", TAG, re);
  9602. } catch (Exception e) {
  9603. //e.printStackTrace();
  9604. LogUtil.errorLogInfo("", TAG, e);
  9605. }
  9606. }
  9607. public String ProcDeviceReset(Element ele) {
  9608. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  9609. "</imap>\r\n";
  9610. NodeList resettype = ele.getElementsByTagName("guidemap");
  9611. Node resettypeItem = resettype.item(0);
  9612. String type = GetAttributeVal(resettypeItem, "type");
  9613. if (type != null) {
  9614. if (type.equals("now")) {
  9615. setDefaultLauncher();
  9616. Intent intent = new Intent();
  9617. intent.setAction(define.NOTIFY_ACNAME);
  9618. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  9619. getApplicationContext().sendBroadcast(intent);
  9620. } else if (type.equals("disable")) {
  9621. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9622. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
  9623. SetReset.closeDB();
  9624. } else if (type.equals("week") || type.equals("month")) {
  9625. int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
  9626. NodeList periodList = ele.getElementsByTagName("period");
  9627. Node perioditem = periodList.item(0);
  9628. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  9629. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  9630. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9631. SetReset.SetResetSchedule(Resettype, cycle, time);
  9632. SetReset.closeDB();
  9633. }
  9634. }
  9635. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  9636. // Intent intent = new Intent();
  9637. // intent.setAction(define.NOTIFY_ACNAME);
  9638. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9639. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  9640. // getApplicationContext().sendBroadcast(intent);
  9641. return retXML;
  9642. }
  9643. public String ProcDeviceLiveCheck() {
  9644. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  9645. return retXML;
  9646. }
  9647. public String ProcPairingHdevSyncAlarm(Element ele) {
  9648. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  9649. return retXML;
  9650. }
  9651. public String ProcPairingHdevSyncSecurity(Element ele) {
  9652. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  9653. return retXML;
  9654. }
  9655. public String ProcParkInformation(Element ele) {
  9656. try {
  9657. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  9658. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  9659. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  9660. NodeList items = ele.getElementsByTagName("destination");
  9661. Node item = items.item(0);
  9662. Node text;
  9663. NamedNodeMap attrsParam = item.getAttributes();
  9664. for (int j = 0; j < attrsParam.getLength(); j++) {
  9665. Node attr = attrsParam.item(j);
  9666. if (attr.getNodeName().equalsIgnoreCase("name"))
  9667. strName = trimquotation(attr.getNodeValue());
  9668. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9669. strDong = trimquotation(attr.getNodeValue());
  9670. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9671. strHo = trimquotation(attr.getNodeValue());
  9672. }
  9673. items = ele.getElementsByTagName("move_info");
  9674. item = items.item(0);
  9675. text = item.getFirstChild();
  9676. strCarMove = trimquotation(text.getNodeValue());
  9677. items = ele.getElementsByTagName("params");
  9678. item = items.item(0);
  9679. attrsParam = item.getAttributes();
  9680. for (int j = 0; j < attrsParam.getLength(); j++) {
  9681. Node attr = attrsParam.item(j);
  9682. if (attr.getNodeName().equalsIgnoreCase("car_num"))
  9683. strCarNo = trimquotation(attr.getNodeValue());
  9684. else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
  9685. strCarLocation = trimquotation(attr.getNodeValue());
  9686. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9687. strMsg = trimquotation(attr.getNodeValue());
  9688. }
  9689. if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
  9690. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  9691. try {
  9692. int iTempDong = Integer.parseInt(AddrDong);
  9693. String sTempDong = Integer.toString(iTempDong);
  9694. int iTempHo = Integer.parseInt(AddrHo);
  9695. String sTempHo = Integer.toString(iTempHo);
  9696. if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  9697. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9698. } else {
  9699. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9700. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9701. return retXML;
  9702. }
  9703. } catch (RuntimeException re) {
  9704. LogUtil.errorLogInfo("", TAG, re);
  9705. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9706. return retXML;
  9707. } catch (Exception e) {
  9708. //e.printStackTrace();
  9709. LogUtil.errorLogInfo("", TAG, e);
  9710. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9711. return retXML;
  9712. }
  9713. //DB정보 업데이트!
  9714. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9715. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  9716. CarDB.closeDB();
  9717. //DB정보 업데이트!
  9718. if (strCarMove.equalsIgnoreCase("in")) {
  9719. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9720. // 팝업을 띄우도록 하자
  9721. wakeupLCD();
  9722. if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
  9723. Intent iIntent = new Intent();
  9724. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9725. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9726. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  9727. getApplicationContext().sendBroadcast(iIntent);
  9728. } else {
  9729. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9730. }
  9731. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  9732. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  9733. }
  9734. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  9735. if (strCarMove.equalsIgnoreCase("park")) {
  9736. //주차정보 얻어오도록 intent 알림
  9737. SendGetParkingInfoIntent();
  9738. }
  9739. } else {
  9740. //주차정보 얻어오도록 intent 알림
  9741. SendGetParkingInfoIntent();
  9742. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  9743. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  9744. }
  9745. return retXML;
  9746. } catch (RuntimeException re) {
  9747. LogUtil.errorLogInfo("", TAG, re);
  9748. return null;
  9749. } catch (Exception e) {
  9750. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  9751. //e.printStackTrace();
  9752. LogUtil.errorLogInfo("", TAG, e);
  9753. return null;
  9754. }
  9755. }
  9756. /**
  9757. * 스마트키 이벤트 수신시 처리
  9758. **/
  9759. public String ProcSmartKeyEvent(Element ele) {
  9760. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  9761. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  9762. String strName = null, strDong = null, strHo = null, strCnt = null;
  9763. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  9764. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  9765. NodeList items = ele.getElementsByTagName("destination");
  9766. Node item = items.item(0);
  9767. NamedNodeMap attrsParam = item.getAttributes();
  9768. for (int j = 0; j < attrsParam.getLength(); j++) {
  9769. Node attr = attrsParam.item(j);
  9770. if (attr.getNodeName().equalsIgnoreCase("name"))
  9771. strName = trimquotation(attr.getNodeValue());
  9772. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9773. strDong = trimquotation(attr.getNodeValue());
  9774. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9775. strHo = trimquotation(attr.getNodeValue());
  9776. }
  9777. items = ele.getElementsByTagName("event_info");
  9778. item = items.item(0);
  9779. attrsParam = item.getAttributes();
  9780. for (int j = 0; j < attrsParam.getLength(); j++) {
  9781. Node attr = attrsParam.item(j);
  9782. if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
  9783. strCnt = trimquotation(attr.getNodeValue());
  9784. }
  9785. items = ele.getElementsByTagName("event");
  9786. item = items.item(0);
  9787. attrsParam = item.getAttributes();
  9788. for (int j = 0; j < attrsParam.getLength(); j++) {
  9789. Node attr = attrsParam.item(j);
  9790. if (attr.getNodeName().equalsIgnoreCase("event_type"))
  9791. strEventType = trimquotation(attr.getNodeValue());
  9792. else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
  9793. strEventTriggerType = trimquotation(attr.getNodeValue());
  9794. else if (attr.getNodeName().equalsIgnoreCase("uid"))
  9795. strEventUID = trimquotation(attr.getNodeValue());
  9796. else if (attr.getNodeName().equalsIgnoreCase("sn"))
  9797. strEventSN = trimquotation(attr.getNodeValue());
  9798. else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
  9799. strEventSitecode = trimquotation(attr.getNodeValue());
  9800. else if (attr.getNodeName().equalsIgnoreCase("dong"))
  9801. strEventDong = trimquotation(attr.getNodeValue());
  9802. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9803. strEventHo = trimquotation(attr.getNodeValue());
  9804. else if (attr.getNodeName().equalsIgnoreCase("card_num"))
  9805. strEventCardNo = trimquotation(attr.getNodeValue());
  9806. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
  9807. strEventIssueCnt = trimquotation(attr.getNodeValue());
  9808. else if (attr.getNodeName().equalsIgnoreCase("card_type"))
  9809. strEventCardType = trimquotation(attr.getNodeValue());
  9810. else if (attr.getNodeName().equalsIgnoreCase("location"))
  9811. strEventLocation = trimquotation(attr.getNodeValue());
  9812. }
  9813. if (strName != null && strDong != null && strHo != null && strCnt != null)
  9814. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  9815. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  9816. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  9817. if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
  9818. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  9819. } else {
  9820. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  9821. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9822. return retXML;
  9823. }
  9824. //데이터가 null인지 확인
  9825. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  9826. return retXML;
  9827. }
  9828. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  9829. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9830. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9831. wakeupLCD();
  9832. // 팝업을 띄우도록 하자
  9833. String CardNum = "";
  9834. try {
  9835. int iEvent_Dong = Integer.parseInt(strEventDong);
  9836. CardNum += String.format("%04d", iEvent_Dong);
  9837. int iEvent_Ho = Integer.parseInt(strEventHo);
  9838. CardNum += String.format("%04d", iEvent_Ho);
  9839. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  9840. CardNum += String.format("%03d", iEvent_CardNum);
  9841. } catch (RuntimeException re) {
  9842. LogUtil.errorLogInfo("", TAG, re);
  9843. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9844. return retXML;
  9845. } catch (Exception e) {
  9846. //e.printStackTrace();
  9847. LogUtil.errorLogInfo("", TAG, e);
  9848. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9849. return retXML;
  9850. }
  9851. Intent iIntent = new Intent();
  9852. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9853. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  9854. iIntent.putExtra("LOCATION", strEventLocation);
  9855. iIntent.putExtra("CARD_NO", CardNum);
  9856. getApplicationContext().sendBroadcast(iIntent);
  9857. }
  9858. }
  9859. } else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  9860. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9861. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9862. int nCardNum;
  9863. try {
  9864. nCardNum = Integer.parseInt(strEventCardNo);
  9865. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  9866. } catch (RuntimeException re) {
  9867. LogUtil.errorLogInfo("", TAG, re);
  9868. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9869. return retXML;
  9870. } catch (Exception e) {
  9871. //e.printStackTrace();
  9872. LogUtil.errorLogInfo("", TAG, e);
  9873. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9874. return retXML;
  9875. }
  9876. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9877. boolean bBandUse = deviceSet.getBandLocationUsage();
  9878. deviceSet.closeDB();
  9879. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  9880. wakeupLCD();
  9881. Intent iIntent = new Intent();
  9882. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9883. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  9884. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  9885. getApplicationContext().sendBroadcast(iIntent);
  9886. }
  9887. }
  9888. }
  9889. }
  9890. return retXML;
  9891. }
  9892. public String ProcParkInformation_cham_upis(Element ele) {
  9893. Log.d(TAG, "ProcParkInformation_cham_upis START");
  9894. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  9895. String infoName = null;
  9896. String infoDong = null;
  9897. String infoHo = null;
  9898. String infoCarMove = null;
  9899. String infoCarnum = null;
  9900. String infoCarLocation = null;
  9901. String infoMessage = null;
  9902. NodeList items = ele.getElementsByTagName("home_info");
  9903. Node item = items.item(0);
  9904. Node text;
  9905. NamedNodeMap attrsParam = item.getAttributes();
  9906. for (int j = 0; j < attrsParam.getLength(); j++) {
  9907. Node attr = attrsParam.item(j);
  9908. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9909. infoDong = trimquotation(attr.getNodeValue());
  9910. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9911. infoHo = trimquotation(attr.getNodeValue());
  9912. }
  9913. items = ele.getElementsByTagName("park_info");
  9914. item = items.item(0);
  9915. attrsParam = item.getAttributes();
  9916. for (int j = 0; j < attrsParam.getLength(); j++) {
  9917. Node attr = attrsParam.item(j);
  9918. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  9919. infoCarnum = trimquotation(attr.getNodeValue());
  9920. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  9921. infoCarLocation = trimquotation(attr.getNodeValue());
  9922. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9923. infoMessage = trimquotation(attr.getNodeValue());
  9924. }
  9925. Log.d(TAG, "ProcParkInformation infoName :" + infoName);
  9926. if (infoDong != null)
  9927. Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
  9928. Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
  9929. Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
  9930. Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
  9931. Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
  9932. Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
  9933. if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  9934. (infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
  9935. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9936. } else {
  9937. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9938. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  9939. return retXML;
  9940. }
  9941. infoCarMove = "park";
  9942. //DB정보 업데이트!
  9943. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9944. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  9945. CarDB.closeDB();
  9946. //DB정보 업데이트!
  9947. Intent iIntent = new Intent();
  9948. iIntent.setAction(define.NOTIFY_ACNAME);
  9949. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  9950. this.sendBroadcast(iIntent);
  9951. /*
  9952. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  9953. {
  9954. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9955. // 팝업을 띄우도록 하자
  9956. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9957. }
  9958. */
  9959. return retXML;
  9960. }
  9961. public String ProcGetSmartKeyInfo(Element ele) {
  9962. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  9963. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  9964. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  9965. NodeList items = ele.getElementsByTagName("info_type");
  9966. Node item = items.item(0);
  9967. Node text = item.getFirstChild();
  9968. String sInfo_type = trimquotation(text.getNodeValue());
  9969. String sCard_info = null;
  9970. String sMessage = null;
  9971. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  9972. {
  9973. items = ele.getElementsByTagName("uid_info");
  9974. item = items.item(0);
  9975. text = item.getFirstChild();
  9976. sCard_info = trimquotation(text.getNodeValue());
  9977. //==============================================//
  9978. items = ele.getElementsByTagName("message");
  9979. item = items.item(0);
  9980. text = item.getFirstChild();
  9981. sMessage = trimquotation(text.getNodeValue());
  9982. //==============================================//
  9983. //쿼리문 작성
  9984. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9985. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9986. for (int i = 0; i < SyncData.size(); i++) {
  9987. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  9988. NewData.add(SyncData.get(i));
  9989. }
  9990. }
  9991. wallpadSmartKeyRegData.closeDB();
  9992. } else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  9993. {
  9994. items = ele.getElementsByTagName("sn_info");
  9995. item = items.item(0);
  9996. text = item.getFirstChild();
  9997. sCard_info = trimquotation(text.getNodeValue());
  9998. //==============================================//
  9999. items = ele.getElementsByTagName("message");
  10000. item = items.item(0);
  10001. text = item.getFirstChild();
  10002. sMessage = trimquotation(text.getNodeValue());
  10003. //==============================================//
  10004. //쿼리문 작성
  10005. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10006. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10007. for (int i = 0; i < SyncData.size(); i++) {
  10008. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  10009. NewData.add(SyncData.get(i));
  10010. }
  10011. }
  10012. wallpadSmartKeyRegData.closeDB();
  10013. } else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  10014. {
  10015. items = ele.getElementsByTagName("uid_info");
  10016. item = items.item(0);
  10017. text = item.getFirstChild();
  10018. sCard_info = trimquotation(text.getNodeValue());
  10019. //==============================================//
  10020. items = ele.getElementsByTagName("message");
  10021. item = items.item(0);
  10022. text = item.getFirstChild();
  10023. sMessage = trimquotation(text.getNodeValue());
  10024. //==============================================//
  10025. //쿼리문 작성
  10026. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10027. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10028. for (int i = 0; i < SyncData.size(); i++) {
  10029. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  10030. NewData.add(SyncData.get(i));
  10031. }
  10032. }
  10033. if (NewData.size() > 0) {
  10034. NewData = SyncData;
  10035. }
  10036. wallpadSmartKeyRegData.closeDB();
  10037. } else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  10038. {
  10039. items = ele.getElementsByTagName("sn_info");
  10040. item = items.item(0);
  10041. text = item.getFirstChild();
  10042. sCard_info = trimquotation(text.getNodeValue());
  10043. //==============================================//
  10044. items = ele.getElementsByTagName("message");
  10045. item = items.item(0);
  10046. text = item.getFirstChild();
  10047. sMessage = trimquotation(text.getNodeValue());
  10048. //==============================================//
  10049. //쿼리문 작성
  10050. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10051. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10052. for (int i = 0; i < SyncData.size(); i++) {
  10053. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  10054. NewData.add(SyncData.get(i));
  10055. }
  10056. }
  10057. if (NewData.size() > 0) {
  10058. NewData = SyncData;
  10059. }
  10060. wallpadSmartKeyRegData.closeDB();
  10061. } else if (sInfo_type.equalsIgnoreCase("hkey")) {
  10062. String dong = "";
  10063. String ho = "";
  10064. String Num = "all";
  10065. //==============================================//
  10066. items = ele.getElementsByTagName("message");
  10067. item = items.item(0);
  10068. text = item.getFirstChild();
  10069. sMessage = trimquotation(text.getNodeValue());
  10070. //==============================================//
  10071. items = ele.getElementsByTagName("hkey_info");
  10072. item = items.item(0);
  10073. if (item == null)
  10074. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10075. NamedNodeMap attrsParam = item.getAttributes();
  10076. for (int j = 0; j < attrsParam.getLength(); j++) {
  10077. Node attr = attrsParam.item(j);
  10078. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10079. dong = attr.getNodeValue();
  10080. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10081. ho = attr.getNodeValue();
  10082. else if (attr.getNodeName().equalsIgnoreCase("num"))
  10083. Num = attr.getNodeValue();
  10084. }
  10085. if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
  10086. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
  10087. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10088. }
  10089. //쿼리문 작성
  10090. int intNum = 0;
  10091. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10092. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10093. for (int i = 0; i < SyncData.size(); i++) {
  10094. if (Num.equalsIgnoreCase("all") == true) {
  10095. NewData.add(SyncData.get(i));
  10096. } else {
  10097. try {
  10098. intNum = Integer.parseInt(Num);
  10099. } catch (RuntimeException re) {
  10100. LogUtil.errorLogInfo("", TAG, re);
  10101. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10102. } catch (Exception e) {
  10103. //e.printStackTrace();
  10104. LogUtil.errorLogInfo("", TAG, e);
  10105. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10106. }
  10107. if (SyncData.get(i).id == intNum) {
  10108. NewData.add(SyncData.get(i));
  10109. }
  10110. }
  10111. }
  10112. wallpadSmartKeyRegData.closeDB();
  10113. } else if (sInfo_type.equalsIgnoreCase("dkey")) {
  10114. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10115. } else if (sInfo_type.equalsIgnoreCase("mkey")) {
  10116. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10117. }
  10118. if (NewData.size() == 0) {
  10119. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  10120. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10121. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10122. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  10123. retXML += " </service>\r\n</imap>";
  10124. return retXML;
  10125. }
  10126. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10127. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10128. for (int i = 0; i < NewData.size(); i++) {
  10129. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  10130. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  10131. String strFormat = sFormat.format(date);
  10132. retXML += " <key_info index = \"" + NewData.get(i).id + "\" "
  10133. + "sn = \"" + NewData.get(i).SerialNumber + "\" "
  10134. + "uid = \"" + NewData.get(i).Uid + "\" "
  10135. + "key_num = \"" + NewData.get(i).id + "\" "
  10136. + "issue_cnt = \"" + 1 + "\" "
  10137. + "issued_date = \"" + strFormat + "\" "
  10138. + "message = \"" + "null" + "\" "
  10139. + "/>\r\n";
  10140. }
  10141. retXML += " </service>\r\n</imap>";
  10142. return retXML;
  10143. }
  10144. public void ProcMobileDevice_AuthNumber(Element ele) {
  10145. String sDong = null;
  10146. String sHo = null;
  10147. String sIP = null;
  10148. String sType = null;
  10149. String sDevice_Name = null;
  10150. String sTwinID = null;
  10151. String sAuthNumber = null;
  10152. try {
  10153. NodeList items = ele.getElementsByTagName("home_info");
  10154. Node item = items.item(0);
  10155. NamedNodeMap attrsParam = item.getAttributes();
  10156. for (int i = 0; i < attrsParam.getLength(); i++) {
  10157. Node attr = attrsParam.item(i);
  10158. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10159. sDong = trimquotation(attr.getNodeValue());
  10160. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10161. sHo = trimquotation(attr.getNodeValue());
  10162. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10163. sIP = trimquotation(attr.getNodeValue());
  10164. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10165. sType = trimquotation(attr.getNodeValue());
  10166. }
  10167. WallpadStatusData DBMGR = null;
  10168. DBMGR = new WallpadStatusData(getApplicationContext());
  10169. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10170. DBMGR.closeDB();
  10171. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10172. items = ele.getElementsByTagName("device_info");
  10173. item = items.item(0);
  10174. attrsParam = item.getAttributes();
  10175. for (int i = 0; i < attrsParam.getLength(); i++) {
  10176. Node attr = attrsParam.item(i);
  10177. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10178. sDevice_Name = trimquotation(attr.getNodeValue());
  10179. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10180. sTwinID = trimquotation(attr.getNodeValue());
  10181. else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
  10182. sAuthNumber = trimquotation(attr.getNodeValue());
  10183. }
  10184. /**데이터 전달**/
  10185. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10186. Log.d(TAG, "sTwinID :" + sTwinID);
  10187. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  10188. Intent intent = new Intent();
  10189. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10190. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  10191. intent.putExtra("AuthNumber", sAuthNumber);
  10192. if (NewServerUse()) {
  10193. getApplicationContext().sendBroadcast(intent);
  10194. }
  10195. } else {
  10196. }
  10197. } catch (RuntimeException re) {
  10198. LogUtil.errorLogInfo("", TAG, re);
  10199. } catch (Exception e) {
  10200. //e.printStackTrace();
  10201. LogUtil.errorLogInfo("", TAG, e);
  10202. }
  10203. }
  10204. public String ProcMobileDevice_ADD_Finish(Element ele) {
  10205. String retXML = "";
  10206. String sDong = null;
  10207. String sHo = null;
  10208. String sIP = null;
  10209. String sType = null;
  10210. String sDevice_Name = null;
  10211. String sTwinID = null;
  10212. try {
  10213. NodeList items = ele.getElementsByTagName("home_info");
  10214. Node item = items.item(0);
  10215. NamedNodeMap attrsParam = item.getAttributes();
  10216. for (int i = 0; i < attrsParam.getLength(); i++) {
  10217. Node attr = attrsParam.item(i);
  10218. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10219. sDong = trimquotation(attr.getNodeValue());
  10220. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10221. sHo = trimquotation(attr.getNodeValue());
  10222. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10223. sIP = trimquotation(attr.getNodeValue());
  10224. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10225. sType = trimquotation(attr.getNodeValue());
  10226. }
  10227. WallpadStatusData DBMGR = null;
  10228. DBMGR = new WallpadStatusData(getApplicationContext());
  10229. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10230. DBMGR.closeDB();
  10231. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10232. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10233. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10234. items = ele.getElementsByTagName("device_info");
  10235. item = items.item(0);
  10236. attrsParam = item.getAttributes();
  10237. for (int i = 0; i < attrsParam.getLength(); i++) {
  10238. Node attr = attrsParam.item(i);
  10239. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10240. sDevice_Name = trimquotation(attr.getNodeValue());
  10241. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10242. sTwinID = trimquotation(attr.getNodeValue());
  10243. }
  10244. /**데이터 전달**/
  10245. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10246. Log.d(TAG, "sTwinID :" + sTwinID);
  10247. Intent intent = new Intent();
  10248. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10249. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  10250. if (NewServerUse()) {
  10251. getApplicationContext().sendBroadcast(intent);
  10252. } else {
  10253. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10254. retXML += " </service>\r\n</imap>";
  10255. return retXML;
  10256. }
  10257. String tempType = "main";
  10258. //DB에 저장 필요
  10259. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10260. if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  10261. {
  10262. wallpadMobileDeviceData.closeDB();
  10263. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10264. retXML += " </service>\r\n</imap>";
  10265. return retXML;
  10266. }
  10267. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  10268. wallpadMobileDeviceData.closeDB();
  10269. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  10270. retXML += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" ip=\"" + addc.IPAddress + "\" type=\"" + tempType + "\"/>\r\n";
  10271. retXML += " <device_info alias=\"" + sDevice_Name + "\" twinid=\"" + sTwinID + "\" />\r\n";
  10272. retXML += " </service>\r\n</imap>";
  10273. return retXML;
  10274. } else {
  10275. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10276. retXML += " </service>\r\n</imap>";
  10277. return retXML;
  10278. }
  10279. } catch (RuntimeException re) {
  10280. LogUtil.errorLogInfo("", TAG, re);
  10281. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10282. retXML += " </service>\r\n</imap>";
  10283. return retXML;
  10284. } catch (Exception e) {
  10285. //e.printStackTrace();
  10286. LogUtil.errorLogInfo("", TAG, e);
  10287. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10288. retXML += " </service>\r\n</imap>";
  10289. return retXML;
  10290. }
  10291. }
  10292. public void ProcMobileDevice_Delete(Element ele) {
  10293. String sDong = null;
  10294. String sHo = null;
  10295. String sIP = null;
  10296. String sType = null;
  10297. String sDevice_Name = null;
  10298. String sTwinID = null;
  10299. Log.d(TAG, "ProcMobileDevice_Delete");
  10300. try {
  10301. NodeList items = ele.getElementsByTagName("home_info");
  10302. Node item = items.item(0);
  10303. NamedNodeMap attrsParam = item.getAttributes();
  10304. for (int i = 0; i < attrsParam.getLength(); i++) {
  10305. Node attr = attrsParam.item(i);
  10306. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10307. sDong = trimquotation(attr.getNodeValue());
  10308. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10309. sHo = trimquotation(attr.getNodeValue());
  10310. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10311. sIP = trimquotation(attr.getNodeValue());
  10312. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10313. sType = trimquotation(attr.getNodeValue());
  10314. }
  10315. WallpadStatusData DBMGR = null;
  10316. DBMGR = new WallpadStatusData(getApplicationContext());
  10317. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10318. DBMGR.closeDB();
  10319. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10320. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10321. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10322. if (NewServerUse()) {
  10323. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10324. items = ele.getElementsByTagName("device_info");
  10325. for (int i = 0; i < items.getLength(); i++) {
  10326. item = items.item(i);
  10327. attrsParam = item.getAttributes();
  10328. for (int j = 0; j < attrsParam.getLength(); j++) {
  10329. Node attr = attrsParam.item(j);
  10330. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10331. sDevice_Name = trimquotation(attr.getNodeValue());
  10332. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10333. sTwinID = trimquotation(attr.getNodeValue());
  10334. }
  10335. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10336. Log.d(TAG, "sTwinID :" + sTwinID);
  10337. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  10338. }
  10339. wallpadMobileDeviceData.closeDB();
  10340. Intent intent = new Intent();
  10341. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  10342. getApplicationContext().sendBroadcast(intent);
  10343. }
  10344. } else {
  10345. }
  10346. } catch (RuntimeException re) {
  10347. LogUtil.errorLogInfo("", TAG, re);
  10348. } catch (Exception e) {
  10349. //e.printStackTrace();
  10350. LogUtil.errorLogInfo("", TAG, e);
  10351. }
  10352. }
  10353. public String ProcGetAppVersionInfo() {
  10354. String retXML = "";
  10355. MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
  10356. int AppCount;
  10357. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  10358. retXML = XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  10359. retXML += " <home_info dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\" platform=\"Android\" count=\"" + AppCount + "\" />\r\n";
  10360. for (int i = 0; i < AppCount; i++) {
  10361. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
  10362. if (getString != null) {
  10363. retXML += " <app_list name=\"" + getString[0] + "\" version=\"" + getString[1] + "\" />\r\n";
  10364. }
  10365. }
  10366. retXML += " </service>\r\n</imap>";
  10367. return retXML;
  10368. }
  10369. public String ProcIgateInitInfo(Element ele) {
  10370. String retXML = "";
  10371. String ctrl_baudrate = "";
  10372. String ctrl_open = "";
  10373. String ctrl_framecheck = "";
  10374. String ctrl_message = "";
  10375. String eth_mode = "";
  10376. String eth_ip = "";
  10377. String eth_mac = "";
  10378. String eth_gw = "";
  10379. String eth_sm = "";
  10380. String noti_send = "";
  10381. String noti_level = "";
  10382. String noti_ip = "";
  10383. String noti_port = "";
  10384. try {
  10385. NodeList items = ele.getElementsByTagName("ctrl_param");
  10386. Node item = items.item(0);
  10387. NamedNodeMap attrsParam = item.getAttributes();
  10388. for (int i = 0; i < attrsParam.getLength(); i++) {
  10389. Node attr = attrsParam.item(i);
  10390. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  10391. ctrl_baudrate = trimquotation(attr.getNodeValue());
  10392. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  10393. ctrl_open = trimquotation(attr.getNodeValue());
  10394. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  10395. ctrl_framecheck = trimquotation(attr.getNodeValue());
  10396. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  10397. ctrl_message = trimquotation(attr.getNodeValue());
  10398. }
  10399. items = ele.getElementsByTagName("eth_param");
  10400. item = items.item(0);
  10401. attrsParam = item.getAttributes();
  10402. for (int i = 0; i < attrsParam.getLength(); i++) {
  10403. Node attr = attrsParam.item(i);
  10404. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  10405. eth_mode = trimquotation(attr.getNodeValue());
  10406. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  10407. eth_ip = trimquotation(attr.getNodeValue());
  10408. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  10409. eth_mac = trimquotation(attr.getNodeValue());
  10410. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  10411. eth_gw = trimquotation(attr.getNodeValue());
  10412. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  10413. eth_sm = trimquotation(attr.getNodeValue());
  10414. }
  10415. items = ele.getElementsByTagName("noti_param");
  10416. item = items.item(0);
  10417. attrsParam = item.getAttributes();
  10418. for (int i = 0; i < attrsParam.getLength(); i++) {
  10419. Node attr = attrsParam.item(i);
  10420. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  10421. noti_send = trimquotation(attr.getNodeValue());
  10422. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  10423. noti_level = trimquotation(attr.getNodeValue());
  10424. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  10425. noti_ip = trimquotation(attr.getNodeValue());
  10426. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  10427. noti_port = trimquotation(attr.getNodeValue());
  10428. }
  10429. wallpaddbmgr WallpadDBMGR = null;
  10430. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  10431. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  10432. if (RowCount_GatewayData > 100) {
  10433. WallpadDBMGR.DeleteLH_GatewayData("50");
  10434. }
  10435. 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);
  10436. WallpadDBMGR.closeDB();
  10437. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  10438. retXML += " </service>\r\n</imap>";
  10439. return retXML;
  10440. } catch (RuntimeException re) {
  10441. LogUtil.errorLogInfo("", TAG, re);
  10442. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10443. retXML += " </service>\r\n</imap>";
  10444. return retXML;
  10445. } catch (Exception e) {
  10446. //e.printStackTrace();
  10447. LogUtil.errorLogInfo("", TAG, e);
  10448. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10449. retXML += " </service>\r\n</imap>";
  10450. return retXML;
  10451. }
  10452. }
  10453. public String ProcElecCarChargeEventInfo(Element ele) {
  10454. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  10455. String retXML = "";
  10456. String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  10457. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  10458. try {
  10459. NodeList items = ele.getElementsByTagName("destination");
  10460. Node item = items.item(0);
  10461. NamedNodeMap attrsParam = item.getAttributes();
  10462. for (int i = 0; i < attrsParam.getLength(); i++) {
  10463. Node attr = attrsParam.item(i);
  10464. if (attr.getNodeName().equalsIgnoreCase("name"))
  10465. sName = trimquotation(attr.getNodeValue());
  10466. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10467. sId_High = trimquotation(attr.getNodeValue());
  10468. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10469. sId_Low = trimquotation(attr.getNodeValue());
  10470. }
  10471. WallpadStatusData DBMGR = null;
  10472. DBMGR = new WallpadStatusData(getApplicationContext());
  10473. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10474. DBMGR.closeDB();
  10475. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  10476. items = ele.getElementsByTagName("charging_info");
  10477. item = items.item(0);
  10478. attrsParam = item.getAttributes();
  10479. for (int i = 0; i < attrsParam.getLength(); i++) {
  10480. Node attr = attrsParam.item(i);
  10481. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  10482. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  10483. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  10484. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  10485. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  10486. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  10487. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  10488. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  10489. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  10490. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  10491. )) {
  10492. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10493. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10494. retXML += " </service>\r\n</imap>";
  10495. return retXML;
  10496. }
  10497. if (attr.getNodeName().equalsIgnoreCase("card_num"))
  10498. sCard_Num = trimquotation(attr.getNodeValue());
  10499. else if (attr.getNodeName().equalsIgnoreCase("car_num"))
  10500. sCar_Num = trimquotation(attr.getNodeValue());
  10501. else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
  10502. sCharger_Num = trimquotation(attr.getNodeValue());
  10503. else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
  10504. sCharger_Loc = trimquotation(attr.getNodeValue());
  10505. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  10506. sCharging_Status = trimquotation(attr.getNodeValue());
  10507. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  10508. (sCharging_Status.equalsIgnoreCase("charging")) ||
  10509. (sCharging_Status.equalsIgnoreCase("full")) ||
  10510. (sCharging_Status.equalsIgnoreCase("charged")) ||
  10511. (sCharging_Status.equalsIgnoreCase("stop")) ||
  10512. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  10513. (sCharging_Status.equalsIgnoreCase("check")) ||
  10514. (sCharging_Status.equalsIgnoreCase("commerror"))
  10515. )) {
  10516. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  10517. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10518. retXML += " </service>\r\n</imap>";
  10519. return retXML;
  10520. }
  10521. } else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  10522. sCharger_sort = trimquotation(attr.getNodeValue());
  10523. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  10524. (sCharger_sort.equalsIgnoreCase("fast")) ||
  10525. (sCharger_sort.equalsIgnoreCase("no_info"))
  10526. )) {
  10527. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  10528. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10529. retXML += " </service>\r\n</imap>";
  10530. return retXML;
  10531. }
  10532. } else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
  10533. sCharging_Ratio = trimquotation(attr.getNodeValue());
  10534. else if (attr.getNodeName().equalsIgnoreCase("start_time"))
  10535. sStart_Time = trimquotation(attr.getNodeValue());
  10536. else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
  10537. sRemain_Time = trimquotation(attr.getNodeValue());
  10538. }
  10539. items = ele.getElementsByTagName("message");
  10540. item = items.item(0);
  10541. Node text = item.getFirstChild();
  10542. sMessage = trimquotation(text.getNodeValue());
  10543. /**데이터 전달**/
  10544. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  10545. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  10546. Intent intent = new Intent();
  10547. intent.setAction(define.NOTIFY_ACNAME);
  10548. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  10549. intent.putExtra("sCard_Num", sCard_Num);
  10550. intent.putExtra("sCar_Num", sCar_Num);
  10551. intent.putExtra("sCharger_Num", sCharger_Num);
  10552. intent.putExtra("sCharger_Loc", sCharger_Loc);
  10553. intent.putExtra("sCharging_Status", sCharging_Status);
  10554. intent.putExtra("sCharger_sort", sCharger_sort);
  10555. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  10556. intent.putExtra("sStart_Time", sStart_Time);
  10557. intent.putExtra("sRemain_Time", sRemain_Time);
  10558. intent.putExtra("sMessage", sMessage);
  10559. WallpadDeviceSet devDB = null;
  10560. devDB = new WallpadDeviceSet(getApplicationContext());
  10561. int retInt = -1;
  10562. retInt = devDB.GetDeviceSetted("전기차충전");
  10563. devDB.closeDB();
  10564. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10565. getApplicationContext().sendBroadcast(intent);
  10566. }
  10567. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  10568. retXML += " <source name=\"homedev\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" />\r\n";
  10569. retXML += " </service>\r\n</imap>";
  10570. return retXML;
  10571. } else {
  10572. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10573. retXML += " </service>\r\n</imap>";
  10574. return retXML;
  10575. }
  10576. } catch (RuntimeException re) {
  10577. LogUtil.errorLogInfo("", TAG, re);
  10578. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10579. retXML += " </service>\r\n</imap>";
  10580. return retXML;
  10581. } catch (Exception e) {
  10582. //e.printStackTrace();
  10583. LogUtil.errorLogInfo("", TAG, e);
  10584. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10585. retXML += " </service>\r\n</imap>";
  10586. return retXML;
  10587. }
  10588. }
  10589. public String ProcEnergyTargetInfoAlarm(Element ele) {
  10590. String retXML = "";
  10591. String sName = "";
  10592. String sId_High = "";
  10593. String sId_Low = "";
  10594. String vName[];
  10595. String vTarget[];
  10596. String vTarget_Cost[];
  10597. String vUsed[];
  10598. String vUsed_Cost[];
  10599. String vPredict[];
  10600. String vPredict_Cost[];
  10601. String vAlarm_info[];
  10602. String vRead_Date[];
  10603. String vRead_Day[];
  10604. String vV_Msg[];
  10605. String sMessage = "";
  10606. try {
  10607. NodeList items = ele.getElementsByTagName("source");
  10608. Node item = items.item(0);
  10609. NamedNodeMap attrsParam = item.getAttributes();
  10610. for (int i = 0; i < attrsParam.getLength(); i++) {
  10611. Node attr = attrsParam.item(i);
  10612. if (attr.getNodeName().equalsIgnoreCase("name"))
  10613. sName = trimquotation(attr.getNodeValue());
  10614. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10615. sId_High = trimquotation(attr.getNodeValue());
  10616. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10617. sId_Low = trimquotation(attr.getNodeValue());
  10618. }
  10619. WallpadStatusData DBMGR = null;
  10620. DBMGR = new WallpadStatusData(getApplicationContext());
  10621. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10622. DBMGR.closeDB();
  10623. if ((sName.equalsIgnoreCase("home") == true) &&
  10624. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  10625. (sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
  10626. items = ele.getElementsByTagName("valuelist");
  10627. Log.d(TAG, "items.getLength() :" + items.getLength());
  10628. vName = new String[items.getLength()];
  10629. vTarget = new String[items.getLength()];
  10630. vTarget_Cost = new String[items.getLength()];
  10631. vUsed = new String[items.getLength()];
  10632. vUsed_Cost = new String[items.getLength()];
  10633. vPredict = new String[items.getLength()];
  10634. vPredict_Cost = new String[items.getLength()];
  10635. vAlarm_info = new String[items.getLength()];
  10636. vRead_Date = new String[items.getLength()];
  10637. vRead_Day = new String[items.getLength()];
  10638. vV_Msg = new String[items.getLength()];
  10639. for (int j = 0; j < items.getLength(); j++) {
  10640. Log.d(TAG, "j :" + j);
  10641. item = items.item(j);
  10642. attrsParam = item.getAttributes();
  10643. Log.d(TAG, "attrsParam :" + attrsParam);
  10644. for (int i = 0; i < attrsParam.getLength(); i++) {
  10645. Node attr = attrsParam.item(i);
  10646. if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  10647. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  10648. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  10649. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  10650. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  10651. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  10652. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  10653. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  10654. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  10655. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  10656. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  10657. )) {
  10658. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10659. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10660. retXML += " </service>\r\n</imap>";
  10661. return retXML;
  10662. }
  10663. if (attr.getNodeName().equalsIgnoreCase("name")) {
  10664. vName[j] = trimquotation(attr.getNodeValue());
  10665. if (!((vName[j].equalsIgnoreCase("elect") == true) ||
  10666. (vName[j].equalsIgnoreCase("water") == true) ||
  10667. (vName[j].equalsIgnoreCase("gas") == true) ||
  10668. (vName[j].equalsIgnoreCase("heating") == true) ||
  10669. (vName[j].equalsIgnoreCase("hotwater") == true)
  10670. )) {
  10671. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  10672. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10673. retXML += " </service>\r\n</imap>";
  10674. return retXML;
  10675. }
  10676. } else if (attr.getNodeName().equalsIgnoreCase("target"))
  10677. vTarget[j] = trimquotation(attr.getNodeValue());
  10678. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  10679. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  10680. else if (attr.getNodeName().equalsIgnoreCase("used"))
  10681. vUsed[j] = trimquotation(attr.getNodeValue());
  10682. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  10683. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  10684. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  10685. vPredict[j] = trimquotation(attr.getNodeValue());
  10686. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  10687. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  10688. else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
  10689. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  10690. if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  10691. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  10692. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  10693. )) {
  10694. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  10695. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10696. retXML += " </service>\r\n</imap>";
  10697. return retXML;
  10698. }
  10699. } else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
  10700. vRead_Date[j] = trimquotation(attr.getNodeValue());
  10701. if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  10702. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  10703. )) {
  10704. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  10705. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10706. retXML += " </service>\r\n</imap>";
  10707. return retXML;
  10708. }
  10709. } else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  10710. vRead_Day[j] = trimquotation(attr.getNodeValue());
  10711. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  10712. vV_Msg[j] = trimquotation(attr.getNodeValue());
  10713. }
  10714. }
  10715. items = ele.getElementsByTagName("message");
  10716. item = items.item(0);
  10717. Node text = item.getFirstChild();
  10718. sMessage = trimquotation(text.getNodeValue());
  10719. /**데이터 전달**/
  10720. for (int i = 0; i < vName.length; i++) {
  10721. Log.d(TAG, "vName[" + i + "]: " + vName[i]);
  10722. Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
  10723. Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
  10724. Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
  10725. Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
  10726. Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
  10727. Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
  10728. Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
  10729. Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
  10730. Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
  10731. Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
  10732. }
  10733. Intent intent = new Intent();
  10734. intent.setAction(define.NOTIFY_ACNAME);
  10735. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  10736. for (int i = 0; i < vName.length; i++) {
  10737. if (vName[i].equals("elect")) {
  10738. intent.putExtra("elect_target", vTarget[i]);
  10739. intent.putExtra("elect_used", vUsed[i]);
  10740. intent.putExtra("elect_info", vAlarm_info[i]);
  10741. } else if (vName[i].equals("water")) {
  10742. intent.putExtra("water_target", vTarget[i]);
  10743. intent.putExtra("water_used", vUsed[i]);
  10744. intent.putExtra("water_info", vAlarm_info[i]);
  10745. } else if (vName[i].equals("gas")) {
  10746. intent.putExtra("gas_target", vTarget[i]);
  10747. intent.putExtra("gas_used", vUsed[i]);
  10748. intent.putExtra("gas_info", vAlarm_info[i]);
  10749. } else if (vName[i].equals("heating")) {
  10750. intent.putExtra("heating_target", vTarget[i]);
  10751. intent.putExtra("heating_used", vUsed[i]);
  10752. intent.putExtra("heating_info", vAlarm_info[i]);
  10753. } else if (vName[i].equals("hotwater")) {
  10754. intent.putExtra("hotwater_target", vTarget[i]);
  10755. intent.putExtra("hotwater_used", vUsed[i]);
  10756. intent.putExtra("hotwater_info", vAlarm_info[i]);
  10757. }
  10758. }
  10759. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  10760. retXML += " <source name=\"home\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" count=\"" + vName.length + "\"" + " s_msg=\"null\" />\r\n";
  10761. for (int i = 0; i < vName.length; i++) {
  10762. retXML += " <valuelist name=\"" + vName[i] + "\" alarm_info=\"" + vAlarm_info[i] + "\" v_msg=\"null\" />\r\n";
  10763. }
  10764. retXML += " <message>\"null\"</message>\r\n";
  10765. retXML += " </service>\r\n</imap>";
  10766. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10767. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  10768. devSet.closeDB();
  10769. if (MetringDB != null) {
  10770. try {
  10771. String devInfo = MetringDB[1];
  10772. devInfo = devInfo.replace('(', '_');
  10773. devInfo = devInfo.replace(':', '_');
  10774. devInfo = devInfo.replace(')', '_');
  10775. String[] MetringInfo = devInfo.split("_");
  10776. // MetringInfo[1] -> 회로수
  10777. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  10778. // MetringInfo[4] -> IP
  10779. // MetringInfo[5] -> IP정보
  10780. // MetringInfo[6] -> 검침일사용자설정
  10781. // MetringInfo[7] -> 사용함 또는 사용안함
  10782. if (MetringInfo[3].equals("사용함") == true) {
  10783. getApplicationContext().sendBroadcast(intent);
  10784. }
  10785. } catch (RuntimeException re) {
  10786. LogUtil.errorLogInfo("", TAG, re);
  10787. } catch (Exception e) {
  10788. //e.printStackTrace();
  10789. LogUtil.errorLogInfo("", TAG, e);
  10790. }
  10791. } else {
  10792. }
  10793. return retXML;
  10794. } else {
  10795. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10796. retXML += " </service>\r\n</imap>";
  10797. return retXML;
  10798. }
  10799. } catch (RuntimeException re) {
  10800. LogUtil.errorLogInfo("", TAG, re);
  10801. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10802. retXML += " </service>\r\n</imap>";
  10803. return retXML;
  10804. } catch (Exception e) {
  10805. //e.printStackTrace();
  10806. LogUtil.errorLogInfo("", TAG, e);
  10807. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10808. retXML += " </service>\r\n</imap>";
  10809. return retXML;
  10810. }
  10811. }
  10812. public String ProcCheckCallOption() {
  10813. int[] resultDB = {0, 0};
  10814. String retXML = "";
  10815. String sOption = "sip";
  10816. String sMessage = "null";
  10817. try {
  10818. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10819. resultDB = devSet.Get_Handicapped_Mode();
  10820. devSet.closeDB();
  10821. if (resultDB[0] == 0) {
  10822. //장애인모드 사용 안함
  10823. } else if (resultDB[0] == 1) {
  10824. //장애인모드 사용함
  10825. }
  10826. switch (resultDB[1]) {
  10827. case 0: //일반모드
  10828. sOption = "sip";
  10829. break;
  10830. case 1: //청각장애인
  10831. sOption = "deaf";
  10832. break;
  10833. case 2: //시각장애인
  10834. sOption = "blind";
  10835. break;
  10836. default:
  10837. break;
  10838. }
  10839. if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  10840. {
  10841. //본 구문에 들어올수 없음
  10842. sOption = "none";
  10843. }
  10844. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  10845. retXML += " <option>\"" + sOption + "\"</option>\r\n";
  10846. retXML += " <message>\"" + sMessage + "\"</message>\r\n";
  10847. retXML += " </service>\r\n</imap>";
  10848. return retXML;
  10849. } catch (RuntimeException re) {
  10850. LogUtil.errorLogInfo("", TAG, re);
  10851. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10852. retXML += " </service>\r\n</imap>";
  10853. return retXML;
  10854. } catch (Exception e) {
  10855. //e.printStackTrace();
  10856. LogUtil.errorLogInfo("", TAG, e);
  10857. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10858. retXML += " </service>\r\n</imap>";
  10859. return retXML;
  10860. }
  10861. }
  10862. public String ProcChatSequence(Element ele) {
  10863. String retXML = "";
  10864. String sFrom = "error";
  10865. String sTo = "error";
  10866. String sContact = "error";
  10867. String sSequence = "error";
  10868. String sStatus = "error";
  10869. String sMessage = "error";
  10870. String reply_Sequence = "error";
  10871. String reply_Status = "error";
  10872. String reply_Message = "null";
  10873. try {
  10874. NodeList items = ele.getElementsByTagName("sequence");
  10875. Node item = items.item(0);
  10876. NamedNodeMap attrsParam = item.getAttributes();
  10877. sSequence = trimquotation(item.getTextContent());
  10878. ///////////////////////////////////////////////
  10879. items = ele.getElementsByTagName("status");
  10880. item = items.item(0);
  10881. attrsParam = item.getAttributes();
  10882. sStatus = trimquotation(item.getTextContent());
  10883. ///////////////////////////////////////////////
  10884. items = ele.getElementsByTagName("message");
  10885. item = items.item(0);
  10886. attrsParam = item.getAttributes();
  10887. sMessage = trimquotation(item.getTextContent());
  10888. ///////////////////////////////////////////////
  10889. items = ele.getElementsByTagName("from");
  10890. item = items.item(0);
  10891. attrsParam = item.getAttributes();
  10892. sFrom = trimquotation(item.getTextContent());
  10893. ///////////////////////////////////////////////
  10894. items = ele.getElementsByTagName("to");
  10895. item = items.item(0);
  10896. attrsParam = item.getAttributes();
  10897. sTo = trimquotation(item.getTextContent());
  10898. ///////////////////////////////////////////////
  10899. items = ele.getElementsByTagName("contact");
  10900. item = items.item(0);
  10901. attrsParam = item.getAttributes();
  10902. sContact = trimquotation(item.getTextContent());
  10903. ///////////////////////////////////////////////
  10904. if (!((sSequence.equalsIgnoreCase("try") == true) ||
  10905. (sSequence.equalsIgnoreCase("start") == true) ||
  10906. (sSequence.equalsIgnoreCase("quit") == true) ||
  10907. (sSequence.equalsIgnoreCase("cancel") == true) ||
  10908. (sSequence.equalsIgnoreCase("ok") == true) ||
  10909. (sSequence.equalsIgnoreCase("busy") == true) ||
  10910. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  10911. (sSequence.equalsIgnoreCase("reject") == true)
  10912. )) {
  10913. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  10914. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10915. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10916. retXML += " </service>\r\n</imap>";
  10917. return retXML;
  10918. }
  10919. if (!((sStatus.equalsIgnoreCase("idle") == true) ||
  10920. (sStatus.equalsIgnoreCase("ringing") == true) ||
  10921. (sStatus.equalsIgnoreCase("talking") == true)
  10922. )) {
  10923. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  10924. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10925. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10926. retXML += " </service>\r\n</imap>";
  10927. return retXML;
  10928. }
  10929. //입력값 처리 필요!!
  10930. //김용성 과장님 작업필요
  10931. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  10932. //확인 하시고 위 정보 확인해주세요.
  10933. Log.d(TAG, "sFrom:" + sFrom);
  10934. Log.d(TAG, "sTo:" + sTo);
  10935. Log.d(TAG, "Contact:" + sContact);
  10936. Log.d(TAG, "sSequence:" + sSequence);
  10937. Log.d(TAG, "sStatus:" + sStatus);
  10938. if (sSequence.equalsIgnoreCase("try") == true) {
  10939. //채팅 요청
  10940. } else if (sSequence.equalsIgnoreCase("start") == true) {
  10941. //채팅 시작
  10942. } else if (sSequence.equalsIgnoreCase("quit") == true) {
  10943. //채팅 종료
  10944. } else if (sSequence.equalsIgnoreCase("cancel") == true) {
  10945. //취소
  10946. } else if (sSequence.equalsIgnoreCase("ok") == true) {
  10947. //요청확인
  10948. } else if (sSequence.equalsIgnoreCase("busy") == true) {
  10949. //통화중
  10950. } else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
  10951. //SIP 통화중
  10952. } else if (sSequence.equalsIgnoreCase("reject") == true) {
  10953. //거절
  10954. }
  10955. if (sStatus.equalsIgnoreCase("idle") == true) {
  10956. //대기
  10957. } else if (sStatus.equalsIgnoreCase("ringing") == true) {
  10958. //연결중
  10959. } else if (sStatus.equalsIgnoreCase("talking") == true) {
  10960. //통화중
  10961. }
  10962. //응답값 입력 필요!!
  10963. //김용성 과장님 작업필요
  10964. reply_Message = "null";
  10965. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  10966. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10967. retXML += " </service>\r\n</imap>";
  10968. return retXML;
  10969. } catch (RuntimeException re) {
  10970. LogUtil.errorLogInfo("", TAG, re);
  10971. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10972. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10973. retXML += " </service>\r\n</imap>";
  10974. return retXML;
  10975. } catch (Exception e) {
  10976. //e.printStackTrace();
  10977. LogUtil.errorLogInfo("", TAG, e);
  10978. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10979. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10980. retXML += " </service>\r\n</imap>";
  10981. return retXML;
  10982. }
  10983. }
  10984. public String ProcChatMessage(Element ele) {
  10985. String retXML = "";
  10986. String sChatMessage = "error";
  10987. String sMessage = "error";
  10988. try {
  10989. NodeList items = ele.getElementsByTagName("chat");
  10990. Node item = items.item(0);
  10991. NamedNodeMap attrsParam = item.getAttributes();
  10992. sChatMessage = trimquotation(item.getTextContent());
  10993. ///////////////////////////////////////////////
  10994. items = ele.getElementsByTagName("message");
  10995. item = items.item(0);
  10996. attrsParam = item.getAttributes();
  10997. sMessage = trimquotation(item.getTextContent());
  10998. ///////////////////////////////////////////////
  10999. //test
  11000. Log.d(TAG, "sChatMessage is " + sChatMessage);
  11001. Log.d(TAG, "sMessage is " + sMessage);
  11002. //test
  11003. Intent intent = new Intent();
  11004. intent.setAction(define.NOTIFY_ACNAME);
  11005. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  11006. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  11007. intent.putExtra("ADD_MESSAGE", sMessage);
  11008. getApplicationContext().sendBroadcast(intent);
  11009. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  11010. retXML += " <message>\"" + "null" + "\"</message>\r\n";
  11011. retXML += " </service>\r\n</imap>";
  11012. return retXML;
  11013. } catch (RuntimeException re) {
  11014. LogUtil.errorLogInfo("", TAG, re);
  11015. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  11016. retXML += " </service>\r\n</imap>";
  11017. return retXML;
  11018. } catch (Exception e) {
  11019. //e.printStackTrace();
  11020. LogUtil.errorLogInfo("", TAG, e);
  11021. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  11022. retXML += " </service>\r\n</imap>";
  11023. return retXML;
  11024. }
  11025. }
  11026. public String ProcEvacuationLadderOpen(Element ele) {
  11027. String retXML = "";
  11028. try {
  11029. String sDong = null;
  11030. String sHo = null;
  11031. NodeList items = ele.getElementsByTagName("home_info");
  11032. Node item = items.item(0);
  11033. NamedNodeMap attrsParam = item.getAttributes();
  11034. for (int i = 0; i < attrsParam.getLength(); i++) {
  11035. Node attr = attrsParam.item(i);
  11036. if (attr.getNodeName().equalsIgnoreCase("dong"))
  11037. sDong = trimquotation(attr.getNodeValue());
  11038. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  11039. sHo = trimquotation(attr.getNodeValue());
  11040. }
  11041. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  11042. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  11043. deviceSet.closeDB();
  11044. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  11045. WallpadStatusData DBMGR = null;
  11046. DBMGR = new WallpadStatusData(getApplicationContext());
  11047. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  11048. DBMGR.closeDB();
  11049. String myIP = addc.IPAddress;
  11050. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  11051. String[] SplitedString = myIP.split("\\.");
  11052. if (SplitedString != null) {
  11053. if (SplitedString.length == 4) {
  11054. int temp = Integer.parseInt(SplitedString[2]);
  11055. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11056. temp = temp - 1;
  11057. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11058. temp = temp + 1;
  11059. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  11060. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  11061. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  11062. DestStair = String.valueOf(temp);
  11063. }
  11064. }
  11065. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
  11066. /**
  11067. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  11068. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  11069. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  11070. * **/
  11071. WallpadDeviceSet devset;
  11072. devset = new WallpadDeviceSet(getApplicationContext());
  11073. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11074. devset.closeDB();
  11075. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11076. /**
  11077. * 피난사다리 알림!!!
  11078. * **/
  11079. ReceiveNetworkLadderBr(ladderDownSend);
  11080. }
  11081. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  11082. retXML += " </service>\r\n</imap>";
  11083. return retXML;
  11084. } else {
  11085. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11086. retXML += " </service>\r\n</imap>";
  11087. return retXML;
  11088. }
  11089. } catch (RuntimeException re) {
  11090. LogUtil.errorLogInfo("", TAG, re);
  11091. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11092. retXML += " </service>\r\n</imap>";
  11093. return retXML;
  11094. } catch (Exception e) {
  11095. //e.printStackTrace();
  11096. LogUtil.errorLogInfo("", TAG, e);
  11097. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11098. retXML += " </service>\r\n</imap>";
  11099. return retXML;
  11100. }
  11101. }
  11102. private void ReceiveNetworkLadderBr(int val) {
  11103. int base = 7000;
  11104. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  11105. int Menu_Start_Option = 1;
  11106. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  11107. int AlarmStatus = wdb.GetAlarmStatus();
  11108. wdb.closeDB();
  11109. boolean MgrAppRun = false;
  11110. final String packageNameMgr = "com.artncore.managersetting";
  11111. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  11112. if (MgrAppRun)
  11113. return;
  11114. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  11115. return;
  11116. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11117. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11118. devset.closeDB();
  11119. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11120. Common.SendAppFinishReqBR(getApplicationContext());
  11121. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11122. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11123. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  11124. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11125. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11126. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  11127. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11128. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  11129. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11130. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11131. getApplicationContext().startActivity(newintent);
  11132. }
  11133. }
  11134. /**
  11135. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  11136. *
  11137. * @param ele Element Xml 데이터
  11138. * @return String 타입의 응답 메시지 생성
  11139. **/
  11140. public String SmartLightDetailInfo(Element ele) {
  11141. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  11142. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  11143. }
  11144. /**
  11145. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  11146. *
  11147. * @param ele Element Xml 데이터
  11148. * @return String 타입의 응답 메시지 생성
  11149. **/
  11150. public String KNXDeviceDetailInfo(Element ele) {
  11151. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  11152. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  11153. }
  11154. public String ProcSetServerChange(Element ele) {
  11155. String retXML = "";
  11156. String versionTXT = null;
  11157. try {
  11158. boolean bRet = false;
  11159. NodeList items = ele.getElementsByTagName("ver_server");
  11160. Node item = items.item(0);
  11161. Node text = item.getFirstChild();
  11162. versionTXT = trimquotation(text.getNodeValue());
  11163. if (versionTXT.equalsIgnoreCase("1.0")) {
  11164. bRet = true;
  11165. } else if (versionTXT.indexOf("2.") >= 0) {
  11166. bRet = true;
  11167. }
  11168. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11169. if (SetData != null && bRet == true) {
  11170. SetData.SetServerVer(versionTXT);
  11171. SetData.closeDB();
  11172. }
  11173. if (bRet == true) {
  11174. try {
  11175. iMapSverReload tSock = new iMapSverReload();
  11176. tSock.start();
  11177. } catch (IOException e) {
  11178. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  11179. //e.printStackTrace();
  11180. LogUtil.errorLogInfo("", TAG, e);
  11181. }
  11182. }
  11183. // 버전 체크해서
  11184. // 응답하고 나서
  11185. // 수신부 쓰레드 재 로딩..
  11186. if (versionTXT != null && bRet == true) {
  11187. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  11188. retXML += " </service>\r\n</imap>";
  11189. return retXML;
  11190. } else {
  11191. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11192. retXML += " </service>\r\n</imap>";
  11193. return retXML;
  11194. }
  11195. } catch (RuntimeException re) {
  11196. LogUtil.errorLogInfo("", TAG, re);
  11197. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11198. retXML += " </service>\r\n</imap>";
  11199. return retXML;
  11200. } catch (Exception e) {
  11201. //e.printStackTrace();
  11202. LogUtil.errorLogInfo("", TAG, e);
  11203. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11204. retXML += " </service>\r\n</imap>";
  11205. return retXML;
  11206. }
  11207. }
  11208. /**
  11209. * 현관 열림 명령을 내린다.
  11210. *
  11211. * @return (String) - > success : 성공, fail : 실패
  11212. */
  11213. private String Device_DoorOpen(final int address) {
  11214. Log.i(TAG, "[Device_DoorOpen] - Start");
  11215. final ModbusClient modbusClient = new ModbusClient("10.0.215.2", 502);
  11216. modbusClient.setConnectionTimeout(5000);
  11217. try {
  11218. new Thread() {
  11219. public void run() {
  11220. try {
  11221. modbusClient.Connect();
  11222. modbusClient.WriteSingleCoil(address, true);
  11223. Thread.sleep(600);
  11224. modbusClient.WriteSingleCoil(address, false);
  11225. modbusClient.Disconnect();
  11226. } catch (IOException | ModbusException | InterruptedException e) {
  11227. e.printStackTrace();
  11228. try {
  11229. modbusClient.Disconnect();
  11230. } catch (IOException ioException) {
  11231. ioException.printStackTrace();
  11232. }
  11233. }
  11234. }
  11235. }.start();
  11236. } catch (RuntimeException re) {
  11237. LogUtil.errorLogInfo("", TAG, re);
  11238. return "fail";
  11239. } catch (Exception e) {
  11240. //e.printStackTrace();
  11241. LogUtil.errorLogInfo("", TAG, e);
  11242. return "fail";
  11243. }
  11244. Log.i(TAG, "[Device_DoorOpen] - OK");
  11245. return "ok";
  11246. }
  11247. /**
  11248. * 현관 문열림 요청에 대한 응답
  11249. * @return String 타입의 응답 메시지 생성
  11250. **/
  11251. private long mLastClickTime = 0;
  11252. private final long MIN_CLICK_INTERVAL = 3000;
  11253. public String ProcFrontOpen() {
  11254. String oepn_result;
  11255. long currentClickTime = SystemClock.uptimeMillis();
  11256. long elapsedTime = currentClickTime - mLastClickTime;
  11257. mLastClickTime = currentClickTime;
  11258. // 연속으로 문열림 요청이 들어오는 경우를 방지하기 위한 처리. 3초안에 문열림 요청이 다시 들어오면 무시하고, fail 처리함.
  11259. if (elapsedTime < MIN_CLICK_INTERVAL) {
  11260. mLastClickTime = 0;
  11261. oepn_result = "fail";
  11262. }else{
  11263. oepn_result = Device_DoorOpen(19);
  11264. }
  11265. String retXML = XMLHeader + "<service type=\"reply\" name=\"front_open\" result=\"" + oepn_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  11266. return retXML;
  11267. }
  11268. // 메인 서버 소켓 클래스
  11269. public class iMapSverReload extends Thread {
  11270. ServerSocket svr;
  11271. public iMapSverReload() throws IOException {
  11272. /////////////////////////////////////////////////////////////////////
  11273. // 신형 단지서버 사용 유무를 가져온다.
  11274. /////////////////////////////////////////////////////////////////////
  11275. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11276. if (SetData != null) {
  11277. String serverVesionInfo = SetData.GetServerVer();
  11278. SetData.closeDB();
  11279. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  11280. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11281. boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
  11282. devset.closeDB();
  11283. } else {
  11284. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11285. boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
  11286. devset.closeDB();
  11287. }
  11288. }
  11289. try {
  11290. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11291. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11292. wallpadDeviceSet.closeDB();
  11293. } catch (RuntimeException re) {
  11294. LogUtil.errorLogInfo("", TAG, re);
  11295. mNewDanjiServer = false;
  11296. } catch (Exception e) {
  11297. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  11298. //e.printStackTrace();
  11299. LogUtil.errorLogInfo("", TAG, e);
  11300. mNewDanjiServer = false;
  11301. }
  11302. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
  11303. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  11304. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  11305. // 관리 PC IP도 변경하도록 한다.
  11306. if (mNewDanjiServer == true) {
  11307. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11308. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  11309. wallpadStatusData.closeDB();
  11310. } else {
  11311. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11312. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  11313. wallpadStatusData.closeDB();
  11314. }
  11315. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  11316. }
  11317. public void run() {
  11318. try {
  11319. try {
  11320. Thread.sleep(400);
  11321. } catch (RuntimeException re) {
  11322. LogUtil.errorLogInfo("", TAG, re);
  11323. } catch (Exception e) {
  11324. LogUtil.errorLogInfo("", TAG, e);
  11325. }
  11326. SvrSock.destoryThread();
  11327. for (int i = 0; i < 20; i++) {
  11328. if (SvrSock.isAlive() == false) {
  11329. Log.d(TAG, " Receive Socket Reload i = : " + i);
  11330. break;
  11331. } else {
  11332. Log.d(TAG, " is Live Socket Reload i = : " + i);
  11333. }
  11334. try {
  11335. Thread.sleep(100);
  11336. } catch (RuntimeException re) {
  11337. LogUtil.errorLogInfo("", TAG, re);
  11338. } catch (Exception e) {
  11339. LogUtil.errorLogInfo("", TAG, e);
  11340. }
  11341. }
  11342. SvrSock = new iMapSverSocket();
  11343. SvrSock.start();
  11344. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  11345. try {
  11346. Thread.sleep(3000);
  11347. } catch (RuntimeException re) {
  11348. LogUtil.errorLogInfo("", TAG, re);
  11349. } catch (Exception e) {
  11350. LogUtil.errorLogInfo("", TAG, e);
  11351. }
  11352. try {
  11353. Intent intent = new Intent();
  11354. intent.setAction(define.NOTIFY_ACNAME);
  11355. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  11356. getApplicationContext().sendBroadcast(intent);
  11357. } catch (RuntimeException re) {
  11358. LogUtil.errorLogInfo("", TAG, re);
  11359. } catch (Exception e) {
  11360. //e.printStackTrace();
  11361. LogUtil.errorLogInfo("", TAG, e);
  11362. }
  11363. } catch (IOException e) {
  11364. //e.printStackTrace();
  11365. LogUtil.errorLogInfo("", TAG, e);
  11366. }
  11367. }
  11368. }
  11369. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  11370. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  11371. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  11372. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  11373. public static final int SCHEDULE_START_CALLAPP = 30004;
  11374. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  11375. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  11376. public class SchedulerThread extends Thread {
  11377. boolean doRun;
  11378. AddressSet addr;
  11379. String AddressStr;
  11380. String IPaddr;
  11381. String VerBSP = "";
  11382. String VerAPP;
  11383. String VerSetting;
  11384. String VerNews;
  11385. String VerWeather;
  11386. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  11387. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  11388. private jni mGleInterface = null;
  11389. private final int LIVE_SIGNAL_TIME = 20;
  11390. private int m_LiveSignalCount = 0;
  11391. private int m_MainAppLiveCount = 0;
  11392. Handler ScheDuleHandler = new Handler() {
  11393. public void handleMessage(Message msg) {
  11394. switch (msg.what) {
  11395. case SCHEDULE_START_HEARTBEAT: {
  11396. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  11397. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11398. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11399. DBMGR.closeDB();
  11400. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11401. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11402. }
  11403. break;
  11404. case SCHEDULE_CHANGE_HEARTBEAT:
  11405. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  11406. synchronized (ScheduleList) {
  11407. ScheduleData CheckData;
  11408. for (int i = 0; i < ScheduleList.size(); i++) {
  11409. CheckData = ScheduleList.get(i);
  11410. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11411. Calendar cal = new GregorianCalendar();
  11412. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11413. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11414. DBMGR.closeDB();
  11415. cal.add(Calendar.MINUTE, heartbeatP);
  11416. CheckData.TData = cal;
  11417. ScheduleList.set(i, CheckData);
  11418. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11419. return;
  11420. }
  11421. }
  11422. }
  11423. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11424. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11425. break;
  11426. case SCHEDULE_START_STATUSBEAT:
  11427. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  11428. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11429. break;
  11430. case SCHEDULE_CHANGE_STATUSBEAT:
  11431. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  11432. synchronized (ScheduleList) {
  11433. ScheduleData CheckData;
  11434. for (int i = 0; i < ScheduleList.size(); i++) {
  11435. CheckData = ScheduleList.get(i);
  11436. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11437. Calendar cal = new GregorianCalendar();
  11438. cal.add(Calendar.MINUTE, heartbeatP);
  11439. CheckData.TData = cal;
  11440. ScheduleList.set(i, CheckData);
  11441. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11442. return;
  11443. }
  11444. }
  11445. }
  11446. break;
  11447. case SCHEDULE_START_CALLAPP:
  11448. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  11449. // Bundle bundle = new Bundle();
  11450. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  11451. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  11452. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  11453. // .putExtra(ITEM_CALL_DATA, bundle);
  11454. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11455. // iMAPstartActivity(intent);
  11456. break;
  11457. }
  11458. }
  11459. };
  11460. Handler GetHandler() {
  11461. return ScheDuleHandler;
  11462. }
  11463. public class ScheduleData {
  11464. Calendar TData;
  11465. String ActionSTR;
  11466. public ScheduleData(Calendar tdata, String ActionStr) {
  11467. TData = tdata;
  11468. ActionSTR = ActionStr;
  11469. }
  11470. }
  11471. public SchedulerThread() {
  11472. doRun = true;
  11473. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11474. addr = DBMGR.getAddressMGR();
  11475. VerAPP = DBMGR.GetAPPVer();
  11476. VerSetting = DBMGR.GetSettingVer();
  11477. VerNews = DBMGR.GetNoticeVer();
  11478. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11479. DBMGR.closeDB();
  11480. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  11481. try {
  11482. mGleInterface = new jni();
  11483. } catch (RuntimeException re) {
  11484. LogUtil.errorLogInfo("", TAG, re);
  11485. } catch (Exception e) {
  11486. Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
  11487. }
  11488. }
  11489. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
  11490. VerAPP = GetAppVersion();
  11491. }
  11492. AddressStr = addr.Dong + "동" + addr.Ho + "호";
  11493. IPaddr = addr.IPAddress;
  11494. ScheDulerHandler = ScheDuleHandler;
  11495. }
  11496. public void reg_schedule(int min, String Action) {
  11497. for (int i = 0; i < ScheduleList.size(); i++) {
  11498. ScheduleData scdata = ScheduleList.get(i);
  11499. if (scdata.ActionSTR.equals(Action)) {
  11500. ScheduleList.remove(i);
  11501. break;
  11502. }
  11503. }
  11504. Calendar cal = new GregorianCalendar();
  11505. cal.add(Calendar.MINUTE, min);
  11506. ScheduleData regData = new ScheduleData(cal, Action);
  11507. synchronized (ScheduleList) {
  11508. ScheduleList.add(regData);
  11509. }
  11510. }
  11511. private void doSchedule(String doing) {
  11512. String[] doingData = doing.split(";");
  11513. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11514. try {
  11515. String SendingStr = MakeHeartbeat();
  11516. SendToServer(SendingStr);
  11517. Calendar cal = new GregorianCalendar();
  11518. 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));
  11519. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11520. DBMGR.SetLastHeartbeat(timedata);
  11521. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11522. DBMGR.closeDB();
  11523. } catch (RuntimeException re) {
  11524. LogUtil.errorLogInfo("", TAG, re);
  11525. } catch (Exception e) {
  11526. //e.printStackTrace();
  11527. LogUtil.errorLogInfo("", TAG, e);
  11528. }
  11529. } else if (doingData[0].equals("UPDATETIME")) {
  11530. } else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11531. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  11532. if (!Common.getDeviceServeiceLoadComplite()) return;
  11533. String SendingStr = MakeStatusReport();
  11534. if (SendingStr == null) return;
  11535. SendToServer(SendingStr);
  11536. Calendar cal = new GregorianCalendar();
  11537. 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));
  11538. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11539. DBMGR.SetLastStatusbeat(timedata);
  11540. DBMGR.closeDB();
  11541. int StatusP = 720;
  11542. try {
  11543. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11544. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11545. devset.closeDB();
  11546. if (StatusVal == null) StatusP = 720;
  11547. else StatusP = Integer.parseInt(StatusVal[1]);
  11548. } catch (RuntimeException re) {
  11549. LogUtil.errorLogInfo("", TAG, re);
  11550. } catch (Exception e) {
  11551. //e.printStackTrace();
  11552. LogUtil.errorLogInfo("", TAG, e);
  11553. }
  11554. reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
  11555. }
  11556. }
  11557. private String MakeHeartbeat() {
  11558. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11559. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11560. VerNews = DBMGR.GetNoticeVer();
  11561. VerSetting = DBMGR.GetSettingVer();
  11562. String VerServer = DBMGR.GetServerVer();
  11563. DBMGR.closeDB();
  11564. if (VerServer == null) {
  11565. Log.d(TAG, "VerServer null");
  11566. VerServer = "1.0";
  11567. }
  11568. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11569. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  11570. wallpadDeviceSet.closeDB();
  11571. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  11572. // 스마트 분전반
  11573. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  11574. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  11575. String retStr = XMLHeader +
  11576. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11577. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11578. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11579. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11580. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11581. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11582. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11583. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11584. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11585. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11586. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11587. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n" +
  11588. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n" +
  11589. "</service>\r\n</imap>";
  11590. return retStr;
  11591. } else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  11592. // TODO KNX 분전반
  11593. // String retStr = XMLHeader+
  11594. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  11595. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  11596. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  11597. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  11598. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  11599. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  11600. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  11601. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  11602. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  11603. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  11604. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11605. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  11606. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  11607. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  11608. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  11609. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  11610. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  11611. // "</service>\r\n</imap>";
  11612. String retStr = XMLHeader +
  11613. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11614. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11615. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11616. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11617. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11618. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11619. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11620. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11621. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11622. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11623. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11624. "</service>\r\n</imap>";
  11625. return retStr;
  11626. } else {
  11627. String retStr = XMLHeader +
  11628. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11629. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11630. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11631. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11632. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11633. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11634. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11635. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11636. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11637. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11638. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11639. "</service>\r\n</imap>";
  11640. return retStr;
  11641. }
  11642. }
  11643. public String GetAppVersion() {
  11644. PackageInfo pi = null;
  11645. try {
  11646. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  11647. } catch (RuntimeException re) {
  11648. LogUtil.errorLogInfo("", TAG, re);
  11649. } catch (Exception e) {
  11650. LogUtil.errorLogInfo("", TAG, e);
  11651. }
  11652. return pi.versionName;
  11653. }
  11654. boolean isAlawaysrun = true;
  11655. public void run() {
  11656. while (/*doRun*/ isAlawaysrun) {
  11657. //Common.DebugLog("SchedulerThread ------ 10Sec");
  11658. CheckHeartBeat();
  11659. CheckStatusBeat();
  11660. CheckWallPadLiveSignal();
  11661. LiveCheckRebooting();
  11662. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  11663. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  11664. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  11665. //다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
  11666. if(skipCount==0) {
  11667. sendMsgToActivity(1234);
  11668. Log.d(TAG, "sendMsgToActivity!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
  11669. }
  11670. skipCount++;
  11671. if(skipCount==18) skipCount = 0 ;
  11672. }
  11673. try {
  11674. Thread.sleep(10000);
  11675. } catch (RuntimeException re) {
  11676. LogUtil.errorLogInfo("", TAG, re);
  11677. } catch (Exception e) {
  11678. LogUtil.errorLogInfo("", TAG, e);
  11679. }
  11680. }
  11681. }
  11682. public void SetLive() {
  11683. m_MainAppLiveCount++;
  11684. }
  11685. private int CheckTime30Sec = 0;
  11686. private void LiveCheckRebooting() {
  11687. try {
  11688. CheckTime30Sec++;
  11689. if (CheckTime30Sec % 20 == 0) {
  11690. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  11691. // // 10초마다 수행되는 함수이니....
  11692. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  11693. // if (m_MainAppLiveCount == 0) {
  11694. // //리셋
  11695. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  11696. // {
  11697. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  11698. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  11699. // pm.userActivity(8, true);
  11700. // }
  11701. // else
  11702. // {
  11703. // Log.d(TAG, "Main App Down Reset IHN_750");
  11704. // WallPadInterface wpdifc = new WallPadInterface();
  11705. // wpdifc.WachdogSystemReset();
  11706. // }
  11707. // }
  11708. // }
  11709. CheckTime30Sec = 0;
  11710. }
  11711. if (CheckTime30Sec >= 30000) {
  11712. CheckTime30Sec = 0;
  11713. }
  11714. } catch (RuntimeException re) {
  11715. LogUtil.errorLogInfo("", TAG, re);
  11716. } catch (Exception e) {
  11717. //e.printStackTrace();
  11718. LogUtil.errorLogInfo("", TAG, e);
  11719. }
  11720. }
  11721. private void CheckWallPadLiveSignal() {
  11722. try {
  11723. int nTime = LIVE_SIGNAL_TIME / 10;
  11724. m_LiveSignalCount++;
  11725. if (m_LiveSignalCount >= nTime) {
  11726. m_LiveSignalCount = 0;
  11727. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  11728. }
  11729. } catch (RuntimeException re) {
  11730. LogUtil.errorLogInfo("", TAG, re);
  11731. } catch (Exception e) {
  11732. Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
  11733. }
  11734. }
  11735. protected void CheckStatusBeat() {
  11736. try {
  11737. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11738. String statusbeatdata = WPD.GetLastStatusbeat();
  11739. WPD.closeDB();
  11740. int StatusP = 720;
  11741. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11742. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11743. if (StatusVal == null) StatusP = 720;
  11744. else
  11745. StatusP = Integer.parseInt(StatusVal[1]);
  11746. devset.closeDB();
  11747. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11748. } catch (RuntimeException re) {
  11749. LogUtil.errorLogInfo("", TAG, re);
  11750. } catch (Exception e) {
  11751. //e.printStackTrace();
  11752. LogUtil.errorLogInfo("", TAG, e);
  11753. }
  11754. }
  11755. protected void CheckHeartBeat() {
  11756. try {
  11757. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11758. String heartbeatdata = WPD.GetLastHeartbeat();
  11759. int heartbeatPer = WPD.GetHeartbeatPeriod();
  11760. WPD.closeDB();
  11761. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11762. } catch (RuntimeException re) {
  11763. LogUtil.errorLogInfo("", TAG, re);
  11764. } catch (Exception e) {
  11765. //e.printStackTrace();
  11766. LogUtil.errorLogInfo("", TAG, e);
  11767. }
  11768. }
  11769. protected boolean CheckTime(String CheckT, int period) {
  11770. Calendar last = new GregorianCalendar();
  11771. String[] timedata = CheckT.split("[.]");
  11772. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  11773. last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
  11774. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  11775. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  11776. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  11777. last.add(Calendar.MINUTE, period);
  11778. Calendar checkCal = new GregorianCalendar();
  11779. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  11780. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  11781. return true;
  11782. return false;
  11783. }
  11784. }
  11785. class SendMSGToSVR extends Thread {
  11786. String sendmsg;
  11787. public SendMSGToSVR(String msg) {
  11788. sendmsg = msg;
  11789. }
  11790. public void run() {
  11791. Socket sock = null;
  11792. DataOutputStream outstream = null;
  11793. try {
  11794. // 신형 단지서버 사용 유무를 가져온다.
  11795. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11796. boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11797. wallpadDeviceSet.closeDB();
  11798. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11799. SVRIP = DBMGR.GetServerIP();
  11800. port = DBMGR.GetServerPort();
  11801. DBMGR.closeDB();
  11802. /////////////////////////////////////////////////////////////////////
  11803. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  11804. // 사용중일 경우 암호화 소켓을 생성한다.
  11805. /////////////////////////////////////////////////////////////////////
  11806. if (!bNewDanjiServer) {
  11807. sock = new Socket(SVRIP, port);
  11808. } else {
  11809. int setport = port + 1000;
  11810. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  11811. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  11812. sock = sslClientSocket.getSocket();
  11813. }
  11814. /////////////////////////////////////////////////////////////////////
  11815. if (sock != null) {
  11816. sock.setSoLinger(true, 1000);
  11817. outstream = new DataOutputStream(sock.getOutputStream());
  11818. byte[] outBF = sendmsg.getBytes("euc-kr");
  11819. outstream.write(outBF);
  11820. outstream.flush();
  11821. }
  11822. } catch (RuntimeException re) {
  11823. LogUtil.errorLogInfo("", TAG, re);
  11824. } catch (Exception e) {
  11825. //e.printStackTrace();
  11826. LogUtil.errorLogInfo("", TAG, e);
  11827. } finally {
  11828. if (outstream != null) {
  11829. try {
  11830. outstream.close();
  11831. } catch (IOException e) {
  11832. LogUtil.errorLogInfo("", TAG, e);
  11833. }
  11834. }
  11835. outstream = null;
  11836. if (sock != null) {
  11837. try {
  11838. sock.close();
  11839. } catch (IOException e) {
  11840. LogUtil.errorLogInfo("", TAG, e);
  11841. }
  11842. }
  11843. sock = null;
  11844. }
  11845. }
  11846. }
  11847. private void SendToServer(String msg) {
  11848. SendMSGToSVR msan = new SendMSGToSVR(msg);
  11849. msan.start();
  11850. }
  11851. boolean StatusBeatRequested = false;
  11852. private String MakeStatusReport() {
  11853. try {
  11854. String ServiceType = StatusBeatRequested ? "requested" : "notice";
  11855. StatusBeatRequested = false;
  11856. String RetData = XMLHeader + "<service type=\"" + ServiceType + "\" name=\"statusbeat\"> \r\n";
  11857. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  11858. String[] typeList = SettManager.GetTypeList();
  11859. if (typeList == null || typeList.length == 0) {
  11860. DefaultProcauscultateReq(SettManager);
  11861. typeList = SettManager.GetTypeList();
  11862. }
  11863. SettManager.closeDB();
  11864. String[] ControlList;
  11865. String Vender = "null";
  11866. String devid = "null";
  11867. String Model = "null";
  11868. String subunitcnt = "null";
  11869. String statusRate = "null";
  11870. String statusType = "null";
  11871. String message = "null";
  11872. int itemCNT = 0;
  11873. int totalGroup = 0;
  11874. int totalItem = 0;
  11875. String ControlDEVList;
  11876. String ContentList = " ";
  11877. if (typeList != null) {
  11878. for (int i = 0; i < typeList.length; i++) {
  11879. if (typeList[i].equals("ctrl_device")) {
  11880. SettManager = new WallpadDevStatus(getApplicationContext());
  11881. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  11882. SettManager.closeDB();
  11883. ControlDEVList = "";
  11884. if (ControlList != null) {
  11885. for (int k = 0; k < ControlList.length; k++) {
  11886. if (ControlList[k].equals("light")) {
  11887. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11888. int[] lightinfo = devSet.Get_Light_info();
  11889. devSet.closeDB();
  11890. if (lightinfo[0] == 1) {
  11891. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  11892. subunitcnt = String.valueOf(lightinfo[2]);
  11893. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  11894. devid = "0x11";
  11895. Vender = "null";
  11896. Model = "null";
  11897. if (lightCTR != null) {
  11898. lightCTR.TRInfo.GetTransactionList(0);
  11899. statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
  11900. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  11901. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11902. message = "null";
  11903. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11904. itemCNT++;
  11905. }
  11906. } else {
  11907. subunitcnt = String.valueOf(lightinfo[2]);
  11908. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  11909. if (MultiSW != null) {
  11910. MultiSW.Refresh((byte) 0xFF, false);
  11911. byte Bdevid = 0x51;
  11912. for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
  11913. devid = String.format("0x%02X", Bdevid + j);
  11914. Vender = "null";
  11915. Model = "null";
  11916. MultiSW.TRInfo.GetTransactionList(j);
  11917. statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
  11918. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  11919. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11920. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11921. itemCNT++;
  11922. }
  11923. }
  11924. }
  11925. } else {
  11926. Vender = "null";
  11927. devid = "null";
  11928. Model = "null";
  11929. subunitcnt = "null";
  11930. statusRate = "null";
  11931. message = "null";
  11932. }
  11933. } else if (ControlList[k].equals("thermostat")) {
  11934. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11935. int ret = devSet.Get_Temper_Info();
  11936. devSet.closeDB();
  11937. if (ret == 1) {
  11938. // 난방 종류를 얻어온다.
  11939. int HeatingKind = mWallPadAPI.GetHeatingKind();
  11940. HeatingV1API heatingV1API = null;
  11941. HeatingV2API heatingV2API = null;
  11942. // 종류별 API를 로딩한다.
  11943. if (HeatingKind == 1) {
  11944. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  11945. if (heatingV1API != null) {
  11946. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  11947. devid = "0x21";
  11948. Vender = "null";
  11949. Model = "null";
  11950. heatingV1API.TRInfo.GetTransactionList(0);
  11951. statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
  11952. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  11953. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11954. message = "null";
  11955. }
  11956. } else if (HeatingKind == 2) {
  11957. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  11958. if (heatingV2API != null) {
  11959. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  11960. devid = "0x28";
  11961. Vender = "null";
  11962. Model = "null";
  11963. heatingV2API.TRInfo.GetTransactionList(0);
  11964. statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
  11965. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  11966. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11967. message = "null";
  11968. }
  11969. } else {
  11970. subunitcnt = "null";
  11971. devid = "null";
  11972. Vender = "null";
  11973. Model = "null";
  11974. statusRate = "0/0";
  11975. statusType = "bad";
  11976. message = "null";
  11977. }
  11978. ControlDEVList += " <unit type=\"thermostat\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11979. itemCNT++;
  11980. } else {
  11981. }
  11982. } else if (ControlList[k].equals("gas")) {
  11983. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11984. if (devSet.Get_GAS_Info() == 1) {
  11985. //여기서 신우전자확인이 더 필요함
  11986. GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
  11987. CooktopAPI HybridCookTopCTR = null;
  11988. subunitcnt = "1";
  11989. devid = "0x31";
  11990. Vender = "null";
  11991. Model = "null";
  11992. if (mWallPadAPI.GetGasKind() == 2) {
  11993. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  11994. if (HybridCookTopCTR != null) {
  11995. HybridCookTopCTR.TRInfo.GetTransactionList(0);
  11996. statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
  11997. double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
  11998. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11999. message = "null";
  12000. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12001. itemCNT++;
  12002. }
  12003. } else {
  12004. GasCTR = mWallPadAPI.Get_GasController();
  12005. if (GasCTR != null) {
  12006. GasCTR.TRInfo.GetTransactionList(0);
  12007. statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
  12008. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  12009. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12010. message = "null";
  12011. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12012. itemCNT++;
  12013. }
  12014. }
  12015. } else {
  12016. }
  12017. devSet.closeDB();
  12018. } else if (ControlList[k].equals("doorlock")) {
  12019. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12020. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  12021. if (doorlockInfo[0] == 1) {
  12022. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  12023. subunitcnt = "1";
  12024. devid = "0x41";
  12025. Vender = "null";
  12026. Model = "null";
  12027. if (DoorCTR != null) {
  12028. DoorCTR.TRInfo.GetTransactionList(0);
  12029. statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
  12030. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  12031. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12032. message = "null";
  12033. ControlDEVList += " <unit type=\"doorlock\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12034. itemCNT++;
  12035. }
  12036. } else {
  12037. }
  12038. devSet.closeDB();
  12039. } else if (ControlList[k].equals("ventil")) {
  12040. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12041. int[] ventilInfo = devSet.Get_Ventil_Info();
  12042. if (ventilInfo[0] == 1) {
  12043. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  12044. subunitcnt = "1";
  12045. devid = "0x61";
  12046. Vender = "null";
  12047. Model = "null";
  12048. if (VentilCTR != null) {
  12049. VentilCTR.TRInfo.GetTransactionList(0);
  12050. statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
  12051. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  12052. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12053. message = "null";
  12054. ControlDEVList += " <unit type=\"ventil\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12055. itemCNT++;
  12056. }
  12057. } else {
  12058. }
  12059. devSet.closeDB();
  12060. } else if (ControlList[k].equals("aircon")) {
  12061. } else if (ControlList[k].equals("curtain")) {
  12062. }
  12063. }
  12064. if (itemCNT > 0) {
  12065. ContentList += "<group type=\"ctrl_device\" count=\"" + itemCNT + "\">\r\n";
  12066. ContentList += ControlDEVList;
  12067. ContentList += "</group>\r\n";
  12068. totalGroup++;
  12069. totalItem += itemCNT;
  12070. }
  12071. }
  12072. } else if (typeList[i].equals("talk_device")) {
  12073. SettManager = new WallpadDevStatus(getApplicationContext());
  12074. ControlList = SettManager.GetSettingGroupData("talk_device");
  12075. SettManager.closeDB();
  12076. itemCNT = 0;
  12077. ControlDEVList = "";
  12078. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  12079. if (testAPI != null)
  12080. testAPI.GetVersion();
  12081. if (ControlList != null) {
  12082. for (int k = 0; k < ControlList.length; k++) {
  12083. if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
  12084. 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";
  12085. itemCNT++;
  12086. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  12087. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  12088. } else if (ControlList[k].equals("bath_phone") && testAPI != null) {
  12089. 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";
  12090. itemCNT++;
  12091. } else if (ControlList[k].equals("subhome_dev")) {
  12092. }
  12093. }
  12094. if (itemCNT > 0) {
  12095. ContentList += "<group type=\"talk_device\" count=\"" + itemCNT + "\">\r\n";
  12096. ContentList += ControlDEVList;
  12097. ContentList += "</group>\r\n";
  12098. totalGroup++;
  12099. totalItem += itemCNT;
  12100. }
  12101. }
  12102. } else if (typeList[i].equals("sensor")) {
  12103. SettManager = new WallpadDevStatus(getApplicationContext());
  12104. ControlList = SettManager.GetSettingGroupData("sensor");
  12105. SettManager.closeDB();
  12106. itemCNT = 0;
  12107. ControlDEVList = "";
  12108. if (ControlList != null) {
  12109. for (int k = 0; k < ControlList.length; k++) {
  12110. if (ControlList[k].equals("magnetic")) {
  12111. WallPadInterface wpifc = new WallPadInterface();
  12112. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  12113. String SenStateCom;
  12114. String SenStateType;
  12115. if (MagSen == 1) {
  12116. SenStateCom = "1/1";
  12117. SenStateType = "";
  12118. } else {
  12119. SenStateCom = "0/1";
  12120. SenStateType = "perfect";
  12121. }
  12122. ControlDEVList += " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12123. itemCNT++;
  12124. } else if (ControlList[k].equals("bugout")) {
  12125. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12126. int sensor = devSet.Get_Sensor_Set();
  12127. devSet.closeDB();
  12128. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  12129. WallPadInterface wpifc = new WallPadInterface();
  12130. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12131. String SenStateCom;
  12132. String SenStateType;
  12133. if (outSen == 1) {
  12134. SenStateCom = "1/1";
  12135. SenStateType = "bad";
  12136. } else {
  12137. SenStateCom = "0/1";
  12138. SenStateType = "perfect";
  12139. }
  12140. ControlDEVList += " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12141. itemCNT++;
  12142. }
  12143. } else if (ControlList[k].equals("bugin")) {
  12144. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12145. int sensor = devSet.Get_Sensor_Set();
  12146. devSet.closeDB();
  12147. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  12148. WallPadInterface wpifc = new WallPadInterface();
  12149. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12150. String SenStateCom;
  12151. String SenStateType;
  12152. if (InSen == 1) {
  12153. SenStateCom = "1/1";
  12154. SenStateType = "bad";
  12155. } else {
  12156. SenStateCom = "0/1";
  12157. SenStateType = "perfect";
  12158. }
  12159. ControlDEVList += " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12160. itemCNT++;
  12161. }
  12162. } else if (ControlList[k].equals("fire")) {
  12163. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12164. } else if (ControlList[k].equals("gas")) {
  12165. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12166. }
  12167. }
  12168. if (itemCNT > 0) {
  12169. ContentList += "<group type=\"sensor\" count=\"" + itemCNT + "\">\r\n";
  12170. ContentList += ControlDEVList;
  12171. ContentList += "</group>\r\n";
  12172. totalGroup++;
  12173. totalItem += itemCNT;
  12174. }
  12175. }
  12176. } else if (typeList[i].equals("extended")) {
  12177. SettManager = new WallpadDevStatus(getApplicationContext());
  12178. ControlList = SettManager.GetSettingGroupData("extended");
  12179. SettManager.closeDB();
  12180. itemCNT = 0;
  12181. ControlDEVList = "";
  12182. if (ControlList != null) {
  12183. for (int k = 0; k < ControlList.length; k++) {
  12184. if (ControlList[k].equals("gateway")) {
  12185. } else if (ControlList[k].equals("handy")) {
  12186. } else if (ControlList[k].equals("smartswitch")) {
  12187. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12188. int[] BatchInfo = devSet.Get_BatchSW_Info();
  12189. devSet.closeDB();
  12190. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
  12191. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  12192. SmartSWCTR.TRInfo.GetTransactionList(0);
  12193. subunitcnt = "1";
  12194. statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
  12195. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  12196. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12197. message = "null";
  12198. ControlDEVList += " <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12199. itemCNT++;
  12200. } else {
  12201. }
  12202. } else if (ControlList[k].equals("energymeter")) {
  12203. }
  12204. }
  12205. if (itemCNT > 0) {
  12206. ContentList += "<group type=\"extended\" count=\"" + itemCNT + "\">\r\n";
  12207. ContentList += ControlDEVList;
  12208. ContentList += "</group>\r\n";
  12209. totalGroup++;
  12210. totalItem += itemCNT;
  12211. }
  12212. }
  12213. }
  12214. }
  12215. SettManager.closeDB();
  12216. ContentList += "</guidemap> \r\n";
  12217. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\"" + totalGroup + "\" device_cnt=\"" + totalItem + "\">\r\n";
  12218. RetData += ContentList;
  12219. String LogSet;
  12220. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  12221. RetData += LogSet;
  12222. try {
  12223. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  12224. String[] ResetData = WsDB.GetResetSchedule();
  12225. WsDB.closeDB();
  12226. if (!ResetData[0].equals("NONE")) {
  12227. int type = Integer.parseInt(ResetData[0]);
  12228. if (type == WallpadStatusData.RESET_MONTH)
  12229. LogSet = "<reset_info enable=\"true\" type=\"month\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12230. else if (type == WallpadStatusData.RESET_WEEK)
  12231. LogSet = "<reset_info enable=\"true\" type=\"week\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12232. else
  12233. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12234. } else
  12235. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12236. } catch (RuntimeException re) {
  12237. LogUtil.errorLogInfo("", TAG, re);
  12238. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12239. } catch (Exception e) {
  12240. //e.printStackTrace();
  12241. LogUtil.errorLogInfo("", TAG, e);
  12242. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12243. }
  12244. RetData += LogSet;
  12245. RetData += "</service>\r\n</imap>\r\n";
  12246. }
  12247. return RetData;
  12248. } catch (RuntimeException re) {
  12249. LogUtil.errorLogInfo("", TAG, re);
  12250. return null;
  12251. } catch (Exception e) {
  12252. //e.printStackTrace();
  12253. LogUtil.errorLogInfo("", TAG, e);
  12254. return null;
  12255. }
  12256. }
  12257. private String getKNXDeviceStatus(int device) {
  12258. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12259. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12260. String status = knxHeartbeat.getStatus();
  12261. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  12262. return status;
  12263. }
  12264. private String getKNXDeviceCause(int device) {
  12265. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12266. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12267. String cause = knxHeartbeat.getCause();
  12268. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  12269. return cause;
  12270. }
  12271. //mWallPadAPI
  12272. // private String TAG = "*yskim*";
  12273. //private IGW200dAPI iGW200dAPI = null;
  12274. /**
  12275. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12276. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12277. * 본 딜레이 코드를 임시로 적용한다.
  12278. */
  12279. @SuppressLint("HandlerLeak")
  12280. protected Handler IGW200APICheckHandler = new Handler() {
  12281. @SuppressLint("HandlerLeak")
  12282. @Override
  12283. public void handleMessage(Message msg) {
  12284. if (msg.what == 0) {
  12285. if (mWallPadAPI != null) {
  12286. Common.DebugLog("handleMessage what 0 ");
  12287. if (mWallPadAPI.Check_Connect())
  12288. IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12289. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12290. }
  12291. } else if (msg.what == 1) {
  12292. Common.DebugLog("handleMessage what 1 ");
  12293. setIGE200Interface();
  12294. }
  12295. }
  12296. };
  12297. public void setIGE200Interface() {
  12298. try {
  12299. Common.DebugLog("setIGE200Interface");
  12300. mIGW200 = new IGW200(this, mWallPadAPI);
  12301. } catch (RuntimeException re) {
  12302. LogUtil.errorLogInfo("", TAG, re);
  12303. } catch (Exception e) {
  12304. Log.e(TAG, "[Exception] setIGE200Interface()");
  12305. //e.printStackTrace();
  12306. LogUtil.errorLogInfo("", TAG, e);
  12307. }
  12308. }
  12309. /**
  12310. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12311. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12312. * 본 딜레이 코드를 임시로 적용한다.
  12313. */
  12314. @SuppressLint("HandlerLeak")
  12315. protected Handler IGW300APICheckHandler = new Handler() {
  12316. @SuppressLint("HandlerLeak")
  12317. @Override
  12318. public void handleMessage(Message msg) {
  12319. if (msg.what == 0) {
  12320. if (mWallPadAPI != null) {
  12321. Common.DebugLog("handleMessage what 0 ");
  12322. if (mWallPadAPI.Check_Connect())
  12323. IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12324. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12325. }
  12326. } else if (msg.what == 1) {
  12327. Common.DebugLog("handleMessage what 1 ");
  12328. setIGE300Interface();
  12329. }
  12330. }
  12331. };
  12332. public void setIGE300Interface() {
  12333. try {
  12334. Common.DebugLog("setIGE300Interface");
  12335. mIGW300 = new IGW300(this, mWallPadAPI);
  12336. } catch (RuntimeException re) {
  12337. LogUtil.errorLogInfo("", TAG, re);
  12338. } catch (Exception e) {
  12339. Log.e(TAG, "[Exception] setIGE300Interface()");
  12340. //e.printStackTrace();
  12341. LogUtil.errorLogInfo("", TAG, e);
  12342. }
  12343. }
  12344. // 외출모드 연동
  12345. private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
  12346. try {
  12347. bSmartSwitch485ComebackMode = false;
  12348. String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
  12349. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12350. String outLinkCtrl = wd.GetOutModeLinkDevice();
  12351. if (BedMode == true)
  12352. outLinkCtrl = wd.GetInBedLinkDevice();
  12353. wd.closeDB();
  12354. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  12355. if (WallpadUI == false) {
  12356. if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
  12357. {
  12358. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
  12359. CallElevatorBtn(false);
  12360. }
  12361. }
  12362. if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
  12363. {
  12364. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
  12365. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  12366. }
  12367. if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  12368. {
  12369. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
  12370. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  12371. }
  12372. if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  12373. {
  12374. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
  12375. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  12376. }
  12377. if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
  12378. {
  12379. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
  12380. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  12381. }
  12382. } catch (RuntimeException re) {
  12383. LogUtil.errorLogInfo("", TAG, re);
  12384. } catch (Exception e) {
  12385. Log.e("YSKIM", e.toString());
  12386. }
  12387. }
  12388. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  12389. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  12390. private boolean bSmartSwitch485ComebackMode = false;
  12391. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  12392. try {
  12393. if (bSmartSwitch485ComebackMode == true) return;
  12394. String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
  12395. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12396. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  12397. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  12398. wd.closeDB();
  12399. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  12400. // 일괄소등 해제
  12401. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
  12402. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  12403. }
  12404. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
  12405. // 환기동작
  12406. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
  12407. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  12408. }
  12409. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  12410. // 난방 외출모드 해제
  12411. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
  12412. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  12413. }
  12414. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  12415. // 웰컴조명 켜기
  12416. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
  12417. // 웰컴조명 Handler 실행
  12418. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  12419. }
  12420. } catch (RuntimeException re) {
  12421. LogUtil.errorLogInfo("", TAG, re);
  12422. } catch (Exception e) {
  12423. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  12424. //e.printStackTrace();
  12425. LogUtil.errorLogInfo("", TAG, e);
  12426. }
  12427. }
  12428. private Handler WelcomeLightHandler = new Handler() {
  12429. int LightOnCount = 0;
  12430. @Override
  12431. public void handleMessage(Message msg) {
  12432. if (msg.what == 0) {
  12433. try {
  12434. if (LightOnCount == 0) {
  12435. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  12436. }
  12437. // 일괄소등 해제이면
  12438. if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
  12439. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  12440. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  12441. } else {
  12442. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  12443. LightOnCount++;
  12444. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  12445. if (LightOnCount > 10) {
  12446. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  12447. LightOnCount = 0;
  12448. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  12449. }
  12450. }
  12451. } catch (RuntimeException re) {
  12452. LogUtil.errorLogInfo("", TAG, re);
  12453. } catch (Exception e1) {
  12454. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  12455. //e1.printStackTrace();
  12456. LogUtil.errorLogInfo("", TAG, e1);
  12457. }
  12458. } else if (msg.what == 1) {
  12459. try {
  12460. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  12461. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  12462. LightOnCount = 0;
  12463. } catch (RuntimeException re) {
  12464. LogUtil.errorLogInfo("", TAG, re);
  12465. } catch (Exception e1) {
  12466. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  12467. //e1.printStackTrace();
  12468. LogUtil.errorLogInfo("", TAG, e1);
  12469. }
  12470. } else if (msg.what == 2) {
  12471. // Do Nothing
  12472. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  12473. WelcomeLightHandler.removeMessages(0);
  12474. }
  12475. }
  12476. };
  12477. //방범 및 알람 상태 확인 Resume 시 처리
  12478. private void CheckMainStatus() {
  12479. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  12480. try {
  12481. final String packageName = "com.artncore.apps.ic_wallpad";
  12482. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  12483. //CallAppRun = getForegroundAPK().equals(packageName);
  12484. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  12485. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12486. int alarmstate = SetData.GetAlarmStatus();
  12487. SetData.closeDB();
  12488. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
  12489. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  12490. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
  12491. return;
  12492. } else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  12493. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  12494. int base = 7000;
  12495. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
  12496. int Menu_Start_Id = 0;
  12497. SetData = new WallpadStatusData(getApplicationContext());
  12498. int alarmtype = SetData.GetAlarmType();
  12499. SetData.closeDB();
  12500. switch (alarmtype) {
  12501. case WallpadStatusData.ALARM_ALERT:
  12502. Menu_Start_Id = Menu_Id_List[1];
  12503. break;
  12504. case WallpadStatusData.ALARM_EMM:
  12505. Menu_Start_Id = Menu_Id_List[0];
  12506. break;
  12507. case WallpadStatusData.ALARM_EVAC:
  12508. Menu_Start_Id = Menu_Id_List[3];
  12509. break;
  12510. case WallpadStatusData.ALARM_INVADE:
  12511. Menu_Start_Id = Menu_Id_List[2];
  12512. break;
  12513. case WallpadStatusData.ALARM_HEATING_LEAK:
  12514. Menu_Start_Id = Menu_Id_List[4];
  12515. break;
  12516. default:
  12517. Menu_Start_Id = Menu_Id_List[1];
  12518. break;
  12519. }
  12520. if (Menu_Start_Id > 0) {
  12521. /*
  12522. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  12523. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  12524. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  12525. * "RESUME"을 전달한다.
  12526. */
  12527. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12528. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12529. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12530. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  12531. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  12532. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12533. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12534. startActivity(newintent);
  12535. return;
  12536. }
  12537. } else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  12538. if (OutModeRunAppRun == true) {
  12539. Log.d(TAG, "already outmoderun app running !!!!");
  12540. return;
  12541. }
  12542. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12543. int sensor = devset.Get_Sensor_Set();
  12544. devset.closeDB();
  12545. int base = 7000;
  12546. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12547. int Menu_Start_Id = 0;
  12548. int Menu_Start_Option = 1;
  12549. if (sensor > 0) {
  12550. WallPadInterface wpifc = new WallPadInterface();
  12551. int[] SensorInfoDB;
  12552. int inSen = 0;
  12553. int outSen = 0;
  12554. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12555. if (SensorInfoDB[0] == 1) {
  12556. // 내부동체가 사용함이면 상태 검사
  12557. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12558. }
  12559. if (SensorInfoDB[1] == 1) {
  12560. // 외부동체가 사용함이면 상태 검사
  12561. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12562. }
  12563. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12564. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12565. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
  12566. ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  12567. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12568. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12569. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12570. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12571. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12572. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
  12573. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12574. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12575. startActivity(newintent);
  12576. return;
  12577. }
  12578. }
  12579. base = 8000;
  12580. Menu_Id_List = new int[]{base + 11};
  12581. Menu_Start_Id = base + 11;
  12582. Menu_Start_Option = -1;
  12583. Intent intent = new Intent(Intent.ACTION_MAIN);
  12584. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12585. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12586. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12587. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  12588. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12589. startActivity(intent);
  12590. } else if (alarmstate == WallpadStatusData.GUARD_IN) {
  12591. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12592. int sensor = devset.Get_Sensor_Set();
  12593. devset.closeDB();
  12594. int base = 7000;
  12595. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12596. int Menu_Start_Option = 1;
  12597. if (sensor > 0) {
  12598. WallPadInterface wpifc = new WallPadInterface();
  12599. int[] SensorInfoDB;
  12600. int outSen = 0;
  12601. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12602. if (SensorInfoDB[1] == 1) {
  12603. // 외부동체가 사용함이면 상태 검사
  12604. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12605. }
  12606. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12607. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
  12608. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12609. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12610. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12611. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12612. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12613. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  12614. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12615. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12616. startActivity(newintent);
  12617. return;
  12618. }
  12619. }
  12620. } else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  12621. WallPadInterface wpifc = new WallPadInterface();
  12622. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  12623. return;
  12624. } else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  12625. int base = 4000;
  12626. int Menu_Start_Id = 0;
  12627. int[] Menu_Id_List = new int[]{base + 11, base + 21};
  12628. Menu_Start_Id = base + 11;
  12629. Intent intent = new Intent(Intent.ACTION_MAIN);
  12630. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12631. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12632. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  12633. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  12634. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12635. startActivity(intent);
  12636. return;
  12637. }
  12638. } catch (RuntimeException re) {
  12639. LogUtil.errorLogInfo("", TAG, re);
  12640. } catch (Exception e) {
  12641. Log.e(TAG, "[Exception] CheckMainStatus()");
  12642. //e.printStackTrace();
  12643. LogUtil.errorLogInfo("", TAG, e);
  12644. }
  12645. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12646. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  12647. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12648. // {
  12649. // WallPadInterface wpifc = new WallPadInterface();
  12650. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  12651. //
  12652. // if (fleeSensor > 0)
  12653. // {
  12654. // int base = 7000;
  12655. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12656. // int Menu_Start_Option = 1;
  12657. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12658. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12659. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  12660. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12661. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  12662. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12663. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12664. // startActivity(newintent);
  12665. // devset.closeDB();
  12666. // return;
  12667. // }
  12668. // }
  12669. //
  12670. // StatusVal = devset.GetDeviceSetted("알람발생");
  12671. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12672. // {
  12673. // WallPadInterface wpifc = new WallPadInterface();
  12674. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  12675. //
  12676. // if (AlarmSensor > 0)
  12677. // {
  12678. // int base = 7000;
  12679. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12680. // int Menu_Start_Option = 1;
  12681. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12682. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12683. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  12684. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12685. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  12686. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12687. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12688. // startActivity(newintent);
  12689. // devset.closeDB();
  12690. // return;
  12691. // }
  12692. //
  12693. // }
  12694. // devset.closeDB();
  12695. }
  12696. /**
  12697. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  12698. *
  12699. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  12700. */
  12701. public boolean GetUseIlgalControlForAdmin() {
  12702. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12703. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  12704. devSet.closeDB();
  12705. boolean result = false;
  12706. if (MetringDB != null) {
  12707. try {
  12708. String devInfo = MetringDB[1];
  12709. devInfo = devInfo.replace('(', '_');
  12710. devInfo = devInfo.replace(':', '_');
  12711. devInfo = devInfo.replace(')', '_');
  12712. String[] MetringInfo = devInfo.split("_");
  12713. if (MetringInfo[3].equals("사용함") == true) {
  12714. result = true;
  12715. }
  12716. } catch (RuntimeException re) {
  12717. LogUtil.errorLogInfo("", TAG, re);
  12718. } catch (Exception e) {
  12719. //e.printStackTrace();
  12720. LogUtil.errorLogInfo("", TAG, e);
  12721. }
  12722. }
  12723. return result;
  12724. }
  12725. class SendLHGWCheck extends Thread {
  12726. private iMAP_hn_config_read m_HnGWConfigRead = null;
  12727. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  12728. private boolean retSucces = false;
  12729. private int retryCount = 0;
  12730. public SendLHGWCheck() {
  12731. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  12732. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  12733. retryCount = 0;
  12734. }
  12735. public void run() {
  12736. try {
  12737. try {
  12738. Thread.sleep(2000);
  12739. } catch (RuntimeException re) {
  12740. LogUtil.errorLogInfo("", TAG, re);
  12741. } catch (Exception e) {
  12742. LogUtil.errorLogInfo("", TAG, e);
  12743. }
  12744. for (int i = 0; i < 10; i++) {
  12745. m_HnGWConfigRead.DoWork();
  12746. m_HnGWConfigRead.SetRetCtr(new RetProci() {
  12747. @Override
  12748. public void ProcSuccess() {
  12749. retSucces = true;
  12750. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
  12751. }
  12752. @Override
  12753. public void ProcError() {
  12754. }
  12755. @Override
  12756. public void ProcDoing() {
  12757. // TODO Auto-generated method stub
  12758. }
  12759. });
  12760. if (retSucces == true)
  12761. break;
  12762. retryCount++;
  12763. try {
  12764. Thread.sleep(3000);
  12765. } catch (RuntimeException re) {
  12766. LogUtil.errorLogInfo("", TAG, re);
  12767. } catch (Exception e) {
  12768. LogUtil.errorLogInfo("", TAG, e);
  12769. }
  12770. }
  12771. m_HnGWEmptyMsg.DoWork();
  12772. m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
  12773. @Override
  12774. public void ProcSuccess() {
  12775. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
  12776. }
  12777. @Override
  12778. public void ProcError() {
  12779. Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
  12780. }
  12781. @Override
  12782. public void ProcDoing() {
  12783. // TODO Auto-generated method stub
  12784. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
  12785. }
  12786. });
  12787. } catch (RuntimeException re) {
  12788. LogUtil.errorLogInfo("", TAG, re);
  12789. } catch (Exception e) {
  12790. //e.printStackTrace();
  12791. LogUtil.errorLogInfo("", TAG, e);
  12792. }
  12793. }
  12794. }
  12795. //Reset Handler
  12796. private Handler mResetHandler = new Handler() {
  12797. @Override
  12798. public void handleMessage(Message msg) {
  12799. if (msg.what == 0) {
  12800. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  12801. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  12802. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  12803. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  12804. if (NowMainStatus == false) {
  12805. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12806. ResetCount = 1;
  12807. }
  12808. ResetCount++;
  12809. NowMainStatus = true;
  12810. if (ResetCount == 30) {
  12811. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12812. } else {
  12813. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12814. }
  12815. } else {
  12816. if (NowMainStatus == true) {
  12817. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12818. ResetCount = 1;
  12819. }
  12820. ResetCount++;
  12821. NowMainStatus = false;
  12822. if (ResetCount == 180) {
  12823. // 3분
  12824. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12825. } else {
  12826. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12827. }
  12828. }
  12829. } else if (msg.what == 1) {
  12830. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  12831. setDefaultLauncher();
  12832. Intent intent = new Intent();
  12833. intent.setAction(define.NOTIFY_ACNAME);
  12834. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12835. getApplicationContext().sendBroadcast(intent);
  12836. }
  12837. }
  12838. };
  12839. // 통화주체를 다루는 enum
  12840. public enum CALLOWNER {
  12841. NONE,
  12842. WALLPAD,
  12843. SUB_WALLPAD,
  12844. KITCHEN_TV,
  12845. BATH_PHONE,
  12846. BATH_TV,
  12847. UNIVERSAL_DEVICE,
  12848. ERROR;
  12849. }
  12850. public enum CALLEVENTTYPE {
  12851. RECEIVE_CALL, // 호출 수신 (호출 수신)
  12852. TRYING_CALL, // 호출 시도중 (호출 발신)
  12853. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  12854. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  12855. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  12856. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  12857. CONNECT_CALL, // 통화 시작
  12858. TERMINATE_CALL, // 통화 종료
  12859. CANCEL_CALL, // 호출 취소
  12860. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  12861. REJECT_CALL, // 호출수신 거절
  12862. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  12863. FORWARD_CALL, // 착신전환 설정
  12864. CALLERID, // Caller ID
  12865. TIMEOUT_1STCALL, // 1st Call Timeout
  12866. TIMEOUT_2NDCALL, // 2nd Call Timeout
  12867. TIMEOUT_3RDCALL, // 3rd Call Timeout
  12868. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  12869. DOOR_OPEN, // 문열림 설정
  12870. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  12871. PSTN_DTMF, // PSTN DTMF 수신
  12872. DETECT_STRANGER, // 거동수상자 발생
  12873. NONE;
  12874. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  12875. try {
  12876. if (value.equals(RECEIVE_CALL.toString())) {
  12877. return RECEIVE_CALL;
  12878. } else if (value.equals(TRYING_CALL.toString())) {
  12879. return TRYING_CALL;
  12880. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  12881. return RECEIVE_CALL_2ND;
  12882. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  12883. return RECEIVE_CALL_ACK;
  12884. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  12885. return REQUEST_FRONT_MONITORING;
  12886. } else if (value.equals(CONNECT_CALL.toString())) {
  12887. return CONNECT_CALL;
  12888. } else if (value.equals(TERMINATE_CALL.toString())) {
  12889. return TERMINATE_CALL;
  12890. } else if (value.equals(CANCEL_CALL.toString())) {
  12891. return CANCEL_CALL;
  12892. } else if (value.equals(REJECT_CALL.toString())) {
  12893. return REJECT_CALL;
  12894. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  12895. return REJECT_BUSY_CALL;
  12896. } else if (value.equals(FORWARD_CALL.toString())) {
  12897. return FORWARD_CALL;
  12898. } else if (value.equals(CALLERID.toString())) {
  12899. return CALLERID;
  12900. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  12901. return TIMEOUT_1STCALL;
  12902. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  12903. return TIMEOUT_2NDCALL;
  12904. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  12905. return TIMEOUT_3RDCALL;
  12906. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  12907. return MOIP_VIDEO_SET;
  12908. } else if (value.equals(DOOR_OPEN.toString())) {
  12909. return DOOR_OPEN;
  12910. } else if (value.equals(PSTN_RING.toString())) {
  12911. return PSTN_RING;
  12912. } else if (value.equals(PSTN_DTMF.toString())) {
  12913. return PSTN_DTMF;
  12914. } else if (value.equals(DETECT_STRANGER.toString())) {
  12915. return DETECT_STRANGER;
  12916. } else if (value.equals(NONE.toString())) {
  12917. return NONE;
  12918. } else {
  12919. return null;
  12920. }
  12921. } catch (RuntimeException re) {
  12922. LogUtil.errorLogInfo("", "", re);
  12923. return null;
  12924. } catch (Exception e) {
  12925. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  12926. //e.printStackTrace();
  12927. LogUtil.errorLogInfo("", "", e);
  12928. return null;
  12929. }
  12930. }
  12931. }
  12932. public enum CALLTYPE {
  12933. NONE,
  12934. FRONT,
  12935. RESIDENCE,
  12936. LOBBY,
  12937. GUARD,
  12938. PSTN,
  12939. IHUB,
  12940. ERROR,
  12941. }
  12942. public static class CALLTRIGGER {
  12943. public static String CALLOWNER = "CALLOWNER";
  12944. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  12945. public static String CALLTYPE = "CALLTYPE";
  12946. public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
  12947. public enum SOURCE {
  12948. USER,
  12949. CALL_RECEIVE,
  12950. SUBPHONE
  12951. }
  12952. public enum TYPE {
  12953. MENU,
  12954. FRONT,
  12955. LOBBY,
  12956. GUARD,
  12957. RESIDENCE,
  12958. PSTN
  12959. }
  12960. }
  12961. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  12962. int TAB_TALKFRONT = 130011;
  12963. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  12964. try {
  12965. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
  12966. if (!bWallPadCallLive) {
  12967. sendLCDBacklightStatus(true);
  12968. // 통화어플을 실행시킨다.
  12969. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12970. Common.SendAppFinishReqBR(getApplicationContext());
  12971. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12972. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12973. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  12974. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12975. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12976. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12977. mIntent.setComponent(mComponentName);
  12978. startActivity(mIntent);
  12979. playFrontBell(eCallOwner, eEventType, eCallType);
  12980. } else {
  12981. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  12982. // if (getUseSmartDoorCam()) {
  12983. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  12984. // }
  12985. }
  12986. } catch (RuntimeException re) {
  12987. LogUtil.errorLogInfo("", TAG, re);
  12988. } catch (Exception e) {
  12989. Log.e(TAG, "[Exception] runCallMainActivity()");
  12990. //e.printStackTrace();
  12991. LogUtil.errorLogInfo("", TAG, e);
  12992. }
  12993. }
  12994. //add KSJ 2021.11.02
  12995. public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
  12996. try {
  12997. if (!bWallPadCallLive || m_bWallpadCallScreen) {
  12998. // 통화어플을 실행시킨다.
  12999. Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
  13000. sendLCDBacklightStatus(true);
  13001. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13002. int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
  13003. mWallpadStatusData.closeDB();
  13004. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  13005. Common.SendAppFinishReqBR(getApplicationContext());
  13006. if(m_bWallpadCallScreen)
  13007. Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  13008. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  13009. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  13010. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  13011. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  13012. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  13013. mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
  13014. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  13015. mIntent.setComponent(mComponentName);
  13016. startActivity(mIntent);
  13017. Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  13018. new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
  13019. @Override
  13020. public void run() {
  13021. Log.w(TAG, "[runCallMainActivity_moip] m_CallAppRunDelay " + m_CallAppRunDelay);
  13022. m_CallAppRunDelay = false;
  13023. }
  13024. }, 3000);
  13025. } else {
  13026. Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
  13027. m_CallAppRunDelay = false;
  13028. }
  13029. } catch (RuntimeException re) {
  13030. LogUtil.errorLogInfo("", TAG, re);
  13031. } catch (Exception e) {
  13032. Log.e(TAG, "[Exception] runCallMainActivity()");
  13033. //e.printStackTrace();
  13034. LogUtil.errorLogInfo("", TAG, e);
  13035. }
  13036. }
  13037. //~add KSJ
  13038. private String getTopActivity() {
  13039. try {
  13040. ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  13041. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  13042. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  13043. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  13044. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  13045. return mComponentName.getPackageName();
  13046. } catch (RuntimeException re) {
  13047. LogUtil.errorLogInfo("", TAG, re);
  13048. return null;
  13049. } catch (Exception e) {
  13050. Log.e(TAG, "[Exception] getTopActivity()");
  13051. //e.printStackTrace();
  13052. LogUtil.errorLogInfo("", TAG, e);
  13053. return null;
  13054. }
  13055. }
  13056. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  13057. try {
  13058. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  13059. WallPadInterface Wiface = new WallPadInterface();
  13060. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  13061. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  13062. }
  13063. } catch (RuntimeException re) {
  13064. LogUtil.errorLogInfo("", TAG, re);
  13065. } catch (Exception e) {
  13066. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  13067. //e.printStackTrace();
  13068. LogUtil.errorLogInfo("", TAG, e);
  13069. }
  13070. }
  13071. private class AfterTransactionTodoListData {
  13072. String Title;
  13073. int Valueint;
  13074. String ValueString;
  13075. private AfterTransactionTodoListData(String title, int valueint, String valueString) {
  13076. Title = title;
  13077. Valueint = valueint;
  13078. ValueString = valueString;
  13079. }
  13080. }
  13081. /**
  13082. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  13083. **/
  13084. public void SendGetParkingInfoIntent() {
  13085. Intent iIntent = new Intent();
  13086. iIntent.setAction(define.NOTIFY_ACNAME);
  13087. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  13088. this.sendBroadcast(iIntent);
  13089. }
  13090. /**
  13091. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  13092. **/
  13093. public Handler SendParkingInfoIntentAfter20min = new Handler() {
  13094. @SuppressLint("HandlerLeak")
  13095. @Override
  13096. public void handleMessage(Message msg) {
  13097. if (msg.what == 0) {
  13098. SendGetParkingInfoIntent();
  13099. }
  13100. }
  13101. };
  13102. /**
  13103. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  13104. **/
  13105. public Handler mWallPadOutmodeSleepHandler = new Handler() {
  13106. @SuppressLint("HandlerLeak")
  13107. @Override
  13108. public void handleMessage(Message msg) {
  13109. if (msg.what == 0) {
  13110. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  13111. }
  13112. }
  13113. };
  13114. // Handler
  13115. public final class HANDLERMSG {
  13116. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  13117. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  13118. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  13119. public final static int CALLAPP_FINISHING_END = 300;
  13120. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  13121. }
  13122. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  13123. public void handleMessage(Message msg) {
  13124. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  13125. switch (msg.what) {
  13126. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  13127. bGlobalScreenRun = true;
  13128. break;
  13129. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  13130. bGlobalScreenRun = false;
  13131. break;
  13132. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  13133. break;
  13134. case HANDLERMSG.CALLAPP_FINISHING_END:
  13135. // bBlockCallEvent = false;
  13136. break;
  13137. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  13138. int time = Sound().PlayMent(SND.call.DINGDONG);
  13139. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  13140. if (time < 0) time = 2088;
  13141. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  13142. break;
  13143. default:
  13144. Log.v(TAG, "iMAPServerHandler : " + msg.what);
  13145. break;
  13146. }
  13147. }
  13148. };
  13149. public void sendHandlerMsg(int what, int arg1, int arg2) {
  13150. try {
  13151. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  13152. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13153. HandleMsg.what = what;
  13154. HandleMsg.arg1 = arg1;
  13155. HandleMsg.arg2 = arg2;
  13156. iMAPServerHandler.sendMessage(HandleMsg);
  13157. } catch (RuntimeException re) {
  13158. LogUtil.errorLogInfo("", TAG, re);
  13159. } catch (Exception e) {
  13160. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  13161. //e.printStackTrace();
  13162. LogUtil.errorLogInfo("", TAG, e);
  13163. }
  13164. }
  13165. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  13166. try {
  13167. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  13168. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13169. HandleMsg.what = what;
  13170. HandleMsg.arg1 = arg1;
  13171. HandleMsg.arg2 = arg2;
  13172. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  13173. } catch (RuntimeException re) {
  13174. LogUtil.errorLogInfo("", TAG, re);
  13175. } catch (Exception e) {
  13176. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  13177. //e.printStackTrace();
  13178. LogUtil.errorLogInfo("", TAG, e);
  13179. }
  13180. }
  13181. int mSensitivity = 0, mDuration = 0;
  13182. int MIN_SENSOR_SENSITIVITY = 1;
  13183. int MAX_SENSOR_SENSITIVITY = 5;
  13184. int MIN_SENSOR_DURATION = 30;
  13185. int MAX_SENSOR_DURATION = 250;
  13186. int DEFAULT_SENSOR_SENSITIVITY = 3;
  13187. int DEFAULT_SENSOR_DURATION = 60;
  13188. private final int COMPONENT_USE = 1;
  13189. /**
  13190. * 스마트현관카메라 사용여부 판별
  13191. */
  13192. private boolean getUseSmartDoorCam() {
  13193. try {
  13194. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13195. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13196. mWallpadDeviceSet.closeDB();
  13197. if (nFrontCam[0] == COMPONENT_USE) {
  13198. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  13199. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  13200. return true;
  13201. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  13202. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  13203. return true;
  13204. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13205. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  13206. return true;
  13207. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  13208. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  13209. return true;
  13210. } else {
  13211. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  13212. return false;
  13213. }
  13214. } else {
  13215. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  13216. return false;
  13217. }
  13218. } catch (RuntimeException re) {
  13219. LogUtil.errorLogInfo("", TAG, re);
  13220. return false;
  13221. } catch (Exception e) {
  13222. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  13223. //e.printStackTrace();
  13224. LogUtil.errorLogInfo("", TAG, e);
  13225. return false;
  13226. }
  13227. }
  13228. private int getSmartDoorCamType() {
  13229. try {
  13230. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13231. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13232. mWallpadDeviceSet.closeDB();
  13233. if (nFrontCam[0] == COMPONENT_USE) {
  13234. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13235. return nFrontCam[1];
  13236. }
  13237. }
  13238. } catch (RuntimeException re) {
  13239. LogUtil.errorLogInfo("", TAG, re);
  13240. } catch (Exception e) {
  13241. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  13242. //e.printStackTrace();
  13243. LogUtil.errorLogInfo("", TAG, e);
  13244. }
  13245. return -1;
  13246. }
  13247. /**
  13248. * 방문객원격통화 솔루션 사용여부 판별
  13249. */
  13250. private boolean getRemoteCallUseInfo() {
  13251. try {
  13252. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13253. if (mWallpadDeviceSet != null) {
  13254. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  13255. if (astrRemoteCall != null) {
  13256. if (astrRemoteCall[1].contains("사용함")) return true;
  13257. } else {
  13258. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  13259. }
  13260. }
  13261. mWallpadDeviceSet.closeDB();
  13262. } catch (RuntimeException re) {
  13263. LogUtil.errorLogInfo("", TAG, re);
  13264. } catch (Exception e) {
  13265. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  13266. //e.printStackTrace();
  13267. LogUtil.errorLogInfo("", TAG, e);
  13268. }
  13269. return false;
  13270. }
  13271. /*
  13272. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  13273. */
  13274. private RealTimeMeterAPI mRealTimeMeterAPI;
  13275. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  13276. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  13277. public Thread saveRealmeterDataThread = null;
  13278. private void startRealtimemeterInfo() {
  13279. try {
  13280. // 영업샘플 모드 판단
  13281. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13282. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  13283. } else {
  13284. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  13285. // 실시간 검침기 사용유무 판단
  13286. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13287. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13288. mWallpadDeviceSet.closeDB();
  13289. boolean bRealtimemeterUsage = false;
  13290. int nRealtimemeterCntDB = -99;
  13291. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  13292. // 실시간 검침 사용함
  13293. bRealtimemeterUsage = true;
  13294. nRealtimemeterCntDB = naRealtimemtInfo[1];
  13295. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  13296. } else {
  13297. // 실시간 검침 사용하지 않음
  13298. bRealtimemeterUsage = false;
  13299. }
  13300. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
  13301. }
  13302. } catch (RuntimeException re) {
  13303. LogUtil.errorLogInfo("", TAG, re);
  13304. } catch (Exception e) {
  13305. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  13306. //e.printStackTrace();
  13307. LogUtil.errorLogInfo("", TAG, e);
  13308. }
  13309. }
  13310. private void startSmartIoTCamInfo() {
  13311. try {
  13312. // 영업샘플 모드 판단
  13313. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13314. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  13315. } else {
  13316. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  13317. if (getUseSmartDoorCam()) {
  13318. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  13319. } else {
  13320. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  13321. }
  13322. }
  13323. } catch (RuntimeException re) {
  13324. LogUtil.errorLogInfo("", TAG, re);
  13325. } catch (Exception e) {
  13326. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  13327. //e.printStackTrace();
  13328. LogUtil.errorLogInfo("", TAG, e);
  13329. }
  13330. }
  13331. private void startDistributionPanel() {
  13332. try {
  13333. // 영업샘플 모드 판단
  13334. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  13335. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  13336. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  13337. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  13338. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13339. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  13340. mWallpadDeviceSet.closeDB();
  13341. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
  13342. initSmartDistributionPanelHandler.sendEmptyMessage(0);
  13343. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
  13344. initKNXDistributionPanelHandler.sendEmptyMessage(0);
  13345. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  13346. } else {
  13347. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  13348. }
  13349. } catch (RuntimeException re) {
  13350. LogUtil.errorLogInfo("", TAG, re);
  13351. } catch (Exception e) {
  13352. Log.e(TAG, "[Exception] startDistributionPanel()");
  13353. //e.printStackTrace();
  13354. LogUtil.errorLogInfo("", TAG, e);
  13355. }
  13356. }
  13357. // =================================================================================================
  13358. // [[ Device ]] region
  13359. // =================================================================================================
  13360. /**
  13361. * 디바이스 API 를 Load 한다.
  13362. *
  13363. * @param wpapi - 생성시 전달받은 WallPadAPI
  13364. * @return (int) - >=0 : 성공, <0 : 실패
  13365. */
  13366. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  13367. // 1. Mode Check
  13368. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13369. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  13370. return -1;
  13371. }
  13372. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  13373. // 2. wpapi Check
  13374. if (wpapi == null) {
  13375. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  13376. return -2;
  13377. }
  13378. // 3. Load API
  13379. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  13380. try {
  13381. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  13382. } catch (RuntimeException re) {
  13383. LogUtil.errorLogInfo("", TAG, re);
  13384. return -100;
  13385. } catch (Exception e) {
  13386. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  13387. //e.printStackTrace();
  13388. LogUtil.errorLogInfo("", TAG, e);
  13389. return -100;
  13390. }
  13391. if (mRealTimeMeterAPI == null) {
  13392. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  13393. return -4;
  13394. }
  13395. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  13396. return 0;
  13397. }
  13398. /**
  13399. * 제어기 상태를 가져온다.
  13400. *
  13401. * @param real - (boolean) true : 실시간 , false : 가장최근
  13402. * @return (int) - >=0 : 성공, <0 : 실패
  13403. */
  13404. @SuppressWarnings("unused")
  13405. private int updateRealtimemeterData(boolean real) {
  13406. try {
  13407. // 1. Api Load Check
  13408. if (mRealTimeMeterAPI == null) {
  13409. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  13410. return -1;
  13411. }
  13412. // 2. reflash
  13413. try {
  13414. int ret = mRealTimeMeterAPI.Refresh(real);
  13415. if (ret < 0) {
  13416. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  13417. return -2;
  13418. }
  13419. } catch (RuntimeException re) {
  13420. LogUtil.errorLogInfo("", TAG, re);
  13421. return -100;
  13422. } catch (Exception e) {
  13423. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  13424. //e.printStackTrace();
  13425. LogUtil.errorLogInfo("", TAG, e);
  13426. return -100;
  13427. }
  13428. // 3. Range Check
  13429. if (mRealTimeMeterAPI.data == null) {
  13430. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  13431. return -9;
  13432. }
  13433. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  13434. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  13435. return -10;
  13436. }
  13437. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  13438. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  13439. return -11;
  13440. }
  13441. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  13442. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  13443. return -12;
  13444. }
  13445. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  13446. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  13447. return -13;
  13448. }
  13449. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  13450. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  13451. return -14;
  13452. }
  13453. // 4. Data Copy
  13454. mRealTimeMeterData = mRealTimeMeterAPI.data;
  13455. // 5. Debug msg
  13456. if (DEBUG_REALMETER_DATA_LOG_ON) {
  13457. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  13458. Log.i(TAG, "[updateRealtimemeterData] - OK");
  13459. }
  13460. return 0;
  13461. } catch (RuntimeException re) {
  13462. LogUtil.errorLogInfo("", TAG, re);
  13463. return -99;
  13464. } catch (Exception e) {
  13465. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  13466. //e.printStackTrace();
  13467. LogUtil.errorLogInfo("", TAG, e);
  13468. return -99;
  13469. }
  13470. }
  13471. /**
  13472. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  13473. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  13474. * 본 딜레이 코드를 임시로 적용한다.
  13475. */
  13476. @SuppressLint("HandlerLeak")
  13477. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  13478. @SuppressLint("HandlerLeak")
  13479. @Override
  13480. public void handleMessage(Message msg) {
  13481. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  13482. if (msg.what == 0) {
  13483. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  13484. if (updateRealtimemeterData(false) == 0) {
  13485. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13486. } else {
  13487. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13488. }
  13489. } else {
  13490. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  13491. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13492. }
  13493. } else if (msg.what == 1) {
  13494. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  13495. if (mRealTimeMeterAPI != null) {
  13496. // Device_BrRegistration(true);
  13497. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13498. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13499. mWallpadDeviceSet.closeDB();
  13500. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  13501. saveRealmeterDataThread = new saveRealmeterData();
  13502. saveRealmeterDataThread.start();
  13503. }
  13504. // RemoveUsedData();
  13505. // ShowUsedDataGraph();
  13506. }
  13507. }
  13508. }
  13509. };
  13510. protected Handler initSmartDistributionPanelHandler = new Handler() {
  13511. @SuppressLint("HandlerLeak")
  13512. @Override
  13513. public void handleMessage(Message msg) {
  13514. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  13515. if (msg.what == 0) {
  13516. if (mWallPadAPI.Check_Connect())
  13517. initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13518. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13519. } else if (msg.what == 1) {
  13520. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  13521. mSdbAPI = mWallPadAPI.Get_SdbController();
  13522. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  13523. mSdb_LivingRoomLightAPI.Refresh();
  13524. }
  13525. }
  13526. };
  13527. protected Handler initKNXDistributionPanelHandler = new Handler() {
  13528. @SuppressLint("HandlerLeak")
  13529. @Override
  13530. public void handleMessage(Message msg) {
  13531. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  13532. if (msg.what == 0) {
  13533. if (mWallPadAPI.Check_Connect())
  13534. initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13535. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13536. } else if (msg.what == 1) {
  13537. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  13538. mKnxAPI = mWallPadAPI.Get_KnxController();
  13539. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  13540. mKnx_LivingRoomLightAPI.Refresh();
  13541. }
  13542. }
  13543. };
  13544. protected Handler initSmartIoTFunctionHandler = new Handler() {
  13545. @SuppressLint("HandlerLeak")
  13546. @Override
  13547. public void handleMessage(Message msg) {
  13548. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  13549. if (msg.what == 0) {
  13550. if (mWallPadAPI.Check_Connect())
  13551. initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13552. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  13553. } else if (msg.what == 1) {
  13554. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  13555. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  13556. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
  13557. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
  13558. Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
  13559. // 거동수상자 녹화를 위한 자동 On 기능 비활성화
  13560. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  13561. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  13562. }
  13563. }
  13564. };
  13565. // 스마트현관카메라 MODE 제어
  13566. private void ctrlSmartIOTCamStatusMode(byte mode) {
  13567. try {
  13568. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  13569. if (mSmartKeyRfDoorAPI != null) {
  13570. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  13571. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  13572. } else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  13573. } catch (RuntimeException re) {
  13574. LogUtil.errorLogInfo("", TAG, re);
  13575. } catch (Exception e) {
  13576. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  13577. //e.printStackTrace();
  13578. LogUtil.errorLogInfo("", TAG, e);
  13579. }
  13580. }
  13581. // 스마트현관카메라 LED 상태 제어
  13582. private void ctrlSmartIOTCamLEDMode(byte mode) {
  13583. try {
  13584. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  13585. if (mSmartKeyRfDoorAPI != null) {
  13586. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  13587. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  13588. } else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  13589. } catch (RuntimeException re) {
  13590. LogUtil.errorLogInfo("", TAG, re);
  13591. } catch (Exception e) {
  13592. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  13593. //e.printStackTrace();
  13594. LogUtil.errorLogInfo("", TAG, e);
  13595. }
  13596. }
  13597. // 현관카메라 거동수상자 감지시간
  13598. private byte getSmartDoorCamDuration() {
  13599. try {
  13600. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
  13601. byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
  13602. wallpadDeviceSet.closeDB();
  13603. Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
  13604. return duration;
  13605. } catch (RuntimeException re) {
  13606. LogUtil.errorLogInfo("", TAG, re);
  13607. } catch (Exception e) {
  13608. Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
  13609. //e.printStackTrace();
  13610. LogUtil.errorLogInfo("", TAG, e);
  13611. }
  13612. return (byte) 0x05;
  13613. }
  13614. // =================================================================================================
  13615. // [[ Thread ]] region
  13616. // =================================================================================================
  13617. /**
  13618. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  13619. * 10분에 한번씩 저장
  13620. */
  13621. @SuppressLint("UseValueOf")
  13622. class saveRealmeterData extends Thread {
  13623. @Override
  13624. public void run() {
  13625. super.run();
  13626. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  13627. int ret;
  13628. wallpaddbmgr WallpadDBMGRforThread = null;
  13629. while (true) {
  13630. try {
  13631. Thread.sleep(1000 * 60 * 3); //3분마다
  13632. if (mRealTimeMeterAPI != null) {
  13633. ret = mRealTimeMeterAPI.Refresh(false);
  13634. if (ret == 0) {
  13635. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  13636. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
  13637. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  13638. WallpadDBMGRforThread.InsertRealTimeMeterData(
  13639. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  13640. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  13641. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  13642. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  13643. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  13644. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  13645. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  13646. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  13647. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  13648. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  13649. );
  13650. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  13651. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
  13652. if (tempInt > 6000) {
  13653. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  13654. }
  13655. WallpadDBMGRforThread.closeDB();
  13656. } else {
  13657. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  13658. }
  13659. } else {
  13660. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  13661. }
  13662. } catch (InterruptedException e1) {
  13663. // TODO Auto-generated catch block
  13664. if (WallpadDBMGRforThread != null) {
  13665. WallpadDBMGRforThread.closeDB();
  13666. }
  13667. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  13668. //e1.printStackTrace();
  13669. LogUtil.errorLogInfo("", TAG, e1);
  13670. }
  13671. }
  13672. }
  13673. }
  13674. /**
  13675. * 단지서버 2.0 사용여부
  13676. *
  13677. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  13678. **/
  13679. public boolean NewServerUse() {
  13680. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  13681. if (SetData != null) {
  13682. String serverVesionInfo = SetData.GetServerVer();
  13683. SetData.closeDB();
  13684. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  13685. return true;
  13686. }
  13687. }
  13688. return false;
  13689. }
  13690. /**
  13691. * 단지서버2.0 적용시에만 사용한다.
  13692. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  13693. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  13694. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  13695. **/
  13696. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  13697. String REMOTETYPE_SVR2WEB = "danji_web_control";
  13698. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  13699. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  13700. try {
  13701. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13702. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13703. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13704. NodeList mNodeList = doc.getElementsByTagName("device_info");
  13705. Node mNode = mNodeList.item(0);
  13706. if (mNode != null) {
  13707. String alias = "null", twinid = "null";
  13708. NamedNodeMap attrsParam = mNode.getAttributes();
  13709. for (int j = 0; j < attrsParam.getLength(); j++) {
  13710. Node attr = attrsParam.item(j);
  13711. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13712. alias = attr.getNodeValue();
  13713. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13714. twinid = attr.getNodeValue();
  13715. }
  13716. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13717. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13718. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  13719. return MOBILE_USER_AUTH_PASSED;
  13720. }
  13721. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13722. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13723. mWallpadMobileDeviceData.closeDB();
  13724. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13725. else {
  13726. //Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  13727. //닫은 DB에 접근하여서 수정.
  13728. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + nCheckResult + "]");
  13729. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13730. return strReplyMsg;
  13731. }
  13732. } else {
  13733. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13734. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13735. return strReplyMsg;
  13736. }
  13737. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13738. NodeList mNodeList = doc.getElementsByTagName("password_info");
  13739. Node mNode = mNodeList.item(0);
  13740. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13741. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13742. mWallpadStatusData.closeDB();
  13743. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
  13744. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13745. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13746. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13747. return strReplyMsg;
  13748. }
  13749. if (mNode != null) {
  13750. String strReceivedPW = "000000";
  13751. NamedNodeMap attrsParam = mNode.getAttributes();
  13752. for (int j = 0; j < attrsParam.getLength(); j++) {
  13753. Node attr = attrsParam.item(j);
  13754. if (attr.getNodeName().equalsIgnoreCase("password"))
  13755. strReceivedPW = attr.getNodeValue();
  13756. }
  13757. if (!checkPWValidation(strReceivedPW)) {
  13758. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13759. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13760. return strReplyMsg;
  13761. }
  13762. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13763. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13764. return WEB_USER_AUTH_PASSED;
  13765. } else {
  13766. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13767. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13768. return strReplyMsg;
  13769. }
  13770. } else {
  13771. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13772. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13773. return strReplyMsg;
  13774. }
  13775. } else {
  13776. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13777. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13778. return strReplyMsg;
  13779. }
  13780. } catch (RuntimeException re) {
  13781. LogUtil.errorLogInfo("", TAG, re);
  13782. return null;
  13783. } catch (Exception e) {
  13784. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  13785. //e.printStackTrace();
  13786. LogUtil.errorLogInfo("", TAG, e);
  13787. return null;
  13788. }
  13789. }
  13790. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  13791. try {
  13792. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13793. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13794. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13795. NodeList mNodeList = ele.getElementsByTagName("device_info");
  13796. Node mNode = mNodeList.item(0);
  13797. if (mNode != null) {
  13798. String alias = "null", twinid = "null";
  13799. NamedNodeMap attrsParam = mNode.getAttributes();
  13800. for (int j = 0; j < attrsParam.getLength(); j++) {
  13801. Node attr = attrsParam.item(j);
  13802. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13803. alias = attr.getNodeValue();
  13804. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13805. twinid = attr.getNodeValue();
  13806. }
  13807. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13808. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13809. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  13810. return MOBILE_USER_AUTH_PASSED;
  13811. }
  13812. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13813. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13814. mWallpadMobileDeviceData.closeDB();
  13815. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13816. else {
  13817. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  13818. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  13819. return strReplyMsg;
  13820. }
  13821. } else {
  13822. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13823. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13824. return strReplyMsg;
  13825. }
  13826. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13827. NodeList mNodeList = ele.getElementsByTagName("password_info");
  13828. Node mNode = mNodeList.item(0);
  13829. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13830. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13831. mWallpadStatusData.closeDB();
  13832. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13833. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13834. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13835. return strReplyMsg;
  13836. }
  13837. if (mNode != null) {
  13838. String strReceivedPW = "000000";
  13839. NamedNodeMap attrsParam = mNode.getAttributes();
  13840. for (int j = 0; j < attrsParam.getLength(); j++) {
  13841. Node attr = attrsParam.item(j);
  13842. if (attr.getNodeName().equalsIgnoreCase("password"))
  13843. strReceivedPW = attr.getNodeValue();
  13844. }
  13845. if (!checkPWValidation(strReceivedPW)) {
  13846. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13847. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13848. return strReplyMsg;
  13849. }
  13850. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13851. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13852. return WEB_USER_AUTH_PASSED;
  13853. } else {
  13854. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13855. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13856. return strReplyMsg;
  13857. }
  13858. } else {
  13859. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13860. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13861. return strReplyMsg;
  13862. }
  13863. } else {
  13864. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13865. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13866. return strReplyMsg;
  13867. }
  13868. } catch (RuntimeException re) {
  13869. LogUtil.errorLogInfo("", TAG, re);
  13870. return null;
  13871. } catch (Exception e) {
  13872. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  13873. //e.printStackTrace();
  13874. LogUtil.errorLogInfo("", TAG, e);
  13875. return null;
  13876. }
  13877. }
  13878. String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
  13879. private boolean checkPWValidation(String strPW) {
  13880. try {
  13881. // null 확인
  13882. if (strPW == null) {
  13883. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  13884. return false;
  13885. }
  13886. // 입력된 비밀번호 길이 확인
  13887. if (strPW.length() != 6) {
  13888. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  13889. return false;
  13890. }
  13891. // 사전 금지된 비밀번호 확인
  13892. for (int i = 0; i < astrPreventedPWs.length; i++) {
  13893. if (strPW.contains(astrPreventedPWs[i])) {
  13894. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  13895. return false;
  13896. }
  13897. }
  13898. /*// 연속된 비밀번호 확인
  13899. int nSerialNoCnt = 0;
  13900. int nCompareNo = 0;
  13901. int[] naPW = new int[strPW.length()];
  13902. for (int i = 0; i < naPW.length; i++)
  13903. {
  13904. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  13905. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  13906. if (i ==0) {
  13907. nCompareNo = naPW[i];
  13908. nCompareNo++;
  13909. }
  13910. else if (0 < i && i < 6) {
  13911. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  13912. nCompareNo++;
  13913. }
  13914. else {
  13915. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  13916. }
  13917. }
  13918. if (nSerialNoCnt > 3) {
  13919. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  13920. return false;
  13921. }*/
  13922. // 동일한 번호 5회이상 입력 확인
  13923. int nSameNoCnt = 0;
  13924. for (int i = 0; i < strPW.length() - 1; i++) {
  13925. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  13926. nSameNoCnt++;
  13927. }
  13928. }
  13929. if (nSameNoCnt > 4) {
  13930. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  13931. return false;
  13932. }
  13933. // 동, 호정보 확인
  13934. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  13935. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  13936. DBMGR.closeDB();
  13937. String strDong = addr.Dong;
  13938. String strHo = addr.Ho;
  13939. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  13940. if (strPW.substring(0, 4).contains(strDong)) {
  13941. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  13942. return false;
  13943. }
  13944. if (strPW.substring(0, 4).contains(strHo)) {
  13945. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  13946. return false;
  13947. }
  13948. return true;
  13949. } catch (RuntimeException re) {
  13950. LogUtil.errorLogInfo("", TAG, re);
  13951. return false;
  13952. } catch (Exception e) {
  13953. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  13954. //e.printStackTrace();
  13955. LogUtil.errorLogInfo("", TAG, e);
  13956. return false;
  13957. }
  13958. }
  13959. public String iCMDProcOnePass(Element ele) {
  13960. String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
  13961. String[] strDeviceInfo = {"null", "null"}; // alias, twinid
  13962. String strAction = "null", strTargetLobbyIP = "null";
  13963. try {
  13964. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  13965. String retStr = CheckiCMDProc("remote_access_onepass");
  13966. if (retStr != null)
  13967. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13968. // 단지서버 2.0 사용여부 확인
  13969. if (!NewServerUse()) {
  13970. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13971. }
  13972. // 메시지 송신지 구분
  13973. NodeList items = ele.getElementsByTagName("target");
  13974. Node item = items.item(0);
  13975. if (item != null) {
  13976. NamedNodeMap attrs = item.getAttributes();
  13977. for (int j = 0; j < attrs.getLength(); j++) {
  13978. Node attr = attrs.item(j);
  13979. if (attr.getNodeName().equalsIgnoreCase("name"))
  13980. strTarget[0] = attr.getNodeValue();
  13981. else if (attr.getNodeName().equalsIgnoreCase("id"))
  13982. strTarget[1] = attr.getNodeValue();
  13983. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  13984. strTarget[2] = attr.getNodeValue();
  13985. }
  13986. }
  13987. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  13988. if (NewServerUse()) {
  13989. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  13990. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  13991. if (ServerCheckResult.contains("fail"))
  13992. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13993. else if (ServerCheckResult.contains("deny"))
  13994. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13995. else if (ServerCheckResult.contains("none"))
  13996. return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  13997. else
  13998. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13999. }
  14000. }
  14001. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  14002. Node itemDeviceParam = itemsDeviceParam.item(0);
  14003. if (itemDeviceParam != null) {
  14004. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  14005. for (int j = 0; j < attrsParam.getLength(); j++) {
  14006. Node attr = attrsParam.item(j);
  14007. if (attr.getNodeName().equalsIgnoreCase("alias"))
  14008. strDeviceInfo[0] = attr.getNodeValue();
  14009. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  14010. strDeviceInfo[1] = attr.getNodeValue();
  14011. }
  14012. } else {
  14013. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14014. }
  14015. // 명령어 구분
  14016. NodeList itemsaction = ele.getElementsByTagName("action");
  14017. Node itemaction = itemsaction.item(0);
  14018. Node text = itemaction.getFirstChild();
  14019. strAction = text.getNodeValue();
  14020. strAction = trimquotation(strAction);
  14021. // 문열림 타겟 로비폰 IP
  14022. NodeList itemsParam = ele.getElementsByTagName("params");
  14023. Node itemParam = itemsParam.item(0);
  14024. if (itemParam != null) {
  14025. NamedNodeMap attrsParam = itemParam.getAttributes();
  14026. for (int j = 0; j < attrsParam.getLength(); j++) {
  14027. Node attr = attrsParam.item(j);
  14028. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  14029. strTargetLobbyIP = attr.getNodeValue();
  14030. }
  14031. }
  14032. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  14033. if (strAction.equalsIgnoreCase("authorize_request")) {
  14034. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  14035. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  14036. } else {
  14037. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14038. }
  14039. } catch (RuntimeException re) {
  14040. LogUtil.errorLogInfo("", TAG, re);
  14041. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14042. } catch (Exception e) {
  14043. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  14044. //e.printStackTrace();
  14045. LogUtil.errorLogInfo("", TAG, e);
  14046. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14047. }
  14048. }
  14049. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  14050. try {
  14051. String strReplyXml = XMLHeader;
  14052. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  14053. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  14054. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  14055. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  14056. strReplyXml += " </service>\n";
  14057. strReplyXml += "</imap>";
  14058. return strReplyXml;
  14059. } catch (RuntimeException re) {
  14060. LogUtil.errorLogInfo("", TAG, re);
  14061. return "ERROR";
  14062. } catch (Exception e) {
  14063. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  14064. //e.printStackTrace();
  14065. LogUtil.errorLogInfo("", TAG, e);
  14066. return "ERROR";
  14067. }
  14068. }
  14069. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  14070. try {
  14071. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
  14072. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  14073. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  14074. miMAPLobbyOnePass.SetRetCtr(new RetProci() {
  14075. @Override
  14076. public void ProcSuccess() {
  14077. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  14078. }
  14079. @Override
  14080. public void ProcError() {
  14081. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  14082. }
  14083. @Override
  14084. public void ProcDoing() {
  14085. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  14086. }
  14087. });
  14088. } catch (RuntimeException re) {
  14089. LogUtil.errorLogInfo("", TAG, re);
  14090. } catch (Exception e) {
  14091. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  14092. //e.printStackTrace();
  14093. LogUtil.errorLogInfo("", TAG, e);
  14094. }
  14095. }
  14096. public String iCMDProcResidentSafety(Element ele) {
  14097. try {
  14098. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  14099. String retStr = CheckiCMDProc("check_resident_safety");
  14100. if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
  14101. // 단지서버 2.0 사용여부 확인
  14102. if (!NewServerUse()) {
  14103. return makeReply_check_resident_safety("deny", null, null, null);
  14104. }
  14105. // 거주자 안전 확인 사용 여부
  14106. if (!bEnableResidentSafetyCheck) {
  14107. return makeReply_check_resident_safety("deny", null, null, null);
  14108. }
  14109. String strSecurity = getSecurityMode();
  14110. String strTouch = getTimeStamp_ScreenTouched();
  14111. String strMagnetic = getTimeStamp_Magnetic();
  14112. return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
  14113. } catch (RuntimeException re) {
  14114. LogUtil.errorLogInfo("", TAG, re);
  14115. return makeReply_check_resident_safety("fail", null, null, null);
  14116. } catch (Exception e) {
  14117. Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
  14118. //e.printStackTrace();
  14119. LogUtil.errorLogInfo("", TAG, e);
  14120. return makeReply_check_resident_safety("fail", null, null, null);
  14121. }
  14122. }
  14123. public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
  14124. try {
  14125. String strReplyXml = XMLHeader;
  14126. strReplyXml += " <service type=\"reply\" name=\"check_resident_safety\" result=\"" + strResult + "\">\n";
  14127. if (strResult.equalsIgnoreCase("ok")) {
  14128. strReplyXml += " <security>\"" + strSecurity + "\"</security>\n";
  14129. strReplyXml += " <touch>\"" + strTouch + "\"</touch>\n";
  14130. strReplyXml += " <magnetic>\"" + magnetic + "\"</magnetic>\n";
  14131. }
  14132. strReplyXml += " <message>\"null\"</message>\n";
  14133. strReplyXml += " </service>\n";
  14134. strReplyXml += "</imap>";
  14135. return strReplyXml;
  14136. } catch (RuntimeException re) {
  14137. LogUtil.errorLogInfo("", TAG, re);
  14138. return "ERROR";
  14139. } catch (Exception e) {
  14140. Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
  14141. //e.printStackTrace();
  14142. LogUtil.errorLogInfo("", TAG, e);
  14143. return "ERROR";
  14144. }
  14145. }
  14146. private void saveBlackoutStatus(boolean bOccurred) {
  14147. try {
  14148. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  14149. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14150. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14151. mEditor.putBoolean("status", bOccurred);
  14152. mEditor.commit();
  14153. } catch (RuntimeException re) {
  14154. LogUtil.errorLogInfo("", TAG, re);
  14155. } catch (Exception e) {
  14156. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  14157. //e.printStackTrace();
  14158. LogUtil.errorLogInfo("", TAG, e);
  14159. }
  14160. }
  14161. private boolean getBlackoutStatus() {
  14162. try {
  14163. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14164. return mSharedPreferences.getBoolean("status", false);
  14165. } catch (RuntimeException re) {
  14166. LogUtil.errorLogInfo("", TAG, re);
  14167. return false;
  14168. } catch (Exception e) {
  14169. Log.e(TAG, "[Exception] getBlackoutStatus()");
  14170. //e.printStackTrace();
  14171. LogUtil.errorLogInfo("", TAG, e);
  14172. return false;
  14173. }
  14174. }
  14175. /**
  14176. * JEFF, 2019.12.25
  14177. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  14178. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  14179. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  14180. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  14181. */
  14182. int MAX_WALLPADCALL_LIVE_CNT = 2;
  14183. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  14184. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  14185. public static boolean bWallPadCallLive_old = false;
  14186. public static boolean m_bWallpadCallScreen = false;
  14187. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  14188. Handler handlerCheckWallPadCallLive = new Handler() {
  14189. public void handleMessage(Message msg) {
  14190. super.handleMessage(msg);
  14191. sendWallPadCallLiveBR_Request();
  14192. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  14193. }
  14194. };
  14195. private void sendWallPadCallLiveBR_Request() {
  14196. try {
  14197. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  14198. Intent mIntent = new Intent();
  14199. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  14200. getApplicationContext().sendBroadcast(mIntent);
  14201. if (nWallPadCallACKCnt >= 0) {
  14202. nWallPadCallACKCnt--;
  14203. } else {
  14204. bWallPadCallLive = false;
  14205. Common.bWallPadCallLive = bWallPadCallLive;
  14206. }
  14207. if (bWallPadCallLive != bWallPadCallLive_old) {
  14208. if (bWallPadCallLive != getCallAppRunning()) {
  14209. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14210. setCallAppRunning(bWallPadCallLive);
  14211. }
  14212. }
  14213. bWallPadCallLive_old = bWallPadCallLive;
  14214. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14215. } catch (RuntimeException re) {
  14216. LogUtil.errorLogInfo("", TAG, re);
  14217. } catch (Exception e) {
  14218. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  14219. //e.printStackTrace();
  14220. LogUtil.errorLogInfo("", TAG, e);
  14221. }
  14222. }
  14223. public boolean getWallpadCallScrean(int iScreen)
  14224. {
  14225. boolean bRet = false;
  14226. try {
  14227. switch (iScreen) {
  14228. case API_Menu.SubMenuCall.Door:
  14229. bRet = false;
  14230. break;
  14231. case API_Menu.SubMenuCall.Lobby:
  14232. bRet = false;
  14233. break;
  14234. case API_Menu.SubMenuCall.Guard:
  14235. bRet = false;
  14236. break;
  14237. case API_Menu.SubMenuCall.Neighbor:
  14238. bRet = false;
  14239. break;
  14240. case API_Menu.SubMenuCall.PSTN:
  14241. bRet = false;
  14242. break;
  14243. case API_Menu.SubMenuCall.CallList:
  14244. bRet = true;
  14245. break;
  14246. case API_Menu.SubMenuCall.Visitor:
  14247. bRet = true;
  14248. break;
  14249. default:
  14250. bRet = false;
  14251. break;
  14252. }
  14253. } catch (RuntimeException re) {
  14254. LogUtil.errorLogInfo("", TAG, re);
  14255. return false;
  14256. } catch (Exception e) {
  14257. Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
  14258. //e.printStackTrace();
  14259. LogUtil.errorLogInfo("", TAG, e);
  14260. return false;
  14261. }
  14262. return bRet;
  14263. }
  14264. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  14265. @Override
  14266. public void onReceive(Context context, Intent intent) {
  14267. try {
  14268. String strActionName = intent.getAction();
  14269. int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
  14270. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  14271. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  14272. bWallPadCallLive = true;
  14273. Common.bWallPadCallLive = bWallPadCallLive;
  14274. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  14275. m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
  14276. Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
  14277. } else {
  14278. Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  14279. }
  14280. } catch (RuntimeException re) {
  14281. LogUtil.errorLogInfo("", TAG, re);
  14282. } catch (Exception e) {
  14283. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  14284. //e.printStackTrace();
  14285. LogUtil.errorLogInfo("", TAG, e);
  14286. }
  14287. }
  14288. };
  14289. static class CALLCTRLHANDLERMSG {
  14290. static final int RELEASE_BLOCK_FRONTCALL = 100;
  14291. }
  14292. boolean bBlockFrontCall = false;
  14293. Handler handlerCallCtrl = new Handler() {
  14294. public void handleMessage(Message msg) {
  14295. super.handleMessage(msg);
  14296. int nMSG = msg.what;
  14297. switch (nMSG) {
  14298. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  14299. bBlockFrontCall = false;
  14300. break;
  14301. }
  14302. }
  14303. };
  14304. /**
  14305. * JEFF, 2019.12.31
  14306. * WallPadCall 실행여부를 DB에 저장한다.
  14307. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  14308. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  14309. */
  14310. public void setCallAppRunning(boolean bRunning) {
  14311. try {
  14312. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14313. mWallpadStatusData.SetCallAPKStatus(bRunning);
  14314. mWallpadStatusData.closeDB();
  14315. } catch (RuntimeException re) {
  14316. LogUtil.errorLogInfo("", TAG, re);
  14317. } catch (Exception e) {
  14318. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  14319. //e.printStackTrace();
  14320. LogUtil.errorLogInfo("", TAG, e);
  14321. }
  14322. }
  14323. private boolean getCallAppRunning() {
  14324. boolean bRunning = false;
  14325. try {
  14326. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14327. bRunning = wallpadStatusData.GetCallAPKStatusRunning();
  14328. wallpadStatusData.closeDB();
  14329. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  14330. return bRunning;
  14331. } catch (RuntimeException re) {
  14332. LogUtil.errorLogInfo("", TAG, re);
  14333. return false;
  14334. } catch (Exception e) {
  14335. Log.d(TAG, "[Exception] getCallAppRunning()");
  14336. //e.printStackTrace();
  14337. LogUtil.errorLogInfo("", TAG, e);
  14338. return false;
  14339. }
  14340. }
  14341. /**
  14342. * 통화앱 종료코드
  14343. */
  14344. public void killWallPadCall() {
  14345. try {
  14346. Log.i(TAG, "[killWallPadCall] ===== START =====");
  14347. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  14348. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14349. Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  14350. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  14351. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14352. // android.os.Process.killProcess(nWallPadCallPID);
  14353. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  14354. // if(list != null){
  14355. // for(int i=0;i<list.size();++i){
  14356. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  14357. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14358. // android.os.Process.killProcess(pid);
  14359. // }
  14360. // }
  14361. // }
  14362. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  14363. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14364. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  14365. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14366. // android.os.Process.killProcess(pid);
  14367. } catch (RuntimeException re) {
  14368. LogUtil.errorLogInfo("", TAG, re);
  14369. } catch (Exception e) {
  14370. Log.e(TAG, "[Exception] killWallPadCall()");
  14371. //e.printStackTrace();
  14372. LogUtil.errorLogInfo("", TAG, e);
  14373. }
  14374. }
  14375. private void checkForegroundActivity() {
  14376. try {
  14377. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  14378. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  14379. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  14380. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  14381. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  14382. } catch (RuntimeException re) {
  14383. LogUtil.errorLogInfo("", TAG, re);
  14384. } catch (Exception e) {
  14385. Log.e(TAG, "[Exception] checkForegroundActivity()");
  14386. //e.printStackTrace();
  14387. LogUtil.errorLogInfo("", TAG, e);
  14388. }
  14389. }
  14390. /**
  14391. * JEFF, 2020.01.04
  14392. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  14393. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  14394. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  14395. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  14396. */
  14397. static long lConnectionPeriod = 0;
  14398. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  14399. boolean bRingGeneratorRun = false;
  14400. private void startIGW300RingGenerator() {
  14401. try {
  14402. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14403. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  14404. bRingGeneratorRun = true;
  14405. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  14406. mIGW300RingGeneratorThread.start();
  14407. } else
  14408. Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  14409. } catch (RuntimeException re) {
  14410. LogUtil.errorLogInfo("", TAG, re);
  14411. } catch (Exception e) {
  14412. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  14413. //e.printStackTrace();
  14414. LogUtil.errorLogInfo("", TAG, e);
  14415. }
  14416. }
  14417. private void stopIGW300RingGenerator() {
  14418. try {
  14419. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14420. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  14421. lConnectionPeriod = -999;
  14422. bRingGeneratorRun = false;
  14423. mIGW300RingGeneratorThread = null;
  14424. } else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  14425. } catch (RuntimeException re) {
  14426. LogUtil.errorLogInfo("", TAG, re);
  14427. } catch (Exception e) {
  14428. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  14429. //e.printStackTrace();
  14430. LogUtil.errorLogInfo("", TAG, e);
  14431. }
  14432. }
  14433. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  14434. private class IGW300RingGeneratorThread extends Thread {
  14435. public IGW300RingGeneratorThread() {
  14436. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  14437. }
  14438. public void run() {
  14439. try {
  14440. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14441. if (bRingGeneratorRun)
  14442. Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  14443. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  14444. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  14445. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  14446. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  14447. try {
  14448. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  14449. } catch (InterruptedException e) {
  14450. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  14451. //e.printStackTrace();
  14452. LogUtil.errorLogInfo("", TAG, e);
  14453. }
  14454. }
  14455. bRingGeneratorRun = false;
  14456. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  14457. } catch (RuntimeException re) {
  14458. LogUtil.errorLogInfo("", TAG, re);
  14459. } catch (Exception e) {
  14460. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  14461. //e.printStackTrace();
  14462. LogUtil.errorLogInfo("", TAG, e);
  14463. }
  14464. }
  14465. }
  14466. private void sendPSTNRingEvent(int nKeyCode) {
  14467. try {
  14468. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  14469. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  14470. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  14471. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  14472. intent.putExtra("keycode", nKeyCode);
  14473. getApplicationContext().sendBroadcast(intent);
  14474. } catch (RuntimeException re) {
  14475. LogUtil.errorLogInfo("", TAG, re);
  14476. } catch (Exception e) {
  14477. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  14478. //e.printStackTrace();
  14479. LogUtil.errorLogInfo("", TAG, e);
  14480. }
  14481. }
  14482. /**
  14483. * 월패드 타입 판별
  14484. *
  14485. * @return bResult
  14486. * false: 메인월패드
  14487. * true: 서브월패드
  14488. */
  14489. public boolean getIsSubWallpad() {
  14490. boolean bResult = false;
  14491. try {
  14492. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14493. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  14494. mWallpadDeviceSet.closeDB();
  14495. if (DBinfo != null) {
  14496. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  14497. else bResult = false;
  14498. }
  14499. } catch (RuntimeException re) {
  14500. LogUtil.errorLogInfo("", TAG, re);
  14501. } catch (Exception e) {
  14502. Log.e(TAG, "[Exception] getIsSubWallpad()");
  14503. //e.printStackTrace();
  14504. LogUtil.errorLogInfo("", TAG, e);
  14505. }
  14506. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  14507. return bResult;
  14508. }
  14509. /**
  14510. * JEFF, 2020.02.05
  14511. * 월패드 비상접점 신호 사용 여부 확인
  14512. */
  14513. public boolean getEmergencyIOUsage() {
  14514. boolean bResult = false;
  14515. try {
  14516. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14517. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  14518. mWallpadDeviceSet.closeDB();
  14519. } catch (RuntimeException re) {
  14520. LogUtil.errorLogInfo("", TAG, re);
  14521. } catch (Exception e) {
  14522. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  14523. //e.printStackTrace();
  14524. LogUtil.errorLogInfo("", TAG, e);
  14525. }
  14526. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  14527. return bResult;
  14528. }
  14529. /**
  14530. * JEFF, 2020.02.05
  14531. * 거동수상자 녹화기능 활성화 확인
  14532. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  14533. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  14534. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  14535. */
  14536. public boolean getStrangerRecordingManagerSetting() {
  14537. boolean bResult = false;
  14538. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14539. try {
  14540. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14541. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  14542. mWallpadDeviceSet.closeDB();
  14543. if (nFrontCam[0] == COMPONENT_USE) {
  14544. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  14545. if (bRecord) bResult = true;
  14546. else bResult = false;
  14547. } else bResult = false;
  14548. } else bResult = false;
  14549. } catch (RuntimeException re) {
  14550. LogUtil.errorLogInfo("", TAG, re);
  14551. mWallpadDeviceSet.closeDB();
  14552. } catch (Exception e) {
  14553. mWallpadDeviceSet.closeDB();
  14554. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  14555. //e.printStackTrace();
  14556. LogUtil.errorLogInfo("", TAG, e);
  14557. }
  14558. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  14559. return bResult;
  14560. }
  14561. /**
  14562. * Edited by jeff (2020.06.22)
  14563. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  14564. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  14565. *
  14566. * @param bOn
  14567. */
  14568. private void sendLCDBacklightStatus(boolean bOn) {
  14569. try {
  14570. Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
  14571. Intent mIntent = new Intent();
  14572. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  14573. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  14574. getApplicationContext().sendBroadcast(mIntent);
  14575. } catch (RuntimeException re) {
  14576. LogUtil.errorLogInfo("", TAG, re);
  14577. } catch (Exception e) {
  14578. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  14579. //e.printStackTrace();
  14580. LogUtil.errorLogInfo("", TAG, e);
  14581. }
  14582. }
  14583. // 명칭 관련
  14584. boolean bRoomNameLog = true;
  14585. public static final int HEATING = 1;
  14586. public static final int LIGHT = 2;
  14587. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  14588. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14589. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  14590. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
  14591. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14592. /**
  14593. * DB 에서 룸이름 정보를 가져온다.
  14594. *
  14595. * @return (String []) null - 실패, not null
  14596. */
  14597. private String[] getDBRoomName() {
  14598. try {
  14599. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14600. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  14601. wallpadStatusData.closeDB();
  14602. if (strRoomNameList == null) {
  14603. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  14604. return null;
  14605. }
  14606. if (bRoomNameLog) {
  14607. for (int i = 0; i < strRoomNameList.length; i++)
  14608. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14609. }
  14610. return strRoomNameList;
  14611. } catch (RuntimeException re) {
  14612. LogUtil.errorLogInfo("", TAG, re);
  14613. } catch (Exception e) {
  14614. Log.e(TAG, "[Exception] getDBRoomName()");
  14615. //e.printStackTrace();
  14616. LogUtil.errorLogInfo("", TAG, e);
  14617. }
  14618. return null;
  14619. }
  14620. /**
  14621. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  14622. *
  14623. * @param nDeviceType - int
  14624. * @return (String []) null - 실패, not null
  14625. */
  14626. private String[] getDBRoomName(int nDeviceType) {
  14627. try {
  14628. String[] strRoomNameList = null;
  14629. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14630. if (nDeviceType == HEATING) {
  14631. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  14632. } else {
  14633. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  14634. }
  14635. wallpadStatusData.closeDB();
  14636. if (strRoomNameList == null) {
  14637. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  14638. return null;
  14639. }
  14640. if (bRoomNameLog) {
  14641. for (int i = 0; i < strRoomNameList.length; i++)
  14642. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14643. }
  14644. return strRoomNameList;
  14645. } catch (RuntimeException re) {
  14646. LogUtil.errorLogInfo("", TAG, re);
  14647. } catch (Exception e) {
  14648. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  14649. //e.printStackTrace();
  14650. LogUtil.errorLogInfo("", TAG, e);
  14651. }
  14652. return null;
  14653. }
  14654. /**
  14655. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  14656. **/
  14657. private void getRoomName() {
  14658. try {
  14659. Log.i(TAG, "[getRoomName] ====================");
  14660. } catch (RuntimeException re) {
  14661. LogUtil.errorLogInfo("", TAG, re);
  14662. } catch (Exception e) {
  14663. Log.e(TAG, "[Exception] getRoomName()");
  14664. //e.printStackTrace();
  14665. LogUtil.errorLogInfo("", TAG, e);
  14666. }
  14667. }
  14668. public boolean getEasyModeUXUsage() {
  14669. try {
  14670. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  14671. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  14672. deviceSet.closeDB();
  14673. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  14674. boolean bUse = data.GetEasyModeUxUse();
  14675. data.closeDB();
  14676. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  14677. return bSupport & bUse;
  14678. } catch (RuntimeException re) {
  14679. LogUtil.errorLogInfo("", TAG, re);
  14680. } catch (Exception e) {
  14681. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  14682. //e.printStackTrace();
  14683. LogUtil.errorLogInfo("", TAG, e);
  14684. }
  14685. return false;
  14686. }
  14687. /**
  14688. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  14689. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  14690. * 재설정 5초 후 월패드 재부팅을 실행한다.
  14691. * 2020.11.18 SEULKI
  14692. */
  14693. public void checkDoorCamConfig() {
  14694. try {
  14695. if (Build.VERSION.SDK_INT > 23) {
  14696. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  14697. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  14698. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  14699. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  14700. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  14701. if (!checkAvailableBSPDoorCamConfig()) {
  14702. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  14703. return;
  14704. }
  14705. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  14706. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  14707. if (mIOInterface != null)
  14708. mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  14709. // 재부팅
  14710. setDefaultLauncher();
  14711. Intent intent = new Intent();
  14712. if (intent != null) {
  14713. intent.setAction(define.NOTIFY_ACNAME);
  14714. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  14715. getApplicationContext().sendBroadcast(intent);
  14716. }
  14717. }
  14718. }
  14719. }
  14720. } catch (RuntimeException re) {
  14721. LogUtil.errorLogInfo("", "", re);
  14722. } catch (Exception e) {
  14723. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  14724. LogUtil.errorLogInfo("", "", e);
  14725. }
  14726. }
  14727. /**
  14728. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  14729. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  14730. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  14731. *
  14732. * @return true: 지원, false: 미지원
  14733. */
  14734. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  14735. private boolean checkAvailableBSPDoorCamConfig() {
  14736. try {
  14737. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  14738. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  14739. if (nCurrentVer >= nCriterionVer) {
  14740. return true;
  14741. } else return false;
  14742. } catch (RuntimeException re) {
  14743. LogUtil.errorLogInfo("", TAG, re);
  14744. return false;
  14745. } catch (Exception e) {
  14746. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  14747. //e.printStackTrace();
  14748. LogUtil.errorLogInfo("", TAG, e);
  14749. return false;
  14750. }
  14751. }
  14752. /**
  14753. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14754. *
  14755. * @return 0 - 스마트현관카메라
  14756. * 2 - 스마트현관카메라 좌우반전
  14757. * 1 - 일반현관카메라
  14758. * 2020.11.18 SEULKI
  14759. */
  14760. public int getBSPDoorCamConfig() {
  14761. InputStreamReader is = null;
  14762. try {
  14763. Runtime mRuntime = Runtime.getRuntime();
  14764. String cmd = "getprop camera.setting.value";
  14765. if (mRuntime != null) {
  14766. Process mProcess = mRuntime.exec(cmd);
  14767. is = new InputStreamReader(mProcess.getInputStream());
  14768. BufferedReader br = new BufferedReader(is);
  14769. String line;
  14770. String strResult = null;
  14771. if (br != null) {
  14772. while ((line = br.readLine()) != null) {
  14773. strResult = line;
  14774. }
  14775. if (strResult != null) {
  14776. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  14777. if (strResult.equals("0")) {
  14778. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  14779. return 0;
  14780. } else if (strResult.equals("1")) {
  14781. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  14782. return 1;
  14783. } else if (strResult.equals("2")) {
  14784. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  14785. return 2;
  14786. } else {
  14787. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  14788. return -1;
  14789. }
  14790. }
  14791. }
  14792. }
  14793. return -1;
  14794. } catch (Exception e) {
  14795. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  14796. e.printStackTrace();
  14797. return -1;
  14798. } finally {
  14799. if (is != null) {
  14800. try {
  14801. is.close();
  14802. } catch (IOException e) {
  14803. LogUtil.errorLogInfo("", TAG, e);
  14804. }
  14805. is = null;
  14806. }
  14807. }
  14808. }
  14809. /**
  14810. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14811. *
  14812. * @return 0 - 스마트현관카메라
  14813. * 2 - 스마트현관카메라 좌우반전
  14814. * 1 - 일반현관카메라
  14815. * 2020.11.18 SEULKI
  14816. */
  14817. public int getDBDoorCamConfig() {
  14818. try {
  14819. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14820. if (mWallpadDeviceSet != null) {
  14821. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14822. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  14823. mWallpadDeviceSet.closeDB();
  14824. if (nType != null) {
  14825. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  14826. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
  14827. // Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14828. if (bFlip) {
  14829. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14830. return 0;
  14831. } else {
  14832. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
  14833. return 2;
  14834. }
  14835. } else {
  14836. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  14837. return 1;
  14838. }
  14839. }
  14840. }
  14841. return -1;
  14842. } catch (Exception e) {
  14843. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  14844. e.printStackTrace();
  14845. return -1;
  14846. }
  14847. }
  14848. /**
  14849. * 공기질 센서 사용여부 확인
  14850. *
  14851. * @return true - 사용함, false: 사용안함
  14852. */
  14853. boolean bAirQualityEnable = false;
  14854. private boolean getAirQualityUsage() {
  14855. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14856. try {
  14857. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  14858. mWallpadDeviceSet.closeDB();
  14859. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  14860. bAirQualityEnable = true;
  14861. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14862. } else {
  14863. bAirQualityEnable = false;
  14864. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14865. }
  14866. return bAirQualityEnable;
  14867. } catch (RuntimeException re) {
  14868. LogUtil.errorLogInfo("", TAG, re);
  14869. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14870. return false;
  14871. } catch (Exception e) {
  14872. Log.e(TAG, "[Exception] getAirQualityUsage()");
  14873. //e.printStackTrace();
  14874. LogUtil.errorLogInfo("", TAG, e);
  14875. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14876. return false;
  14877. }
  14878. }
  14879. String strAirQualityFWVer = "";
  14880. String strAirQualityProtocolVer = "";
  14881. String strAirQualityInfo = "";
  14882. private String getAirQualityInfo() {
  14883. try {
  14884. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  14885. if (mAirQualitySensorAPI != null) {
  14886. int nRet = mAirQualitySensorAPI.Refresh(false);
  14887. if (nRet >= 0) {
  14888. Log.i(TAG, "[getAirQualityInfo] ");
  14889. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  14890. strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  14891. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  14892. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  14893. return strAirQualityInfo;
  14894. } else return "FAIL";
  14895. } else return "NULL";
  14896. } catch (RuntimeException re) {
  14897. LogUtil.errorLogInfo("", TAG, re);
  14898. return "ERROR";
  14899. } catch (Exception e) {
  14900. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14901. //e.printStackTrace();
  14902. LogUtil.errorLogInfo("", TAG, e);
  14903. return "ERROR";
  14904. }
  14905. }
  14906. private String getAOSVerCode() {
  14907. try {
  14908. int nOSVer = Build.VERSION.SDK_INT;
  14909. switch (nOSVer) {
  14910. case Build.VERSION_CODES.BASE:
  14911. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  14912. case Build.VERSION_CODES.BASE_1_1:
  14913. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  14914. case Build.VERSION_CODES.CUPCAKE:
  14915. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  14916. case Build.VERSION_CODES.DONUT:
  14917. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  14918. case Build.VERSION_CODES.ECLAIR:
  14919. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  14920. case Build.VERSION_CODES.ECLAIR_0_1:
  14921. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  14922. case Build.VERSION_CODES.ECLAIR_MR1:
  14923. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  14924. case Build.VERSION_CODES.FROYO:
  14925. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  14926. case Build.VERSION_CODES.GINGERBREAD:
  14927. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  14928. case Build.VERSION_CODES.GINGERBREAD_MR1:
  14929. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  14930. case Build.VERSION_CODES.HONEYCOMB:
  14931. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  14932. case Build.VERSION_CODES.HONEYCOMB_MR1:
  14933. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  14934. case Build.VERSION_CODES.HONEYCOMB_MR2:
  14935. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  14936. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  14937. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  14938. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  14939. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  14940. case Build.VERSION_CODES.JELLY_BEAN:
  14941. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  14942. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  14943. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  14944. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  14945. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  14946. case Build.VERSION_CODES.KITKAT:
  14947. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  14948. case Build.VERSION_CODES.KITKAT_WATCH:
  14949. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  14950. case Build.VERSION_CODES.LOLLIPOP:
  14951. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  14952. case Build.VERSION_CODES.LOLLIPOP_MR1:
  14953. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  14954. case Build.VERSION_CODES.M:
  14955. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  14956. case Build.VERSION_CODES.N:
  14957. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  14958. case Build.VERSION_CODES.N_MR1:
  14959. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  14960. case Build.VERSION_CODES.O:
  14961. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  14962. case Build.VERSION_CODES.O_MR1:
  14963. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  14964. case Build.VERSION_CODES.P:
  14965. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  14966. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  14967. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  14968. default:
  14969. return "SDK(" + nOSVer + ")/UNKNOWN";
  14970. }
  14971. } catch (RuntimeException re) {
  14972. LogUtil.errorLogInfo("", TAG, re);
  14973. return "ERROR";
  14974. } catch (Exception e) {
  14975. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14976. //e.printStackTrace();
  14977. LogUtil.errorLogInfo("", TAG, e);
  14978. return "ERROR";
  14979. }
  14980. }
  14981. /**
  14982. * 조명 ON/OFF 상태
  14983. */
  14984. public static class LIGHT_ONOFF {
  14985. /**
  14986. * ON
  14987. */
  14988. public static byte ON = (byte) 0x01;
  14989. /**
  14990. * OFF
  14991. */
  14992. public static byte OFF = (byte) 0x02;
  14993. /**
  14994. * OFF
  14995. */
  14996. public static byte DONTCARE = (byte) 0xFF;
  14997. }
  14998. private byte convertSmartLightPowerValue(String cmd) {
  14999. try {
  15000. if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
  15001. else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
  15002. else return LIGHT_ONOFF.DONTCARE;
  15003. } catch (RuntimeException re) {
  15004. LogUtil.errorLogInfo("", TAG, re);
  15005. return -1;
  15006. } catch (Exception e) {
  15007. Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
  15008. //e.printStackTrace();
  15009. LogUtil.errorLogInfo("", TAG, e);
  15010. return -1;
  15011. }
  15012. }
  15013. /** 거주자 안정 확인 서비스용 코드 시작 */
  15014. /**
  15015. * Edited by Jeff, 2021.06.15
  15016. */
  15017. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  15018. public boolean bEnableResidentSafetyCheck = false;
  15019. private void getResidentSafetyCheckSetting() {
  15020. try {
  15021. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  15022. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  15023. mWallpadDeviceSet.closeDB();
  15024. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  15025. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
  15026. bEnableResidentSafetyCheck = true;
  15027. else bEnableResidentSafetyCheck = false;
  15028. } catch (RuntimeException re) {
  15029. LogUtil.errorLogInfo("", TAG, re);
  15030. } catch (Exception e) {
  15031. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  15032. //e.printStackTrace();
  15033. LogUtil.errorLogInfo("", TAG, e);
  15034. }
  15035. }
  15036. private String getSecurityMode() {
  15037. try {
  15038. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  15039. int nStatus = mWallpadStatusData.GetAlarmStatus();
  15040. mWallpadStatusData.closeDB();
  15041. String strSecurity = "null";
  15042. if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
  15043. else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
  15044. else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
  15045. else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
  15046. else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
  15047. else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
  15048. return strSecurity;
  15049. } catch (Exception e) {
  15050. Log.e(TAG, "[Exception] getSecurityMode()");
  15051. //e.printStackTrace();
  15052. LogUtil.errorLogInfo("", TAG, e);
  15053. return null;
  15054. }
  15055. }
  15056. String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
  15057. String Touch = "Touch";
  15058. String Magnetic = "Magnetic";
  15059. private void setTimeStamp_ScreenTouched() {
  15060. try {
  15061. Calendar mCal = Calendar.getInstance();
  15062. String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  15063. // Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
  15064. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15065. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  15066. mEditor.putString(Touch, strTouchTime);
  15067. mEditor.apply();
  15068. } catch (Exception e) {
  15069. Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
  15070. //e.printStackTrace();
  15071. LogUtil.errorLogInfo("", TAG, e);
  15072. }
  15073. }
  15074. private String getTimeStamp_ScreenTouched() {
  15075. try {
  15076. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15077. String strTouchTime = mSharedPreferences.getString(Touch, null);
  15078. // Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
  15079. return strTouchTime;
  15080. } catch (Exception e) {
  15081. Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
  15082. //e.printStackTrace();
  15083. LogUtil.errorLogInfo("", TAG, e);
  15084. return null;
  15085. }
  15086. }
  15087. private void setTimeStamp_Magnetic() {
  15088. try {
  15089. Calendar mCal = Calendar.getInstance();
  15090. String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  15091. // Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
  15092. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15093. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  15094. mEditor.putString(Magnetic, strMagneticTime);
  15095. mEditor.apply();
  15096. } catch (Exception e) {
  15097. Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
  15098. //e.printStackTrace();
  15099. LogUtil.errorLogInfo("", TAG, e);
  15100. }
  15101. }
  15102. private String getTimeStamp_Magnetic() {
  15103. try {
  15104. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15105. String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
  15106. // Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
  15107. return strMagneticTime;
  15108. } catch (Exception e) {
  15109. Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
  15110. //e.printStackTrace();
  15111. LogUtil.errorLogInfo("", TAG, e);
  15112. return null;
  15113. }
  15114. }
  15115. /** 거주자 안정 확인 서비스용 코드 종료 */
  15116. /**
  15117. * 가스밸브를 쿡탑콘센트로 사용
  15118. */
  15119. private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
  15120. /** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
  15121. /** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
  15122. /**
  15123. * false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
  15124. */
  15125. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  15126. private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
  15127. /**
  15128. * 기기 연동 제어 옵션 설정 확인
  15129. */
  15130. // 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
  15131. // 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
  15132. private void getDeviceCtrlOption() {
  15133. int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
  15134. boolean bUserSetting_SmartLightEnable = false;
  15135. int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
  15136. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  15137. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  15138. try {
  15139. bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
  15140. nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
  15141. nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
  15142. mWallpadDeviceSet.closeDB();
  15143. bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
  15144. mWallpadStatusData.closeDB();
  15145. if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  15146. // 스마트 분전반을 사용하는 경우에만
  15147. // 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
  15148. if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
  15149. // 사용자선택인 경우
  15150. if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
  15151. else bLightCMDUseAsSmartLight = true;
  15152. } else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
  15153. // 스마트조명을 사용하는 경우
  15154. bLightCMDUseAsSmartLight = false;
  15155. } else {
  15156. // 스마트조명을 사용하지 않는 경우
  15157. bLightCMDUseAsSmartLight = true;
  15158. }
  15159. } else {
  15160. // 스마트분전반을 사용하지 않는 경우
  15161. bLightCMDUseAsSmartLight = true;
  15162. }
  15163. Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
  15164. } catch (Exception e) {
  15165. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  15166. if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
  15167. Log.e(TAG, "[Exception] getDeviceCtrlOption()");
  15168. //e.printStackTrace();
  15169. LogUtil.errorLogInfo("", TAG, e);
  15170. }
  15171. }
  15172. private String[] getRoomNameFromDBV2(String strDeviceType) {
  15173. try {
  15174. String[] RoomNameList = null;
  15175. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  15176. RoomNameList = wallpadStatusData.GetDevRoomNameList(strDeviceType);
  15177. wallpadStatusData.closeDB();
  15178. if (RoomNameList == null) {
  15179. Log.e(TAG, "[getRoomNameFromDBV2] - RoomNameList is null !!!");
  15180. return null;
  15181. }
  15182. Log.i(TAG, "[getRoomNameFromDBV2] RoomNameList " + Arrays.toString(RoomNameList));
  15183. return RoomNameList;
  15184. } catch (RuntimeException re) {
  15185. LogUtil.errorLogInfo("", TAG, re);
  15186. } catch (Exception e) {
  15187. Log.e(TAG, "[Exception] getRoomNameFromDBV2(int Device)");
  15188. //e.printStackTrace();
  15189. LogUtil.errorLogInfo("", TAG, e);
  15190. }
  15191. return null;
  15192. }
  15193. // private void demoPushMsg()
  15194. // {
  15195. // String urlStr1 = "";
  15196. //
  15197. // if(android.os.Build.VERSION.SDK_INT > 9 )
  15198. // {
  15199. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  15200. // StrictMode.setThreadPolicy(policy);
  15201. // }
  15202. //
  15203. // String Msg ="";
  15204. // try {
  15205. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  15206. // } catch (UnsupportedEncodingException e1) {
  15207. // // TODO Auto-generated catch block
  15208. // e1.printStackTrace();
  15209. // }
  15210. //
  15211. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  15212. // Log.d(TAG , "################ : " + urlStr1);
  15213. // try
  15214. // {
  15215. // //URLEncoder.encode(s)
  15216. // HttpClient client = new DefaultHttpClient();
  15217. //
  15218. // HttpGet get = new HttpGet();
  15219. // //get.setURI(new URI("http://www.google.com/"));
  15220. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  15221. // HttpResponse resp = client.execute(get);
  15222. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  15223. // String str = null;
  15224. // StringBuilder sb = new StringBuilder();
  15225. // while((str = br.readLine()) != null)
  15226. // {
  15227. // sb.append(str).append("\n");
  15228. // }
  15229. // br.close();
  15230. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  15231. // //txt.setText(sb.toString());
  15232. // }catch(Exception e)
  15233. // {
  15234. //
  15235. // e.printStackTrace();
  15236. //
  15237. // }
  15238. //
  15239. //
  15240. // }
  15241. //
  15242. //
  15243. // public static boolean checkForExternal(String str) {
  15244. // int length = str.length();
  15245. // for (int i = 0; i < length; i++) {
  15246. // if (str.charAt(i) > 0x7F) {
  15247. // return true;
  15248. // }
  15249. // }
  15250. // return false;
  15251. // }
  15252. //
  15253. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  15254. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  15255. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  15256. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  15257. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  15258. //
  15259. // public static String encodeUrl(String url) {
  15260. // if (checkForExternal(url)) {
  15261. // try {
  15262. // String value = URLEncoder.encode(url, "UTF-8");
  15263. // value = COLON.matcher(value).replaceAll(":");
  15264. // value = SLASH.matcher(value).replaceAll("/");
  15265. // value = QUEST_MARK.matcher(value).replaceAll("?");
  15266. // value = EQUAL.matcher(value).replaceAll("=");
  15267. // return AMP.matcher(value).replaceAll("&");
  15268. // } catch (UnsupportedEncodingException e) {
  15269. // //throw LOGGER.getIllegalStateException(e);
  15270. // return null;
  15271. // }
  15272. // } else {
  15273. // return url;
  15274. // }
  15275. // }
  15276. }