iMapServer.java 886 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050
  1. package kr.co.icontrols.wallpadmain.util;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningTaskInfo;
  5. import android.app.Service;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.media.AudioManager;
  15. import android.os.Build;
  16. import android.os.Bundle;
  17. import android.os.CountDownTimer;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Looper;
  21. import android.os.Message;
  22. import android.os.Messenger;
  23. import android.os.PowerManager;
  24. import android.os.RemoteException;
  25. import android.provider.Settings;
  26. import android.util.Log;
  27. import android.view.KeyEvent;
  28. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  29. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  30. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  31. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  32. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  33. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  34. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  35. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  36. import com.artncore.WallPadDataMgr.WallpadStatusData;
  37. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  38. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  39. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  40. import com.artncore.WallPadKNXSystem.WallPadKNX;
  41. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  42. import com.artncore.commons.APIErrorCode;
  43. import com.artncore.commons.API_Menu;
  44. import com.artncore.commons.DataClasses;
  45. import com.artncore.commons.DataClasses.HeatingV1;
  46. import com.artncore.commons.DataClasses.HeatingV2;
  47. import com.artncore.commons.DataClasses.MultiSwitch;
  48. import com.artncore.commons.KNX_DataClasses;
  49. import com.artncore.commons.define;
  50. import com.artncore.deviceinterface.WallPadInterface;
  51. import com.artncore.wallpadapi.AirQualitySensorAPI;
  52. import com.artncore.wallpadapi.CooktopAPI;
  53. import com.artncore.wallpadapi.DLockAPI;
  54. import com.artncore.wallpadapi.EnergyMeterAPI;
  55. import com.artncore.wallpadapi.GasAPI;
  56. import com.artncore.wallpadapi.HeatingV1API;
  57. import com.artncore.wallpadapi.HeatingV2API;
  58. import com.artncore.wallpadapi.IGW200dAPI;
  59. import com.artncore.wallpadapi.IGW300API;
  60. import com.artncore.wallpadapi.IntLightAPI;
  61. import com.artncore.wallpadapi.KnxAPI;
  62. import com.artncore.wallpadapi.KnxSystemAirconAPI;
  63. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  64. import com.artncore.wallpadapi.LightAPI;
  65. import com.artncore.wallpadapi.MultiSwitchAPI;
  66. import com.artncore.wallpadapi.PhonNRemocon;
  67. import com.artncore.wallpadapi.RealTimeMeterAPI;
  68. import com.artncore.wallpadapi.SdbAPI;
  69. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  70. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  71. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  72. import com.artncore.wallpadapi.VentiAPI;
  73. import com.artncore.wallpadapi.WallPadAPI;
  74. import com.artncore.wallpadimap.RetProci;
  75. import com.artncore.wallpadimap.WallPadFTPUploader;
  76. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  77. import com.artncore.wallpadimap.WallpadiCMDParser;
  78. import com.util.LogUtil;
  79. import org.apache.commons.net.ftp.FTP;
  80. import org.w3c.dom.Document;
  81. import org.w3c.dom.Element;
  82. import org.w3c.dom.NamedNodeMap;
  83. import org.w3c.dom.Node;
  84. import org.w3c.dom.NodeList;
  85. import java.io.BufferedReader;
  86. import java.io.ByteArrayInputStream;
  87. import java.io.DataOutputStream;
  88. import java.io.File;
  89. import java.io.FilenameFilter;
  90. import java.io.IOException;
  91. import java.io.InputStream;
  92. import java.io.InputStreamReader;
  93. import java.net.ServerSocket;
  94. import java.net.Socket;
  95. import java.text.SimpleDateFormat;
  96. import java.util.ArrayList;
  97. import java.util.Arrays;
  98. import java.util.Calendar;
  99. import java.util.Date;
  100. import java.util.GregorianCalendar;
  101. import java.util.LinkedList;
  102. import java.util.List;
  103. import java.util.Queue;
  104. import javax.net.ssl.SSLServerSocket;
  105. import javax.xml.parsers.DocumentBuilder;
  106. import javax.xml.parsers.DocumentBuilderFactory;
  107. import kr.co.icontrols.gledeviceinterface.jni;
  108. import kr.co.icontrols.hdcftp.HDCFTPManager;
  109. import kr.co.icontrols.sslapi.SSLClient;
  110. import kr.co.icontrols.sslapi.SSLServer;
  111. import kr.co.icontrols.wallpadmain.IOInterface;
  112. import kr.co.icontrols.wallpadmain.MainActivity;
  113. import kr.co.icontrols.wallpadmain.R;
  114. import kr.co.icontrols.wallpadmain.declare.Common;
  115. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  116. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  117. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  118. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  119. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  120. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  121. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  122. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  123. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  124. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  125. import kr.co.icontrols.wallpadsupport.Version;
  126. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  127. import kr.co.icontrols.wallpadsupport.WpadSound;
  128. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  129. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  130. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  131. public class iMapServer extends Service {
  132. private String TAG = "iMapServer";
  133. static final int EVENTTIMELIMITE = 2000;
  134. iMapSverSocket SvrSock;
  135. int port = 10000;
  136. String StrAddr = "";
  137. String IPaddr;
  138. String AddrDong;
  139. String AddrHo;
  140. int ho;
  141. boolean log_sw = true;
  142. String SVRIP = "";
  143. static WallPadAPI mWallPadAPI;
  144. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  145. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  146. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  147. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  148. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  149. private IGW200 mIGW200;
  150. private IGW300 mIGW300;
  151. PhonNRemocon PnRCtr;
  152. boolean CallConnected = false;
  153. long ALERTTIME = 0;
  154. long CALLTIME = 0;
  155. long OPENDOORTIME = 0;
  156. long currentTime = 0;
  157. long DoorDelayTime = 0;
  158. static Handler ScheDulerHandler;
  159. static final boolean iMAPDOORCTR = true;
  160. private jni mGleInterface = null;
  161. IOInterface mIOInterface = null;
  162. private boolean ResetFlag = false;
  163. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  164. private int ResetCount = 0;
  165. private boolean NowMainStatus = false;
  166. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  167. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  168. public iMapServer() {
  169. Log.i(TAG, "[iMapServer] ========== START ==========");
  170. }
  171. public static final int SENSOR_MAG = 0x01;
  172. public static final int SENSOR_IN = 0x02;
  173. public static final int SENSOR_OUT = 0x04;
  174. static int PORT_NUM_iMAP = 10000;
  175. static int SOCKET_WAIT_TIME = 40;
  176. static long lSocketConnectionPeriod = 0;
  177. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  178. static int SOCKET_BUFFER_SIZE_READ = 50;
  179. public static final String ITEM_MENU_TYPE = "call_menu";
  180. static final int DOOR_DELAY_TIME = 3000;
  181. static final String MULTISW_CTR = "remote_access_electric";
  182. String XMLHeader;
  183. SchedulerThread ScheServer;
  184. int OutGoingSensorWaiting = 0;
  185. private int ModelType = Version.getModelType();
  186. private WpadSound mSound;
  187. private WpadSound Sound() {
  188. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  189. return mSound;
  190. }
  191. /**
  192. * 신형 단지서버 사용 유무
  193. */
  194. private boolean mNewDanjiServer = false;
  195. /**
  196. * 방범 앱 재실행 여부
  197. */
  198. private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
  199. /**
  200. * JEFF, 2019.12.31
  201. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  202. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  203. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  204. * 통화앱 종료 BR을 삭제하면 안됨
  205. */
  206. // 통화어플이 종료중인 경우에는 호출 무시
  207. // private boolean bBlockCallEvent = false;
  208. ////////////////////////////////////////////////////////////////////////////////
  209. // 엘리베이터관련
  210. ////////////////////////////////////////////////////////////////////////////////
  211. /**
  212. * 엘리베이터 호출관련 class
  213. * <p>
  214. * shkang
  215. */
  216. private class ElevatorClass {
  217. /**
  218. * 엘리베이터 호출 타임아웃 (단위:초)
  219. */
  220. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
  221. /**
  222. * 상향/하향 플레그 true:상향UP, false:하향DN
  223. */
  224. private boolean mUpDn = false;
  225. /**
  226. * 엘리베이터 호출중
  227. */
  228. private boolean mCallElevator = false;
  229. /**
  230. * 엘리베이터 호출 API
  231. */
  232. private WallPadiMAPNotifyAPI mElevatorAPI;
  233. /**
  234. * 엘리베이터 호출 타이머
  235. */
  236. private CountDownTimer mElevatorTimer;
  237. /**
  238. * 엘리베이터 호출중 상태 가져오기
  239. */
  240. public boolean getElevatorCalling() {
  241. return mCallElevator;
  242. }
  243. /**
  244. * 엘리베이터 호출 상태 클리어
  245. */
  246. public void ClearElevator() {
  247. mCallElevator = false;
  248. }
  249. /**
  250. * 생성자
  251. *
  252. * @param Up - (boolean) true:상향, false:하향
  253. */
  254. private ElevatorClass(boolean Up) {
  255. try {
  256. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
  257. // 1. Input Param
  258. mUpDn = Up;
  259. mCallElevator = false;
  260. // 2. Create API
  261. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  262. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  263. @Override
  264. public void ProcDoing() {
  265. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  266. }
  267. @Override
  268. public void ProcError() {
  269. Log.i(TAG, "[ElevatorClass] ProcError()");
  270. mCallElevator = false;
  271. // 엘리베이터 호출 에러 알림
  272. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  273. }
  274. @Override
  275. public void ProcSuccess() {
  276. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  277. mCallElevator = true;
  278. // 엘리베이터 호출 성공 알림
  279. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  280. // "엘리베이터를 호출하였습니다" 멘트출력
  281. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  282. Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
  283. if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
  284. Sound().PlayMent(WpadSound.SND.elevator.CALL);
  285. bOutModeRestart = false;
  286. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  287. // 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
  288. // 타임아웃 시작
  289. TimeOutStart();
  290. }
  291. });
  292. // 3. Create Timer
  293. mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  294. @Override
  295. public void onFinish() {
  296. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  297. mCallElevator = false;
  298. // 호출 타임아웃 알림
  299. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  300. }
  301. @Override
  302. public void onTick(long arg0) {
  303. int RemainingTime = (int) (arg0 / 1000);
  304. if (RemainingTime <= 10) {
  305. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  306. }
  307. }
  308. };
  309. } catch (RuntimeException re) {
  310. LogUtil.errorLogInfo("", TAG, re);
  311. } catch (Exception e) {
  312. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  313. //e.printStackTrace();
  314. LogUtil.errorLogInfo("", TAG, e);
  315. }
  316. }
  317. /**
  318. * 엘리베이터 호출을 한다.
  319. */
  320. public void CallElevator() {
  321. try {
  322. if (mElevatorAPI == null) return;
  323. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  324. mCallElevator = true;
  325. } catch (RuntimeException re) {
  326. LogUtil.errorLogInfo("", TAG, re);
  327. } catch (Exception e) {
  328. Log.e(TAG, "[Exception] CallElevator()");
  329. //e.printStackTrace();
  330. LogUtil.errorLogInfo("", TAG, e);
  331. }
  332. }
  333. /**
  334. * 엘리베이터 상향호출 타임아웃을 취소한다.
  335. */
  336. public void TimeOutCancel() {
  337. try {
  338. if (mElevatorTimer == null) return;
  339. mElevatorTimer.cancel();
  340. } catch (RuntimeException re) {
  341. LogUtil.errorLogInfo("", TAG, re);
  342. } catch (Exception e) {
  343. Log.e(TAG, "[Exception] TimeOutCancel()");
  344. //e.printStackTrace();
  345. LogUtil.errorLogInfo("", TAG, e);
  346. }
  347. }
  348. /**
  349. * 엘리베이터 상향호출 타임아웃을 시작한다.
  350. */
  351. private void TimeOutStart() {
  352. try {
  353. if (mElevatorTimer == null) return;
  354. mElevatorTimer.cancel();
  355. mElevatorTimer.start();
  356. } catch (RuntimeException re) {
  357. LogUtil.errorLogInfo("", TAG, re);
  358. } catch (Exception e) {
  359. Log.e(TAG, "[Exception] TimeOutStart()");
  360. //e.printStackTrace();
  361. LogUtil.errorLogInfo("", TAG, e);
  362. }
  363. }
  364. /**
  365. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  366. *
  367. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  368. */
  369. private void SendNotifyKindBR(int kind) {
  370. try {
  371. Intent notiIntent = new Intent();
  372. notiIntent.setAction(define.NOTIFY_ACNAME);
  373. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  374. getApplicationContext().sendBroadcast(notiIntent);
  375. } catch (RuntimeException re) {
  376. LogUtil.errorLogInfo("", TAG, re);
  377. } catch (Exception e) {
  378. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  379. //e.printStackTrace();
  380. LogUtil.errorLogInfo("", TAG, e);
  381. }
  382. }
  383. }
  384. /**
  385. * 엘리베이터 상향호출 Class
  386. */
  387. private ElevatorClass ElevatorUp;
  388. /**
  389. * 엘리베이터 하향호출 Class
  390. */
  391. private ElevatorClass ElevatorDown;
  392. /**
  393. * 엘리베이터 호출한다.
  394. *
  395. * @param Up (boolean) true : 상향, false : 하향
  396. */
  397. private void CallElevatorBtn(boolean Up) {
  398. try {
  399. Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
  400. if (Up) {
  401. // 상향호출
  402. if (ElevatorUp == null) {
  403. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  404. return;
  405. }
  406. ElevatorUp.CallElevator();
  407. } else {
  408. // 하향호출
  409. if (ElevatorDown == null) {
  410. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  411. return;
  412. }
  413. ElevatorDown.CallElevator();
  414. }
  415. } catch (RuntimeException re) {
  416. LogUtil.errorLogInfo("", TAG, re);
  417. } catch (Exception e) {
  418. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  419. //e.printStackTrace();
  420. LogUtil.errorLogInfo("", TAG, e);
  421. }
  422. }
  423. ////////////////////////////////////////////////////////////////////////////////
  424. ////////////////////////////////////////////////////////////////////////////////
  425. @Override
  426. public void onCreate() {
  427. try {
  428. super.onCreate();
  429. Log.i(TAG, "[onCreate] ========== START ==========");
  430. setGlobalScreenAppRunningStatus(false);
  431. ModelType = Version.getModelType();
  432. mSound = new WpadSound(getApplicationContext());
  433. ElevatorUp = new ElevatorClass(true);
  434. ElevatorDown = new ElevatorClass(false);
  435. } catch (RuntimeException re) {
  436. Log.e(TAG, "[Exception] onCreate()");
  437. //e.printStackTrace();
  438. LogUtil.errorLogInfo("", TAG, re);
  439. } catch (Exception e) {
  440. Log.e(TAG, "[Exception] onCreate()");
  441. //e.printStackTrace();
  442. LogUtil.errorLogInfo("", TAG, e);
  443. }
  444. }
  445. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  446. try {
  447. Intent notiIntent = new Intent();
  448. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  449. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  450. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  451. getApplicationContext().sendBroadcast(notiIntent);
  452. } catch (RuntimeException re) {
  453. LogUtil.errorLogInfo("", TAG, re);
  454. } catch (Exception e) {
  455. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  456. //e.printStackTrace();
  457. LogUtil.errorLogInfo("", TAG, e);
  458. }
  459. }
  460. protected String GetForegroundAPP() {
  461. try {
  462. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  463. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  464. ComponentName topActivity = taskInfo.get(0).topActivity;
  465. String str = topActivity.getPackageName();
  466. return str;
  467. } catch (RuntimeException re) {
  468. LogUtil.errorLogInfo("", TAG, re);
  469. return " ";
  470. } catch (Exception e) {
  471. Log.e(TAG, "[Exception] GetForegroundAPP()");
  472. //e.printStackTrace();
  473. LogUtil.errorLogInfo("", TAG, e);
  474. return " ";
  475. }
  476. }
  477. long lSavedTimestamp = 0;
  478. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  479. public void onReceive(Context context, Intent intent) {
  480. try {
  481. String strActionName = intent.getAction();
  482. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
  483. if (strActionName.equals(define.NOTIFY_DAIL)) {
  484. long lTimestamp = System.currentTimeMillis();
  485. long lInterval = lTimestamp - lSavedTimestamp;
  486. if (lInterval < 1000) return;
  487. else
  488. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
  489. lSavedTimestamp = lTimestamp;
  490. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  491. if (mSdb_LivingRoomLightAPI == null) {
  492. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  493. return;
  494. }
  495. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  496. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  497. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  498. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  499. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  500. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  501. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  502. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  503. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  504. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  505. mSdb_LivingRoomLightAPI.SetControlMode(false);
  506. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  507. }
  508. return;
  509. }
  510. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  511. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  512. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  513. return;
  514. }
  515. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  516. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  517. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  518. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  519. } else {
  520. setGlobalScreenAppRunningStatus(false);
  521. }
  522. } else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  523. if (mKnx_LivingRoomLightAPI == null) {
  524. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  525. return;
  526. }
  527. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  528. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  529. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  530. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  531. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  532. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  533. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  534. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  535. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  536. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  537. mKnx_LivingRoomLightAPI.SetControlMode(false);
  538. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  539. }
  540. return;
  541. }
  542. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  543. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  544. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  545. return;
  546. }
  547. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  548. 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 + "]");
  549. }
  550. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  551. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  552. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  553. } else {
  554. setGlobalScreenAppRunningStatus(false);
  555. }
  556. } else {
  557. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  558. }
  559. } else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  560. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  561. } else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
  562. int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
  563. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
  564. switch (kind) {
  565. case define.NOTIFY_SCREEN_TOUCHED:
  566. setTimeStamp_ScreenTouched();
  567. break;
  568. case define.NOTIFY_DOOR_OPENED:
  569. setTimeStamp_Magnetic();
  570. break;
  571. }
  572. } else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  573. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
  574. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  575. switch (kind) {
  576. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  577. procUploadMissedVisitorPic(intent);
  578. break;
  579. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  580. // bBlockCallEvent = true;
  581. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  582. break;
  583. case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
  584. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
  585. Sound().Play(SND.mode.OUTMODE_SETTING);
  586. break;
  587. case Common.BR_MAIN_NOTI.SOUND_INMODE:
  588. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
  589. Sound().Play(SND.mode.INMODE_SETTING);
  590. break;
  591. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  592. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  593. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  594. break;
  595. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
  596. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  597. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  598. break;
  599. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
  600. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  601. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  602. break;
  603. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  604. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  605. CallElevatorBtn(false);
  606. break;
  607. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  608. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  609. CallElevatorBtn(true);
  610. break;
  611. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
  612. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  613. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  614. int CalledWallPadUI = intent.getIntExtra("Called", 0);
  615. if (CalledWallPadUI == 1) {
  616. ModeRunCtrlWorking(true, false);
  617. } else {
  618. ModeRunCtrlWorking(false, false);
  619. }
  620. break;
  621. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
  622. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  623. ModeReleaseCtrlWorking(false);
  624. break;
  625. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
  626. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  627. CheckMainStatus();
  628. break;
  629. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
  630. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  631. ModeRunCtrlWorking(false, false);
  632. break;
  633. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
  634. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  635. ModeReleaseCtrlWorking(false);
  636. break;
  637. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
  638. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  639. if (ElevatorUp != null && ElevatorDown != null) {
  640. boolean UpCalling = ElevatorUp.getElevatorCalling();
  641. boolean DownCalling = ElevatorDown.getElevatorCalling();
  642. Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
  643. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  644. if (UpCalling && DownCalling)
  645. Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  646. else if (UpCalling && !DownCalling)
  647. Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  648. else if (!UpCalling && DownCalling)
  649. Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  650. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  651. Log.d(TAG, " ElvCallState : " + ElvCallState);
  652. SendBRElevatorCallState(ElvCallState);
  653. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  654. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  655. // sendIntent.putExtra("ELV", ElvCallState);
  656. // getApplicationContext().sendBroadcast(sendIntent);
  657. }
  658. break;
  659. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  660. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  661. try {
  662. if (ScheServer != null) {
  663. ScheServer.SetLive();
  664. }
  665. } catch (RuntimeException re) {
  666. LogUtil.errorLogInfo("", TAG, re);
  667. } catch (Exception e) {
  668. //e.printStackTrace();
  669. LogUtil.errorLogInfo("", TAG, e);
  670. }
  671. break;
  672. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  673. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  674. stopIGW300RingGenerator();
  675. break;
  676. }
  677. } else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  678. int kind = intent.getIntExtra("KIND", 0);
  679. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  680. switch (kind) {
  681. case define.NOTIFY_SERVER_VERSION:
  682. try {
  683. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  684. iMapSverReload tSock = new iMapSverReload();
  685. tSock.start();
  686. } catch (IOException e) {
  687. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  688. //e.printStackTrace();
  689. LogUtil.errorLogInfo("", TAG, e);
  690. }
  691. break;
  692. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  693. // 제어기기 엘리베이터 상향 호출 요청
  694. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  695. CallElevatorBtn(true);
  696. break;
  697. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  698. // 제어기기에서 엘리베이터 하향 호출 요청
  699. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  700. CallElevatorBtn(false);
  701. break;
  702. case define.NOTIFY_SUBDEVCALLBUSY:
  703. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  704. CallConnected = true;
  705. break;
  706. case define.NOTIFY_SUBDEVCALLEND:
  707. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  708. CallConnected = false;
  709. break;
  710. case define.NOTIFY_STARTHEARTBEAT:
  711. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  712. {
  713. Message msg = ScheDulerHandler.obtainMessage();
  714. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  715. ScheDulerHandler.sendMessage(msg);
  716. }
  717. break;
  718. case define.NOTIFY_STARTSTATUSBEAT:
  719. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  720. {
  721. Message msg = ScheDulerHandler.obtainMessage();
  722. msg.what = SCHEDULE_START_STATUSBEAT;
  723. ScheDulerHandler.sendMessage(msg);
  724. }
  725. break;
  726. case define.NOTIFY_OUTGOINGSETTED:
  727. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  728. OutGoingSensorWaiting = 0;
  729. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  730. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  731. sdata.closeDB();
  732. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  733. return;
  734. WallPadInterface wpifc = new WallPadInterface();
  735. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
  736. OutGoingSensorWaiting |= SENSOR_MAG;
  737. int[] SensorInfoDB;
  738. int sensorIn = 0;
  739. int sensorOut = 0;
  740. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  741. if (SensorInfoDB[0] == 1) {
  742. // 내부동체가 사용함이면 상태 검사
  743. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
  744. OutGoingSensorWaiting |= SENSOR_IN;
  745. }
  746. if (SensorInfoDB[1] == 1) {
  747. // 외부동체가 사용함이면 상태 검사
  748. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
  749. OutGoingSensorWaiting |= SENSOR_OUT;
  750. }
  751. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  752. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  753. if (OutGoingSensorWaiting > 0) {
  754. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  755. SensorThread.start();
  756. }
  757. break;
  758. case define.NOTIFY_DOOR_SET_DELAY:
  759. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  760. DoorDelayTime = System.currentTimeMillis();
  761. imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
  762. break;
  763. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  764. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  765. Common.setDeviceServeiceLoadComplite();
  766. startRealtimemeterInfo(); // 실시간 검침기 확인
  767. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  768. startDistributionPanel(); // 분전반 확인
  769. getRoomName();
  770. break;
  771. case define.NOTIFY_DLOCK_SET_OUTING:
  772. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  773. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  774. try {
  775. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  776. int AlarmStatus = DBMGR.GetAlarmStatus();
  777. DBMGR.closeDB();
  778. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  779. // 센서 체크하고
  780. // 현관폰으로 사운드 출력하고
  781. boolean bSensorOk = false;
  782. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  783. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  784. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  785. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  786. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  787. bSensorOk = mIGW300.checkSensorforOutmode();
  788. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  789. bSensorOk = mIGW200.checkSensorforOutmode();
  790. } else {
  791. bSensorOk = checkSensorforOutmode();
  792. }
  793. if (bSensorOk) {
  794. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  795. CallOutModeRunActivity();
  796. } else {
  797. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  798. }
  799. }
  800. } catch (RuntimeException re) {
  801. LogUtil.errorLogInfo("", TAG, re);
  802. } catch (Exception e) {
  803. //e.printStackTrace();
  804. LogUtil.errorLogInfo("", TAG, e);
  805. }
  806. break;
  807. case define.NOTIFY_DLOCK_FREE_OUTING:
  808. // 도어락 외출모드 해제
  809. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  810. try {
  811. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  812. int AlarmStatus = DBMGR.GetAlarmStatus();
  813. DBMGR.closeDB();
  814. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  815. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  816. Common.SendAppFinishReqBR(getApplicationContext());
  817. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  818. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  819. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  820. devDB.closeDB();
  821. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  822. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  823. }
  824. }
  825. } catch (RuntimeException re) {
  826. LogUtil.errorLogInfo("", TAG, re);
  827. } catch (Exception e) {
  828. //e.printStackTrace();
  829. LogUtil.errorLogInfo("", TAG, e);
  830. }
  831. break;
  832. case define.NOTIFY_SMARTSW_SET_OUTING:
  833. // 485 대외향 스마트스위치 외출모드
  834. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  835. setUnoccupiedModeByNotHDCSmartSwitch();
  836. break;
  837. case define.NOTIFY_SMARTSW_FREE_OUTING:
  838. //대외향 485 스마트스위치 외출모드 해제
  839. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  840. releaseUnoccupiedModeByNotHDCSmartSwitch();
  841. break;
  842. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  843. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  844. String Type = intent.getStringExtra("TYPE");
  845. String Device = intent.getStringExtra("DEVICE");
  846. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  847. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  848. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  849. iMAPSmartLightEvent imapSmartLightEvent;
  850. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  851. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  852. imapSmartLightEvent.SetRetCtr(new RetProci() {
  853. @Override
  854. public void ProcSuccess() {
  855. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  856. }
  857. @Override
  858. public void ProcError() {
  859. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  860. }
  861. @Override
  862. public void ProcDoing() {
  863. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  864. }
  865. });
  866. break;
  867. case define.NOTIFY_KNX_DEVICE_EVENT:
  868. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  869. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  870. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  871. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  872. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  873. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  874. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  875. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  876. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  877. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  878. @Override
  879. public void ProcSuccess() {
  880. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  881. }
  882. @Override
  883. public void ProcError() {
  884. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  885. }
  886. @Override
  887. public void ProcDoing() {
  888. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  889. }
  890. });
  891. break;
  892. case define.NOTIFY_SMART_DCAM_DETECT:
  893. // 스마트현관카메라 거동수상자 발생
  894. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  895. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  896. if (!bWallPadCallLive && !bBlockFrontCall) {
  897. if (getStrangerRecordingManagerSetting()) {
  898. if (getStrangerRecordingUserSetting()) {
  899. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  900. Intent Newintent = new Intent();
  901. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  902. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  903. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  904. getApplicationContext().sendBroadcast(Newintent);
  905. } else {
  906. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  907. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  908. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  909. }
  910. } else {
  911. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  912. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  913. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  914. }
  915. } else {
  916. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  917. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  918. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  919. }
  920. break;
  921. case define.NOTIFY_SMART_DCAM_RELEASE:
  922. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  923. break;
  924. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  925. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  926. if (getStrangerRecordingManagerSetting()) {
  927. if (getStrangerRecordingUserSetting()) {
  928. // 알람 상태 확인
  929. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  930. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  931. mWallpadStatusData.closeDB();
  932. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  933. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  934. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  935. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  936. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  937. } else {
  938. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  939. Intent Newintent = new Intent();
  940. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  941. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  942. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  943. getApplicationContext().sendBroadcast(Newintent);
  944. }
  945. } else {
  946. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  947. }
  948. } else {
  949. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  950. }
  951. break;
  952. case define.NOTIFY_REJECT_RECORD_STRANGER:
  953. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  954. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  955. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  956. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  957. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  958. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  959. }
  960. break;
  961. case define.NOTIFY_ROOMNAME_CHANGED:
  962. getRoomName();
  963. break;
  964. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  965. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  966. break;
  967. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  968. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  969. break;
  970. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  971. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  972. break;
  973. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  974. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  975. break;
  976. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  977. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  978. break;
  979. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  980. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  981. break;
  982. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  983. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  984. break;
  985. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  986. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  987. break;
  988. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  989. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  990. break;
  991. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  992. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  993. break;
  994. case define.NOTIFY_FINISH_RECORD_STRANGER:
  995. // 녹화 종료 알림
  996. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  997. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  998. mWallpadStatusData.closeDB();
  999. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
  1000. if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
  1001. break;
  1002. case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
  1003. // 사용자 설정화면에서 원격제어시 조명제어 타입 변경
  1004. getDeviceCtrlOption();
  1005. break;
  1006. default:
  1007. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  1008. break;
  1009. }
  1010. }
  1011. } catch (RuntimeException re) {
  1012. LogUtil.errorLogInfo("", TAG, re);
  1013. } catch (Exception e) {
  1014. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1015. //e.printStackTrace();
  1016. LogUtil.errorLogInfo("", TAG, e);
  1017. }
  1018. }
  1019. };
  1020. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1021. try {
  1022. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1023. // 485 대외향 스마트스위치 외출모드
  1024. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1025. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1026. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1027. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1028. mWallpadStatusData.closeDB();
  1029. if (UseGuardSensorCheck == false) {
  1030. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1031. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1032. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1033. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
  1034. mWallpadStatusData.closeDB();
  1035. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1036. //메인화면 업데이트
  1037. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1038. getApplicationContext().sendBroadcast(newIntent);
  1039. ModeRunCtrlWorking(false, false);
  1040. }
  1041. } else {
  1042. // 실제 외출 방범 모드를 설정하도록 한다.
  1043. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1044. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1045. // 센서 체크하고
  1046. // 센서 체크하는 부분이 들어가야 함
  1047. Common.SendAppFinishReqBR(getApplicationContext());
  1048. 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
  1049. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1050. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1051. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1052. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1053. if (mIGW300.checkSensorforOutmode()) {
  1054. CallOutModeWaitingActivity(AlarmStatus);
  1055. } else {
  1056. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1057. }
  1058. } else {
  1059. if (checkSensorforOutmode()) {
  1060. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1061. CallOutModeWaitingActivity(AlarmStatus);
  1062. } else {
  1063. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1064. }
  1065. }
  1066. }
  1067. }
  1068. } catch (RuntimeException re) {
  1069. LogUtil.errorLogInfo("", TAG, re);
  1070. } catch (Exception e) {
  1071. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1072. //e.printStackTrace();
  1073. LogUtil.errorLogInfo("", TAG, e);
  1074. }
  1075. }
  1076. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1077. try {
  1078. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1079. //대외향 485 스마트스위치 외출모드 해제
  1080. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1081. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1082. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1083. mWallpadStatusData.closeDB();
  1084. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
  1085. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1086. if (OutModePwRelease) {
  1087. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1088. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1089. // 요청하여도 해제 되지 않으며
  1090. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1091. Intent notiIntent = new Intent();
  1092. notiIntent.setAction(define.NOTIFY_ACNAME);
  1093. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1094. getApplicationContext().sendBroadcast(notiIntent);
  1095. } else {
  1096. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1097. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1098. // 처리하고.
  1099. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1100. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1101. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1102. mWallpadStatusData.closeDB();
  1103. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1104. Common.SendAppFinishReqBR(getApplicationContext());
  1105. }
  1106. } else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1107. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1108. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1109. ModeReleaseCtrlWorking(false);
  1110. bSmartSwitch485ComebackMode = true;
  1111. Intent notiIntent = new Intent();
  1112. notiIntent.setAction(define.NOTIFY_ACNAME);
  1113. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1114. getApplicationContext().sendBroadcast(notiIntent);
  1115. } else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1116. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1117. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1118. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1119. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1120. mWallpadStatusData.closeDB();
  1121. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1122. //메인화면 업데이트
  1123. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1124. getApplicationContext().sendBroadcast(newIntent);
  1125. ModeReleaseCtrlWorking(false);
  1126. }
  1127. } catch (RuntimeException re) {
  1128. LogUtil.errorLogInfo("", TAG, re);
  1129. } catch (Exception e) {
  1130. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1131. //e.printStackTrace();
  1132. LogUtil.errorLogInfo("", TAG, e);
  1133. }
  1134. }
  1135. /**
  1136. * 스마트현관카메라 녹화 여부 판별
  1137. * 사용자 화면에서 설정
  1138. */
  1139. private boolean getStrangerRecordingUserSetting() {
  1140. boolean bResult = false;
  1141. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1142. try {
  1143. bResult = DBMGR.GetStrangerRecordingOnOff();
  1144. DBMGR.closeDB();
  1145. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1146. } catch (RuntimeException re) {
  1147. LogUtil.errorLogInfo("", TAG, re);
  1148. DBMGR.closeDB();
  1149. bResult = false;
  1150. } catch (Exception e) {
  1151. DBMGR.closeDB();
  1152. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1153. //e.printStackTrace();
  1154. LogUtil.errorLogInfo("", TAG, e);
  1155. bResult = false;
  1156. }
  1157. return bResult;
  1158. }
  1159. private boolean getStrangerTakePic() {
  1160. try {
  1161. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1162. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1163. DBMGR.closeDB();
  1164. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1165. return bResult;
  1166. } catch (RuntimeException re) {
  1167. LogUtil.errorLogInfo("", TAG, re);
  1168. return false;
  1169. } catch (Exception e) {
  1170. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1171. //e.printStackTrace();
  1172. LogUtil.errorLogInfo("", TAG, e);
  1173. return false;
  1174. }
  1175. }
  1176. // 관리자 설정 항목에 있음
  1177. private boolean getStrangerRecordUsage() {
  1178. try {
  1179. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1180. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1181. mWallpadDeviceSet.closeDB();
  1182. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1183. return bResult;
  1184. } catch (RuntimeException re) {
  1185. LogUtil.errorLogInfo("", TAG, re);
  1186. return false;
  1187. } catch (Exception e) {
  1188. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1189. //e.printStackTrace();
  1190. LogUtil.errorLogInfo("", TAG, e);
  1191. return false;
  1192. }
  1193. }
  1194. private boolean checkSensorforOutmode() {
  1195. try {
  1196. WallPadInterface wallPadInterface = new WallPadInterface();
  1197. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1198. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1199. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1200. int[] SensorInfoDB;
  1201. int sensorIn = 0;
  1202. int sensorOut = 0;
  1203. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1204. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1205. if (SensorInfoDB[0] == 1) {
  1206. // 내부동체가 사용함이면 상태 검사
  1207. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1208. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1209. }
  1210. if (SensorInfoDB[1] == 1) {
  1211. // 외부동체가 사용함이면 상태 검사
  1212. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1213. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1214. }
  1215. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1216. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1217. // 동체 사용 설정 체크..
  1218. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1219. int sensor = devSet.Get_Sensor_Set();
  1220. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1221. devSet.closeDB();
  1222. int OtherInSensor = 0;
  1223. // 내부동체 사용안함 이면
  1224. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1225. // 외부동체 사용안함 이면
  1226. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1227. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1228. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1229. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1230. return true;
  1231. } else {
  1232. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1233. return false;
  1234. }
  1235. } catch (RuntimeException re) {
  1236. LogUtil.errorLogInfo("", TAG, re);
  1237. return false;
  1238. } catch (Exception e) {
  1239. //e.printStackTrace();
  1240. LogUtil.errorLogInfo("", TAG, e);
  1241. return false;
  1242. }
  1243. }
  1244. private boolean checkSensorforInmode() {
  1245. try {
  1246. WallPadInterface wallPadInterface = new WallPadInterface();
  1247. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1248. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1249. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1250. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1251. if (sensorMag == 0) {
  1252. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1253. return true;
  1254. } else {
  1255. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1256. return false;
  1257. }
  1258. } catch (RuntimeException re) {
  1259. LogUtil.errorLogInfo("", TAG, re);
  1260. return false;
  1261. } catch (Exception e) {
  1262. Log.e(TAG, e.toString());
  1263. //e.printStackTrace();
  1264. LogUtil.errorLogInfo("", TAG, e);
  1265. return false;
  1266. }
  1267. }
  1268. /////////////////////
  1269. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1270. //////////////
  1271. /////////////////////
  1272. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1273. //////////////
  1274. public void playSoundthroughDoorphone(int SoundIdx) {
  1275. try {
  1276. WallPadInterface Wiface = new WallPadInterface();
  1277. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1278. 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
  1279. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1280. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1281. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1282. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1283. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1284. if (getUseSmartDoorCam()) {
  1285. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1286. }
  1287. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1288. /*
  1289. JEFF (2019.01.14)
  1290. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1291. 강신구입니다.
  1292. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1293. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1294. 내용 공유합니다.
  1295. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1296. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1297. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1298. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1299. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1300. 문제 없습니다.
  1301. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1302. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1303. 문의사항은 하기 연락바랍니다.
  1304. 감사합니다.
  1305. */
  1306. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1307. } else {
  1308. // 대외향 모델 처리
  1309. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
  1310. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1311. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1312. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1313. }
  1314. try {
  1315. Thread.sleep(100);
  1316. } catch (RuntimeException re) {
  1317. LogUtil.errorLogInfo("", TAG, re);
  1318. } catch (Exception e) {
  1319. LogUtil.errorLogInfo("", TAG, e);
  1320. }
  1321. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1322. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1323. try {
  1324. Thread.sleep(1500);
  1325. } catch (RuntimeException re) {
  1326. LogUtil.errorLogInfo("", TAG, re);
  1327. } catch (Exception e) {
  1328. LogUtil.errorLogInfo("", TAG, e);
  1329. }
  1330. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1331. int SLevel = Wdb.GetDoorSoundLevel();
  1332. Wdb.closeDB();
  1333. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1334. if (SLevel != -1) {
  1335. /**
  1336. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1337. * **/
  1338. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1339. } else {
  1340. // 사용안함이면
  1341. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1342. }
  1343. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1344. int time = Sound().PlayMent(SoundIdx);
  1345. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1346. if (0 > time) {
  1347. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1348. time = 1000;
  1349. }
  1350. try {
  1351. Thread.sleep(time + 1000);
  1352. } catch (RuntimeException re) {
  1353. LogUtil.errorLogInfo("", TAG, re);
  1354. } catch (Exception e) {
  1355. LogUtil.errorLogInfo("", TAG, e);
  1356. }
  1357. amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1358. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1359. try {
  1360. Thread.sleep(100);
  1361. } catch (RuntimeException re) {
  1362. LogUtil.errorLogInfo("", TAG, re);
  1363. } catch (Exception e) {
  1364. LogUtil.errorLogInfo("", TAG, e);
  1365. }
  1366. 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
  1367. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1368. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1369. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1370. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1371. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1372. if (getUseSmartDoorCam()) {
  1373. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1374. }
  1375. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1376. /*
  1377. JEFF (2019.01.14)
  1378. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1379. 강신구입니다.
  1380. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1381. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1382. 내용 공유합니다.
  1383. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1384. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1385. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1386. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1387. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1388. 문제 없습니다.
  1389. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1390. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1391. 문의사항은 하기 연락바랍니다.
  1392. 감사합니다.
  1393. */
  1394. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1395. } else {
  1396. // 대외향 모델 처리
  1397. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1398. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1399. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1400. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1401. }
  1402. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1403. } catch (RuntimeException re) {
  1404. LogUtil.errorLogInfo("", TAG, re);
  1405. } catch (Exception e) {
  1406. //e.printStackTrace();
  1407. LogUtil.errorLogInfo("", TAG, e);
  1408. }
  1409. }
  1410. public void CallOutModeRunActivity() {
  1411. int base = 8000;
  1412. int[] Menu_Id_List = {base + 11};
  1413. int Menu_StartId = base + 11;
  1414. int Menu_Option = -1;
  1415. Intent intent = new Intent(Intent.ACTION_MAIN);
  1416. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1417. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1418. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1419. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1420. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1421. startActivity(intent);
  1422. }
  1423. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1424. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1425. int base = 4000;
  1426. int[] Menu_Id_List = {base + 11, base + 21};
  1427. int Menu_StartId = base + 11;
  1428. int Menu_Option = 1000;
  1429. Intent intent = new Intent(Intent.ACTION_MAIN);
  1430. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1431. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1432. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1433. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1434. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  1435. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1436. startActivity(intent);
  1437. }
  1438. private boolean getGlobalScreenAppRunningStatus() {
  1439. boolean bRunning = false;
  1440. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1441. try {
  1442. bRunning = DBMGR.getGlobalScreenAPKRun();
  1443. DBMGR.closeDB();
  1444. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1445. return bRunning;
  1446. } catch (RuntimeException re) {
  1447. LogUtil.errorLogInfo("", TAG, re);
  1448. DBMGR.closeDB();
  1449. } catch (Exception e) {
  1450. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1451. //e.printStackTrace();
  1452. LogUtil.errorLogInfo("", TAG, e);
  1453. DBMGR.closeDB();
  1454. }
  1455. return bRunning;
  1456. }
  1457. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1458. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1459. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1460. try {
  1461. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1462. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1463. DBMGR.closeDB();
  1464. } catch (RuntimeException re) {
  1465. LogUtil.errorLogInfo("", TAG, re);
  1466. DBMGR.closeDB();
  1467. } catch (Exception e) {
  1468. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1469. //e.printStackTrace();
  1470. LogUtil.errorLogInfo("", TAG, e);
  1471. DBMGR.closeDB();
  1472. }
  1473. }
  1474. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1475. boolean bGlobalScreenRun = false;
  1476. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1477. try {
  1478. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1479. wakeupLCD();
  1480. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1481. setGlobalScreenAppRunningStatus(true);
  1482. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1483. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1484. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1485. mIntent.putExtra("ONOFF", hOnOff);
  1486. mIntent.putExtra("DIAL", hDial);
  1487. mIntent.putExtra("LEVEL", hLevel);
  1488. mIntent.putExtra("COLOR", hColor);
  1489. mIntent.putExtra("CONTROL", hControl);
  1490. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1491. mIntent.setComponent(mComponentName);
  1492. startActivity(mIntent);
  1493. } else {
  1494. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1495. }
  1496. } catch (RuntimeException re) {
  1497. LogUtil.errorLogInfo("", TAG, re);
  1498. } catch (Exception e) {
  1499. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1500. //e.printStackTrace();
  1501. LogUtil.errorLogInfo("", TAG, e);
  1502. }
  1503. }
  1504. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1505. try {
  1506. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1507. wakeupLCD();
  1508. if (!getGlobalScreenAppRunningStatus()) {
  1509. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1510. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1511. return;
  1512. }
  1513. setGlobalScreenAppRunningStatus(true);
  1514. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1515. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1516. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1517. mIntent.putExtra("SCREENID", nScreenID);
  1518. mIntent.putExtra("ONOFF", hOnOff);
  1519. mIntent.putExtra("DIAL", hDial);
  1520. mIntent.putExtra("LEVEL", hLevel);
  1521. mIntent.putExtra("COLOR", hColor);
  1522. mIntent.putExtra("CONTROL", hControl);
  1523. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1524. mIntent.setComponent(mComponentName);
  1525. startActivity(mIntent);
  1526. } else {
  1527. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1528. }
  1529. } catch (RuntimeException re) {
  1530. LogUtil.errorLogInfo("", TAG, re);
  1531. } catch (Exception e) {
  1532. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1533. //e.printStackTrace();
  1534. LogUtil.errorLogInfo("", TAG, e);
  1535. }
  1536. }
  1537. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1538. public void sendBlackoutReleasedBR() {
  1539. try {
  1540. Intent notiIntent = new Intent();
  1541. notiIntent.setAction(strBLACKOUT_RELEASED);
  1542. getApplicationContext().sendBroadcast(notiIntent);
  1543. } catch (RuntimeException re) {
  1544. LogUtil.errorLogInfo("", TAG, re);
  1545. } catch (Exception e) {
  1546. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1547. //e.printStackTrace();
  1548. LogUtil.errorLogInfo("", TAG, e);
  1549. }
  1550. }
  1551. private int getCurrentScreen() {
  1552. int nScreenID = 0;
  1553. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1554. try {
  1555. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1556. DBMGR.closeDB();
  1557. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1558. return nScreenID;
  1559. } catch (RuntimeException re) {
  1560. LogUtil.errorLogInfo("", TAG, re);
  1561. DBMGR.closeDB();
  1562. } catch (Exception e) {
  1563. Log.e(TAG, "[Exception] getCurrentScreen()");
  1564. //e.printStackTrace();
  1565. LogUtil.errorLogInfo("", TAG, e);
  1566. DBMGR.closeDB();
  1567. }
  1568. return nScreenID;
  1569. }
  1570. private void setCurrentScreen(int nScreenID) {
  1571. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1572. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1573. try {
  1574. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1575. DBMGR.closeDB();
  1576. } catch (RuntimeException re) {
  1577. LogUtil.errorLogInfo("", TAG, re);
  1578. DBMGR.closeDB();
  1579. } catch (Exception e) {
  1580. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1581. //e.printStackTrace();
  1582. LogUtil.errorLogInfo("", TAG, e);
  1583. DBMGR.closeDB();
  1584. }
  1585. }
  1586. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1587. private void procUploadMissedVisitorPic(Intent intent) {
  1588. try {
  1589. String strDong = intent.getStringExtra("DONG");
  1590. String strHo = intent.getStringExtra("HO");
  1591. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1592. int nCnt = intent.getIntExtra("CNT", 0);
  1593. String[] strMissedPicURI = new String[nCnt];
  1594. strArrayMissedPicURI.clear();
  1595. for (int i = 0; i < nCnt; i++) {
  1596. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1597. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1598. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1599. }
  1600. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1601. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1602. }
  1603. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1604. } catch (RuntimeException re) {
  1605. LogUtil.errorLogInfo("", TAG, re);
  1606. } catch (Exception e) {
  1607. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1608. //e.printStackTrace();
  1609. LogUtil.errorLogInfo("", TAG, e);
  1610. }
  1611. }
  1612. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1613. try {
  1614. String strURI = "", strFileName = "", strTime = "", strType = "";
  1615. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1616. // strURI = strArrayMissedPicURI.get(i).toString();
  1617. // strFileName = extractFileName(strURI);
  1618. // strTime = extractFileTime(strURI);
  1619. // strType = extractCallType(strFileName);
  1620. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1621. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1622. // }
  1623. if (strArrayMissedPicURI.size() > 0) {
  1624. strURI = strArrayMissedPicURI.get(0).toString();
  1625. strFileName = extractFileName(strURI);
  1626. strTime = extractFileTime(strFileName);
  1627. strType = extractCallType(strFileName);
  1628. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1629. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1630. } else {
  1631. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1632. }
  1633. } catch (RuntimeException re) {
  1634. LogUtil.errorLogInfo("", TAG, re);
  1635. } catch (Exception e) {
  1636. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1637. //e.printStackTrace();
  1638. LogUtil.errorLogInfo("", TAG, e);
  1639. }
  1640. }
  1641. public class uploadVisitorPicture extends Thread {
  1642. HDCFTPManager mFTPManager;
  1643. boolean bMainServer2dot0 = false;
  1644. String strRemoteIP = "10.0.1.1";
  1645. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1646. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1647. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1648. try {
  1649. strDong = dong;
  1650. strHo = ho;
  1651. strType = type;
  1652. strTime = time;
  1653. strFileName = filename;
  1654. strUploadFile = uploadfile;
  1655. bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1656. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1657. wallpadDeviceSet.closeDB();
  1658. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
  1659. } catch (RuntimeException re) {
  1660. LogUtil.errorLogInfo("", TAG, re);
  1661. } catch (Exception e) {
  1662. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1663. //e.printStackTrace();
  1664. LogUtil.errorLogInfo("", TAG, e);
  1665. }
  1666. }
  1667. public void run() {
  1668. try {
  1669. mFTPManager = new HDCFTPManager();
  1670. if (!mFTPManager.isFTPConnected()) {
  1671. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1672. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1673. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1674. return;
  1675. }
  1676. }
  1677. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1678. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1679. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1680. return;
  1681. }
  1682. if (!bMainServer2dot0) {
  1683. if (!mFTPManager.setPassiveMode()) {
  1684. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1685. disconnectFTP();
  1686. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1687. return;
  1688. }
  1689. }
  1690. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1691. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1692. disconnectFTP();
  1693. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1694. return;
  1695. }
  1696. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1697. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1698. disconnectFTP();
  1699. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1700. return;
  1701. }
  1702. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1703. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1704. disconnectFTP();
  1705. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1706. return;
  1707. }
  1708. disconnectFTP();
  1709. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1710. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1711. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1712. } catch (RuntimeException re) {
  1713. LogUtil.errorLogInfo("", TAG, re);
  1714. } catch (Exception e) {
  1715. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1716. //e.printStackTrace();
  1717. LogUtil.errorLogInfo("", TAG, e);
  1718. }
  1719. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1720. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1721. }
  1722. public boolean disconnectFTP() {
  1723. try {
  1724. if (mFTPManager.logoutFTP()) {
  1725. if (mFTPManager.disconnectFTP()) {
  1726. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1727. return true;
  1728. }
  1729. }
  1730. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1731. return false;
  1732. } catch (RuntimeException re) {
  1733. LogUtil.errorLogInfo("", TAG, re);
  1734. return false;
  1735. } catch (Exception e) {
  1736. Log.e(TAG, "[Exception] disconnectFTP()");
  1737. //e.printStackTrace();
  1738. LogUtil.errorLogInfo("", TAG, e);
  1739. return false;
  1740. }
  1741. }
  1742. }
  1743. private String extractCallType(String strFileName) {
  1744. try {
  1745. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1746. String[] strParse_01 = strFileName.split("_");
  1747. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1748. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1749. else return "none";
  1750. } catch (RuntimeException re) {
  1751. LogUtil.errorLogInfo("", TAG, re);
  1752. return null;
  1753. } catch (Exception e) {
  1754. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1755. //e.printStackTrace();
  1756. LogUtil.errorLogInfo("", TAG, e);
  1757. return null;
  1758. }
  1759. }
  1760. private String extractFileName(String strTargetFile) {
  1761. try {
  1762. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1763. String[] strParse_01 = strTargetFile.split("/");
  1764. return strParse_01[strParse_01.length - 1];
  1765. } catch (RuntimeException re) {
  1766. LogUtil.errorLogInfo("", TAG, re);
  1767. return null;
  1768. } catch (Exception e) {
  1769. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1770. //e.printStackTrace();
  1771. LogUtil.errorLogInfo("", TAG, e);
  1772. return null;
  1773. }
  1774. }
  1775. private String extractFileTime(String strFileName) {
  1776. try {
  1777. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1778. String[] strParse_01 = strFileName.split("\\.");
  1779. String[] strParse_02 = strParse_01[0].split("_");
  1780. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1781. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1782. // 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);
  1783. return strParse_02[5] + "_" + strParse_02[6];
  1784. } catch (RuntimeException re) {
  1785. LogUtil.errorLogInfo("", TAG, re);
  1786. return null;
  1787. } catch (Exception e) {
  1788. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1789. //e.printStackTrace();
  1790. LogUtil.errorLogInfo("", TAG, e);
  1791. return null;
  1792. }
  1793. }
  1794. String strRemoteURI, strUserID, strPW, strPath;
  1795. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1796. String strKey_Pass = "passwd";
  1797. 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) {
  1798. try {
  1799. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1800. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1801. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1802. visitor_access_info.setResultCtrl(new RetProci() {
  1803. @Override
  1804. public void ProcSuccess() {
  1805. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1806. visitor_access_info.SetItem("ftp_info");
  1807. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1808. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1809. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1810. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1811. strUserID = strReply_User;
  1812. strPW = strReply_PW;
  1813. strPath = strReply_Path;
  1814. strRemoteURI = strPath + "/" + strFileName;
  1815. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1816. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1817. mUploadVisitorPicture.start();
  1818. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1819. // mUploadVisitorPicture.start();
  1820. }
  1821. @Override
  1822. public void ProcError() {
  1823. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1824. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1825. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1826. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1827. }
  1828. @Override
  1829. public void ProcDoing() {
  1830. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1831. }
  1832. });
  1833. return true;
  1834. }
  1835. } catch (RuntimeException re) {
  1836. LogUtil.errorLogInfo("", TAG, re);
  1837. } catch (Exception e) {
  1838. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1839. //e.printStackTrace();
  1840. LogUtil.errorLogInfo("", TAG, e);
  1841. }
  1842. return false;
  1843. }
  1844. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1845. try {
  1846. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1847. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1848. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1849. visitor_upload_complete.setResultCtrl(new RetProci() {
  1850. @Override
  1851. public void ProcSuccess() {
  1852. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1853. }
  1854. @Override
  1855. public void ProcError() {
  1856. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1857. }
  1858. @Override
  1859. public void ProcDoing() {
  1860. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1861. }
  1862. });
  1863. return true;
  1864. }
  1865. } catch (RuntimeException re) {
  1866. LogUtil.errorLogInfo("", TAG, re);
  1867. } catch (Exception e) {
  1868. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1869. //e.printStackTrace();
  1870. LogUtil.errorLogInfo("", TAG, e);
  1871. }
  1872. return false;
  1873. }
  1874. /**
  1875. * 이통사 연동 서비스를 위한 BR
  1876. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1877. *
  1878. * @param kind (String) "lobby" or "home"
  1879. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1880. */
  1881. public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
  1882. try {
  1883. Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
  1884. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1885. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1886. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1887. Intent mIntent = new Intent();
  1888. mIntent.setAction(BR_VISITOR_EVENT);
  1889. mIntent.putExtra("KIND", kind);
  1890. mIntent.putExtra("TIME", datetime);
  1891. mIntent.putExtra("FILENAME", filename);
  1892. getApplicationContext().sendBroadcast(mIntent);
  1893. } catch (RuntimeException re) {
  1894. LogUtil.errorLogInfo("", TAG, re);
  1895. } catch (Exception e) {
  1896. Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
  1897. //e.printStackTrace();
  1898. LogUtil.errorLogInfo("", TAG, e);
  1899. }
  1900. }
  1901. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1902. public void onReceive(Context context, Intent intent) {
  1903. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1904. Bundle bundle;
  1905. WallpadDeviceSet devset;
  1906. Intent newintent;
  1907. boolean CallAppRun = false;
  1908. boolean MgrAppRun = false;
  1909. final String packageName = "com.artncore.apps.ic_wallpad";
  1910. final String packageNameMgr = "com.artncore.managersetting";
  1911. //CallAppRun = getForegroundAPK().equals(packageName);
  1912. // CallAppRun = getCallAppRunning();
  1913. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1914. int base = 7000;
  1915. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  1916. int Menu_Start_Option = 1;
  1917. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1918. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1919. int keyevt = ReceiveEvt.getKeyCode();
  1920. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1921. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1922. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1923. sdata.closeDB();
  1924. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1925. return;
  1926. }
  1927. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1928. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1929. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1930. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1931. mWallpadStatusData.closeDB();
  1932. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1933. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1934. sdata.closeDB();
  1935. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1936. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1937. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1938. int nModelType = Version.getModelType();
  1939. switch (ReceiveEvt.getKeyCode()) {
  1940. case 251: // 현산향 비상버튼 다운 업 처리
  1941. try {
  1942. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1943. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1944. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1945. } else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1946. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1947. }
  1948. }
  1949. } catch (RuntimeException re) {
  1950. LogUtil.errorLogInfo("", TAG, re);
  1951. } catch (Exception e) {
  1952. //e.printStackTrace();
  1953. LogUtil.errorLogInfo("", TAG, e);
  1954. }
  1955. break;
  1956. case WallPadInterface.EVT_RING:
  1957. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1958. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1959. // 전화 수신 링 수신
  1960. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1961. if (Version.getGatewayUsage()) {
  1962. // 국선 시작만 올라온다.
  1963. startIGW300RingGenerator();
  1964. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1965. } else {
  1966. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1967. }
  1968. break;
  1969. case WallPadInterface.EVT_END_RING:
  1970. // 전화 수신 링 종료
  1971. // Jeff added below codes for call app (2018.01.25)
  1972. // This event is managed by WallPadCall
  1973. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  1974. if (Version.getGatewayUsage()) {
  1975. stopIGW300RingGenerator();
  1976. }
  1977. break;
  1978. case WallPadInterface.BTN_EMR:
  1979. case WallPadInterface.BTN_EMR_IHN1010:
  1980. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  1981. // 월패드 비상버튼 입력 SA 와 GLE 공통
  1982. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  1983. if (MgrAppRun) return;
  1984. if (Common.DIAGNOSTIC_MODE) return;
  1985. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1986. return;
  1987. //currentTime = System.currentTimeMillis();
  1988. //if (ALERTTIME > currentTime) break;
  1989. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  1990. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  1991. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  1992. break;
  1993. devset = new WallpadDeviceSet(getApplicationContext());
  1994. int StatusVal = devset.GetDeviceSetted("알람발생");
  1995. devset.closeDB();
  1996. Log.d("imap", "StatusVal : " + StatusVal);
  1997. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  1998. // 보안 처리가 필요함..
  1999. // 지속적으로 이벤트가 들어올 경우 대비
  2000. Common.SendAppFinishReqBR(getApplicationContext());
  2001. newintent = new Intent(Intent.ACTION_MAIN);
  2002. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2003. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2004. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2005. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2006. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2007. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2008. iMAPstartActivity(newintent);
  2009. }
  2010. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2011. if (getIsSubWallpad()) {
  2012. Intent notiIntent = new Intent();
  2013. notiIntent.setAction(define.NOTIFY_ACNAME);
  2014. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2015. getApplicationContext().sendBroadcast(notiIntent);
  2016. }
  2017. break;
  2018. case WallPadInterface.BTN_CALL:
  2019. case WallPadInterface.BTN_CALL_IHN1010:
  2020. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2021. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2022. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2023. // Jeff added below codes for call app (2018.01.25)
  2024. try {
  2025. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2026. if (getIsSubWallpad()) {
  2027. // 서브월패드
  2028. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2029. } else {
  2030. // 메인월패드
  2031. if (MainActivity.bRecordStatus) {
  2032. // 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2033. Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2034. Intent iIntent = new Intent();
  2035. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2036. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
  2037. getApplicationContext().sendBroadcast(iIntent);
  2038. }
  2039. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2040. }
  2041. } catch (RuntimeException re) {
  2042. LogUtil.errorLogInfo("", TAG, re);
  2043. } catch (Exception e) {
  2044. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2045. //e.printStackTrace();
  2046. LogUtil.errorLogInfo("", TAG, e);
  2047. }
  2048. break;
  2049. case WallPadInterface.BTN_OPEN:
  2050. // 월패드 문여림 버튼 입력 상태 SA
  2051. break;
  2052. case WallPadInterface.BTN_DOOR:
  2053. case WallPadInterface.BTN_DOOR_IHN1010:
  2054. // 현관 도어폰 벨 눌림 입력 상태
  2055. // Jeff added below codes for call app (2018.01.25)
  2056. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2057. if (!bWallPadCallLive && !bBlockFrontCall) {
  2058. if (MainActivity.bRecordStatus) {
  2059. // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2060. Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2061. Intent iIntent = new Intent();
  2062. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2063. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
  2064. getApplicationContext().sendBroadcast(iIntent);
  2065. }
  2066. bBlockFrontCall = true;
  2067. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2068. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2069. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2070. try {
  2071. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2072. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2073. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2074. } 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
  2075. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2076. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2077. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2078. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2079. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2080. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2081. }
  2082. if (!Version.getGatewayUsage()) {
  2083. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2084. }
  2085. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2086. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2087. } catch (RuntimeException re) {
  2088. LogUtil.errorLogInfo("", TAG, re);
  2089. } catch (Exception e) {
  2090. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2091. //e.printStackTrace();
  2092. LogUtil.errorLogInfo("", TAG, e);
  2093. }
  2094. } else {
  2095. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2096. }
  2097. break;
  2098. case WallPadInterface.BTN_CAMERA_SET:
  2099. Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
  2100. Intent iIntent = new Intent();
  2101. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2102. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
  2103. getApplicationContext().sendBroadcast(iIntent);
  2104. break;
  2105. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2106. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
  2107. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2108. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
  2109. && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
  2110. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2111. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2112. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2113. if (MgrAppRun) return;
  2114. if (Common.DIAGNOSTIC_MODE) return;
  2115. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  2116. return;
  2117. //currentTime = System.currentTimeMillis();
  2118. //if (ALERTTIME > currentTime) break;
  2119. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2120. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2121. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2122. break;
  2123. devset = new WallpadDeviceSet(getApplicationContext());
  2124. StatusVal = devset.GetDeviceSetted("알람발생");
  2125. devset.closeDB();
  2126. Log.d("imap", "StatusVal : " + StatusVal);
  2127. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2128. // 보안 처리가 필요함..
  2129. // 지속적으로 이벤트가 들어올 경우 대비
  2130. Common.SendAppFinishReqBR(getApplicationContext());
  2131. newintent = new Intent(Intent.ACTION_MAIN);
  2132. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2133. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2134. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2135. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2136. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2137. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2138. iMAPstartActivity(newintent);
  2139. }
  2140. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2141. if (getIsSubWallpad()) {
  2142. Intent notiIntent = new Intent();
  2143. notiIntent.setAction(define.NOTIFY_ACNAME);
  2144. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2145. getApplicationContext().sendBroadcast(notiIntent);
  2146. }
  2147. } else {
  2148. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2149. if (!getEmergencyIOUsage()) {
  2150. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2151. return;
  2152. }
  2153. if (MgrAppRun) {
  2154. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2155. return;
  2156. }
  2157. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2158. break;
  2159. devset = new WallpadDeviceSet(getApplicationContext());
  2160. StatusVal = devset.GetDeviceSetted("알람발생");
  2161. devset.closeDB();
  2162. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2163. Common.SendAppFinishReqBR(getApplicationContext());
  2164. newintent = new Intent(Intent.ACTION_MAIN);
  2165. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2166. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2167. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2168. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2169. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2170. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2171. iMAPstartActivity(newintent);
  2172. }
  2173. }
  2174. break;
  2175. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2176. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2177. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2178. // 대외향의 경우 여기에서 마그네틱이 감지된다.
  2179. if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
  2180. if (MgrAppRun) return;
  2181. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2182. WallPadInterface mWallPadInterface = new WallPadInterface();
  2183. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2184. if (sensorMag == 0) return;
  2185. }
  2186. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2187. break;
  2188. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2189. break;
  2190. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2191. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2192. if (OutGoingSensorWaiting == 0) {
  2193. // wakeupLCD();
  2194. mIOInterface.ctrlLcdWakeUp();
  2195. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2196. SensorThread.start();
  2197. }
  2198. OutGoingSensorWaiting |= SENSOR_MAG;
  2199. } else {
  2200. Common.SendAppFinishReqBR(getApplicationContext());
  2201. newintent = new Intent(Intent.ACTION_MAIN);
  2202. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2203. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2204. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2205. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2206. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2207. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2208. iMAPstartActivity(newintent);
  2209. }
  2210. break;
  2211. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2212. saveBlackoutStatus(true);
  2213. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2214. break;
  2215. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2216. saveBlackoutStatus(false);
  2217. sendBlackoutReleasedBR();
  2218. break;
  2219. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2220. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2221. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2222. if (MgrAppRun) return;
  2223. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2224. break;
  2225. devset = new WallpadDeviceSet(getApplicationContext());
  2226. StatusVal = devset.GetDeviceSetted("피난사다리");
  2227. int LadderSend = devset.getEscapeLadderDownSend();
  2228. String pentHouseHo = devset.getPentHouseHoEscapeLadder();
  2229. devset.closeDB();
  2230. Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
  2231. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2232. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2233. Common.SendAppFinishReqBR(getApplicationContext());
  2234. newintent = new Intent(Intent.ACTION_MAIN);
  2235. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2236. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2237. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2238. if (!pentHouseHo.equals("")) {
  2239. // 윗집이 펜트하우스인 경우
  2240. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2241. } else {
  2242. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  2243. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2244. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  2245. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2246. }
  2247. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2248. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2249. iMAPstartActivity(newintent);
  2250. }
  2251. break;
  2252. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2253. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2254. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2255. {
  2256. // 내부동체가 상태가 변경된 경우
  2257. int[] SensorInfoDB;
  2258. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2259. if (SensorInfoDB[0] != 1) {
  2260. //내부동체가 사용함이면 상태 검사
  2261. return;
  2262. }
  2263. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2264. WallPadInterface mWallPadInterface = new WallPadInterface();
  2265. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2266. if (sensorMag == 0) return;
  2267. }
  2268. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2269. int sensor = devSet.Get_Sensor_Set();
  2270. devSet.closeDB();
  2271. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2272. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2273. break;
  2274. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2275. if (OutGoingSensorWaiting == 0) {
  2276. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2277. SensorThread.start();
  2278. }
  2279. OutGoingSensorWaiting |= SENSOR_IN;
  2280. }
  2281. break;
  2282. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2283. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2284. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2285. {
  2286. // 외부동체가 상태가 변경된 경우
  2287. int[] SensorInfoDB;
  2288. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2289. if (SensorInfoDB[1] != 1) {
  2290. // 외부동체가 사용함이면 상태 검사
  2291. return;
  2292. }
  2293. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2294. WallPadInterface mWallPadInterface = new WallPadInterface();
  2295. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2296. if (sensorMag == 0) return;
  2297. }
  2298. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2299. int sensor = devSet.Get_Sensor_Set();
  2300. devSet.closeDB();
  2301. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2302. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2303. break;
  2304. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2305. break;
  2306. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2307. break;
  2308. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2309. {
  2310. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2311. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2312. break;
  2313. }*/
  2314. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2315. if (OutGoingSensorWaiting == 0) {
  2316. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2317. SensorThread.start();
  2318. }
  2319. OutGoingSensorWaiting |= SENSOR_OUT;
  2320. } else {
  2321. Common.SendAppFinishReqBR(getApplicationContext());
  2322. newintent = new Intent(Intent.ACTION_MAIN);
  2323. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2324. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2325. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2326. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2327. newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2328. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2329. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2330. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2331. iMAPstartActivity(newintent);
  2332. }
  2333. }
  2334. break;
  2335. }
  2336. } else {
  2337. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2338. }
  2339. }
  2340. };
  2341. protected void iMAPstartActivity(Intent intent) {
  2342. try {
  2343. startActivity(intent);
  2344. } catch (RuntimeException re) {
  2345. LogUtil.errorLogInfo("", TAG, re);
  2346. } catch (Exception e) {
  2347. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2348. //e.printStackTrace();
  2349. LogUtil.errorLogInfo("", TAG, e);
  2350. }
  2351. }
  2352. /**
  2353. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2354. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2355. * 1. 현관카메라 키이벤트 수신
  2356. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2357. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2358. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2359. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2360. * 6. 시스템 볼륨 원복
  2361. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2362. */
  2363. AudioManager mAudioManager;
  2364. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2365. Handler mDingDongHandler = new Handler() {
  2366. public void handleMessage(Message msg) {
  2367. try {
  2368. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2369. if (msg.what == 0) {
  2370. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2371. int nVolume = 10;
  2372. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
  2373. nVolume = 12;
  2374. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2375. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2376. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2377. mDingDongHandler.sendEmptyMessage(1);
  2378. } else if (msg.what == 1) {
  2379. // 띵똥 패스 체크
  2380. check1++;
  2381. if (check1 > 200) {
  2382. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2383. finishDingDongHandler();
  2384. check1 = 0;
  2385. return;
  2386. } else {
  2387. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2388. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2389. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2390. }
  2391. } else if (msg.what == 2) {
  2392. // 띵똥 음원 재생
  2393. mIOInterface.ctrlSetTalkPathDoor();
  2394. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2395. } else if (msg.what == 3) {
  2396. mIOInterface.ctrlSetTalkPathNormal();
  2397. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2398. mDingDongHandler.sendEmptyMessage(4);
  2399. } else if (msg.what == 4) {
  2400. // Normal 패스 체크
  2401. check2++;
  2402. if (check2 > 200) {
  2403. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2404. finishDingDongHandler();
  2405. check2 = 0;
  2406. return;
  2407. } else {
  2408. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2409. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2410. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2411. }
  2412. } else if (msg.what == 5) {
  2413. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2414. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2415. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2416. wdb.closeDB();
  2417. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2418. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2419. intent.setAction(define.NOTIFY_ACNAME);
  2420. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2421. sendBroadcast(intent);
  2422. }
  2423. } catch (RuntimeException re) {
  2424. LogUtil.errorLogInfo("", TAG, re);
  2425. finishDingDongHandler();
  2426. } catch (Exception e) {
  2427. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2428. //e.printStackTrace();
  2429. LogUtil.errorLogInfo("", TAG, e);
  2430. finishDingDongHandler();
  2431. }
  2432. }
  2433. };
  2434. private void finishDingDongHandler() {
  2435. try {
  2436. Log.d(TAG, "[finishDingDongHandler]");
  2437. if (mDingDongHandler != null) {
  2438. mDingDongHandler.removeMessages(0);
  2439. mDingDongHandler.removeMessages(1);
  2440. mDingDongHandler.removeMessages(2);
  2441. mDingDongHandler.removeMessages(3);
  2442. mDingDongHandler.removeMessages(4);
  2443. mDingDongHandler.removeMessages(5);
  2444. }
  2445. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2446. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2447. wdb.closeDB();
  2448. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2449. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2450. mIOInterface.ctrlSetTalkPathNormal();
  2451. } catch (RuntimeException re) {
  2452. LogUtil.errorLogInfo("", TAG, re);
  2453. } catch (Exception e) {
  2454. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2455. //e.printStackTrace();
  2456. LogUtil.errorLogInfo("", TAG, e);
  2457. }
  2458. }
  2459. // 외출방범 대기 모드 중 사운드와 센서 체크
  2460. class OutgoingCheckSensor extends Thread {
  2461. public OutgoingCheckSensor() {
  2462. }
  2463. public void run() {
  2464. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2465. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2466. WallPadInterface wpifc = new WallPadInterface();
  2467. mWallpadStatusData.closeDB();
  2468. int checkcount = timedata / 5;
  2469. int i;
  2470. for (i = checkcount; i > 0; i--) {
  2471. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2472. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2473. mWallpadStatusData.closeDB();
  2474. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2475. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2476. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2477. try {
  2478. Thread.sleep(5000);
  2479. } catch (RuntimeException re) {
  2480. LogUtil.errorLogInfo("", TAG, re);
  2481. } catch (Exception e) {
  2482. LogUtil.errorLogInfo("", TAG, e);
  2483. }
  2484. }
  2485. if (i == 0) {
  2486. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2487. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2488. mWallpadStatusData.closeDB();
  2489. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2490. Common.SendAppFinishReqBR(getApplicationContext());
  2491. int base = 7000;
  2492. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  2493. int Menu_Start_Option = 1;
  2494. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2495. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2496. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2497. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2498. String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
  2499. if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
  2500. else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
  2501. else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
  2502. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2503. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2504. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2505. iMAPstartActivity(mIntent);
  2506. }
  2507. }
  2508. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2509. OutGoingSensorWaiting = 0;
  2510. }
  2511. }
  2512. @Override
  2513. public IBinder onBind(Intent arg0) {
  2514. return mMessenger.getBinder();
  2515. //return null;
  2516. }
  2517. public void imapsvrlog(String msg) {
  2518. if (!log_sw) return;
  2519. Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
  2520. }
  2521. public int onStartCommand(Intent intent, int flags, int startID) {
  2522. try {
  2523. try {
  2524. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2525. } catch (RuntimeException re) {
  2526. LogUtil.errorLogInfo("", TAG, re);
  2527. } catch (Exception e) {
  2528. //e.printStackTrace();
  2529. LogUtil.errorLogInfo("", TAG, e);
  2530. }
  2531. getDeviceCtrlOption();
  2532. SvrSock = new iMapSverSocket();
  2533. SvrSock.start();
  2534. } catch (IOException e) {
  2535. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2536. //e.printStackTrace();
  2537. LogUtil.errorLogInfo("", TAG, e);
  2538. }
  2539. try {
  2540. mGleInterface = new jni();
  2541. } catch (RuntimeException re) {
  2542. LogUtil.errorLogInfo("", TAG, re);
  2543. } catch (Exception e) {
  2544. Log.e(TAG, "[Exception] mGleInterface init...");
  2545. //e.printStackTrace();
  2546. LogUtil.errorLogInfo("", TAG, e);
  2547. }
  2548. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2549. AddressSet addr = DBMGR.getAddressMGR();
  2550. DBMGR.closeDB();
  2551. String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
  2552. AddrDong = addr.Dong;
  2553. AddrHo = addr.Ho;
  2554. ho = Integer.valueOf(AddrHo.substring(0, 1));
  2555. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  2556. "<imap ver=\"1.0\" address=\"" + addr.IPAddress + "\" sender=\"" + AddressStr + "\">\r\n";
  2557. Log.d(TAG, "*****************************************");
  2558. Log.d(TAG, "****************SchedulerThread**********");
  2559. Log.d(TAG, "*****************************************");
  2560. ScheServer = new SchedulerThread();
  2561. ScheServer.start();
  2562. // BR 등록 시작
  2563. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2564. IntentFilter mIntentFilter = new IntentFilter();
  2565. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2566. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2567. mIntentFilter = new IntentFilter();
  2568. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2569. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2570. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2571. mIntentFilter = new IntentFilter();
  2572. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2573. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2574. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2575. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2576. mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
  2577. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2578. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2579. // BR 등록 완료
  2580. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2581. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
  2582. IGW200APICheckHandler.sendEmptyMessage(0);
  2583. 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
  2584. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2585. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2586. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2587. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2588. IGW300APICheckHandler.sendEmptyMessage(0);
  2589. }
  2590. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2591. mIOInterface.setEmergencyType();
  2592. Intent notiIntent = new Intent();
  2593. notiIntent.setAction(define.NOTIFY_ACNAME);
  2594. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2595. getApplicationContext().sendBroadcast(notiIntent);
  2596. CheckMainStatus();
  2597. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2598. getAirQualityUsage();
  2599. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2600. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2601. GwCheckThread.start();
  2602. }
  2603. getResidentSafetyCheckSetting();
  2604. return START_STICKY;
  2605. }
  2606. //멀티기기 정보 전송을 위한 추가
  2607. public static final int MSG_REGISTER_CLIENT = 1;
  2608. //public static final int MSG_UNREGISTER_CLIENT = 2;
  2609. public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
  2610. public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
  2611. public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
  2612. public static final int MSG_SEND_TO_ACTIVITY = 4;
  2613. private Messenger mClient = null; // Activity 에서 가져온 Messenger
  2614. String remote_get_home_devices1;
  2615. String remote_get_home_devices2;
  2616. String remote_get_home_devices3;
  2617. int skipCount = 0;
  2618. /**
  2619. * activity로부터 binding 된 Messenger
  2620. */
  2621. private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
  2622. @Override
  2623. public boolean handleMessage(Message msg) {
  2624. Log.w("test", "ControlService - message what : " + msg.what + " , msg.obj " + msg.obj);
  2625. switch (msg.what) {
  2626. case MSG_REGISTER_CLIENT:
  2627. mClient = msg.replyTo; // activity로부터 가져온
  2628. break;
  2629. case MSG_SEND_TO_SERVICE_DEVICES1:
  2630. remote_get_home_devices1 = (String) msg.obj; // activity로부터 가져온
  2631. break;
  2632. case MSG_SEND_TO_SERVICE_DEVICES2:
  2633. remote_get_home_devices2 = (String) msg.obj; // activity로부터 가져온
  2634. break;
  2635. case MSG_SEND_TO_SERVICE_DEVICES3:
  2636. remote_get_home_devices3 = (String) msg.obj; // activity로부터 가져온
  2637. break;
  2638. default:
  2639. break;
  2640. }
  2641. return false;
  2642. }
  2643. }));
  2644. private void sendMsgToActivity(int sendValue) {
  2645. try {
  2646. Bundle bundle = new Bundle();
  2647. bundle.putInt("fromService", sendValue);
  2648. Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
  2649. msg.setData(bundle);
  2650. if(mClient!=null) {
  2651. mClient.send(msg); // msg 보내기
  2652. }
  2653. } catch (Exception e) {
  2654. }
  2655. }
  2656. // 메인 서버 소켓 클래스
  2657. public class iMapSverSocket extends Thread {
  2658. ServerSocket svr;
  2659. private SSLServerSocket sslsvr;
  2660. boolean receiveSocketRun = true;
  2661. public iMapSverSocket() throws IOException {
  2662. /////////////////////////////////////////////////////////////////////
  2663. // 신형 단지서버 사용 유무를 가져온다.
  2664. /////////////////////////////////////////////////////////////////////
  2665. try {
  2666. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2667. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2668. wallpadDeviceSet.closeDB();
  2669. } catch (RuntimeException re) {
  2670. LogUtil.errorLogInfo("", TAG, re);
  2671. mNewDanjiServer = false;
  2672. } catch (Exception e) {
  2673. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2674. //e.printStackTrace();
  2675. LogUtil.errorLogInfo("", TAG, e);
  2676. mNewDanjiServer = false;
  2677. }
  2678. //////////////////////////////////////////////////
  2679. /////////////////////////////////////////////////////////////////////
  2680. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2681. /////////////////////////////////////////////////////////////////////
  2682. if (!mNewDanjiServer) {
  2683. svr = new ServerSocket(port);
  2684. } else {
  2685. int svrport = port + 1000;
  2686. Log.i(TAG, "============================================");
  2687. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2688. Log.i(TAG, "============================================");
  2689. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2690. sslsvr = sslServerSocket.getServerSocket();
  2691. }
  2692. }
  2693. public void run() {
  2694. while (receiveSocketRun) {
  2695. try {
  2696. Socket sock = null;
  2697. /////////////////////////////////////////////////////////////////////
  2698. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2699. /////////////////////////////////////////////////////////////////////
  2700. if (!mNewDanjiServer) {
  2701. sock = svr.accept();
  2702. } else {
  2703. sock = sslsvr.accept();
  2704. }
  2705. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2706. ProciMap.start();
  2707. } catch (IOException e) {
  2708. //e.printStackTrace();
  2709. LogUtil.errorLogInfo("", TAG, e);
  2710. }
  2711. }
  2712. }
  2713. public void destoryThread() {
  2714. receiveSocketRun = false;
  2715. try {
  2716. if (svr != null) {
  2717. svr.close();
  2718. svr = null;
  2719. }
  2720. if (sslsvr != null) {
  2721. sslsvr.close();
  2722. sslsvr = null;
  2723. }
  2724. } catch (RuntimeException re) {
  2725. LogUtil.errorLogInfo("", TAG, re);
  2726. } catch (Exception e) {
  2727. //e.printStackTrace();
  2728. LogUtil.errorLogInfo("", TAG, e);
  2729. }
  2730. }
  2731. }
  2732. public String getRemoteIPAddress(Socket Sock) {
  2733. try {
  2734. // Log.i(TAG, "[getRemoteIPAddress] == START ==");
  2735. if (Sock == null) return "10.0.1.1";
  2736. String strRemoteIP = Sock.getRemoteSocketAddress().toString();
  2737. String[] strSplited_01 = strRemoteIP.split(":");
  2738. String[] strSplited_02 = strSplited_01[0].split("/");
  2739. strRemoteIP = strSplited_02[1];
  2740. return strRemoteIP;
  2741. } catch (Exception e) {
  2742. Log.e(TAG, "[Exception] getRemoteIPAddress(Sock)");
  2743. e.printStackTrace();
  2744. return "10.0.1.1";
  2745. }
  2746. }
  2747. // iMAP 서버 소켓 처리
  2748. public class iMapSverSocketThread extends Thread {
  2749. private final Socket iMAPSock;
  2750. String strRcvMSG;
  2751. WallPadiMAPUpgrade upgradeProc;
  2752. Document doc;
  2753. public iMapSverSocketThread(Socket sock) {
  2754. iMAPSock = sock;
  2755. }
  2756. public void run() {
  2757. try {
  2758. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2759. InputStream InStm = iMAPSock.getInputStream();
  2760. iMAPSock.setSoLinger(true, 3000);
  2761. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2762. strRcvMSG = "";
  2763. String InBuffer;
  2764. int i = 0;
  2765. boolean bRcvOK = false;
  2766. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2767. /////////////////////////////////////////////////////////////////////
  2768. // 신형단지서버 미사용중일 경우 기존 코드로,
  2769. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2770. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2771. /////////////////////////////////////////////////////////////////////
  2772. if (!mNewDanjiServer) {
  2773. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2774. try {
  2775. if (MsgReader.ready()) {
  2776. try {
  2777. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2778. InBuffer = "";
  2779. while (MsgReader.ready()) {
  2780. long charCnt = MsgReader.read(ReadData);
  2781. InBuffer += new String(ReadData, 0, (int) charCnt);
  2782. }
  2783. if (InBuffer != null) strRcvMSG += InBuffer;
  2784. if (0 < InBuffer.indexOf("</imap>")) {
  2785. bRcvOK = true;
  2786. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2787. break;
  2788. }
  2789. } catch (RuntimeException re) {
  2790. LogUtil.errorLogInfo("", TAG, re);
  2791. return;
  2792. } catch (Exception e) {
  2793. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2794. //e.printStackTrace();
  2795. LogUtil.errorLogInfo("", TAG, e);
  2796. return;
  2797. }
  2798. } else {
  2799. Thread.sleep(100);
  2800. }
  2801. } catch (RuntimeException re) {
  2802. LogUtil.errorLogInfo("", TAG, re);
  2803. iMAPSock.close();
  2804. return;
  2805. } catch (Exception e) {
  2806. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  2807. iMAPSock.close();
  2808. //e.printStackTrace();
  2809. LogUtil.errorLogInfo("", TAG, e);
  2810. return;
  2811. }
  2812. }
  2813. } else {
  2814. // SSL 암호화 데이터 수신부
  2815. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  2816. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2817. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2818. try {
  2819. InBuffer = "";
  2820. long charCnt = MsgReader.read(ReadData);
  2821. if (charCnt > 0) {
  2822. InBuffer += new String(ReadData, 0, (int) charCnt);
  2823. strRcvMSG += InBuffer;
  2824. if (-1 < InBuffer.indexOf("</imap>")) {
  2825. bRcvOK = true;
  2826. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  2827. break;
  2828. }
  2829. } else {
  2830. Thread.sleep(100);
  2831. }
  2832. } catch (RuntimeException re) {
  2833. LogUtil.errorLogInfo("", TAG, re);
  2834. iMAPSock.close();
  2835. return;
  2836. } catch (Exception e) {
  2837. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  2838. iMAPSock.close();
  2839. //e.printStackTrace();
  2840. LogUtil.errorLogInfo("", TAG, e);
  2841. return;
  2842. }
  2843. }
  2844. }
  2845. if (!bRcvOK) {
  2846. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  2847. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  2848. Log.i(TAG, strRcvMSG);
  2849. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  2850. iMAPSock.close();
  2851. return;
  2852. }
  2853. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  2854. imapsvrlog("Socket read end accept </imap>\n" + strRcvMSG);
  2855. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2856. DocumentBuilder builder = factory.newDocumentBuilder();
  2857. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  2858. doc = builder.parse(istream);
  2859. Element elelist = doc.getDocumentElement();
  2860. NodeList items = elelist.getElementsByTagName("service");
  2861. Node item = items.item(0);
  2862. NamedNodeMap attrs = item.getAttributes();
  2863. String retXML = "";
  2864. for (int j = 0; j < attrs.getLength(); j++) {
  2865. Node attr = attrs.item(j);
  2866. String cmd;
  2867. if (attr.getNodeName().equalsIgnoreCase("type")) {
  2868. cmd = attr.getNodeValue();
  2869. if (cmd.equalsIgnoreCase("notice")) {
  2870. iMAPSock.close();
  2871. }
  2872. } else if (attr.getNodeName().equalsIgnoreCase("name")) {
  2873. cmd = attr.getNodeValue();
  2874. if (cmd.equalsIgnoreCase("event_notify")) {
  2875. retXML = ProcEventNotify(elelist);
  2876. } else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  2877. ProcElevatorinfo(elelist);
  2878. retXML = null;
  2879. } else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  2880. retXML = ProcCheckEpiceUpload(doc);
  2881. } else if (cmd.equalsIgnoreCase("update_news")) {
  2882. retXML = ProcUpdateNews(doc);
  2883. } else if (cmd.equalsIgnoreCase("update_weather")) {
  2884. retXML = ProcUpdateWeather(doc);
  2885. } else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  2886. retXML = ProcSchduleInquiry(doc);
  2887. } else if (cmd.equalsIgnoreCase("schedule_renew")) {
  2888. retXML = ProcSchduleRenew(doc);
  2889. } else if (cmd.equalsIgnoreCase("schdule")) {
  2890. String SvcType = "";
  2891. int k;
  2892. for (k = j + 1; k < attrs.getLength(); k++) {
  2893. Node attr1 = attrs.item(k);
  2894. SvcType = attr1.getNodeName();
  2895. if (SvcType.equalsIgnoreCase("shc_type")) {
  2896. SvcType = attr1.getNodeValue();
  2897. break;
  2898. }
  2899. }
  2900. retXML = ProcUpdateSchedule(elelist, SvcType);
  2901. } else if (cmd.equalsIgnoreCase("device_reset")) {
  2902. retXML = ProcDeviceReset(elelist);
  2903. } else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  2904. retXML = ProcNotifyparcel(doc);
  2905. } else if (cmd.equalsIgnoreCase("notify_post_info")) {
  2906. // 스마트우편함 연동 여부
  2907. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  2908. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  2909. DevSet.closeDB();
  2910. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  2911. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  2912. } else if (cmd.equalsIgnoreCase("get_security_mode")) {
  2913. String Dong = null;
  2914. String Ho = null;
  2915. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  2916. String result;
  2917. String modeStr = null;
  2918. int status = statusDB.GetAlarmStatus();
  2919. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  2920. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  2921. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  2922. else if (status == WallpadStatusData.GUARD_OUT)
  2923. modeStr = "unoccupied";
  2924. else if (status == WallpadStatusData.GUARD_OUT_WAIT)
  2925. modeStr = "waitunoccupied";
  2926. result = "ok";
  2927. } else {
  2928. modeStr = "null";
  2929. result = "fail";
  2930. }
  2931. try {
  2932. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  2933. Node GSM_item = GSM_items.item(0);
  2934. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  2935. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  2936. Node GSM_attr = GSM_attrsParam.item(k);
  2937. if (GSM_attr.getNodeName().equalsIgnoreCase("dong"))
  2938. Dong = trimquotation(GSM_attr.getNodeValue());
  2939. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho"))
  2940. Ho = trimquotation(GSM_attr.getNodeValue());
  2941. }
  2942. WallpadStatusData DBMGR = null;
  2943. DBMGR = new WallpadStatusData(getApplicationContext());
  2944. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  2945. DBMGR.closeDB();
  2946. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  2947. result = "fail";
  2948. }
  2949. } catch (RuntimeException re) {
  2950. LogUtil.errorLogInfo("", TAG, re);
  2951. result = "fail";
  2952. } catch (Exception e) {
  2953. result = "fail";
  2954. }
  2955. retXML = XMLHeader +
  2956. " <service type=\"reply\" name=\"get_security_mode\" result=\"" + result + "\">\r\n" +
  2957. " <home_info dong=\"" + AddrDong + "\" ho=\"" + AddrHo + "\" mode=\"" + modeStr + "\"/>\r\n" +
  2958. " </service>\r\n" +
  2959. "</imap>\r\n";
  2960. statusDB.closeDB();
  2961. } else if (cmd.equalsIgnoreCase("set_setup_info")) {
  2962. retXML = ProcSetsetup(doc);
  2963. } else if (cmd.equalsIgnoreCase("get_setup_info")) {
  2964. retXML = ProcGetsetup(doc);
  2965. } else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  2966. retXML = CheckPassword(doc);
  2967. } else if (cmd.equalsIgnoreCase("device_live_check")) {
  2968. retXML = ProcDeviceLiveCheck();
  2969. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  2970. retXML = ProcPairingHdevSyncAlarm(elelist);
  2971. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  2972. retXML = ProcPairingHdevSyncSecurity(elelist);
  2973. } else if (cmd.equalsIgnoreCase("notify_car_event")) {
  2974. retXML = ProcParkInformation(elelist);
  2975. } else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2976. retXML = ProcSmartKeyEvent(elelist);
  2977. } else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  2978. retXML = ProcParkInformation_cham_upis(elelist);
  2979. } else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  2980. retXML = ProcauscultateReq(doc);
  2981. } else if (cmd.equalsIgnoreCase("upgrade")) {
  2982. imapsvrlog("Enter Upgrade");
  2983. procUpgrade();
  2984. retXML = null;
  2985. } else if (cmd.equals("check_sip_activation")) {
  2986. String sip_result = "fail";
  2987. ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  2988. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  2989. //add KSJ 2021.11.02 socket addr 가져오기 위해 추가
  2990. String strIP = getRemoteIPAddress(iMAPSock);
  2991. //~add KSJ
  2992. // Jeff added below codes for call app (2018.01.25)
  2993. String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
  2994. for (int k = 0; k < rsi.size(); k++) {
  2995. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  2996. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  2997. sip_result = "ok";
  2998. break;
  2999. }
  3000. }
  3001. if(bWallPadCallLive && m_bWallpadCallScreen == false)
  3002. {
  3003. sip_result = "fail";
  3004. }
  3005. 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";
  3006. //add KSJ 2021.11.02 check_sip_activation msg recv 이후 wallpadcall app start
  3007. String[] IP_Parse = strIP.split("\\.");
  3008. Log.d(TAG, "1" + strIP);
  3009. //Log.d(TAG, "2" + strSplit[1]);
  3010. //Log.d(TAG, "3" + strSplit[2]);
  3011. //Log.d(TAG, "4" + strSplit[3]);
  3012. CALLTYPE eCallType = CALLTYPE.LOBBY;
  3013. if (IP_Parse[2].equals("0")) {
  3014. eCallType = CALLTYPE.LOBBY;
  3015. if (IP_Parse[3].equals("11"))
  3016. eCallType = CALLTYPE.FRONT;
  3017. } else if (IP_Parse[2].equals("129")) {
  3018. eCallType = CALLTYPE.FRONT;
  3019. } else {
  3020. eCallType = CALLTYPE.RESIDENCE;
  3021. }
  3022. if ((eCallType == CALLTYPE.LOBBY) || (eCallType == CALLTYPE.FRONT))
  3023. runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
  3024. }
  3025. //add KSJ 2021.11.02 stop_talking msg 추가 (wallpadcall 종료)
  3026. else if (cmd.equals("stop_talking")) {
  3027. Common.SendAppFinishReqBR(getApplicationContext());
  3028. }
  3029. //~add KSJ
  3030. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3031. retXML = iCMDProcDevList(doc);
  3032. } else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3033. retXML = iCMDProcGASControl(elelist);
  3034. } else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3035. // 현대건설 더펜트하우스 와 구분하여 처리
  3036. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3037. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  3038. mWallpadDeviceSet.closeDB();
  3039. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  3040. retXML = iCMDProcChumDamSmartLightControl(doc);
  3041. }
  3042. else {
  3043. retXML = iCMDProcSDPSmartLightControl(doc);
  3044. }
  3045. } else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3046. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3047. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3048. retXML = iCMDProc_I_LightControl(doc);
  3049. } else {
  3050. retXML = iCMDProcLivingLightControl(doc);
  3051. }
  3052. } else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3053. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  3054. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
  3055. || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
  3056. retXML = iCMDProcSDPConcentControl(doc);
  3057. } else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3058. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3059. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3060. } else {
  3061. retXML = iCMDProcMultiSWControl(doc);
  3062. }
  3063. } else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3064. retXML = iCMDProcDoorlockControl(doc);
  3065. } else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3066. retXML = iCMDProcTemperControl(doc);
  3067. } else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3068. retXML = iCMDProcModeControl(doc);
  3069. } else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3070. retXML = iCMDProcVentilControl(doc);
  3071. } else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3072. retXML = iCMDProcCurtainControl(doc);
  3073. } else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3074. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3075. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3076. retXML = iCMDProcEnergyMeterLightControl(doc);
  3077. } else {
  3078. retXML = iCMDProcLightControl(doc);
  3079. }
  3080. } else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3081. retXML = iCMDProcLightBatchControl(elelist);
  3082. }
  3083. else if (cmd.equalsIgnoreCase("remote_access_sysaircon")) {
  3084. retXML = iCMDProcSysairconControl(elelist);
  3085. }
  3086. //모바일 사용자 인증 관련 메시지
  3087. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3088. ProcMobileDevice_AuthNumber(elelist);
  3089. } else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3090. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3091. } else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3092. ProcMobileDevice_Delete(elelist);
  3093. } else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3094. retXML = ProcGetSmartKeyInfo(elelist);
  3095. } else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3096. retXML = ProcGetAppVersionInfo();
  3097. } else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3098. retXML = ProcIgateInitInfo(elelist);
  3099. } else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3100. retXML = ProcElecCarChargeEventInfo(elelist);
  3101. } else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3102. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3103. } else if (cmd.equalsIgnoreCase("check_call_option")) {
  3104. retXML = ProcCheckCallOption();
  3105. } else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3106. retXML = ProcChatSequence(elelist);
  3107. } else if (cmd.equalsIgnoreCase("chat_message")) {
  3108. retXML = ProcChatMessage(elelist);
  3109. } else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3110. retXML = ProcEvacuationLadderOpen(elelist);
  3111. } else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3112. retXML = SmartLightDetailInfo(elelist);
  3113. } else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3114. retXML = KNXDeviceDetailInfo(elelist);
  3115. } else if (cmd.equalsIgnoreCase("set_server_version")) {
  3116. retXML = ProcSetServerChange(elelist);
  3117. } else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
  3118. retXML = iCMDProcOnePass(elelist);
  3119. } else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3120. 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
  3121. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3122. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3123. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3124. }
  3125. } else if (cmd.equalsIgnoreCase("check_resident_safety")) {
  3126. retXML = iCMDProcResidentSafety(elelist);
  3127. }
  3128. break;
  3129. }
  3130. }
  3131. if (retXML != null) {
  3132. imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
  3133. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3134. byte[] outBF = retXML.getBytes("euc-kr");
  3135. outstream.write(outBF);
  3136. outstream.flush();
  3137. try {
  3138. Thread.sleep(3000);
  3139. } catch (RuntimeException re) {
  3140. LogUtil.errorLogInfo("", TAG, re);
  3141. } catch (Exception e) {
  3142. LogUtil.errorLogInfo("", TAG, e);
  3143. }
  3144. iMAPSock.close();
  3145. } else {
  3146. try {
  3147. iMAPSock.close();
  3148. } catch (RuntimeException re) {
  3149. LogUtil.errorLogInfo("", TAG, re);
  3150. } catch (Exception e) {
  3151. LogUtil.errorLogInfo("", TAG, e);
  3152. }
  3153. }
  3154. } catch (RuntimeException re) {
  3155. LogUtil.errorLogInfo("", TAG, re);
  3156. } catch (Exception e) {
  3157. try {
  3158. iMAPSock.close();
  3159. } catch (RuntimeException re) {
  3160. LogUtil.errorLogInfo("", TAG, re);
  3161. } catch (Exception E) {
  3162. LogUtil.errorLogInfo("", TAG, E);
  3163. }
  3164. LogUtil.errorLogInfo("", TAG, e);
  3165. }
  3166. }
  3167. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3168. private void procUpgrade() {
  3169. imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
  3170. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3171. String[] getstate = sdb.GetSystemUpdateStatus();
  3172. sdb.closeDB();
  3173. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3174. for (int i = 0; i < getstate.length; i++) {
  3175. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3176. }
  3177. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3178. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3179. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3180. }
  3181. }
  3182. // " 제거
  3183. private String trimquotation(String sen) {
  3184. sen = sen.replaceAll("\"", "");
  3185. return sen.trim();
  3186. }
  3187. //remote_auscultate 처리
  3188. public String ProcauscultateReq(Document Doc) {
  3189. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3190. NodeList items = Doc.getElementsByTagName("group");
  3191. Node item;
  3192. String itemname = null;
  3193. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3194. SettManager.DeleteSettingData();
  3195. SettManager.DropTable();
  3196. try {
  3197. for (int i = 0; i < items.getLength(); i++) {
  3198. item = items.item(i);
  3199. itemname = GetAttributeVal(item, "type");
  3200. String GetCNT = GetAttributeVal(item, "count");
  3201. if (Integer.parseInt(GetCNT) <= 0)
  3202. continue;
  3203. Element SettingItem = (Element) item;
  3204. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3205. for (int j = 0; j < SettingList.getLength(); j++) {
  3206. Node subdevListitem = SettingList.item(j);
  3207. String devname = trimquotation(subdevListitem.getTextContent());
  3208. SettManager.InsertSettingData(itemname, devname, j);
  3209. }
  3210. }
  3211. } catch (RuntimeException re) {
  3212. LogUtil.errorLogInfo("", TAG, re);
  3213. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3214. SettManager.closeDB();
  3215. return RetVal;
  3216. } catch (Exception e) {
  3217. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3218. //e.printStackTrace();
  3219. LogUtil.errorLogInfo("", TAG, e);
  3220. SettManager.closeDB();
  3221. return RetVal;
  3222. }
  3223. SettManager.closeDB();
  3224. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3225. StatusBeatRequested = true;
  3226. Intent intent = new Intent();
  3227. intent.setAction(define.NOTIFY_ACNAME);
  3228. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
  3229. sendBroadcast(intent);
  3230. return RetVal;
  3231. }
  3232. public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
  3233. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  3234. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n" +
  3235. "<service type=\"request\" name=\"remote_auscultate\">\r\n" +
  3236. " <guidemap devtype=\"homedev\" count=\"4\">\r\n" +
  3237. " <group type=\"ctrl_device\" count=\"5\">\r\n" +
  3238. " <unit>\"light\"</unit>\r\n" +
  3239. " <unit>\"thermostat\"</unit>\r\n" +
  3240. " <unit>\"gas\"</unit>\r\n" +
  3241. " <unit>\"doorlock\"</unit>\r\n" +
  3242. " <unit>\"ventil\"</unit>\r\n" +
  3243. " </group>\r\n" +
  3244. " <group type=\"talk_device\" count=\"4\">\r\n" +
  3245. " <unit>\"sub_homedev\"</unit>\r\n" +
  3246. " <unit>\"kitchen_tv\"</unit>\r\n" +
  3247. " <unit>\"bath_tv\"</unit>\r\n" +
  3248. " <unit>\"bath_phone\"</unit>\r\n" +
  3249. " </group>\r\n" +
  3250. " <group type=\"sensor\" count=\"6\">\r\n" +
  3251. " <unit>\"magnetic\"</unit>\r\n" +
  3252. " <unit>\"bugout\"</unit>\r\n" +
  3253. " <unit>\"bugin\"</unit>\r\n" +
  3254. " <unit>\"fire\"</unit>\r\n" +
  3255. " <unit>\"gas\"</unit>\r\n" +
  3256. " <unit>\"emergency\"</unit>\r\n" +
  3257. " </group>\r\n" +
  3258. " <group type=\"extended\" count=\"4\">\r\n" +
  3259. " <unit>\"gateway\"</unit>\r\n" +
  3260. " <unit>\"smartswitch\"</unit>\r\n" +
  3261. " <unit>\"handy\"</unit>\r\n" +
  3262. " <unit>\"energymeter\"</unit>\r\n" +
  3263. " </group>\r\n" +
  3264. " </guidemap>\r\n" +
  3265. "</service>\r\n" +
  3266. "</imap>\r\n";
  3267. try {
  3268. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3269. DocumentBuilder builder = factory.newDocumentBuilder();
  3270. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3271. Document doc = builder.parse(istream);
  3272. NodeList items = doc.getElementsByTagName("group");
  3273. Node item;
  3274. String itemname = null;
  3275. SettManager.DeleteSettingData();
  3276. SettManager.DropTable();
  3277. for (int i = 0; i < items.getLength(); i++) {
  3278. item = items.item(i);
  3279. itemname = GetAttributeVal(item, "type");
  3280. String GetCNT = GetAttributeVal(item, "count");
  3281. if (Integer.parseInt(GetCNT) <= 0)
  3282. continue;
  3283. Element SettingItem = (Element) item;
  3284. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3285. for (int j = 0; j < SettingList.getLength(); j++) {
  3286. Node subdevListitem = SettingList.item(j);
  3287. String devname = trimquotation(subdevListitem.getTextContent());
  3288. SettManager.InsertSettingData(itemname, devname, j);
  3289. }
  3290. }
  3291. } catch (RuntimeException re) {
  3292. LogUtil.errorLogInfo("", TAG, re);
  3293. } catch (Exception e) {
  3294. //e.printStackTrace();
  3295. LogUtil.errorLogInfo("", TAG, e);
  3296. }
  3297. }
  3298. String MakeFailMessage(String msg) {
  3299. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\"" + msg + "\"</first_failed>\r\n</service>\r\n</imap>";
  3300. }
  3301. //SetInfo의 각 항목들의 무결성 확인
  3302. final String isUse = "사용함";
  3303. final String isNotUse = "사용안함";
  3304. boolean CheckSubdevData(String devName, String devData) {
  3305. String[] SplitedMSG;
  3306. try {
  3307. if (devName.equals("가스밸브")) {
  3308. SplitedMSG = devData.split("[(]");
  3309. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3310. String UseStr = SplitedMSG[2].split("[)]")[0];
  3311. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3312. } else if (devName.equals("디지털도어락")) {
  3313. SplitedMSG = devData.split("[(]");
  3314. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3315. String[] UseStr = SplitedMSG[2].split("[)]");
  3316. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3317. if (!UseStr[1].equals("종류")) return false;
  3318. UseStr = SplitedMSG[3].split("[)]");
  3319. if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
  3320. } else if (devName.equals("온도조절기")) {
  3321. SplitedMSG = devData.split("[(]");
  3322. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3323. String[] UseStr = SplitedMSG[2].split("[)]");
  3324. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3325. } else if (devName.equals("조명제어기")) {
  3326. SplitedMSG = devData.split("[(]");
  3327. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3328. String[] UseStr = SplitedMSG[2].split("[)]");
  3329. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3330. /*
  3331. if (!UseStr[1].equals("종류"))
  3332. return false;
  3333. UseStr = SplitedMSG[3].split("[)]");
  3334. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3335. return false;
  3336. */
  3337. } else if (devName.equals("환기시스템")) {
  3338. SplitedMSG = devData.split("[(]");
  3339. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3340. String[] UseStr = SplitedMSG[2].split("[)]");
  3341. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3342. /*
  3343. if (!UseStr[1].equals("종류"))
  3344. return false;
  3345. UseStr = SplitedMSG[3].split("[)]");
  3346. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  3347. return false;
  3348. */
  3349. } else if (devName.equals("시스템에어컨")) {
  3350. SplitedMSG = devData.split("[(]");
  3351. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3352. String[] UseStr = SplitedMSG[2].split("[)]");
  3353. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3354. } else if (devName.equals("전동커튼")) {
  3355. SplitedMSG = devData.split("[(]");
  3356. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3357. String[] UseStr = SplitedMSG[2].split("[)]");
  3358. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3359. /*
  3360. if (!UseStr[1].equals("종류"))
  3361. return false;
  3362. UseStr = SplitedMSG[3].split("[)]");
  3363. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  3364. return false;
  3365. */
  3366. } else if (devName.equals("실시간검침기")) {
  3367. SplitedMSG = devData.split("[(]");
  3368. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3369. String[] UseStr = SplitedMSG[2].split("[)]");
  3370. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3371. } else if (devName.equals("스마트스위치&일괄소등")) {
  3372. SplitedMSG = devData.split("[(]");
  3373. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3374. String[] UseStr = SplitedMSG[2].split("[)]");
  3375. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3376. /*
  3377. if (!UseStr[1].equals("종류"))
  3378. return false;
  3379. UseStr = SplitedMSG[3].split("[)]");
  3380. if (!UseStr[0].equals("대외향스마트스위치")&&
  3381. !UseStr[0].equals("대외향일괄소등제어기")&&
  3382. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  3383. !UseStr[0].equals("현산향스마트스위치")&&
  3384. !UseStr[0].equals("현산향LCD스마트스위치"))
  3385. return false;
  3386. */
  3387. } else if (devName.equals("무선리모컨")) {
  3388. SplitedMSG = devData.split("[(]");
  3389. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3390. String[] UseStr = SplitedMSG[2].split("[)]");
  3391. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3392. } else if (devName.equals("현관카메라")) {
  3393. SplitedMSG = devData.split("[(]");
  3394. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3395. String[] UseStr = SplitedMSG[2].split("[)]");
  3396. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3397. /*
  3398. if (!UseStr[1].equals("종류"))
  3399. return false;
  3400. UseStr = SplitedMSG[3].split("[)]");
  3401. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  3402. return false;
  3403. */
  3404. } else if (devName.equals("공지사항")) {
  3405. SplitedMSG = devData.split("[(]");
  3406. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3407. String[] UseStr = SplitedMSG[2].split("[)]");
  3408. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3409. } else if (devName.equals("날씨")) {
  3410. SplitedMSG = devData.split("[(]");
  3411. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3412. String[] UseStr = SplitedMSG[2].split("[)]");
  3413. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3414. } else if (devName.equals("메모")) {
  3415. SplitedMSG = devData.split("[(]");
  3416. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3417. String[] UseStr = SplitedMSG[2].split("[)]");
  3418. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3419. } else if (devName.equals("전자액자")) {
  3420. SplitedMSG = devData.split("[(]");
  3421. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3422. String[] UseStr = SplitedMSG[2].split("[)]");
  3423. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3424. } else if (devName.equals("일정표")) {
  3425. SplitedMSG = devData.split("[(]");
  3426. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3427. String[] UseStr = SplitedMSG[2].split("[)]");
  3428. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3429. } else if (devName.equals("주차확인")) {
  3430. SplitedMSG = devData.split("[(]");
  3431. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3432. String[] UseStr = SplitedMSG[2].split("[)]");
  3433. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3434. /*
  3435. UseStr = SplitedMSG[3].split("[)]");
  3436. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3437. return false;
  3438. */
  3439. } else if (devName.equals("시간설정")) {
  3440. SplitedMSG = devData.split("[(]");
  3441. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3442. String[] UseStr = SplitedMSG[2].split("[)]");
  3443. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3444. } else if (devName.equals("원격검침")) {
  3445. SplitedMSG = devData.split("[(]");
  3446. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3447. String[] UseStr = SplitedMSG[2].split("[)]");
  3448. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3449. } else if (devName.equals("뮤직")) {
  3450. SplitedMSG = devData.split("[(]");
  3451. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3452. String[] UseStr = SplitedMSG[2].split("[)]");
  3453. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3454. } else if (devName.equals("영상재생")) {
  3455. SplitedMSG = devData.split("[(]");
  3456. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3457. String[] UseStr = SplitedMSG[2].split("[)]");
  3458. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3459. } else if (devName.equals("CCTV")) {
  3460. SplitedMSG = devData.split("[(]");
  3461. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3462. String[] UseStr = SplitedMSG[2].split("[)]");
  3463. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3464. /*
  3465. UseStr = SplitedMSG[3].split("[)]");
  3466. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3467. return false;
  3468. */
  3469. } else if (devName.equals("명칭설정")) {
  3470. SplitedMSG = devData.split("[(]");
  3471. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3472. String[] UseStr = SplitedMSG[2].split("[)]");
  3473. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3474. } else if (devName.equals("출동경비")) {
  3475. SplitedMSG = devData.split("[(]");
  3476. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3477. String[] UseStr = SplitedMSG[2].split("[)]");
  3478. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3479. } else if (devName.equals("경비실영상통화")) {
  3480. SplitedMSG = devData.split("[(]");
  3481. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3482. String[] UseStr = SplitedMSG[2].split("[)]");
  3483. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3484. } else if (devName.equals("엘리베이터")) {
  3485. SplitedMSG = devData.split("[(]");
  3486. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3487. String[] UseStr = SplitedMSG[2].split("[)]");
  3488. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3489. /*
  3490. UseStr = SplitedMSG[3].split("[)]");
  3491. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3492. return false;
  3493. */
  3494. } else if (devName.equals("현장특화기능")) {
  3495. SplitedMSG = devData.split("[(]");
  3496. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3497. String[] UseStr = SplitedMSG[2].split("[)]");
  3498. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3499. /*
  3500. UseStr = SplitedMSG[3].split("[)]");
  3501. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3502. return false;
  3503. */
  3504. } else if (devName.equals("월패드카메라")) {
  3505. SplitedMSG = devData.split("[(]");
  3506. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3507. String[] UseStr = SplitedMSG[2].split("[)]");
  3508. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3509. } else if (devName.equals("무드등")) {
  3510. SplitedMSG = devData.split("[(]");
  3511. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3512. String[] UseStr = SplitedMSG[2].split("[)]");
  3513. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3514. /*
  3515. UseStr = SplitedMSG[3].split("[)]");
  3516. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3517. return false;
  3518. */
  3519. } else if (devName.equals("피난사다리")) {
  3520. SplitedMSG = devData.split("[(]");
  3521. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3522. String[] UseStr = SplitedMSG[2].split("[)]");
  3523. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3524. } else if (devName.equals("동체설정")) {
  3525. return true;
  3526. /*
  3527. SplitedMSG = devData.split("[(]");
  3528. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3529. return false;
  3530. String[] UseStr = SplitedMSG[2].split("[)]");
  3531. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3532. return false;
  3533. if (UseStr[0].equals(isNotUse)) return true;
  3534. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3535. return false;
  3536. for (int i=3; i < SplitedMSG.length; i++)
  3537. {
  3538. UseStr = SplitedMSG[i].split("[)]");
  3539. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3540. return false;
  3541. if (i != SplitedMSG.length-1)
  3542. {
  3543. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3544. return false;
  3545. }
  3546. }
  3547. */
  3548. } else if (devName.equals("알람발생")) {
  3549. SplitedMSG = devData.split("[(]");
  3550. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3551. String[] UseStr = SplitedMSG[2].split("[)]");
  3552. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3553. } else if (devName.equals("UI순서")) {
  3554. SplitedMSG = devData.split("[(]");
  3555. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3556. String[] UseStr = SplitedMSG[2].split("[)]");
  3557. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3558. } else {
  3559. Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
  3560. Log.w("iMAP", "Return true");
  3561. return true;
  3562. }
  3563. } catch (RuntimeException re) {
  3564. LogUtil.errorLogInfo("", TAG, re);
  3565. return false;
  3566. } catch (Exception e) {
  3567. //e.printStackTrace();
  3568. LogUtil.errorLogInfo("", TAG, e);
  3569. return false;
  3570. }
  3571. return true;
  3572. }
  3573. public String ProcSetsetup(Document ele) {
  3574. Common.DebugLog("ProcSetsetup------------------------->");
  3575. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3576. NodeList items = ele.getElementsByTagName("setting");
  3577. Node item;
  3578. String itemname = null;
  3579. String dateData = null;
  3580. String heartbeatP = null;
  3581. String Versions = null;
  3582. String SdbAccInit_Str = null;
  3583. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3584. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3585. if (!SettManager.StartTransaction()) {
  3586. ResetFlag = false;
  3587. RetVal += "\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3588. SettManager.EndTransaction(false);
  3589. SettManager.closeDB();
  3590. return RetVal;
  3591. }
  3592. try {
  3593. for (int i = 0; i < items.getLength(); i++) {
  3594. item = items.item(i);
  3595. itemname = GetAttributeVal(item, "name");
  3596. if (itemname != null) {
  3597. if (itemname.equals("beat_time")) {
  3598. heartbeatP = GetAttributeVal(item, "value");
  3599. } else if (itemname.equals("ver_setting")) {
  3600. Versions = GetAttributeVal(item, "value");
  3601. } else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3602. Element guardlist = (Element) item;
  3603. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3604. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3605. else continue;
  3606. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3607. Node GuardListitem = GuardCTList.item(j);
  3608. String guardname = GetAttributeVal(GuardListitem, "name");
  3609. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3610. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3611. }
  3612. } else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3613. Element subdevList = (Element) item;
  3614. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3615. for (int j = 0; j < SubDevList.getLength(); j++) {
  3616. Node subdevListitem = SubDevList.item(j);
  3617. String devname = GetAttributeVal(subdevListitem, "name");
  3618. String devval = GetAttributeVal(subdevListitem, "value");
  3619. if (devname != null && devval != null) {
  3620. devname = devname.replaceAll("\\p{Z}", "");
  3621. devval = devval.replaceAll("\\p{Z}", "");
  3622. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  3623. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3624. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3625. }
  3626. if (CheckSubdevData(devname, devval) == false) {
  3627. ResetFlag = false;
  3628. Log.w("iMAP", "Set Setup Fail name : " + devname + " Value : " + devval);
  3629. SettManager.EndTransaction(false);
  3630. SettManager.closeDB();
  3631. return MakeFailMessage(devname);
  3632. }
  3633. String[] SettingDBValue = SettManager.GetSettingData(devname);
  3634. if (SettingDBValue != null) {
  3635. String devInfo = SettingDBValue[1];
  3636. if (devInfo.equals(devval) == false) {
  3637. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3638. Log.w("iMAP", "DB Setup Value : " + devInfo);
  3639. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3640. ResetFlag = true;
  3641. }
  3642. } else {
  3643. Log.w("iMAP", "DB No Setup Name and Value");
  3644. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3645. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3646. ResetFlag = true;
  3647. }
  3648. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3649. if (devname.equals("로고설정")) {
  3650. String devInfo = devval;
  3651. devInfo = devInfo.replace('(', '_');
  3652. devInfo = devInfo.replace(':', '_');
  3653. devInfo = devInfo.replace(')', '_');
  3654. String[] DetailInfo = devInfo.split("_");
  3655. int LogoType = 0;
  3656. if (DetailInfo[5].equals("표시안함") == true) {
  3657. LogoType = 0;
  3658. } else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3659. LogoType = 1;
  3660. } else if (DetailInfo[5].equals("양우내안애") == true) {
  3661. LogoType = 2;
  3662. } else if (DetailInfo[5].equals("GSITM") == true) {
  3663. LogoType = 3;
  3664. } else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3665. LogoType = 4;
  3666. } else if (DetailInfo[5].equals("거실조명표시") == true) {
  3667. LogoType = 5;
  3668. } else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3669. LogoType = 6;
  3670. } else if (DetailInfo[5].equals("기타1") == true) {
  3671. LogoType = 7;
  3672. } else if (DetailInfo[5].equals("기타2") == true) {
  3673. LogoType = 8;
  3674. }
  3675. if ((LogoType >= 0) && (LogoType <= 8)) {
  3676. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3677. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3678. }
  3679. } else if (devname.equals("엘리베이터위젯복구")) {
  3680. String devInfo = devval;
  3681. devInfo = devInfo.replace('(', '_');
  3682. devInfo = devInfo.replace(':', '_');
  3683. devInfo = devInfo.replace(')', '_');
  3684. String[] DetailInfo = devInfo.split("_");
  3685. if (DetailInfo[3].equals("사용함") == true) {
  3686. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3687. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3688. }
  3689. } else if (devname.equals("분전반알람설정")) {
  3690. try {
  3691. String devInfo = devval;
  3692. devInfo = devInfo.replace('(', '_');
  3693. devInfo = devInfo.replace(':', '_');
  3694. devInfo = devInfo.replace(')', '_');
  3695. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3696. //[0] - 기기번호
  3697. //[1] - 회로수
  3698. //[2] - 기기이름
  3699. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3700. //[4] - 명칭
  3701. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3702. String[] DetailInfo = devInfo.split("_");
  3703. for (int a = 0; a < DetailInfo.length; a++) {
  3704. if (DetailInfo[a].equals("누적전력초기화")) {
  3705. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3706. if ((a + 1) <= DetailInfo.length) {
  3707. // 설정정보가 존재해야 인식하도록 함
  3708. if (DetailInfo[a + 1].equals("1")) {
  3709. // 1(사용함) 일때
  3710. if (sdbAPI != null) {
  3711. if (sdbAPI.Set_AccPwReset() >= 0) {
  3712. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3713. } else {
  3714. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3715. }
  3716. }
  3717. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3718. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3719. }
  3720. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3721. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3722. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3723. }
  3724. }
  3725. }
  3726. } catch (RuntimeException re) {
  3727. LogUtil.errorLogInfo("", TAG, re);
  3728. } catch (Exception e) {
  3729. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3730. //e.printStackTrace();
  3731. LogUtil.errorLogInfo("", TAG, e);
  3732. }
  3733. } else if (devname.equals("욕실폰통화음량값")) {
  3734. Intent Iintent = new Intent();
  3735. Iintent.setAction(define.NOTIFY_ACNAME);
  3736. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3737. sendBroadcast(Iintent);
  3738. } else if (devname.equals("주방TV통화음량값")) {
  3739. Intent Iintent = new Intent();
  3740. Iintent.setAction(define.NOTIFY_ACNAME);
  3741. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3742. sendBroadcast(Iintent);
  3743. } else if (devname.equals("현관카메라")) {
  3744. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  3745. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3746. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3747. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  3748. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3749. String devInfo = devval;
  3750. if (devInfo != null) {
  3751. devInfo = devInfo.replace('(', '_');
  3752. devInfo = devInfo.replace(':', '_');
  3753. devInfo = devInfo.replace(')', '_');
  3754. String[] DetailInfo = devInfo.split("_");
  3755. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3756. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  3757. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3758. if (mIOInterface != null)
  3759. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3760. } else {
  3761. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  3762. if (mIOInterface != null)
  3763. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3764. }
  3765. }
  3766. }
  3767. }
  3768. } else if (devname.equals("거동수상자녹화")) {
  3769. String devInfo = devval;
  3770. devInfo = devInfo.replace('(', '_');
  3771. devInfo = devInfo.replace(':', '_');
  3772. devInfo = devInfo.replace(')', '_');
  3773. String[] DetailInfo = devInfo.split("_");
  3774. } else if (devname.equals("스마트현관카메라좌우반전")) {
  3775. String devInfo = devval;
  3776. if (devInfo != null) {
  3777. devInfo = devInfo.replace('(', '_');
  3778. devInfo = devInfo.replace(':', '_');
  3779. devInfo = devInfo.replace(')', '_');
  3780. }
  3781. String[] DetailInfo = devInfo.split("_");
  3782. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3783. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3784. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3785. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3786. } else {
  3787. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  3788. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  3789. }
  3790. }
  3791. } else {
  3792. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3793. }
  3794. }
  3795. }
  3796. } else if (itemname.equals("datetime")) {
  3797. dateData = GetAttributeVal(item, "value");
  3798. } else {
  3799. String GetVal = GetAttributeVal(item, "value");
  3800. if (GetVal != null) {
  3801. if (!GetVal.equals("list")) {
  3802. if (itemname.equals("site_code")) {
  3803. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3804. if (Existing_SiteCode_Array == null) {
  3805. ResetFlag = true;
  3806. } else {
  3807. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3808. if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
  3809. ResetFlag = true;
  3810. }
  3811. }
  3812. }
  3813. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3814. } else {
  3815. String GetCNT = GetAttributeVal(item, "count");
  3816. if (Integer.parseInt(GetCNT) <= 0) continue;
  3817. Element SettingItem = (Element) item;
  3818. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3819. for (int j = 0; j < SettingList.getLength(); j++) {
  3820. Node subdevListitem = SettingList.item(j);
  3821. String devname = GetAttributeVal(subdevListitem, "name");
  3822. String devval = GetAttributeVal(subdevListitem, "value");
  3823. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3824. }
  3825. }
  3826. }
  3827. }
  3828. }
  3829. }
  3830. } catch (RuntimeException re) {
  3831. LogUtil.errorLogInfo("", TAG, re);
  3832. ResetFlag = false;
  3833. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3834. SettManager.EndTransaction(false);
  3835. SettManager.closeDB();
  3836. return RetVal;
  3837. } catch (Exception e) {
  3838. ResetFlag = false;
  3839. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3840. //e.printStackTrace();
  3841. LogUtil.errorLogInfo("", TAG, e);
  3842. SettManager.EndTransaction(false);
  3843. SettManager.closeDB();
  3844. return RetVal;
  3845. }
  3846. SettManager.EndTransaction(true);
  3847. SettManager.closeDB();
  3848. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3849. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3850. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3851. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3852. }
  3853. if (AfterTransactionTodoList != null) {
  3854. if (AfterTransactionTodoList.size() > 0) {
  3855. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3856. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3857. if (afterTransactionTodoListData != null) {
  3858. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3859. WallpadSalesSampleData mWallpadSalesSampleData;
  3860. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3861. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3862. mWallpadSalesSampleData.closeDB();
  3863. } else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3864. //ifdb에 있는지
  3865. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3866. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3867. int result = devSet.Get_Elevator_Info();
  3868. devSet.closeDB();
  3869. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3870. // 엘리베이터가 사용함이면
  3871. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3872. boolean result_get_restoreUseOrNot;
  3873. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3874. if (wdb != null) {
  3875. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3876. if (result_get_restoreUseOrNot == false) {
  3877. wdb.SetElevator_Widget_Restore(true);
  3878. //위젯 DB 초기화
  3879. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3880. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3881. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3882. devSet2.initWidgetData();
  3883. devSet2.closeDB();
  3884. }
  3885. }
  3886. wdb.closeDB();
  3887. }
  3888. }
  3889. }
  3890. }
  3891. }
  3892. }
  3893. }
  3894. if (dateData != null) {
  3895. try {
  3896. int year = Integer.parseInt(dateData.substring(0, 4));
  3897. int month = Integer.parseInt(dateData.substring(4, 6));
  3898. int day = Integer.parseInt(dateData.substring(6, 8));
  3899. int hour = Integer.parseInt(dateData.substring(8, 10));
  3900. int min = Integer.parseInt(dateData.substring(10, 12));
  3901. int sec = Integer.parseInt(dateData.substring(12, 14));
  3902. Calendar nowdate = new GregorianCalendar();
  3903. long settedtime = nowdate.getTimeInMillis();
  3904. nowdate.set(Calendar.YEAR, year);
  3905. nowdate.set(Calendar.MONTH, month);
  3906. nowdate.set(Calendar.DAY_OF_MONTH, day);
  3907. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  3908. nowdate.set(Calendar.MINUTE, min);
  3909. nowdate.set(Calendar.SECOND, sec);
  3910. long bootupmil = nowdate.getTimeInMillis();
  3911. if (Math.abs(bootupmil - settedtime) > 5000) {
  3912. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3913. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  3914. DBMGR.closeDB();
  3915. Intent Iintent = new Intent();
  3916. Iintent.setAction(define.NOTIFY_ACNAME);
  3917. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  3918. sendBroadcast(Iintent);
  3919. }
  3920. } catch (RuntimeException re) {
  3921. LogUtil.errorLogInfo("", TAG, re);
  3922. } catch (Exception e) {
  3923. //e.printStackTrace();
  3924. LogUtil.errorLogInfo("", TAG, e);
  3925. }
  3926. }
  3927. if (heartbeatP != null) {
  3928. try {
  3929. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3930. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  3931. DBMGR.closeDB();
  3932. } catch (RuntimeException re) {
  3933. LogUtil.errorLogInfo("", TAG, re);
  3934. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3935. SettManager.closeDB();
  3936. return RetVal;
  3937. } catch (Exception e) {
  3938. //e.printStackTrace();
  3939. LogUtil.errorLogInfo("", TAG, e);
  3940. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3941. SettManager.closeDB();
  3942. return RetVal;
  3943. }
  3944. }
  3945. if (Versions != null) {
  3946. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3947. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  3948. DBMGR.SetSettingVer(Versions);
  3949. DBMGR.closeDB();
  3950. }
  3951. Intent intent = new Intent();
  3952. intent.setAction(define.NOTIFY_ACNAME);
  3953. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  3954. getApplicationContext().sendBroadcast(intent);
  3955. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3956. return RetVal;
  3957. }
  3958. public String ProcNotifyparcel(Document doc) {
  3959. String moveInfo = "null";
  3960. String boxNo = "null";
  3961. String serviceInfo = "null";
  3962. String receiverInfo = "null";
  3963. String message = "null";
  3964. int remainCnt = 0;
  3965. try {
  3966. NodeList param = doc.getElementsByTagName("move_info");
  3967. Node item = param.item(0);
  3968. moveInfo = trimquotation(item.getTextContent());
  3969. param = doc.getElementsByTagName("params");
  3970. item = param.item(0);
  3971. if (item != null) {
  3972. boxNo = GetAttributeVal(item, "box_num");
  3973. serviceInfo = GetAttributeVal(item, "service_info");
  3974. receiverInfo = GetAttributeVal(item, "receiver_info");
  3975. message = GetAttributeVal(item, "message");
  3976. if (message != null) {
  3977. String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
  3978. if (msgList[0].equalsIgnoreCase("remains")) {
  3979. remainCnt = Integer.parseInt(msgList[1]);
  3980. if (remainCnt > 0) {
  3981. wakeupLCD();
  3982. Intent intent = new Intent();
  3983. intent.setAction(define.NOTIFY_ACNAME);
  3984. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  3985. intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
  3986. intent.putExtra("BOX_NO", boxNo);
  3987. intent.putExtra("SERVICE_INFO", serviceInfo);
  3988. intent.putExtra("RECEIVER_INFO", receiverInfo);
  3989. intent.putExtra("REMAIN_CNT", remainCnt);
  3990. getApplicationContext().sendBroadcast(intent);
  3991. }
  3992. }
  3993. }
  3994. }
  3995. String retVal = XMLHeader +
  3996. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n" +
  3997. "</imap>\r\n";
  3998. return retVal;
  3999. } catch (RuntimeException re) {
  4000. LogUtil.errorLogInfo("", TAG, re);
  4001. String retVal = XMLHeader +
  4002. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4003. "</imap>\r\n";
  4004. return retVal;
  4005. } catch (Exception e) {
  4006. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4007. //e.printStackTrace();
  4008. LogUtil.errorLogInfo("", TAG, e);
  4009. String retVal = XMLHeader +
  4010. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4011. "</imap>\r\n";
  4012. return retVal;
  4013. }
  4014. }
  4015. public String ProcNotiPostInfo(Document doc) {
  4016. NodeList param = doc.getElementsByTagName("move_info");
  4017. Node item = param.item(0);
  4018. String aa = item.getTextContent();
  4019. aa = trimquotation(aa);
  4020. if (item != null) {
  4021. String info = item.getTextContent();
  4022. if (info != null) {
  4023. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4024. if (info.contains("post_in")) { // 우편물 보관
  4025. wakeupLCD();
  4026. int itemCount = -1;
  4027. param = doc.getElementsByTagName("params");
  4028. item = param.item(0);
  4029. if (item != null) {
  4030. String devname = GetAttributeVal(item, "message");
  4031. if (devname != null) {
  4032. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4033. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4034. if (msgList[0].equalsIgnoreCase("remains")) {
  4035. itemCount = Integer.parseInt(msgList[1]);
  4036. }
  4037. }
  4038. }
  4039. }
  4040. if (itemCount > 0) {
  4041. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4042. Intent intent = new Intent();
  4043. intent.setAction(define.NOTIFY_ACNAME);
  4044. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4045. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4046. intent.putExtra("ITEM", itemCount);
  4047. getApplicationContext().sendBroadcast(intent);
  4048. }
  4049. }
  4050. }
  4051. }
  4052. String retVal = XMLHeader +
  4053. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n" +
  4054. "</imap>\r\n";
  4055. return retVal;
  4056. }
  4057. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4058. public String ProcNotifypark(Document doc)
  4059. {
  4060. String MoveInfo = "none";
  4061. NodeList param = doc.getElementsByTagName("destination");
  4062. Node item = param.item(0);
  4063. if (item != null)
  4064. {
  4065. String dong = GetAttributeVal(item, "id_high").trim();
  4066. String ho = GetAttributeVal(item, "id_low").trim();
  4067. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4068. return (XMLHeader +
  4069. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4070. "</imap>\r\n");
  4071. }
  4072. param = doc.getElementsByTagName("move_info");
  4073. item = param.item(0);
  4074. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4075. param = doc.getElementsByTagName("params");
  4076. item = param.item(0);
  4077. if (item != null)
  4078. {
  4079. String carnum = GetAttributeVal(item, "car_num");
  4080. String locinfo = GetAttributeVal(item, "loc_info");
  4081. String msg = GetAttributeVal(item, "message");
  4082. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4083. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4084. parkdb.closeDB();Intent intent = new Intent();
  4085. intent.setAction(define.NOTIFY_ACNAME);
  4086. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4087. getApplicationContext().sendBroadcast(intent);
  4088. }
  4089. String retVal = XMLHeader +
  4090. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4091. "</imap>\r\n";
  4092. return retVal;
  4093. }
  4094. */
  4095. public String ProcGetsetup(Document doc) {
  4096. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4097. NodeList items = doc.getElementsByTagName("variable");
  4098. String RetVal = XMLHeader + "<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n" +
  4099. " <guidemap devtype=\"homedev\" count=\"" + items.getLength() + "\">\r\n";
  4100. Node item;
  4101. try {
  4102. for (int i = 0; i < items.getLength(); i++) {
  4103. item = items.item(i);
  4104. //String mRealTimeMeterData = item.getNodeValue();
  4105. String data = trimquotation(item.getTextContent());
  4106. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4107. if (gData.size() == 1) {
  4108. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + gData.get(0)[1] + "\" />\r\n";
  4109. } else if (gData.size() > 1) {
  4110. RetVal += " <setting name=\"" + data + "\" count=\"" + gData.size() + "\" value=\"list\" >\r\n";
  4111. RetVal += " <list name=\"DeviceInfo\" value=\"" + Build.MODEL + "/" + getAOSVerCode() + "\" />\r\n";
  4112. for (int k = 0; k < gData.size(); k++) {
  4113. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4114. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4115. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4116. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4117. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4118. }
  4119. RetVal += " <list name=\"" + gData.get(k)[0] + "\" value=\"" + gData.get(k)[1] + "\" />\r\n";
  4120. }
  4121. if (bAirQualityEnable) {
  4122. RetVal += " <list name=\"공기질센서버전\" value=\"" + getAirQualityInfo() + "\" />\r\n";
  4123. }
  4124. RetVal += " </setting>\r\n";
  4125. } else {
  4126. if (data.equals("beat_time")) {
  4127. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4128. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4129. DBMGR.closeDB();
  4130. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + heartbeatP + "\" />\r\n";
  4131. } else if (data.equals("ver_setting")) {
  4132. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4133. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + DBMGR.GetSettingVer() + "\" />\r\n";
  4134. DBMGR.closeDB();
  4135. } else if (data.equals("datetime")) {
  4136. Calendar cal = new GregorianCalendar();
  4137. 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";
  4138. } else if (data.equals("security_state")) {
  4139. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4140. int alarmST = DBMGR.GetAlarmStatus();
  4141. String SEC_ST;
  4142. if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
  4143. else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
  4144. else SEC_ST = "normal";
  4145. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + SEC_ST + "\" />\r\n";
  4146. DBMGR.closeDB();
  4147. } else if (data.equals("sensor_state")) {
  4148. int senIDX = 0;
  4149. String resultStr = "";
  4150. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4151. int BugSensor = DBMGR.Get_Sensor_Set();
  4152. WallPadInterface wpifc = new WallPadInterface();
  4153. if (BugSensor > 0) {
  4154. if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4155. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4156. String Senret;
  4157. if (outSen > 0) Senret = "detect";
  4158. else Senret = "undetect";
  4159. resultStr += " <list name=\"in_move\" count=\"0\" value=\"" + Senret + "\" />\r\n";
  4160. senIDX++;
  4161. } else {
  4162. if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4163. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4164. String Senret;
  4165. if (outSen > 0) Senret = "detect";
  4166. else Senret = "undetect";
  4167. resultStr += " <list name=\"in_move\" value=\"" + Senret + "\" />\r\n";
  4168. senIDX++;
  4169. }
  4170. if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4171. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4172. String Senret;
  4173. if (outSen > 0) Senret = "detect";
  4174. else Senret = "undetect";
  4175. resultStr += " <list name=\"out_move\" value=\"" + Senret + "\" />\r\n";
  4176. senIDX++;
  4177. }
  4178. }
  4179. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4180. String Senret;
  4181. if (outSen > 0) Senret = "detect";
  4182. else Senret = "undetect";
  4183. resultStr += " <list name=\"magnetic\" value=\"" + Senret + "\" />\r\n";
  4184. senIDX++;
  4185. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4186. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4187. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4188. if (outSen > 0) Senret = "detect";
  4189. else Senret = "undetect";
  4190. resultStr += " <list name=\"emergency\" value=\"" + Senret + "\" />\r\n";
  4191. senIDX++;
  4192. }
  4193. DBMGR.closeDB();
  4194. }
  4195. if (senIDX > 0) {
  4196. RetVal += " <setting name = \"sensor_state\" count = \"" + senIDX + "\" value = \"list\" >\r\n";
  4197. RetVal += resultStr;
  4198. RetVal += " </setting>\r\n";
  4199. }
  4200. } else if (data.equals("statusbeat_time")) {
  4201. } else {
  4202. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"\" />\r\n";
  4203. }
  4204. }
  4205. }
  4206. } catch (RuntimeException re) {
  4207. LogUtil.errorLogInfo("", TAG, re);
  4208. } catch (Exception e) {
  4209. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4210. //e.printStackTrace();
  4211. LogUtil.errorLogInfo("", TAG, e);
  4212. }
  4213. SettManager.closeDB();
  4214. RetVal += " </guidemap>\r\n </service>\r\n</imap>";
  4215. return RetVal;
  4216. }
  4217. public void ProcElevatorinfo(Element ele) {
  4218. try {
  4219. String floor;
  4220. String move_dir;
  4221. /*
  4222. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4223. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4224. Node info = evinfo.item(0);
  4225. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4226. if (info != null)
  4227. {
  4228. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4229. }
  4230. */
  4231. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4232. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
  4233. Node iinfo = ievinfo.item(0);
  4234. if (iinfo == null) {
  4235. Log.d("iMapServer", "func ProcElevatorinfo info == null");
  4236. return;
  4237. }
  4238. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4239. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4240. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4241. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4242. if (move_dir != null) {
  4243. if (move_dir.equalsIgnoreCase("up")) {
  4244. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4245. } else if (move_dir.equalsIgnoreCase("down")) {
  4246. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4247. } else if (move_dir.equalsIgnoreCase("stop")) {
  4248. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4249. } else if (move_dir.equalsIgnoreCase("wrong")) {
  4250. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4251. } else if (move_dir.equalsIgnoreCase("finish")) {
  4252. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4253. }
  4254. Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
  4255. }
  4256. byte updown = 0x00;
  4257. if (ievinfo != null) {
  4258. boolean downCall = false;
  4259. boolean upCall = false;
  4260. for (int i = 0; i < ievinfo.getLength(); i++) {
  4261. Node valItem = ievinfo.item(i);
  4262. if (valItem != null) {
  4263. if (downCall == false) {
  4264. String val = GetAttributeVal(valItem, "ev_call_dir");
  4265. if (val != null)
  4266. downCall = val.equalsIgnoreCase("down");
  4267. }
  4268. if (upCall == false) {
  4269. String val = GetAttributeVal(valItem, "ev_call_dir");
  4270. if (val != null) {
  4271. upCall = val.equalsIgnoreCase("up");
  4272. }
  4273. }
  4274. }
  4275. }
  4276. Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
  4277. if (downCall == true && upCall == true) updown = 0x02;
  4278. else if (downCall == false && upCall == true) updown = 0x01;
  4279. }
  4280. Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  4281. Intent intent = new Intent();
  4282. intent.setAction(define.NOTIFY_ACNAME);
  4283. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  4284. intent.putExtra(define.NOTIBR_FLOOR, floor);
  4285. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  4286. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  4287. getApplicationContext().sendBroadcast(intent);
  4288. } catch (RuntimeException re) {
  4289. LogUtil.errorLogInfo("", TAG, re);
  4290. } catch (Exception e) {
  4291. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  4292. //e.printStackTrace();
  4293. LogUtil.errorLogInfo("", TAG, e);
  4294. }
  4295. }
  4296. private String MakeTargetStr(WallpadiCMDParser data) {
  4297. return " <target name=\"" + data.target + "\" id = \"" + data.tid + "\" msg_no=\"" + data.msgno + "\"/>\r\n";
  4298. }
  4299. public String iCMDProcVentilControl(Document doc) {
  4300. try {
  4301. String unit_status = "null", mode = "null", unit_mode = "null";
  4302. String retStr = CheckiCMDProc("remote_access_ventil");
  4303. if (retStr != null) return retStr;
  4304. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  4305. String target = "null", tid = "null", msgno = "null";
  4306. NodeList items = doc.getElementsByTagName("target");
  4307. Node item = items.item(0);
  4308. if (item != null) {
  4309. NamedNodeMap attrs = item.getAttributes();
  4310. for (int j = 0; j < attrs.getLength(); j++) {
  4311. Node attr = attrs.item(j);
  4312. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4313. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4314. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4315. msgno = attr.getNodeValue();
  4316. }
  4317. }
  4318. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4319. if (NewServerUse()) {
  4320. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4321. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4322. return ServerCheckResult;
  4323. }
  4324. boolean procSucc = true;
  4325. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  4326. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  4327. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  4328. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4329. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  4330. boolean OnOff = false;
  4331. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  4332. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  4333. else procSucc = false;
  4334. } else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  4335. byte strength = 0;
  4336. if (ventilParser.ctraction.equalsIgnoreCase("low"))
  4337. strength = VentiAPI.WIND.LOW;
  4338. else if (ventilParser.ctraction.equalsIgnoreCase("mid"))
  4339. strength = VentiAPI.WIND.MID;
  4340. else strength = VentiAPI.WIND.HI;
  4341. if (VentilCTR.data.OnOff) {
  4342. // 환기가 On인 경우
  4343. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4344. else procSucc = false;
  4345. } else {
  4346. // 환기가 Off인 경우
  4347. if (VentilCTR.SetOnOff(true) >= 0) {
  4348. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4349. else procSucc = false;
  4350. } else {
  4351. procSucc = false;
  4352. }
  4353. }
  4354. }
  4355. if (VentilCTR.Refresh(true) == 0) {
  4356. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4357. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4358. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4359. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4360. else unit_status = "unknown";
  4361. if (VentilCTR.data.Support.AutoDriving) {
  4362. mode = "normal/auto";
  4363. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4364. else unit_mode = "normal";
  4365. } else {
  4366. mode = "normal";
  4367. unit_mode = "normal";
  4368. }
  4369. } else {
  4370. procSucc = false;
  4371. }
  4372. } else {
  4373. procSucc = false;
  4374. }
  4375. } else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4376. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4377. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4378. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4379. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4380. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4381. else unit_status = "unknown";
  4382. if (VentilCTR.data.Support.AutoDriving) {
  4383. mode = "normal/auto";
  4384. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4385. else unit_mode = "normal";
  4386. } else {
  4387. mode = "normal";
  4388. unit_mode = "normal";
  4389. }
  4390. } else {
  4391. procSucc = false;
  4392. }
  4393. } else {
  4394. procSucc = false;
  4395. }
  4396. if (procSucc == false) {
  4397. retStr += (" result=\"fail\" >\r\n");
  4398. unit_status = "unknown";
  4399. } else {
  4400. retStr += (" result=\"ok\" >\r\n");
  4401. }
  4402. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4403. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4404. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4405. // retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4406. retStr += " <status_info unit_num=\"ventil\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4407. return retStr;
  4408. } catch (RuntimeException re) {
  4409. LogUtil.errorLogInfo("", TAG, re);
  4410. return null;
  4411. } catch (Exception e) {
  4412. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4413. //e.printStackTrace();
  4414. LogUtil.errorLogInfo("", TAG, e);
  4415. return null;
  4416. }
  4417. }
  4418. public String iCMDProcTemperControl(Document doc) {
  4419. try {
  4420. String target = "null", tid = "null", msgno = "null";
  4421. String retStr = CheckiCMDProc("remote_access_temper");
  4422. if (retStr != null) return retStr;
  4423. else
  4424. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4425. NodeList items = doc.getElementsByTagName("target");
  4426. Node item = items.item(0);
  4427. if (item != null) {
  4428. NamedNodeMap attrs = item.getAttributes();
  4429. for (int j = 0; j < attrs.getLength(); j++) {
  4430. Node attr = attrs.item(j);
  4431. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4432. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4433. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4434. }
  4435. }
  4436. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4437. if (NewServerUse()) {
  4438. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4439. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4440. return ServerCheckResult;
  4441. }
  4442. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4443. //String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4444. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4445. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_HEATING);
  4446. if(knxRoomNameList==null) knxRoomNameList = mDefaultRoomNameList_Heating;
  4447. // 난방 종류를 얻어온다.
  4448. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4449. HeatingV1API heatingV1API = null;
  4450. HeatingV2API heatingV2API = null;
  4451. // 종류별 API를 로딩한다.
  4452. if (HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4453. else if (HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4454. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4455. if (tempercmd.actionTXT.equals("control")) {
  4456. String[] CtrList;
  4457. byte ctrl = 0;
  4458. byte roomNum = (byte) 0xFF;
  4459. double temp = 0;
  4460. if (tempercmd.unitnum.equals("all")) {
  4461. if (tempercmd.ctraction.equals("on")) {
  4462. ctrl = 1;
  4463. } else if (tempercmd.ctraction.equals("off")) {
  4464. ctrl = 0;
  4465. } else {
  4466. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\" />\r\n </service>\r\n</imap> ";
  4467. return retStr;
  4468. }
  4469. } else {
  4470. CtrList = tempercmd.ctraction.split("/");
  4471. if (CtrList[0].equals("on")) ctrl = 1;
  4472. else ctrl = 0;
  4473. roomNum = (byte) 0xFF;
  4474. temp = Double.parseDouble(CtrList[1]);
  4475. }
  4476. if (HeatingKind == 1) {
  4477. boolean OnOff = false;
  4478. if (ctrl == 1) OnOff = true;
  4479. if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
  4480. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4481. if (ret != APIErrorCode.C_SUCCESS) {
  4482. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4483. return retStr;
  4484. }
  4485. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4486. } else {
  4487. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4488. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4489. roomNum = i;
  4490. break;
  4491. }
  4492. }
  4493. if (roomNum == (byte) 0xFF) {
  4494. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4495. return retStr;
  4496. }
  4497. if (heatingV1API != null) {
  4498. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
  4499. if (ret != APIErrorCode.C_SUCCESS) {
  4500. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4501. return retStr;
  4502. }
  4503. heatingV1API.Refresh(roomNum, false);
  4504. }
  4505. }
  4506. }
  4507. else if (HeatingKind == 2) {
  4508. byte Mode = HeatingV2.MODE.HeatingOFF;
  4509. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4510. if (tempercmd.unitnum.equals("all")) {
  4511. if (heatingV2API != null) {
  4512. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4513. if (ret != APIErrorCode.C_SUCCESS) {
  4514. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4515. return retStr;
  4516. }
  4517. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4518. }
  4519. } else {
  4520. int nDevNum = Integer.parseInt(tempercmd.devnum);
  4521. if (heatingV2API != null) {
  4522. int ret = heatingV2API.SetEachRoomStatus((byte) nDevNum, Mode, temp);
  4523. if (ret != APIErrorCode.C_SUCCESS) {
  4524. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4525. return retStr;
  4526. }
  4527. heatingV2API.Refresh((byte) nDevNum, false);
  4528. }
  4529. }
  4530. }
  4531. else {
  4532. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4533. return retStr;
  4534. }
  4535. }
  4536. String resultStr = " <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4537. if (HeatingKind == 1) {
  4538. try {
  4539. if (heatingV1API == null) {
  4540. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4541. return retStr;
  4542. }
  4543. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4544. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4545. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount + "\"/>\r\n";
  4546. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4547. String drvmode = "off";
  4548. for (byte i = 0; i < RoomCount; i++) {
  4549. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4550. if (roomData.bOnOff) drvmode = "on";
  4551. else drvmode = "off";
  4552. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4553. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4554. }
  4555. resultStr += " </service>\r\n</imap>\r\n";
  4556. retStr += ("\"ok\">\r\n" + resultStr);
  4557. return retStr;
  4558. } else {
  4559. String drvmode = "off";
  4560. byte roomNum = (byte) 0xFF;
  4561. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4562. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4563. roomNum = i;
  4564. break;
  4565. }
  4566. }
  4567. if (roomNum == (byte) 0xFF) {
  4568. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4569. return retStr;
  4570. }
  4571. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4572. if (roomData.bOnOff) drvmode = "on";
  4573. else drvmode = "off";
  4574. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4575. resultStr += " <status_info unit_num=\"" + knxRoomNameList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4576. resultStr += " </service>\r\n</imap>\r\n";
  4577. retStr += ("\"ok\">\r\n" + resultStr);
  4578. return retStr;
  4579. }
  4580. } catch (RuntimeException re) {
  4581. LogUtil.errorLogInfo("", TAG, re);
  4582. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4583. return retStr;
  4584. } catch (Exception e) {
  4585. //e.printStackTrace();
  4586. LogUtil.errorLogInfo("", TAG, e);
  4587. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4588. return retStr;
  4589. }
  4590. }
  4591. else if (HeatingKind == 2) {
  4592. try {
  4593. if (heatingV2API == null) {
  4594. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4595. return retStr;
  4596. }
  4597. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4598. resultStr += " <action> \"" + tempercmd.actionTXT + "\"</action>\r\n";
  4599. //resultStr += " <status_map dev_num=\"1\" unit_cnt = \"" + RoomCount + "\" />\r\n";
  4600. if ((tempercmd.devnum.equals("all"))) {
  4601. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
  4602. String drvmode = "off";
  4603. for (byte i = 0; i < RoomCount; i++) {
  4604. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4605. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4606. else drvmode = "off";
  4607. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4608. resultStr += " <status_map dev_num=\"" + (i+1) + "\" unit_cnt = \"1\"/>\r\n";
  4609. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4610. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + knxRoomNameList[i] + "\"/>\r\n";
  4611. } else {
  4612. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4613. }
  4614. }
  4615. resultStr += " </service>\r\n</imap>\r\n";
  4616. retStr += ("\"ok\">\r\n" + resultStr);
  4617. return retStr;
  4618. }
  4619. else {
  4620. String drvmode = "off";
  4621. int nDevNum = Integer.parseInt(tempercmd.unitnum);
  4622. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum];
  4623. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4624. else drvmode = "off";
  4625. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4626. resultStr += " <status_map dev_num=\"" + (nDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  4627. resultStr += " <status_info unit_num=\"" + knxRoomNameList[nDevNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4628. resultStr += " </service>\r\n</imap>\r\n";
  4629. retStr += ("\"ok\">\r\n" + resultStr);
  4630. return retStr;
  4631. }
  4632. } catch (RuntimeException re) {
  4633. LogUtil.errorLogInfo("", TAG, re);
  4634. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4635. return retStr;
  4636. } catch (Exception e) {
  4637. //e.printStackTrace();
  4638. LogUtil.errorLogInfo("", TAG, e);
  4639. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4640. return retStr;
  4641. }
  4642. } else {
  4643. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
  4644. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4645. return retStr;
  4646. }
  4647. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4648. // return retStr;
  4649. } catch (RuntimeException re) {
  4650. LogUtil.errorLogInfo("", TAG, re);
  4651. return null;
  4652. } catch (Exception e) {
  4653. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4654. //e.printStackTrace();
  4655. LogUtil.errorLogInfo("", TAG, e);
  4656. return null;
  4657. }
  4658. }
  4659. public String iCMDProcDoorlockControl(Document doc) {
  4660. try {
  4661. String DLStatus = "none";
  4662. String strResult = CheckiCMDProc("remote_access_doorlock");
  4663. if (strResult != null) return strResult;
  4664. else
  4665. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4666. String target = "null", tid = "null", msgno = "null";
  4667. NodeList items = doc.getElementsByTagName("target");
  4668. Node item = items.item(0);
  4669. if (item != null) {
  4670. NamedNodeMap attrs = item.getAttributes();
  4671. for (int j = 0; j < attrs.getLength(); j++) {
  4672. Node attr = attrs.item(j);
  4673. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4674. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4675. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4676. msgno = attr.getNodeValue();
  4677. }
  4678. }
  4679. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4680. if (NewServerUse()) {
  4681. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4682. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4683. return ServerCheckResult;
  4684. }
  4685. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4686. try {
  4687. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4688. if (doorStatus != null) {
  4689. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4690. DLStatus = "unknown";
  4691. } else {
  4692. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce)
  4693. DLStatus = "close";
  4694. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce)
  4695. DLStatus = "open";
  4696. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation)
  4697. DLStatus = "ing";
  4698. else DLStatus = "unknown";
  4699. }
  4700. }
  4701. } catch (RuntimeException re) {
  4702. LogUtil.errorLogInfo("", TAG, re);
  4703. DLStatus = "unknown";
  4704. } catch (Exception e) {
  4705. //e.printStackTrace();
  4706. LogUtil.errorLogInfo("", TAG, e);
  4707. DLStatus = "unknown";
  4708. }
  4709. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n" +
  4710. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n" +
  4711. " <action>\"status\"</action>\r\n" +
  4712. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n" +
  4713. " <status_info unit_num=\"doorlock1\" unit_status=\"" + DLStatus + "\"/>\r\n </service>\r\n</imap>";
  4714. return retXML;
  4715. } catch (RuntimeException re) {
  4716. LogUtil.errorLogInfo("", TAG, re);
  4717. return null;
  4718. } catch (Exception e) {
  4719. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4720. //e.printStackTrace();
  4721. LogUtil.errorLogInfo("", TAG, e);
  4722. return null;
  4723. }
  4724. }
  4725. /*
  4726. protected String iCMDProcsavelog(Document doc)
  4727. {
  4728. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4729. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4730. NodeList items = doc.getElementsByTagName("guidemap");
  4731. Node item = items.item(0);
  4732. NamedNodeMap attrsParam = item.getAttributes();
  4733. for(int j=0; j< attrsParam.getLength();j++)
  4734. {
  4735. Node attr = attrsParam.item(j);
  4736. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4737. {
  4738. String enable = attr.getNodeValue();
  4739. if (enable == null) return FailretStr;
  4740. if (enable.equals("false"))
  4741. {
  4742. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4743. logSet.SetLogDoing(0);
  4744. logSet.closeDB();
  4745. return SucretStr;
  4746. }
  4747. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4748. logSet.SetLogDoing(1);
  4749. logSet.closeDB();
  4750. }
  4751. }
  4752. items = doc.getElementsByTagName("setting");
  4753. item = items.item(0);
  4754. attrsParam = item.getAttributes();
  4755. String SaveType = "";
  4756. String FtpLoc = "";
  4757. String Ftpuser = "";
  4758. String FtpPW= "";
  4759. String period = "";
  4760. String FileSize = "";
  4761. for(int j=0; j< attrsParam.getLength();j++)
  4762. {
  4763. Node attr = attrsParam.item(j);
  4764. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4765. SaveType = attr.getNodeValue();
  4766. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4767. FtpLoc = attr.getNodeValue();
  4768. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4769. Ftpuser = attr.getNodeValue();
  4770. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4771. FtpPW = attr.getNodeValue();
  4772. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4773. period = attr.getNodeValue();
  4774. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4775. FileSize = attr.getNodeValue();
  4776. }
  4777. if (SaveType.equalsIgnoreCase("now"))
  4778. {
  4779. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4780. LogUpThread.start();
  4781. return SucretStr;
  4782. }
  4783. else if (SaveType.equalsIgnoreCase("periodic"))
  4784. {
  4785. try
  4786. {
  4787. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4788. period = period.trim();
  4789. String[] logperiod = period.split("[-]");
  4790. String StartDate = logperiod[0].replace(".", "_");
  4791. String EndDate = logperiod[1].replace(".", "_");
  4792. logSet.SetLogDoing(1);
  4793. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4794. if (FileSize.equalsIgnoreCase("null"))
  4795. logSet.SetLogLogFileSize(0);
  4796. else
  4797. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4798. logSet.SetLogStartDate(StartDate);
  4799. logSet.SetLogEndDate(EndDate);
  4800. logSet.closeDB();
  4801. return SucretStr;
  4802. }
  4803. catch (RuntimeException re) {
  4804. LogUtil.errorLogInfo("", TAG, re);
  4805. }
  4806. catch (Exception e)
  4807. {
  4808. e.printStackTrace();
  4809. return FailretStr;
  4810. }
  4811. }
  4812. else
  4813. {
  4814. return FailretStr;
  4815. }
  4816. }
  4817. */
  4818. protected void SendLogSaved(String ftploc, String fname, String size) {
  4819. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n" +
  4820. " <device_info devtype=\"homedev\" id_high=\"" + AddrDong + "\" id_low=\"" + AddrHo + "\"/>\r\n" +
  4821. " <file_info path=\"" + ftploc + "\" name=\"" + fname + "\" size=\"" + size + "\"/>\r\n</service>\r\n</imap>";
  4822. SendToServer(SendMsg);
  4823. }
  4824. public final static int FTPLOGTRSUCC = 1110;
  4825. public final static int FTPLOGTRFAIL = 1120;
  4826. Handler FileTrHandler = new Handler() {
  4827. public void handleMessage(Message msg) {
  4828. switch (msg.what) {
  4829. case FTPLOGTRSUCC:
  4830. String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4831. File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
  4832. int size = (int) (fileinfo.length() / 1024);
  4833. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4834. imapsvrlog("FTPLOGTRSUCC");
  4835. break;
  4836. case FTPLOGTRFAIL:
  4837. imapsvrlog("FTPLOGTRFAIL");
  4838. break;
  4839. }
  4840. }
  4841. };
  4842. class LogUploader extends Thread {
  4843. int fileidx = 0;
  4844. boolean TRing = false;
  4845. String FtpLoc;
  4846. String FtpID;
  4847. String FtpPasswd;
  4848. class ftpuploader extends WallPadFTPUploader {
  4849. String filename;
  4850. public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
  4851. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
  4852. filename = LocalFile;
  4853. }
  4854. protected void ProcUploadFail() {
  4855. Message TrResult = FileTrHandler.obtainMessage();
  4856. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4857. TrResult.what = FTPLOGTRFAIL;
  4858. TRing = false;
  4859. imapsvrlog("Send Log Fail Message");
  4860. FileTrHandler.sendMessage(TrResult);
  4861. }
  4862. protected void ProcUploadSuccess() {
  4863. Message TrResult = FileTrHandler.obtainMessage();
  4864. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4865. TrResult.what = FTPLOGTRSUCC;
  4866. TRing = false;
  4867. imapsvrlog("Send Log success Message");
  4868. FileTrHandler.sendMessage(TrResult);
  4869. }
  4870. }
  4871. public LogUploader(String loc, String user, String pw) {
  4872. FtpLoc = loc;
  4873. FtpID = user;
  4874. FtpPasswd = pw;
  4875. }
  4876. public void run() {
  4877. File LogLoc = new File(define.LOG_FILE_LOCATION);
  4878. String[] LogFileList = LogLoc.list();
  4879. while (true) {
  4880. if (TRing == false) {
  4881. if (LogFileList != null && fileidx < LogFileList.length) {
  4882. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
  4883. fileidx++;
  4884. TRing = true;
  4885. uploader.start();
  4886. } else
  4887. return;
  4888. }
  4889. try {
  4890. Thread.sleep(500);
  4891. } catch (RuntimeException re) {
  4892. LogUtil.errorLogInfo("", TAG, re);
  4893. } catch (Exception e) {
  4894. LogUtil.errorLogInfo("", TAG, e);
  4895. }
  4896. }
  4897. }
  4898. }
  4899. public String iCMDProcDevList(Document ele) {
  4900. try {
  4901. String strResult = CheckiCMDProc("remote_get_home_devices");
  4902. if (strResult != null) return strResult;
  4903. else
  4904. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" ";
  4905. String target = "null", tid = "null", msgno = "null";
  4906. NodeList items = ele.getElementsByTagName("target");
  4907. Node item = items.item(0);
  4908. if (item != null) {
  4909. NamedNodeMap attrs = item.getAttributes();
  4910. for (int j = 0; j < attrs.getLength(); j++) {
  4911. Node attr = attrs.item(j);
  4912. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4913. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4914. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4915. msgno = attr.getNodeValue();
  4916. }
  4917. }
  4918. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4919. if (NewServerUse()) {
  4920. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  4921. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4922. return ServerCheckResult;
  4923. }
  4924. GasAPI mGasAPI = null;
  4925. CooktopAPI mCooktopAPI = null;
  4926. if (mWallPadAPI.GetGasKind() == 1) {
  4927. mGasAPI = mWallPadAPI.Get_GasController();
  4928. } else if (mWallPadAPI.GetGasKind() == 2) {
  4929. mCooktopAPI = mWallPadAPI.Get_CookTopController();
  4930. }
  4931. Log.i(TAG, "[iCMDProcDevList] bLightCMDUseAsSmartLight: " + bLightCMDUseAsSmartLight);
  4932. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  4933. int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  4934. String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
  4935. int nConcentEnable = mWallpadDeviceSet.Get_Concent_Info(); // 콘센트 사용 유무
  4936. mWallpadDeviceSet.closeDB();
  4937. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  4938. String[] devlist;
  4939. if(nConcentEnable==1){
  4940. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
  4941. } else {
  4942. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "smartlight", "cooktop", "sysaircon"};
  4943. }
  4944. strResult += "result=\"ok\">\r\n";
  4945. strResult += " <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
  4946. strResult += " <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
  4947. //strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  4948. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  4949. String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
  4950. String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
  4951. String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
  4952. strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
  4953. strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
  4954. strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
  4955. for (int i = 0; i < devlist.length; i++) {
  4956. if (devlist[i].equals("cooktop")) {
  4957. if (mWallPadAPI.GetGasKind() == 1) {
  4958. // 가스밸브
  4959. int Gasinfo = devSet.Get_GAS_Info();
  4960. if (Gasinfo == 1) {
  4961. // 사용함
  4962. if (bGasAsCooktopOutlet) {
  4963. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4964. strResult += " <devinfo name=\"cooktop\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4965. } else {
  4966. strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4967. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4968. }
  4969. } else {
  4970. // 사용안함
  4971. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4972. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4973. }
  4974. } else if (mWallPadAPI.GetGasKind() == 2) {
  4975. // 하이브리드 쿡탑
  4976. if (mCooktopAPI != null) {
  4977. int nGas = 0;
  4978. int nOutlet = 0;
  4979. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  4980. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  4981. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
  4982. nGas++;
  4983. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
  4984. nOutlet++;
  4985. }
  4986. }
  4987. strResult += " <devinfo name=\"gas\" value=\"" + nGas + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4988. strResult += " <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4989. }
  4990. } else {
  4991. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4992. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4993. }
  4994. }
  4995. else if (devlist[i].equals("doorlock")) {
  4996. try {
  4997. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  4998. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  4999. strResult += " <devinfo name=\"doorlock\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5000. } else {
  5001. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5002. }
  5003. } catch (RuntimeException re) {
  5004. LogUtil.errorLogInfo("", TAG, re);
  5005. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5006. } catch (Exception e) {
  5007. //e.printStackTrace();
  5008. LogUtil.errorLogInfo("", TAG, e);
  5009. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5010. }
  5011. }
  5012. else if (devlist[i].equals("light")) {
  5013. try {
  5014. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5015. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5016. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5017. if (bLightCMDUseAsSmartLight) {
  5018. if (mSdbAPI != null) {
  5019. strResult += " <devinfo name=\"light\" value=\"" + mSdbAPI.data.BadRoom_Em_Count + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5020. } else {
  5021. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5022. }
  5023. } else {
  5024. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5025. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5026. }
  5027. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5028. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5029. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5030. strResult += " <devinfo name=\"light\" value=\"" + energymeter.data.RoomCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5031. } else {
  5032. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5033. }
  5034. } else {
  5035. int[] lightinfo = devSet.Get_Light_info();
  5036. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5037. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5038. } else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5039. strResult += " <devinfo name=\"light\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5040. } else {
  5041. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5042. int ret = multisw.Refresh((byte) 0xFF, false);
  5043. if (ret < 0 || multisw.data.DeviceCnt < 1)
  5044. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5045. else
  5046. strResult += " <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5047. }
  5048. }
  5049. } catch (RuntimeException re) {
  5050. LogUtil.errorLogInfo("", TAG, re);
  5051. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5052. } catch (Exception e) {
  5053. //e.printStackTrace();
  5054. LogUtil.errorLogInfo("", TAG, e);
  5055. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5056. }
  5057. }
  5058. else if (devlist[i].equals("livinglight")) {
  5059. try {
  5060. int[] lightinfo = devSet.Get_Light_info();
  5061. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5062. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5063. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5064. if (bLightCMDUseAsSmartLight) {
  5065. if (mSdb_LivingRoomLightAPI != null) {
  5066. strResult += " <devinfo name=\"livinglight\" value=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5067. } else {
  5068. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5069. }
  5070. } else {
  5071. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5072. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5073. }
  5074. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5075. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5076. } else {
  5077. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5078. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5079. } else {
  5080. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5081. }
  5082. }
  5083. } catch (RuntimeException re) {
  5084. LogUtil.errorLogInfo("", TAG, re);
  5085. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5086. } catch (Exception e) {
  5087. //e.printStackTrace();
  5088. LogUtil.errorLogInfo("", TAG, e);
  5089. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5090. }
  5091. }
  5092. else if (devlist[i].equals("ventil")) {
  5093. try {
  5094. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5095. if (Ventilinfo[0] == 0)
  5096. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5097. else
  5098. strResult += " <devinfo name=\"ventil\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5099. } catch (RuntimeException re) {
  5100. LogUtil.errorLogInfo("", TAG, re);
  5101. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5102. } catch (Exception e) {
  5103. //e.printStackTrace();
  5104. LogUtil.errorLogInfo("", TAG, e);
  5105. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5106. }
  5107. }
  5108. else if (devlist[i].equals("thermostat")) {
  5109. try {
  5110. int Temperinfo = devSet.Get_Temper_Info();
  5111. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5112. HeatingV1API heatingV1API = null;
  5113. HeatingV2API heatingV2API = null;
  5114. byte RoomCount = 0;
  5115. // 종류별 API를 로딩한다.
  5116. if (HeatingKind == 1) {
  5117. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5118. if (heatingV1API != null) {
  5119. RoomCount = heatingV1API.data.Device.RoomCount;
  5120. }
  5121. } else if (HeatingKind == 2) {
  5122. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5123. if (heatingV2API != null) {
  5124. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5125. }
  5126. }
  5127. if (Temperinfo == 0)
  5128. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5129. else
  5130. strResult += " <devinfo name=\"thermostat\" value=\"" + RoomCount + "\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5131. } catch (RuntimeException re) {
  5132. LogUtil.errorLogInfo("", TAG, re);
  5133. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5134. } catch (Exception e) {
  5135. //e.printStackTrace();
  5136. LogUtil.errorLogInfo("", TAG, e);
  5137. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5138. }
  5139. }
  5140. else if (devlist[i].equals("curtain")) {
  5141. try {
  5142. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5143. if (Curtaininfo[0] == 0)
  5144. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5145. else
  5146. strResult += " <devinfo name=\"curtain\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5147. } catch (RuntimeException re) {
  5148. LogUtil.errorLogInfo("", TAG, re);
  5149. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5150. } catch (Exception e) {
  5151. //e.printStackTrace();
  5152. LogUtil.errorLogInfo("", TAG, e);
  5153. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5154. }
  5155. }
  5156. else if (devlist[i].equals("electric")) {
  5157. try {
  5158. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5159. // 청담 콘센트 처리
  5160. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5161. int BadConcentCount = 0;
  5162. if (KnxApi != null) {
  5163. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5164. if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
  5165. BadConcentCount = 1;
  5166. }
  5167. int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  5168. for (int k = 0; k < BadConCount; k++) {
  5169. if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
  5170. BadConcentCount++;
  5171. }
  5172. Log.d(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
  5173. strResult += " <devinfo name=\"electric\" value=\"" + BadConcentCount + "\" floor=\"" + ho + "\"/>\r\n";
  5174. }
  5175. } else {
  5176. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5177. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5178. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5179. int nOutlet = 0;
  5180. if (mSdb_LivingRoomLightAPI != null) {
  5181. if (mSdbAPI != null) {
  5182. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5183. } else {
  5184. nOutlet = 1;
  5185. }
  5186. } else {
  5187. if (mSdbAPI != null) {
  5188. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5189. } else {
  5190. nOutlet = 0;
  5191. }
  5192. }
  5193. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"" + ho + "\"/>\r\n";
  5194. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5195. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5196. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5197. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"" + ho + "\"/>\r\n";
  5198. } else {
  5199. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5200. }
  5201. } else {
  5202. int[] lightinfo = devSet.Get_Light_info();
  5203. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5204. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5205. } else {
  5206. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5207. int ret = multisw.Refresh((byte) 0xFF, false);
  5208. if (ret < 0 || multisw.data.DeviceCnt < 1) {
  5209. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5210. } else {
  5211. int DeviceCount = 0;
  5212. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5213. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5214. DeviceCount++;
  5215. }
  5216. }
  5217. strResult += " <devinfo name=\"electric\" value=\"" + DeviceCount + "\" floor=\"" + ho + "\"/>\r\n";
  5218. }
  5219. }
  5220. }
  5221. }
  5222. } catch (RuntimeException re) {
  5223. LogUtil.errorLogInfo("", TAG, re);
  5224. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5225. } catch (Exception e) {
  5226. //e.printStackTrace();
  5227. LogUtil.errorLogInfo("", TAG, e);
  5228. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5229. }
  5230. }
  5231. else if (devlist[i].equals("smartlight")) {
  5232. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5233. // KNX 조명 처리
  5234. try {
  5235. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5236. if (KnxApi != null) {
  5237. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5238. if (KnxApi.data == null)
  5239. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
  5240. if (KnxApi.data.MasterController == null)
  5241. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
  5242. if (ret >= 0) {
  5243. int LivingLightCount = 0;
  5244. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  5245. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  5246. } else {
  5247. if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  5248. LivingLightCount = 1;
  5249. }
  5250. int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount + KnxApi.data.MasterController.Info.Light_SwitchCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
  5251. strResult += " <devinfo name=\"smartlight\" value=\"" + AllEMcount + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5252. }
  5253. }
  5254. } catch (Exception ek) {
  5255. strResult += " <devinfo name=\"smartlight\" value=\"" + 0 + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5256. }
  5257. } else {
  5258. if (!bLightCMDUseAsSmartLight) {
  5259. int nSmartLight = 0;
  5260. if (mSdb_LivingRoomLightAPI != null) {
  5261. if (mSdbAPI != null) {
  5262. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5263. } else {
  5264. nSmartLight = 1;
  5265. }
  5266. } else {
  5267. if (mSdbAPI != null) {
  5268. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5269. } else {
  5270. nSmartLight = 0;
  5271. }
  5272. }
  5273. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5274. }
  5275. }
  5276. }
  5277. else if (devlist[i].equals("sysaircon")) {
  5278. // 에어컨 처리
  5279. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5280. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  5281. if (airconAPI != null) {
  5282. int nCount = airconAPI.data.Device.info.InsideAirconCount;
  5283. Log.d(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
  5284. // 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
  5285. strResult += " <devinfo name=\"sysaircon\" value=\"" + nCount + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5286. } else {
  5287. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5288. }
  5289. } else {
  5290. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5291. }
  5292. }
  5293. }
  5294. //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
  5295. strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5296. strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5297. if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
  5298. strResult += remote_get_home_devices1;
  5299. }
  5300. if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
  5301. strResult += remote_get_home_devices2;
  5302. }
  5303. if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
  5304. strResult += remote_get_home_devices3;
  5305. }
  5306. /*
  5307. for (int i = 0; i < devlist.length; i++) {
  5308. if (devlist[i].equals("cooktop")) {
  5309. if (mWallPadAPI.GetGasKind() == 1) {
  5310. // 가스밸브
  5311. int Gasinfo = devSet.Get_GAS_Info();
  5312. if (Gasinfo == 1) {
  5313. // 사용함
  5314. if (bGasAsCooktopOutlet) {
  5315. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5316. strResult +=" <devinfo name=\"cooktop\" value=\"1\" floor=\"2\"/>\r\n";
  5317. }
  5318. else {
  5319. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n";
  5320. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5321. }
  5322. }
  5323. else {
  5324. // 사용안함
  5325. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5326. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5327. }
  5328. }
  5329. else if (mWallPadAPI.GetGasKind() == 2) {
  5330. // 하이브리드 쿡탑
  5331. if (mCooktopAPI != null) {
  5332. int nGas = 0; int nOutlet = 0;
  5333. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5334. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5335. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5336. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5337. }
  5338. }
  5339. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"2\"/>\r\n";
  5340. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5341. }
  5342. }
  5343. else {
  5344. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5345. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5346. }
  5347. }
  5348. else if (devlist[i].equals("doorlock")) {
  5349. try {
  5350. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5351. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5352. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"2\"/>\r\n";
  5353. }
  5354. else {
  5355. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5356. }
  5357. } catch (RuntimeException re) {
  5358. LogUtil.errorLogInfo("", TAG, re);
  5359. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5360. }
  5361. catch (Exception e) {
  5362. //e.printStackTrace();
  5363. LogUtil.errorLogInfo("", TAG, e);
  5364. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5365. }
  5366. }
  5367. else if (devlist[i].equals("light")) {
  5368. try {
  5369. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5370. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5371. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5372. if (bLightCMDUseAsSmartLight) {
  5373. if (mSdbAPI != null) {
  5374. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"2\"/>\r\n";
  5375. }
  5376. else {
  5377. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5378. }
  5379. }
  5380. else {
  5381. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5382. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5383. }
  5384. }
  5385. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5386. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5387. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5388. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"2\"/>\r\n";
  5389. }
  5390. else {
  5391. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5392. }
  5393. }
  5394. else {
  5395. int[] lightinfo = devSet.Get_Light_info();
  5396. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5397. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5398. }
  5399. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5400. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"2\"/>\r\n";
  5401. }
  5402. else {
  5403. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5404. int ret = multisw.Refresh((byte)0xFF, false);
  5405. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5406. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"2\"/>\r\n";
  5407. }
  5408. }
  5409. } catch (RuntimeException re) {
  5410. LogUtil.errorLogInfo("", TAG, re);
  5411. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5412. }
  5413. catch (Exception e) {
  5414. //e.printStackTrace();
  5415. LogUtil.errorLogInfo("", TAG, e);
  5416. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5417. }
  5418. }
  5419. else if (devlist[i].equals("livinglight")) {
  5420. try {
  5421. int[] lightinfo = devSet.Get_Light_info();
  5422. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5423. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5424. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5425. if (bLightCMDUseAsSmartLight) {
  5426. if (mSdb_LivingRoomLightAPI != null) {
  5427. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"2\"/>\r\n";
  5428. }
  5429. else {
  5430. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5431. }
  5432. }
  5433. else {
  5434. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5435. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5436. }
  5437. }
  5438. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5439. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5440. }
  5441. else {
  5442. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5443. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5444. }
  5445. else {
  5446. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5447. }
  5448. }
  5449. } catch (RuntimeException re) {
  5450. LogUtil.errorLogInfo("", TAG, re);
  5451. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5452. }
  5453. catch (Exception e) {
  5454. //e.printStackTrace();
  5455. LogUtil.errorLogInfo("", TAG, e);
  5456. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5457. }
  5458. }
  5459. else if (devlist[i].equals("ventil")) {
  5460. try {
  5461. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5462. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5463. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n";
  5464. } catch (RuntimeException re) {
  5465. LogUtil.errorLogInfo("", TAG, re);
  5466. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5467. }
  5468. catch (Exception e) {
  5469. //e.printStackTrace();
  5470. LogUtil.errorLogInfo("", TAG, e);
  5471. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5472. }
  5473. }
  5474. else if (devlist[i].equals("thermostat")) {
  5475. try {
  5476. int Temperinfo = devSet.Get_Temper_Info();
  5477. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5478. HeatingV1API heatingV1API = null;
  5479. HeatingV2API heatingV2API = null;
  5480. byte RoomCount = 0;
  5481. // 종류별 API를 로딩한다.
  5482. if (HeatingKind == 1) {
  5483. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5484. if (heatingV1API != null) {
  5485. RoomCount = heatingV1API.data.Device.RoomCount;
  5486. }
  5487. }
  5488. else if (HeatingKind == 2) {
  5489. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5490. if (heatingV2API != null) {
  5491. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5492. }
  5493. }
  5494. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5495. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"2\"/>\r\n";
  5496. } catch (RuntimeException re) {
  5497. LogUtil.errorLogInfo("", TAG, re);
  5498. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5499. }
  5500. catch (Exception e) {
  5501. //e.printStackTrace();
  5502. LogUtil.errorLogInfo("", TAG, e);
  5503. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5504. }
  5505. }
  5506. else if (devlist[i].equals("curtain")) {
  5507. try {
  5508. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5509. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5510. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"2\"/>\r\n";
  5511. } catch (RuntimeException re) {
  5512. LogUtil.errorLogInfo("", TAG, re);
  5513. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5514. }
  5515. catch (Exception e) {
  5516. //e.printStackTrace();
  5517. LogUtil.errorLogInfo("", TAG, e);
  5518. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5519. }
  5520. }
  5521. else if (devlist[i].equals("electric")) {
  5522. try {
  5523. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5524. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5525. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5526. int nOutlet = 0;
  5527. if (mSdb_LivingRoomLightAPI != null) {
  5528. if (mSdbAPI != null) {
  5529. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5530. }
  5531. else {
  5532. nOutlet = 1;
  5533. }
  5534. }
  5535. else {
  5536. if (mSdbAPI != null) {
  5537. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5538. }
  5539. else {
  5540. nOutlet = 0;
  5541. }
  5542. }
  5543. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5544. }
  5545. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5546. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5547. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5548. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"2\"/>\r\n";
  5549. }
  5550. else {
  5551. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5552. }
  5553. }
  5554. else {
  5555. int[] lightinfo = devSet.Get_Light_info();
  5556. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5557. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5558. }
  5559. else {
  5560. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5561. int ret = multisw.Refresh((byte)0xFF, false);
  5562. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5563. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5564. }
  5565. else {
  5566. int DeviceCount = 0;
  5567. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5568. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5569. DeviceCount++;
  5570. }
  5571. }
  5572. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"2\"/>\r\n";
  5573. }
  5574. }
  5575. }
  5576. } catch (RuntimeException re) {
  5577. LogUtil.errorLogInfo("", TAG, re);
  5578. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5579. }
  5580. catch (Exception e) {
  5581. //e.printStackTrace();
  5582. LogUtil.errorLogInfo("", TAG, e);
  5583. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5584. }
  5585. }
  5586. else if (devlist[i].equals("smartlight")) {
  5587. if (!bLightCMDUseAsSmartLight) {
  5588. int nSmartLight = 0;
  5589. if (mSdb_LivingRoomLightAPI != null) {
  5590. if (mSdbAPI != null) {
  5591. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5592. }
  5593. else {
  5594. nSmartLight = 1;
  5595. }
  5596. }
  5597. else {
  5598. if (mSdbAPI != null) {
  5599. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5600. }
  5601. else {
  5602. nSmartLight = 0;
  5603. }
  5604. }
  5605. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"2\"/>\r\n";
  5606. }
  5607. }
  5608. }
  5609. for (int i = 0; i < devlist.length; i++) {
  5610. if (devlist[i].equals("cooktop")) {
  5611. if (mWallPadAPI.GetGasKind() == 1) {
  5612. // 가스밸브
  5613. int Gasinfo = devSet.Get_GAS_Info();
  5614. if (Gasinfo == 1) {
  5615. // 사용함
  5616. if (bGasAsCooktopOutlet) {
  5617. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5618. strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5619. }
  5620. else {
  5621. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n";
  5622. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5623. }
  5624. }
  5625. else {
  5626. // 사용안함
  5627. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5628. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5629. }
  5630. }
  5631. else if (mWallPadAPI.GetGasKind() == 2) {
  5632. // 하이브리드 쿡탑
  5633. if (mCooktopAPI != null) {
  5634. int nGas = 0; int nOutlet = 0;
  5635. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5636. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5637. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5638. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5639. }
  5640. }
  5641. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"3\"/>\r\n";
  5642. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5643. }
  5644. }
  5645. else {
  5646. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5647. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5648. }
  5649. }
  5650. else if (devlist[i].equals("doorlock")) {
  5651. try {
  5652. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5653. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5654. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"3\"/>\r\n";
  5655. }
  5656. else {
  5657. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5658. }
  5659. } catch (RuntimeException re) {
  5660. LogUtil.errorLogInfo("", TAG, re);
  5661. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5662. }
  5663. catch (Exception e) {
  5664. //e.printStackTrace();
  5665. LogUtil.errorLogInfo("", TAG, e);
  5666. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5667. }
  5668. }
  5669. else if (devlist[i].equals("light")) {
  5670. try {
  5671. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5672. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5673. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5674. if (bLightCMDUseAsSmartLight) {
  5675. if (mSdbAPI != null) {
  5676. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"3\"/>\r\n";
  5677. }
  5678. else {
  5679. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5680. }
  5681. }
  5682. else {
  5683. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5684. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5685. }
  5686. }
  5687. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5688. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5689. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5690. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"3\"/>\r\n";
  5691. }
  5692. else {
  5693. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5694. }
  5695. }
  5696. else {
  5697. int[] lightinfo = devSet.Get_Light_info();
  5698. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5699. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5700. }
  5701. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5702. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"3\"/>\r\n";
  5703. }
  5704. else {
  5705. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5706. int ret = multisw.Refresh((byte)0xFF, false);
  5707. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5708. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"3\"/>\r\n";
  5709. }
  5710. }
  5711. } catch (RuntimeException re) {
  5712. LogUtil.errorLogInfo("", TAG, re);
  5713. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5714. }
  5715. catch (Exception e) {
  5716. //e.printStackTrace();
  5717. LogUtil.errorLogInfo("", TAG, e);
  5718. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5719. }
  5720. }
  5721. else if (devlist[i].equals("livinglight")) {
  5722. try {
  5723. int[] lightinfo = devSet.Get_Light_info();
  5724. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5725. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5726. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5727. if (bLightCMDUseAsSmartLight) {
  5728. if (mSdb_LivingRoomLightAPI != null) {
  5729. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"3\"/>\r\n";
  5730. }
  5731. else {
  5732. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5733. }
  5734. }
  5735. else {
  5736. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5737. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5738. }
  5739. }
  5740. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5741. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5742. }
  5743. else {
  5744. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5745. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5746. }
  5747. else {
  5748. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5749. }
  5750. }
  5751. } catch (RuntimeException re) {
  5752. LogUtil.errorLogInfo("", TAG, re);
  5753. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5754. }
  5755. catch (Exception e) {
  5756. //e.printStackTrace();
  5757. LogUtil.errorLogInfo("", TAG, e);
  5758. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5759. }
  5760. }
  5761. else if (devlist[i].equals("ventil")) {
  5762. try {
  5763. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5764. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5765. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n";
  5766. } catch (RuntimeException re) {
  5767. LogUtil.errorLogInfo("", TAG, re);
  5768. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5769. }
  5770. catch (Exception e) {
  5771. //e.printStackTrace();
  5772. LogUtil.errorLogInfo("", TAG, e);
  5773. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5774. }
  5775. }
  5776. else if (devlist[i].equals("thermostat")) {
  5777. try {
  5778. int Temperinfo = devSet.Get_Temper_Info();
  5779. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5780. HeatingV1API heatingV1API = null;
  5781. HeatingV2API heatingV2API = null;
  5782. byte RoomCount = 0;
  5783. // 종류별 API를 로딩한다.
  5784. if (HeatingKind == 1) {
  5785. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5786. if (heatingV1API != null) {
  5787. RoomCount = heatingV1API.data.Device.RoomCount;
  5788. }
  5789. }
  5790. else if (HeatingKind == 2) {
  5791. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5792. if (heatingV2API != null) {
  5793. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5794. }
  5795. }
  5796. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5797. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"3\"/>\r\n";
  5798. } catch (RuntimeException re) {
  5799. LogUtil.errorLogInfo("", TAG, re);
  5800. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5801. }
  5802. catch (Exception e) {
  5803. //e.printStackTrace();
  5804. LogUtil.errorLogInfo("", TAG, e);
  5805. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5806. }
  5807. }
  5808. else if (devlist[i].equals("curtain")) {
  5809. try {
  5810. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5811. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5812. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"3\"/>\r\n";
  5813. } catch (RuntimeException re) {
  5814. LogUtil.errorLogInfo("", TAG, re);
  5815. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5816. }
  5817. catch (Exception e) {
  5818. //e.printStackTrace();
  5819. LogUtil.errorLogInfo("", TAG, e);
  5820. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5821. }
  5822. }
  5823. else if (devlist[i].equals("electric")) {
  5824. try {
  5825. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5826. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5827. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5828. int nOutlet = 0;
  5829. if (mSdb_LivingRoomLightAPI != null) {
  5830. if (mSdbAPI != null) {
  5831. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5832. }
  5833. else {
  5834. nOutlet = 1;
  5835. }
  5836. }
  5837. else {
  5838. if (mSdbAPI != null) {
  5839. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5840. }
  5841. else {
  5842. nOutlet = 0;
  5843. }
  5844. }
  5845. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5846. }
  5847. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5848. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5849. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5850. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"3\"/>\r\n";
  5851. }
  5852. else {
  5853. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5854. }
  5855. }
  5856. else {
  5857. int[] lightinfo = devSet.Get_Light_info();
  5858. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5859. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5860. }
  5861. else {
  5862. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5863. int ret = multisw.Refresh((byte)0xFF, false);
  5864. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5865. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5866. }
  5867. else {
  5868. int DeviceCount = 0;
  5869. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5870. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5871. DeviceCount++;
  5872. }
  5873. }
  5874. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"3\"/>\r\n";
  5875. }
  5876. }
  5877. }
  5878. } catch (RuntimeException re) {
  5879. LogUtil.errorLogInfo("", TAG, re);
  5880. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5881. }
  5882. catch (Exception e) {
  5883. //e.printStackTrace();
  5884. LogUtil.errorLogInfo("", TAG, e);
  5885. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5886. }
  5887. }
  5888. else if (devlist[i].equals("smartlight")) {
  5889. if (!bLightCMDUseAsSmartLight) {
  5890. int nSmartLight = 0;
  5891. if (mSdb_LivingRoomLightAPI != null) {
  5892. if (mSdbAPI != null) {
  5893. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5894. }
  5895. else {
  5896. nSmartLight = 1;
  5897. }
  5898. }
  5899. else {
  5900. if (mSdbAPI != null) {
  5901. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5902. }
  5903. else {
  5904. nSmartLight = 0;
  5905. }
  5906. }
  5907. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"3\"/>\r\n";
  5908. }
  5909. }
  5910. }
  5911. */
  5912. strResult += " </service>\r\n</imap>\r\n";
  5913. devSet.closeDB();
  5914. return strResult;
  5915. } catch (RuntimeException re) {
  5916. LogUtil.errorLogInfo("", TAG, re);
  5917. return null;
  5918. } catch (Exception e) {
  5919. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  5920. //e.printStackTrace();
  5921. LogUtil.errorLogInfo("", TAG, e);
  5922. return null;
  5923. }
  5924. }
  5925. public String iCMDProcMultiSWControl(Document ele) {
  5926. try {
  5927. String retStr = CheckiCMDProc(MULTISW_CTR);
  5928. if (retStr != null) return retStr;
  5929. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\"";
  5930. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  5931. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5932. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  5933. int devNum = Integer.parseInt(multiswcmd.devnum);
  5934. if (multisw != null) {
  5935. int ret = multisw.Refresh((byte) 0xFF, false);
  5936. String result;
  5937. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  5938. else result = "fail";
  5939. retStr += (" result=\"" + result + "\" >\r\n");
  5940. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5941. retStr += MakeTargetStr(multiswcmd);
  5942. retStr += " <action>\"status\"</action>\r\n";
  5943. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5944. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5945. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  5946. 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";
  5947. } else {
  5948. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  5949. }
  5950. } else {
  5951. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5952. }
  5953. String unitStr;
  5954. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5955. Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
  5956. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5957. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5958. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5959. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  5960. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  5961. }
  5962. }
  5963. retStr += " </service>\r\n</imap>\r\n";
  5964. }
  5965. } else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  5966. int devNum = Integer.parseInt(multiswcmd.devnum);
  5967. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  5968. {
  5969. if (multisw != null) {
  5970. multisw.Refresh((byte) 0xFF, false);
  5971. String result;
  5972. int ret = -1;
  5973. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  5974. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
  5975. } else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  5976. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
  5977. } else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
  5978. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
  5979. } else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
  5980. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
  5981. }
  5982. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  5983. else result = "fail";
  5984. if (ret == APIErrorCode.C_SUCCESS) {
  5985. ret = multisw.Refresh((byte) 0xFF, false);
  5986. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5987. retStr += (" result=\"" + result + "\" > \r\n");
  5988. retStr += MakeTargetStr(multiswcmd);
  5989. retStr += " <action>\"control\"</action>\r\n";
  5990. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5991. String unitStr;
  5992. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5993. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5994. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5995. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5996. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
  5997. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  5998. }
  5999. } else {
  6000. retStr += (" result=\"fail\"> \r\n");
  6001. }
  6002. } else {
  6003. retStr += (" result=\"fail\"> \r\n");
  6004. }
  6005. retStr += " </service>\r\n</imap>\r\n";
  6006. }
  6007. }
  6008. }
  6009. return retStr;
  6010. } catch (RuntimeException re) {
  6011. LogUtil.errorLogInfo("", TAG, re);
  6012. return null;
  6013. } catch (Exception e) {
  6014. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  6015. //e.printStackTrace();
  6016. LogUtil.errorLogInfo("", TAG, e);
  6017. return null;
  6018. }
  6019. }
  6020. public String iCMDProcSDPConcentControl(Document ele) {
  6021. try {
  6022. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  6023. String retStr = CheckiCMDProc("remote_access_electric");
  6024. if (retStr != null) return retStr;
  6025. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  6026. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6027. if (NewServerUse()) {
  6028. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  6029. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6030. return ServerCheckResult;
  6031. }
  6032. if (mSdbAPI == null) {
  6033. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6034. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  6035. return retStr;
  6036. }
  6037. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6038. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6039. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6040. return retStr;
  6041. }
  6042. int nTotalLightCnt = 0;
  6043. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  6044. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6045. } else {
  6046. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  6047. }
  6048. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  6049. int nDevNo = 0;
  6050. try {
  6051. nDevNo = Integer.parseInt(concentcmd.devnum);
  6052. } catch (RuntimeException re) {
  6053. LogUtil.errorLogInfo("", TAG, re);
  6054. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6055. return retStr;
  6056. } catch (Exception e) {
  6057. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  6058. //e.printStackTrace();
  6059. LogUtil.errorLogInfo("", TAG, e);
  6060. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6061. return retStr;
  6062. }
  6063. if (nDevNo < 1 && 12 < nDevNo) {
  6064. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6065. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  6066. return retStr;
  6067. }
  6068. String strAction = trimquotation(concentcmd.actionTXT);
  6069. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  6070. String dev_num = "null", unit_num = "null", ctrl_action = "null";
  6071. int nRet_Mode = -99, nRet_OnOff = -99;
  6072. boolean Set = false, OnOff = false; // 제어요청 상태
  6073. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  6074. if (strAction.equalsIgnoreCase("status")) {
  6075. retStr += " result=\"ok\">\r\n";
  6076. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6077. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6078. if (nDevNo == 1) {
  6079. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6080. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  6081. } else {
  6082. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6083. }
  6084. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6085. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6086. status_mode = "unset";
  6087. else status_mode = "set";
  6088. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6089. status_onoff = "on";
  6090. else status_onoff = "off";
  6091. unit_status = status_mode + "/" + status_onoff;
  6092. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6093. }
  6094. // retStr += " </status_map>\r\n";
  6095. retStr += " </service>\r\n</imap>\r\n";
  6096. } else if (nDevNo > 1) {
  6097. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6098. 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";
  6099. } else {
  6100. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6101. }
  6102. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6103. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6104. status_mode = "unset";
  6105. else status_mode = "set";
  6106. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6107. status_onoff = "on";
  6108. else status_onoff = "off";
  6109. unit_status = status_mode + "/" + status_onoff;
  6110. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6111. }
  6112. // retStr += " </status_map>\r\n";
  6113. retStr += " </service>\r\n</imap>\r\n";
  6114. }
  6115. } else if (strAction.equalsIgnoreCase("control")) {
  6116. NodeList items = ele.getElementsByTagName("params");
  6117. Node item = items.item(0);
  6118. if (item != null) {
  6119. NamedNodeMap attrs = item.getAttributes();
  6120. for (int i = 0; i < attrs.getLength(); i++) {
  6121. Node attr = attrs.item(i);
  6122. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  6123. dev_num = attr.getNodeValue();
  6124. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  6125. unit_num = attr.getNodeValue();
  6126. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6127. ctrl_action = attr.getNodeValue();
  6128. }
  6129. } else {
  6130. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  6131. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6132. return retStr;
  6133. }
  6134. try {
  6135. nDevNo = Integer.parseInt(dev_num);
  6136. } catch (RuntimeException re) {
  6137. LogUtil.errorLogInfo("", TAG, re);
  6138. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6139. return retStr;
  6140. } catch (Exception e) {
  6141. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  6142. //e.printStackTrace();
  6143. LogUtil.errorLogInfo("", TAG, e);
  6144. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6145. return retStr;
  6146. }
  6147. if (nDevNo < 1 && 12 < nDevNo) {
  6148. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6149. return retStr;
  6150. }
  6151. int nUnitNo = 0;
  6152. if (!unit_num.equalsIgnoreCase("all")) {
  6153. try {
  6154. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  6155. } catch (RuntimeException re) {
  6156. LogUtil.errorLogInfo("", TAG, re);
  6157. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6158. return retStr;
  6159. } catch (Exception e) {
  6160. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  6161. //e.printStackTrace();
  6162. LogUtil.errorLogInfo("", TAG, e);
  6163. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6164. return retStr;
  6165. }
  6166. }
  6167. if (ctrl_action.contains("/")) {
  6168. String[] strParsed = ctrl_action.split("/");
  6169. if (strParsed[0].equals("set")) {
  6170. Set = true;
  6171. bCtrl_Set = true;
  6172. } else if (strParsed[0].equals("unset")) {
  6173. Set = false;
  6174. bCtrl_Set = true;
  6175. }
  6176. if (strParsed[1].equals("on")) {
  6177. OnOff = true;
  6178. bCtrl_OnOff = true;
  6179. } else if (strParsed[1].equals("off")) {
  6180. OnOff = false;
  6181. bCtrl_OnOff = true;
  6182. }
  6183. } else {
  6184. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  6185. if (ctrl_action.equalsIgnoreCase("set")) {
  6186. Set = true;
  6187. bCtrl_Set = true;
  6188. } else if (ctrl_action.equalsIgnoreCase("unset")) {
  6189. Set = false;
  6190. bCtrl_Set = true;
  6191. }
  6192. }
  6193. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  6194. if (ctrl_action.equalsIgnoreCase("on")) {
  6195. OnOff = true;
  6196. bCtrl_OnOff = true;
  6197. } else if (ctrl_action.equalsIgnoreCase("off")) {
  6198. OnOff = false;
  6199. bCtrl_OnOff = true;
  6200. }
  6201. }
  6202. }
  6203. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  6204. if (nDevNo == 1) {
  6205. if (unit_num.equalsIgnoreCase("all")) {
  6206. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6207. if (bCtrl_Set)
  6208. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  6209. if (bCtrl_OnOff)
  6210. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  6211. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6212. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6213. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6214. return retStr;
  6215. }
  6216. }
  6217. } else {
  6218. if (bCtrl_Set)
  6219. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  6220. if (bCtrl_OnOff)
  6221. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  6222. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6223. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6224. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6225. return retStr;
  6226. }
  6227. }
  6228. } else {
  6229. if (unit_num.equalsIgnoreCase("all")) {
  6230. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6231. if (bCtrl_Set)
  6232. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  6233. if (bCtrl_OnOff)
  6234. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  6235. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6236. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6237. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6238. return retStr;
  6239. }
  6240. }
  6241. } else {
  6242. if (bCtrl_Set)
  6243. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  6244. if (bCtrl_OnOff)
  6245. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  6246. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6247. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6248. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6249. return retStr;
  6250. }
  6251. }
  6252. }
  6253. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6254. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6255. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6256. return retStr;
  6257. }
  6258. retStr += " result=\"ok\">\r\n";
  6259. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6260. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6261. if (nDevNo == 1) {
  6262. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6263. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6264. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6265. status_mode = "unset";
  6266. else status_mode = "set";
  6267. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6268. status_onoff = "on";
  6269. else status_onoff = "off";
  6270. unit_status = status_mode + "/" + status_onoff;
  6271. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6272. }
  6273. // retStr += " </status_map>\r\n";
  6274. retStr += " </service>\r\n</imap>\r\n";
  6275. } else if (nDevNo > 1) {
  6276. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6277. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6278. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6279. status_mode = "unset";
  6280. else status_mode = "set";
  6281. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6282. status_onoff = "on";
  6283. else status_onoff = "off";
  6284. unit_status = status_mode + "/" + status_onoff;
  6285. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6286. }
  6287. // retStr += " </status_map>\r\n";
  6288. retStr += " </service>\r\n</imap>\r\n";
  6289. }
  6290. } else {
  6291. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  6292. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6293. }
  6294. return retStr;
  6295. } catch (RuntimeException re) {
  6296. LogUtil.errorLogInfo("", TAG, re);
  6297. return null;
  6298. } catch (Exception e) {
  6299. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  6300. //e.printStackTrace();
  6301. LogUtil.errorLogInfo("", TAG, e);
  6302. return null;
  6303. }
  6304. }
  6305. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  6306. try {
  6307. String retStr = CheckiCMDProc(MULTISW_CTR);
  6308. if (retStr != null) return retStr;
  6309. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\" ";
  6310. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6311. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6312. if (energymetercmd == null) return null;
  6313. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6314. if (energymeter == null) return null;
  6315. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6316. int ret = energymeter.Refresh((byte) 0xFF, false);
  6317. String result;
  6318. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  6319. else result = "fail";
  6320. retStr += (" result=\"" + result + "\" >\r\n");
  6321. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6322. retStr += MakeTargetStr(energymetercmd);
  6323. retStr += " <action>\"status\"</action>\r\n";
  6324. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6325. String unitStr;
  6326. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6327. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6328. if (i == 2) {
  6329. unitStr += "on";
  6330. } else {
  6331. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6332. }
  6333. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6334. }
  6335. }
  6336. retStr += " </service>\r\n</imap>\r\n";
  6337. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6338. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6339. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
  6340. byte cmd = 0;
  6341. int ret = 0;
  6342. String result;
  6343. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  6344. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  6345. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  6346. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  6347. if (cmd > 0) {
  6348. if (energymeter != null) {
  6349. energymeter.Refresh((byte) 0xFF, false);
  6350. if (cmd == 1) {
  6351. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  6352. } else if (cmd == 2) {
  6353. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  6354. } else if (cmd == 3) {
  6355. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
  6356. } else if (cmd == 4) {
  6357. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
  6358. }
  6359. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6360. else result = "fail";
  6361. retStr += (" result=\"" + result + "\" >\r\n");
  6362. if (ret == APIErrorCode.C_SUCCESS) {
  6363. ret = energymeter.Refresh((byte) 0xFF, false);
  6364. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6365. retStr += MakeTargetStr(energymetercmd);
  6366. retStr += " <action>\"control\"</action>\r\n";
  6367. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6368. String unitStr;
  6369. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6370. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6371. if (i == 2) {
  6372. unitStr += "on";
  6373. } else {
  6374. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6375. }
  6376. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6377. }
  6378. } else {
  6379. retStr += (" result=\"fail\"> \r\n");
  6380. }
  6381. } else {
  6382. retStr += (" result=\"fail\"> \r\n");
  6383. }
  6384. retStr += " </service>\r\n</imap>\r\n";
  6385. }
  6386. }
  6387. }
  6388. return retStr;
  6389. } catch (RuntimeException re) {
  6390. LogUtil.errorLogInfo("", TAG, re);
  6391. return null;
  6392. } catch (Exception e) {
  6393. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  6394. //e.printStackTrace();
  6395. LogUtil.errorLogInfo("", TAG, e);
  6396. return null;
  6397. }
  6398. }
  6399. public String iCMDProcModeControl(Document doc) {
  6400. try {
  6401. String status = "unknown";
  6402. boolean SendBR = false;
  6403. String retStr = CheckiCMDProc("remote_access_mode");
  6404. if (retStr != null) return retStr;
  6405. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  6406. String target = "null", tid = "null", msgno = "null";
  6407. NodeList items = doc.getElementsByTagName("target");
  6408. Node item = items.item(0);
  6409. if (item != null) {
  6410. NamedNodeMap attrs = item.getAttributes();
  6411. for (int j = 0; j < attrs.getLength(); j++) {
  6412. Node attr = attrs.item(j);
  6413. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6414. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6415. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6416. msgno = attr.getNodeValue();
  6417. }
  6418. }
  6419. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6420. if (NewServerUse()) {
  6421. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  6422. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6423. return ServerCheckResult;
  6424. }
  6425. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  6426. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  6427. int curState = SetData.GetAlarmStatus();
  6428. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  6429. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  6430. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  6431. switch (curState) {
  6432. case WallpadStatusData.GUARD_IN:
  6433. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  6434. Intent intent = new Intent();
  6435. intent.setAction(define.NOTIFY_ACNAME);
  6436. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6437. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  6438. getApplicationContext().sendBroadcast(intent);
  6439. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  6440. SendBR = true;
  6441. break;
  6442. case WallpadStatusData.GUARD_OUT:
  6443. break;
  6444. }
  6445. } else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  6446. switch (curState) {
  6447. case WallpadStatusData.ALARM_NONE:
  6448. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6449. if (mIGW200.checkSensorforInmode()) {
  6450. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6451. Intent intent = new Intent();
  6452. intent.setAction(define.NOTIFY_ACNAME);
  6453. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6454. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6455. getApplicationContext().sendBroadcast(intent);
  6456. SendBR = true;
  6457. } else {
  6458. SendBR = false;
  6459. }
  6460. } 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
  6461. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6462. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6463. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6464. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6465. if (mIGW300.checkSensorforInmode()) {
  6466. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6467. Intent intent = new Intent();
  6468. intent.setAction(define.NOTIFY_ACNAME);
  6469. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6470. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6471. getApplicationContext().sendBroadcast(intent);
  6472. SendBR = true;
  6473. } else {
  6474. SendBR = false;
  6475. }
  6476. } else {
  6477. if (checkSensorforInmode()) {
  6478. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6479. Intent intent = new Intent();
  6480. intent.setAction(define.NOTIFY_ACNAME);
  6481. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6482. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6483. getApplicationContext().sendBroadcast(intent);
  6484. Sound().PlayMent(SND.mode.INMODE_SETTING);
  6485. SendBR = true;
  6486. } else {
  6487. SendBR = false;
  6488. }
  6489. }
  6490. break;
  6491. default:
  6492. break;
  6493. }
  6494. } else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  6495. if (GetUseIlgalControlForAdmin() == false) {
  6496. // 관리자용 일괄소등 원격제어 사용안할 시
  6497. switch (curState) {
  6498. case WallpadStatusData.ALARM_NONE:
  6499. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6500. if (mIGW200.checkSensorforOutmode()) {
  6501. Common.SendAppFinishReqBR(getApplicationContext());
  6502. Intent intent = new Intent();
  6503. intent.setAction(define.NOTIFY_ACNAME);
  6504. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6505. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6506. getApplicationContext().sendBroadcast(intent);
  6507. SendBR = true;
  6508. } else {
  6509. SendBR = false;
  6510. }
  6511. } 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
  6512. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6513. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6514. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6515. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6516. if (mIGW300.checkSensorforOutmode()) {
  6517. Common.SendAppFinishReqBR(getApplicationContext());
  6518. Intent intent = new Intent();
  6519. intent.setAction(define.NOTIFY_ACNAME);
  6520. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6521. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6522. getApplicationContext().sendBroadcast(intent);
  6523. SendBR = true;
  6524. } else {
  6525. SendBR = false;
  6526. }
  6527. } else {
  6528. if (checkSensorforOutmode()) {
  6529. Common.SendAppFinishReqBR(getApplicationContext());
  6530. Intent intent = new Intent();
  6531. intent.setAction(define.NOTIFY_ACNAME);
  6532. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6533. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6534. getApplicationContext().sendBroadcast(intent);
  6535. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  6536. SendBR = true;
  6537. } else {
  6538. SendBR = false;
  6539. }
  6540. }
  6541. break;
  6542. default:
  6543. break;
  6544. }
  6545. } else {
  6546. // 관리자용 일괄소등 원격제어 사용 시
  6547. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6548. SendBR = true;
  6549. }
  6550. }
  6551. } else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  6552. int getStatus = SetData.GetAlarmStatus();
  6553. switch (getStatus) {
  6554. case WallpadStatusData.GUARD_IN:
  6555. status = "occupied";
  6556. break;
  6557. case WallpadStatusData.GUARD_OUT:
  6558. status = "unoccupied";
  6559. break;
  6560. case WallpadStatusData.ALARM_NONE:
  6561. status = "normal";
  6562. break;
  6563. case WallpadStatusData.ALARM_ARISE:
  6564. status = "emergency";
  6565. break;
  6566. default:
  6567. break;
  6568. }
  6569. retStr += ("\"ok\">\r\n ");
  6570. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6571. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6572. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6573. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6574. return retStr;
  6575. }
  6576. if (!SendBR) {
  6577. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6578. SetData.closeDB();
  6579. return retStr;
  6580. } else {
  6581. try {
  6582. Thread.sleep(1000);
  6583. } catch (RuntimeException re) {
  6584. LogUtil.errorLogInfo("", TAG, re);
  6585. } catch (Exception e) {
  6586. LogUtil.errorLogInfo("", TAG, e);
  6587. }
  6588. int getStatus = SetData.GetAlarmStatus();
  6589. switch (getStatus) {
  6590. case WallpadStatusData.GUARD_IN:
  6591. status = "occupied";
  6592. break;
  6593. case WallpadStatusData.GUARD_OUT:
  6594. status = "unoccupied";
  6595. break;
  6596. case WallpadStatusData.ALARM_NONE:
  6597. status = "normal";
  6598. break;
  6599. case WallpadStatusData.ALARM_ARISE:
  6600. status = "emergency";
  6601. break;
  6602. }
  6603. }
  6604. retStr += "\"ok\">\r\n";
  6605. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6606. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6607. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6608. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6609. SetData.closeDB();
  6610. return retStr;
  6611. } catch (RuntimeException re) {
  6612. LogUtil.errorLogInfo("", TAG, re);
  6613. return null;
  6614. } catch (Exception e) {
  6615. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6616. //e.printStackTrace();
  6617. LogUtil.errorLogInfo("", TAG, e);
  6618. return null;
  6619. }
  6620. }
  6621. public String iCMDProcCurtainControl(Document ele) {
  6622. return " ";
  6623. }
  6624. public String iCMDProcSDPLightControl(Document ele) {
  6625. try {
  6626. String retStr = CheckiCMDProc("remote_access_light");
  6627. if (retStr != null) return retStr;
  6628. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6629. String target = "null", tid = "null", msgno = "null";
  6630. NodeList items = ele.getElementsByTagName("target");
  6631. Node item = items.item(0);
  6632. if (item != null) {
  6633. NamedNodeMap attrs = item.getAttributes();
  6634. for (int j = 0; j < attrs.getLength(); j++) {
  6635. Node attr = attrs.item(j);
  6636. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6637. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6638. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6639. msgno = attr.getNodeValue();
  6640. }
  6641. }
  6642. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6643. if (NewServerUse()) {
  6644. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6645. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6646. return ServerCheckResult;
  6647. }
  6648. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6649. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6650. if (energymetercmd == null) return null;
  6651. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6652. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6653. if (energymeter == null) return null;
  6654. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6655. retStr += "result=\"ok\">\r\n" +
  6656. " <action>\"status\"</action>\r\n" +
  6657. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6658. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6659. 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");
  6660. }
  6661. retStr += "\r\n</service>\r\n</imap>";
  6662. } else {
  6663. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6664. }
  6665. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6666. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6667. num--;
  6668. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6669. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6670. if (energymeter == null) return null;
  6671. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6672. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6673. retStr += "result=\"ok\">\r\n" +
  6674. " <action>\"control\"</action>\r\n" +
  6675. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6676. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6677. 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");
  6678. }
  6679. retStr += "\r\n</service>\r\n</imap>";
  6680. } else {
  6681. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6682. }
  6683. } else {
  6684. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6685. }
  6686. } else {
  6687. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6688. }
  6689. energymetercmd = null;
  6690. return retStr;
  6691. } catch (RuntimeException re) {
  6692. LogUtil.errorLogInfo("", TAG, re);
  6693. return null;
  6694. } catch (Exception e) {
  6695. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6696. //e.printStackTrace();
  6697. LogUtil.errorLogInfo("", TAG, e);
  6698. return null;
  6699. }
  6700. }
  6701. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6702. try {
  6703. String retStr = CheckiCMDProc("remote_access_light");
  6704. if (retStr != null) return retStr;
  6705. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6706. String target = "null", tid = "null", msgno = "null";
  6707. NodeList items = ele.getElementsByTagName("target");
  6708. Node item = items.item(0);
  6709. if (item != null) {
  6710. NamedNodeMap attrs = item.getAttributes();
  6711. for (int j = 0; j < attrs.getLength(); j++) {
  6712. Node attr = attrs.item(j);
  6713. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6714. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6715. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6716. msgno = attr.getNodeValue();
  6717. }
  6718. }
  6719. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6720. if (NewServerUse()) {
  6721. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6722. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6723. return ServerCheckResult;
  6724. }
  6725. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6726. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6727. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6728. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6729. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6730. retStr += "result=\"ok\">\r\n" +
  6731. " <action>\"status\"</action>\r\n" +
  6732. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6733. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6734. 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");
  6735. }
  6736. retStr += "\r\n</service>\r\n</imap>";
  6737. } else {
  6738. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6739. }
  6740. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6741. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6742. num--;
  6743. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6744. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6745. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6746. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6747. retStr += "result=\"ok\">\r\n" +
  6748. " <action>\"control\"</action>\r\n" +
  6749. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6750. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6751. 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");
  6752. }
  6753. retStr += "\r\n</service>\r\n</imap>";
  6754. } else {
  6755. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6756. }
  6757. } else {
  6758. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6759. }
  6760. } else {
  6761. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6762. }
  6763. energymetercmd = null;
  6764. return retStr;
  6765. } catch (RuntimeException re) {
  6766. LogUtil.errorLogInfo("", TAG, re);
  6767. return null;
  6768. } catch (Exception e) {
  6769. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6770. //e.printStackTrace();
  6771. LogUtil.errorLogInfo("", TAG, e);
  6772. return null;
  6773. }
  6774. }
  6775. public String iCMDProcLightControl(Document ele) {
  6776. try {
  6777. String retStr = CheckiCMDProc("remote_access_light");
  6778. if (retStr != null) return retStr;
  6779. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6780. String target = "null", tid = "null", msgno = "null";
  6781. NodeList items = ele.getElementsByTagName("target");
  6782. Node item = items.item(0);
  6783. if (item != null) {
  6784. NamedNodeMap attrs = item.getAttributes();
  6785. for (int j = 0; j < attrs.getLength(); j++) {
  6786. Node attr = attrs.item(j);
  6787. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6788. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6789. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6790. msgno = attr.getNodeValue();
  6791. }
  6792. }
  6793. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6794. if (NewServerUse()) {
  6795. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6796. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6797. return ServerCheckResult;
  6798. }
  6799. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6800. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6801. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6802. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6803. if (bLightCMDUseAsSmartLight) {
  6804. if (mSdbAPI != null) {
  6805. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6806. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6807. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6808. retStr += "result=\"ok\">\r\n" +
  6809. " <action>\"status\"</action>\r\n";
  6810. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6811. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6812. } else {
  6813. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6814. }
  6815. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6816. 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");
  6817. }
  6818. retStr += " </service>\r\n</imap>";
  6819. } else {
  6820. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6821. }
  6822. } else {
  6823. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6824. }
  6825. } else {
  6826. if (mMultiSwitchAPI != null) {
  6827. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6828. if (nResult == 0) {
  6829. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6830. retStr += "result=\"ok\">\r\n" +
  6831. " <action>\"status\"</action>\r\n";
  6832. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6833. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6834. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6835. } else {
  6836. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6837. }
  6838. } else {
  6839. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6840. }
  6841. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6842. 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");
  6843. }
  6844. retStr += " </service>\r\n</imap>";
  6845. } else {
  6846. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6847. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6848. }
  6849. } else {
  6850. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6851. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6852. }
  6853. } else {
  6854. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  6855. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6856. }
  6857. }
  6858. } else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  6859. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6860. boolean OnOff = false;
  6861. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6862. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  6863. if (bLightCMDUseAsSmartLight) {
  6864. if (mSdbAPI != null) {
  6865. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6866. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  6867. if (ret >= 0) {
  6868. retStr += "result=\"ok\">\r\n" +
  6869. " <action>\"status\"</action>\r\n" +
  6870. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6871. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6872. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6873. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6874. 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");
  6875. }
  6876. retStr += " </service>\r\n</imap>";
  6877. } else {
  6878. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6879. }
  6880. } else {
  6881. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6882. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  6883. if (ret >= 0) {
  6884. retStr += "result=\"ok\">\r\n" +
  6885. " <action>\"status\"</action>\r\n" +
  6886. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6887. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6888. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6889. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6890. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  6891. 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");
  6892. }
  6893. retStr += " </service>\r\n</imap>";
  6894. } else {
  6895. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6896. }
  6897. }
  6898. } else {
  6899. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6900. }
  6901. } else {
  6902. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6903. if (mMultiSwitchAPI != null) {
  6904. int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6905. if (nResultRefresh == 0) {
  6906. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6907. if (nCtrlResult == 0) {
  6908. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6909. if (nResult == 0) {
  6910. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6911. retStr += "result=\"ok\">\r\n" +
  6912. " <action>\"status\"</action>\r\n" +
  6913. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6914. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  6915. 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");
  6916. }
  6917. retStr += " </service>\r\n</imap>";
  6918. } else {
  6919. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6920. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6921. }
  6922. } else {
  6923. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6924. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6925. }
  6926. } else {
  6927. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6928. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6929. }
  6930. } else {
  6931. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6932. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6933. }
  6934. }
  6935. } else {
  6936. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6937. if (mMultiSwitchAPI != null) {
  6938. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6939. if (nCtrlResult == 0) {
  6940. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6941. if (nResult == 0) {
  6942. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6943. retStr += "result=\"ok\">\r\n" +
  6944. " <action>\"status\"</action>\r\n" +
  6945. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6946. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6947. 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");
  6948. }
  6949. retStr += " </service>\r\n</imap>";
  6950. } else {
  6951. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6952. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6953. }
  6954. } else {
  6955. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6956. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6957. }
  6958. } else {
  6959. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6960. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6961. }
  6962. }
  6963. }
  6964. }
  6965. } else {
  6966. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6967. }
  6968. } else {
  6969. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6970. }
  6971. MSlightcmd = null;
  6972. return retStr;
  6973. } catch (RuntimeException re) {
  6974. LogUtil.errorLogInfo("", TAG, re);
  6975. return null;
  6976. } catch (Exception e) {
  6977. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  6978. //e.printStackTrace();
  6979. LogUtil.errorLogInfo("", TAG, e);
  6980. return null;
  6981. }
  6982. }
  6983. public String iCMDProcSDPSmartLightControl(Document ele) {
  6984. try {
  6985. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6986. String retStr = CheckiCMDProc("remote_access_smartlight");
  6987. if (retStr != null) return retStr;
  6988. else
  6989. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  6990. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6991. if (NewServerUse()) {
  6992. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  6993. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6994. return ServerCheckResult;
  6995. }
  6996. if (mSdb_LivingRoomLightAPI == null) {
  6997. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6998. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  6999. return retStr;
  7000. }
  7001. if (mSdbAPI == null) {
  7002. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7003. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  7004. return retStr;
  7005. }
  7006. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7007. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7008. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7009. return retStr;
  7010. }
  7011. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7012. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
  7013. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7014. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7015. return retStr;
  7016. }
  7017. }
  7018. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  7019. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7020. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7021. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7022. retStr += " result=\"ok\">\r\n";
  7023. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7024. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7025. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7026. for (int i = 0; i < nTotalLightCnt; i++) {
  7027. if (i == 0) {
  7028. 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";
  7029. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7030. String status_power = "off", status_dim = "null", status_color = "null";
  7031. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7032. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7033. } else {
  7034. status_power = "null";
  7035. }
  7036. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7037. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7038. } else {
  7039. status_dim = "null";
  7040. }
  7041. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7042. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7043. } else {
  7044. status_color = "null";
  7045. }
  7046. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7047. }
  7048. retStr += " </status_map>\r\n";
  7049. } else {
  7050. 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";
  7051. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7052. String status_power = "off", status_dim = "null", status_color = "null";
  7053. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7054. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7055. } else {
  7056. status_power = "null";
  7057. }
  7058. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7059. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7060. } else {
  7061. status_dim = "null";
  7062. }
  7063. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7064. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7065. } else {
  7066. status_color = "null";
  7067. }
  7068. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7069. }
  7070. retStr += " </status_map>\r\n";
  7071. }
  7072. }
  7073. retStr += " </service>\r\n</imap>\r\n";
  7074. } else {
  7075. int nDevNo = 0;
  7076. try {
  7077. nDevNo = Integer.parseInt(lightcmd.devnum);
  7078. } catch (RuntimeException re) {
  7079. LogUtil.errorLogInfo("", TAG, re);
  7080. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7081. return retStr;
  7082. } catch (Exception e) {
  7083. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  7084. //e.printStackTrace();
  7085. LogUtil.errorLogInfo("", TAG, e);
  7086. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7087. return retStr;
  7088. }
  7089. if ((nDevNo - 1) > nTotalLightCnt) {
  7090. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7091. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7092. return retStr;
  7093. }
  7094. retStr += " result=\"ok\">\r\n";
  7095. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7096. retStr += " <action>\"status\"</action>\r\n";
  7097. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7098. if (nDevNo == 1) {
  7099. 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";
  7100. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7101. String status_power = "off", status_dim = "null", status_color = "null";
  7102. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7103. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7104. } else {
  7105. status_power = "null";
  7106. }
  7107. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7108. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7109. } else {
  7110. status_dim = "null";
  7111. }
  7112. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7113. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7114. } else {
  7115. status_color = "null";
  7116. }
  7117. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7118. }
  7119. retStr += " </status_map>\r\n";
  7120. } else {
  7121. 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";
  7122. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7123. String status_power = "off", status_dim = "null", status_color = "null";
  7124. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7125. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7126. } else {
  7127. status_power = "null";
  7128. }
  7129. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7130. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7131. } else {
  7132. status_dim = "null";
  7133. }
  7134. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7135. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7136. } else {
  7137. status_color = "null";
  7138. }
  7139. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7140. }
  7141. retStr += " </status_map>\r\n";
  7142. }
  7143. retStr += " </service>\r\n</imap>\r\n";
  7144. }
  7145. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7146. int nResult = -99;
  7147. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7148. NodeList items = ele.getElementsByTagName("params");
  7149. Node item = items.item(0);
  7150. if (item != null) {
  7151. NamedNodeMap attrs = item.getAttributes();
  7152. for (int j = 0; j < attrs.getLength(); j++) {
  7153. Node attr = attrs.item(j);
  7154. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7155. dev_num = attr.getNodeValue();
  7156. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7157. dev_mode = attr.getNodeValue();
  7158. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7159. unit_num = attr.getNodeValue();
  7160. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7161. unit_status = attr.getNodeValue();
  7162. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7163. unit_dimming = attr.getNodeValue();
  7164. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7165. unit_color = attr.getNodeValue();
  7166. }
  7167. }
  7168. if (dev_num.equalsIgnoreCase("all")) {
  7169. nResult = 0;
  7170. for (int i = 0; i < nTotalLightCnt; i++) {
  7171. if (i == 0) {
  7172. nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7173. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7174. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7175. } else {
  7176. nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7177. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7178. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7179. }
  7180. }
  7181. if (nResult != 0) {
  7182. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7183. Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
  7184. return retStr;
  7185. } else {
  7186. retStr += " result=\"ok\">\r\n";
  7187. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7188. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7189. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7190. }
  7191. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7192. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7193. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7194. return retStr;
  7195. }
  7196. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
  7197. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7198. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7199. return retStr;
  7200. }
  7201. for (int i = 0; i < nTotalLightCnt; i++) {
  7202. if (i == 0) {
  7203. 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";
  7204. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7205. String status_power = "off", status_dim = "null", status_color = "null";
  7206. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7207. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7208. } else {
  7209. status_power = "null";
  7210. }
  7211. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7212. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7213. } else {
  7214. status_dim = "null";
  7215. }
  7216. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7217. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7218. } else {
  7219. status_color = "null";
  7220. }
  7221. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7222. }
  7223. retStr += " </status_map>\r\n";
  7224. } else {
  7225. 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";
  7226. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7227. String status_power = "off", status_dim = "null", status_color = "null";
  7228. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7229. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7230. } else {
  7231. status_power = "null";
  7232. }
  7233. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7234. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7235. } else {
  7236. status_dim = "null";
  7237. }
  7238. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7239. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7240. } else {
  7241. status_color = "null";
  7242. }
  7243. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7244. }
  7245. retStr += " </status_map>\r\n";
  7246. }
  7247. }
  7248. retStr += " </service>\r\n</imap>\r\n";
  7249. } else {
  7250. int nDevNo = 0;
  7251. int nUnitNo = 0;
  7252. try {
  7253. nDevNo = Integer.parseInt(dev_num);
  7254. } catch (RuntimeException re) {
  7255. LogUtil.errorLogInfo("", TAG, re);
  7256. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7257. return retStr;
  7258. } catch (Exception e) {
  7259. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7260. //e.printStackTrace();
  7261. LogUtil.errorLogInfo("", TAG, e);
  7262. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7263. return retStr;
  7264. }
  7265. if ((nDevNo - 1) > nTotalLightCnt) {
  7266. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7267. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7268. return retStr;
  7269. }
  7270. nResult = -99;
  7271. if (unit_num.equalsIgnoreCase("all")) {
  7272. if (nDevNo == 1) {
  7273. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7274. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7275. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7276. } else {
  7277. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7278. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7279. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7280. }
  7281. if (nResult != 0) {
  7282. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7283. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7284. return retStr;
  7285. }
  7286. } else {
  7287. try {
  7288. nUnitNo = Integer.parseInt(unit_num);
  7289. } catch (RuntimeException re) {
  7290. LogUtil.errorLogInfo("", TAG, re);
  7291. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7292. return retStr;
  7293. } catch (Exception e) {
  7294. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7295. //e.printStackTrace();
  7296. LogUtil.errorLogInfo("", TAG, e);
  7297. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7298. return retStr;
  7299. }
  7300. nResult = -99;
  7301. if (nDevNo == 1) {
  7302. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), 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) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7307. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7308. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7309. }
  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. }
  7316. if (nDevNo == 1) {
  7317. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7318. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7319. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7320. return retStr;
  7321. } else {
  7322. retStr += " result=\"ok\">\r\n";
  7323. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7324. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7325. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7326. }
  7327. 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";
  7328. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7329. String status_power = "off", status_dim = "null", status_color = "null";
  7330. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7331. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7332. } else {
  7333. status_power = "null";
  7334. }
  7335. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7336. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7337. } else {
  7338. status_dim = "null";
  7339. }
  7340. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7341. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7342. } else {
  7343. status_color = "null";
  7344. }
  7345. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7346. }
  7347. retStr += " </status_map>\r\n";
  7348. } else {
  7349. int nRealDevNo = (byte) (nDevNo - 2);
  7350. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
  7351. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7352. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7353. return retStr;
  7354. } else {
  7355. retStr += " result=\"ok\">\r\n";
  7356. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7357. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7358. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7359. }
  7360. 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";
  7361. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
  7362. String status_power = "off", status_dim = "null", status_color = "null";
  7363. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
  7364. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7365. } else {
  7366. status_power = "null";
  7367. }
  7368. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
  7369. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
  7370. } else {
  7371. status_dim = "null";
  7372. }
  7373. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
  7374. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
  7375. } else {
  7376. status_color = "null";
  7377. }
  7378. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7379. }
  7380. retStr += " </status_map>\r\n";
  7381. }
  7382. retStr += " </service>\r\n</imap>\r\n";
  7383. }
  7384. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  7385. int nResult = 0;
  7386. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7387. NodeList items = ele.getElementsByTagName("params");
  7388. Node item = items.item(0);
  7389. if (item != null) {
  7390. NamedNodeMap attrs = item.getAttributes();
  7391. for (int j = 0; j < attrs.getLength(); j++) {
  7392. Node attr = attrs.item(j);
  7393. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7394. dev_num = attr.getNodeValue();
  7395. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7396. dev_mode = attr.getNodeValue();
  7397. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7398. unit_num = attr.getNodeValue();
  7399. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7400. unit_status = attr.getNodeValue();
  7401. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7402. unit_dimming = attr.getNodeValue();
  7403. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7404. unit_color = attr.getNodeValue();
  7405. }
  7406. }
  7407. if (dev_num.equalsIgnoreCase("all")) {
  7408. if (!dev_mode.equals("null")) {
  7409. nResult = -99;
  7410. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7411. if (nResult != 0) {
  7412. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7413. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7414. return retStr;
  7415. }
  7416. } else {
  7417. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7418. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7419. return retStr;
  7420. }
  7421. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7422. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7423. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7424. return retStr;
  7425. } else {
  7426. retStr += " result=\"ok\">\r\n";
  7427. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7428. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7429. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7430. }
  7431. 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";
  7432. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  7433. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7434. } else {
  7435. int nDevNo = 0;
  7436. try {
  7437. nDevNo = Integer.parseInt(dev_num);
  7438. } catch (RuntimeException re) {
  7439. LogUtil.errorLogInfo("", TAG, re);
  7440. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7441. return retStr;
  7442. } catch (Exception e) {
  7443. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7444. //e.printStackTrace();
  7445. LogUtil.errorLogInfo("", TAG, e);
  7446. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7447. return retStr;
  7448. }
  7449. if (nDevNo != 1) {
  7450. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  7451. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7452. return retStr;
  7453. }
  7454. if (!dev_mode.equals("null")) {
  7455. nResult = -99;
  7456. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7457. if (nResult != 0) {
  7458. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7459. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7460. return retStr;
  7461. }
  7462. } else {
  7463. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7464. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7465. return retStr;
  7466. }
  7467. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7468. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7469. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7470. return retStr;
  7471. } else {
  7472. retStr += " result=\"ok\">\r\n";
  7473. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7474. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7475. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7476. }
  7477. 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";
  7478. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7479. String status_power = "off", status_dim = "null", status_color = "null";
  7480. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7481. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7482. } else {
  7483. status_power = "null";
  7484. }
  7485. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7486. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7487. } else {
  7488. status_dim = "null";
  7489. }
  7490. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7491. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7492. } else {
  7493. status_color = "null";
  7494. }
  7495. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7496. }
  7497. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7498. }
  7499. } else {
  7500. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7501. }
  7502. lightcmd = null;
  7503. return retStr;
  7504. } catch (RuntimeException re) {
  7505. LogUtil.errorLogInfo("", TAG, re);
  7506. return null;
  7507. } catch (Exception e) {
  7508. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7509. //e.printStackTrace();
  7510. LogUtil.errorLogInfo("", TAG, e);
  7511. return null;
  7512. }
  7513. }
  7514. private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
  7515. byte type = 0;
  7516. //각 스위치 개수는 4개임
  7517. switch (lightIndex) {
  7518. case 0:
  7519. type = benEm.Info.LightType_1;
  7520. break;
  7521. case 1:
  7522. type = benEm.Info.LightType_2;
  7523. break;
  7524. case 2:
  7525. type = benEm.Info.LightType_3;
  7526. break;
  7527. case 3:
  7528. type = benEm.Info.LightType_4;
  7529. break;
  7530. default:
  7531. break;
  7532. }
  7533. return type;
  7534. }
  7535. public String iCMDProcChumDamSmartLightControl(Document ele) {
  7536. try {
  7537. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7538. String retStr = CheckiCMDProc("remote_access_smartlight");
  7539. if (retStr != null) return retStr;
  7540. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7541. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7542. if (NewServerUse()) {
  7543. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7544. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7545. }
  7546. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  7547. if (KnxApi == null) {
  7548. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7549. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
  7550. return retStr;
  7551. }
  7552. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7553. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7554. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7555. return retStr;
  7556. }
  7557. int LivingLightCount = 0;
  7558. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  7559. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  7560. } else {
  7561. if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  7562. LivingLightCount = 1;
  7563. }
  7564. //기준층 명칭
  7565. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  7566. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  7567. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_LIGHT);
  7568. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  7569. int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  7570. int SwitchCount = KnxApi.data.MasterController.Info.Light_SwitchCount;
  7571. int totalLightCount = LivingLightCount + BadLightCount + SwitchCount;
  7572. int emCount = LivingLightCount + BadLightCount;
  7573. //mData.MasterController.Info.Light_SwitchCount
  7574. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
  7575. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
  7576. {
  7577. retStr += " result=\"ok\">\r\n";
  7578. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7579. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7580. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7581. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7582. for (int i = 0; i < totalLightCount; i++) {
  7583. if (i == 0) {
  7584. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7585. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7586. String status_power = "off", status_dim = "null", status_color = "null";
  7587. 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);
  7588. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7589. 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);
  7590. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7591. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7592. }
  7593. retStr += " </status_map>\r\n";
  7594. } else if(i>0 && i<emCount){
  7595. 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";
  7596. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7597. String status_power = "off", status_dim = "null", status_color = "null";
  7598. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7599. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7600. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7601. status_dim ="null";
  7602. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7603. }
  7604. retStr += " </status_map>\r\n";
  7605. } else{
  7606. 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";
  7607. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7608. String status_power = "off", status_dim = "null", status_color = "null";
  7609. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7610. status_dim ="null";
  7611. // zzz
  7612. //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
  7613. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7614. }
  7615. retStr += " </status_map>\r\n";
  7616. }
  7617. }
  7618. }
  7619. else
  7620. {
  7621. int nResult = 0;
  7622. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7623. NodeList items = ele.getElementsByTagName("params");
  7624. Node item = items.item(0);
  7625. if (item != null) {
  7626. NamedNodeMap attrs = item.getAttributes();
  7627. for (int j = 0; j< attrs.getLength(); j++) {
  7628. Node attr = attrs.item(j);
  7629. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7630. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7631. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7632. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7633. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7634. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7635. }
  7636. }
  7637. int nDevNo = Integer.parseInt(dev_num);
  7638. if (nDevNo == 1) {
  7639. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7640. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7641. String status_power = "off", status_dim = "null", status_color = "null";
  7642. 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);
  7643. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7644. 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);
  7645. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7646. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7647. }
  7648. retStr += " </status_map>\r\n";
  7649. } else if(nDevNo>1 && nDevNo<emCount+1){
  7650. 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";
  7651. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
  7652. String status_power = "off", status_dim = "null", status_color = "null";
  7653. status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7654. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
  7655. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
  7656. status_dim ="null";
  7657. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7658. }
  7659. retStr += " </status_map>\r\n";
  7660. } else{
  7661. 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";
  7662. for (int j = 0; j < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount; j++) {
  7663. String status_power = "off", status_dim = "null", status_color = "null";
  7664. status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7665. status_dim ="null";
  7666. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7667. }
  7668. retStr += " </status_map>\r\n";
  7669. }
  7670. }
  7671. retStr += " </service>\r\n</imap>\r\n";
  7672. }
  7673. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7674. int nResult = 0;
  7675. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7676. NodeList items = ele.getElementsByTagName("params");
  7677. Node item = items.item(0);
  7678. if (item != null) {
  7679. NamedNodeMap attrs = item.getAttributes();
  7680. for (int j = 0; j< attrs.getLength(); j++) {
  7681. Node attr = attrs.item(j);
  7682. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7683. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7684. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7685. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7686. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7687. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7688. }
  7689. }
  7690. if (dev_num.equalsIgnoreCase("ALL")) {
  7691. // 일괄소등 실행/해제
  7692. if (!unit_status.equalsIgnoreCase("null")) {
  7693. KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
  7694. }
  7695. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7696. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7697. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7698. return retStr;
  7699. }
  7700. retStr += " result=\"ok\">\r\n";
  7701. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7702. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7703. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7704. for (int i = 0; i < totalLightCount; i++) {
  7705. if (i == 0) {
  7706. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ "null" + "\" dev_name=\""+ knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7707. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7708. String status_power = "off", status_dim = "null", status_color = "null";
  7709. 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);
  7710. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7711. 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);
  7712. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7713. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7714. }
  7715. retStr += " </status_map>\r\n";
  7716. }
  7717. else if(i>0 && i<emCount){
  7718. 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";
  7719. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7720. String status_power = "off", status_dim = "null", status_color = "null";
  7721. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7722. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7723. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7724. status_dim ="null";
  7725. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7726. }
  7727. retStr += " </status_map>\r\n";
  7728. } else {
  7729. 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";
  7730. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7731. String status_power = "off", status_dim = "null", status_color = "null";
  7732. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7733. status_dim ="null";
  7734. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7735. }
  7736. retStr += " </status_map>\r\n";
  7737. }
  7738. }
  7739. retStr += " </service>\r\n</imap>\r\n";
  7740. }
  7741. else {
  7742. int nDevNo = 0;
  7743. int nUnitNo = 0;
  7744. try {
  7745. nDevNo = Integer.parseInt(dev_num);
  7746. } catch (Exception e) {
  7747. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7748. e.printStackTrace();
  7749. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7750. return retStr;
  7751. }
  7752. if ((nDevNo - 1) > totalLightCount) {
  7753. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
  7754. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7755. return retStr;
  7756. }
  7757. // retStr += " result=\"ok\">\r\n";
  7758. // retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7759. // retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7760. // retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7761. if (unit_num.equalsIgnoreCase("all")) {
  7762. if (nDevNo == 1) {
  7763. // 거실 조명 일괄제어일 경우
  7764. if (!unit_status.equalsIgnoreCase("null")) {
  7765. int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7766. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7767. }
  7768. if (!unit_dimming.equalsIgnoreCase("null")) {
  7769. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7770. }
  7771. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7772. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7773. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7774. return retStr;
  7775. }
  7776. retStr += " result=\"ok\">\r\n";
  7777. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7778. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7779. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7780. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7781. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7782. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7783. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7784. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7785. }
  7786. }
  7787. else if(nDevNo>1 && nDevNo<emCount+1){
  7788. // 각각 EM 조명 일괄제어일 경우
  7789. if (!unit_status.equalsIgnoreCase("null")) {
  7790. KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7791. }
  7792. if (!unit_dimming.equalsIgnoreCase("null")) {
  7793. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : ");
  7794. if( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_2 == 0x0F
  7795. || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_3 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_4 == 0x0F)
  7796. {
  7797. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] ==> Fan : " + nDevNo );
  7798. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7799. // 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
  7800. int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
  7801. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7802. }
  7803. }
  7804. else {
  7805. int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7806. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7807. }
  7808. //KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
  7809. }
  7810. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7811. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7812. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7813. return retStr;
  7814. }
  7815. retStr += " result=\"ok\">\r\n";
  7816. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7817. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7818. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7819. 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";
  7820. nDevNo = Integer.parseInt(dev_num);
  7821. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7822. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7823. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7824. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7825. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7826. status_dim ="null";
  7827. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7828. }
  7829. } else {
  7830. // 각각 EM 스위치 일괄제어일 경우
  7831. if (!unit_status.equalsIgnoreCase("null")) {
  7832. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7833. }
  7834. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7835. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7836. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7837. return retStr;
  7838. }
  7839. retStr += " result=\"ok\">\r\n";
  7840. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7841. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7842. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7843. 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";
  7844. nDevNo = Integer.parseInt(dev_num);
  7845. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7846. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7847. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7848. String status_dim ="null";
  7849. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7850. }
  7851. }
  7852. // retStr += " </status_map>\r\n";
  7853. // retStr += " </service>\r\n</imap>\r\n";
  7854. }
  7855. else {
  7856. // 회로별 제어일경우
  7857. try {
  7858. nUnitNo = Integer.parseInt(unit_num);
  7859. } catch (Exception e) {
  7860. Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7861. e.printStackTrace();
  7862. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7863. return retStr;
  7864. }
  7865. if (nDevNo == 1) {
  7866. if (!unit_status.equalsIgnoreCase("null")) {
  7867. int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
  7868. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7869. }
  7870. if (!unit_dimming.equalsIgnoreCase("null")) {
  7871. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7872. //mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  7873. }
  7874. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7875. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7876. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7877. return retStr;
  7878. }
  7879. retStr += " result=\"ok\">\r\n";
  7880. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7881. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7882. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7883. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7884. nDevNo = Integer.parseInt(dev_num);
  7885. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7886. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7887. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7888. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7889. }
  7890. }
  7891. else if(nDevNo>1 && nDevNo<emCount+1){
  7892. if (!unit_status.equalsIgnoreCase("null")) {
  7893. KnxApi.SetLightOnOff((byte) (nDevNo -2), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7894. //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7895. //회로별 제어는 On/Off 만 가능함
  7896. }
  7897. if (!unit_dimming.equalsIgnoreCase("null")) {
  7898. KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)(nUnitNo-1),(byte) Integer.parseInt(unit_dimming));
  7899. //일괄제어라 회로별 제어기능은 없음
  7900. // 시험 2021.05.12
  7901. }
  7902. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7903. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7904. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7905. return retStr;
  7906. }
  7907. retStr += " result=\"ok\">\r\n";
  7908. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7909. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7910. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7911. 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";
  7912. nDevNo = Integer.parseInt(dev_num);
  7913. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7914. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7915. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7916. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7917. status_dim ="null";
  7918. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7919. }
  7920. } else{
  7921. if (!unit_status.equalsIgnoreCase("null")) {
  7922. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7923. }
  7924. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7925. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7926. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7927. return retStr;
  7928. }
  7929. retStr += " result=\"ok\">\r\n";
  7930. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7931. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7932. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7933. 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";
  7934. nDevNo = Integer.parseInt(dev_num);
  7935. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7936. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7937. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7938. String status_dim ="null";
  7939. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7940. }
  7941. }
  7942. }
  7943. retStr += " </status_map>\r\n";
  7944. retStr += " </service>\r\n</imap>\r\n";
  7945. }
  7946. }
  7947. else {
  7948. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7949. }
  7950. return retStr;
  7951. } catch (Exception e) {
  7952. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7953. e.printStackTrace();
  7954. return null;
  7955. }
  7956. }
  7957. public String iCMDProcLivingLightControl(Document ele) {
  7958. try {
  7959. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7960. String retStr = CheckiCMDProc("remote_access_livinglight");
  7961. if (retStr != null) return retStr;
  7962. else
  7963. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  7964. String target = "null", tid = "null", msgno = "null";
  7965. NodeList items = ele.getElementsByTagName("target");
  7966. Node item = items.item(0);
  7967. if (item != null) {
  7968. NamedNodeMap attrs = item.getAttributes();
  7969. for (int j = 0; j < attrs.getLength(); j++) {
  7970. Node attr = attrs.item(j);
  7971. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7972. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7973. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  7974. msgno = attr.getNodeValue();
  7975. }
  7976. }
  7977. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7978. if (NewServerUse()) {
  7979. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7980. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  7981. return ServerCheckResult;
  7982. }
  7983. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7984. if (bLightCMDUseAsSmartLight) {
  7985. if (mSdb_LivingRoomLightAPI != null) {
  7986. mSdb_LivingRoomLightAPI.Refresh();
  7987. 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";
  7988. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7989. 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");
  7990. }
  7991. retStr += " </service>\r\n</imap>\r\n";
  7992. } else {
  7993. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7994. }
  7995. } else {
  7996. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  7997. if (lightCTR != null) {
  7998. if (lightCTR.Refresh(false) == 0) {
  7999. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8000. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8001. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8002. }
  8003. retStr += " </service>\r\n</imap>\r\n";
  8004. } else {
  8005. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  8006. }
  8007. }
  8008. }
  8009. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8010. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  8011. boolean OnOff = false;
  8012. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  8013. if (bLightCMDUseAsSmartLight) {
  8014. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8015. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  8016. if (ret >= 0) {
  8017. ret = mSdb_LivingRoomLightAPI.Refresh();
  8018. if (ret >= 0) {
  8019. 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";
  8020. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8021. 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");
  8022. }
  8023. retStr += " </service>\r\n</imap>\r\n";
  8024. } else {
  8025. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8026. }
  8027. } else {
  8028. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8029. }
  8030. } else {
  8031. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8032. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  8033. if (ret >= 0) {
  8034. ret = mSdb_LivingRoomLightAPI.Refresh();
  8035. if (ret >= 0) {
  8036. 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";
  8037. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8038. 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");
  8039. }
  8040. retStr += " </service>\r\n</imap>\r\n";
  8041. } else {
  8042. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8043. }
  8044. } else {
  8045. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8046. }
  8047. }
  8048. } else {
  8049. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8050. if (lightCTR != null) {
  8051. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8052. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  8053. if (ret >= 0) {
  8054. ret = lightCTR.Refresh(false);
  8055. if (ret >= 0) {
  8056. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8057. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8058. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8059. }
  8060. retStr += " </service>\r\n</imap>\r\n";
  8061. } else {
  8062. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8063. }
  8064. } else {
  8065. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8066. }
  8067. } else {
  8068. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8069. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  8070. if (ret >= 0) {
  8071. ret = lightCTR.Refresh(false);
  8072. if (ret >= 0) {
  8073. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8074. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8075. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8076. }
  8077. retStr += " </service>\r\n</imap>\r\n";
  8078. } else {
  8079. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8080. }
  8081. } else {
  8082. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8083. }
  8084. }
  8085. }
  8086. }
  8087. } else {
  8088. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8089. }
  8090. } else {
  8091. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  8092. }
  8093. lightcmd = null;
  8094. return retStr;
  8095. } catch (RuntimeException re) {
  8096. LogUtil.errorLogInfo("", TAG, re);
  8097. return null;
  8098. } catch (Exception e) {
  8099. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  8100. //e.printStackTrace();
  8101. LogUtil.errorLogInfo("", TAG, e);
  8102. return null;
  8103. }
  8104. }
  8105. public String iCMDProc_I_LightControl(Document ele) {
  8106. try {
  8107. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  8108. String retStr = CheckiCMDProc("remote_access_livinglight");
  8109. if (retStr != null) return retStr;
  8110. else
  8111. retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  8112. String target = "null", tid = "null", msgno = "null";
  8113. NodeList items = ele.getElementsByTagName("target");
  8114. Node item = items.item(0);
  8115. if (item != null) {
  8116. NamedNodeMap attrs = item.getAttributes();
  8117. for (int j = 0; j < attrs.getLength(); j++) {
  8118. Node attr = attrs.item(j);
  8119. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8120. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8121. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8122. msgno = attr.getNodeValue();
  8123. }
  8124. }
  8125. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8126. if (NewServerUse()) {
  8127. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8128. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8129. return ServerCheckResult;
  8130. }
  8131. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  8132. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8133. if (lightCTR != null && lightCTR.Refresh(false) == 0) {
  8134. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8135. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8136. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8137. }
  8138. retStr += " </service>\r\n</imap>\r\n";
  8139. } else {
  8140. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  8141. }
  8142. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8143. if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  8144. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  8145. int result = -999;
  8146. if (lightCTR != null) {
  8147. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  8148. result = lightCTR.LightProgramControl((byte) num, (byte) 1);
  8149. } else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  8150. result = lightCTR.LightProgramControl((byte) num, (byte) 0);
  8151. }
  8152. if (result >= 0) {
  8153. // 제어 성공
  8154. try {
  8155. Thread.sleep(1000);
  8156. } catch (RuntimeException re) {
  8157. LogUtil.errorLogInfo("", TAG, re);
  8158. } catch (Exception e) {
  8159. LogUtil.errorLogInfo("", TAG, e);
  8160. }
  8161. lightCTR.Refresh(false);
  8162. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8163. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8164. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8165. }
  8166. retStr += " </service>\r\n</imap>";
  8167. } else {
  8168. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8169. }
  8170. } else {
  8171. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8172. }
  8173. } else {
  8174. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8175. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  8176. if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  8177. try {
  8178. Thread.sleep(1000);
  8179. } catch (RuntimeException re) {
  8180. LogUtil.errorLogInfo("", TAG, re);
  8181. } catch (Exception e) {
  8182. LogUtil.errorLogInfo("", TAG, e);
  8183. }
  8184. lightCTR.Refresh(false);
  8185. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8186. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8187. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8188. }
  8189. retStr += " </service>\r\n</imap>\r\n";
  8190. } else {
  8191. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8192. }
  8193. }
  8194. } else {
  8195. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  8196. }
  8197. lightcmd = null;
  8198. return retStr;
  8199. } catch (RuntimeException re) {
  8200. LogUtil.errorLogInfo("", TAG, re);
  8201. return null;
  8202. } catch (Exception e) {
  8203. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  8204. //e.printStackTrace();
  8205. LogUtil.errorLogInfo("", TAG, e);
  8206. return null;
  8207. }
  8208. }
  8209. public String iCMDProcGASControl(Element ele) {
  8210. try {
  8211. String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
  8212. String strResult = CheckiCMDProc("remote_access_gas");
  8213. if (strResult != null) return strResult;
  8214. else
  8215. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  8216. NodeList items = ele.getElementsByTagName("target");
  8217. Node item = items.item(0);
  8218. if (item != null) {
  8219. NamedNodeMap attrs = item.getAttributes();
  8220. for (int j = 0; j < attrs.getLength(); j++) {
  8221. Node attr = attrs.item(j);
  8222. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8223. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8224. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8225. msgno = attr.getNodeValue();
  8226. }
  8227. }
  8228. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8229. if (NewServerUse()) {
  8230. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  8231. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8232. return ServerCheckResult;
  8233. }
  8234. NodeList itemsParam = ele.getElementsByTagName("params");
  8235. Node itemParam = itemsParam.item(0);
  8236. if (itemParam != null) {
  8237. NamedNodeMap attrsParam = itemParam.getAttributes();
  8238. for (int j = 0; j < attrsParam.getLength(); j++) {
  8239. Node attr = attrsParam.item(j);
  8240. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8241. devnum = attr.getNodeValue();
  8242. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  8243. //unitnum = attr.getNodeValue();
  8244. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8245. ctraction = attr.getNodeValue();
  8246. }
  8247. }
  8248. NodeList itemsaction = ele.getElementsByTagName("action");
  8249. Node itemaction = itemsaction.item(0);
  8250. Node text = itemaction.getFirstChild();
  8251. String actionTXT = text.getNodeValue();
  8252. //수정
  8253. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  8254. actionTXT = trimquotation(actionTXT);
  8255. GasAPI GasValveCTR = null;
  8256. CooktopAPI HybridCookTopCTR = null;
  8257. if (mWallPadAPI.GetGasKind() == 2) {
  8258. //하이브리드
  8259. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  8260. } else {
  8261. GasValveCTR = mWallPadAPI.Get_GasController();
  8262. }
  8263. if (actionTXT.equalsIgnoreCase("status")) {
  8264. // 가스밸브 상태 조회
  8265. if (mWallPadAPI.GetGasKind() == 2) {
  8266. //하이브리드
  8267. if (HybridCookTopCTR != null) {
  8268. //전체 정보가져오기
  8269. int ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8270. if (ret < 0) {
  8271. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8272. return strResult;
  8273. }
  8274. int OnOpenCount = 0;
  8275. int OperationCount = 0;
  8276. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8277. // 콘센트 ON/OFF 업데이트
  8278. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8279. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8280. OnOpenCount++;
  8281. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8282. OperationCount++;
  8283. }
  8284. }
  8285. }
  8286. if (OperationCount > 0) {
  8287. valvestatus = "ing";
  8288. } else if (OnOpenCount > 0) {
  8289. valvestatus = "open";
  8290. } else {
  8291. valvestatus = "close";
  8292. }
  8293. }
  8294. } else {
  8295. if (GasValveCTR != null) {
  8296. int ret = GasValveCTR.Refresh((byte) 0, false);
  8297. if (ret < 0) {
  8298. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8299. return strResult;
  8300. }
  8301. if (GasValveCTR.data.DeviceCnt == 2) {
  8302. GasValveCTR.Refresh((byte) 1, false);
  8303. }
  8304. byte GasStatus = GasAPI.GASSTATUS.Close;
  8305. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8306. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8307. GasStatus = GasAPI.GASSTATUS.Operation;
  8308. break;
  8309. }
  8310. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8311. GasStatus = GasAPI.GASSTATUS.Open;
  8312. break;
  8313. }
  8314. }
  8315. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8316. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8317. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8318. else valvestatus = "unknown";
  8319. }
  8320. }
  8321. } else if (actionTXT.equalsIgnoreCase("control")) {
  8322. // 가스밸브 콘트롤
  8323. if (mWallPadAPI.GetGasKind() == 2) {
  8324. //하이브리드
  8325. if (HybridCookTopCTR != null) {
  8326. int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
  8327. if (ret < 0) {
  8328. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8329. return strResult;
  8330. }
  8331. ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8332. if (ret < 0) {
  8333. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8334. return strResult;
  8335. }
  8336. int OnOpenCount = 0;
  8337. int OperationCount = 0;
  8338. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8339. // 콘센트 ON/OFF 업데이트
  8340. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8341. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8342. OnOpenCount++;
  8343. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8344. OperationCount++;
  8345. }
  8346. }
  8347. }
  8348. if (OperationCount > 0) {
  8349. valvestatus = "ing";
  8350. } else if (OnOpenCount > 0) {
  8351. valvestatus = "open";
  8352. } else {
  8353. valvestatus = "close";
  8354. }
  8355. }
  8356. } else {
  8357. if (GasValveCTR != null) {
  8358. int ret = GasValveCTR.SetClose((byte) 0xFF);
  8359. if (ret < 0) {
  8360. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8361. return strResult;
  8362. }
  8363. ret = GasValveCTR.Refresh((byte) 0, false);
  8364. if (ret < 0) {
  8365. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8366. return strResult;
  8367. }
  8368. if (GasValveCTR.data.DeviceCnt == 2) {
  8369. GasValveCTR.Refresh((byte) 1, false);
  8370. }
  8371. byte GasStatus = GasAPI.GASSTATUS.Close;
  8372. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8373. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8374. GasStatus = GasAPI.GASSTATUS.Operation;
  8375. break;
  8376. }
  8377. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8378. GasStatus = GasAPI.GASSTATUS.Open;
  8379. break;
  8380. }
  8381. }
  8382. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8383. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8384. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8385. else valvestatus = "unknown";
  8386. }
  8387. }
  8388. } else {
  8389. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8390. return strResult;
  8391. }
  8392. strResult += "\"ok\" >\r\n";
  8393. strResult += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8394. strResult += " <action>\"" + actionTXT + "\"</action>\r\n";
  8395. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  8396. strResult += " <status_info unit_num=\"gas1\" unit_status=\"" + valvestatus + "\"/>\r\n";
  8397. strResult += " </service>\r\n";
  8398. strResult += "</imap> ";
  8399. return strResult;
  8400. } catch (RuntimeException re) {
  8401. LogUtil.errorLogInfo("", TAG, re);
  8402. return null;
  8403. } catch (Exception e) {
  8404. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  8405. //e.printStackTrace();
  8406. LogUtil.errorLogInfo("", TAG, e);
  8407. return null;
  8408. }
  8409. }
  8410. private String iCMDProcLightBatchControl(Element ele) {
  8411. try {
  8412. String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
  8413. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  8414. if (retStr != null) return retStr;
  8415. NodeList items = ele.getElementsByTagName("target");
  8416. Node item = items.item(0);
  8417. if (item != null) {
  8418. NamedNodeMap attrs = item.getAttributes();
  8419. for (int j = 0; j < attrs.getLength(); j++) {
  8420. Node attr = attrs.item(j);
  8421. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8422. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8423. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8424. msgno = attr.getNodeValue();
  8425. }
  8426. }
  8427. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8428. if (NewServerUse()) {
  8429. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8430. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8431. return ServerCheckResult;
  8432. }
  8433. NodeList itemsParam = ele.getElementsByTagName("params");
  8434. Node itemParam = itemsParam.item(0);
  8435. if (itemParam != null) {
  8436. NamedNodeMap attrsParam = itemParam.getAttributes();
  8437. for (int j = 0; j < attrsParam.getLength(); j++) {
  8438. Node attr = attrsParam.item(j);
  8439. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8440. ctraction = attr.getNodeValue();
  8441. }
  8442. }
  8443. }
  8444. NodeList itemsaction = ele.getElementsByTagName("action");
  8445. Node itemaction = itemsaction.item(0);
  8446. Node text = itemaction.getFirstChild();
  8447. String actionTXT = text.getNodeValue();
  8448. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  8449. actionTXT = trimquotation(actionTXT);
  8450. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8451. if (actionTXT.equalsIgnoreCase("status")) {
  8452. // 일괄소등 상태 조회
  8453. int ret = mWallPadAPI.GetBatchSwitchStatus();
  8454. if (ret > 1) {
  8455. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8456. return retStr;
  8457. }
  8458. if (ret == 0) {
  8459. ilgalstatus = "on";
  8460. } else if (ret == 1) {
  8461. ilgalstatus = "off";
  8462. } else {
  8463. ilgalstatus = "error";
  8464. }
  8465. } else if (actionTXT.equalsIgnoreCase("control")) {
  8466. // 일괄소등 제어
  8467. int ret = -1;
  8468. int status = -1;
  8469. if (ctraction.equals("on") == true) {
  8470. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  8471. status = 0;
  8472. } else if (ctraction.equals("off") == true) {
  8473. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  8474. status = 1;
  8475. }
  8476. if (ret < 0) {
  8477. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8478. return retStr;
  8479. }
  8480. if (status == 0) {
  8481. ilgalstatus = "on";
  8482. } else if (status == 1) {
  8483. ilgalstatus = "off";
  8484. } else {
  8485. ilgalstatus = "error";
  8486. }
  8487. } else {
  8488. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8489. return retStr;
  8490. }
  8491. retStr += "\"ok\" >\r\n";
  8492. retStr += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8493. retStr += " <action>\"" + actionTXT + "\"</action>\r\n";
  8494. retStr += " <status_info unit_status=\"" + ilgalstatus + "\"/>\r\n </service>\r\n</imap> ";
  8495. return retStr;
  8496. } catch (RuntimeException re) {
  8497. LogUtil.errorLogInfo("", TAG, re);
  8498. return null;
  8499. } catch (Exception e) {
  8500. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  8501. //e.printStackTrace();
  8502. LogUtil.errorLogInfo("", TAG, e);
  8503. return null;
  8504. }
  8505. }
  8506. private boolean airconTestMode = false;
  8507. private boolean [] airconTestModeOnOff = {false, true, false, true, false, true, false, true, false, true, false};
  8508. private String getTextSysAirconMode(byte in)
  8509. {
  8510. if( in == DataClasses.KnxSystemAircon.MODE.Auto)
  8511. return "auto";
  8512. else if( in == DataClasses.KnxSystemAircon.MODE.Cold)
  8513. return "cool";
  8514. else if( in == DataClasses.KnxSystemAircon.MODE.Dry)
  8515. return "dehum";
  8516. else if( in == DataClasses.KnxSystemAircon.MODE.Venti)
  8517. return "blow";
  8518. else if( in == DataClasses.KnxSystemAircon.MODE.Heat)
  8519. return "heat";
  8520. else
  8521. return "null";
  8522. }
  8523. private String iCMDProcSysairconControl(Element ele) {
  8524. try {
  8525. String target= "null", tid= "null", msgno= "null", devnum = "null",ctraction = "null", ilgalstatus = "null";
  8526. String retStr = CheckiCMDProc("remote_access_sysaircon");
  8527. if (retStr != null) return retStr;
  8528. NodeList items = ele.getElementsByTagName("target");
  8529. Node item = items.item(0);
  8530. if (item != null) {
  8531. NamedNodeMap attrs = item.getAttributes();
  8532. for (int j = 0; j < attrs.getLength(); j++) {
  8533. Node attr = attrs.item(j);
  8534. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8535. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8536. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  8537. }
  8538. }
  8539. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8540. if (NewServerUse()) {
  8541. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8542. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  8543. }
  8544. NodeList itemsParam = ele.getElementsByTagName("params");
  8545. Node itemParam = itemsParam.item(0);
  8546. if (itemParam != null) {
  8547. NamedNodeMap attrsParam = itemParam.getAttributes();
  8548. for (int j = 0; j < attrsParam.getLength(); j++) {
  8549. Node attr = attrsParam.item(j);
  8550. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  8551. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8552. ctraction = attr.getNodeValue();
  8553. }
  8554. }
  8555. }
  8556. NodeList itemsaction = ele.getElementsByTagName("action");
  8557. Node itemaction = itemsaction.item(0);
  8558. Node text = itemaction.getFirstChild();
  8559. String actionTXT = text.getNodeValue();
  8560. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_sysaircon\" result=";
  8561. actionTXT = trimquotation(actionTXT);
  8562. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8563. int ndeviceCount = 0;
  8564. String sMode = "auto/cool/dehum/blow/heat"; // 자동, 냉방, 제습, 송풍, 난방
  8565. String [] aMode = {"auto","cool","dehum","blow","heat"};
  8566. String strResultStatus = "";
  8567. //기준층 명칭
  8568. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  8569. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  8570. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_SYSTEMAIRCON);
  8571. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  8572. String [] mTextWindType = {"자동", "약", "중", "강"};
  8573. String m_TextWindRange = "자동/약/중/강";
  8574. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  8575. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  8576. mWallpadDeviceSet.closeDB();
  8577. if (nResult != Version.DISTRIBUTION_MODEL.KNX_DIST) {
  8578. String[] mAirconNmae = new String[]{"에어컨1", "에어컨2", "에어컨3", "에어컨4", "에어컨5", "에어컨6", "에어컨7", "에어컨8"};
  8579. knxRoomNameList = mAirconNmae;
  8580. }
  8581. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  8582. int nCount = 7;
  8583. if( airconAPI != null )
  8584. nCount = airconAPI.data.Device.info.InsideAirconCount;
  8585. if( airconTestMode == true )nCount = 7;
  8586. if( actionTXT.equalsIgnoreCase("status") ) {
  8587. // 에어컨 상태조회
  8588. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8589. if (devnum.equalsIgnoreCase("all")) {
  8590. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : airconTestMode : " + airconTestMode + " nCount : " + nCount );
  8591. if (airconTestMode == false && ret < 0) {
  8592. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8593. return retStr;
  8594. } else {
  8595. for (int i = 0; i < nCount; i++) {
  8596. String sOnOff = "off";
  8597. if( airconTestMode == true )
  8598. {
  8599. if( airconTestModeOnOff[i] == true )sOnOff = "on";
  8600. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8601. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8602. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8603. }
  8604. else {
  8605. if (airconAPI.data.Device.Aircon[i].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8606. sOnOff = "on";
  8607. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8608. 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";
  8609. }
  8610. }
  8611. }
  8612. }
  8613. else
  8614. {
  8615. // 개별 상태 조회
  8616. if (airconTestMode == false && ret < 0) {
  8617. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8618. return retStr;
  8619. } else {
  8620. int reqDevNum = Integer.parseInt(devnum);
  8621. String sOnOff = "off";
  8622. if( airconTestMode == true )
  8623. {
  8624. if( airconTestModeOnOff[reqDevNum-1] == true )sOnOff = "on";
  8625. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8626. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8627. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8628. }
  8629. else {
  8630. if (airconAPI.data.Device.Aircon[reqDevNum-1].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8631. sOnOff = "on";
  8632. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8633. 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";
  8634. }
  8635. }
  8636. }
  8637. }
  8638. else if (actionTXT.equalsIgnoreCase("control")) {
  8639. // 에어컨 제어
  8640. String[] CtrList;
  8641. CtrList = ctraction.split("/");
  8642. for( int k = 0 ; k < CtrList.length; k++)
  8643. {
  8644. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : CtrList[k] : " + k + " CtrList[k] : " + CtrList[k]);
  8645. }
  8646. strResultStatus = "";
  8647. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8648. if (devnum.equalsIgnoreCase("all")) {
  8649. // 일괄제어는 Off 밖에 없음
  8650. if( airconTestMode == true )
  8651. {
  8652. for (int i = 0; i < nCount; i++) {
  8653. String sOnOff = "off";
  8654. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8655. if(CtrList[0].equalsIgnoreCase("off"))
  8656. {
  8657. airconTestModeOnOff[i] = false;
  8658. }
  8659. else
  8660. {
  8661. airconTestModeOnOff[i] = true;
  8662. sOnOff = "on";
  8663. }
  8664. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8665. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8666. }
  8667. }
  8668. else
  8669. {
  8670. for (int i = 0; i < nCount; i++) {
  8671. String sOnOff = "off";
  8672. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8673. byte hOnOff = 0x00;
  8674. if(CtrList[0].equalsIgnoreCase("off"))
  8675. {
  8676. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8677. sOnOff = "off";
  8678. }
  8679. else
  8680. {
  8681. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8682. sOnOff = "on";
  8683. }
  8684. double setTemp = airconAPI.data.Device.Aircon[i].SetTemp;
  8685. byte volume = airconAPI.data.Device.Aircon[i].Volume;
  8686. byte mode = airconAPI.data.Device.Aircon[i].Mode;
  8687. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8688. ret = airconAPI.SetEachRoomStatus((byte)i, hMode, setTemp);
  8689. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8690. 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";
  8691. }
  8692. }
  8693. }
  8694. else
  8695. {
  8696. // 개별 제어
  8697. int nDevNum = Integer.parseInt(devnum);
  8698. if( airconTestMode == true )
  8699. {
  8700. String sOnOff = "off";
  8701. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8702. if(CtrList[0].equalsIgnoreCase("off"))
  8703. {
  8704. airconTestModeOnOff[nDevNum-1] = false;
  8705. }
  8706. else
  8707. {
  8708. airconTestModeOnOff[nDevNum-1] = true;
  8709. sOnOff = "on";
  8710. }
  8711. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8712. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8713. }
  8714. else
  8715. {
  8716. String sOnOff = "off";
  8717. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8718. byte hOnOff = 0x00;
  8719. if(CtrList[0].equalsIgnoreCase("off"))
  8720. {
  8721. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8722. sOnOff = "off";
  8723. }
  8724. else
  8725. {
  8726. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8727. sOnOff = "on";
  8728. }
  8729. //String [] aMode = {"auto","cool","dehum","blow","heat"};
  8730. byte mode = 0x00;
  8731. if(CtrList[1].equalsIgnoreCase("auto"))
  8732. mode = DataClasses.KnxSystemAircon.MODE.Auto;
  8733. else if(CtrList[1].equalsIgnoreCase("cool"))
  8734. mode = DataClasses.KnxSystemAircon.MODE.Cold;
  8735. else if(CtrList[1].equalsIgnoreCase("dehum"))
  8736. mode = DataClasses.KnxSystemAircon.MODE.Dry;
  8737. else if(CtrList[1].equalsIgnoreCase("blow"))
  8738. mode = DataClasses.KnxSystemAircon.MODE.Venti;
  8739. else if(CtrList[1].equalsIgnoreCase("heat"))
  8740. mode = DataClasses.KnxSystemAircon.MODE.Heat;
  8741. else
  8742. mode = airconAPI.data.Device.Aircon[nDevNum-1].Mode;
  8743. byte volume = 0x00;
  8744. if(CtrList[2].equalsIgnoreCase(mTextWindType[0]))
  8745. volume = DataClasses.KnxSystemAircon.VOLUME.Auto;
  8746. else if(CtrList[2].equalsIgnoreCase(mTextWindType[1]))
  8747. volume = DataClasses.KnxSystemAircon.VOLUME.Weak;
  8748. else if(CtrList[2].equalsIgnoreCase(mTextWindType[2]))
  8749. volume = DataClasses.KnxSystemAircon.VOLUME.Medium;
  8750. else if(CtrList[2].equalsIgnoreCase(mTextWindType[3]))
  8751. volume = DataClasses.KnxSystemAircon.VOLUME.Strong;
  8752. else
  8753. volume = airconAPI.data.Device.Aircon[nDevNum-1].Volume;
  8754. double setTemp = 0;
  8755. if( CtrList[3].equalsIgnoreCase("null"))
  8756. setTemp = airconAPI.data.Device.Aircon[nDevNum-1].SetTemp;
  8757. else
  8758. setTemp = Double.parseDouble(CtrList[3]);
  8759. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8760. ret = airconAPI.SetEachRoomStatus((byte)(nDevNum-1), hMode, setTemp);
  8761. if( ret >= 0 ) {
  8762. ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8763. }
  8764. double curTemp = airconAPI.data.Device.Aircon[nDevNum-1].NowTemp;
  8765. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8766. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume] + "/" + setTemp + "/" + curTemp + "\"/>\r\n";
  8767. }
  8768. }
  8769. }
  8770. else {
  8771. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8772. return retStr;
  8773. }
  8774. retStr += "\"ok\" >\r\n";
  8775. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  8776. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  8777. retStr += strResultStatus;
  8778. retStr += " </service>\r\n";
  8779. retStr += "</imap> ";
  8780. return retStr;
  8781. } catch (Exception e) {
  8782. Log.e(TAG, "[Exception] iCMDProcSysairconControl(Document ele)");
  8783. e.printStackTrace();
  8784. return null;
  8785. }
  8786. }
  8787. private String iCMDProcEntireLightControl(Document ele) {
  8788. try {
  8789. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  8790. if (retStr != null) return retStr;
  8791. else
  8792. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  8793. String sDong = null;
  8794. String sHo = null;
  8795. String sDevice_Num = null;
  8796. String sSelCtrl_Action = null;
  8797. String sUnselCtrl_Action = null;
  8798. NodeList items = ele.getElementsByTagName("home_info");
  8799. Node item = items.item(0);
  8800. NamedNodeMap attrsParam = item.getAttributes();
  8801. for (int i = 0; i < attrsParam.getLength(); i++) {
  8802. Node attr = attrsParam.item(i);
  8803. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8804. sDong = trimquotation(attr.getNodeValue());
  8805. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8806. sHo = trimquotation(attr.getNodeValue());
  8807. }
  8808. WallpadStatusData DBMGR = null;
  8809. DBMGR = new WallpadStatusData(getApplicationContext());
  8810. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8811. DBMGR.closeDB();
  8812. if (mSdb_LivingRoomLightAPI == null) {
  8813. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  8814. retStr += " result=\"fail\" >\r\n";
  8815. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8816. retStr += " </service>\r\n</imap>";
  8817. return retStr;
  8818. }
  8819. if (mSdbAPI == null) {
  8820. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  8821. retStr += " result=\"fail\" >\r\n";
  8822. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8823. retStr += " </service>\r\n</imap>";
  8824. return retStr;
  8825. }
  8826. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
  8827. items = ele.getElementsByTagName("sel_ctrlinfo");
  8828. item = items.item(0);
  8829. attrsParam = item.getAttributes();
  8830. for (int i = 0; i < attrsParam.getLength(); i++) {
  8831. Node attr = attrsParam.item(i);
  8832. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8833. sDevice_Num = trimquotation(attr.getNodeValue());
  8834. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8835. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  8836. }
  8837. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  8838. int result = -1; // 조명 제어 결과
  8839. boolean bLivingLightSel = false; // 거실조명 선택 여부
  8840. // ============================== 선택된 조명 ==============================
  8841. String[] sel_devNum = null;
  8842. if (sDevice_Num != null && sDevice_Num.contains("light")) {
  8843. if (sDevice_Num.contains("/"))
  8844. sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  8845. else {
  8846. sel_devNum = new String[1];
  8847. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  8848. }
  8849. }
  8850. if (sel_devNum == null) sel_devNum = new String[0];
  8851. for (int i = 0; i < sel_devNum.length; i++) {
  8852. if (sel_devNum[i].equals("1")) {
  8853. bLivingLightSel = true;
  8854. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  8855. if (sSelCtrl_Action != null) {
  8856. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8857. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8858. } else {
  8859. int nColor = 0;
  8860. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8861. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8862. if (nColor > 0) {
  8863. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8864. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8865. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8866. }
  8867. }
  8868. // 거실조명 제어 결과
  8869. if (result < 0) {
  8870. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  8871. retStr += " result=\"fail\" >\r\n";
  8872. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8873. retStr += " </service>\r\n</imap>";
  8874. return retStr;
  8875. }
  8876. }
  8877. } else {
  8878. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  8879. if (sSelCtrl_Action != null) {
  8880. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8881. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  8882. } else {
  8883. int nColor = 0;
  8884. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8885. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8886. if (nColor > 0) {
  8887. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  8888. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  8889. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  8890. }
  8891. }
  8892. }
  8893. // 그 외 방 조명 제어 결과
  8894. if (result < 0) {
  8895. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  8896. retStr += " result=\"fail\" >\r\n";
  8897. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8898. retStr += " </service>\r\n</imap>";
  8899. return retStr;
  8900. }
  8901. }
  8902. }
  8903. // ============================== 선택안된 조명 ==============================
  8904. items = ele.getElementsByTagName("unsel_ctrlinfo");
  8905. item = items.item(0);
  8906. attrsParam = item.getAttributes();
  8907. for (int i = 0; i < attrsParam.getLength(); i++) {
  8908. Node attr = attrsParam.item(i);
  8909. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8910. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  8911. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  8912. }
  8913. if (!bLivingLightSel) {
  8914. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  8915. if (sUnselCtrl_Action != null) {
  8916. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8917. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8918. } else {
  8919. int nColor = 0;
  8920. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8921. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8922. if (nColor > 0) {
  8923. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8924. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8925. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8926. }
  8927. }
  8928. }
  8929. if (result < 0) {
  8930. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  8931. retStr += " result=\"fail\" >\r\n";
  8932. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8933. retStr += " </service>\r\n</imap>";
  8934. return retStr;
  8935. }
  8936. }
  8937. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  8938. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  8939. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  8940. unsel_devNum.add(i + 1);
  8941. }
  8942. for (int i = 0; i < unsel_devNum.size(); i++) {
  8943. for (int j = 0; j < sel_devNum.length; j++) {
  8944. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
  8945. unsel_devNum.remove(i);
  8946. }
  8947. }
  8948. for (int i = 0; i < unsel_devNum.size(); i++) {
  8949. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
  8950. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8951. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  8952. } else {
  8953. int nColor = 0;
  8954. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8955. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8956. if (nColor > 0) {
  8957. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  8958. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  8959. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  8960. }
  8961. }
  8962. if (result < 0) {
  8963. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  8964. retStr += " result=\"fail\" >\r\n";
  8965. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8966. retStr += " </service>\r\n</imap>";
  8967. return retStr;
  8968. }
  8969. }
  8970. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  8971. retStr += " result=\"ok\">\r\n";
  8972. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8973. retStr += " </service>\r\n</imap>";
  8974. return retStr;
  8975. } else {
  8976. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  8977. retStr += " result=\"fail\" >\r\n";
  8978. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8979. retStr += " </service>\r\n</imap>";
  8980. return retStr;
  8981. }
  8982. } catch (RuntimeException re) {
  8983. LogUtil.errorLogInfo("", TAG, re);
  8984. return null;
  8985. } catch (Exception e) {
  8986. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  8987. //e.printStackTrace();
  8988. LogUtil.errorLogInfo("", TAG, e);
  8989. return null;
  8990. }
  8991. }
  8992. // 월패드에 원격제어 사용 여부를 확인하다.
  8993. private String CheckiCMDProc(String CMDStr) {
  8994. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  8995. try {
  8996. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  8997. mWallpadStatusData.closeDB();
  8998. if (!bRemoteCtrlEnabled) {
  8999. String retXML = XMLHeader + "<service type=\"reply\" name=\"" + CMDStr + "\" result=\"deny\">\r\n" +
  9000. " </service>\r\n</imap>";
  9001. return retXML;
  9002. }
  9003. return null;
  9004. } catch (RuntimeException re) {
  9005. LogUtil.errorLogInfo("", TAG, re);
  9006. mWallpadStatusData.closeDB();
  9007. return null;
  9008. } catch (Exception e) {
  9009. mWallpadStatusData.closeDB();
  9010. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  9011. //e.printStackTrace();
  9012. LogUtil.errorLogInfo("", TAG, e);
  9013. return null;
  9014. }
  9015. }
  9016. //메인으로 공지 해야 할 노티 사항을 처리
  9017. public String ProcEventNotify(Element ele) {
  9018. try {
  9019. NodeList items = ele.getElementsByTagName("event");
  9020. Node item = items.item(0);
  9021. Node text = item.getFirstChild();
  9022. String eventTXT = trimquotation(text.getNodeValue());
  9023. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  9024. // 새로운 공지사항 존재
  9025. wakeupLCD();
  9026. Intent intent = new Intent();
  9027. intent.setAction(define.NOTIFY_ACNAME);
  9028. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9029. getApplicationContext().sendBroadcast(intent);
  9030. } else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  9031. // 택배 도착
  9032. wakeupLCD();
  9033. Intent intent = new Intent();
  9034. intent.setAction(define.NOTIFY_ACNAME);
  9035. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9036. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  9037. intent.putExtra("REMAIN_CNT", 1);
  9038. getApplicationContext().sendBroadcast(intent);
  9039. } else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  9040. // 택배 반출
  9041. wakeupLCD();
  9042. Intent intent = new Intent();
  9043. intent.setAction(define.NOTIFY_ACNAME);
  9044. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9045. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  9046. intent.putExtra("REMAIN_CNT", 0);
  9047. getApplicationContext().sendBroadcast(intent);
  9048. } else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  9049. // 등록된 차량 도착
  9050. wakeupLCD();
  9051. // 팝업을 띄우도록 하자
  9052. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9053. Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
  9054. } else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  9055. // 내려가는 방향의 엘리베이터가 도착함
  9056. if (ElevatorDown != null) {
  9057. ElevatorDown.TimeOutCancel();
  9058. ElevatorDown.ClearElevator();
  9059. }
  9060. Intent intent = new Intent();
  9061. intent.setAction(define.NOTIFY_ACNAME);
  9062. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  9063. getApplicationContext().sendBroadcast(intent);
  9064. } else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  9065. // 올라가는 방향의 엘리베이터가 도착함
  9066. if (ElevatorUp != null) {
  9067. ElevatorUp.TimeOutCancel();
  9068. ElevatorUp.ClearElevator();
  9069. }
  9070. Intent intent = new Intent();
  9071. intent.setAction(define.NOTIFY_ACNAME);
  9072. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  9073. getApplicationContext().sendBroadcast(intent);
  9074. } else {
  9075. }
  9076. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  9077. "<event> \"" + eventTXT + "\" </event>\r\n" + " </service>\r\n </imap> ";
  9078. return returnStr;
  9079. } catch (RuntimeException re) {
  9080. LogUtil.errorLogInfo("", TAG, re);
  9081. return null;
  9082. } catch (Exception e) {
  9083. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  9084. //e.printStackTrace();
  9085. LogUtil.errorLogInfo("", TAG, e);
  9086. return null;
  9087. }
  9088. }
  9089. public String GetAttributeVal(Node node, String attname) {
  9090. NamedNodeMap attrs = node.getAttributes();
  9091. for (int j = 0; j < attrs.getLength(); j++) {
  9092. Node attr = attrs.item(j);
  9093. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  9094. }
  9095. return null;
  9096. }
  9097. public class imageFileFilter implements FilenameFilter {
  9098. public boolean accept(File dir, String name) {
  9099. 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"))
  9100. return true;
  9101. else return false;
  9102. }
  9103. }
  9104. public String ProcCheckEpiceUpload(Document ele) {
  9105. try {
  9106. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  9107. NodeList items = ele.getElementsByTagName("filename");
  9108. Node item = items.item(0);
  9109. Node text = item.getFirstChild();
  9110. String filename = trimquotation(text.getNodeValue());
  9111. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  9112. String duplicate = null;
  9113. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  9114. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  9115. if (!dirInternal.exists()) dirInternal.mkdir();
  9116. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9117. AddressSet addr = SetData.getAddressMGR();
  9118. if (!dirInternal.exists()) {
  9119. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9120. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + define.MAX_ALBUM_PICTURE + "\" available=\"0\" duplicate=\"new\"/>\r\n" +
  9121. " </service>\r\n</imap>";
  9122. return returnStr;
  9123. }
  9124. imageFileFilter jpegfilter = new imageFileFilter();
  9125. String[] subfile = dirInternal.list(jpegfilter);
  9126. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  9127. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  9128. if (checkFile.exists()) duplicate = "exist";
  9129. else duplicate = "new";
  9130. if (subfile != null) {
  9131. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9132. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + subfile.length + "\" available=\"" + (define.MAX_ALBUM_PICTURE - subfile.length) + "\" duplicate=\"" + duplicate + "\"/>\r\n" +
  9133. " </service>\r\n</imap>";
  9134. }
  9135. SetData.closeDB();
  9136. return returnStr;
  9137. } catch (RuntimeException re) {
  9138. LogUtil.errorLogInfo("", TAG, re);
  9139. return null;
  9140. } catch (Exception e) {
  9141. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  9142. //e.printStackTrace();
  9143. LogUtil.errorLogInfo("", TAG, e);
  9144. return null;
  9145. }
  9146. }
  9147. private void playNotifySound(int nSoundID) {
  9148. try {
  9149. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9150. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9151. if (getCompareBSPVersion()) {
  9152. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  9153. } else {
  9154. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9155. }
  9156. boolean NeedPlay = false;
  9157. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9158. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  9159. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  9160. } else {
  9161. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  9162. }
  9163. SetData.closeDB();
  9164. if (NeedPlay) Sound().PlayMent(nSoundID);
  9165. } catch (RuntimeException re) {
  9166. LogUtil.errorLogInfo("", TAG, re);
  9167. } catch (Exception e) {
  9168. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  9169. //e.printStackTrace();
  9170. LogUtil.errorLogInfo("", TAG, e);
  9171. }
  9172. }
  9173. private void wakeupLCD() {
  9174. try {
  9175. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9176. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9177. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9178. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  9179. int AlarmStatus = WsDB.GetAlarmStatus();
  9180. WsDB.closeDB();
  9181. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  9182. Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
  9183. return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
  9184. } else {
  9185. Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
  9186. mIOInterface.ctrlLcdWakeUp();
  9187. }
  9188. } catch (RuntimeException re) {
  9189. LogUtil.errorLogInfo("", TAG, re);
  9190. } catch (Exception e) {
  9191. Log.e(TAG, "[Exception] wakeupLCD()");
  9192. //e.printStackTrace();
  9193. LogUtil.errorLogInfo("", TAG, e);
  9194. }
  9195. }
  9196. /**
  9197. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  9198. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  9199. * Jeff, 2020.09.07
  9200. *
  9201. * @return true: LCD backlight On, false: LCD backlight Off
  9202. */
  9203. public boolean checkLCDOnByCMD() {
  9204. try {
  9205. Runtime mRuntime = Runtime.getRuntime();
  9206. Process mProcess;
  9207. String cmd = "getprop persist.sys.lcdcon";
  9208. mProcess = mRuntime.exec(cmd);
  9209. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  9210. String line;
  9211. String strResult = null;
  9212. while ((line = br.readLine()) != null) {
  9213. strResult = line;
  9214. }
  9215. if (strResult != null) {
  9216. if (strResult.equals("0")) {
  9217. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  9218. return true;
  9219. } else if (strResult.equals("1")) {
  9220. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  9221. return false;
  9222. } else {
  9223. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  9224. return false;
  9225. }
  9226. } else
  9227. return false;
  9228. } catch (RuntimeException re) {
  9229. LogUtil.errorLogInfo("", TAG, re);
  9230. return false;
  9231. } catch (Exception e) {
  9232. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  9233. //e.printStackTrace();
  9234. LogUtil.errorLogInfo("", TAG, e);
  9235. return false;
  9236. }
  9237. }
  9238. /**
  9239. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  9240. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  9241. *
  9242. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  9243. */
  9244. public boolean getCompareBSPVersion() {
  9245. try {
  9246. StringBuilder strBSPVersion = new StringBuilder();
  9247. StringBuffer sysInfoBuffer = new StringBuffer();
  9248. sysInfoBuffer.append(Build.DISPLAY);
  9249. strBSPVersion.append(sysInfoBuffer.toString());
  9250. String result = strBSPVersion.toString();
  9251. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  9252. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  9253. Date date = simpleDateFormat.parse(result);
  9254. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  9255. if (date.compareTo(standardDate) >= 0) {
  9256. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  9257. return true;
  9258. }
  9259. } catch (RuntimeException re) {
  9260. LogUtil.errorLogInfo("", TAG, re);
  9261. } catch (Exception e) {
  9262. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  9263. //e.printStackTrace();
  9264. LogUtil.errorLogInfo("", TAG, e);
  9265. }
  9266. return false;
  9267. }
  9268. public String ProcUpdateWeather(Document ele) {
  9269. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  9270. String nowloc = "";
  9271. String nowlcode = "";
  9272. String nowdate = "";
  9273. String nowtext = "";
  9274. String nowcode = "";
  9275. String nowtemp = "";
  9276. String nowlo = "", nowhigh = "";
  9277. NodeList items = ele.getElementsByTagName("now");
  9278. Node item = items.item(0);
  9279. if (item == null)
  9280. return resultstr += "\"fail\"/> \r\n </imap>";
  9281. NamedNodeMap attrsParam = item.getAttributes();
  9282. for (int j = 0; j < attrsParam.getLength(); j++) {
  9283. Node attr = attrsParam.item(j);
  9284. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  9285. else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
  9286. nowlcode = attr.getNodeValue();
  9287. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  9288. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  9289. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  9290. else if (attr.getNodeName().equalsIgnoreCase("temperature"))
  9291. nowtemp = attr.getNodeValue();
  9292. }
  9293. items = ele.getElementsByTagName("week");
  9294. String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
  9295. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9296. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  9297. Weathertbl.InitWeatherTable();
  9298. for (int i = 0; i < items.getLength(); i++) {
  9299. item = items.item(i);
  9300. attrsParam = item.getAttributes();
  9301. for (int j = 0; j < attrsParam.getLength(); j++) {
  9302. Node attr = attrsParam.item(j);
  9303. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  9304. else if (attr.getNodeName().equalsIgnoreCase("text"))
  9305. weektext = attr.getNodeValue();
  9306. else if (attr.getNodeName().equalsIgnoreCase("code"))
  9307. weekcode = attr.getNodeValue();
  9308. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  9309. else if (attr.getNodeName().equalsIgnoreCase("high"))
  9310. weekhigh = attr.getNodeValue();
  9311. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  9312. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  9313. }
  9314. if (i == 0) {
  9315. nowlo = weeklow;
  9316. nowhigh = weekhigh;
  9317. }
  9318. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  9319. }
  9320. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  9321. Intent intent = new Intent();
  9322. intent.setAction(define.NOTIFY_ACNAME);
  9323. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  9324. intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
  9325. getApplicationContext().sendBroadcast(intent);
  9326. String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
  9327. 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);
  9328. //air
  9329. items = ele.getElementsByTagName("air");
  9330. String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
  9331. item = items.item(0);
  9332. if (item != null) {
  9333. attrsParam = item.getAttributes();
  9334. for (int j = 0; j < attrsParam.getLength(); j++) {
  9335. Node attr = attrsParam.item(j);
  9336. if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
  9337. else if (attr.getNodeName().equalsIgnoreCase("pm25"))
  9338. airpm25 = attr.getNodeValue();
  9339. else if (attr.getNodeName().equalsIgnoreCase("co2"))
  9340. airco2 = attr.getNodeValue();
  9341. else if (attr.getNodeName().equalsIgnoreCase("ozone"))
  9342. airozone = attr.getNodeValue();
  9343. else if (attr.getNodeName().equalsIgnoreCase("air_index"))
  9344. air_index = attr.getNodeValue();
  9345. }
  9346. Intent intentAir = new Intent();
  9347. intentAir.setAction(define.NOTIFY_ACNAME);
  9348. intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
  9349. getApplicationContext().sendBroadcast(intentAir);
  9350. DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
  9351. }
  9352. DBMGR.closeDB();
  9353. return resultstr += "\"ok\"/> \r\n </imap>";
  9354. }
  9355. //iMAP update_news 처리
  9356. public String ProcUpdateNews(Document ele) {
  9357. NodeList items = ele.getElementsByTagName("ver_news");
  9358. Node item = items.item(0);
  9359. String strNewsVer = item.getTextContent();
  9360. strNewsVer = trimquotation(strNewsVer);
  9361. String retXML = XMLHeader + "<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n" +
  9362. " <ver_news>\"" + strNewsVer + "\"</ver_news>\r\n<service/>\r\n</imap>";
  9363. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9364. String NotiVer = DBMGR.GetNoticeVer();
  9365. int noticeCNT = DBMGR.GetNoticeCNT();
  9366. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  9367. String[] spdt = strNewsVer.split("[.]");
  9368. noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
  9369. } else {
  9370. String[] spdt = strNewsVer.split("[.]");
  9371. int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
  9372. spdt = NotiVer.split("[.]");
  9373. newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
  9374. noticeCNT += newcnt;
  9375. }
  9376. Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
  9377. DBMGR.SetNoticeVer(strNewsVer);
  9378. DBMGR.SetNoticeCNT(noticeCNT);
  9379. DBMGR.closeDB();
  9380. if (NotiVer.compareTo(strNewsVer) != 0) {
  9381. Intent intent = new Intent();
  9382. intent.setAction(define.NOTIFY_ACNAME);
  9383. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9384. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  9385. getApplicationContext().sendBroadcast(intent);
  9386. }
  9387. return retXML;
  9388. }
  9389. //iMAP check_lobby_passwd 처리
  9390. public String CheckPassword(Document doc) {
  9391. NodeList items = doc.getElementsByTagName("inpasswd");
  9392. Node item = items.item(0);
  9393. Node text = item.getFirstChild();
  9394. String passwd = trimquotation(text.getNodeValue());
  9395. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9396. String settedpasswd = DBMGR.GetUserPW();
  9397. DBMGR.closeDB();
  9398. String retString = XMLHeader;
  9399. Common.DebugLog("================ CheckPassword ================ ");
  9400. Common.DebugLog("Saved Password :" + settedpasswd);
  9401. Common.DebugLog("Input Password :" + passwd);
  9402. Common.DebugLog("================ CheckPassword ================ ");
  9403. if (settedpasswd.equals(passwd)) {
  9404. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  9405. } else {
  9406. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>" + passwd + "</wrongpasswd>\r\n</service>";
  9407. }
  9408. retString += "</imap>";
  9409. return retString;
  9410. }
  9411. //schedule_renew 처리
  9412. protected String ProcSchduleRenew(Document doc) {
  9413. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n " +
  9414. "<homeaddr dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" /> \r\n </service> \r\n </imap>";
  9415. WallpadScheduleData schedulDB = null;
  9416. try {
  9417. NodeList items = doc.getElementsByTagName("renew_info");
  9418. schedulDB = new WallpadScheduleData(getApplicationContext());
  9419. for (int i = 0; i < items.getLength(); i++) {
  9420. Node item = items.item(i);
  9421. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  9422. NamedNodeMap attrsParam = item.getAttributes();
  9423. String Type = "none";
  9424. for (int j = 0; j < attrsParam.getLength(); j++) {
  9425. Node attr = attrsParam.item(j);
  9426. String name = attr.getNodeName();
  9427. String Val = attr.getNodeValue();
  9428. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  9429. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  9430. else if (name.equalsIgnoreCase("rn_type"))
  9431. Type = Val;
  9432. else if (name.equalsIgnoreCase("rn_t_type"))
  9433. SCdata.inqttype = Val;
  9434. else if (name.equalsIgnoreCase("rn_c_type"))
  9435. SCdata.inqctype = Val;
  9436. else if (name.equalsIgnoreCase("rn_a_type"))
  9437. SCdata.inqatype = Val;
  9438. else if (name.equalsIgnoreCase("rn_i_type"))
  9439. SCdata.inqitype = Val;
  9440. else if (name.equalsIgnoreCase("rn_year"))
  9441. SCdata.inqyear = Integer.parseInt(Val);
  9442. else if (name.equalsIgnoreCase("rn_month"))
  9443. SCdata.inqmonth = Integer.parseInt(Val);
  9444. else if (name.equalsIgnoreCase("rn_day"))
  9445. SCdata.inqday = Integer.parseInt(Val);
  9446. else if (name.equalsIgnoreCase("rn_hour"))
  9447. SCdata.inqhour = Integer.parseInt(Val);
  9448. else if (name.equalsIgnoreCase("rn_message"))
  9449. SCdata.inqmsg = Val;
  9450. }
  9451. if (Type.equals("delete")) {
  9452. schedulDB.DeleteSchedule(SCdata);
  9453. } else if (Type.equals("add")) {
  9454. schedulDB.AddSchedule(SCdata);
  9455. } else if (Type.equals("change")) {
  9456. schedulDB.UpdateSchedule(SCdata);
  9457. }
  9458. }
  9459. schedulDB.closeDB();
  9460. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  9461. // Intent intent = new Intent();
  9462. // intent.setAction(define.NOTIFY_ACNAME);
  9463. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9464. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  9465. // getApplicationContext().sendBroadcast(intent);
  9466. } catch (RuntimeException re) {
  9467. LogUtil.errorLogInfo("", TAG, re);
  9468. if (schedulDB != null) schedulDB.closeDB();
  9469. } catch (Exception e) {
  9470. //e.printStackTrace();
  9471. LogUtil.errorLogInfo("", TAG, e);
  9472. if (schedulDB != null) schedulDB.closeDB();
  9473. }
  9474. return retXML;
  9475. }
  9476. //schedule_inquiry 처리
  9477. @SuppressWarnings("unused")
  9478. public String ProcSchduleInquiry(Document doc) {
  9479. WallpadScheduleData schedulDB = null;
  9480. String retXML;
  9481. int QYear = 0;
  9482. int QMonth = 0;
  9483. try {
  9484. NodeList items = doc.getElementsByTagName("inquiry_time");
  9485. schedulDB = new WallpadScheduleData(getApplicationContext());
  9486. Node item = items.item(0);
  9487. NamedNodeMap attrsParam = item.getAttributes();
  9488. for (int j = 0; j < attrsParam.getLength(); j++) {
  9489. Node attr = attrsParam.item(j);
  9490. if (attr.getNodeName().equalsIgnoreCase("year"))
  9491. QYear = Integer.parseInt(attr.getNodeValue());
  9492. else if (attr.getNodeName().equalsIgnoreCase("month"))
  9493. QMonth = Integer.parseInt(attr.getNodeValue());
  9494. }
  9495. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  9496. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9497. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9498. " <inquiry_time year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9499. " <inquiry_count>" + SCData.size() + "</inquiry_count>\r\n";
  9500. if (SCData != null) {
  9501. if (SCData.size() > 0) {
  9502. for (int i = 0; i < SCData.size(); i++) {
  9503. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  9504. 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=\"" +
  9505. SCINQDATA.inqyear + "\" inq_month=\"" + SCINQDATA.inqmonth + "\" inq_day=\"" + SCINQDATA.inqday + "\" inq_hour=\"" + SCINQDATA.inqhour + "\" inq_message=\"" + SCINQDATA.inqmsg + "\"/>\r\n";
  9506. }
  9507. }
  9508. retXML += "</service>\r\n</imap>";
  9509. } else {
  9510. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9511. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9512. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9513. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9514. }
  9515. } catch (RuntimeException re) {
  9516. LogUtil.errorLogInfo("", TAG, re);
  9517. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9518. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9519. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9520. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9521. } catch (Exception e) {
  9522. //e.printStackTrace();
  9523. LogUtil.errorLogInfo("", TAG, e);
  9524. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9525. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9526. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9527. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9528. }
  9529. schedulDB.closeDB();
  9530. return retXML;
  9531. }
  9532. public String ProcUpdateSchedule(Element ele, String type) {
  9533. String retXML = "";
  9534. return retXML;
  9535. }
  9536. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  9537. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  9538. private void setDefaultLauncher() {
  9539. try {
  9540. PackageManager pm = getPackageManager();
  9541. IntentFilter filter = new IntentFilter();
  9542. filter.addAction(Intent.ACTION_MAIN);
  9543. filter.addCategory(Intent.CATEGORY_HOME);
  9544. filter.addCategory(Intent.CATEGORY_DEFAULT);
  9545. Context context = getApplicationContext();
  9546. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  9547. ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  9548. pm.clearPackagePreferredActivities("com.android.launcher");
  9549. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  9550. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  9551. try {
  9552. Thread.sleep(300);
  9553. } catch (RuntimeException re) {
  9554. LogUtil.errorLogInfo("", TAG, re);
  9555. } catch (Exception e) {
  9556. LogUtil.errorLogInfo("", TAG, e);
  9557. }
  9558. // 리셋코드 추가
  9559. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  9560. try {
  9561. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9562. powerMg.reboot(null);
  9563. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  9564. } catch (RuntimeException re) {
  9565. LogUtil.errorLogInfo("", TAG, re);
  9566. } catch (Exception e) {
  9567. //e.printStackTrace();
  9568. LogUtil.errorLogInfo("", TAG, e);
  9569. }
  9570. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  9571. } catch (RuntimeException re) {
  9572. LogUtil.errorLogInfo("", TAG, re);
  9573. } catch (Exception e) {
  9574. //e.printStackTrace();
  9575. LogUtil.errorLogInfo("", TAG, e);
  9576. }
  9577. }
  9578. public String ProcDeviceReset(Element ele) {
  9579. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  9580. "</imap>\r\n";
  9581. NodeList resettype = ele.getElementsByTagName("guidemap");
  9582. Node resettypeItem = resettype.item(0);
  9583. String type = GetAttributeVal(resettypeItem, "type");
  9584. if (type != null) {
  9585. if (type.equals("now")) {
  9586. setDefaultLauncher();
  9587. Intent intent = new Intent();
  9588. intent.setAction(define.NOTIFY_ACNAME);
  9589. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  9590. getApplicationContext().sendBroadcast(intent);
  9591. } else if (type.equals("disable")) {
  9592. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9593. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
  9594. SetReset.closeDB();
  9595. } else if (type.equals("week") || type.equals("month")) {
  9596. int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
  9597. NodeList periodList = ele.getElementsByTagName("period");
  9598. Node perioditem = periodList.item(0);
  9599. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  9600. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  9601. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9602. SetReset.SetResetSchedule(Resettype, cycle, time);
  9603. SetReset.closeDB();
  9604. }
  9605. }
  9606. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  9607. // Intent intent = new Intent();
  9608. // intent.setAction(define.NOTIFY_ACNAME);
  9609. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9610. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  9611. // getApplicationContext().sendBroadcast(intent);
  9612. return retXML;
  9613. }
  9614. public String ProcDeviceLiveCheck() {
  9615. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  9616. return retXML;
  9617. }
  9618. public String ProcPairingHdevSyncAlarm(Element ele) {
  9619. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  9620. return retXML;
  9621. }
  9622. public String ProcPairingHdevSyncSecurity(Element ele) {
  9623. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  9624. return retXML;
  9625. }
  9626. public String ProcParkInformation(Element ele) {
  9627. try {
  9628. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  9629. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  9630. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  9631. NodeList items = ele.getElementsByTagName("destination");
  9632. Node item = items.item(0);
  9633. Node text;
  9634. NamedNodeMap attrsParam = item.getAttributes();
  9635. for (int j = 0; j < attrsParam.getLength(); j++) {
  9636. Node attr = attrsParam.item(j);
  9637. if (attr.getNodeName().equalsIgnoreCase("name"))
  9638. strName = trimquotation(attr.getNodeValue());
  9639. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9640. strDong = trimquotation(attr.getNodeValue());
  9641. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9642. strHo = trimquotation(attr.getNodeValue());
  9643. }
  9644. items = ele.getElementsByTagName("move_info");
  9645. item = items.item(0);
  9646. text = item.getFirstChild();
  9647. strCarMove = trimquotation(text.getNodeValue());
  9648. items = ele.getElementsByTagName("params");
  9649. item = items.item(0);
  9650. attrsParam = item.getAttributes();
  9651. for (int j = 0; j < attrsParam.getLength(); j++) {
  9652. Node attr = attrsParam.item(j);
  9653. if (attr.getNodeName().equalsIgnoreCase("car_num"))
  9654. strCarNo = trimquotation(attr.getNodeValue());
  9655. else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
  9656. strCarLocation = trimquotation(attr.getNodeValue());
  9657. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9658. strMsg = trimquotation(attr.getNodeValue());
  9659. }
  9660. if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
  9661. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  9662. try {
  9663. int iTempDong = Integer.parseInt(AddrDong);
  9664. String sTempDong = Integer.toString(iTempDong);
  9665. int iTempHo = Integer.parseInt(AddrHo);
  9666. String sTempHo = Integer.toString(iTempHo);
  9667. if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  9668. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9669. } else {
  9670. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9671. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9672. return retXML;
  9673. }
  9674. } catch (RuntimeException re) {
  9675. LogUtil.errorLogInfo("", TAG, re);
  9676. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9677. return retXML;
  9678. } catch (Exception e) {
  9679. //e.printStackTrace();
  9680. LogUtil.errorLogInfo("", TAG, e);
  9681. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9682. return retXML;
  9683. }
  9684. //DB정보 업데이트!
  9685. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9686. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  9687. CarDB.closeDB();
  9688. //DB정보 업데이트!
  9689. if (strCarMove.equalsIgnoreCase("in")) {
  9690. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9691. // 팝업을 띄우도록 하자
  9692. wakeupLCD();
  9693. if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
  9694. Intent iIntent = new Intent();
  9695. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9696. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9697. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  9698. getApplicationContext().sendBroadcast(iIntent);
  9699. } else {
  9700. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9701. }
  9702. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  9703. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  9704. }
  9705. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  9706. if (strCarMove.equalsIgnoreCase("park")) {
  9707. //주차정보 얻어오도록 intent 알림
  9708. SendGetParkingInfoIntent();
  9709. }
  9710. } else {
  9711. //주차정보 얻어오도록 intent 알림
  9712. SendGetParkingInfoIntent();
  9713. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  9714. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  9715. }
  9716. return retXML;
  9717. } catch (RuntimeException re) {
  9718. LogUtil.errorLogInfo("", TAG, re);
  9719. return null;
  9720. } catch (Exception e) {
  9721. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  9722. //e.printStackTrace();
  9723. LogUtil.errorLogInfo("", TAG, e);
  9724. return null;
  9725. }
  9726. }
  9727. /**
  9728. * 스마트키 이벤트 수신시 처리
  9729. **/
  9730. public String ProcSmartKeyEvent(Element ele) {
  9731. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  9732. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  9733. String strName = null, strDong = null, strHo = null, strCnt = null;
  9734. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  9735. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  9736. NodeList items = ele.getElementsByTagName("destination");
  9737. Node item = items.item(0);
  9738. NamedNodeMap attrsParam = item.getAttributes();
  9739. for (int j = 0; j < attrsParam.getLength(); j++) {
  9740. Node attr = attrsParam.item(j);
  9741. if (attr.getNodeName().equalsIgnoreCase("name"))
  9742. strName = trimquotation(attr.getNodeValue());
  9743. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9744. strDong = trimquotation(attr.getNodeValue());
  9745. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9746. strHo = trimquotation(attr.getNodeValue());
  9747. }
  9748. items = ele.getElementsByTagName("event_info");
  9749. item = items.item(0);
  9750. attrsParam = item.getAttributes();
  9751. for (int j = 0; j < attrsParam.getLength(); j++) {
  9752. Node attr = attrsParam.item(j);
  9753. if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
  9754. strCnt = trimquotation(attr.getNodeValue());
  9755. }
  9756. items = ele.getElementsByTagName("event");
  9757. item = items.item(0);
  9758. attrsParam = item.getAttributes();
  9759. for (int j = 0; j < attrsParam.getLength(); j++) {
  9760. Node attr = attrsParam.item(j);
  9761. if (attr.getNodeName().equalsIgnoreCase("event_type"))
  9762. strEventType = trimquotation(attr.getNodeValue());
  9763. else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
  9764. strEventTriggerType = trimquotation(attr.getNodeValue());
  9765. else if (attr.getNodeName().equalsIgnoreCase("uid"))
  9766. strEventUID = trimquotation(attr.getNodeValue());
  9767. else if (attr.getNodeName().equalsIgnoreCase("sn"))
  9768. strEventSN = trimquotation(attr.getNodeValue());
  9769. else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
  9770. strEventSitecode = trimquotation(attr.getNodeValue());
  9771. else if (attr.getNodeName().equalsIgnoreCase("dong"))
  9772. strEventDong = trimquotation(attr.getNodeValue());
  9773. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9774. strEventHo = trimquotation(attr.getNodeValue());
  9775. else if (attr.getNodeName().equalsIgnoreCase("card_num"))
  9776. strEventCardNo = trimquotation(attr.getNodeValue());
  9777. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
  9778. strEventIssueCnt = trimquotation(attr.getNodeValue());
  9779. else if (attr.getNodeName().equalsIgnoreCase("card_type"))
  9780. strEventCardType = trimquotation(attr.getNodeValue());
  9781. else if (attr.getNodeName().equalsIgnoreCase("location"))
  9782. strEventLocation = trimquotation(attr.getNodeValue());
  9783. }
  9784. if (strName != null && strDong != null && strHo != null && strCnt != null)
  9785. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  9786. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  9787. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  9788. if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
  9789. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  9790. } else {
  9791. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  9792. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9793. return retXML;
  9794. }
  9795. //데이터가 null인지 확인
  9796. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  9797. return retXML;
  9798. }
  9799. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  9800. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9801. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9802. wakeupLCD();
  9803. // 팝업을 띄우도록 하자
  9804. String CardNum = "";
  9805. try {
  9806. int iEvent_Dong = Integer.parseInt(strEventDong);
  9807. CardNum += String.format("%04d", iEvent_Dong);
  9808. int iEvent_Ho = Integer.parseInt(strEventHo);
  9809. CardNum += String.format("%04d", iEvent_Ho);
  9810. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  9811. CardNum += String.format("%03d", iEvent_CardNum);
  9812. } catch (RuntimeException re) {
  9813. LogUtil.errorLogInfo("", TAG, re);
  9814. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9815. return retXML;
  9816. } catch (Exception e) {
  9817. //e.printStackTrace();
  9818. LogUtil.errorLogInfo("", TAG, e);
  9819. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9820. return retXML;
  9821. }
  9822. Intent iIntent = new Intent();
  9823. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9824. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  9825. iIntent.putExtra("LOCATION", strEventLocation);
  9826. iIntent.putExtra("CARD_NO", CardNum);
  9827. getApplicationContext().sendBroadcast(iIntent);
  9828. }
  9829. }
  9830. } else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  9831. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9832. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9833. int nCardNum;
  9834. try {
  9835. nCardNum = Integer.parseInt(strEventCardNo);
  9836. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  9837. } catch (RuntimeException re) {
  9838. LogUtil.errorLogInfo("", TAG, re);
  9839. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9840. return retXML;
  9841. } catch (Exception e) {
  9842. //e.printStackTrace();
  9843. LogUtil.errorLogInfo("", TAG, e);
  9844. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9845. return retXML;
  9846. }
  9847. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9848. boolean bBandUse = deviceSet.getBandLocationUsage();
  9849. deviceSet.closeDB();
  9850. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  9851. wakeupLCD();
  9852. Intent iIntent = new Intent();
  9853. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9854. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  9855. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  9856. getApplicationContext().sendBroadcast(iIntent);
  9857. }
  9858. }
  9859. }
  9860. }
  9861. return retXML;
  9862. }
  9863. public String ProcParkInformation_cham_upis(Element ele) {
  9864. Log.d(TAG, "ProcParkInformation_cham_upis START");
  9865. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  9866. String infoName = null;
  9867. String infoDong = null;
  9868. String infoHo = null;
  9869. String infoCarMove = null;
  9870. String infoCarnum = null;
  9871. String infoCarLocation = null;
  9872. String infoMessage = null;
  9873. NodeList items = ele.getElementsByTagName("home_info");
  9874. Node item = items.item(0);
  9875. Node text;
  9876. NamedNodeMap attrsParam = item.getAttributes();
  9877. for (int j = 0; j < attrsParam.getLength(); j++) {
  9878. Node attr = attrsParam.item(j);
  9879. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9880. infoDong = trimquotation(attr.getNodeValue());
  9881. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9882. infoHo = trimquotation(attr.getNodeValue());
  9883. }
  9884. items = ele.getElementsByTagName("park_info");
  9885. item = items.item(0);
  9886. attrsParam = item.getAttributes();
  9887. for (int j = 0; j < attrsParam.getLength(); j++) {
  9888. Node attr = attrsParam.item(j);
  9889. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  9890. infoCarnum = trimquotation(attr.getNodeValue());
  9891. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  9892. infoCarLocation = trimquotation(attr.getNodeValue());
  9893. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9894. infoMessage = trimquotation(attr.getNodeValue());
  9895. }
  9896. Log.d(TAG, "ProcParkInformation infoName :" + infoName);
  9897. if (infoDong != null)
  9898. Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
  9899. Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
  9900. Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
  9901. Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
  9902. Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
  9903. Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
  9904. if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  9905. (infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
  9906. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9907. } else {
  9908. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9909. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  9910. return retXML;
  9911. }
  9912. infoCarMove = "park";
  9913. //DB정보 업데이트!
  9914. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9915. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  9916. CarDB.closeDB();
  9917. //DB정보 업데이트!
  9918. Intent iIntent = new Intent();
  9919. iIntent.setAction(define.NOTIFY_ACNAME);
  9920. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  9921. this.sendBroadcast(iIntent);
  9922. /*
  9923. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  9924. {
  9925. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9926. // 팝업을 띄우도록 하자
  9927. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9928. }
  9929. */
  9930. return retXML;
  9931. }
  9932. public String ProcGetSmartKeyInfo(Element ele) {
  9933. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  9934. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  9935. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  9936. NodeList items = ele.getElementsByTagName("info_type");
  9937. Node item = items.item(0);
  9938. Node text = item.getFirstChild();
  9939. String sInfo_type = trimquotation(text.getNodeValue());
  9940. String sCard_info = null;
  9941. String sMessage = null;
  9942. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  9943. {
  9944. items = ele.getElementsByTagName("uid_info");
  9945. item = items.item(0);
  9946. text = item.getFirstChild();
  9947. sCard_info = trimquotation(text.getNodeValue());
  9948. //==============================================//
  9949. items = ele.getElementsByTagName("message");
  9950. item = items.item(0);
  9951. text = item.getFirstChild();
  9952. sMessage = trimquotation(text.getNodeValue());
  9953. //==============================================//
  9954. //쿼리문 작성
  9955. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9956. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9957. for (int i = 0; i < SyncData.size(); i++) {
  9958. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  9959. NewData.add(SyncData.get(i));
  9960. }
  9961. }
  9962. wallpadSmartKeyRegData.closeDB();
  9963. } else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  9964. {
  9965. items = ele.getElementsByTagName("sn_info");
  9966. item = items.item(0);
  9967. text = item.getFirstChild();
  9968. sCard_info = trimquotation(text.getNodeValue());
  9969. //==============================================//
  9970. items = ele.getElementsByTagName("message");
  9971. item = items.item(0);
  9972. text = item.getFirstChild();
  9973. sMessage = trimquotation(text.getNodeValue());
  9974. //==============================================//
  9975. //쿼리문 작성
  9976. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9977. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9978. for (int i = 0; i < SyncData.size(); i++) {
  9979. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  9980. NewData.add(SyncData.get(i));
  9981. }
  9982. }
  9983. wallpadSmartKeyRegData.closeDB();
  9984. } else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  9985. {
  9986. items = ele.getElementsByTagName("uid_info");
  9987. item = items.item(0);
  9988. text = item.getFirstChild();
  9989. sCard_info = trimquotation(text.getNodeValue());
  9990. //==============================================//
  9991. items = ele.getElementsByTagName("message");
  9992. item = items.item(0);
  9993. text = item.getFirstChild();
  9994. sMessage = trimquotation(text.getNodeValue());
  9995. //==============================================//
  9996. //쿼리문 작성
  9997. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9998. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9999. for (int i = 0; i < SyncData.size(); i++) {
  10000. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  10001. NewData.add(SyncData.get(i));
  10002. }
  10003. }
  10004. if (NewData.size() > 0) {
  10005. NewData = SyncData;
  10006. }
  10007. wallpadSmartKeyRegData.closeDB();
  10008. } else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  10009. {
  10010. items = ele.getElementsByTagName("sn_info");
  10011. item = items.item(0);
  10012. text = item.getFirstChild();
  10013. sCard_info = trimquotation(text.getNodeValue());
  10014. //==============================================//
  10015. items = ele.getElementsByTagName("message");
  10016. item = items.item(0);
  10017. text = item.getFirstChild();
  10018. sMessage = trimquotation(text.getNodeValue());
  10019. //==============================================//
  10020. //쿼리문 작성
  10021. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10022. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10023. for (int i = 0; i < SyncData.size(); i++) {
  10024. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  10025. NewData.add(SyncData.get(i));
  10026. }
  10027. }
  10028. if (NewData.size() > 0) {
  10029. NewData = SyncData;
  10030. }
  10031. wallpadSmartKeyRegData.closeDB();
  10032. } else if (sInfo_type.equalsIgnoreCase("hkey")) {
  10033. String dong = "";
  10034. String ho = "";
  10035. String Num = "all";
  10036. //==============================================//
  10037. items = ele.getElementsByTagName("message");
  10038. item = items.item(0);
  10039. text = item.getFirstChild();
  10040. sMessage = trimquotation(text.getNodeValue());
  10041. //==============================================//
  10042. items = ele.getElementsByTagName("hkey_info");
  10043. item = items.item(0);
  10044. if (item == null)
  10045. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10046. NamedNodeMap attrsParam = item.getAttributes();
  10047. for (int j = 0; j < attrsParam.getLength(); j++) {
  10048. Node attr = attrsParam.item(j);
  10049. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10050. dong = attr.getNodeValue();
  10051. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10052. ho = attr.getNodeValue();
  10053. else if (attr.getNodeName().equalsIgnoreCase("num"))
  10054. Num = attr.getNodeValue();
  10055. }
  10056. if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
  10057. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
  10058. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10059. }
  10060. //쿼리문 작성
  10061. int intNum = 0;
  10062. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10063. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10064. for (int i = 0; i < SyncData.size(); i++) {
  10065. if (Num.equalsIgnoreCase("all") == true) {
  10066. NewData.add(SyncData.get(i));
  10067. } else {
  10068. try {
  10069. intNum = Integer.parseInt(Num);
  10070. } catch (RuntimeException re) {
  10071. LogUtil.errorLogInfo("", TAG, re);
  10072. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10073. } catch (Exception e) {
  10074. //e.printStackTrace();
  10075. LogUtil.errorLogInfo("", TAG, e);
  10076. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10077. }
  10078. if (SyncData.get(i).id == intNum) {
  10079. NewData.add(SyncData.get(i));
  10080. }
  10081. }
  10082. }
  10083. wallpadSmartKeyRegData.closeDB();
  10084. } else if (sInfo_type.equalsIgnoreCase("dkey")) {
  10085. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10086. } else if (sInfo_type.equalsIgnoreCase("mkey")) {
  10087. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10088. }
  10089. if (NewData.size() == 0) {
  10090. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  10091. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10092. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10093. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  10094. retXML += " </service>\r\n</imap>";
  10095. return retXML;
  10096. }
  10097. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10098. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10099. for (int i = 0; i < NewData.size(); i++) {
  10100. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  10101. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  10102. String strFormat = sFormat.format(date);
  10103. retXML += " <key_info index = \"" + NewData.get(i).id + "\" "
  10104. + "sn = \"" + NewData.get(i).SerialNumber + "\" "
  10105. + "uid = \"" + NewData.get(i).Uid + "\" "
  10106. + "key_num = \"" + NewData.get(i).id + "\" "
  10107. + "issue_cnt = \"" + 1 + "\" "
  10108. + "issued_date = \"" + strFormat + "\" "
  10109. + "message = \"" + "null" + "\" "
  10110. + "/>\r\n";
  10111. }
  10112. retXML += " </service>\r\n</imap>";
  10113. return retXML;
  10114. }
  10115. public void ProcMobileDevice_AuthNumber(Element ele) {
  10116. String sDong = null;
  10117. String sHo = null;
  10118. String sIP = null;
  10119. String sType = null;
  10120. String sDevice_Name = null;
  10121. String sTwinID = null;
  10122. String sAuthNumber = null;
  10123. try {
  10124. NodeList items = ele.getElementsByTagName("home_info");
  10125. Node item = items.item(0);
  10126. NamedNodeMap attrsParam = item.getAttributes();
  10127. for (int i = 0; i < attrsParam.getLength(); i++) {
  10128. Node attr = attrsParam.item(i);
  10129. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10130. sDong = trimquotation(attr.getNodeValue());
  10131. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10132. sHo = trimquotation(attr.getNodeValue());
  10133. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10134. sIP = trimquotation(attr.getNodeValue());
  10135. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10136. sType = trimquotation(attr.getNodeValue());
  10137. }
  10138. WallpadStatusData DBMGR = null;
  10139. DBMGR = new WallpadStatusData(getApplicationContext());
  10140. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10141. DBMGR.closeDB();
  10142. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10143. items = ele.getElementsByTagName("device_info");
  10144. item = items.item(0);
  10145. attrsParam = item.getAttributes();
  10146. for (int i = 0; i < attrsParam.getLength(); i++) {
  10147. Node attr = attrsParam.item(i);
  10148. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10149. sDevice_Name = trimquotation(attr.getNodeValue());
  10150. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10151. sTwinID = trimquotation(attr.getNodeValue());
  10152. else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
  10153. sAuthNumber = trimquotation(attr.getNodeValue());
  10154. }
  10155. /**데이터 전달**/
  10156. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10157. Log.d(TAG, "sTwinID :" + sTwinID);
  10158. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  10159. Intent intent = new Intent();
  10160. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10161. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  10162. intent.putExtra("AuthNumber", sAuthNumber);
  10163. if (NewServerUse()) {
  10164. getApplicationContext().sendBroadcast(intent);
  10165. }
  10166. } else {
  10167. }
  10168. } catch (RuntimeException re) {
  10169. LogUtil.errorLogInfo("", TAG, re);
  10170. } catch (Exception e) {
  10171. //e.printStackTrace();
  10172. LogUtil.errorLogInfo("", TAG, e);
  10173. }
  10174. }
  10175. public String ProcMobileDevice_ADD_Finish(Element ele) {
  10176. String retXML = "";
  10177. String sDong = null;
  10178. String sHo = null;
  10179. String sIP = null;
  10180. String sType = null;
  10181. String sDevice_Name = null;
  10182. String sTwinID = null;
  10183. try {
  10184. NodeList items = ele.getElementsByTagName("home_info");
  10185. Node item = items.item(0);
  10186. NamedNodeMap attrsParam = item.getAttributes();
  10187. for (int i = 0; i < attrsParam.getLength(); i++) {
  10188. Node attr = attrsParam.item(i);
  10189. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10190. sDong = trimquotation(attr.getNodeValue());
  10191. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10192. sHo = trimquotation(attr.getNodeValue());
  10193. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10194. sIP = trimquotation(attr.getNodeValue());
  10195. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10196. sType = trimquotation(attr.getNodeValue());
  10197. }
  10198. WallpadStatusData DBMGR = null;
  10199. DBMGR = new WallpadStatusData(getApplicationContext());
  10200. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10201. DBMGR.closeDB();
  10202. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10203. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10204. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10205. items = ele.getElementsByTagName("device_info");
  10206. item = items.item(0);
  10207. attrsParam = item.getAttributes();
  10208. for (int i = 0; i < attrsParam.getLength(); i++) {
  10209. Node attr = attrsParam.item(i);
  10210. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10211. sDevice_Name = trimquotation(attr.getNodeValue());
  10212. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10213. sTwinID = trimquotation(attr.getNodeValue());
  10214. }
  10215. /**데이터 전달**/
  10216. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10217. Log.d(TAG, "sTwinID :" + sTwinID);
  10218. Intent intent = new Intent();
  10219. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10220. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  10221. if (NewServerUse()) {
  10222. getApplicationContext().sendBroadcast(intent);
  10223. } else {
  10224. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10225. retXML += " </service>\r\n</imap>";
  10226. return retXML;
  10227. }
  10228. String tempType = "main";
  10229. //DB에 저장 필요
  10230. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10231. if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  10232. {
  10233. wallpadMobileDeviceData.closeDB();
  10234. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10235. retXML += " </service>\r\n</imap>";
  10236. return retXML;
  10237. }
  10238. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  10239. wallpadMobileDeviceData.closeDB();
  10240. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  10241. retXML += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" ip=\"" + addc.IPAddress + "\" type=\"" + tempType + "\"/>\r\n";
  10242. retXML += " <device_info alias=\"" + sDevice_Name + "\" twinid=\"" + sTwinID + "\" />\r\n";
  10243. retXML += " </service>\r\n</imap>";
  10244. return retXML;
  10245. } else {
  10246. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10247. retXML += " </service>\r\n</imap>";
  10248. return retXML;
  10249. }
  10250. } catch (RuntimeException re) {
  10251. LogUtil.errorLogInfo("", TAG, re);
  10252. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10253. retXML += " </service>\r\n</imap>";
  10254. return retXML;
  10255. } catch (Exception e) {
  10256. //e.printStackTrace();
  10257. LogUtil.errorLogInfo("", TAG, e);
  10258. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10259. retXML += " </service>\r\n</imap>";
  10260. return retXML;
  10261. }
  10262. }
  10263. public void ProcMobileDevice_Delete(Element ele) {
  10264. String sDong = null;
  10265. String sHo = null;
  10266. String sIP = null;
  10267. String sType = null;
  10268. String sDevice_Name = null;
  10269. String sTwinID = null;
  10270. Log.d(TAG, "ProcMobileDevice_Delete");
  10271. try {
  10272. NodeList items = ele.getElementsByTagName("home_info");
  10273. Node item = items.item(0);
  10274. NamedNodeMap attrsParam = item.getAttributes();
  10275. for (int i = 0; i < attrsParam.getLength(); i++) {
  10276. Node attr = attrsParam.item(i);
  10277. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10278. sDong = trimquotation(attr.getNodeValue());
  10279. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10280. sHo = trimquotation(attr.getNodeValue());
  10281. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10282. sIP = trimquotation(attr.getNodeValue());
  10283. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10284. sType = trimquotation(attr.getNodeValue());
  10285. }
  10286. WallpadStatusData DBMGR = null;
  10287. DBMGR = new WallpadStatusData(getApplicationContext());
  10288. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10289. DBMGR.closeDB();
  10290. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10291. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10292. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10293. if (NewServerUse()) {
  10294. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10295. items = ele.getElementsByTagName("device_info");
  10296. for (int i = 0; i < items.getLength(); i++) {
  10297. item = items.item(i);
  10298. attrsParam = item.getAttributes();
  10299. for (int j = 0; j < attrsParam.getLength(); j++) {
  10300. Node attr = attrsParam.item(j);
  10301. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10302. sDevice_Name = trimquotation(attr.getNodeValue());
  10303. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10304. sTwinID = trimquotation(attr.getNodeValue());
  10305. }
  10306. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10307. Log.d(TAG, "sTwinID :" + sTwinID);
  10308. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  10309. }
  10310. wallpadMobileDeviceData.closeDB();
  10311. Intent intent = new Intent();
  10312. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  10313. getApplicationContext().sendBroadcast(intent);
  10314. }
  10315. } else {
  10316. }
  10317. } catch (RuntimeException re) {
  10318. LogUtil.errorLogInfo("", TAG, re);
  10319. } catch (Exception e) {
  10320. //e.printStackTrace();
  10321. LogUtil.errorLogInfo("", TAG, e);
  10322. }
  10323. }
  10324. public String ProcGetAppVersionInfo() {
  10325. String retXML = "";
  10326. MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
  10327. int AppCount;
  10328. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  10329. retXML = XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  10330. retXML += " <home_info dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\" platform=\"Android\" count=\"" + AppCount + "\" />\r\n";
  10331. for (int i = 0; i < AppCount; i++) {
  10332. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
  10333. if (getString != null) {
  10334. retXML += " <app_list name=\"" + getString[0] + "\" version=\"" + getString[1] + "\" />\r\n";
  10335. }
  10336. }
  10337. retXML += " </service>\r\n</imap>";
  10338. return retXML;
  10339. }
  10340. public String ProcIgateInitInfo(Element ele) {
  10341. String retXML = "";
  10342. String ctrl_baudrate = "";
  10343. String ctrl_open = "";
  10344. String ctrl_framecheck = "";
  10345. String ctrl_message = "";
  10346. String eth_mode = "";
  10347. String eth_ip = "";
  10348. String eth_mac = "";
  10349. String eth_gw = "";
  10350. String eth_sm = "";
  10351. String noti_send = "";
  10352. String noti_level = "";
  10353. String noti_ip = "";
  10354. String noti_port = "";
  10355. try {
  10356. NodeList items = ele.getElementsByTagName("ctrl_param");
  10357. Node item = items.item(0);
  10358. NamedNodeMap attrsParam = item.getAttributes();
  10359. for (int i = 0; i < attrsParam.getLength(); i++) {
  10360. Node attr = attrsParam.item(i);
  10361. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  10362. ctrl_baudrate = trimquotation(attr.getNodeValue());
  10363. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  10364. ctrl_open = trimquotation(attr.getNodeValue());
  10365. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  10366. ctrl_framecheck = trimquotation(attr.getNodeValue());
  10367. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  10368. ctrl_message = trimquotation(attr.getNodeValue());
  10369. }
  10370. items = ele.getElementsByTagName("eth_param");
  10371. item = items.item(0);
  10372. attrsParam = item.getAttributes();
  10373. for (int i = 0; i < attrsParam.getLength(); i++) {
  10374. Node attr = attrsParam.item(i);
  10375. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  10376. eth_mode = trimquotation(attr.getNodeValue());
  10377. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  10378. eth_ip = trimquotation(attr.getNodeValue());
  10379. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  10380. eth_mac = trimquotation(attr.getNodeValue());
  10381. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  10382. eth_gw = trimquotation(attr.getNodeValue());
  10383. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  10384. eth_sm = trimquotation(attr.getNodeValue());
  10385. }
  10386. items = ele.getElementsByTagName("noti_param");
  10387. item = items.item(0);
  10388. attrsParam = item.getAttributes();
  10389. for (int i = 0; i < attrsParam.getLength(); i++) {
  10390. Node attr = attrsParam.item(i);
  10391. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  10392. noti_send = trimquotation(attr.getNodeValue());
  10393. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  10394. noti_level = trimquotation(attr.getNodeValue());
  10395. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  10396. noti_ip = trimquotation(attr.getNodeValue());
  10397. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  10398. noti_port = trimquotation(attr.getNodeValue());
  10399. }
  10400. wallpaddbmgr WallpadDBMGR = null;
  10401. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  10402. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  10403. if (RowCount_GatewayData > 100) {
  10404. WallpadDBMGR.DeleteLH_GatewayData("50");
  10405. }
  10406. 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);
  10407. WallpadDBMGR.closeDB();
  10408. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  10409. retXML += " </service>\r\n</imap>";
  10410. return retXML;
  10411. } catch (RuntimeException re) {
  10412. LogUtil.errorLogInfo("", TAG, re);
  10413. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10414. retXML += " </service>\r\n</imap>";
  10415. return retXML;
  10416. } catch (Exception e) {
  10417. //e.printStackTrace();
  10418. LogUtil.errorLogInfo("", TAG, e);
  10419. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10420. retXML += " </service>\r\n</imap>";
  10421. return retXML;
  10422. }
  10423. }
  10424. public String ProcElecCarChargeEventInfo(Element ele) {
  10425. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  10426. String retXML = "";
  10427. String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  10428. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  10429. try {
  10430. NodeList items = ele.getElementsByTagName("destination");
  10431. Node item = items.item(0);
  10432. NamedNodeMap attrsParam = item.getAttributes();
  10433. for (int i = 0; i < attrsParam.getLength(); i++) {
  10434. Node attr = attrsParam.item(i);
  10435. if (attr.getNodeName().equalsIgnoreCase("name"))
  10436. sName = trimquotation(attr.getNodeValue());
  10437. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10438. sId_High = trimquotation(attr.getNodeValue());
  10439. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10440. sId_Low = trimquotation(attr.getNodeValue());
  10441. }
  10442. WallpadStatusData DBMGR = null;
  10443. DBMGR = new WallpadStatusData(getApplicationContext());
  10444. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10445. DBMGR.closeDB();
  10446. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  10447. items = ele.getElementsByTagName("charging_info");
  10448. item = items.item(0);
  10449. attrsParam = item.getAttributes();
  10450. for (int i = 0; i < attrsParam.getLength(); i++) {
  10451. Node attr = attrsParam.item(i);
  10452. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  10453. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  10454. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  10455. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  10456. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  10457. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  10458. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  10459. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  10460. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  10461. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  10462. )) {
  10463. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10464. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10465. retXML += " </service>\r\n</imap>";
  10466. return retXML;
  10467. }
  10468. if (attr.getNodeName().equalsIgnoreCase("card_num"))
  10469. sCard_Num = trimquotation(attr.getNodeValue());
  10470. else if (attr.getNodeName().equalsIgnoreCase("car_num"))
  10471. sCar_Num = trimquotation(attr.getNodeValue());
  10472. else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
  10473. sCharger_Num = trimquotation(attr.getNodeValue());
  10474. else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
  10475. sCharger_Loc = trimquotation(attr.getNodeValue());
  10476. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  10477. sCharging_Status = trimquotation(attr.getNodeValue());
  10478. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  10479. (sCharging_Status.equalsIgnoreCase("charging")) ||
  10480. (sCharging_Status.equalsIgnoreCase("full")) ||
  10481. (sCharging_Status.equalsIgnoreCase("charged")) ||
  10482. (sCharging_Status.equalsIgnoreCase("stop")) ||
  10483. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  10484. (sCharging_Status.equalsIgnoreCase("check")) ||
  10485. (sCharging_Status.equalsIgnoreCase("commerror"))
  10486. )) {
  10487. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  10488. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10489. retXML += " </service>\r\n</imap>";
  10490. return retXML;
  10491. }
  10492. } else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  10493. sCharger_sort = trimquotation(attr.getNodeValue());
  10494. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  10495. (sCharger_sort.equalsIgnoreCase("fast")) ||
  10496. (sCharger_sort.equalsIgnoreCase("no_info"))
  10497. )) {
  10498. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  10499. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10500. retXML += " </service>\r\n</imap>";
  10501. return retXML;
  10502. }
  10503. } else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
  10504. sCharging_Ratio = trimquotation(attr.getNodeValue());
  10505. else if (attr.getNodeName().equalsIgnoreCase("start_time"))
  10506. sStart_Time = trimquotation(attr.getNodeValue());
  10507. else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
  10508. sRemain_Time = trimquotation(attr.getNodeValue());
  10509. }
  10510. items = ele.getElementsByTagName("message");
  10511. item = items.item(0);
  10512. Node text = item.getFirstChild();
  10513. sMessage = trimquotation(text.getNodeValue());
  10514. /**데이터 전달**/
  10515. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  10516. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  10517. Intent intent = new Intent();
  10518. intent.setAction(define.NOTIFY_ACNAME);
  10519. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  10520. intent.putExtra("sCard_Num", sCard_Num);
  10521. intent.putExtra("sCar_Num", sCar_Num);
  10522. intent.putExtra("sCharger_Num", sCharger_Num);
  10523. intent.putExtra("sCharger_Loc", sCharger_Loc);
  10524. intent.putExtra("sCharging_Status", sCharging_Status);
  10525. intent.putExtra("sCharger_sort", sCharger_sort);
  10526. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  10527. intent.putExtra("sStart_Time", sStart_Time);
  10528. intent.putExtra("sRemain_Time", sRemain_Time);
  10529. intent.putExtra("sMessage", sMessage);
  10530. WallpadDeviceSet devDB = null;
  10531. devDB = new WallpadDeviceSet(getApplicationContext());
  10532. int retInt = -1;
  10533. retInt = devDB.GetDeviceSetted("전기차충전");
  10534. devDB.closeDB();
  10535. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10536. getApplicationContext().sendBroadcast(intent);
  10537. }
  10538. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  10539. retXML += " <source name=\"homedev\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" />\r\n";
  10540. retXML += " </service>\r\n</imap>";
  10541. return retXML;
  10542. } else {
  10543. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10544. retXML += " </service>\r\n</imap>";
  10545. return retXML;
  10546. }
  10547. } catch (RuntimeException re) {
  10548. LogUtil.errorLogInfo("", TAG, re);
  10549. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10550. retXML += " </service>\r\n</imap>";
  10551. return retXML;
  10552. } catch (Exception e) {
  10553. //e.printStackTrace();
  10554. LogUtil.errorLogInfo("", TAG, e);
  10555. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10556. retXML += " </service>\r\n</imap>";
  10557. return retXML;
  10558. }
  10559. }
  10560. public String ProcEnergyTargetInfoAlarm(Element ele) {
  10561. String retXML = "";
  10562. String sName = "";
  10563. String sId_High = "";
  10564. String sId_Low = "";
  10565. String vName[];
  10566. String vTarget[];
  10567. String vTarget_Cost[];
  10568. String vUsed[];
  10569. String vUsed_Cost[];
  10570. String vPredict[];
  10571. String vPredict_Cost[];
  10572. String vAlarm_info[];
  10573. String vRead_Date[];
  10574. String vRead_Day[];
  10575. String vV_Msg[];
  10576. String sMessage = "";
  10577. try {
  10578. NodeList items = ele.getElementsByTagName("source");
  10579. Node item = items.item(0);
  10580. NamedNodeMap attrsParam = item.getAttributes();
  10581. for (int i = 0; i < attrsParam.getLength(); i++) {
  10582. Node attr = attrsParam.item(i);
  10583. if (attr.getNodeName().equalsIgnoreCase("name"))
  10584. sName = trimquotation(attr.getNodeValue());
  10585. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10586. sId_High = trimquotation(attr.getNodeValue());
  10587. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10588. sId_Low = trimquotation(attr.getNodeValue());
  10589. }
  10590. WallpadStatusData DBMGR = null;
  10591. DBMGR = new WallpadStatusData(getApplicationContext());
  10592. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10593. DBMGR.closeDB();
  10594. if ((sName.equalsIgnoreCase("home") == true) &&
  10595. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  10596. (sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
  10597. items = ele.getElementsByTagName("valuelist");
  10598. Log.d(TAG, "items.getLength() :" + items.getLength());
  10599. vName = new String[items.getLength()];
  10600. vTarget = new String[items.getLength()];
  10601. vTarget_Cost = new String[items.getLength()];
  10602. vUsed = new String[items.getLength()];
  10603. vUsed_Cost = new String[items.getLength()];
  10604. vPredict = new String[items.getLength()];
  10605. vPredict_Cost = new String[items.getLength()];
  10606. vAlarm_info = new String[items.getLength()];
  10607. vRead_Date = new String[items.getLength()];
  10608. vRead_Day = new String[items.getLength()];
  10609. vV_Msg = new String[items.getLength()];
  10610. for (int j = 0; j < items.getLength(); j++) {
  10611. Log.d(TAG, "j :" + j);
  10612. item = items.item(j);
  10613. attrsParam = item.getAttributes();
  10614. Log.d(TAG, "attrsParam :" + attrsParam);
  10615. for (int i = 0; i < attrsParam.getLength(); i++) {
  10616. Node attr = attrsParam.item(i);
  10617. if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  10618. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  10619. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  10620. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  10621. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  10622. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  10623. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  10624. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  10625. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  10626. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  10627. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  10628. )) {
  10629. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10630. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10631. retXML += " </service>\r\n</imap>";
  10632. return retXML;
  10633. }
  10634. if (attr.getNodeName().equalsIgnoreCase("name")) {
  10635. vName[j] = trimquotation(attr.getNodeValue());
  10636. if (!((vName[j].equalsIgnoreCase("elect") == true) ||
  10637. (vName[j].equalsIgnoreCase("water") == true) ||
  10638. (vName[j].equalsIgnoreCase("gas") == true) ||
  10639. (vName[j].equalsIgnoreCase("heating") == true) ||
  10640. (vName[j].equalsIgnoreCase("hotwater") == true)
  10641. )) {
  10642. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  10643. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10644. retXML += " </service>\r\n</imap>";
  10645. return retXML;
  10646. }
  10647. } else if (attr.getNodeName().equalsIgnoreCase("target"))
  10648. vTarget[j] = trimquotation(attr.getNodeValue());
  10649. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  10650. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  10651. else if (attr.getNodeName().equalsIgnoreCase("used"))
  10652. vUsed[j] = trimquotation(attr.getNodeValue());
  10653. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  10654. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  10655. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  10656. vPredict[j] = trimquotation(attr.getNodeValue());
  10657. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  10658. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  10659. else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
  10660. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  10661. if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  10662. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  10663. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  10664. )) {
  10665. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  10666. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10667. retXML += " </service>\r\n</imap>";
  10668. return retXML;
  10669. }
  10670. } else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
  10671. vRead_Date[j] = trimquotation(attr.getNodeValue());
  10672. if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  10673. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  10674. )) {
  10675. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  10676. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10677. retXML += " </service>\r\n</imap>";
  10678. return retXML;
  10679. }
  10680. } else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  10681. vRead_Day[j] = trimquotation(attr.getNodeValue());
  10682. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  10683. vV_Msg[j] = trimquotation(attr.getNodeValue());
  10684. }
  10685. }
  10686. items = ele.getElementsByTagName("message");
  10687. item = items.item(0);
  10688. Node text = item.getFirstChild();
  10689. sMessage = trimquotation(text.getNodeValue());
  10690. /**데이터 전달**/
  10691. for (int i = 0; i < vName.length; i++) {
  10692. Log.d(TAG, "vName[" + i + "]: " + vName[i]);
  10693. Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
  10694. Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
  10695. Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
  10696. Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
  10697. Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
  10698. Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
  10699. Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
  10700. Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
  10701. Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
  10702. Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
  10703. }
  10704. Intent intent = new Intent();
  10705. intent.setAction(define.NOTIFY_ACNAME);
  10706. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  10707. for (int i = 0; i < vName.length; i++) {
  10708. if (vName[i].equals("elect")) {
  10709. intent.putExtra("elect_target", vTarget[i]);
  10710. intent.putExtra("elect_used", vUsed[i]);
  10711. intent.putExtra("elect_info", vAlarm_info[i]);
  10712. } else if (vName[i].equals("water")) {
  10713. intent.putExtra("water_target", vTarget[i]);
  10714. intent.putExtra("water_used", vUsed[i]);
  10715. intent.putExtra("water_info", vAlarm_info[i]);
  10716. } else if (vName[i].equals("gas")) {
  10717. intent.putExtra("gas_target", vTarget[i]);
  10718. intent.putExtra("gas_used", vUsed[i]);
  10719. intent.putExtra("gas_info", vAlarm_info[i]);
  10720. } else if (vName[i].equals("heating")) {
  10721. intent.putExtra("heating_target", vTarget[i]);
  10722. intent.putExtra("heating_used", vUsed[i]);
  10723. intent.putExtra("heating_info", vAlarm_info[i]);
  10724. } else if (vName[i].equals("hotwater")) {
  10725. intent.putExtra("hotwater_target", vTarget[i]);
  10726. intent.putExtra("hotwater_used", vUsed[i]);
  10727. intent.putExtra("hotwater_info", vAlarm_info[i]);
  10728. }
  10729. }
  10730. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  10731. retXML += " <source name=\"home\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" count=\"" + vName.length + "\"" + " s_msg=\"null\" />\r\n";
  10732. for (int i = 0; i < vName.length; i++) {
  10733. retXML += " <valuelist name=\"" + vName[i] + "\" alarm_info=\"" + vAlarm_info[i] + "\" v_msg=\"null\" />\r\n";
  10734. }
  10735. retXML += " <message>\"null\"</message>\r\n";
  10736. retXML += " </service>\r\n</imap>";
  10737. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10738. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  10739. devSet.closeDB();
  10740. if (MetringDB != null) {
  10741. try {
  10742. String devInfo = MetringDB[1];
  10743. devInfo = devInfo.replace('(', '_');
  10744. devInfo = devInfo.replace(':', '_');
  10745. devInfo = devInfo.replace(')', '_');
  10746. String[] MetringInfo = devInfo.split("_");
  10747. // MetringInfo[1] -> 회로수
  10748. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  10749. // MetringInfo[4] -> IP
  10750. // MetringInfo[5] -> IP정보
  10751. // MetringInfo[6] -> 검침일사용자설정
  10752. // MetringInfo[7] -> 사용함 또는 사용안함
  10753. if (MetringInfo[3].equals("사용함") == true) {
  10754. getApplicationContext().sendBroadcast(intent);
  10755. }
  10756. } catch (RuntimeException re) {
  10757. LogUtil.errorLogInfo("", TAG, re);
  10758. } catch (Exception e) {
  10759. //e.printStackTrace();
  10760. LogUtil.errorLogInfo("", TAG, e);
  10761. }
  10762. } else {
  10763. }
  10764. return retXML;
  10765. } else {
  10766. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10767. retXML += " </service>\r\n</imap>";
  10768. return retXML;
  10769. }
  10770. } catch (RuntimeException re) {
  10771. LogUtil.errorLogInfo("", TAG, re);
  10772. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10773. retXML += " </service>\r\n</imap>";
  10774. return retXML;
  10775. } catch (Exception e) {
  10776. //e.printStackTrace();
  10777. LogUtil.errorLogInfo("", TAG, e);
  10778. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10779. retXML += " </service>\r\n</imap>";
  10780. return retXML;
  10781. }
  10782. }
  10783. public String ProcCheckCallOption() {
  10784. int[] resultDB = {0, 0};
  10785. String retXML = "";
  10786. String sOption = "sip";
  10787. String sMessage = "null";
  10788. try {
  10789. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10790. resultDB = devSet.Get_Handicapped_Mode();
  10791. devSet.closeDB();
  10792. if (resultDB[0] == 0) {
  10793. //장애인모드 사용 안함
  10794. } else if (resultDB[0] == 1) {
  10795. //장애인모드 사용함
  10796. }
  10797. switch (resultDB[1]) {
  10798. case 0: //일반모드
  10799. sOption = "sip";
  10800. break;
  10801. case 1: //청각장애인
  10802. sOption = "deaf";
  10803. break;
  10804. case 2: //시각장애인
  10805. sOption = "blind";
  10806. break;
  10807. default:
  10808. break;
  10809. }
  10810. if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  10811. {
  10812. //본 구문에 들어올수 없음
  10813. sOption = "none";
  10814. }
  10815. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  10816. retXML += " <option>\"" + sOption + "\"</option>\r\n";
  10817. retXML += " <message>\"" + sMessage + "\"</message>\r\n";
  10818. retXML += " </service>\r\n</imap>";
  10819. return retXML;
  10820. } catch (RuntimeException re) {
  10821. LogUtil.errorLogInfo("", TAG, re);
  10822. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10823. retXML += " </service>\r\n</imap>";
  10824. return retXML;
  10825. } catch (Exception e) {
  10826. //e.printStackTrace();
  10827. LogUtil.errorLogInfo("", TAG, e);
  10828. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10829. retXML += " </service>\r\n</imap>";
  10830. return retXML;
  10831. }
  10832. }
  10833. public String ProcChatSequence(Element ele) {
  10834. String retXML = "";
  10835. String sFrom = "error";
  10836. String sTo = "error";
  10837. String sContact = "error";
  10838. String sSequence = "error";
  10839. String sStatus = "error";
  10840. String sMessage = "error";
  10841. String reply_Sequence = "error";
  10842. String reply_Status = "error";
  10843. String reply_Message = "null";
  10844. try {
  10845. NodeList items = ele.getElementsByTagName("sequence");
  10846. Node item = items.item(0);
  10847. NamedNodeMap attrsParam = item.getAttributes();
  10848. sSequence = trimquotation(item.getTextContent());
  10849. ///////////////////////////////////////////////
  10850. items = ele.getElementsByTagName("status");
  10851. item = items.item(0);
  10852. attrsParam = item.getAttributes();
  10853. sStatus = trimquotation(item.getTextContent());
  10854. ///////////////////////////////////////////////
  10855. items = ele.getElementsByTagName("message");
  10856. item = items.item(0);
  10857. attrsParam = item.getAttributes();
  10858. sMessage = trimquotation(item.getTextContent());
  10859. ///////////////////////////////////////////////
  10860. items = ele.getElementsByTagName("from");
  10861. item = items.item(0);
  10862. attrsParam = item.getAttributes();
  10863. sFrom = trimquotation(item.getTextContent());
  10864. ///////////////////////////////////////////////
  10865. items = ele.getElementsByTagName("to");
  10866. item = items.item(0);
  10867. attrsParam = item.getAttributes();
  10868. sTo = trimquotation(item.getTextContent());
  10869. ///////////////////////////////////////////////
  10870. items = ele.getElementsByTagName("contact");
  10871. item = items.item(0);
  10872. attrsParam = item.getAttributes();
  10873. sContact = trimquotation(item.getTextContent());
  10874. ///////////////////////////////////////////////
  10875. if (!((sSequence.equalsIgnoreCase("try") == true) ||
  10876. (sSequence.equalsIgnoreCase("start") == true) ||
  10877. (sSequence.equalsIgnoreCase("quit") == true) ||
  10878. (sSequence.equalsIgnoreCase("cancel") == true) ||
  10879. (sSequence.equalsIgnoreCase("ok") == true) ||
  10880. (sSequence.equalsIgnoreCase("busy") == true) ||
  10881. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  10882. (sSequence.equalsIgnoreCase("reject") == true)
  10883. )) {
  10884. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  10885. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10886. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10887. retXML += " </service>\r\n</imap>";
  10888. return retXML;
  10889. }
  10890. if (!((sStatus.equalsIgnoreCase("idle") == true) ||
  10891. (sStatus.equalsIgnoreCase("ringing") == true) ||
  10892. (sStatus.equalsIgnoreCase("talking") == true)
  10893. )) {
  10894. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  10895. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10896. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10897. retXML += " </service>\r\n</imap>";
  10898. return retXML;
  10899. }
  10900. //입력값 처리 필요!!
  10901. //김용성 과장님 작업필요
  10902. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  10903. //확인 하시고 위 정보 확인해주세요.
  10904. Log.d(TAG, "sFrom:" + sFrom);
  10905. Log.d(TAG, "sTo:" + sTo);
  10906. Log.d(TAG, "Contact:" + sContact);
  10907. Log.d(TAG, "sSequence:" + sSequence);
  10908. Log.d(TAG, "sStatus:" + sStatus);
  10909. if (sSequence.equalsIgnoreCase("try") == true) {
  10910. //채팅 요청
  10911. } else if (sSequence.equalsIgnoreCase("start") == true) {
  10912. //채팅 시작
  10913. } else if (sSequence.equalsIgnoreCase("quit") == true) {
  10914. //채팅 종료
  10915. } else if (sSequence.equalsIgnoreCase("cancel") == true) {
  10916. //취소
  10917. } else if (sSequence.equalsIgnoreCase("ok") == true) {
  10918. //요청확인
  10919. } else if (sSequence.equalsIgnoreCase("busy") == true) {
  10920. //통화중
  10921. } else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
  10922. //SIP 통화중
  10923. } else if (sSequence.equalsIgnoreCase("reject") == true) {
  10924. //거절
  10925. }
  10926. if (sStatus.equalsIgnoreCase("idle") == true) {
  10927. //대기
  10928. } else if (sStatus.equalsIgnoreCase("ringing") == true) {
  10929. //연결중
  10930. } else if (sStatus.equalsIgnoreCase("talking") == true) {
  10931. //통화중
  10932. }
  10933. //응답값 입력 필요!!
  10934. //김용성 과장님 작업필요
  10935. reply_Message = "null";
  10936. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  10937. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10938. retXML += " </service>\r\n</imap>";
  10939. return retXML;
  10940. } catch (RuntimeException re) {
  10941. LogUtil.errorLogInfo("", TAG, re);
  10942. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10943. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10944. retXML += " </service>\r\n</imap>";
  10945. return retXML;
  10946. } catch (Exception e) {
  10947. //e.printStackTrace();
  10948. LogUtil.errorLogInfo("", TAG, e);
  10949. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10950. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10951. retXML += " </service>\r\n</imap>";
  10952. return retXML;
  10953. }
  10954. }
  10955. public String ProcChatMessage(Element ele) {
  10956. String retXML = "";
  10957. String sChatMessage = "error";
  10958. String sMessage = "error";
  10959. try {
  10960. NodeList items = ele.getElementsByTagName("chat");
  10961. Node item = items.item(0);
  10962. NamedNodeMap attrsParam = item.getAttributes();
  10963. sChatMessage = trimquotation(item.getTextContent());
  10964. ///////////////////////////////////////////////
  10965. items = ele.getElementsByTagName("message");
  10966. item = items.item(0);
  10967. attrsParam = item.getAttributes();
  10968. sMessage = trimquotation(item.getTextContent());
  10969. ///////////////////////////////////////////////
  10970. //test
  10971. Log.d(TAG, "sChatMessage is " + sChatMessage);
  10972. Log.d(TAG, "sMessage is " + sMessage);
  10973. //test
  10974. Intent intent = new Intent();
  10975. intent.setAction(define.NOTIFY_ACNAME);
  10976. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  10977. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  10978. intent.putExtra("ADD_MESSAGE", sMessage);
  10979. getApplicationContext().sendBroadcast(intent);
  10980. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  10981. retXML += " <message>\"" + "null" + "\"</message>\r\n";
  10982. retXML += " </service>\r\n</imap>";
  10983. return retXML;
  10984. } catch (RuntimeException re) {
  10985. LogUtil.errorLogInfo("", TAG, re);
  10986. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10987. retXML += " </service>\r\n</imap>";
  10988. return retXML;
  10989. } catch (Exception e) {
  10990. //e.printStackTrace();
  10991. LogUtil.errorLogInfo("", TAG, e);
  10992. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10993. retXML += " </service>\r\n</imap>";
  10994. return retXML;
  10995. }
  10996. }
  10997. public String ProcEvacuationLadderOpen(Element ele) {
  10998. String retXML = "";
  10999. try {
  11000. String sDong = null;
  11001. String sHo = null;
  11002. NodeList items = ele.getElementsByTagName("home_info");
  11003. Node item = items.item(0);
  11004. NamedNodeMap attrsParam = item.getAttributes();
  11005. for (int i = 0; i < attrsParam.getLength(); i++) {
  11006. Node attr = attrsParam.item(i);
  11007. if (attr.getNodeName().equalsIgnoreCase("dong"))
  11008. sDong = trimquotation(attr.getNodeValue());
  11009. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  11010. sHo = trimquotation(attr.getNodeValue());
  11011. }
  11012. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  11013. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  11014. deviceSet.closeDB();
  11015. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  11016. WallpadStatusData DBMGR = null;
  11017. DBMGR = new WallpadStatusData(getApplicationContext());
  11018. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  11019. DBMGR.closeDB();
  11020. String myIP = addc.IPAddress;
  11021. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  11022. String[] SplitedString = myIP.split("\\.");
  11023. if (SplitedString != null) {
  11024. if (SplitedString.length == 4) {
  11025. int temp = Integer.parseInt(SplitedString[2]);
  11026. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11027. temp = temp - 1;
  11028. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11029. temp = temp + 1;
  11030. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  11031. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  11032. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  11033. DestStair = String.valueOf(temp);
  11034. }
  11035. }
  11036. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
  11037. /**
  11038. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  11039. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  11040. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  11041. * **/
  11042. WallpadDeviceSet devset;
  11043. devset = new WallpadDeviceSet(getApplicationContext());
  11044. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11045. devset.closeDB();
  11046. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11047. /**
  11048. * 피난사다리 알림!!!
  11049. * **/
  11050. ReceiveNetworkLadderBr(ladderDownSend);
  11051. }
  11052. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  11053. retXML += " </service>\r\n</imap>";
  11054. return retXML;
  11055. } else {
  11056. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11057. retXML += " </service>\r\n</imap>";
  11058. return retXML;
  11059. }
  11060. } catch (RuntimeException re) {
  11061. LogUtil.errorLogInfo("", TAG, re);
  11062. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11063. retXML += " </service>\r\n</imap>";
  11064. return retXML;
  11065. } catch (Exception e) {
  11066. //e.printStackTrace();
  11067. LogUtil.errorLogInfo("", TAG, e);
  11068. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11069. retXML += " </service>\r\n</imap>";
  11070. return retXML;
  11071. }
  11072. }
  11073. private void ReceiveNetworkLadderBr(int val) {
  11074. int base = 7000;
  11075. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  11076. int Menu_Start_Option = 1;
  11077. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  11078. int AlarmStatus = wdb.GetAlarmStatus();
  11079. wdb.closeDB();
  11080. boolean MgrAppRun = false;
  11081. final String packageNameMgr = "com.artncore.managersetting";
  11082. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  11083. if (MgrAppRun)
  11084. return;
  11085. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  11086. return;
  11087. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11088. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11089. devset.closeDB();
  11090. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11091. Common.SendAppFinishReqBR(getApplicationContext());
  11092. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11093. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11094. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  11095. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11096. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11097. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  11098. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11099. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  11100. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11101. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11102. getApplicationContext().startActivity(newintent);
  11103. }
  11104. }
  11105. /**
  11106. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  11107. *
  11108. * @param ele Element Xml 데이터
  11109. * @return String 타입의 응답 메시지 생성
  11110. **/
  11111. public String SmartLightDetailInfo(Element ele) {
  11112. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  11113. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  11114. }
  11115. /**
  11116. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  11117. *
  11118. * @param ele Element Xml 데이터
  11119. * @return String 타입의 응답 메시지 생성
  11120. **/
  11121. public String KNXDeviceDetailInfo(Element ele) {
  11122. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  11123. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  11124. }
  11125. public String ProcSetServerChange(Element ele) {
  11126. String retXML = "";
  11127. String versionTXT = null;
  11128. try {
  11129. boolean bRet = false;
  11130. NodeList items = ele.getElementsByTagName("ver_server");
  11131. Node item = items.item(0);
  11132. Node text = item.getFirstChild();
  11133. versionTXT = trimquotation(text.getNodeValue());
  11134. if (versionTXT.equalsIgnoreCase("1.0")) {
  11135. bRet = true;
  11136. } else if (versionTXT.indexOf("2.") >= 0) {
  11137. bRet = true;
  11138. }
  11139. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11140. if (SetData != null && bRet == true) {
  11141. SetData.SetServerVer(versionTXT);
  11142. SetData.closeDB();
  11143. }
  11144. if (bRet == true) {
  11145. try {
  11146. iMapSverReload tSock = new iMapSverReload();
  11147. tSock.start();
  11148. } catch (IOException e) {
  11149. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  11150. //e.printStackTrace();
  11151. LogUtil.errorLogInfo("", TAG, e);
  11152. }
  11153. }
  11154. // 버전 체크해서
  11155. // 응답하고 나서
  11156. // 수신부 쓰레드 재 로딩..
  11157. if (versionTXT != null && bRet == true) {
  11158. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  11159. retXML += " </service>\r\n</imap>";
  11160. return retXML;
  11161. } else {
  11162. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11163. retXML += " </service>\r\n</imap>";
  11164. return retXML;
  11165. }
  11166. } catch (RuntimeException re) {
  11167. LogUtil.errorLogInfo("", TAG, re);
  11168. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11169. retXML += " </service>\r\n</imap>";
  11170. return retXML;
  11171. } catch (Exception e) {
  11172. //e.printStackTrace();
  11173. LogUtil.errorLogInfo("", TAG, e);
  11174. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11175. retXML += " </service>\r\n</imap>";
  11176. return retXML;
  11177. }
  11178. }
  11179. // 메인 서버 소켓 클래스
  11180. public class iMapSverReload extends Thread {
  11181. ServerSocket svr;
  11182. public iMapSverReload() throws IOException {
  11183. /////////////////////////////////////////////////////////////////////
  11184. // 신형 단지서버 사용 유무를 가져온다.
  11185. /////////////////////////////////////////////////////////////////////
  11186. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11187. if (SetData != null) {
  11188. String serverVesionInfo = SetData.GetServerVer();
  11189. SetData.closeDB();
  11190. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  11191. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11192. boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
  11193. devset.closeDB();
  11194. } else {
  11195. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11196. boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
  11197. devset.closeDB();
  11198. }
  11199. }
  11200. try {
  11201. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11202. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11203. wallpadDeviceSet.closeDB();
  11204. } catch (RuntimeException re) {
  11205. LogUtil.errorLogInfo("", TAG, re);
  11206. mNewDanjiServer = false;
  11207. } catch (Exception e) {
  11208. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  11209. //e.printStackTrace();
  11210. LogUtil.errorLogInfo("", TAG, e);
  11211. mNewDanjiServer = false;
  11212. }
  11213. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
  11214. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  11215. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  11216. // 관리 PC IP도 변경하도록 한다.
  11217. if (mNewDanjiServer == true) {
  11218. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11219. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  11220. wallpadStatusData.closeDB();
  11221. } else {
  11222. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11223. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  11224. wallpadStatusData.closeDB();
  11225. }
  11226. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  11227. }
  11228. public void run() {
  11229. try {
  11230. try {
  11231. Thread.sleep(400);
  11232. } catch (RuntimeException re) {
  11233. LogUtil.errorLogInfo("", TAG, re);
  11234. } catch (Exception e) {
  11235. LogUtil.errorLogInfo("", TAG, e);
  11236. }
  11237. SvrSock.destoryThread();
  11238. for (int i = 0; i < 20; i++) {
  11239. if (SvrSock.isAlive() == false) {
  11240. Log.d(TAG, " Receive Socket Reload i = : " + i);
  11241. break;
  11242. } else {
  11243. Log.d(TAG, " is Live Socket Reload i = : " + i);
  11244. }
  11245. try {
  11246. Thread.sleep(100);
  11247. } catch (RuntimeException re) {
  11248. LogUtil.errorLogInfo("", TAG, re);
  11249. } catch (Exception e) {
  11250. LogUtil.errorLogInfo("", TAG, e);
  11251. }
  11252. }
  11253. SvrSock = new iMapSverSocket();
  11254. SvrSock.start();
  11255. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  11256. try {
  11257. Thread.sleep(3000);
  11258. } catch (RuntimeException re) {
  11259. LogUtil.errorLogInfo("", TAG, re);
  11260. } catch (Exception e) {
  11261. LogUtil.errorLogInfo("", TAG, e);
  11262. }
  11263. try {
  11264. Intent intent = new Intent();
  11265. intent.setAction(define.NOTIFY_ACNAME);
  11266. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  11267. getApplicationContext().sendBroadcast(intent);
  11268. } catch (RuntimeException re) {
  11269. LogUtil.errorLogInfo("", TAG, re);
  11270. } catch (Exception e) {
  11271. //e.printStackTrace();
  11272. LogUtil.errorLogInfo("", TAG, e);
  11273. }
  11274. } catch (IOException e) {
  11275. //e.printStackTrace();
  11276. LogUtil.errorLogInfo("", TAG, e);
  11277. }
  11278. }
  11279. }
  11280. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  11281. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  11282. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  11283. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  11284. public static final int SCHEDULE_START_CALLAPP = 30004;
  11285. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  11286. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  11287. public class SchedulerThread extends Thread {
  11288. boolean doRun;
  11289. AddressSet addr;
  11290. String AddressStr;
  11291. String IPaddr;
  11292. String VerBSP = "";
  11293. String VerAPP;
  11294. String VerSetting;
  11295. String VerNews;
  11296. String VerWeather;
  11297. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  11298. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  11299. private jni mGleInterface = null;
  11300. private final int LIVE_SIGNAL_TIME = 20;
  11301. private int m_LiveSignalCount = 0;
  11302. private int m_MainAppLiveCount = 0;
  11303. Handler ScheDuleHandler = new Handler() {
  11304. public void handleMessage(Message msg) {
  11305. switch (msg.what) {
  11306. case SCHEDULE_START_HEARTBEAT: {
  11307. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  11308. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11309. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11310. DBMGR.closeDB();
  11311. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11312. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11313. }
  11314. break;
  11315. case SCHEDULE_CHANGE_HEARTBEAT:
  11316. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  11317. synchronized (ScheduleList) {
  11318. ScheduleData CheckData;
  11319. for (int i = 0; i < ScheduleList.size(); i++) {
  11320. CheckData = ScheduleList.get(i);
  11321. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11322. Calendar cal = new GregorianCalendar();
  11323. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11324. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11325. DBMGR.closeDB();
  11326. cal.add(Calendar.MINUTE, heartbeatP);
  11327. CheckData.TData = cal;
  11328. ScheduleList.set(i, CheckData);
  11329. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11330. return;
  11331. }
  11332. }
  11333. }
  11334. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11335. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11336. break;
  11337. case SCHEDULE_START_STATUSBEAT:
  11338. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  11339. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11340. break;
  11341. case SCHEDULE_CHANGE_STATUSBEAT:
  11342. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  11343. synchronized (ScheduleList) {
  11344. ScheduleData CheckData;
  11345. for (int i = 0; i < ScheduleList.size(); i++) {
  11346. CheckData = ScheduleList.get(i);
  11347. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11348. Calendar cal = new GregorianCalendar();
  11349. cal.add(Calendar.MINUTE, heartbeatP);
  11350. CheckData.TData = cal;
  11351. ScheduleList.set(i, CheckData);
  11352. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11353. return;
  11354. }
  11355. }
  11356. }
  11357. break;
  11358. case SCHEDULE_START_CALLAPP:
  11359. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  11360. // Bundle bundle = new Bundle();
  11361. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  11362. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  11363. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  11364. // .putExtra(ITEM_CALL_DATA, bundle);
  11365. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11366. // iMAPstartActivity(intent);
  11367. break;
  11368. }
  11369. }
  11370. };
  11371. Handler GetHandler() {
  11372. return ScheDuleHandler;
  11373. }
  11374. public class ScheduleData {
  11375. Calendar TData;
  11376. String ActionSTR;
  11377. public ScheduleData(Calendar tdata, String ActionStr) {
  11378. TData = tdata;
  11379. ActionSTR = ActionStr;
  11380. }
  11381. }
  11382. public SchedulerThread() {
  11383. doRun = true;
  11384. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11385. addr = DBMGR.getAddressMGR();
  11386. VerAPP = DBMGR.GetAPPVer();
  11387. VerSetting = DBMGR.GetSettingVer();
  11388. VerNews = DBMGR.GetNoticeVer();
  11389. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11390. DBMGR.closeDB();
  11391. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  11392. try {
  11393. mGleInterface = new jni();
  11394. } catch (RuntimeException re) {
  11395. LogUtil.errorLogInfo("", TAG, re);
  11396. } catch (Exception e) {
  11397. Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
  11398. }
  11399. }
  11400. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
  11401. VerAPP = GetAppVersion();
  11402. }
  11403. AddressStr = addr.Dong + "동" + addr.Ho + "호";
  11404. IPaddr = addr.IPAddress;
  11405. ScheDulerHandler = ScheDuleHandler;
  11406. }
  11407. public void reg_schedule(int min, String Action) {
  11408. for (int i = 0; i < ScheduleList.size(); i++) {
  11409. ScheduleData scdata = ScheduleList.get(i);
  11410. if (scdata.ActionSTR.equals(Action)) {
  11411. ScheduleList.remove(i);
  11412. break;
  11413. }
  11414. }
  11415. Calendar cal = new GregorianCalendar();
  11416. cal.add(Calendar.MINUTE, min);
  11417. ScheduleData regData = new ScheduleData(cal, Action);
  11418. synchronized (ScheduleList) {
  11419. ScheduleList.add(regData);
  11420. }
  11421. }
  11422. private void doSchedule(String doing) {
  11423. String[] doingData = doing.split(";");
  11424. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11425. try {
  11426. String SendingStr = MakeHeartbeat();
  11427. SendToServer(SendingStr);
  11428. Calendar cal = new GregorianCalendar();
  11429. 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));
  11430. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11431. DBMGR.SetLastHeartbeat(timedata);
  11432. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11433. DBMGR.closeDB();
  11434. } catch (RuntimeException re) {
  11435. LogUtil.errorLogInfo("", TAG, re);
  11436. } catch (Exception e) {
  11437. //e.printStackTrace();
  11438. LogUtil.errorLogInfo("", TAG, e);
  11439. }
  11440. } else if (doingData[0].equals("UPDATETIME")) {
  11441. } else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11442. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  11443. if (!Common.getDeviceServeiceLoadComplite()) return;
  11444. String SendingStr = MakeStatusReport();
  11445. if (SendingStr == null) return;
  11446. SendToServer(SendingStr);
  11447. Calendar cal = new GregorianCalendar();
  11448. 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));
  11449. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11450. DBMGR.SetLastStatusbeat(timedata);
  11451. DBMGR.closeDB();
  11452. int StatusP = 720;
  11453. try {
  11454. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11455. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11456. devset.closeDB();
  11457. if (StatusVal == null) StatusP = 720;
  11458. else StatusP = Integer.parseInt(StatusVal[1]);
  11459. } catch (RuntimeException re) {
  11460. LogUtil.errorLogInfo("", TAG, re);
  11461. } catch (Exception e) {
  11462. //e.printStackTrace();
  11463. LogUtil.errorLogInfo("", TAG, e);
  11464. }
  11465. reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
  11466. }
  11467. }
  11468. private String MakeHeartbeat() {
  11469. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11470. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11471. VerNews = DBMGR.GetNoticeVer();
  11472. VerSetting = DBMGR.GetSettingVer();
  11473. String VerServer = DBMGR.GetServerVer();
  11474. DBMGR.closeDB();
  11475. if (VerServer == null) {
  11476. Log.d(TAG, "VerServer null");
  11477. VerServer = "1.0";
  11478. }
  11479. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11480. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  11481. wallpadDeviceSet.closeDB();
  11482. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  11483. // 스마트 분전반
  11484. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  11485. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  11486. String retStr = XMLHeader +
  11487. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11488. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11489. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11490. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11491. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11492. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11493. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11494. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11495. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11496. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11497. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11498. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n" +
  11499. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n" +
  11500. "</service>\r\n</imap>";
  11501. return retStr;
  11502. } else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  11503. // TODO KNX 분전반
  11504. // String retStr = XMLHeader+
  11505. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  11506. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  11507. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  11508. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  11509. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  11510. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  11511. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  11512. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  11513. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  11514. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  11515. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11516. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  11517. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  11518. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  11519. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  11520. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  11521. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  11522. // "</service>\r\n</imap>";
  11523. String retStr = XMLHeader +
  11524. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11525. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11526. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11527. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11528. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11529. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11530. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11531. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11532. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11533. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11534. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11535. "</service>\r\n</imap>";
  11536. return retStr;
  11537. } else {
  11538. String retStr = XMLHeader +
  11539. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11540. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11541. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11542. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11543. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11544. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11545. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11546. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11547. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11548. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11549. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11550. "</service>\r\n</imap>";
  11551. return retStr;
  11552. }
  11553. }
  11554. public String GetAppVersion() {
  11555. PackageInfo pi = null;
  11556. try {
  11557. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  11558. } catch (RuntimeException re) {
  11559. LogUtil.errorLogInfo("", TAG, re);
  11560. } catch (Exception e) {
  11561. LogUtil.errorLogInfo("", TAG, e);
  11562. }
  11563. return pi.versionName;
  11564. }
  11565. boolean isAlawaysrun = true;
  11566. public void run() {
  11567. while (/*doRun*/ isAlawaysrun) {
  11568. //Common.DebugLog("SchedulerThread ------ 10Sec");
  11569. CheckHeartBeat();
  11570. CheckStatusBeat();
  11571. CheckWallPadLiveSignal();
  11572. LiveCheckRebooting();
  11573. 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
  11574. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  11575. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  11576. //다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
  11577. if(skipCount==0) {
  11578. sendMsgToActivity(1234);
  11579. Log.d(TAG, "sendMsgToActivity!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
  11580. }
  11581. skipCount++;
  11582. if(skipCount==3) skipCount = 0 ;
  11583. }
  11584. try {
  11585. Thread.sleep(10000);
  11586. } catch (RuntimeException re) {
  11587. LogUtil.errorLogInfo("", TAG, re);
  11588. } catch (Exception e) {
  11589. LogUtil.errorLogInfo("", TAG, e);
  11590. }
  11591. }
  11592. }
  11593. public void SetLive() {
  11594. m_MainAppLiveCount++;
  11595. }
  11596. private int CheckTime30Sec = 0;
  11597. private void LiveCheckRebooting() {
  11598. try {
  11599. CheckTime30Sec++;
  11600. if (CheckTime30Sec % 20 == 0) {
  11601. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  11602. // // 10초마다 수행되는 함수이니....
  11603. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  11604. // if (m_MainAppLiveCount == 0) {
  11605. // //리셋
  11606. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  11607. // {
  11608. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  11609. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  11610. // pm.userActivity(8, true);
  11611. // }
  11612. // else
  11613. // {
  11614. // Log.d(TAG, "Main App Down Reset IHN_750");
  11615. // WallPadInterface wpdifc = new WallPadInterface();
  11616. // wpdifc.WachdogSystemReset();
  11617. // }
  11618. // }
  11619. // }
  11620. CheckTime30Sec = 0;
  11621. }
  11622. if (CheckTime30Sec >= 30000) {
  11623. CheckTime30Sec = 0;
  11624. }
  11625. } catch (RuntimeException re) {
  11626. LogUtil.errorLogInfo("", TAG, re);
  11627. } catch (Exception e) {
  11628. //e.printStackTrace();
  11629. LogUtil.errorLogInfo("", TAG, e);
  11630. }
  11631. }
  11632. private void CheckWallPadLiveSignal() {
  11633. try {
  11634. int nTime = LIVE_SIGNAL_TIME / 10;
  11635. m_LiveSignalCount++;
  11636. if (m_LiveSignalCount >= nTime) {
  11637. m_LiveSignalCount = 0;
  11638. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  11639. }
  11640. } catch (RuntimeException re) {
  11641. LogUtil.errorLogInfo("", TAG, re);
  11642. } catch (Exception e) {
  11643. Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
  11644. }
  11645. }
  11646. protected void CheckStatusBeat() {
  11647. try {
  11648. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11649. String statusbeatdata = WPD.GetLastStatusbeat();
  11650. WPD.closeDB();
  11651. int StatusP = 720;
  11652. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11653. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11654. if (StatusVal == null) StatusP = 720;
  11655. else
  11656. StatusP = Integer.parseInt(StatusVal[1]);
  11657. devset.closeDB();
  11658. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11659. } catch (RuntimeException re) {
  11660. LogUtil.errorLogInfo("", TAG, re);
  11661. } catch (Exception e) {
  11662. //e.printStackTrace();
  11663. LogUtil.errorLogInfo("", TAG, e);
  11664. }
  11665. }
  11666. protected void CheckHeartBeat() {
  11667. try {
  11668. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11669. String heartbeatdata = WPD.GetLastHeartbeat();
  11670. int heartbeatPer = WPD.GetHeartbeatPeriod();
  11671. WPD.closeDB();
  11672. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11673. } catch (RuntimeException re) {
  11674. LogUtil.errorLogInfo("", TAG, re);
  11675. } catch (Exception e) {
  11676. //e.printStackTrace();
  11677. LogUtil.errorLogInfo("", TAG, e);
  11678. }
  11679. }
  11680. protected boolean CheckTime(String CheckT, int period) {
  11681. Calendar last = new GregorianCalendar();
  11682. String[] timedata = CheckT.split("[.]");
  11683. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  11684. last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
  11685. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  11686. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  11687. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  11688. last.add(Calendar.MINUTE, period);
  11689. Calendar checkCal = new GregorianCalendar();
  11690. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  11691. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  11692. return true;
  11693. return false;
  11694. }
  11695. }
  11696. class SendMSGToSVR extends Thread {
  11697. String sendmsg;
  11698. public SendMSGToSVR(String msg) {
  11699. sendmsg = msg;
  11700. }
  11701. public void run() {
  11702. Socket sock = null;
  11703. DataOutputStream outstream = null;
  11704. try {
  11705. // 신형 단지서버 사용 유무를 가져온다.
  11706. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11707. boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11708. wallpadDeviceSet.closeDB();
  11709. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11710. SVRIP = DBMGR.GetServerIP();
  11711. port = DBMGR.GetServerPort();
  11712. DBMGR.closeDB();
  11713. /////////////////////////////////////////////////////////////////////
  11714. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  11715. // 사용중일 경우 암호화 소켓을 생성한다.
  11716. /////////////////////////////////////////////////////////////////////
  11717. if (!bNewDanjiServer) {
  11718. sock = new Socket(SVRIP, port);
  11719. } else {
  11720. int setport = port + 1000;
  11721. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  11722. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  11723. sock = sslClientSocket.getSocket();
  11724. }
  11725. /////////////////////////////////////////////////////////////////////
  11726. if (sock != null) {
  11727. sock.setSoLinger(true, 1000);
  11728. outstream = new DataOutputStream(sock.getOutputStream());
  11729. byte[] outBF = sendmsg.getBytes("euc-kr");
  11730. outstream.write(outBF);
  11731. outstream.flush();
  11732. }
  11733. } catch (RuntimeException re) {
  11734. LogUtil.errorLogInfo("", TAG, re);
  11735. } catch (Exception e) {
  11736. //e.printStackTrace();
  11737. LogUtil.errorLogInfo("", TAG, e);
  11738. } finally {
  11739. if (outstream != null) {
  11740. try {
  11741. outstream.close();
  11742. } catch (IOException e) {
  11743. LogUtil.errorLogInfo("", TAG, e);
  11744. }
  11745. }
  11746. outstream = null;
  11747. if (sock != null) {
  11748. try {
  11749. sock.close();
  11750. } catch (IOException e) {
  11751. LogUtil.errorLogInfo("", TAG, e);
  11752. }
  11753. }
  11754. sock = null;
  11755. }
  11756. }
  11757. }
  11758. private void SendToServer(String msg) {
  11759. SendMSGToSVR msan = new SendMSGToSVR(msg);
  11760. msan.start();
  11761. }
  11762. boolean StatusBeatRequested = false;
  11763. private String MakeStatusReport() {
  11764. try {
  11765. String ServiceType = StatusBeatRequested ? "requested" : "notice";
  11766. StatusBeatRequested = false;
  11767. String RetData = XMLHeader + "<service type=\"" + ServiceType + "\" name=\"statusbeat\"> \r\n";
  11768. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  11769. String[] typeList = SettManager.GetTypeList();
  11770. if (typeList == null || typeList.length == 0) {
  11771. DefaultProcauscultateReq(SettManager);
  11772. typeList = SettManager.GetTypeList();
  11773. }
  11774. SettManager.closeDB();
  11775. String[] ControlList;
  11776. String Vender = "null";
  11777. String devid = "null";
  11778. String Model = "null";
  11779. String subunitcnt = "null";
  11780. String statusRate = "null";
  11781. String statusType = "null";
  11782. String message = "null";
  11783. int itemCNT = 0;
  11784. int totalGroup = 0;
  11785. int totalItem = 0;
  11786. String ControlDEVList;
  11787. String ContentList = " ";
  11788. if (typeList != null) {
  11789. for (int i = 0; i < typeList.length; i++) {
  11790. if (typeList[i].equals("ctrl_device")) {
  11791. SettManager = new WallpadDevStatus(getApplicationContext());
  11792. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  11793. SettManager.closeDB();
  11794. ControlDEVList = "";
  11795. if (ControlList != null) {
  11796. for (int k = 0; k < ControlList.length; k++) {
  11797. if (ControlList[k].equals("light")) {
  11798. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11799. int[] lightinfo = devSet.Get_Light_info();
  11800. devSet.closeDB();
  11801. if (lightinfo[0] == 1) {
  11802. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  11803. subunitcnt = String.valueOf(lightinfo[2]);
  11804. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  11805. devid = "0x11";
  11806. Vender = "null";
  11807. Model = "null";
  11808. if (lightCTR != null) {
  11809. lightCTR.TRInfo.GetTransactionList(0);
  11810. statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
  11811. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  11812. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11813. message = "null";
  11814. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11815. itemCNT++;
  11816. }
  11817. } else {
  11818. subunitcnt = String.valueOf(lightinfo[2]);
  11819. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  11820. if (MultiSW != null) {
  11821. MultiSW.Refresh((byte) 0xFF, false);
  11822. byte Bdevid = 0x51;
  11823. for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
  11824. devid = String.format("0x%02X", Bdevid + j);
  11825. Vender = "null";
  11826. Model = "null";
  11827. MultiSW.TRInfo.GetTransactionList(j);
  11828. statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
  11829. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  11830. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11831. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11832. itemCNT++;
  11833. }
  11834. }
  11835. }
  11836. } else {
  11837. Vender = "null";
  11838. devid = "null";
  11839. Model = "null";
  11840. subunitcnt = "null";
  11841. statusRate = "null";
  11842. message = "null";
  11843. }
  11844. } else if (ControlList[k].equals("thermostat")) {
  11845. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11846. int ret = devSet.Get_Temper_Info();
  11847. devSet.closeDB();
  11848. if (ret == 1) {
  11849. // 난방 종류를 얻어온다.
  11850. int HeatingKind = mWallPadAPI.GetHeatingKind();
  11851. HeatingV1API heatingV1API = null;
  11852. HeatingV2API heatingV2API = null;
  11853. // 종류별 API를 로딩한다.
  11854. if (HeatingKind == 1) {
  11855. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  11856. if (heatingV1API != null) {
  11857. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  11858. devid = "0x21";
  11859. Vender = "null";
  11860. Model = "null";
  11861. heatingV1API.TRInfo.GetTransactionList(0);
  11862. statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
  11863. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  11864. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11865. message = "null";
  11866. }
  11867. } else if (HeatingKind == 2) {
  11868. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  11869. if (heatingV2API != null) {
  11870. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  11871. devid = "0x28";
  11872. Vender = "null";
  11873. Model = "null";
  11874. heatingV2API.TRInfo.GetTransactionList(0);
  11875. statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
  11876. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  11877. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11878. message = "null";
  11879. }
  11880. } else {
  11881. subunitcnt = "null";
  11882. devid = "null";
  11883. Vender = "null";
  11884. Model = "null";
  11885. statusRate = "0/0";
  11886. statusType = "bad";
  11887. message = "null";
  11888. }
  11889. ControlDEVList += " <unit type=\"thermostat\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11890. itemCNT++;
  11891. } else {
  11892. }
  11893. } else if (ControlList[k].equals("gas")) {
  11894. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11895. if (devSet.Get_GAS_Info() == 1) {
  11896. //여기서 신우전자확인이 더 필요함
  11897. GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
  11898. CooktopAPI HybridCookTopCTR = null;
  11899. subunitcnt = "1";
  11900. devid = "0x31";
  11901. Vender = "null";
  11902. Model = "null";
  11903. if (mWallPadAPI.GetGasKind() == 2) {
  11904. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  11905. if (HybridCookTopCTR != null) {
  11906. HybridCookTopCTR.TRInfo.GetTransactionList(0);
  11907. statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
  11908. double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
  11909. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11910. message = "null";
  11911. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11912. itemCNT++;
  11913. }
  11914. } else {
  11915. GasCTR = mWallPadAPI.Get_GasController();
  11916. if (GasCTR != null) {
  11917. GasCTR.TRInfo.GetTransactionList(0);
  11918. statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
  11919. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  11920. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11921. message = "null";
  11922. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11923. itemCNT++;
  11924. }
  11925. }
  11926. } else {
  11927. }
  11928. devSet.closeDB();
  11929. } else if (ControlList[k].equals("doorlock")) {
  11930. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11931. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  11932. if (doorlockInfo[0] == 1) {
  11933. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  11934. subunitcnt = "1";
  11935. devid = "0x41";
  11936. Vender = "null";
  11937. Model = "null";
  11938. if (DoorCTR != null) {
  11939. DoorCTR.TRInfo.GetTransactionList(0);
  11940. statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
  11941. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  11942. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11943. message = "null";
  11944. ControlDEVList += " <unit type=\"doorlock\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11945. itemCNT++;
  11946. }
  11947. } else {
  11948. }
  11949. devSet.closeDB();
  11950. } else if (ControlList[k].equals("ventil")) {
  11951. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11952. int[] ventilInfo = devSet.Get_Ventil_Info();
  11953. if (ventilInfo[0] == 1) {
  11954. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  11955. subunitcnt = "1";
  11956. devid = "0x61";
  11957. Vender = "null";
  11958. Model = "null";
  11959. if (VentilCTR != null) {
  11960. VentilCTR.TRInfo.GetTransactionList(0);
  11961. statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
  11962. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  11963. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11964. message = "null";
  11965. ControlDEVList += " <unit type=\"ventil\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11966. itemCNT++;
  11967. }
  11968. } else {
  11969. }
  11970. devSet.closeDB();
  11971. } else if (ControlList[k].equals("aircon")) {
  11972. } else if (ControlList[k].equals("curtain")) {
  11973. }
  11974. }
  11975. if (itemCNT > 0) {
  11976. ContentList += "<group type=\"ctrl_device\" count=\"" + itemCNT + "\">\r\n";
  11977. ContentList += ControlDEVList;
  11978. ContentList += "</group>\r\n";
  11979. totalGroup++;
  11980. totalItem += itemCNT;
  11981. }
  11982. }
  11983. } else if (typeList[i].equals("talk_device")) {
  11984. SettManager = new WallpadDevStatus(getApplicationContext());
  11985. ControlList = SettManager.GetSettingGroupData("talk_device");
  11986. SettManager.closeDB();
  11987. itemCNT = 0;
  11988. ControlDEVList = "";
  11989. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  11990. if (testAPI != null)
  11991. testAPI.GetVersion();
  11992. if (ControlList != null) {
  11993. for (int k = 0; k < ControlList.length; k++) {
  11994. if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
  11995. 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";
  11996. itemCNT++;
  11997. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  11998. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  11999. } else if (ControlList[k].equals("bath_phone") && testAPI != null) {
  12000. 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";
  12001. itemCNT++;
  12002. } else if (ControlList[k].equals("subhome_dev")) {
  12003. }
  12004. }
  12005. if (itemCNT > 0) {
  12006. ContentList += "<group type=\"talk_device\" count=\"" + itemCNT + "\">\r\n";
  12007. ContentList += ControlDEVList;
  12008. ContentList += "</group>\r\n";
  12009. totalGroup++;
  12010. totalItem += itemCNT;
  12011. }
  12012. }
  12013. } else if (typeList[i].equals("sensor")) {
  12014. SettManager = new WallpadDevStatus(getApplicationContext());
  12015. ControlList = SettManager.GetSettingGroupData("sensor");
  12016. SettManager.closeDB();
  12017. itemCNT = 0;
  12018. ControlDEVList = "";
  12019. if (ControlList != null) {
  12020. for (int k = 0; k < ControlList.length; k++) {
  12021. if (ControlList[k].equals("magnetic")) {
  12022. WallPadInterface wpifc = new WallPadInterface();
  12023. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  12024. String SenStateCom;
  12025. String SenStateType;
  12026. if (MagSen == 1) {
  12027. SenStateCom = "1/1";
  12028. SenStateType = "";
  12029. } else {
  12030. SenStateCom = "0/1";
  12031. SenStateType = "perfect";
  12032. }
  12033. ControlDEVList += " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12034. itemCNT++;
  12035. } else if (ControlList[k].equals("bugout")) {
  12036. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12037. int sensor = devSet.Get_Sensor_Set();
  12038. devSet.closeDB();
  12039. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  12040. WallPadInterface wpifc = new WallPadInterface();
  12041. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12042. String SenStateCom;
  12043. String SenStateType;
  12044. if (outSen == 1) {
  12045. SenStateCom = "1/1";
  12046. SenStateType = "bad";
  12047. } else {
  12048. SenStateCom = "0/1";
  12049. SenStateType = "perfect";
  12050. }
  12051. ControlDEVList += " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12052. itemCNT++;
  12053. }
  12054. } else if (ControlList[k].equals("bugin")) {
  12055. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12056. int sensor = devSet.Get_Sensor_Set();
  12057. devSet.closeDB();
  12058. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  12059. WallPadInterface wpifc = new WallPadInterface();
  12060. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12061. String SenStateCom;
  12062. String SenStateType;
  12063. if (InSen == 1) {
  12064. SenStateCom = "1/1";
  12065. SenStateType = "bad";
  12066. } else {
  12067. SenStateCom = "0/1";
  12068. SenStateType = "perfect";
  12069. }
  12070. ControlDEVList += " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12071. itemCNT++;
  12072. }
  12073. } else if (ControlList[k].equals("fire")) {
  12074. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12075. } else if (ControlList[k].equals("gas")) {
  12076. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12077. }
  12078. }
  12079. if (itemCNT > 0) {
  12080. ContentList += "<group type=\"sensor\" count=\"" + itemCNT + "\">\r\n";
  12081. ContentList += ControlDEVList;
  12082. ContentList += "</group>\r\n";
  12083. totalGroup++;
  12084. totalItem += itemCNT;
  12085. }
  12086. }
  12087. } else if (typeList[i].equals("extended")) {
  12088. SettManager = new WallpadDevStatus(getApplicationContext());
  12089. ControlList = SettManager.GetSettingGroupData("extended");
  12090. SettManager.closeDB();
  12091. itemCNT = 0;
  12092. ControlDEVList = "";
  12093. if (ControlList != null) {
  12094. for (int k = 0; k < ControlList.length; k++) {
  12095. if (ControlList[k].equals("gateway")) {
  12096. } else if (ControlList[k].equals("handy")) {
  12097. } else if (ControlList[k].equals("smartswitch")) {
  12098. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12099. int[] BatchInfo = devSet.Get_BatchSW_Info();
  12100. devSet.closeDB();
  12101. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
  12102. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  12103. SmartSWCTR.TRInfo.GetTransactionList(0);
  12104. subunitcnt = "1";
  12105. statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
  12106. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  12107. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12108. message = "null";
  12109. ControlDEVList += " <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12110. itemCNT++;
  12111. } else {
  12112. }
  12113. } else if (ControlList[k].equals("energymeter")) {
  12114. }
  12115. }
  12116. if (itemCNT > 0) {
  12117. ContentList += "<group type=\"extended\" count=\"" + itemCNT + "\">\r\n";
  12118. ContentList += ControlDEVList;
  12119. ContentList += "</group>\r\n";
  12120. totalGroup++;
  12121. totalItem += itemCNT;
  12122. }
  12123. }
  12124. }
  12125. }
  12126. SettManager.closeDB();
  12127. ContentList += "</guidemap> \r\n";
  12128. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\"" + totalGroup + "\" device_cnt=\"" + totalItem + "\">\r\n";
  12129. RetData += ContentList;
  12130. String LogSet;
  12131. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  12132. RetData += LogSet;
  12133. try {
  12134. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  12135. String[] ResetData = WsDB.GetResetSchedule();
  12136. WsDB.closeDB();
  12137. if (!ResetData[0].equals("NONE")) {
  12138. int type = Integer.parseInt(ResetData[0]);
  12139. if (type == WallpadStatusData.RESET_MONTH)
  12140. LogSet = "<reset_info enable=\"true\" type=\"month\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12141. else if (type == WallpadStatusData.RESET_WEEK)
  12142. LogSet = "<reset_info enable=\"true\" type=\"week\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12143. else
  12144. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12145. } else
  12146. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12147. } catch (RuntimeException re) {
  12148. LogUtil.errorLogInfo("", TAG, re);
  12149. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12150. } catch (Exception e) {
  12151. //e.printStackTrace();
  12152. LogUtil.errorLogInfo("", TAG, e);
  12153. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12154. }
  12155. RetData += LogSet;
  12156. RetData += "</service>\r\n</imap>\r\n";
  12157. }
  12158. return RetData;
  12159. } catch (RuntimeException re) {
  12160. LogUtil.errorLogInfo("", TAG, re);
  12161. return null;
  12162. } catch (Exception e) {
  12163. //e.printStackTrace();
  12164. LogUtil.errorLogInfo("", TAG, e);
  12165. return null;
  12166. }
  12167. }
  12168. private String getKNXDeviceStatus(int device) {
  12169. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12170. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12171. String status = knxHeartbeat.getStatus();
  12172. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  12173. return status;
  12174. }
  12175. private String getKNXDeviceCause(int device) {
  12176. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12177. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12178. String cause = knxHeartbeat.getCause();
  12179. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  12180. return cause;
  12181. }
  12182. //mWallPadAPI
  12183. // private String TAG = "*yskim*";
  12184. //private IGW200dAPI iGW200dAPI = null;
  12185. /**
  12186. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12187. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12188. * 본 딜레이 코드를 임시로 적용한다.
  12189. */
  12190. @SuppressLint("HandlerLeak")
  12191. protected Handler IGW200APICheckHandler = new Handler() {
  12192. @SuppressLint("HandlerLeak")
  12193. @Override
  12194. public void handleMessage(Message msg) {
  12195. if (msg.what == 0) {
  12196. if (mWallPadAPI != null) {
  12197. Common.DebugLog("handleMessage what 0 ");
  12198. if (mWallPadAPI.Check_Connect())
  12199. IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12200. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12201. }
  12202. } else if (msg.what == 1) {
  12203. Common.DebugLog("handleMessage what 1 ");
  12204. setIGE200Interface();
  12205. }
  12206. }
  12207. };
  12208. public void setIGE200Interface() {
  12209. try {
  12210. Common.DebugLog("setIGE200Interface");
  12211. mIGW200 = new IGW200(this, mWallPadAPI);
  12212. } catch (RuntimeException re) {
  12213. LogUtil.errorLogInfo("", TAG, re);
  12214. } catch (Exception e) {
  12215. Log.e(TAG, "[Exception] setIGE200Interface()");
  12216. //e.printStackTrace();
  12217. LogUtil.errorLogInfo("", TAG, e);
  12218. }
  12219. }
  12220. /**
  12221. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12222. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12223. * 본 딜레이 코드를 임시로 적용한다.
  12224. */
  12225. @SuppressLint("HandlerLeak")
  12226. protected Handler IGW300APICheckHandler = new Handler() {
  12227. @SuppressLint("HandlerLeak")
  12228. @Override
  12229. public void handleMessage(Message msg) {
  12230. if (msg.what == 0) {
  12231. if (mWallPadAPI != null) {
  12232. Common.DebugLog("handleMessage what 0 ");
  12233. if (mWallPadAPI.Check_Connect())
  12234. IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12235. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12236. }
  12237. } else if (msg.what == 1) {
  12238. Common.DebugLog("handleMessage what 1 ");
  12239. setIGE300Interface();
  12240. }
  12241. }
  12242. };
  12243. public void setIGE300Interface() {
  12244. try {
  12245. Common.DebugLog("setIGE300Interface");
  12246. mIGW300 = new IGW300(this, mWallPadAPI);
  12247. } catch (RuntimeException re) {
  12248. LogUtil.errorLogInfo("", TAG, re);
  12249. } catch (Exception e) {
  12250. Log.e(TAG, "[Exception] setIGE300Interface()");
  12251. //e.printStackTrace();
  12252. LogUtil.errorLogInfo("", TAG, e);
  12253. }
  12254. }
  12255. // 외출모드 연동
  12256. private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
  12257. try {
  12258. bSmartSwitch485ComebackMode = false;
  12259. String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
  12260. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12261. String outLinkCtrl = wd.GetOutModeLinkDevice();
  12262. if (BedMode == true)
  12263. outLinkCtrl = wd.GetInBedLinkDevice();
  12264. wd.closeDB();
  12265. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  12266. if (WallpadUI == false) {
  12267. if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
  12268. {
  12269. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
  12270. CallElevatorBtn(false);
  12271. }
  12272. }
  12273. if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
  12274. {
  12275. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
  12276. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  12277. }
  12278. if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  12279. {
  12280. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
  12281. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  12282. }
  12283. if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  12284. {
  12285. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
  12286. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  12287. }
  12288. if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
  12289. {
  12290. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
  12291. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  12292. }
  12293. } catch (RuntimeException re) {
  12294. LogUtil.errorLogInfo("", TAG, re);
  12295. } catch (Exception e) {
  12296. Log.e("YSKIM", e.toString());
  12297. }
  12298. }
  12299. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  12300. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  12301. private boolean bSmartSwitch485ComebackMode = false;
  12302. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  12303. try {
  12304. if (bSmartSwitch485ComebackMode == true) return;
  12305. String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
  12306. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12307. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  12308. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  12309. wd.closeDB();
  12310. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  12311. // 일괄소등 해제
  12312. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
  12313. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  12314. }
  12315. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
  12316. // 환기동작
  12317. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
  12318. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  12319. }
  12320. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  12321. // 난방 외출모드 해제
  12322. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
  12323. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  12324. }
  12325. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  12326. // 웰컴조명 켜기
  12327. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
  12328. // 웰컴조명 Handler 실행
  12329. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  12330. }
  12331. } catch (RuntimeException re) {
  12332. LogUtil.errorLogInfo("", TAG, re);
  12333. } catch (Exception e) {
  12334. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  12335. //e.printStackTrace();
  12336. LogUtil.errorLogInfo("", TAG, e);
  12337. }
  12338. }
  12339. private Handler WelcomeLightHandler = new Handler() {
  12340. int LightOnCount = 0;
  12341. @Override
  12342. public void handleMessage(Message msg) {
  12343. if (msg.what == 0) {
  12344. try {
  12345. if (LightOnCount == 0) {
  12346. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  12347. }
  12348. // 일괄소등 해제이면
  12349. if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
  12350. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  12351. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  12352. } else {
  12353. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  12354. LightOnCount++;
  12355. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  12356. if (LightOnCount > 10) {
  12357. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  12358. LightOnCount = 0;
  12359. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  12360. }
  12361. }
  12362. } catch (RuntimeException re) {
  12363. LogUtil.errorLogInfo("", TAG, re);
  12364. } catch (Exception e1) {
  12365. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  12366. //e1.printStackTrace();
  12367. LogUtil.errorLogInfo("", TAG, e1);
  12368. }
  12369. } else if (msg.what == 1) {
  12370. try {
  12371. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  12372. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  12373. LightOnCount = 0;
  12374. } catch (RuntimeException re) {
  12375. LogUtil.errorLogInfo("", TAG, re);
  12376. } catch (Exception e1) {
  12377. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  12378. //e1.printStackTrace();
  12379. LogUtil.errorLogInfo("", TAG, e1);
  12380. }
  12381. } else if (msg.what == 2) {
  12382. // Do Nothing
  12383. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  12384. WelcomeLightHandler.removeMessages(0);
  12385. }
  12386. }
  12387. };
  12388. //방범 및 알람 상태 확인 Resume 시 처리
  12389. private void CheckMainStatus() {
  12390. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  12391. try {
  12392. final String packageName = "com.artncore.apps.ic_wallpad";
  12393. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  12394. //CallAppRun = getForegroundAPK().equals(packageName);
  12395. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  12396. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12397. int alarmstate = SetData.GetAlarmStatus();
  12398. SetData.closeDB();
  12399. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
  12400. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  12401. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
  12402. return;
  12403. } else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  12404. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  12405. int base = 7000;
  12406. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
  12407. int Menu_Start_Id = 0;
  12408. SetData = new WallpadStatusData(getApplicationContext());
  12409. int alarmtype = SetData.GetAlarmType();
  12410. SetData.closeDB();
  12411. switch (alarmtype) {
  12412. case WallpadStatusData.ALARM_ALERT:
  12413. Menu_Start_Id = Menu_Id_List[1];
  12414. break;
  12415. case WallpadStatusData.ALARM_EMM:
  12416. Menu_Start_Id = Menu_Id_List[0];
  12417. break;
  12418. case WallpadStatusData.ALARM_EVAC:
  12419. Menu_Start_Id = Menu_Id_List[3];
  12420. break;
  12421. case WallpadStatusData.ALARM_INVADE:
  12422. Menu_Start_Id = Menu_Id_List[2];
  12423. break;
  12424. case WallpadStatusData.ALARM_HEATING_LEAK:
  12425. Menu_Start_Id = Menu_Id_List[4];
  12426. break;
  12427. default:
  12428. Menu_Start_Id = Menu_Id_List[1];
  12429. break;
  12430. }
  12431. if (Menu_Start_Id > 0) {
  12432. /*
  12433. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  12434. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  12435. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  12436. * "RESUME"을 전달한다.
  12437. */
  12438. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12439. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12440. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12441. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  12442. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  12443. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12444. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12445. startActivity(newintent);
  12446. return;
  12447. }
  12448. } else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  12449. if (OutModeRunAppRun == true) {
  12450. Log.d(TAG, "already outmoderun app running !!!!");
  12451. return;
  12452. }
  12453. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12454. int sensor = devset.Get_Sensor_Set();
  12455. devset.closeDB();
  12456. int base = 7000;
  12457. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12458. int Menu_Start_Id = 0;
  12459. int Menu_Start_Option = 1;
  12460. if (sensor > 0) {
  12461. WallPadInterface wpifc = new WallPadInterface();
  12462. int[] SensorInfoDB;
  12463. int inSen = 0;
  12464. int outSen = 0;
  12465. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12466. if (SensorInfoDB[0] == 1) {
  12467. // 내부동체가 사용함이면 상태 검사
  12468. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12469. }
  12470. if (SensorInfoDB[1] == 1) {
  12471. // 외부동체가 사용함이면 상태 검사
  12472. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12473. }
  12474. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12475. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12476. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
  12477. ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  12478. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12479. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12480. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12481. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12482. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12483. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
  12484. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12485. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12486. startActivity(newintent);
  12487. return;
  12488. }
  12489. }
  12490. base = 8000;
  12491. Menu_Id_List = new int[]{base + 11};
  12492. Menu_Start_Id = base + 11;
  12493. Menu_Start_Option = -1;
  12494. Intent intent = new Intent(Intent.ACTION_MAIN);
  12495. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12496. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12497. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12498. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  12499. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12500. startActivity(intent);
  12501. } else if (alarmstate == WallpadStatusData.GUARD_IN) {
  12502. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12503. int sensor = devset.Get_Sensor_Set();
  12504. devset.closeDB();
  12505. int base = 7000;
  12506. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12507. int Menu_Start_Option = 1;
  12508. if (sensor > 0) {
  12509. WallPadInterface wpifc = new WallPadInterface();
  12510. int[] SensorInfoDB;
  12511. int outSen = 0;
  12512. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12513. if (SensorInfoDB[1] == 1) {
  12514. // 외부동체가 사용함이면 상태 검사
  12515. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12516. }
  12517. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12518. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
  12519. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12520. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12521. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12522. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12523. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12524. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  12525. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12526. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12527. startActivity(newintent);
  12528. return;
  12529. }
  12530. }
  12531. } else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  12532. WallPadInterface wpifc = new WallPadInterface();
  12533. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  12534. return;
  12535. } else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  12536. int base = 4000;
  12537. int Menu_Start_Id = 0;
  12538. int[] Menu_Id_List = new int[]{base + 11, base + 21};
  12539. Menu_Start_Id = base + 11;
  12540. Intent intent = new Intent(Intent.ACTION_MAIN);
  12541. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12542. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12543. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  12544. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  12545. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12546. startActivity(intent);
  12547. return;
  12548. }
  12549. } catch (RuntimeException re) {
  12550. LogUtil.errorLogInfo("", TAG, re);
  12551. } catch (Exception e) {
  12552. Log.e(TAG, "[Exception] CheckMainStatus()");
  12553. //e.printStackTrace();
  12554. LogUtil.errorLogInfo("", TAG, e);
  12555. }
  12556. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12557. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  12558. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12559. // {
  12560. // WallPadInterface wpifc = new WallPadInterface();
  12561. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  12562. //
  12563. // if (fleeSensor > 0)
  12564. // {
  12565. // int base = 7000;
  12566. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12567. // int Menu_Start_Option = 1;
  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[3]); // KEY : MENU_START_ID
  12571. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12572. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  12573. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12574. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12575. // startActivity(newintent);
  12576. // devset.closeDB();
  12577. // return;
  12578. // }
  12579. // }
  12580. //
  12581. // StatusVal = devset.GetDeviceSetted("알람발생");
  12582. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12583. // {
  12584. // WallPadInterface wpifc = new WallPadInterface();
  12585. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  12586. //
  12587. // if (AlarmSensor > 0)
  12588. // {
  12589. // int base = 7000;
  12590. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12591. // int Menu_Start_Option = 1;
  12592. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12593. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12594. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  12595. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12596. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  12597. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12598. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12599. // startActivity(newintent);
  12600. // devset.closeDB();
  12601. // return;
  12602. // }
  12603. //
  12604. // }
  12605. // devset.closeDB();
  12606. }
  12607. /**
  12608. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  12609. *
  12610. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  12611. */
  12612. public boolean GetUseIlgalControlForAdmin() {
  12613. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12614. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  12615. devSet.closeDB();
  12616. boolean result = false;
  12617. if (MetringDB != null) {
  12618. try {
  12619. String devInfo = MetringDB[1];
  12620. devInfo = devInfo.replace('(', '_');
  12621. devInfo = devInfo.replace(':', '_');
  12622. devInfo = devInfo.replace(')', '_');
  12623. String[] MetringInfo = devInfo.split("_");
  12624. if (MetringInfo[3].equals("사용함") == true) {
  12625. result = true;
  12626. }
  12627. } catch (RuntimeException re) {
  12628. LogUtil.errorLogInfo("", TAG, re);
  12629. } catch (Exception e) {
  12630. //e.printStackTrace();
  12631. LogUtil.errorLogInfo("", TAG, e);
  12632. }
  12633. }
  12634. return result;
  12635. }
  12636. class SendLHGWCheck extends Thread {
  12637. private iMAP_hn_config_read m_HnGWConfigRead = null;
  12638. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  12639. private boolean retSucces = false;
  12640. private int retryCount = 0;
  12641. public SendLHGWCheck() {
  12642. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  12643. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  12644. retryCount = 0;
  12645. }
  12646. public void run() {
  12647. try {
  12648. try {
  12649. Thread.sleep(2000);
  12650. } catch (RuntimeException re) {
  12651. LogUtil.errorLogInfo("", TAG, re);
  12652. } catch (Exception e) {
  12653. LogUtil.errorLogInfo("", TAG, e);
  12654. }
  12655. for (int i = 0; i < 10; i++) {
  12656. m_HnGWConfigRead.DoWork();
  12657. m_HnGWConfigRead.SetRetCtr(new RetProci() {
  12658. @Override
  12659. public void ProcSuccess() {
  12660. retSucces = true;
  12661. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
  12662. }
  12663. @Override
  12664. public void ProcError() {
  12665. }
  12666. @Override
  12667. public void ProcDoing() {
  12668. // TODO Auto-generated method stub
  12669. }
  12670. });
  12671. if (retSucces == true)
  12672. break;
  12673. retryCount++;
  12674. try {
  12675. Thread.sleep(3000);
  12676. } catch (RuntimeException re) {
  12677. LogUtil.errorLogInfo("", TAG, re);
  12678. } catch (Exception e) {
  12679. LogUtil.errorLogInfo("", TAG, e);
  12680. }
  12681. }
  12682. m_HnGWEmptyMsg.DoWork();
  12683. m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
  12684. @Override
  12685. public void ProcSuccess() {
  12686. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
  12687. }
  12688. @Override
  12689. public void ProcError() {
  12690. Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
  12691. }
  12692. @Override
  12693. public void ProcDoing() {
  12694. // TODO Auto-generated method stub
  12695. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
  12696. }
  12697. });
  12698. } catch (RuntimeException re) {
  12699. LogUtil.errorLogInfo("", TAG, re);
  12700. } catch (Exception e) {
  12701. //e.printStackTrace();
  12702. LogUtil.errorLogInfo("", TAG, e);
  12703. }
  12704. }
  12705. }
  12706. //Reset Handler
  12707. private Handler mResetHandler = new Handler() {
  12708. @Override
  12709. public void handleMessage(Message msg) {
  12710. if (msg.what == 0) {
  12711. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  12712. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  12713. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  12714. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  12715. if (NowMainStatus == false) {
  12716. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12717. ResetCount = 1;
  12718. }
  12719. ResetCount++;
  12720. NowMainStatus = true;
  12721. if (ResetCount == 30) {
  12722. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12723. } else {
  12724. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12725. }
  12726. } else {
  12727. if (NowMainStatus == true) {
  12728. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12729. ResetCount = 1;
  12730. }
  12731. ResetCount++;
  12732. NowMainStatus = false;
  12733. if (ResetCount == 180) {
  12734. // 3분
  12735. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12736. } else {
  12737. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12738. }
  12739. }
  12740. } else if (msg.what == 1) {
  12741. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  12742. setDefaultLauncher();
  12743. Intent intent = new Intent();
  12744. intent.setAction(define.NOTIFY_ACNAME);
  12745. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12746. getApplicationContext().sendBroadcast(intent);
  12747. }
  12748. }
  12749. };
  12750. // 통화주체를 다루는 enum
  12751. public enum CALLOWNER {
  12752. NONE,
  12753. WALLPAD,
  12754. SUB_WALLPAD,
  12755. KITCHEN_TV,
  12756. BATH_PHONE,
  12757. BATH_TV,
  12758. UNIVERSAL_DEVICE,
  12759. ERROR;
  12760. }
  12761. public enum CALLEVENTTYPE {
  12762. RECEIVE_CALL, // 호출 수신 (호출 수신)
  12763. TRYING_CALL, // 호출 시도중 (호출 발신)
  12764. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  12765. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  12766. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  12767. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  12768. CONNECT_CALL, // 통화 시작
  12769. TERMINATE_CALL, // 통화 종료
  12770. CANCEL_CALL, // 호출 취소
  12771. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  12772. REJECT_CALL, // 호출수신 거절
  12773. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  12774. FORWARD_CALL, // 착신전환 설정
  12775. CALLERID, // Caller ID
  12776. TIMEOUT_1STCALL, // 1st Call Timeout
  12777. TIMEOUT_2NDCALL, // 2nd Call Timeout
  12778. TIMEOUT_3RDCALL, // 3rd Call Timeout
  12779. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  12780. DOOR_OPEN, // 문열림 설정
  12781. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  12782. PSTN_DTMF, // PSTN DTMF 수신
  12783. DETECT_STRANGER, // 거동수상자 발생
  12784. NONE;
  12785. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  12786. try {
  12787. if (value.equals(RECEIVE_CALL.toString())) {
  12788. return RECEIVE_CALL;
  12789. } else if (value.equals(TRYING_CALL.toString())) {
  12790. return TRYING_CALL;
  12791. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  12792. return RECEIVE_CALL_2ND;
  12793. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  12794. return RECEIVE_CALL_ACK;
  12795. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  12796. return REQUEST_FRONT_MONITORING;
  12797. } else if (value.equals(CONNECT_CALL.toString())) {
  12798. return CONNECT_CALL;
  12799. } else if (value.equals(TERMINATE_CALL.toString())) {
  12800. return TERMINATE_CALL;
  12801. } else if (value.equals(CANCEL_CALL.toString())) {
  12802. return CANCEL_CALL;
  12803. } else if (value.equals(REJECT_CALL.toString())) {
  12804. return REJECT_CALL;
  12805. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  12806. return REJECT_BUSY_CALL;
  12807. } else if (value.equals(FORWARD_CALL.toString())) {
  12808. return FORWARD_CALL;
  12809. } else if (value.equals(CALLERID.toString())) {
  12810. return CALLERID;
  12811. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  12812. return TIMEOUT_1STCALL;
  12813. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  12814. return TIMEOUT_2NDCALL;
  12815. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  12816. return TIMEOUT_3RDCALL;
  12817. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  12818. return MOIP_VIDEO_SET;
  12819. } else if (value.equals(DOOR_OPEN.toString())) {
  12820. return DOOR_OPEN;
  12821. } else if (value.equals(PSTN_RING.toString())) {
  12822. return PSTN_RING;
  12823. } else if (value.equals(PSTN_DTMF.toString())) {
  12824. return PSTN_DTMF;
  12825. } else if (value.equals(DETECT_STRANGER.toString())) {
  12826. return DETECT_STRANGER;
  12827. } else if (value.equals(NONE.toString())) {
  12828. return NONE;
  12829. } else {
  12830. return null;
  12831. }
  12832. } catch (RuntimeException re) {
  12833. LogUtil.errorLogInfo("", "", re);
  12834. return null;
  12835. } catch (Exception e) {
  12836. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  12837. //e.printStackTrace();
  12838. LogUtil.errorLogInfo("", "", e);
  12839. return null;
  12840. }
  12841. }
  12842. }
  12843. public enum CALLTYPE {
  12844. NONE,
  12845. FRONT,
  12846. RESIDENCE,
  12847. LOBBY,
  12848. GUARD,
  12849. PSTN,
  12850. IHUB,
  12851. ERROR,
  12852. }
  12853. public static class CALLTRIGGER {
  12854. public static String CALLOWNER = "CALLOWNER";
  12855. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  12856. public static String CALLTYPE = "CALLTYPE";
  12857. public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
  12858. public enum SOURCE {
  12859. USER,
  12860. CALL_RECEIVE,
  12861. SUBPHONE
  12862. }
  12863. public enum TYPE {
  12864. MENU,
  12865. FRONT,
  12866. LOBBY,
  12867. GUARD,
  12868. RESIDENCE,
  12869. PSTN
  12870. }
  12871. }
  12872. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  12873. int TAB_TALKFRONT = 130011;
  12874. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  12875. try {
  12876. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
  12877. if (!bWallPadCallLive) {
  12878. sendLCDBacklightStatus(true);
  12879. // 통화어플을 실행시킨다.
  12880. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12881. Common.SendAppFinishReqBR(getApplicationContext());
  12882. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12883. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12884. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  12885. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12886. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12887. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12888. mIntent.setComponent(mComponentName);
  12889. startActivity(mIntent);
  12890. playFrontBell(eCallOwner, eEventType, eCallType);
  12891. } else {
  12892. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  12893. // if (getUseSmartDoorCam()) {
  12894. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  12895. // }
  12896. }
  12897. } catch (RuntimeException re) {
  12898. LogUtil.errorLogInfo("", TAG, re);
  12899. } catch (Exception e) {
  12900. Log.e(TAG, "[Exception] runCallMainActivity()");
  12901. //e.printStackTrace();
  12902. LogUtil.errorLogInfo("", TAG, e);
  12903. }
  12904. }
  12905. //add KSJ 2021.11.02
  12906. public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
  12907. try {
  12908. if (!bWallPadCallLive || m_bWallpadCallScreen) {
  12909. // 통화어플을 실행시킨다.
  12910. Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
  12911. sendLCDBacklightStatus(true);
  12912. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  12913. int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
  12914. mWallpadStatusData.closeDB();
  12915. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12916. Common.SendAppFinishReqBR(getApplicationContext());
  12917. if(m_bWallpadCallScreen)
  12918. Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  12919. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12920. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12921. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  12922. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12923. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12924. mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
  12925. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12926. mIntent.setComponent(mComponentName);
  12927. startActivity(mIntent);
  12928. Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  12929. } else {
  12930. Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
  12931. }
  12932. } catch (RuntimeException re) {
  12933. LogUtil.errorLogInfo("", TAG, re);
  12934. } catch (Exception e) {
  12935. Log.e(TAG, "[Exception] runCallMainActivity()");
  12936. //e.printStackTrace();
  12937. LogUtil.errorLogInfo("", TAG, e);
  12938. }
  12939. }
  12940. //~add KSJ
  12941. private String getTopActivity() {
  12942. try {
  12943. ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  12944. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  12945. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  12946. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  12947. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  12948. return mComponentName.getPackageName();
  12949. } catch (RuntimeException re) {
  12950. LogUtil.errorLogInfo("", TAG, re);
  12951. return null;
  12952. } catch (Exception e) {
  12953. Log.e(TAG, "[Exception] getTopActivity()");
  12954. //e.printStackTrace();
  12955. LogUtil.errorLogInfo("", TAG, e);
  12956. return null;
  12957. }
  12958. }
  12959. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  12960. try {
  12961. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  12962. WallPadInterface Wiface = new WallPadInterface();
  12963. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  12964. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  12965. }
  12966. } catch (RuntimeException re) {
  12967. LogUtil.errorLogInfo("", TAG, re);
  12968. } catch (Exception e) {
  12969. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  12970. //e.printStackTrace();
  12971. LogUtil.errorLogInfo("", TAG, e);
  12972. }
  12973. }
  12974. private class AfterTransactionTodoListData {
  12975. String Title;
  12976. int Valueint;
  12977. String ValueString;
  12978. private AfterTransactionTodoListData(String title, int valueint, String valueString) {
  12979. Title = title;
  12980. Valueint = valueint;
  12981. ValueString = valueString;
  12982. }
  12983. }
  12984. /**
  12985. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  12986. **/
  12987. public void SendGetParkingInfoIntent() {
  12988. Intent iIntent = new Intent();
  12989. iIntent.setAction(define.NOTIFY_ACNAME);
  12990. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  12991. this.sendBroadcast(iIntent);
  12992. }
  12993. /**
  12994. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  12995. **/
  12996. public Handler SendParkingInfoIntentAfter20min = new Handler() {
  12997. @SuppressLint("HandlerLeak")
  12998. @Override
  12999. public void handleMessage(Message msg) {
  13000. if (msg.what == 0) {
  13001. SendGetParkingInfoIntent();
  13002. }
  13003. }
  13004. };
  13005. /**
  13006. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  13007. **/
  13008. public Handler mWallPadOutmodeSleepHandler = new Handler() {
  13009. @SuppressLint("HandlerLeak")
  13010. @Override
  13011. public void handleMessage(Message msg) {
  13012. if (msg.what == 0) {
  13013. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  13014. }
  13015. }
  13016. };
  13017. // Handler
  13018. public final class HANDLERMSG {
  13019. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  13020. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  13021. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  13022. public final static int CALLAPP_FINISHING_END = 300;
  13023. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  13024. }
  13025. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  13026. public void handleMessage(Message msg) {
  13027. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  13028. switch (msg.what) {
  13029. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  13030. bGlobalScreenRun = true;
  13031. break;
  13032. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  13033. bGlobalScreenRun = false;
  13034. break;
  13035. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  13036. break;
  13037. case HANDLERMSG.CALLAPP_FINISHING_END:
  13038. // bBlockCallEvent = false;
  13039. break;
  13040. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  13041. int time = Sound().PlayMent(SND.call.DINGDONG);
  13042. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  13043. if (time < 0) time = 2088;
  13044. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  13045. break;
  13046. default:
  13047. Log.v(TAG, "iMAPServerHandler : " + msg.what);
  13048. break;
  13049. }
  13050. }
  13051. };
  13052. public void sendHandlerMsg(int what, int arg1, int arg2) {
  13053. try {
  13054. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  13055. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13056. HandleMsg.what = what;
  13057. HandleMsg.arg1 = arg1;
  13058. HandleMsg.arg2 = arg2;
  13059. iMAPServerHandler.sendMessage(HandleMsg);
  13060. } catch (RuntimeException re) {
  13061. LogUtil.errorLogInfo("", TAG, re);
  13062. } catch (Exception e) {
  13063. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  13064. //e.printStackTrace();
  13065. LogUtil.errorLogInfo("", TAG, e);
  13066. }
  13067. }
  13068. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  13069. try {
  13070. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  13071. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13072. HandleMsg.what = what;
  13073. HandleMsg.arg1 = arg1;
  13074. HandleMsg.arg2 = arg2;
  13075. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  13076. } catch (RuntimeException re) {
  13077. LogUtil.errorLogInfo("", TAG, re);
  13078. } catch (Exception e) {
  13079. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  13080. //e.printStackTrace();
  13081. LogUtil.errorLogInfo("", TAG, e);
  13082. }
  13083. }
  13084. int mSensitivity = 0, mDuration = 0;
  13085. int MIN_SENSOR_SENSITIVITY = 1;
  13086. int MAX_SENSOR_SENSITIVITY = 5;
  13087. int MIN_SENSOR_DURATION = 30;
  13088. int MAX_SENSOR_DURATION = 250;
  13089. int DEFAULT_SENSOR_SENSITIVITY = 3;
  13090. int DEFAULT_SENSOR_DURATION = 60;
  13091. private final int COMPONENT_USE = 1;
  13092. /**
  13093. * 스마트현관카메라 사용여부 판별
  13094. */
  13095. private boolean getUseSmartDoorCam() {
  13096. try {
  13097. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13098. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13099. mWallpadDeviceSet.closeDB();
  13100. if (nFrontCam[0] == COMPONENT_USE) {
  13101. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  13102. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  13103. return true;
  13104. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  13105. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  13106. return true;
  13107. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13108. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  13109. return true;
  13110. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  13111. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  13112. return true;
  13113. } else {
  13114. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  13115. return false;
  13116. }
  13117. } else {
  13118. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  13119. return false;
  13120. }
  13121. } catch (RuntimeException re) {
  13122. LogUtil.errorLogInfo("", TAG, re);
  13123. return false;
  13124. } catch (Exception e) {
  13125. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  13126. //e.printStackTrace();
  13127. LogUtil.errorLogInfo("", TAG, e);
  13128. return false;
  13129. }
  13130. }
  13131. private int getSmartDoorCamType() {
  13132. try {
  13133. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13134. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13135. mWallpadDeviceSet.closeDB();
  13136. if (nFrontCam[0] == COMPONENT_USE) {
  13137. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13138. return nFrontCam[1];
  13139. }
  13140. }
  13141. } catch (RuntimeException re) {
  13142. LogUtil.errorLogInfo("", TAG, re);
  13143. } catch (Exception e) {
  13144. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  13145. //e.printStackTrace();
  13146. LogUtil.errorLogInfo("", TAG, e);
  13147. }
  13148. return -1;
  13149. }
  13150. /**
  13151. * 방문객원격통화 솔루션 사용여부 판별
  13152. */
  13153. private boolean getRemoteCallUseInfo() {
  13154. try {
  13155. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13156. if (mWallpadDeviceSet != null) {
  13157. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  13158. if (astrRemoteCall != null) {
  13159. if (astrRemoteCall[1].contains("사용함")) return true;
  13160. } else {
  13161. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  13162. }
  13163. }
  13164. mWallpadDeviceSet.closeDB();
  13165. } catch (RuntimeException re) {
  13166. LogUtil.errorLogInfo("", TAG, re);
  13167. } catch (Exception e) {
  13168. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  13169. //e.printStackTrace();
  13170. LogUtil.errorLogInfo("", TAG, e);
  13171. }
  13172. return false;
  13173. }
  13174. /*
  13175. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  13176. */
  13177. private RealTimeMeterAPI mRealTimeMeterAPI;
  13178. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  13179. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  13180. public Thread saveRealmeterDataThread = null;
  13181. private void startRealtimemeterInfo() {
  13182. try {
  13183. // 영업샘플 모드 판단
  13184. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13185. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  13186. } else {
  13187. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  13188. // 실시간 검침기 사용유무 판단
  13189. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13190. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13191. mWallpadDeviceSet.closeDB();
  13192. boolean bRealtimemeterUsage = false;
  13193. int nRealtimemeterCntDB = -99;
  13194. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  13195. // 실시간 검침 사용함
  13196. bRealtimemeterUsage = true;
  13197. nRealtimemeterCntDB = naRealtimemtInfo[1];
  13198. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  13199. } else {
  13200. // 실시간 검침 사용하지 않음
  13201. bRealtimemeterUsage = false;
  13202. }
  13203. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
  13204. }
  13205. } catch (RuntimeException re) {
  13206. LogUtil.errorLogInfo("", TAG, re);
  13207. } catch (Exception e) {
  13208. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  13209. //e.printStackTrace();
  13210. LogUtil.errorLogInfo("", TAG, e);
  13211. }
  13212. }
  13213. private void startSmartIoTCamInfo() {
  13214. try {
  13215. // 영업샘플 모드 판단
  13216. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13217. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  13218. } else {
  13219. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  13220. if (getUseSmartDoorCam()) {
  13221. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  13222. } else {
  13223. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  13224. }
  13225. }
  13226. } catch (RuntimeException re) {
  13227. LogUtil.errorLogInfo("", TAG, re);
  13228. } catch (Exception e) {
  13229. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  13230. //e.printStackTrace();
  13231. LogUtil.errorLogInfo("", TAG, e);
  13232. }
  13233. }
  13234. private void startDistributionPanel() {
  13235. try {
  13236. // 영업샘플 모드 판단
  13237. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  13238. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  13239. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  13240. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  13241. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13242. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  13243. mWallpadDeviceSet.closeDB();
  13244. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
  13245. initSmartDistributionPanelHandler.sendEmptyMessage(0);
  13246. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
  13247. initKNXDistributionPanelHandler.sendEmptyMessage(0);
  13248. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  13249. } else {
  13250. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  13251. }
  13252. } catch (RuntimeException re) {
  13253. LogUtil.errorLogInfo("", TAG, re);
  13254. } catch (Exception e) {
  13255. Log.e(TAG, "[Exception] startDistributionPanel()");
  13256. //e.printStackTrace();
  13257. LogUtil.errorLogInfo("", TAG, e);
  13258. }
  13259. }
  13260. // =================================================================================================
  13261. // [[ Device ]] region
  13262. // =================================================================================================
  13263. /**
  13264. * 디바이스 API 를 Load 한다.
  13265. *
  13266. * @param wpapi - 생성시 전달받은 WallPadAPI
  13267. * @return (int) - >=0 : 성공, <0 : 실패
  13268. */
  13269. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  13270. // 1. Mode Check
  13271. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13272. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  13273. return -1;
  13274. }
  13275. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  13276. // 2. wpapi Check
  13277. if (wpapi == null) {
  13278. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  13279. return -2;
  13280. }
  13281. // 3. Load API
  13282. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  13283. try {
  13284. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  13285. } catch (RuntimeException re) {
  13286. LogUtil.errorLogInfo("", TAG, re);
  13287. return -100;
  13288. } catch (Exception e) {
  13289. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  13290. //e.printStackTrace();
  13291. LogUtil.errorLogInfo("", TAG, e);
  13292. return -100;
  13293. }
  13294. if (mRealTimeMeterAPI == null) {
  13295. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  13296. return -4;
  13297. }
  13298. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  13299. return 0;
  13300. }
  13301. /**
  13302. * 제어기 상태를 가져온다.
  13303. *
  13304. * @param real - (boolean) true : 실시간 , false : 가장최근
  13305. * @return (int) - >=0 : 성공, <0 : 실패
  13306. */
  13307. @SuppressWarnings("unused")
  13308. private int updateRealtimemeterData(boolean real) {
  13309. try {
  13310. // 1. Api Load Check
  13311. if (mRealTimeMeterAPI == null) {
  13312. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  13313. return -1;
  13314. }
  13315. // 2. reflash
  13316. try {
  13317. int ret = mRealTimeMeterAPI.Refresh(real);
  13318. if (ret < 0) {
  13319. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  13320. return -2;
  13321. }
  13322. } catch (RuntimeException re) {
  13323. LogUtil.errorLogInfo("", TAG, re);
  13324. return -100;
  13325. } catch (Exception e) {
  13326. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  13327. //e.printStackTrace();
  13328. LogUtil.errorLogInfo("", TAG, e);
  13329. return -100;
  13330. }
  13331. // 3. Range Check
  13332. if (mRealTimeMeterAPI.data == null) {
  13333. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  13334. return -9;
  13335. }
  13336. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  13337. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  13338. return -10;
  13339. }
  13340. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  13341. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  13342. return -11;
  13343. }
  13344. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  13345. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  13346. return -12;
  13347. }
  13348. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  13349. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  13350. return -13;
  13351. }
  13352. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  13353. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  13354. return -14;
  13355. }
  13356. // 4. Data Copy
  13357. mRealTimeMeterData = mRealTimeMeterAPI.data;
  13358. // 5. Debug msg
  13359. if (DEBUG_REALMETER_DATA_LOG_ON) {
  13360. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  13361. Log.i(TAG, "[updateRealtimemeterData] - OK");
  13362. }
  13363. return 0;
  13364. } catch (RuntimeException re) {
  13365. LogUtil.errorLogInfo("", TAG, re);
  13366. return -99;
  13367. } catch (Exception e) {
  13368. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  13369. //e.printStackTrace();
  13370. LogUtil.errorLogInfo("", TAG, e);
  13371. return -99;
  13372. }
  13373. }
  13374. /**
  13375. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  13376. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  13377. * 본 딜레이 코드를 임시로 적용한다.
  13378. */
  13379. @SuppressLint("HandlerLeak")
  13380. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  13381. @SuppressLint("HandlerLeak")
  13382. @Override
  13383. public void handleMessage(Message msg) {
  13384. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  13385. if (msg.what == 0) {
  13386. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  13387. if (updateRealtimemeterData(false) == 0) {
  13388. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13389. } else {
  13390. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13391. }
  13392. } else {
  13393. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  13394. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13395. }
  13396. } else if (msg.what == 1) {
  13397. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  13398. if (mRealTimeMeterAPI != null) {
  13399. // Device_BrRegistration(true);
  13400. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13401. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13402. mWallpadDeviceSet.closeDB();
  13403. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  13404. saveRealmeterDataThread = new saveRealmeterData();
  13405. saveRealmeterDataThread.start();
  13406. }
  13407. // RemoveUsedData();
  13408. // ShowUsedDataGraph();
  13409. }
  13410. }
  13411. }
  13412. };
  13413. protected Handler initSmartDistributionPanelHandler = new Handler() {
  13414. @SuppressLint("HandlerLeak")
  13415. @Override
  13416. public void handleMessage(Message msg) {
  13417. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  13418. if (msg.what == 0) {
  13419. if (mWallPadAPI.Check_Connect())
  13420. initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13421. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13422. } else if (msg.what == 1) {
  13423. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  13424. mSdbAPI = mWallPadAPI.Get_SdbController();
  13425. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  13426. mSdb_LivingRoomLightAPI.Refresh();
  13427. }
  13428. }
  13429. };
  13430. protected Handler initKNXDistributionPanelHandler = new Handler() {
  13431. @SuppressLint("HandlerLeak")
  13432. @Override
  13433. public void handleMessage(Message msg) {
  13434. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  13435. if (msg.what == 0) {
  13436. if (mWallPadAPI.Check_Connect())
  13437. initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13438. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13439. } else if (msg.what == 1) {
  13440. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  13441. mKnxAPI = mWallPadAPI.Get_KnxController();
  13442. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  13443. mKnx_LivingRoomLightAPI.Refresh();
  13444. }
  13445. }
  13446. };
  13447. protected Handler initSmartIoTFunctionHandler = new Handler() {
  13448. @SuppressLint("HandlerLeak")
  13449. @Override
  13450. public void handleMessage(Message msg) {
  13451. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  13452. if (msg.what == 0) {
  13453. if (mWallPadAPI.Check_Connect())
  13454. initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13455. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  13456. } else if (msg.what == 1) {
  13457. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  13458. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  13459. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
  13460. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
  13461. Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
  13462. // 거동수상자 녹화를 위한 자동 On 기능 비활성화
  13463. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  13464. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  13465. }
  13466. }
  13467. };
  13468. // 스마트현관카메라 MODE 제어
  13469. private void ctrlSmartIOTCamStatusMode(byte mode) {
  13470. try {
  13471. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  13472. if (mSmartKeyRfDoorAPI != null) {
  13473. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  13474. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  13475. } else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  13476. } catch (RuntimeException re) {
  13477. LogUtil.errorLogInfo("", TAG, re);
  13478. } catch (Exception e) {
  13479. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  13480. //e.printStackTrace();
  13481. LogUtil.errorLogInfo("", TAG, e);
  13482. }
  13483. }
  13484. // 스마트현관카메라 LED 상태 제어
  13485. private void ctrlSmartIOTCamLEDMode(byte mode) {
  13486. try {
  13487. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  13488. if (mSmartKeyRfDoorAPI != null) {
  13489. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  13490. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  13491. } else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  13492. } catch (RuntimeException re) {
  13493. LogUtil.errorLogInfo("", TAG, re);
  13494. } catch (Exception e) {
  13495. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  13496. //e.printStackTrace();
  13497. LogUtil.errorLogInfo("", TAG, e);
  13498. }
  13499. }
  13500. // 현관카메라 거동수상자 감지시간
  13501. private byte getSmartDoorCamDuration() {
  13502. try {
  13503. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
  13504. byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
  13505. wallpadDeviceSet.closeDB();
  13506. Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
  13507. return duration;
  13508. } catch (RuntimeException re) {
  13509. LogUtil.errorLogInfo("", TAG, re);
  13510. } catch (Exception e) {
  13511. Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
  13512. //e.printStackTrace();
  13513. LogUtil.errorLogInfo("", TAG, e);
  13514. }
  13515. return (byte) 0x05;
  13516. }
  13517. // =================================================================================================
  13518. // [[ Thread ]] region
  13519. // =================================================================================================
  13520. /**
  13521. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  13522. * 10분에 한번씩 저장
  13523. */
  13524. @SuppressLint("UseValueOf")
  13525. class saveRealmeterData extends Thread {
  13526. @Override
  13527. public void run() {
  13528. super.run();
  13529. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  13530. int ret;
  13531. wallpaddbmgr WallpadDBMGRforThread = null;
  13532. while (true) {
  13533. try {
  13534. Thread.sleep(1000 * 60 * 3); //3분마다
  13535. if (mRealTimeMeterAPI != null) {
  13536. ret = mRealTimeMeterAPI.Refresh(false);
  13537. if (ret == 0) {
  13538. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  13539. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
  13540. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  13541. WallpadDBMGRforThread.InsertRealTimeMeterData(
  13542. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  13543. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  13544. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  13545. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  13546. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  13547. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  13548. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  13549. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  13550. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  13551. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  13552. );
  13553. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  13554. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
  13555. if (tempInt > 6000) {
  13556. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  13557. }
  13558. WallpadDBMGRforThread.closeDB();
  13559. } else {
  13560. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  13561. }
  13562. } else {
  13563. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  13564. }
  13565. } catch (InterruptedException e1) {
  13566. // TODO Auto-generated catch block
  13567. if (WallpadDBMGRforThread != null) {
  13568. WallpadDBMGRforThread.closeDB();
  13569. }
  13570. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  13571. //e1.printStackTrace();
  13572. LogUtil.errorLogInfo("", TAG, e1);
  13573. }
  13574. }
  13575. }
  13576. }
  13577. /**
  13578. * 단지서버 2.0 사용여부
  13579. *
  13580. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  13581. **/
  13582. public boolean NewServerUse() {
  13583. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  13584. if (SetData != null) {
  13585. String serverVesionInfo = SetData.GetServerVer();
  13586. SetData.closeDB();
  13587. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  13588. return true;
  13589. }
  13590. }
  13591. return false;
  13592. }
  13593. /**
  13594. * 단지서버2.0 적용시에만 사용한다.
  13595. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  13596. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  13597. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  13598. **/
  13599. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  13600. String REMOTETYPE_SVR2WEB = "danji_web_control";
  13601. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  13602. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  13603. try {
  13604. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13605. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13606. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13607. NodeList mNodeList = doc.getElementsByTagName("device_info");
  13608. Node mNode = mNodeList.item(0);
  13609. if (mNode != null) {
  13610. String alias = "null", twinid = "null";
  13611. NamedNodeMap attrsParam = mNode.getAttributes();
  13612. for (int j = 0; j < attrsParam.getLength(); j++) {
  13613. Node attr = attrsParam.item(j);
  13614. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13615. alias = attr.getNodeValue();
  13616. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13617. twinid = attr.getNodeValue();
  13618. }
  13619. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13620. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13621. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  13622. return MOBILE_USER_AUTH_PASSED;
  13623. }
  13624. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13625. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13626. mWallpadMobileDeviceData.closeDB();
  13627. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13628. else {
  13629. //Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  13630. //닫은 DB에 접근하여서 수정.
  13631. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + nCheckResult + "]");
  13632. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13633. return strReplyMsg;
  13634. }
  13635. } else {
  13636. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13637. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13638. return strReplyMsg;
  13639. }
  13640. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13641. NodeList mNodeList = doc.getElementsByTagName("password_info");
  13642. Node mNode = mNodeList.item(0);
  13643. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13644. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13645. mWallpadStatusData.closeDB();
  13646. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
  13647. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13648. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13649. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13650. return strReplyMsg;
  13651. }
  13652. if (mNode != null) {
  13653. String strReceivedPW = "000000";
  13654. NamedNodeMap attrsParam = mNode.getAttributes();
  13655. for (int j = 0; j < attrsParam.getLength(); j++) {
  13656. Node attr = attrsParam.item(j);
  13657. if (attr.getNodeName().equalsIgnoreCase("password"))
  13658. strReceivedPW = attr.getNodeValue();
  13659. }
  13660. if (!checkPWValidation(strReceivedPW)) {
  13661. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13662. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13663. return strReplyMsg;
  13664. }
  13665. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13666. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13667. return WEB_USER_AUTH_PASSED;
  13668. } else {
  13669. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13670. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13671. return strReplyMsg;
  13672. }
  13673. } else {
  13674. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13675. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13676. return strReplyMsg;
  13677. }
  13678. } else {
  13679. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13680. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13681. return strReplyMsg;
  13682. }
  13683. } catch (RuntimeException re) {
  13684. LogUtil.errorLogInfo("", TAG, re);
  13685. return null;
  13686. } catch (Exception e) {
  13687. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  13688. //e.printStackTrace();
  13689. LogUtil.errorLogInfo("", TAG, e);
  13690. return null;
  13691. }
  13692. }
  13693. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  13694. try {
  13695. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13696. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13697. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13698. NodeList mNodeList = ele.getElementsByTagName("device_info");
  13699. Node mNode = mNodeList.item(0);
  13700. if (mNode != null) {
  13701. String alias = "null", twinid = "null";
  13702. NamedNodeMap attrsParam = mNode.getAttributes();
  13703. for (int j = 0; j < attrsParam.getLength(); j++) {
  13704. Node attr = attrsParam.item(j);
  13705. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13706. alias = attr.getNodeValue();
  13707. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13708. twinid = attr.getNodeValue();
  13709. }
  13710. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13711. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13712. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  13713. return MOBILE_USER_AUTH_PASSED;
  13714. }
  13715. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13716. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13717. mWallpadMobileDeviceData.closeDB();
  13718. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13719. else {
  13720. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  13721. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  13722. return strReplyMsg;
  13723. }
  13724. } else {
  13725. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13726. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13727. return strReplyMsg;
  13728. }
  13729. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13730. NodeList mNodeList = ele.getElementsByTagName("password_info");
  13731. Node mNode = mNodeList.item(0);
  13732. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13733. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13734. mWallpadStatusData.closeDB();
  13735. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13736. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13737. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13738. return strReplyMsg;
  13739. }
  13740. if (mNode != null) {
  13741. String strReceivedPW = "000000";
  13742. NamedNodeMap attrsParam = mNode.getAttributes();
  13743. for (int j = 0; j < attrsParam.getLength(); j++) {
  13744. Node attr = attrsParam.item(j);
  13745. if (attr.getNodeName().equalsIgnoreCase("password"))
  13746. strReceivedPW = attr.getNodeValue();
  13747. }
  13748. if (!checkPWValidation(strReceivedPW)) {
  13749. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13750. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13751. return strReplyMsg;
  13752. }
  13753. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13754. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13755. return WEB_USER_AUTH_PASSED;
  13756. } else {
  13757. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13758. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13759. return strReplyMsg;
  13760. }
  13761. } else {
  13762. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13763. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13764. return strReplyMsg;
  13765. }
  13766. } else {
  13767. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13768. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13769. return strReplyMsg;
  13770. }
  13771. } catch (RuntimeException re) {
  13772. LogUtil.errorLogInfo("", TAG, re);
  13773. return null;
  13774. } catch (Exception e) {
  13775. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  13776. //e.printStackTrace();
  13777. LogUtil.errorLogInfo("", TAG, e);
  13778. return null;
  13779. }
  13780. }
  13781. String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
  13782. private boolean checkPWValidation(String strPW) {
  13783. try {
  13784. // null 확인
  13785. if (strPW == null) {
  13786. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  13787. return false;
  13788. }
  13789. // 입력된 비밀번호 길이 확인
  13790. if (strPW.length() != 6) {
  13791. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  13792. return false;
  13793. }
  13794. // 사전 금지된 비밀번호 확인
  13795. for (int i = 0; i < astrPreventedPWs.length; i++) {
  13796. if (strPW.contains(astrPreventedPWs[i])) {
  13797. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  13798. return false;
  13799. }
  13800. }
  13801. /*// 연속된 비밀번호 확인
  13802. int nSerialNoCnt = 0;
  13803. int nCompareNo = 0;
  13804. int[] naPW = new int[strPW.length()];
  13805. for (int i = 0; i < naPW.length; i++)
  13806. {
  13807. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  13808. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  13809. if (i ==0) {
  13810. nCompareNo = naPW[i];
  13811. nCompareNo++;
  13812. }
  13813. else if (0 < i && i < 6) {
  13814. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  13815. nCompareNo++;
  13816. }
  13817. else {
  13818. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  13819. }
  13820. }
  13821. if (nSerialNoCnt > 3) {
  13822. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  13823. return false;
  13824. }*/
  13825. // 동일한 번호 5회이상 입력 확인
  13826. int nSameNoCnt = 0;
  13827. for (int i = 0; i < strPW.length() - 1; i++) {
  13828. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  13829. nSameNoCnt++;
  13830. }
  13831. }
  13832. if (nSameNoCnt > 4) {
  13833. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  13834. return false;
  13835. }
  13836. // 동, 호정보 확인
  13837. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  13838. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  13839. DBMGR.closeDB();
  13840. String strDong = addr.Dong;
  13841. String strHo = addr.Ho;
  13842. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  13843. if (strPW.substring(0, 4).contains(strDong)) {
  13844. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  13845. return false;
  13846. }
  13847. if (strPW.substring(0, 4).contains(strHo)) {
  13848. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  13849. return false;
  13850. }
  13851. return true;
  13852. } catch (RuntimeException re) {
  13853. LogUtil.errorLogInfo("", TAG, re);
  13854. return false;
  13855. } catch (Exception e) {
  13856. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  13857. //e.printStackTrace();
  13858. LogUtil.errorLogInfo("", TAG, e);
  13859. return false;
  13860. }
  13861. }
  13862. public String iCMDProcOnePass(Element ele) {
  13863. String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
  13864. String[] strDeviceInfo = {"null", "null"}; // alias, twinid
  13865. String strAction = "null", strTargetLobbyIP = "null";
  13866. try {
  13867. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  13868. String retStr = CheckiCMDProc("remote_access_onepass");
  13869. if (retStr != null)
  13870. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13871. // 단지서버 2.0 사용여부 확인
  13872. if (!NewServerUse()) {
  13873. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13874. }
  13875. // 메시지 송신지 구분
  13876. NodeList items = ele.getElementsByTagName("target");
  13877. Node item = items.item(0);
  13878. if (item != null) {
  13879. NamedNodeMap attrs = item.getAttributes();
  13880. for (int j = 0; j < attrs.getLength(); j++) {
  13881. Node attr = attrs.item(j);
  13882. if (attr.getNodeName().equalsIgnoreCase("name"))
  13883. strTarget[0] = attr.getNodeValue();
  13884. else if (attr.getNodeName().equalsIgnoreCase("id"))
  13885. strTarget[1] = attr.getNodeValue();
  13886. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  13887. strTarget[2] = attr.getNodeValue();
  13888. }
  13889. }
  13890. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  13891. if (NewServerUse()) {
  13892. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  13893. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  13894. if (ServerCheckResult.contains("fail"))
  13895. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13896. else if (ServerCheckResult.contains("deny"))
  13897. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13898. else if (ServerCheckResult.contains("none"))
  13899. return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  13900. else
  13901. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13902. }
  13903. }
  13904. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  13905. Node itemDeviceParam = itemsDeviceParam.item(0);
  13906. if (itemDeviceParam != null) {
  13907. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  13908. for (int j = 0; j < attrsParam.getLength(); j++) {
  13909. Node attr = attrsParam.item(j);
  13910. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13911. strDeviceInfo[0] = attr.getNodeValue();
  13912. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13913. strDeviceInfo[1] = attr.getNodeValue();
  13914. }
  13915. } else {
  13916. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13917. }
  13918. // 명령어 구분
  13919. NodeList itemsaction = ele.getElementsByTagName("action");
  13920. Node itemaction = itemsaction.item(0);
  13921. Node text = itemaction.getFirstChild();
  13922. strAction = text.getNodeValue();
  13923. strAction = trimquotation(strAction);
  13924. // 문열림 타겟 로비폰 IP
  13925. NodeList itemsParam = ele.getElementsByTagName("params");
  13926. Node itemParam = itemsParam.item(0);
  13927. if (itemParam != null) {
  13928. NamedNodeMap attrsParam = itemParam.getAttributes();
  13929. for (int j = 0; j < attrsParam.getLength(); j++) {
  13930. Node attr = attrsParam.item(j);
  13931. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  13932. strTargetLobbyIP = attr.getNodeValue();
  13933. }
  13934. }
  13935. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  13936. if (strAction.equalsIgnoreCase("authorize_request")) {
  13937. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  13938. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  13939. } else {
  13940. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13941. }
  13942. } catch (RuntimeException re) {
  13943. LogUtil.errorLogInfo("", TAG, re);
  13944. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13945. } catch (Exception e) {
  13946. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  13947. //e.printStackTrace();
  13948. LogUtil.errorLogInfo("", TAG, e);
  13949. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13950. }
  13951. }
  13952. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  13953. try {
  13954. String strReplyXml = XMLHeader;
  13955. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  13956. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  13957. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  13958. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  13959. strReplyXml += " </service>\n";
  13960. strReplyXml += "</imap>";
  13961. return strReplyXml;
  13962. } catch (RuntimeException re) {
  13963. LogUtil.errorLogInfo("", TAG, re);
  13964. return "ERROR";
  13965. } catch (Exception e) {
  13966. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  13967. //e.printStackTrace();
  13968. LogUtil.errorLogInfo("", TAG, e);
  13969. return "ERROR";
  13970. }
  13971. }
  13972. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  13973. try {
  13974. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
  13975. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  13976. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  13977. miMAPLobbyOnePass.SetRetCtr(new RetProci() {
  13978. @Override
  13979. public void ProcSuccess() {
  13980. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  13981. }
  13982. @Override
  13983. public void ProcError() {
  13984. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  13985. }
  13986. @Override
  13987. public void ProcDoing() {
  13988. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  13989. }
  13990. });
  13991. } catch (RuntimeException re) {
  13992. LogUtil.errorLogInfo("", TAG, re);
  13993. } catch (Exception e) {
  13994. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  13995. //e.printStackTrace();
  13996. LogUtil.errorLogInfo("", TAG, e);
  13997. }
  13998. }
  13999. public String iCMDProcResidentSafety(Element ele) {
  14000. try {
  14001. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  14002. String retStr = CheckiCMDProc("check_resident_safety");
  14003. if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
  14004. // 단지서버 2.0 사용여부 확인
  14005. if (!NewServerUse()) {
  14006. return makeReply_check_resident_safety("deny", null, null, null);
  14007. }
  14008. // 거주자 안전 확인 사용 여부
  14009. if (!bEnableResidentSafetyCheck) {
  14010. return makeReply_check_resident_safety("deny", null, null, null);
  14011. }
  14012. String strSecurity = getSecurityMode();
  14013. String strTouch = getTimeStamp_ScreenTouched();
  14014. String strMagnetic = getTimeStamp_Magnetic();
  14015. return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
  14016. } catch (RuntimeException re) {
  14017. LogUtil.errorLogInfo("", TAG, re);
  14018. return makeReply_check_resident_safety("fail", null, null, null);
  14019. } catch (Exception e) {
  14020. Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
  14021. //e.printStackTrace();
  14022. LogUtil.errorLogInfo("", TAG, e);
  14023. return makeReply_check_resident_safety("fail", null, null, null);
  14024. }
  14025. }
  14026. public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
  14027. try {
  14028. String strReplyXml = XMLHeader;
  14029. strReplyXml += " <service type=\"reply\" name=\"check_resident_safety\" result=\"" + strResult + "\">\n";
  14030. if (strResult.equalsIgnoreCase("ok")) {
  14031. strReplyXml += " <security>\"" + strSecurity + "\"</security>\n";
  14032. strReplyXml += " <touch>\"" + strTouch + "\"</touch>\n";
  14033. strReplyXml += " <magnetic>\"" + magnetic + "\"</magnetic>\n";
  14034. }
  14035. strReplyXml += " <message>\"null\"</message>\n";
  14036. strReplyXml += " </service>\n";
  14037. strReplyXml += "</imap>";
  14038. return strReplyXml;
  14039. } catch (RuntimeException re) {
  14040. LogUtil.errorLogInfo("", TAG, re);
  14041. return "ERROR";
  14042. } catch (Exception e) {
  14043. Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
  14044. //e.printStackTrace();
  14045. LogUtil.errorLogInfo("", TAG, e);
  14046. return "ERROR";
  14047. }
  14048. }
  14049. private void saveBlackoutStatus(boolean bOccurred) {
  14050. try {
  14051. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  14052. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14053. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14054. mEditor.putBoolean("status", bOccurred);
  14055. mEditor.commit();
  14056. } catch (RuntimeException re) {
  14057. LogUtil.errorLogInfo("", TAG, re);
  14058. } catch (Exception e) {
  14059. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  14060. //e.printStackTrace();
  14061. LogUtil.errorLogInfo("", TAG, e);
  14062. }
  14063. }
  14064. private boolean getBlackoutStatus() {
  14065. try {
  14066. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14067. return mSharedPreferences.getBoolean("status", false);
  14068. } catch (RuntimeException re) {
  14069. LogUtil.errorLogInfo("", TAG, re);
  14070. return false;
  14071. } catch (Exception e) {
  14072. Log.e(TAG, "[Exception] getBlackoutStatus()");
  14073. //e.printStackTrace();
  14074. LogUtil.errorLogInfo("", TAG, e);
  14075. return false;
  14076. }
  14077. }
  14078. /**
  14079. * JEFF, 2019.12.25
  14080. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  14081. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  14082. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  14083. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  14084. */
  14085. int MAX_WALLPADCALL_LIVE_CNT = 1;
  14086. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  14087. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  14088. public static boolean m_bWallpadCallScreen = false;
  14089. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  14090. Handler handlerCheckWallPadCallLive = new Handler() {
  14091. public void handleMessage(Message msg) {
  14092. super.handleMessage(msg);
  14093. sendWallPadCallLiveBR_Request();
  14094. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  14095. }
  14096. };
  14097. private void sendWallPadCallLiveBR_Request() {
  14098. try {
  14099. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  14100. Intent mIntent = new Intent();
  14101. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  14102. getApplicationContext().sendBroadcast(mIntent);
  14103. if (nWallPadCallACKCnt >= 0) {
  14104. nWallPadCallACKCnt--;
  14105. } else {
  14106. bWallPadCallLive = false;
  14107. Common.bWallPadCallLive = bWallPadCallLive;
  14108. }
  14109. if (bWallPadCallLive != getCallAppRunning()) {
  14110. setCallAppRunning(bWallPadCallLive);
  14111. }
  14112. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14113. } catch (RuntimeException re) {
  14114. LogUtil.errorLogInfo("", TAG, re);
  14115. } catch (Exception e) {
  14116. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  14117. //e.printStackTrace();
  14118. LogUtil.errorLogInfo("", TAG, e);
  14119. }
  14120. }
  14121. public boolean getWallpadCallScrean(int iScreen)
  14122. {
  14123. boolean bRet = false;
  14124. try {
  14125. switch (iScreen) {
  14126. case API_Menu.SubMenuCall.Door:
  14127. bRet = false;
  14128. break;
  14129. case API_Menu.SubMenuCall.Lobby:
  14130. bRet = false;
  14131. break;
  14132. case API_Menu.SubMenuCall.Guard:
  14133. bRet = false;
  14134. break;
  14135. case API_Menu.SubMenuCall.Neighbor:
  14136. bRet = false;
  14137. break;
  14138. case API_Menu.SubMenuCall.PSTN:
  14139. bRet = false;
  14140. break;
  14141. case API_Menu.SubMenuCall.CallList:
  14142. bRet = true;
  14143. break;
  14144. case API_Menu.SubMenuCall.Visitor:
  14145. bRet = true;
  14146. break;
  14147. default:
  14148. bRet = false;
  14149. break;
  14150. }
  14151. } catch (RuntimeException re) {
  14152. LogUtil.errorLogInfo("", TAG, re);
  14153. return false;
  14154. } catch (Exception e) {
  14155. Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
  14156. //e.printStackTrace();
  14157. LogUtil.errorLogInfo("", TAG, e);
  14158. return false;
  14159. }
  14160. return bRet;
  14161. }
  14162. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  14163. @Override
  14164. public void onReceive(Context context, Intent intent) {
  14165. try {
  14166. String strActionName = intent.getAction();
  14167. int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
  14168. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  14169. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  14170. bWallPadCallLive = true;
  14171. Common.bWallPadCallLive = bWallPadCallLive;
  14172. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  14173. m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
  14174. Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
  14175. } else {
  14176. Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  14177. }
  14178. } catch (RuntimeException re) {
  14179. LogUtil.errorLogInfo("", TAG, re);
  14180. } catch (Exception e) {
  14181. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  14182. //e.printStackTrace();
  14183. LogUtil.errorLogInfo("", TAG, e);
  14184. }
  14185. }
  14186. };
  14187. static class CALLCTRLHANDLERMSG {
  14188. static final int RELEASE_BLOCK_FRONTCALL = 100;
  14189. }
  14190. boolean bBlockFrontCall = false;
  14191. Handler handlerCallCtrl = new Handler() {
  14192. public void handleMessage(Message msg) {
  14193. super.handleMessage(msg);
  14194. int nMSG = msg.what;
  14195. switch (nMSG) {
  14196. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  14197. bBlockFrontCall = false;
  14198. break;
  14199. }
  14200. }
  14201. };
  14202. /**
  14203. * JEFF, 2019.12.31
  14204. * WallPadCall 실행여부를 DB에 저장한다.
  14205. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  14206. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  14207. */
  14208. public void setCallAppRunning(boolean bRunning) {
  14209. try {
  14210. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14211. mWallpadStatusData.SetCallAPKStatus(bRunning);
  14212. mWallpadStatusData.closeDB();
  14213. } catch (RuntimeException re) {
  14214. LogUtil.errorLogInfo("", TAG, re);
  14215. } catch (Exception e) {
  14216. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  14217. //e.printStackTrace();
  14218. LogUtil.errorLogInfo("", TAG, e);
  14219. }
  14220. }
  14221. private boolean getCallAppRunning() {
  14222. boolean bRunning = false;
  14223. try {
  14224. WallpadStatusData WallpadStatusData = new WallpadStatusData(getApplicationContext());
  14225. bRunning = WallpadStatusData.GetCallAPKStatusRunning();
  14226. WallpadStatusData.closeDB();
  14227. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  14228. return bRunning;
  14229. } catch (RuntimeException re) {
  14230. LogUtil.errorLogInfo("", TAG, re);
  14231. return false;
  14232. } catch (Exception e) {
  14233. Log.d(TAG, "[Exception] getCallAppRunning()");
  14234. //e.printStackTrace();
  14235. LogUtil.errorLogInfo("", TAG, e);
  14236. return false;
  14237. }
  14238. }
  14239. /**
  14240. * 통화앱 종료코드
  14241. */
  14242. public void killWallPadCall() {
  14243. try {
  14244. Log.i(TAG, "[killWallPadCall] ===== START =====");
  14245. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  14246. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14247. Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  14248. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  14249. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14250. // android.os.Process.killProcess(nWallPadCallPID);
  14251. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  14252. // if(list != null){
  14253. // for(int i=0;i<list.size();++i){
  14254. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  14255. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14256. // android.os.Process.killProcess(pid);
  14257. // }
  14258. // }
  14259. // }
  14260. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  14261. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14262. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  14263. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14264. // android.os.Process.killProcess(pid);
  14265. } catch (RuntimeException re) {
  14266. LogUtil.errorLogInfo("", TAG, re);
  14267. } catch (Exception e) {
  14268. Log.e(TAG, "[Exception] killWallPadCall()");
  14269. //e.printStackTrace();
  14270. LogUtil.errorLogInfo("", TAG, e);
  14271. }
  14272. }
  14273. private void checkForegroundActivity() {
  14274. try {
  14275. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  14276. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  14277. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  14278. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  14279. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  14280. } catch (RuntimeException re) {
  14281. LogUtil.errorLogInfo("", TAG, re);
  14282. } catch (Exception e) {
  14283. Log.e(TAG, "[Exception] checkForegroundActivity()");
  14284. //e.printStackTrace();
  14285. LogUtil.errorLogInfo("", TAG, e);
  14286. }
  14287. }
  14288. /**
  14289. * JEFF, 2020.01.04
  14290. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  14291. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  14292. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  14293. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  14294. */
  14295. static long lConnectionPeriod = 0;
  14296. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  14297. boolean bRingGeneratorRun = false;
  14298. private void startIGW300RingGenerator() {
  14299. try {
  14300. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14301. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  14302. bRingGeneratorRun = true;
  14303. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  14304. mIGW300RingGeneratorThread.start();
  14305. } else
  14306. Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  14307. } catch (RuntimeException re) {
  14308. LogUtil.errorLogInfo("", TAG, re);
  14309. } catch (Exception e) {
  14310. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  14311. //e.printStackTrace();
  14312. LogUtil.errorLogInfo("", TAG, e);
  14313. }
  14314. }
  14315. private void stopIGW300RingGenerator() {
  14316. try {
  14317. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14318. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  14319. lConnectionPeriod = -999;
  14320. bRingGeneratorRun = false;
  14321. mIGW300RingGeneratorThread = null;
  14322. } else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  14323. } catch (RuntimeException re) {
  14324. LogUtil.errorLogInfo("", TAG, re);
  14325. } catch (Exception e) {
  14326. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  14327. //e.printStackTrace();
  14328. LogUtil.errorLogInfo("", TAG, e);
  14329. }
  14330. }
  14331. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  14332. private class IGW300RingGeneratorThread extends Thread {
  14333. public IGW300RingGeneratorThread() {
  14334. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  14335. }
  14336. public void run() {
  14337. try {
  14338. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14339. if (bRingGeneratorRun)
  14340. Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  14341. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  14342. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  14343. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  14344. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  14345. try {
  14346. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  14347. } catch (InterruptedException e) {
  14348. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  14349. //e.printStackTrace();
  14350. LogUtil.errorLogInfo("", TAG, e);
  14351. }
  14352. }
  14353. bRingGeneratorRun = false;
  14354. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  14355. } catch (RuntimeException re) {
  14356. LogUtil.errorLogInfo("", TAG, re);
  14357. } catch (Exception e) {
  14358. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  14359. //e.printStackTrace();
  14360. LogUtil.errorLogInfo("", TAG, e);
  14361. }
  14362. }
  14363. }
  14364. private void sendPSTNRingEvent(int nKeyCode) {
  14365. try {
  14366. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  14367. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  14368. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  14369. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  14370. intent.putExtra("keycode", nKeyCode);
  14371. getApplicationContext().sendBroadcast(intent);
  14372. } catch (RuntimeException re) {
  14373. LogUtil.errorLogInfo("", TAG, re);
  14374. } catch (Exception e) {
  14375. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  14376. //e.printStackTrace();
  14377. LogUtil.errorLogInfo("", TAG, e);
  14378. }
  14379. }
  14380. /**
  14381. * 월패드 타입 판별
  14382. *
  14383. * @return bResult
  14384. * false: 메인월패드
  14385. * true: 서브월패드
  14386. */
  14387. public boolean getIsSubWallpad() {
  14388. boolean bResult = false;
  14389. try {
  14390. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14391. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  14392. mWallpadDeviceSet.closeDB();
  14393. if (DBinfo != null) {
  14394. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  14395. else bResult = false;
  14396. }
  14397. } catch (RuntimeException re) {
  14398. LogUtil.errorLogInfo("", TAG, re);
  14399. } catch (Exception e) {
  14400. Log.e(TAG, "[Exception] getIsSubWallpad()");
  14401. //e.printStackTrace();
  14402. LogUtil.errorLogInfo("", TAG, e);
  14403. }
  14404. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  14405. return bResult;
  14406. }
  14407. /**
  14408. * JEFF, 2020.02.05
  14409. * 월패드 비상접점 신호 사용 여부 확인
  14410. */
  14411. public boolean getEmergencyIOUsage() {
  14412. boolean bResult = false;
  14413. try {
  14414. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14415. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  14416. mWallpadDeviceSet.closeDB();
  14417. } catch (RuntimeException re) {
  14418. LogUtil.errorLogInfo("", TAG, re);
  14419. } catch (Exception e) {
  14420. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  14421. //e.printStackTrace();
  14422. LogUtil.errorLogInfo("", TAG, e);
  14423. }
  14424. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  14425. return bResult;
  14426. }
  14427. /**
  14428. * JEFF, 2020.02.05
  14429. * 거동수상자 녹화기능 활성화 확인
  14430. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  14431. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  14432. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  14433. */
  14434. public boolean getStrangerRecordingManagerSetting() {
  14435. boolean bResult = false;
  14436. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14437. try {
  14438. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14439. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  14440. mWallpadDeviceSet.closeDB();
  14441. if (nFrontCam[0] == COMPONENT_USE) {
  14442. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  14443. if (bRecord) bResult = true;
  14444. else bResult = false;
  14445. } else bResult = false;
  14446. } else bResult = false;
  14447. } catch (RuntimeException re) {
  14448. LogUtil.errorLogInfo("", TAG, re);
  14449. mWallpadDeviceSet.closeDB();
  14450. } catch (Exception e) {
  14451. mWallpadDeviceSet.closeDB();
  14452. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  14453. //e.printStackTrace();
  14454. LogUtil.errorLogInfo("", TAG, e);
  14455. }
  14456. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  14457. return bResult;
  14458. }
  14459. /**
  14460. * Edited by jeff (2020.06.22)
  14461. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  14462. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  14463. *
  14464. * @param bOn
  14465. */
  14466. private void sendLCDBacklightStatus(boolean bOn) {
  14467. try {
  14468. Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
  14469. Intent mIntent = new Intent();
  14470. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  14471. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  14472. getApplicationContext().sendBroadcast(mIntent);
  14473. } catch (RuntimeException re) {
  14474. LogUtil.errorLogInfo("", TAG, re);
  14475. } catch (Exception e) {
  14476. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  14477. //e.printStackTrace();
  14478. LogUtil.errorLogInfo("", TAG, e);
  14479. }
  14480. }
  14481. // 명칭 관련
  14482. boolean bRoomNameLog = true;
  14483. public static final int HEATING = 1;
  14484. public static final int LIGHT = 2;
  14485. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  14486. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14487. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  14488. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
  14489. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14490. /**
  14491. * DB 에서 룸이름 정보를 가져온다.
  14492. *
  14493. * @return (String []) null - 실패, not null
  14494. */
  14495. private String[] getDBRoomName() {
  14496. try {
  14497. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14498. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  14499. wallpadStatusData.closeDB();
  14500. if (strRoomNameList == null) {
  14501. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  14502. return null;
  14503. }
  14504. if (bRoomNameLog) {
  14505. for (int i = 0; i < strRoomNameList.length; i++)
  14506. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14507. }
  14508. return strRoomNameList;
  14509. } catch (RuntimeException re) {
  14510. LogUtil.errorLogInfo("", TAG, re);
  14511. } catch (Exception e) {
  14512. Log.e(TAG, "[Exception] getDBRoomName()");
  14513. //e.printStackTrace();
  14514. LogUtil.errorLogInfo("", TAG, e);
  14515. }
  14516. return null;
  14517. }
  14518. /**
  14519. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  14520. *
  14521. * @param nDeviceType - int
  14522. * @return (String []) null - 실패, not null
  14523. */
  14524. private String[] getDBRoomName(int nDeviceType) {
  14525. try {
  14526. String[] strRoomNameList = null;
  14527. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14528. if (nDeviceType == HEATING) {
  14529. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  14530. } else {
  14531. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  14532. }
  14533. wallpadStatusData.closeDB();
  14534. if (strRoomNameList == null) {
  14535. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  14536. return null;
  14537. }
  14538. if (bRoomNameLog) {
  14539. for (int i = 0; i < strRoomNameList.length; i++)
  14540. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14541. }
  14542. return strRoomNameList;
  14543. } catch (RuntimeException re) {
  14544. LogUtil.errorLogInfo("", TAG, re);
  14545. } catch (Exception e) {
  14546. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  14547. //e.printStackTrace();
  14548. LogUtil.errorLogInfo("", TAG, e);
  14549. }
  14550. return null;
  14551. }
  14552. /**
  14553. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  14554. **/
  14555. private void getRoomName() {
  14556. try {
  14557. Log.i(TAG, "[getRoomName] ====================");
  14558. } catch (RuntimeException re) {
  14559. LogUtil.errorLogInfo("", TAG, re);
  14560. } catch (Exception e) {
  14561. Log.e(TAG, "[Exception] getRoomName()");
  14562. //e.printStackTrace();
  14563. LogUtil.errorLogInfo("", TAG, e);
  14564. }
  14565. }
  14566. public boolean getEasyModeUXUsage() {
  14567. try {
  14568. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  14569. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  14570. deviceSet.closeDB();
  14571. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  14572. boolean bUse = data.GetEasyModeUxUse();
  14573. data.closeDB();
  14574. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  14575. return bSupport & bUse;
  14576. } catch (RuntimeException re) {
  14577. LogUtil.errorLogInfo("", TAG, re);
  14578. } catch (Exception e) {
  14579. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  14580. //e.printStackTrace();
  14581. LogUtil.errorLogInfo("", TAG, e);
  14582. }
  14583. return false;
  14584. }
  14585. /**
  14586. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  14587. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  14588. * 재설정 5초 후 월패드 재부팅을 실행한다.
  14589. * 2020.11.18 SEULKI
  14590. */
  14591. public void checkDoorCamConfig() {
  14592. try {
  14593. if (Build.VERSION.SDK_INT > 23) {
  14594. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  14595. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  14596. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  14597. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  14598. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  14599. if (!checkAvailableBSPDoorCamConfig()) {
  14600. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  14601. return;
  14602. }
  14603. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  14604. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  14605. if (mIOInterface != null)
  14606. mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  14607. // 재부팅
  14608. setDefaultLauncher();
  14609. Intent intent = new Intent();
  14610. if (intent != null) {
  14611. intent.setAction(define.NOTIFY_ACNAME);
  14612. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  14613. getApplicationContext().sendBroadcast(intent);
  14614. }
  14615. }
  14616. }
  14617. }
  14618. } catch (RuntimeException re) {
  14619. LogUtil.errorLogInfo("", "", re);
  14620. } catch (Exception e) {
  14621. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  14622. LogUtil.errorLogInfo("", "", e);
  14623. }
  14624. }
  14625. /**
  14626. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  14627. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  14628. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  14629. *
  14630. * @return true: 지원, false: 미지원
  14631. */
  14632. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  14633. private boolean checkAvailableBSPDoorCamConfig() {
  14634. try {
  14635. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  14636. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  14637. if (nCurrentVer >= nCriterionVer) {
  14638. return true;
  14639. } else return false;
  14640. } catch (RuntimeException re) {
  14641. LogUtil.errorLogInfo("", TAG, re);
  14642. return false;
  14643. } catch (Exception e) {
  14644. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  14645. //e.printStackTrace();
  14646. LogUtil.errorLogInfo("", TAG, e);
  14647. return false;
  14648. }
  14649. }
  14650. /**
  14651. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14652. *
  14653. * @return 0 - 스마트현관카메라
  14654. * 2 - 스마트현관카메라 좌우반전
  14655. * 1 - 일반현관카메라
  14656. * 2020.11.18 SEULKI
  14657. */
  14658. public int getBSPDoorCamConfig() {
  14659. InputStreamReader is = null;
  14660. try {
  14661. Runtime mRuntime = Runtime.getRuntime();
  14662. String cmd = "getprop camera.setting.value";
  14663. if (mRuntime != null) {
  14664. Process mProcess = mRuntime.exec(cmd);
  14665. is = new InputStreamReader(mProcess.getInputStream());
  14666. BufferedReader br = new BufferedReader(is);
  14667. String line;
  14668. String strResult = null;
  14669. if (br != null) {
  14670. while ((line = br.readLine()) != null) {
  14671. strResult = line;
  14672. }
  14673. if (strResult != null) {
  14674. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  14675. if (strResult.equals("0")) {
  14676. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  14677. return 0;
  14678. } else if (strResult.equals("1")) {
  14679. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  14680. return 1;
  14681. } else if (strResult.equals("2")) {
  14682. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  14683. return 2;
  14684. } else {
  14685. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  14686. return -1;
  14687. }
  14688. }
  14689. }
  14690. }
  14691. return -1;
  14692. } catch (Exception e) {
  14693. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  14694. e.printStackTrace();
  14695. return -1;
  14696. } finally {
  14697. if (is != null) {
  14698. try {
  14699. is.close();
  14700. } catch (IOException e) {
  14701. LogUtil.errorLogInfo("", TAG, e);
  14702. }
  14703. is = null;
  14704. }
  14705. }
  14706. }
  14707. /**
  14708. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14709. *
  14710. * @return 0 - 스마트현관카메라
  14711. * 2 - 스마트현관카메라 좌우반전
  14712. * 1 - 일반현관카메라
  14713. * 2020.11.18 SEULKI
  14714. */
  14715. public int getDBDoorCamConfig() {
  14716. try {
  14717. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14718. if (mWallpadDeviceSet != null) {
  14719. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14720. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  14721. mWallpadDeviceSet.closeDB();
  14722. if (nType != null) {
  14723. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  14724. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
  14725. // Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14726. if (bFlip) {
  14727. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14728. return 0;
  14729. } else {
  14730. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
  14731. return 2;
  14732. }
  14733. } else {
  14734. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  14735. return 1;
  14736. }
  14737. }
  14738. }
  14739. return -1;
  14740. } catch (Exception e) {
  14741. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  14742. e.printStackTrace();
  14743. return -1;
  14744. }
  14745. }
  14746. /**
  14747. * 공기질 센서 사용여부 확인
  14748. *
  14749. * @return true - 사용함, false: 사용안함
  14750. */
  14751. boolean bAirQualityEnable = false;
  14752. private boolean getAirQualityUsage() {
  14753. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14754. try {
  14755. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  14756. mWallpadDeviceSet.closeDB();
  14757. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  14758. bAirQualityEnable = true;
  14759. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14760. } else {
  14761. bAirQualityEnable = false;
  14762. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14763. }
  14764. return bAirQualityEnable;
  14765. } catch (RuntimeException re) {
  14766. LogUtil.errorLogInfo("", TAG, re);
  14767. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14768. return false;
  14769. } catch (Exception e) {
  14770. Log.e(TAG, "[Exception] getAirQualityUsage()");
  14771. //e.printStackTrace();
  14772. LogUtil.errorLogInfo("", TAG, e);
  14773. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14774. return false;
  14775. }
  14776. }
  14777. String strAirQualityFWVer = "";
  14778. String strAirQualityProtocolVer = "";
  14779. String strAirQualityInfo = "";
  14780. private String getAirQualityInfo() {
  14781. try {
  14782. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  14783. if (mAirQualitySensorAPI != null) {
  14784. int nRet = mAirQualitySensorAPI.Refresh(false);
  14785. if (nRet >= 0) {
  14786. Log.i(TAG, "[getAirQualityInfo] ");
  14787. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  14788. strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  14789. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  14790. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  14791. return strAirQualityInfo;
  14792. } else return "FAIL";
  14793. } else return "NULL";
  14794. } catch (RuntimeException re) {
  14795. LogUtil.errorLogInfo("", TAG, re);
  14796. return "ERROR";
  14797. } catch (Exception e) {
  14798. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14799. //e.printStackTrace();
  14800. LogUtil.errorLogInfo("", TAG, e);
  14801. return "ERROR";
  14802. }
  14803. }
  14804. private String getAOSVerCode() {
  14805. try {
  14806. int nOSVer = Build.VERSION.SDK_INT;
  14807. switch (nOSVer) {
  14808. case Build.VERSION_CODES.BASE:
  14809. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  14810. case Build.VERSION_CODES.BASE_1_1:
  14811. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  14812. case Build.VERSION_CODES.CUPCAKE:
  14813. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  14814. case Build.VERSION_CODES.DONUT:
  14815. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  14816. case Build.VERSION_CODES.ECLAIR:
  14817. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  14818. case Build.VERSION_CODES.ECLAIR_0_1:
  14819. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  14820. case Build.VERSION_CODES.ECLAIR_MR1:
  14821. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  14822. case Build.VERSION_CODES.FROYO:
  14823. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  14824. case Build.VERSION_CODES.GINGERBREAD:
  14825. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  14826. case Build.VERSION_CODES.GINGERBREAD_MR1:
  14827. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  14828. case Build.VERSION_CODES.HONEYCOMB:
  14829. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  14830. case Build.VERSION_CODES.HONEYCOMB_MR1:
  14831. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  14832. case Build.VERSION_CODES.HONEYCOMB_MR2:
  14833. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  14834. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  14835. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  14836. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  14837. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  14838. case Build.VERSION_CODES.JELLY_BEAN:
  14839. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  14840. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  14841. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  14842. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  14843. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  14844. case Build.VERSION_CODES.KITKAT:
  14845. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  14846. case Build.VERSION_CODES.KITKAT_WATCH:
  14847. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  14848. case Build.VERSION_CODES.LOLLIPOP:
  14849. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  14850. case Build.VERSION_CODES.LOLLIPOP_MR1:
  14851. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  14852. case Build.VERSION_CODES.M:
  14853. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  14854. case Build.VERSION_CODES.N:
  14855. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  14856. case Build.VERSION_CODES.N_MR1:
  14857. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  14858. case Build.VERSION_CODES.O:
  14859. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  14860. case Build.VERSION_CODES.O_MR1:
  14861. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  14862. case Build.VERSION_CODES.P:
  14863. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  14864. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  14865. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  14866. default:
  14867. return "SDK(" + nOSVer + ")/UNKNOWN";
  14868. }
  14869. } catch (RuntimeException re) {
  14870. LogUtil.errorLogInfo("", TAG, re);
  14871. return "ERROR";
  14872. } catch (Exception e) {
  14873. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14874. //e.printStackTrace();
  14875. LogUtil.errorLogInfo("", TAG, e);
  14876. return "ERROR";
  14877. }
  14878. }
  14879. /**
  14880. * 조명 ON/OFF 상태
  14881. */
  14882. public static class LIGHT_ONOFF {
  14883. /**
  14884. * ON
  14885. */
  14886. public static byte ON = (byte) 0x01;
  14887. /**
  14888. * OFF
  14889. */
  14890. public static byte OFF = (byte) 0x02;
  14891. /**
  14892. * OFF
  14893. */
  14894. public static byte DONTCARE = (byte) 0xFF;
  14895. }
  14896. private byte convertSmartLightPowerValue(String cmd) {
  14897. try {
  14898. if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
  14899. else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
  14900. else return LIGHT_ONOFF.DONTCARE;
  14901. } catch (RuntimeException re) {
  14902. LogUtil.errorLogInfo("", TAG, re);
  14903. return -1;
  14904. } catch (Exception e) {
  14905. Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
  14906. //e.printStackTrace();
  14907. LogUtil.errorLogInfo("", TAG, e);
  14908. return -1;
  14909. }
  14910. }
  14911. /** 거주자 안정 확인 서비스용 코드 시작 */
  14912. /**
  14913. * Edited by Jeff, 2021.06.15
  14914. */
  14915. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  14916. public boolean bEnableResidentSafetyCheck = false;
  14917. private void getResidentSafetyCheckSetting() {
  14918. try {
  14919. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14920. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  14921. mWallpadDeviceSet.closeDB();
  14922. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  14923. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
  14924. bEnableResidentSafetyCheck = true;
  14925. else bEnableResidentSafetyCheck = false;
  14926. } catch (RuntimeException re) {
  14927. LogUtil.errorLogInfo("", TAG, re);
  14928. } catch (Exception e) {
  14929. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  14930. //e.printStackTrace();
  14931. LogUtil.errorLogInfo("", TAG, e);
  14932. }
  14933. }
  14934. private String getSecurityMode() {
  14935. try {
  14936. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14937. int nStatus = mWallpadStatusData.GetAlarmStatus();
  14938. mWallpadStatusData.closeDB();
  14939. String strSecurity = "null";
  14940. if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
  14941. else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
  14942. else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
  14943. else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
  14944. else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
  14945. else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
  14946. return strSecurity;
  14947. } catch (Exception e) {
  14948. Log.e(TAG, "[Exception] getSecurityMode()");
  14949. //e.printStackTrace();
  14950. LogUtil.errorLogInfo("", TAG, e);
  14951. return null;
  14952. }
  14953. }
  14954. String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
  14955. String Touch = "Touch";
  14956. String Magnetic = "Magnetic";
  14957. private void setTimeStamp_ScreenTouched() {
  14958. try {
  14959. Calendar mCal = Calendar.getInstance();
  14960. String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  14961. // Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
  14962. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14963. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14964. mEditor.putString(Touch, strTouchTime);
  14965. mEditor.apply();
  14966. } catch (Exception e) {
  14967. Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
  14968. //e.printStackTrace();
  14969. LogUtil.errorLogInfo("", TAG, e);
  14970. }
  14971. }
  14972. private String getTimeStamp_ScreenTouched() {
  14973. try {
  14974. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14975. String strTouchTime = mSharedPreferences.getString(Touch, null);
  14976. // Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
  14977. return strTouchTime;
  14978. } catch (Exception e) {
  14979. Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
  14980. //e.printStackTrace();
  14981. LogUtil.errorLogInfo("", TAG, e);
  14982. return null;
  14983. }
  14984. }
  14985. private void setTimeStamp_Magnetic() {
  14986. try {
  14987. Calendar mCal = Calendar.getInstance();
  14988. String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  14989. // Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
  14990. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14991. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14992. mEditor.putString(Magnetic, strMagneticTime);
  14993. mEditor.apply();
  14994. } catch (Exception e) {
  14995. Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
  14996. //e.printStackTrace();
  14997. LogUtil.errorLogInfo("", TAG, e);
  14998. }
  14999. }
  15000. private String getTimeStamp_Magnetic() {
  15001. try {
  15002. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15003. String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
  15004. // Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
  15005. return strMagneticTime;
  15006. } catch (Exception e) {
  15007. Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
  15008. //e.printStackTrace();
  15009. LogUtil.errorLogInfo("", TAG, e);
  15010. return null;
  15011. }
  15012. }
  15013. /** 거주자 안정 확인 서비스용 코드 종료 */
  15014. /**
  15015. * 가스밸브를 쿡탑콘센트로 사용
  15016. */
  15017. private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
  15018. /** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
  15019. /** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
  15020. /**
  15021. * false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
  15022. */
  15023. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  15024. private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
  15025. /**
  15026. * 기기 연동 제어 옵션 설정 확인
  15027. */
  15028. // 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
  15029. // 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
  15030. private void getDeviceCtrlOption() {
  15031. int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
  15032. boolean bUserSetting_SmartLightEnable = false;
  15033. int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
  15034. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  15035. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  15036. try {
  15037. bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
  15038. nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
  15039. nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
  15040. mWallpadDeviceSet.closeDB();
  15041. bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
  15042. mWallpadStatusData.closeDB();
  15043. if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  15044. // 스마트 분전반을 사용하는 경우에만
  15045. // 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
  15046. if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
  15047. // 사용자선택인 경우
  15048. if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
  15049. else bLightCMDUseAsSmartLight = true;
  15050. } else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
  15051. // 스마트조명을 사용하는 경우
  15052. bLightCMDUseAsSmartLight = false;
  15053. } else {
  15054. // 스마트조명을 사용하지 않는 경우
  15055. bLightCMDUseAsSmartLight = true;
  15056. }
  15057. } else {
  15058. // 스마트분전반을 사용하지 않는 경우
  15059. bLightCMDUseAsSmartLight = true;
  15060. }
  15061. Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
  15062. } catch (Exception e) {
  15063. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  15064. if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
  15065. Log.e(TAG, "[Exception] getDeviceCtrlOption()");
  15066. //e.printStackTrace();
  15067. LogUtil.errorLogInfo("", TAG, e);
  15068. }
  15069. }
  15070. private String[] getRoomNameFromDBV2(String strDeviceType) {
  15071. try {
  15072. String[] RoomNameList = null;
  15073. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  15074. RoomNameList = wallpadStatusData.GetDevRoomNameList(strDeviceType);
  15075. wallpadStatusData.closeDB();
  15076. if (RoomNameList == null) {
  15077. Log.e(TAG, "[getRoomNameFromDBV2] - RoomNameList is null !!!");
  15078. return null;
  15079. }
  15080. Log.i(TAG, "[getRoomNameFromDBV2] RoomNameList " + Arrays.toString(RoomNameList));
  15081. return RoomNameList;
  15082. } catch (RuntimeException re) {
  15083. LogUtil.errorLogInfo("", TAG, re);
  15084. } catch (Exception e) {
  15085. Log.e(TAG, "[Exception] getRoomNameFromDBV2(int Device)");
  15086. //e.printStackTrace();
  15087. LogUtil.errorLogInfo("", TAG, e);
  15088. }
  15089. return null;
  15090. }
  15091. // private void demoPushMsg()
  15092. // {
  15093. // String urlStr1 = "";
  15094. //
  15095. // if(android.os.Build.VERSION.SDK_INT > 9 )
  15096. // {
  15097. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  15098. // StrictMode.setThreadPolicy(policy);
  15099. // }
  15100. //
  15101. // String Msg ="";
  15102. // try {
  15103. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  15104. // } catch (UnsupportedEncodingException e1) {
  15105. // // TODO Auto-generated catch block
  15106. // e1.printStackTrace();
  15107. // }
  15108. //
  15109. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  15110. // Log.d(TAG , "################ : " + urlStr1);
  15111. // try
  15112. // {
  15113. // //URLEncoder.encode(s)
  15114. // HttpClient client = new DefaultHttpClient();
  15115. //
  15116. // HttpGet get = new HttpGet();
  15117. // //get.setURI(new URI("http://www.google.com/"));
  15118. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  15119. // HttpResponse resp = client.execute(get);
  15120. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  15121. // String str = null;
  15122. // StringBuilder sb = new StringBuilder();
  15123. // while((str = br.readLine()) != null)
  15124. // {
  15125. // sb.append(str).append("\n");
  15126. // }
  15127. // br.close();
  15128. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  15129. // //txt.setText(sb.toString());
  15130. // }catch(Exception e)
  15131. // {
  15132. //
  15133. // e.printStackTrace();
  15134. //
  15135. // }
  15136. //
  15137. //
  15138. // }
  15139. //
  15140. //
  15141. // public static boolean checkForExternal(String str) {
  15142. // int length = str.length();
  15143. // for (int i = 0; i < length; i++) {
  15144. // if (str.charAt(i) > 0x7F) {
  15145. // return true;
  15146. // }
  15147. // }
  15148. // return false;
  15149. // }
  15150. //
  15151. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  15152. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  15153. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  15154. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  15155. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  15156. //
  15157. // public static String encodeUrl(String url) {
  15158. // if (checkForExternal(url)) {
  15159. // try {
  15160. // String value = URLEncoder.encode(url, "UTF-8");
  15161. // value = COLON.matcher(value).replaceAll(":");
  15162. // value = SLASH.matcher(value).replaceAll("/");
  15163. // value = QUEST_MARK.matcher(value).replaceAll("?");
  15164. // value = EQUAL.matcher(value).replaceAll("=");
  15165. // return AMP.matcher(value).replaceAll("&");
  15166. // } catch (UnsupportedEncodingException e) {
  15167. // //throw LOGGER.getIllegalStateException(e);
  15168. // return null;
  15169. // }
  15170. // } else {
  15171. // return url;
  15172. // }
  15173. // }
  15174. }