iMapServer.java 887 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060
  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. //
  134. static final int EVENTTIMELIMITE = 2000;
  135. iMapSverSocket SvrSock;
  136. int port = 10000;
  137. String StrAddr = "";
  138. String IPaddr;
  139. String AddrDong;
  140. String AddrHo;
  141. int ho;
  142. boolean log_sw = true;
  143. String SVRIP = "";
  144. static WallPadAPI mWallPadAPI;
  145. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  146. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  147. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  148. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  149. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  150. private IGW200 mIGW200;
  151. private IGW300 mIGW300;
  152. PhonNRemocon PnRCtr;
  153. boolean CallConnected = false;
  154. long ALERTTIME = 0;
  155. long CALLTIME = 0;
  156. long OPENDOORTIME = 0;
  157. long currentTime = 0;
  158. long DoorDelayTime = 0;
  159. static Handler ScheDulerHandler;
  160. static final boolean iMAPDOORCTR = true;
  161. private jni mGleInterface = null;
  162. IOInterface mIOInterface = null;
  163. private boolean ResetFlag = false;
  164. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  165. private int ResetCount = 0;
  166. private boolean NowMainStatus = false;
  167. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  168. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  169. public iMapServer() {
  170. Log.i(TAG, "[iMapServer] ========== START ==========");
  171. }
  172. public static final int SENSOR_MAG = 0x01;
  173. public static final int SENSOR_IN = 0x02;
  174. public static final int SENSOR_OUT = 0x04;
  175. static int PORT_NUM_iMAP = 10000;
  176. static int SOCKET_WAIT_TIME = 40;
  177. static long lSocketConnectionPeriod = 0;
  178. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  179. static int SOCKET_BUFFER_SIZE_READ = 50;
  180. public static final String ITEM_MENU_TYPE = "call_menu";
  181. static final int DOOR_DELAY_TIME = 3000;
  182. static final String MULTISW_CTR = "remote_access_electric";
  183. String XMLHeader;
  184. SchedulerThread ScheServer;
  185. int OutGoingSensorWaiting = 0;
  186. private int ModelType = Version.getModelType();
  187. private WpadSound mSound;
  188. private WpadSound Sound() {
  189. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  190. return mSound;
  191. }
  192. /**
  193. * 신형 단지서버 사용 유무
  194. */
  195. private boolean mNewDanjiServer = false;
  196. /**
  197. * 방범 앱 재실행 여부
  198. */
  199. private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
  200. /**
  201. * JEFF, 2019.12.31
  202. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  203. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  204. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  205. * 통화앱 종료 BR을 삭제하면 안됨
  206. */
  207. // 통화어플이 종료중인 경우에는 호출 무시
  208. // private boolean bBlockCallEvent = false;
  209. ////////////////////////////////////////////////////////////////////////////////
  210. // 엘리베이터관련
  211. ////////////////////////////////////////////////////////////////////////////////
  212. /**
  213. * 엘리베이터 호출관련 class
  214. * <p>
  215. * shkang
  216. */
  217. private class ElevatorClass {
  218. /**
  219. * 엘리베이터 호출 타임아웃 (단위:초)
  220. */
  221. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
  222. /**
  223. * 상향/하향 플레그 true:상향UP, false:하향DN
  224. */
  225. private boolean mUpDn = false;
  226. /**
  227. * 엘리베이터 호출중
  228. */
  229. private boolean mCallElevator = false;
  230. /**
  231. * 엘리베이터 호출 API
  232. */
  233. private WallPadiMAPNotifyAPI mElevatorAPI;
  234. /**
  235. * 엘리베이터 호출 타이머
  236. */
  237. private CountDownTimer mElevatorTimer;
  238. /**
  239. * 엘리베이터 호출중 상태 가져오기
  240. */
  241. public boolean getElevatorCalling() {
  242. return mCallElevator;
  243. }
  244. /**
  245. * 엘리베이터 호출 상태 클리어
  246. */
  247. public void ClearElevator() {
  248. mCallElevator = false;
  249. }
  250. /**
  251. * 생성자
  252. *
  253. * @param Up - (boolean) true:상향, false:하향
  254. */
  255. private ElevatorClass(boolean Up) {
  256. try {
  257. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
  258. // 1. Input Param
  259. mUpDn = Up;
  260. mCallElevator = false;
  261. // 2. Create API
  262. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  263. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  264. @Override
  265. public void ProcDoing() {
  266. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  267. }
  268. @Override
  269. public void ProcError() {
  270. Log.i(TAG, "[ElevatorClass] ProcError()");
  271. mCallElevator = false;
  272. // 엘리베이터 호출 에러 알림
  273. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  274. }
  275. @Override
  276. public void ProcSuccess() {
  277. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  278. mCallElevator = true;
  279. // 엘리베이터 호출 성공 알림
  280. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  281. // "엘리베이터를 호출하였습니다" 멘트출력
  282. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  283. Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
  284. if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
  285. Sound().PlayMent(WpadSound.SND.elevator.CALL);
  286. bOutModeRestart = false;
  287. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  288. // 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
  289. // 타임아웃 시작
  290. TimeOutStart();
  291. }
  292. });
  293. // 3. Create Timer
  294. mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  295. @Override
  296. public void onFinish() {
  297. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  298. mCallElevator = false;
  299. // 호출 타임아웃 알림
  300. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  301. }
  302. @Override
  303. public void onTick(long arg0) {
  304. int RemainingTime = (int) (arg0 / 1000);
  305. if (RemainingTime <= 10) {
  306. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  307. }
  308. }
  309. };
  310. } catch (RuntimeException re) {
  311. LogUtil.errorLogInfo("", TAG, re);
  312. } catch (Exception e) {
  313. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  314. //e.printStackTrace();
  315. LogUtil.errorLogInfo("", TAG, e);
  316. }
  317. }
  318. /**
  319. * 엘리베이터 호출을 한다.
  320. */
  321. public void CallElevator() {
  322. try {
  323. if (mElevatorAPI == null) return;
  324. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  325. mCallElevator = true;
  326. } catch (RuntimeException re) {
  327. LogUtil.errorLogInfo("", TAG, re);
  328. } catch (Exception e) {
  329. Log.e(TAG, "[Exception] CallElevator()");
  330. //e.printStackTrace();
  331. LogUtil.errorLogInfo("", TAG, e);
  332. }
  333. }
  334. /**
  335. * 엘리베이터 상향호출 타임아웃을 취소한다.
  336. */
  337. public void TimeOutCancel() {
  338. try {
  339. if (mElevatorTimer == null) return;
  340. mElevatorTimer.cancel();
  341. } catch (RuntimeException re) {
  342. LogUtil.errorLogInfo("", TAG, re);
  343. } catch (Exception e) {
  344. Log.e(TAG, "[Exception] TimeOutCancel()");
  345. //e.printStackTrace();
  346. LogUtil.errorLogInfo("", TAG, e);
  347. }
  348. }
  349. /**
  350. * 엘리베이터 상향호출 타임아웃을 시작한다.
  351. */
  352. private void TimeOutStart() {
  353. try {
  354. if (mElevatorTimer == null) return;
  355. mElevatorTimer.cancel();
  356. mElevatorTimer.start();
  357. } catch (RuntimeException re) {
  358. LogUtil.errorLogInfo("", TAG, re);
  359. } catch (Exception e) {
  360. Log.e(TAG, "[Exception] TimeOutStart()");
  361. //e.printStackTrace();
  362. LogUtil.errorLogInfo("", TAG, e);
  363. }
  364. }
  365. /**
  366. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  367. *
  368. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  369. */
  370. private void SendNotifyKindBR(int kind) {
  371. try {
  372. Intent notiIntent = new Intent();
  373. notiIntent.setAction(define.NOTIFY_ACNAME);
  374. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  375. getApplicationContext().sendBroadcast(notiIntent);
  376. } catch (RuntimeException re) {
  377. LogUtil.errorLogInfo("", TAG, re);
  378. } catch (Exception e) {
  379. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  380. //e.printStackTrace();
  381. LogUtil.errorLogInfo("", TAG, e);
  382. }
  383. }
  384. }
  385. /**
  386. * 엘리베이터 상향호출 Class
  387. */
  388. private ElevatorClass ElevatorUp;
  389. /**
  390. * 엘리베이터 하향호출 Class
  391. */
  392. private ElevatorClass ElevatorDown;
  393. /**
  394. * 엘리베이터 호출한다.
  395. *
  396. * @param Up (boolean) true : 상향, false : 하향
  397. */
  398. private void CallElevatorBtn(boolean Up) {
  399. try {
  400. Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
  401. if (Up) {
  402. // 상향호출
  403. if (ElevatorUp == null) {
  404. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  405. return;
  406. }
  407. ElevatorUp.CallElevator();
  408. } else {
  409. // 하향호출
  410. if (ElevatorDown == null) {
  411. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  412. return;
  413. }
  414. ElevatorDown.CallElevator();
  415. }
  416. } catch (RuntimeException re) {
  417. LogUtil.errorLogInfo("", TAG, re);
  418. } catch (Exception e) {
  419. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  420. //e.printStackTrace();
  421. LogUtil.errorLogInfo("", TAG, e);
  422. }
  423. }
  424. ////////////////////////////////////////////////////////////////////////////////
  425. ////////////////////////////////////////////////////////////////////////////////
  426. @Override
  427. public void onCreate() {
  428. try {
  429. super.onCreate();
  430. Log.i(TAG, "[onCreate] ========== START ==========");
  431. setGlobalScreenAppRunningStatus(false);
  432. ModelType = Version.getModelType();
  433. mSound = new WpadSound(getApplicationContext());
  434. ElevatorUp = new ElevatorClass(true);
  435. ElevatorDown = new ElevatorClass(false);
  436. } catch (RuntimeException re) {
  437. Log.e(TAG, "[Exception] onCreate()");
  438. //e.printStackTrace();
  439. LogUtil.errorLogInfo("", TAG, re);
  440. } catch (Exception e) {
  441. Log.e(TAG, "[Exception] onCreate()");
  442. //e.printStackTrace();
  443. LogUtil.errorLogInfo("", TAG, e);
  444. }
  445. }
  446. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  447. try {
  448. Intent notiIntent = new Intent();
  449. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  450. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  451. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  452. getApplicationContext().sendBroadcast(notiIntent);
  453. } catch (RuntimeException re) {
  454. LogUtil.errorLogInfo("", TAG, re);
  455. } catch (Exception e) {
  456. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  457. //e.printStackTrace();
  458. LogUtil.errorLogInfo("", TAG, e);
  459. }
  460. }
  461. protected String GetForegroundAPP() {
  462. try {
  463. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  464. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  465. ComponentName topActivity = taskInfo.get(0).topActivity;
  466. String str = topActivity.getPackageName();
  467. return str;
  468. } catch (RuntimeException re) {
  469. LogUtil.errorLogInfo("", TAG, re);
  470. return " ";
  471. } catch (Exception e) {
  472. Log.e(TAG, "[Exception] GetForegroundAPP()");
  473. //e.printStackTrace();
  474. LogUtil.errorLogInfo("", TAG, e);
  475. return " ";
  476. }
  477. }
  478. long lSavedTimestamp = 0;
  479. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  480. public void onReceive(Context context, Intent intent) {
  481. try {
  482. String strActionName = intent.getAction();
  483. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
  484. if (strActionName.equals(define.NOTIFY_DAIL)) {
  485. long lTimestamp = System.currentTimeMillis();
  486. long lInterval = lTimestamp - lSavedTimestamp;
  487. if (lInterval < 1000) return;
  488. else
  489. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
  490. lSavedTimestamp = lTimestamp;
  491. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  492. if (mSdb_LivingRoomLightAPI == null) {
  493. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  494. return;
  495. }
  496. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  497. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  498. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  499. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  500. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  501. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  502. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  503. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  504. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  505. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  506. mSdb_LivingRoomLightAPI.SetControlMode(false);
  507. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  508. }
  509. return;
  510. }
  511. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  512. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  513. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  514. return;
  515. }
  516. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  517. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  518. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  519. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  520. } else {
  521. setGlobalScreenAppRunningStatus(false);
  522. }
  523. } else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  524. if (mKnx_LivingRoomLightAPI == null) {
  525. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  526. return;
  527. }
  528. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  529. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  530. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  531. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  532. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  533. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  534. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  535. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  536. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  537. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  538. mKnx_LivingRoomLightAPI.SetControlMode(false);
  539. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  540. }
  541. return;
  542. }
  543. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  544. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  545. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  546. return;
  547. }
  548. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  549. 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 + "]");
  550. }
  551. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  552. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  553. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  554. } else {
  555. setGlobalScreenAppRunningStatus(false);
  556. }
  557. } else {
  558. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  559. }
  560. } else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  561. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  562. } else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
  563. int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
  564. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
  565. switch (kind) {
  566. case define.NOTIFY_SCREEN_TOUCHED:
  567. setTimeStamp_ScreenTouched();
  568. break;
  569. case define.NOTIFY_DOOR_OPENED:
  570. setTimeStamp_Magnetic();
  571. break;
  572. }
  573. } else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  574. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
  575. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  576. switch (kind) {
  577. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  578. procUploadMissedVisitorPic(intent);
  579. break;
  580. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  581. // bBlockCallEvent = true;
  582. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  583. break;
  584. case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
  585. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
  586. Sound().Play(SND.mode.OUTMODE_SETTING);
  587. break;
  588. case Common.BR_MAIN_NOTI.SOUND_INMODE:
  589. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
  590. Sound().Play(SND.mode.INMODE_SETTING);
  591. break;
  592. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  593. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  594. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  595. break;
  596. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
  597. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  598. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  599. break;
  600. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
  601. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  602. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  603. break;
  604. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  605. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  606. CallElevatorBtn(false);
  607. break;
  608. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  609. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  610. CallElevatorBtn(true);
  611. break;
  612. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
  613. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  614. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  615. int CalledWallPadUI = intent.getIntExtra("Called", 0);
  616. if (CalledWallPadUI == 1) {
  617. ModeRunCtrlWorking(true, false);
  618. } else {
  619. ModeRunCtrlWorking(false, false);
  620. }
  621. break;
  622. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
  623. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  624. ModeReleaseCtrlWorking(false);
  625. break;
  626. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
  627. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  628. CheckMainStatus();
  629. break;
  630. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
  631. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  632. ModeRunCtrlWorking(false, false);
  633. break;
  634. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
  635. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  636. ModeReleaseCtrlWorking(false);
  637. break;
  638. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
  639. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  640. if (ElevatorUp != null && ElevatorDown != null) {
  641. boolean UpCalling = ElevatorUp.getElevatorCalling();
  642. boolean DownCalling = ElevatorDown.getElevatorCalling();
  643. Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
  644. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  645. if (UpCalling && DownCalling)
  646. Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  647. else if (UpCalling && !DownCalling)
  648. Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  649. else if (!UpCalling && DownCalling)
  650. Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  651. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  652. Log.d(TAG, " ElvCallState : " + ElvCallState);
  653. SendBRElevatorCallState(ElvCallState);
  654. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  655. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  656. // sendIntent.putExtra("ELV", ElvCallState);
  657. // getApplicationContext().sendBroadcast(sendIntent);
  658. }
  659. break;
  660. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  661. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  662. try {
  663. if (ScheServer != null) {
  664. ScheServer.SetLive();
  665. }
  666. } catch (RuntimeException re) {
  667. LogUtil.errorLogInfo("", TAG, re);
  668. } catch (Exception e) {
  669. //e.printStackTrace();
  670. LogUtil.errorLogInfo("", TAG, e);
  671. }
  672. break;
  673. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  674. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  675. stopIGW300RingGenerator();
  676. break;
  677. }
  678. } else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  679. int kind = intent.getIntExtra("KIND", 0);
  680. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  681. switch (kind) {
  682. case define.NOTIFY_SERVER_VERSION:
  683. try {
  684. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  685. iMapSverReload tSock = new iMapSverReload();
  686. tSock.start();
  687. } catch (IOException e) {
  688. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  689. //e.printStackTrace();
  690. LogUtil.errorLogInfo("", TAG, e);
  691. }
  692. break;
  693. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  694. // 제어기기 엘리베이터 상향 호출 요청
  695. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  696. CallElevatorBtn(true);
  697. break;
  698. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  699. // 제어기기에서 엘리베이터 하향 호출 요청
  700. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  701. CallElevatorBtn(false);
  702. break;
  703. case define.NOTIFY_SUBDEVCALLBUSY:
  704. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  705. CallConnected = true;
  706. break;
  707. case define.NOTIFY_SUBDEVCALLEND:
  708. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  709. CallConnected = false;
  710. break;
  711. case define.NOTIFY_STARTHEARTBEAT:
  712. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  713. {
  714. Message msg = ScheDulerHandler.obtainMessage();
  715. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  716. ScheDulerHandler.sendMessage(msg);
  717. }
  718. break;
  719. case define.NOTIFY_STARTSTATUSBEAT:
  720. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  721. {
  722. Message msg = ScheDulerHandler.obtainMessage();
  723. msg.what = SCHEDULE_START_STATUSBEAT;
  724. ScheDulerHandler.sendMessage(msg);
  725. }
  726. break;
  727. case define.NOTIFY_OUTGOINGSETTED:
  728. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  729. OutGoingSensorWaiting = 0;
  730. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  731. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  732. sdata.closeDB();
  733. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  734. return;
  735. WallPadInterface wpifc = new WallPadInterface();
  736. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
  737. OutGoingSensorWaiting |= SENSOR_MAG;
  738. int[] SensorInfoDB;
  739. int sensorIn = 0;
  740. int sensorOut = 0;
  741. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  742. if (SensorInfoDB[0] == 1) {
  743. // 내부동체가 사용함이면 상태 검사
  744. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
  745. OutGoingSensorWaiting |= SENSOR_IN;
  746. }
  747. if (SensorInfoDB[1] == 1) {
  748. // 외부동체가 사용함이면 상태 검사
  749. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
  750. OutGoingSensorWaiting |= SENSOR_OUT;
  751. }
  752. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  753. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  754. if (OutGoingSensorWaiting > 0) {
  755. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  756. SensorThread.start();
  757. }
  758. break;
  759. case define.NOTIFY_DOOR_SET_DELAY:
  760. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  761. DoorDelayTime = System.currentTimeMillis();
  762. imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
  763. break;
  764. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  765. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  766. Common.setDeviceServeiceLoadComplite();
  767. startRealtimemeterInfo(); // 실시간 검침기 확인
  768. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  769. startDistributionPanel(); // 분전반 확인
  770. getRoomName();
  771. break;
  772. case define.NOTIFY_DLOCK_SET_OUTING:
  773. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  774. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  775. try {
  776. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  777. int AlarmStatus = DBMGR.GetAlarmStatus();
  778. DBMGR.closeDB();
  779. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  780. // 센서 체크하고
  781. // 현관폰으로 사운드 출력하고
  782. boolean bSensorOk = false;
  783. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  784. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  785. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  786. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  787. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  788. bSensorOk = mIGW300.checkSensorforOutmode();
  789. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  790. bSensorOk = mIGW200.checkSensorforOutmode();
  791. } else {
  792. bSensorOk = checkSensorforOutmode();
  793. }
  794. if (bSensorOk) {
  795. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  796. CallOutModeRunActivity();
  797. } else {
  798. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  799. }
  800. }
  801. } catch (RuntimeException re) {
  802. LogUtil.errorLogInfo("", TAG, re);
  803. } catch (Exception e) {
  804. //e.printStackTrace();
  805. LogUtil.errorLogInfo("", TAG, e);
  806. }
  807. break;
  808. case define.NOTIFY_DLOCK_FREE_OUTING:
  809. // 도어락 외출모드 해제
  810. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  811. try {
  812. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  813. int AlarmStatus = DBMGR.GetAlarmStatus();
  814. DBMGR.closeDB();
  815. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  816. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  817. Common.SendAppFinishReqBR(getApplicationContext());
  818. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  819. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  820. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  821. devDB.closeDB();
  822. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  823. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  824. }
  825. }
  826. } catch (RuntimeException re) {
  827. LogUtil.errorLogInfo("", TAG, re);
  828. } catch (Exception e) {
  829. //e.printStackTrace();
  830. LogUtil.errorLogInfo("", TAG, e);
  831. }
  832. break;
  833. case define.NOTIFY_SMARTSW_SET_OUTING:
  834. // 485 대외향 스마트스위치 외출모드
  835. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  836. setUnoccupiedModeByNotHDCSmartSwitch();
  837. break;
  838. case define.NOTIFY_SMARTSW_FREE_OUTING:
  839. //대외향 485 스마트스위치 외출모드 해제
  840. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  841. releaseUnoccupiedModeByNotHDCSmartSwitch();
  842. break;
  843. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  844. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  845. String Type = intent.getStringExtra("TYPE");
  846. String Device = intent.getStringExtra("DEVICE");
  847. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  848. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  849. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  850. iMAPSmartLightEvent imapSmartLightEvent;
  851. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  852. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  853. imapSmartLightEvent.SetRetCtr(new RetProci() {
  854. @Override
  855. public void ProcSuccess() {
  856. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  857. }
  858. @Override
  859. public void ProcError() {
  860. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  861. }
  862. @Override
  863. public void ProcDoing() {
  864. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  865. }
  866. });
  867. break;
  868. case define.NOTIFY_KNX_DEVICE_EVENT:
  869. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  870. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  871. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  872. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  873. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  874. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  875. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  876. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  877. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  878. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  879. @Override
  880. public void ProcSuccess() {
  881. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  882. }
  883. @Override
  884. public void ProcError() {
  885. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  886. }
  887. @Override
  888. public void ProcDoing() {
  889. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  890. }
  891. });
  892. break;
  893. case define.NOTIFY_SMART_DCAM_DETECT:
  894. // 스마트현관카메라 거동수상자 발생
  895. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  896. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  897. if (!bWallPadCallLive && !bBlockFrontCall) {
  898. if (getStrangerRecordingManagerSetting()) {
  899. if (getStrangerRecordingUserSetting()) {
  900. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  901. Intent Newintent = new Intent();
  902. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  903. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  904. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  905. getApplicationContext().sendBroadcast(Newintent);
  906. } else {
  907. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  908. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  909. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  910. }
  911. } else {
  912. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  913. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  914. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  915. }
  916. } else {
  917. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  918. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  919. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  920. }
  921. break;
  922. case define.NOTIFY_SMART_DCAM_RELEASE:
  923. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  924. break;
  925. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  926. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  927. if (getStrangerRecordingManagerSetting()) {
  928. if (getStrangerRecordingUserSetting()) {
  929. // 알람 상태 확인
  930. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  931. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  932. mWallpadStatusData.closeDB();
  933. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  934. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  935. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  936. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  937. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  938. } else {
  939. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  940. Intent Newintent = new Intent();
  941. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  942. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  943. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  944. getApplicationContext().sendBroadcast(Newintent);
  945. }
  946. } else {
  947. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  948. }
  949. } else {
  950. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  951. }
  952. break;
  953. case define.NOTIFY_REJECT_RECORD_STRANGER:
  954. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  955. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  956. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  957. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  958. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  959. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  960. }
  961. break;
  962. case define.NOTIFY_ROOMNAME_CHANGED:
  963. getRoomName();
  964. break;
  965. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  966. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  967. break;
  968. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  969. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  970. break;
  971. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  972. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  973. break;
  974. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  975. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  976. break;
  977. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  978. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  979. break;
  980. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  981. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  982. break;
  983. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  984. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  985. break;
  986. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  987. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  988. break;
  989. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  990. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  991. break;
  992. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  993. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  994. break;
  995. case define.NOTIFY_FINISH_RECORD_STRANGER:
  996. // 녹화 종료 알림
  997. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  998. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  999. mWallpadStatusData.closeDB();
  1000. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
  1001. if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
  1002. break;
  1003. case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
  1004. // 사용자 설정화면에서 원격제어시 조명제어 타입 변경
  1005. getDeviceCtrlOption();
  1006. break;
  1007. default:
  1008. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  1009. break;
  1010. }
  1011. }
  1012. } catch (RuntimeException re) {
  1013. LogUtil.errorLogInfo("", TAG, re);
  1014. } catch (Exception e) {
  1015. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1016. //e.printStackTrace();
  1017. LogUtil.errorLogInfo("", TAG, e);
  1018. }
  1019. }
  1020. };
  1021. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1022. try {
  1023. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1024. // 485 대외향 스마트스위치 외출모드
  1025. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1026. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1027. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1028. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1029. mWallpadStatusData.closeDB();
  1030. if (UseGuardSensorCheck == false) {
  1031. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1032. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1033. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1034. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
  1035. mWallpadStatusData.closeDB();
  1036. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1037. //메인화면 업데이트
  1038. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1039. getApplicationContext().sendBroadcast(newIntent);
  1040. ModeRunCtrlWorking(false, false);
  1041. }
  1042. } else {
  1043. // 실제 외출 방범 모드를 설정하도록 한다.
  1044. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1045. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1046. // 센서 체크하고
  1047. // 센서 체크하는 부분이 들어가야 함
  1048. Common.SendAppFinishReqBR(getApplicationContext());
  1049. 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
  1050. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1051. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1052. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1053. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1054. if (mIGW300.checkSensorforOutmode()) {
  1055. CallOutModeWaitingActivity(AlarmStatus);
  1056. } else {
  1057. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1058. }
  1059. } else {
  1060. if (checkSensorforOutmode()) {
  1061. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1062. CallOutModeWaitingActivity(AlarmStatus);
  1063. } else {
  1064. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1065. }
  1066. }
  1067. }
  1068. }
  1069. } catch (RuntimeException re) {
  1070. LogUtil.errorLogInfo("", TAG, re);
  1071. } catch (Exception e) {
  1072. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1073. //e.printStackTrace();
  1074. LogUtil.errorLogInfo("", TAG, e);
  1075. }
  1076. }
  1077. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1078. try {
  1079. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1080. //대외향 485 스마트스위치 외출모드 해제
  1081. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1082. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1083. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1084. mWallpadStatusData.closeDB();
  1085. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
  1086. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1087. if (OutModePwRelease) {
  1088. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1089. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1090. // 요청하여도 해제 되지 않으며
  1091. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1092. Intent notiIntent = new Intent();
  1093. notiIntent.setAction(define.NOTIFY_ACNAME);
  1094. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1095. getApplicationContext().sendBroadcast(notiIntent);
  1096. } else {
  1097. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1098. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1099. // 처리하고.
  1100. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1101. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1102. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1103. mWallpadStatusData.closeDB();
  1104. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1105. Common.SendAppFinishReqBR(getApplicationContext());
  1106. }
  1107. } else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1108. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1109. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1110. ModeReleaseCtrlWorking(false);
  1111. bSmartSwitch485ComebackMode = true;
  1112. Intent notiIntent = new Intent();
  1113. notiIntent.setAction(define.NOTIFY_ACNAME);
  1114. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1115. getApplicationContext().sendBroadcast(notiIntent);
  1116. } else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1117. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1118. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1119. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1120. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1121. mWallpadStatusData.closeDB();
  1122. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1123. //메인화면 업데이트
  1124. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1125. getApplicationContext().sendBroadcast(newIntent);
  1126. ModeReleaseCtrlWorking(false);
  1127. }
  1128. } catch (RuntimeException re) {
  1129. LogUtil.errorLogInfo("", TAG, re);
  1130. } catch (Exception e) {
  1131. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1132. //e.printStackTrace();
  1133. LogUtil.errorLogInfo("", TAG, e);
  1134. }
  1135. }
  1136. /**
  1137. * 스마트현관카메라 녹화 여부 판별
  1138. * 사용자 화면에서 설정
  1139. */
  1140. private boolean getStrangerRecordingUserSetting() {
  1141. boolean bResult = false;
  1142. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1143. try {
  1144. bResult = DBMGR.GetStrangerRecordingOnOff();
  1145. DBMGR.closeDB();
  1146. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1147. } catch (RuntimeException re) {
  1148. LogUtil.errorLogInfo("", TAG, re);
  1149. DBMGR.closeDB();
  1150. bResult = false;
  1151. } catch (Exception e) {
  1152. DBMGR.closeDB();
  1153. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1154. //e.printStackTrace();
  1155. LogUtil.errorLogInfo("", TAG, e);
  1156. bResult = false;
  1157. }
  1158. return bResult;
  1159. }
  1160. private boolean getStrangerTakePic() {
  1161. try {
  1162. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1163. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1164. DBMGR.closeDB();
  1165. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1166. return bResult;
  1167. } catch (RuntimeException re) {
  1168. LogUtil.errorLogInfo("", TAG, re);
  1169. return false;
  1170. } catch (Exception e) {
  1171. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1172. //e.printStackTrace();
  1173. LogUtil.errorLogInfo("", TAG, e);
  1174. return false;
  1175. }
  1176. }
  1177. // 관리자 설정 항목에 있음
  1178. private boolean getStrangerRecordUsage() {
  1179. try {
  1180. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1181. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1182. mWallpadDeviceSet.closeDB();
  1183. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1184. return bResult;
  1185. } catch (RuntimeException re) {
  1186. LogUtil.errorLogInfo("", TAG, re);
  1187. return false;
  1188. } catch (Exception e) {
  1189. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1190. //e.printStackTrace();
  1191. LogUtil.errorLogInfo("", TAG, e);
  1192. return false;
  1193. }
  1194. }
  1195. private boolean checkSensorforOutmode() {
  1196. try {
  1197. WallPadInterface wallPadInterface = new WallPadInterface();
  1198. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1199. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1200. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1201. int[] SensorInfoDB;
  1202. int sensorIn = 0;
  1203. int sensorOut = 0;
  1204. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1205. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1206. if (SensorInfoDB[0] == 1) {
  1207. // 내부동체가 사용함이면 상태 검사
  1208. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1209. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1210. }
  1211. if (SensorInfoDB[1] == 1) {
  1212. // 외부동체가 사용함이면 상태 검사
  1213. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1214. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1215. }
  1216. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1217. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1218. // 동체 사용 설정 체크..
  1219. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1220. int sensor = devSet.Get_Sensor_Set();
  1221. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1222. devSet.closeDB();
  1223. int OtherInSensor = 0;
  1224. // 내부동체 사용안함 이면
  1225. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1226. // 외부동체 사용안함 이면
  1227. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1228. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1229. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1230. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1231. return true;
  1232. } else {
  1233. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1234. return false;
  1235. }
  1236. } catch (RuntimeException re) {
  1237. LogUtil.errorLogInfo("", TAG, re);
  1238. return false;
  1239. } catch (Exception e) {
  1240. //e.printStackTrace();
  1241. LogUtil.errorLogInfo("", TAG, e);
  1242. return false;
  1243. }
  1244. }
  1245. private boolean checkSensorforInmode() {
  1246. try {
  1247. WallPadInterface wallPadInterface = new WallPadInterface();
  1248. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1249. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1250. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1251. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1252. if (sensorMag == 0) {
  1253. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1254. return true;
  1255. } else {
  1256. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1257. return false;
  1258. }
  1259. } catch (RuntimeException re) {
  1260. LogUtil.errorLogInfo("", TAG, re);
  1261. return false;
  1262. } catch (Exception e) {
  1263. Log.e(TAG, e.toString());
  1264. //e.printStackTrace();
  1265. LogUtil.errorLogInfo("", TAG, e);
  1266. return false;
  1267. }
  1268. }
  1269. /////////////////////
  1270. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1271. //////////////
  1272. /////////////////////
  1273. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1274. //////////////
  1275. public void playSoundthroughDoorphone(int SoundIdx) {
  1276. try {
  1277. WallPadInterface Wiface = new WallPadInterface();
  1278. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1279. 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
  1280. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1281. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1282. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1283. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1284. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1285. if (getUseSmartDoorCam()) {
  1286. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1287. }
  1288. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1289. /*
  1290. JEFF (2019.01.14)
  1291. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1292. 강신구입니다.
  1293. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1294. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1295. 내용 공유합니다.
  1296. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1297. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1298. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1299. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1300. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1301. 문제 없습니다.
  1302. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1303. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1304. 문의사항은 하기 연락바랍니다.
  1305. 감사합니다.
  1306. */
  1307. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1308. } else {
  1309. // 대외향 모델 처리
  1310. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
  1311. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1312. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1313. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1314. }
  1315. try {
  1316. Thread.sleep(100);
  1317. } catch (RuntimeException re) {
  1318. LogUtil.errorLogInfo("", TAG, re);
  1319. } catch (Exception e) {
  1320. LogUtil.errorLogInfo("", TAG, e);
  1321. }
  1322. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1323. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1324. try {
  1325. Thread.sleep(1500);
  1326. } catch (RuntimeException re) {
  1327. LogUtil.errorLogInfo("", TAG, re);
  1328. } catch (Exception e) {
  1329. LogUtil.errorLogInfo("", TAG, e);
  1330. }
  1331. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1332. int SLevel = Wdb.GetDoorSoundLevel();
  1333. Wdb.closeDB();
  1334. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1335. if (SLevel != -1) {
  1336. /**
  1337. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1338. * **/
  1339. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1340. } else {
  1341. // 사용안함이면
  1342. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1343. }
  1344. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1345. int time = Sound().PlayMent(SoundIdx);
  1346. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1347. if (0 > time) {
  1348. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1349. time = 1000;
  1350. }
  1351. try {
  1352. Thread.sleep(time + 1000);
  1353. } catch (RuntimeException re) {
  1354. LogUtil.errorLogInfo("", TAG, re);
  1355. } catch (Exception e) {
  1356. LogUtil.errorLogInfo("", TAG, e);
  1357. }
  1358. amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1359. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1360. try {
  1361. Thread.sleep(100);
  1362. } catch (RuntimeException re) {
  1363. LogUtil.errorLogInfo("", TAG, re);
  1364. } catch (Exception e) {
  1365. LogUtil.errorLogInfo("", TAG, e);
  1366. }
  1367. 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
  1368. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1369. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1370. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1371. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1372. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1373. if (getUseSmartDoorCam()) {
  1374. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1375. }
  1376. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1377. /*
  1378. JEFF (2019.01.14)
  1379. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1380. 강신구입니다.
  1381. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1382. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1383. 내용 공유합니다.
  1384. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1385. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1386. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1387. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1388. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1389. 문제 없습니다.
  1390. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1391. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1392. 문의사항은 하기 연락바랍니다.
  1393. 감사합니다.
  1394. */
  1395. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1396. } else {
  1397. // 대외향 모델 처리
  1398. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1399. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1400. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1401. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1402. }
  1403. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1404. } catch (RuntimeException re) {
  1405. LogUtil.errorLogInfo("", TAG, re);
  1406. } catch (Exception e) {
  1407. //e.printStackTrace();
  1408. LogUtil.errorLogInfo("", TAG, e);
  1409. }
  1410. }
  1411. public void CallOutModeRunActivity() {
  1412. int base = 8000;
  1413. int[] Menu_Id_List = {base + 11};
  1414. int Menu_StartId = base + 11;
  1415. int Menu_Option = -1;
  1416. Intent intent = new Intent(Intent.ACTION_MAIN);
  1417. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1418. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1419. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1420. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1421. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1422. startActivity(intent);
  1423. }
  1424. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1425. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1426. int base = 4000;
  1427. int[] Menu_Id_List = {base + 11, base + 21};
  1428. int Menu_StartId = base + 11;
  1429. int Menu_Option = 1000;
  1430. Intent intent = new Intent(Intent.ACTION_MAIN);
  1431. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1432. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1433. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1434. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1435. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  1436. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1437. startActivity(intent);
  1438. }
  1439. private boolean getGlobalScreenAppRunningStatus() {
  1440. boolean bRunning = false;
  1441. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1442. try {
  1443. bRunning = DBMGR.getGlobalScreenAPKRun();
  1444. DBMGR.closeDB();
  1445. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1446. return bRunning;
  1447. } catch (RuntimeException re) {
  1448. LogUtil.errorLogInfo("", TAG, re);
  1449. DBMGR.closeDB();
  1450. } catch (Exception e) {
  1451. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1452. //e.printStackTrace();
  1453. LogUtil.errorLogInfo("", TAG, e);
  1454. DBMGR.closeDB();
  1455. }
  1456. return bRunning;
  1457. }
  1458. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1459. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1460. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1461. try {
  1462. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1463. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1464. DBMGR.closeDB();
  1465. } catch (RuntimeException re) {
  1466. LogUtil.errorLogInfo("", TAG, re);
  1467. DBMGR.closeDB();
  1468. } catch (Exception e) {
  1469. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1470. //e.printStackTrace();
  1471. LogUtil.errorLogInfo("", TAG, e);
  1472. DBMGR.closeDB();
  1473. }
  1474. }
  1475. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1476. boolean bGlobalScreenRun = false;
  1477. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1478. try {
  1479. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1480. wakeupLCD();
  1481. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1482. setGlobalScreenAppRunningStatus(true);
  1483. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1484. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1485. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1486. mIntent.putExtra("ONOFF", hOnOff);
  1487. mIntent.putExtra("DIAL", hDial);
  1488. mIntent.putExtra("LEVEL", hLevel);
  1489. mIntent.putExtra("COLOR", hColor);
  1490. mIntent.putExtra("CONTROL", hControl);
  1491. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1492. mIntent.setComponent(mComponentName);
  1493. startActivity(mIntent);
  1494. } else {
  1495. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1496. }
  1497. } catch (RuntimeException re) {
  1498. LogUtil.errorLogInfo("", TAG, re);
  1499. } catch (Exception e) {
  1500. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1501. //e.printStackTrace();
  1502. LogUtil.errorLogInfo("", TAG, e);
  1503. }
  1504. }
  1505. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1506. try {
  1507. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1508. wakeupLCD();
  1509. if (!getGlobalScreenAppRunningStatus()) {
  1510. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1511. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1512. return;
  1513. }
  1514. setGlobalScreenAppRunningStatus(true);
  1515. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1516. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1517. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1518. mIntent.putExtra("SCREENID", nScreenID);
  1519. mIntent.putExtra("ONOFF", hOnOff);
  1520. mIntent.putExtra("DIAL", hDial);
  1521. mIntent.putExtra("LEVEL", hLevel);
  1522. mIntent.putExtra("COLOR", hColor);
  1523. mIntent.putExtra("CONTROL", hControl);
  1524. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1525. mIntent.setComponent(mComponentName);
  1526. startActivity(mIntent);
  1527. } else {
  1528. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1529. }
  1530. } catch (RuntimeException re) {
  1531. LogUtil.errorLogInfo("", TAG, re);
  1532. } catch (Exception e) {
  1533. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1534. //e.printStackTrace();
  1535. LogUtil.errorLogInfo("", TAG, e);
  1536. }
  1537. }
  1538. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1539. public void sendBlackoutReleasedBR() {
  1540. try {
  1541. Intent notiIntent = new Intent();
  1542. notiIntent.setAction(strBLACKOUT_RELEASED);
  1543. getApplicationContext().sendBroadcast(notiIntent);
  1544. } catch (RuntimeException re) {
  1545. LogUtil.errorLogInfo("", TAG, re);
  1546. } catch (Exception e) {
  1547. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1548. //e.printStackTrace();
  1549. LogUtil.errorLogInfo("", TAG, e);
  1550. }
  1551. }
  1552. private int getCurrentScreen() {
  1553. int nScreenID = 0;
  1554. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1555. try {
  1556. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1557. DBMGR.closeDB();
  1558. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1559. return nScreenID;
  1560. } catch (RuntimeException re) {
  1561. LogUtil.errorLogInfo("", TAG, re);
  1562. DBMGR.closeDB();
  1563. } catch (Exception e) {
  1564. Log.e(TAG, "[Exception] getCurrentScreen()");
  1565. //e.printStackTrace();
  1566. LogUtil.errorLogInfo("", TAG, e);
  1567. DBMGR.closeDB();
  1568. }
  1569. return nScreenID;
  1570. }
  1571. private void setCurrentScreen(int nScreenID) {
  1572. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1573. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1574. try {
  1575. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1576. DBMGR.closeDB();
  1577. } catch (RuntimeException re) {
  1578. LogUtil.errorLogInfo("", TAG, re);
  1579. DBMGR.closeDB();
  1580. } catch (Exception e) {
  1581. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1582. //e.printStackTrace();
  1583. LogUtil.errorLogInfo("", TAG, e);
  1584. DBMGR.closeDB();
  1585. }
  1586. }
  1587. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1588. private void procUploadMissedVisitorPic(Intent intent) {
  1589. try {
  1590. String strDong = intent.getStringExtra("DONG");
  1591. String strHo = intent.getStringExtra("HO");
  1592. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1593. int nCnt = intent.getIntExtra("CNT", 0);
  1594. String[] strMissedPicURI = new String[nCnt];
  1595. strArrayMissedPicURI.clear();
  1596. for (int i = 0; i < nCnt; i++) {
  1597. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1598. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1599. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1600. }
  1601. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1602. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1603. }
  1604. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1605. } catch (RuntimeException re) {
  1606. LogUtil.errorLogInfo("", TAG, re);
  1607. } catch (Exception e) {
  1608. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1609. //e.printStackTrace();
  1610. LogUtil.errorLogInfo("", TAG, e);
  1611. }
  1612. }
  1613. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1614. try {
  1615. String strURI = "", strFileName = "", strTime = "", strType = "";
  1616. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1617. // strURI = strArrayMissedPicURI.get(i).toString();
  1618. // strFileName = extractFileName(strURI);
  1619. // strTime = extractFileTime(strURI);
  1620. // strType = extractCallType(strFileName);
  1621. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1622. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1623. // }
  1624. if (strArrayMissedPicURI.size() > 0) {
  1625. strURI = strArrayMissedPicURI.get(0).toString();
  1626. strFileName = extractFileName(strURI);
  1627. strTime = extractFileTime(strFileName);
  1628. strType = extractCallType(strFileName);
  1629. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1630. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1631. } else {
  1632. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1633. }
  1634. } catch (RuntimeException re) {
  1635. LogUtil.errorLogInfo("", TAG, re);
  1636. } catch (Exception e) {
  1637. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1638. //e.printStackTrace();
  1639. LogUtil.errorLogInfo("", TAG, e);
  1640. }
  1641. }
  1642. public class uploadVisitorPicture extends Thread {
  1643. HDCFTPManager mFTPManager;
  1644. boolean bMainServer2dot0 = false;
  1645. String strRemoteIP = "10.0.1.1";
  1646. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1647. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1648. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1649. try {
  1650. strDong = dong;
  1651. strHo = ho;
  1652. strType = type;
  1653. strTime = time;
  1654. strFileName = filename;
  1655. strUploadFile = uploadfile;
  1656. bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1657. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1658. wallpadDeviceSet.closeDB();
  1659. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
  1660. } catch (RuntimeException re) {
  1661. LogUtil.errorLogInfo("", TAG, re);
  1662. } catch (Exception e) {
  1663. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1664. //e.printStackTrace();
  1665. LogUtil.errorLogInfo("", TAG, e);
  1666. }
  1667. }
  1668. public void run() {
  1669. try {
  1670. mFTPManager = new HDCFTPManager();
  1671. if (!mFTPManager.isFTPConnected()) {
  1672. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1673. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1674. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1675. return;
  1676. }
  1677. }
  1678. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1679. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1680. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1681. return;
  1682. }
  1683. if (!bMainServer2dot0) {
  1684. if (!mFTPManager.setPassiveMode()) {
  1685. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1686. disconnectFTP();
  1687. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1688. return;
  1689. }
  1690. }
  1691. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1692. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1693. disconnectFTP();
  1694. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1695. return;
  1696. }
  1697. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1698. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1699. disconnectFTP();
  1700. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1701. return;
  1702. }
  1703. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1704. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1705. disconnectFTP();
  1706. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1707. return;
  1708. }
  1709. disconnectFTP();
  1710. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1711. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1712. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1713. } catch (RuntimeException re) {
  1714. LogUtil.errorLogInfo("", TAG, re);
  1715. } catch (Exception e) {
  1716. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1717. //e.printStackTrace();
  1718. LogUtil.errorLogInfo("", TAG, e);
  1719. }
  1720. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1721. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1722. }
  1723. public boolean disconnectFTP() {
  1724. try {
  1725. if (mFTPManager.logoutFTP()) {
  1726. if (mFTPManager.disconnectFTP()) {
  1727. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1728. return true;
  1729. }
  1730. }
  1731. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1732. return false;
  1733. } catch (RuntimeException re) {
  1734. LogUtil.errorLogInfo("", TAG, re);
  1735. return false;
  1736. } catch (Exception e) {
  1737. Log.e(TAG, "[Exception] disconnectFTP()");
  1738. //e.printStackTrace();
  1739. LogUtil.errorLogInfo("", TAG, e);
  1740. return false;
  1741. }
  1742. }
  1743. }
  1744. private String extractCallType(String strFileName) {
  1745. try {
  1746. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1747. String[] strParse_01 = strFileName.split("_");
  1748. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1749. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1750. else return "none";
  1751. } catch (RuntimeException re) {
  1752. LogUtil.errorLogInfo("", TAG, re);
  1753. return null;
  1754. } catch (Exception e) {
  1755. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1756. //e.printStackTrace();
  1757. LogUtil.errorLogInfo("", TAG, e);
  1758. return null;
  1759. }
  1760. }
  1761. private String extractFileName(String strTargetFile) {
  1762. try {
  1763. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1764. String[] strParse_01 = strTargetFile.split("/");
  1765. return strParse_01[strParse_01.length - 1];
  1766. } catch (RuntimeException re) {
  1767. LogUtil.errorLogInfo("", TAG, re);
  1768. return null;
  1769. } catch (Exception e) {
  1770. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1771. //e.printStackTrace();
  1772. LogUtil.errorLogInfo("", TAG, e);
  1773. return null;
  1774. }
  1775. }
  1776. private String extractFileTime(String strFileName) {
  1777. try {
  1778. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1779. String[] strParse_01 = strFileName.split("\\.");
  1780. String[] strParse_02 = strParse_01[0].split("_");
  1781. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1782. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1783. // 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);
  1784. return strParse_02[5] + "_" + strParse_02[6];
  1785. } catch (RuntimeException re) {
  1786. LogUtil.errorLogInfo("", TAG, re);
  1787. return null;
  1788. } catch (Exception e) {
  1789. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1790. //e.printStackTrace();
  1791. LogUtil.errorLogInfo("", TAG, e);
  1792. return null;
  1793. }
  1794. }
  1795. String strRemoteURI, strUserID, strPW, strPath;
  1796. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1797. String strKey_Pass = "passwd";
  1798. 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) {
  1799. try {
  1800. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1801. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1802. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1803. visitor_access_info.setResultCtrl(new RetProci() {
  1804. @Override
  1805. public void ProcSuccess() {
  1806. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1807. visitor_access_info.SetItem("ftp_info");
  1808. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1809. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1810. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1811. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1812. strUserID = strReply_User;
  1813. strPW = strReply_PW;
  1814. strPath = strReply_Path;
  1815. strRemoteURI = strPath + "/" + strFileName;
  1816. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1817. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1818. mUploadVisitorPicture.start();
  1819. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1820. // mUploadVisitorPicture.start();
  1821. }
  1822. @Override
  1823. public void ProcError() {
  1824. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1825. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1826. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1827. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1828. }
  1829. @Override
  1830. public void ProcDoing() {
  1831. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1832. }
  1833. });
  1834. return true;
  1835. }
  1836. } catch (RuntimeException re) {
  1837. LogUtil.errorLogInfo("", TAG, re);
  1838. } catch (Exception e) {
  1839. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1840. //e.printStackTrace();
  1841. LogUtil.errorLogInfo("", TAG, e);
  1842. }
  1843. return false;
  1844. }
  1845. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1846. try {
  1847. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1848. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1849. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1850. visitor_upload_complete.setResultCtrl(new RetProci() {
  1851. @Override
  1852. public void ProcSuccess() {
  1853. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1854. }
  1855. @Override
  1856. public void ProcError() {
  1857. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1858. }
  1859. @Override
  1860. public void ProcDoing() {
  1861. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1862. }
  1863. });
  1864. return true;
  1865. }
  1866. } catch (RuntimeException re) {
  1867. LogUtil.errorLogInfo("", TAG, re);
  1868. } catch (Exception e) {
  1869. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1870. //e.printStackTrace();
  1871. LogUtil.errorLogInfo("", TAG, e);
  1872. }
  1873. return false;
  1874. }
  1875. /**
  1876. * 이통사 연동 서비스를 위한 BR
  1877. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1878. *
  1879. * @param kind (String) "lobby" or "home"
  1880. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1881. */
  1882. public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
  1883. try {
  1884. Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
  1885. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1886. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1887. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1888. Intent mIntent = new Intent();
  1889. mIntent.setAction(BR_VISITOR_EVENT);
  1890. mIntent.putExtra("KIND", kind);
  1891. mIntent.putExtra("TIME", datetime);
  1892. mIntent.putExtra("FILENAME", filename);
  1893. getApplicationContext().sendBroadcast(mIntent);
  1894. } catch (RuntimeException re) {
  1895. LogUtil.errorLogInfo("", TAG, re);
  1896. } catch (Exception e) {
  1897. Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
  1898. //e.printStackTrace();
  1899. LogUtil.errorLogInfo("", TAG, e);
  1900. }
  1901. }
  1902. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1903. public void onReceive(Context context, Intent intent) {
  1904. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1905. Bundle bundle;
  1906. WallpadDeviceSet devset;
  1907. Intent newintent;
  1908. boolean CallAppRun = false;
  1909. boolean MgrAppRun = false;
  1910. final String packageName = "com.artncore.apps.ic_wallpad";
  1911. final String packageNameMgr = "com.artncore.managersetting";
  1912. //CallAppRun = getForegroundAPK().equals(packageName);
  1913. // CallAppRun = getCallAppRunning();
  1914. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1915. int base = 7000;
  1916. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  1917. int Menu_Start_Option = 1;
  1918. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1919. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1920. int keyevt = ReceiveEvt.getKeyCode();
  1921. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1922. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1923. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1924. sdata.closeDB();
  1925. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1926. return;
  1927. }
  1928. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1929. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1930. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1931. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1932. mWallpadStatusData.closeDB();
  1933. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1934. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1935. sdata.closeDB();
  1936. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1937. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1938. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1939. int nModelType = Version.getModelType();
  1940. switch (ReceiveEvt.getKeyCode()) {
  1941. case 251: // 현산향 비상버튼 다운 업 처리
  1942. try {
  1943. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1944. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1945. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1946. } else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1947. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1948. }
  1949. }
  1950. } catch (RuntimeException re) {
  1951. LogUtil.errorLogInfo("", TAG, re);
  1952. } catch (Exception e) {
  1953. //e.printStackTrace();
  1954. LogUtil.errorLogInfo("", TAG, e);
  1955. }
  1956. break;
  1957. case WallPadInterface.EVT_RING:
  1958. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1959. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1960. // 전화 수신 링 수신
  1961. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1962. if (Version.getGatewayUsage()) {
  1963. // 국선 시작만 올라온다.
  1964. startIGW300RingGenerator();
  1965. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1966. } else {
  1967. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1968. }
  1969. break;
  1970. case WallPadInterface.EVT_END_RING:
  1971. // 전화 수신 링 종료
  1972. // Jeff added below codes for call app (2018.01.25)
  1973. // This event is managed by WallPadCall
  1974. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  1975. if (Version.getGatewayUsage()) {
  1976. stopIGW300RingGenerator();
  1977. }
  1978. break;
  1979. case WallPadInterface.BTN_EMR:
  1980. case WallPadInterface.BTN_EMR_IHN1010:
  1981. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  1982. // 월패드 비상버튼 입력 SA 와 GLE 공통
  1983. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  1984. if (MgrAppRun) return;
  1985. if (Common.DIAGNOSTIC_MODE) return;
  1986. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1987. return;
  1988. //currentTime = System.currentTimeMillis();
  1989. //if (ALERTTIME > currentTime) break;
  1990. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  1991. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  1992. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  1993. break;
  1994. devset = new WallpadDeviceSet(getApplicationContext());
  1995. int StatusVal = devset.GetDeviceSetted("알람발생");
  1996. devset.closeDB();
  1997. Log.d("imap", "StatusVal : " + StatusVal);
  1998. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  1999. // 보안 처리가 필요함..
  2000. // 지속적으로 이벤트가 들어올 경우 대비
  2001. Common.SendAppFinishReqBR(getApplicationContext());
  2002. newintent = new Intent(Intent.ACTION_MAIN);
  2003. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2004. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2005. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2006. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2007. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2008. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2009. iMAPstartActivity(newintent);
  2010. }
  2011. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2012. if (getIsSubWallpad()) {
  2013. Intent notiIntent = new Intent();
  2014. notiIntent.setAction(define.NOTIFY_ACNAME);
  2015. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2016. getApplicationContext().sendBroadcast(notiIntent);
  2017. }
  2018. break;
  2019. case WallPadInterface.BTN_CALL:
  2020. case WallPadInterface.BTN_CALL_IHN1010:
  2021. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2022. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2023. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2024. // Jeff added below codes for call app (2018.01.25)
  2025. try {
  2026. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2027. if (getIsSubWallpad()) {
  2028. // 서브월패드
  2029. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2030. } else {
  2031. // 메인월패드
  2032. if (MainActivity.bRecordStatus) {
  2033. // 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2034. Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2035. Intent iIntent = new Intent();
  2036. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2037. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
  2038. getApplicationContext().sendBroadcast(iIntent);
  2039. }
  2040. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2041. }
  2042. } catch (RuntimeException re) {
  2043. LogUtil.errorLogInfo("", TAG, re);
  2044. } catch (Exception e) {
  2045. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2046. //e.printStackTrace();
  2047. LogUtil.errorLogInfo("", TAG, e);
  2048. }
  2049. break;
  2050. case WallPadInterface.BTN_OPEN:
  2051. // 월패드 문여림 버튼 입력 상태 SA
  2052. break;
  2053. case WallPadInterface.BTN_DOOR:
  2054. case WallPadInterface.BTN_DOOR_IHN1010:
  2055. // 현관 도어폰 벨 눌림 입력 상태
  2056. // Jeff added below codes for call app (2018.01.25)
  2057. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2058. if (!bWallPadCallLive && !bBlockFrontCall) {
  2059. if (MainActivity.bRecordStatus) {
  2060. // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2061. Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2062. Intent iIntent = new Intent();
  2063. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2064. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
  2065. getApplicationContext().sendBroadcast(iIntent);
  2066. }
  2067. bBlockFrontCall = true;
  2068. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2069. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2070. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2071. try {
  2072. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2073. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2074. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2075. } 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
  2076. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2077. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2078. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2079. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2080. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2081. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2082. }
  2083. if (!Version.getGatewayUsage()) {
  2084. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2085. }
  2086. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2087. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2088. } catch (RuntimeException re) {
  2089. LogUtil.errorLogInfo("", TAG, re);
  2090. } catch (Exception e) {
  2091. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2092. //e.printStackTrace();
  2093. LogUtil.errorLogInfo("", TAG, e);
  2094. }
  2095. } else {
  2096. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2097. }
  2098. break;
  2099. case WallPadInterface.BTN_CAMERA_SET:
  2100. Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
  2101. Intent iIntent = new Intent();
  2102. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2103. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
  2104. getApplicationContext().sendBroadcast(iIntent);
  2105. break;
  2106. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2107. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
  2108. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2109. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
  2110. && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
  2111. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2112. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2113. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2114. if (MgrAppRun) return;
  2115. if (Common.DIAGNOSTIC_MODE) return;
  2116. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  2117. return;
  2118. //currentTime = System.currentTimeMillis();
  2119. //if (ALERTTIME > currentTime) break;
  2120. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2121. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2122. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2123. break;
  2124. devset = new WallpadDeviceSet(getApplicationContext());
  2125. StatusVal = devset.GetDeviceSetted("알람발생");
  2126. devset.closeDB();
  2127. Log.d("imap", "StatusVal : " + StatusVal);
  2128. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2129. // 보안 처리가 필요함..
  2130. // 지속적으로 이벤트가 들어올 경우 대비
  2131. Common.SendAppFinishReqBR(getApplicationContext());
  2132. newintent = new Intent(Intent.ACTION_MAIN);
  2133. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2134. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2135. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2136. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2137. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2138. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2139. iMAPstartActivity(newintent);
  2140. }
  2141. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2142. if (getIsSubWallpad()) {
  2143. Intent notiIntent = new Intent();
  2144. notiIntent.setAction(define.NOTIFY_ACNAME);
  2145. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2146. getApplicationContext().sendBroadcast(notiIntent);
  2147. }
  2148. } else {
  2149. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2150. if (!getEmergencyIOUsage()) {
  2151. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2152. return;
  2153. }
  2154. if (MgrAppRun) {
  2155. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2156. return;
  2157. }
  2158. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2159. break;
  2160. devset = new WallpadDeviceSet(getApplicationContext());
  2161. StatusVal = devset.GetDeviceSetted("알람발생");
  2162. devset.closeDB();
  2163. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2164. Common.SendAppFinishReqBR(getApplicationContext());
  2165. newintent = new Intent(Intent.ACTION_MAIN);
  2166. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2167. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2168. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2169. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2170. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2171. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2172. iMAPstartActivity(newintent);
  2173. }
  2174. }
  2175. break;
  2176. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2177. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2178. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2179. // 대외향의 경우 여기에서 마그네틱이 감지된다.
  2180. if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
  2181. if (MgrAppRun) return;
  2182. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2183. WallPadInterface mWallPadInterface = new WallPadInterface();
  2184. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2185. if (sensorMag == 0) return;
  2186. }
  2187. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2188. break;
  2189. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2190. break;
  2191. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2192. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2193. if (OutGoingSensorWaiting == 0) {
  2194. // wakeupLCD();
  2195. mIOInterface.ctrlLcdWakeUp();
  2196. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2197. SensorThread.start();
  2198. }
  2199. OutGoingSensorWaiting |= SENSOR_MAG;
  2200. } else {
  2201. Common.SendAppFinishReqBR(getApplicationContext());
  2202. newintent = new Intent(Intent.ACTION_MAIN);
  2203. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2204. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2205. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2206. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2207. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2208. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2209. iMAPstartActivity(newintent);
  2210. }
  2211. break;
  2212. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2213. saveBlackoutStatus(true);
  2214. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2215. break;
  2216. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2217. saveBlackoutStatus(false);
  2218. sendBlackoutReleasedBR();
  2219. break;
  2220. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2221. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2222. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2223. if (MgrAppRun) return;
  2224. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2225. break;
  2226. devset = new WallpadDeviceSet(getApplicationContext());
  2227. StatusVal = devset.GetDeviceSetted("피난사다리");
  2228. int LadderSend = devset.getEscapeLadderDownSend();
  2229. String pentHouseHo = devset.getPentHouseHoEscapeLadder();
  2230. devset.closeDB();
  2231. Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
  2232. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2233. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2234. Common.SendAppFinishReqBR(getApplicationContext());
  2235. newintent = new Intent(Intent.ACTION_MAIN);
  2236. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2237. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2238. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2239. if (!pentHouseHo.equals("")) {
  2240. // 윗집이 펜트하우스인 경우
  2241. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2242. } else {
  2243. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  2244. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2245. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  2246. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2247. }
  2248. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2249. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2250. iMAPstartActivity(newintent);
  2251. }
  2252. break;
  2253. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2254. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2255. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2256. {
  2257. // 내부동체가 상태가 변경된 경우
  2258. int[] SensorInfoDB;
  2259. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2260. if (SensorInfoDB[0] != 1) {
  2261. //내부동체가 사용함이면 상태 검사
  2262. return;
  2263. }
  2264. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2265. WallPadInterface mWallPadInterface = new WallPadInterface();
  2266. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2267. if (sensorMag == 0) return;
  2268. }
  2269. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2270. int sensor = devSet.Get_Sensor_Set();
  2271. devSet.closeDB();
  2272. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2273. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2274. break;
  2275. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2276. if (OutGoingSensorWaiting == 0) {
  2277. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2278. SensorThread.start();
  2279. }
  2280. OutGoingSensorWaiting |= SENSOR_IN;
  2281. }
  2282. break;
  2283. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2284. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2285. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2286. {
  2287. // 외부동체가 상태가 변경된 경우
  2288. int[] SensorInfoDB;
  2289. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2290. if (SensorInfoDB[1] != 1) {
  2291. // 외부동체가 사용함이면 상태 검사
  2292. return;
  2293. }
  2294. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2295. WallPadInterface mWallPadInterface = new WallPadInterface();
  2296. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2297. if (sensorMag == 0) return;
  2298. }
  2299. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2300. int sensor = devSet.Get_Sensor_Set();
  2301. devSet.closeDB();
  2302. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2303. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2304. break;
  2305. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2306. break;
  2307. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2308. break;
  2309. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2310. {
  2311. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2312. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2313. break;
  2314. }*/
  2315. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2316. if (OutGoingSensorWaiting == 0) {
  2317. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2318. SensorThread.start();
  2319. }
  2320. OutGoingSensorWaiting |= SENSOR_OUT;
  2321. } else {
  2322. Common.SendAppFinishReqBR(getApplicationContext());
  2323. newintent = new Intent(Intent.ACTION_MAIN);
  2324. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2325. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2326. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2327. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2328. newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2329. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2330. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2331. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2332. iMAPstartActivity(newintent);
  2333. }
  2334. }
  2335. break;
  2336. }
  2337. } else {
  2338. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2339. }
  2340. }
  2341. };
  2342. protected void iMAPstartActivity(Intent intent) {
  2343. try {
  2344. startActivity(intent);
  2345. } catch (RuntimeException re) {
  2346. LogUtil.errorLogInfo("", TAG, re);
  2347. } catch (Exception e) {
  2348. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2349. //e.printStackTrace();
  2350. LogUtil.errorLogInfo("", TAG, e);
  2351. }
  2352. }
  2353. /**
  2354. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2355. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2356. * 1. 현관카메라 키이벤트 수신
  2357. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2358. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2359. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2360. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2361. * 6. 시스템 볼륨 원복
  2362. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2363. */
  2364. AudioManager mAudioManager;
  2365. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2366. Handler mDingDongHandler = new Handler() {
  2367. public void handleMessage(Message msg) {
  2368. try {
  2369. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2370. if (msg.what == 0) {
  2371. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2372. int nVolume = 10;
  2373. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
  2374. nVolume = 12;
  2375. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2376. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2377. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2378. mDingDongHandler.sendEmptyMessage(1);
  2379. } else if (msg.what == 1) {
  2380. // 띵똥 패스 체크
  2381. check1++;
  2382. if (check1 > 200) {
  2383. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2384. finishDingDongHandler();
  2385. check1 = 0;
  2386. return;
  2387. } else {
  2388. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2389. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2390. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2391. }
  2392. } else if (msg.what == 2) {
  2393. // 띵똥 음원 재생
  2394. mIOInterface.ctrlSetTalkPathDoor();
  2395. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2396. } else if (msg.what == 3) {
  2397. mIOInterface.ctrlSetTalkPathNormal();
  2398. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2399. mDingDongHandler.sendEmptyMessage(4);
  2400. } else if (msg.what == 4) {
  2401. // Normal 패스 체크
  2402. check2++;
  2403. if (check2 > 200) {
  2404. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2405. finishDingDongHandler();
  2406. check2 = 0;
  2407. return;
  2408. } else {
  2409. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2410. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2411. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2412. }
  2413. } else if (msg.what == 5) {
  2414. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2415. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2416. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2417. wdb.closeDB();
  2418. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2419. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2420. intent.setAction(define.NOTIFY_ACNAME);
  2421. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2422. sendBroadcast(intent);
  2423. }
  2424. } catch (RuntimeException re) {
  2425. LogUtil.errorLogInfo("", TAG, re);
  2426. finishDingDongHandler();
  2427. } catch (Exception e) {
  2428. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2429. //e.printStackTrace();
  2430. LogUtil.errorLogInfo("", TAG, e);
  2431. finishDingDongHandler();
  2432. }
  2433. }
  2434. };
  2435. private void finishDingDongHandler() {
  2436. try {
  2437. Log.d(TAG, "[finishDingDongHandler]");
  2438. if (mDingDongHandler != null) {
  2439. mDingDongHandler.removeMessages(0);
  2440. mDingDongHandler.removeMessages(1);
  2441. mDingDongHandler.removeMessages(2);
  2442. mDingDongHandler.removeMessages(3);
  2443. mDingDongHandler.removeMessages(4);
  2444. mDingDongHandler.removeMessages(5);
  2445. }
  2446. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2447. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2448. wdb.closeDB();
  2449. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2450. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2451. mIOInterface.ctrlSetTalkPathNormal();
  2452. } catch (RuntimeException re) {
  2453. LogUtil.errorLogInfo("", TAG, re);
  2454. } catch (Exception e) {
  2455. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2456. //e.printStackTrace();
  2457. LogUtil.errorLogInfo("", TAG, e);
  2458. }
  2459. }
  2460. // 외출방범 대기 모드 중 사운드와 센서 체크
  2461. class OutgoingCheckSensor extends Thread {
  2462. public OutgoingCheckSensor() {
  2463. }
  2464. public void run() {
  2465. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2466. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2467. WallPadInterface wpifc = new WallPadInterface();
  2468. mWallpadStatusData.closeDB();
  2469. int checkcount = timedata / 5;
  2470. int i;
  2471. for (i = checkcount; i > 0; i--) {
  2472. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2473. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2474. mWallpadStatusData.closeDB();
  2475. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2476. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2477. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2478. try {
  2479. Thread.sleep(5000);
  2480. } catch (RuntimeException re) {
  2481. LogUtil.errorLogInfo("", TAG, re);
  2482. } catch (Exception e) {
  2483. LogUtil.errorLogInfo("", TAG, e);
  2484. }
  2485. }
  2486. if (i == 0) {
  2487. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2488. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2489. mWallpadStatusData.closeDB();
  2490. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2491. Common.SendAppFinishReqBR(getApplicationContext());
  2492. int base = 7000;
  2493. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  2494. int Menu_Start_Option = 1;
  2495. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2496. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2497. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2498. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2499. String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
  2500. if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
  2501. else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
  2502. else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
  2503. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2504. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2505. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2506. iMAPstartActivity(mIntent);
  2507. }
  2508. }
  2509. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2510. OutGoingSensorWaiting = 0;
  2511. }
  2512. }
  2513. @Override
  2514. public IBinder onBind(Intent arg0) {
  2515. return mMessenger.getBinder();
  2516. //return null;
  2517. }
  2518. public void imapsvrlog(String msg) {
  2519. if (!log_sw) return;
  2520. Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
  2521. }
  2522. public int onStartCommand(Intent intent, int flags, int startID) {
  2523. try {
  2524. try {
  2525. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2526. } catch (RuntimeException re) {
  2527. LogUtil.errorLogInfo("", TAG, re);
  2528. } catch (Exception e) {
  2529. //e.printStackTrace();
  2530. LogUtil.errorLogInfo("", TAG, e);
  2531. }
  2532. getDeviceCtrlOption();
  2533. SvrSock = new iMapSverSocket();
  2534. SvrSock.start();
  2535. } catch (IOException e) {
  2536. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2537. //e.printStackTrace();
  2538. LogUtil.errorLogInfo("", TAG, e);
  2539. }
  2540. try {
  2541. mGleInterface = new jni();
  2542. } catch (RuntimeException re) {
  2543. LogUtil.errorLogInfo("", TAG, re);
  2544. } catch (Exception e) {
  2545. Log.e(TAG, "[Exception] mGleInterface init...");
  2546. //e.printStackTrace();
  2547. LogUtil.errorLogInfo("", TAG, e);
  2548. }
  2549. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2550. AddressSet addr = DBMGR.getAddressMGR();
  2551. DBMGR.closeDB();
  2552. String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
  2553. AddrDong = addr.Dong;
  2554. AddrHo = addr.Ho;
  2555. ho = Integer.valueOf(AddrHo.substring(0, 1));
  2556. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  2557. "<imap ver=\"1.0\" address=\"" + addr.IPAddress + "\" sender=\"" + AddressStr + "\">\r\n";
  2558. Log.d(TAG, "*****************************************");
  2559. Log.d(TAG, "****************SchedulerThread**********");
  2560. Log.d(TAG, "*****************************************");
  2561. ScheServer = new SchedulerThread();
  2562. ScheServer.start();
  2563. // BR 등록 시작
  2564. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2565. IntentFilter mIntentFilter = new IntentFilter();
  2566. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2567. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2568. mIntentFilter = new IntentFilter();
  2569. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2570. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2571. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2572. mIntentFilter = new IntentFilter();
  2573. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2574. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2575. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2576. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2577. mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
  2578. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2579. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2580. // BR 등록 완료
  2581. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2582. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
  2583. IGW200APICheckHandler.sendEmptyMessage(0);
  2584. 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
  2585. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2586. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2587. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2588. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2589. IGW300APICheckHandler.sendEmptyMessage(0);
  2590. }
  2591. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2592. mIOInterface.setEmergencyType();
  2593. Intent notiIntent = new Intent();
  2594. notiIntent.setAction(define.NOTIFY_ACNAME);
  2595. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2596. getApplicationContext().sendBroadcast(notiIntent);
  2597. CheckMainStatus();
  2598. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2599. getAirQualityUsage();
  2600. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2601. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2602. GwCheckThread.start();
  2603. }
  2604. getResidentSafetyCheckSetting();
  2605. return START_STICKY;
  2606. }
  2607. //멀티기기 정보 전송을 위한 추가
  2608. public static final int MSG_REGISTER_CLIENT = 1;
  2609. //public static final int MSG_UNREGISTER_CLIENT = 2;
  2610. public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
  2611. public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
  2612. public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
  2613. public static final int MSG_SEND_TO_ACTIVITY = 4;
  2614. private Messenger mClient = null; // Activity 에서 가져온 Messenger
  2615. String remote_get_home_devices1;
  2616. String remote_get_home_devices2;
  2617. String remote_get_home_devices3;
  2618. int skipCount = 0;
  2619. /**
  2620. * activity로부터 binding 된 Messenger
  2621. */
  2622. private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
  2623. @Override
  2624. public boolean handleMessage(Message msg) {
  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. String sip_result = "ok";
  3028. //sip_result = "ok";
  3029. retXML = XMLHeader + "<service type=\"reply\" name=\"stop_talking\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  3030. Common.SendAppFinishReqBR(getApplicationContext());
  3031. }
  3032. //~add KSJ
  3033. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3034. retXML = iCMDProcDevList(doc);
  3035. } else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3036. retXML = iCMDProcGASControl(elelist);
  3037. } else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3038. // 현대건설 더펜트하우스 와 구분하여 처리
  3039. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3040. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  3041. mWallpadDeviceSet.closeDB();
  3042. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  3043. retXML = iCMDProcChumDamSmartLightControl(doc);
  3044. }
  3045. else {
  3046. retXML = iCMDProcSDPSmartLightControl(doc);
  3047. }
  3048. } else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3049. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3050. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3051. retXML = iCMDProc_I_LightControl(doc);
  3052. } else {
  3053. retXML = iCMDProcLivingLightControl(doc);
  3054. }
  3055. } else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3056. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  3057. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
  3058. || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
  3059. retXML = iCMDProcSDPConcentControl(doc);
  3060. } else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3061. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3062. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3063. } else {
  3064. retXML = iCMDProcMultiSWControl(doc);
  3065. }
  3066. } else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3067. retXML = iCMDProcDoorlockControl(doc);
  3068. } else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3069. retXML = iCMDProcTemperControl(doc);
  3070. } else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3071. retXML = iCMDProcModeControl(doc);
  3072. } else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3073. retXML = iCMDProcVentilControl(doc);
  3074. } else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3075. retXML = iCMDProcCurtainControl(doc);
  3076. } else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3077. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3078. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3079. retXML = iCMDProcEnergyMeterLightControl(doc);
  3080. } else {
  3081. retXML = iCMDProcLightControl(doc);
  3082. }
  3083. } else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3084. retXML = iCMDProcLightBatchControl(elelist);
  3085. }
  3086. else if (cmd.equalsIgnoreCase("remote_access_sysaircon")) {
  3087. retXML = iCMDProcSysairconControl(elelist);
  3088. }
  3089. //모바일 사용자 인증 관련 메시지
  3090. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3091. ProcMobileDevice_AuthNumber(elelist);
  3092. } else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3093. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3094. } else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3095. ProcMobileDevice_Delete(elelist);
  3096. } else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3097. retXML = ProcGetSmartKeyInfo(elelist);
  3098. } else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3099. retXML = ProcGetAppVersionInfo();
  3100. } else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3101. retXML = ProcIgateInitInfo(elelist);
  3102. } else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3103. retXML = ProcElecCarChargeEventInfo(elelist);
  3104. } else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3105. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3106. } else if (cmd.equalsIgnoreCase("check_call_option")) {
  3107. retXML = ProcCheckCallOption();
  3108. } else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3109. retXML = ProcChatSequence(elelist);
  3110. } else if (cmd.equalsIgnoreCase("chat_message")) {
  3111. retXML = ProcChatMessage(elelist);
  3112. } else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3113. retXML = ProcEvacuationLadderOpen(elelist);
  3114. } else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3115. retXML = SmartLightDetailInfo(elelist);
  3116. } else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3117. retXML = KNXDeviceDetailInfo(elelist);
  3118. } else if (cmd.equalsIgnoreCase("set_server_version")) {
  3119. retXML = ProcSetServerChange(elelist);
  3120. } else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
  3121. retXML = iCMDProcOnePass(elelist);
  3122. } else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3123. 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
  3124. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3125. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3126. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3127. }
  3128. } else if (cmd.equalsIgnoreCase("check_resident_safety")) {
  3129. retXML = iCMDProcResidentSafety(elelist);
  3130. }
  3131. break;
  3132. }
  3133. }
  3134. if (retXML != null) {
  3135. imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
  3136. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3137. byte[] outBF = retXML.getBytes("euc-kr");
  3138. outstream.write(outBF);
  3139. outstream.flush();
  3140. try {
  3141. Thread.sleep(3000);
  3142. } catch (RuntimeException re) {
  3143. LogUtil.errorLogInfo("", TAG, re);
  3144. } catch (Exception e) {
  3145. LogUtil.errorLogInfo("", TAG, e);
  3146. }
  3147. iMAPSock.close();
  3148. } else {
  3149. try {
  3150. iMAPSock.close();
  3151. } catch (RuntimeException re) {
  3152. LogUtil.errorLogInfo("", TAG, re);
  3153. } catch (Exception e) {
  3154. LogUtil.errorLogInfo("", TAG, e);
  3155. }
  3156. }
  3157. } catch (RuntimeException re) {
  3158. LogUtil.errorLogInfo("", TAG, re);
  3159. } catch (Exception e) {
  3160. try {
  3161. iMAPSock.close();
  3162. } catch (RuntimeException re) {
  3163. LogUtil.errorLogInfo("", TAG, re);
  3164. } catch (Exception E) {
  3165. LogUtil.errorLogInfo("", TAG, E);
  3166. }
  3167. LogUtil.errorLogInfo("", TAG, e);
  3168. }
  3169. }
  3170. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3171. private void procUpgrade() {
  3172. imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
  3173. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3174. String[] getstate = sdb.GetSystemUpdateStatus();
  3175. sdb.closeDB();
  3176. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3177. for (int i = 0; i < getstate.length; i++) {
  3178. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3179. }
  3180. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3181. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3182. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3183. }
  3184. }
  3185. // " 제거
  3186. private String trimquotation(String sen) {
  3187. sen = sen.replaceAll("\"", "");
  3188. return sen.trim();
  3189. }
  3190. //remote_auscultate 처리
  3191. public String ProcauscultateReq(Document Doc) {
  3192. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3193. NodeList items = Doc.getElementsByTagName("group");
  3194. Node item;
  3195. String itemname = null;
  3196. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3197. SettManager.DeleteSettingData();
  3198. SettManager.DropTable();
  3199. try {
  3200. for (int i = 0; i < items.getLength(); i++) {
  3201. item = items.item(i);
  3202. itemname = GetAttributeVal(item, "type");
  3203. String GetCNT = GetAttributeVal(item, "count");
  3204. if (Integer.parseInt(GetCNT) <= 0)
  3205. continue;
  3206. Element SettingItem = (Element) item;
  3207. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3208. for (int j = 0; j < SettingList.getLength(); j++) {
  3209. Node subdevListitem = SettingList.item(j);
  3210. String devname = trimquotation(subdevListitem.getTextContent());
  3211. SettManager.InsertSettingData(itemname, devname, j);
  3212. }
  3213. }
  3214. } catch (RuntimeException re) {
  3215. LogUtil.errorLogInfo("", TAG, re);
  3216. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3217. SettManager.closeDB();
  3218. return RetVal;
  3219. } catch (Exception e) {
  3220. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3221. //e.printStackTrace();
  3222. LogUtil.errorLogInfo("", TAG, e);
  3223. SettManager.closeDB();
  3224. return RetVal;
  3225. }
  3226. SettManager.closeDB();
  3227. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3228. StatusBeatRequested = true;
  3229. Intent intent = new Intent();
  3230. intent.setAction(define.NOTIFY_ACNAME);
  3231. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
  3232. sendBroadcast(intent);
  3233. return RetVal;
  3234. }
  3235. public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
  3236. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  3237. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n" +
  3238. "<service type=\"request\" name=\"remote_auscultate\">\r\n" +
  3239. " <guidemap devtype=\"homedev\" count=\"4\">\r\n" +
  3240. " <group type=\"ctrl_device\" count=\"5\">\r\n" +
  3241. " <unit>\"light\"</unit>\r\n" +
  3242. " <unit>\"thermostat\"</unit>\r\n" +
  3243. " <unit>\"gas\"</unit>\r\n" +
  3244. " <unit>\"doorlock\"</unit>\r\n" +
  3245. " <unit>\"ventil\"</unit>\r\n" +
  3246. " </group>\r\n" +
  3247. " <group type=\"talk_device\" count=\"4\">\r\n" +
  3248. " <unit>\"sub_homedev\"</unit>\r\n" +
  3249. " <unit>\"kitchen_tv\"</unit>\r\n" +
  3250. " <unit>\"bath_tv\"</unit>\r\n" +
  3251. " <unit>\"bath_phone\"</unit>\r\n" +
  3252. " </group>\r\n" +
  3253. " <group type=\"sensor\" count=\"6\">\r\n" +
  3254. " <unit>\"magnetic\"</unit>\r\n" +
  3255. " <unit>\"bugout\"</unit>\r\n" +
  3256. " <unit>\"bugin\"</unit>\r\n" +
  3257. " <unit>\"fire\"</unit>\r\n" +
  3258. " <unit>\"gas\"</unit>\r\n" +
  3259. " <unit>\"emergency\"</unit>\r\n" +
  3260. " </group>\r\n" +
  3261. " <group type=\"extended\" count=\"4\">\r\n" +
  3262. " <unit>\"gateway\"</unit>\r\n" +
  3263. " <unit>\"smartswitch\"</unit>\r\n" +
  3264. " <unit>\"handy\"</unit>\r\n" +
  3265. " <unit>\"energymeter\"</unit>\r\n" +
  3266. " </group>\r\n" +
  3267. " </guidemap>\r\n" +
  3268. "</service>\r\n" +
  3269. "</imap>\r\n";
  3270. try {
  3271. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3272. DocumentBuilder builder = factory.newDocumentBuilder();
  3273. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3274. Document doc = builder.parse(istream);
  3275. NodeList items = doc.getElementsByTagName("group");
  3276. Node item;
  3277. String itemname = null;
  3278. SettManager.DeleteSettingData();
  3279. SettManager.DropTable();
  3280. for (int i = 0; i < items.getLength(); i++) {
  3281. item = items.item(i);
  3282. itemname = GetAttributeVal(item, "type");
  3283. String GetCNT = GetAttributeVal(item, "count");
  3284. if (Integer.parseInt(GetCNT) <= 0)
  3285. continue;
  3286. Element SettingItem = (Element) item;
  3287. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3288. for (int j = 0; j < SettingList.getLength(); j++) {
  3289. Node subdevListitem = SettingList.item(j);
  3290. String devname = trimquotation(subdevListitem.getTextContent());
  3291. SettManager.InsertSettingData(itemname, devname, j);
  3292. }
  3293. }
  3294. } catch (RuntimeException re) {
  3295. LogUtil.errorLogInfo("", TAG, re);
  3296. } catch (Exception e) {
  3297. //e.printStackTrace();
  3298. LogUtil.errorLogInfo("", TAG, e);
  3299. }
  3300. }
  3301. String MakeFailMessage(String msg) {
  3302. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\"" + msg + "\"</first_failed>\r\n</service>\r\n</imap>";
  3303. }
  3304. //SetInfo의 각 항목들의 무결성 확인
  3305. final String isUse = "사용함";
  3306. final String isNotUse = "사용안함";
  3307. boolean CheckSubdevData(String devName, String devData) {
  3308. String[] SplitedMSG;
  3309. try {
  3310. if (devName.equals("가스밸브")) {
  3311. SplitedMSG = devData.split("[(]");
  3312. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3313. String UseStr = SplitedMSG[2].split("[)]")[0];
  3314. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3315. } else if (devName.equals("디지털도어락")) {
  3316. SplitedMSG = devData.split("[(]");
  3317. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3318. String[] UseStr = SplitedMSG[2].split("[)]");
  3319. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3320. if (!UseStr[1].equals("종류")) return false;
  3321. UseStr = SplitedMSG[3].split("[)]");
  3322. if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
  3323. } else if (devName.equals("온도조절기")) {
  3324. SplitedMSG = devData.split("[(]");
  3325. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3326. String[] UseStr = SplitedMSG[2].split("[)]");
  3327. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3328. } else if (devName.equals("조명제어기")) {
  3329. SplitedMSG = devData.split("[(]");
  3330. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3331. String[] UseStr = SplitedMSG[2].split("[)]");
  3332. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3333. /*
  3334. if (!UseStr[1].equals("종류"))
  3335. return false;
  3336. UseStr = SplitedMSG[3].split("[)]");
  3337. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3338. return false;
  3339. */
  3340. } else if (devName.equals("환기시스템")) {
  3341. SplitedMSG = devData.split("[(]");
  3342. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3343. String[] UseStr = SplitedMSG[2].split("[)]");
  3344. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3345. /*
  3346. if (!UseStr[1].equals("종류"))
  3347. return false;
  3348. UseStr = SplitedMSG[3].split("[)]");
  3349. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  3350. return false;
  3351. */
  3352. } else if (devName.equals("시스템에어컨")) {
  3353. SplitedMSG = devData.split("[(]");
  3354. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3355. String[] UseStr = SplitedMSG[2].split("[)]");
  3356. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3357. } else if (devName.equals("전동커튼")) {
  3358. SplitedMSG = devData.split("[(]");
  3359. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3360. String[] UseStr = SplitedMSG[2].split("[)]");
  3361. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3362. /*
  3363. if (!UseStr[1].equals("종류"))
  3364. return false;
  3365. UseStr = SplitedMSG[3].split("[)]");
  3366. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  3367. return false;
  3368. */
  3369. } else if (devName.equals("실시간검침기")) {
  3370. SplitedMSG = devData.split("[(]");
  3371. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3372. String[] UseStr = SplitedMSG[2].split("[)]");
  3373. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3374. } else if (devName.equals("스마트스위치&일괄소등")) {
  3375. SplitedMSG = devData.split("[(]");
  3376. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3377. String[] UseStr = SplitedMSG[2].split("[)]");
  3378. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3379. /*
  3380. if (!UseStr[1].equals("종류"))
  3381. return false;
  3382. UseStr = SplitedMSG[3].split("[)]");
  3383. if (!UseStr[0].equals("대외향스마트스위치")&&
  3384. !UseStr[0].equals("대외향일괄소등제어기")&&
  3385. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  3386. !UseStr[0].equals("현산향스마트스위치")&&
  3387. !UseStr[0].equals("현산향LCD스마트스위치"))
  3388. return false;
  3389. */
  3390. } else if (devName.equals("무선리모컨")) {
  3391. SplitedMSG = devData.split("[(]");
  3392. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3393. String[] UseStr = SplitedMSG[2].split("[)]");
  3394. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3395. } else if (devName.equals("현관카메라")) {
  3396. SplitedMSG = devData.split("[(]");
  3397. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3398. String[] UseStr = SplitedMSG[2].split("[)]");
  3399. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3400. /*
  3401. if (!UseStr[1].equals("종류"))
  3402. return false;
  3403. UseStr = SplitedMSG[3].split("[)]");
  3404. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  3405. return false;
  3406. */
  3407. } else if (devName.equals("공지사항")) {
  3408. SplitedMSG = devData.split("[(]");
  3409. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3410. String[] UseStr = SplitedMSG[2].split("[)]");
  3411. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3412. } else if (devName.equals("날씨")) {
  3413. SplitedMSG = devData.split("[(]");
  3414. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3415. String[] UseStr = SplitedMSG[2].split("[)]");
  3416. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3417. } else if (devName.equals("메모")) {
  3418. SplitedMSG = devData.split("[(]");
  3419. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3420. String[] UseStr = SplitedMSG[2].split("[)]");
  3421. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3422. } else if (devName.equals("전자액자")) {
  3423. SplitedMSG = devData.split("[(]");
  3424. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3425. String[] UseStr = SplitedMSG[2].split("[)]");
  3426. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3427. } else if (devName.equals("일정표")) {
  3428. SplitedMSG = devData.split("[(]");
  3429. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3430. String[] UseStr = SplitedMSG[2].split("[)]");
  3431. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3432. } else if (devName.equals("주차확인")) {
  3433. SplitedMSG = devData.split("[(]");
  3434. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3435. String[] UseStr = SplitedMSG[2].split("[)]");
  3436. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3437. /*
  3438. UseStr = SplitedMSG[3].split("[)]");
  3439. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3440. return false;
  3441. */
  3442. } else if (devName.equals("시간설정")) {
  3443. SplitedMSG = devData.split("[(]");
  3444. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3445. String[] UseStr = SplitedMSG[2].split("[)]");
  3446. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3447. } else if (devName.equals("원격검침")) {
  3448. SplitedMSG = devData.split("[(]");
  3449. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3450. String[] UseStr = SplitedMSG[2].split("[)]");
  3451. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3452. } else if (devName.equals("뮤직")) {
  3453. SplitedMSG = devData.split("[(]");
  3454. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3455. String[] UseStr = SplitedMSG[2].split("[)]");
  3456. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3457. } else if (devName.equals("영상재생")) {
  3458. SplitedMSG = devData.split("[(]");
  3459. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3460. String[] UseStr = SplitedMSG[2].split("[)]");
  3461. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3462. } else if (devName.equals("CCTV")) {
  3463. SplitedMSG = devData.split("[(]");
  3464. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3465. String[] UseStr = SplitedMSG[2].split("[)]");
  3466. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3467. /*
  3468. UseStr = SplitedMSG[3].split("[)]");
  3469. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3470. return false;
  3471. */
  3472. } else if (devName.equals("명칭설정")) {
  3473. SplitedMSG = devData.split("[(]");
  3474. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3475. String[] UseStr = SplitedMSG[2].split("[)]");
  3476. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3477. } else if (devName.equals("출동경비")) {
  3478. SplitedMSG = devData.split("[(]");
  3479. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3480. String[] UseStr = SplitedMSG[2].split("[)]");
  3481. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3482. } else if (devName.equals("경비실영상통화")) {
  3483. SplitedMSG = devData.split("[(]");
  3484. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3485. String[] UseStr = SplitedMSG[2].split("[)]");
  3486. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3487. } else if (devName.equals("엘리베이터")) {
  3488. SplitedMSG = devData.split("[(]");
  3489. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3490. String[] UseStr = SplitedMSG[2].split("[)]");
  3491. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3492. /*
  3493. UseStr = SplitedMSG[3].split("[)]");
  3494. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3495. return false;
  3496. */
  3497. } else if (devName.equals("현장특화기능")) {
  3498. SplitedMSG = devData.split("[(]");
  3499. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3500. String[] UseStr = SplitedMSG[2].split("[)]");
  3501. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3502. /*
  3503. UseStr = SplitedMSG[3].split("[)]");
  3504. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3505. return false;
  3506. */
  3507. } else if (devName.equals("월패드카메라")) {
  3508. SplitedMSG = devData.split("[(]");
  3509. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3510. String[] UseStr = SplitedMSG[2].split("[)]");
  3511. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3512. } else if (devName.equals("무드등")) {
  3513. SplitedMSG = devData.split("[(]");
  3514. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3515. String[] UseStr = SplitedMSG[2].split("[)]");
  3516. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3517. /*
  3518. UseStr = SplitedMSG[3].split("[)]");
  3519. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3520. return false;
  3521. */
  3522. } else if (devName.equals("피난사다리")) {
  3523. SplitedMSG = devData.split("[(]");
  3524. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3525. String[] UseStr = SplitedMSG[2].split("[)]");
  3526. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3527. } else if (devName.equals("동체설정")) {
  3528. return true;
  3529. /*
  3530. SplitedMSG = devData.split("[(]");
  3531. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3532. return false;
  3533. String[] UseStr = SplitedMSG[2].split("[)]");
  3534. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3535. return false;
  3536. if (UseStr[0].equals(isNotUse)) return true;
  3537. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3538. return false;
  3539. for (int i=3; i < SplitedMSG.length; i++)
  3540. {
  3541. UseStr = SplitedMSG[i].split("[)]");
  3542. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3543. return false;
  3544. if (i != SplitedMSG.length-1)
  3545. {
  3546. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3547. return false;
  3548. }
  3549. }
  3550. */
  3551. } else if (devName.equals("알람발생")) {
  3552. SplitedMSG = devData.split("[(]");
  3553. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3554. String[] UseStr = SplitedMSG[2].split("[)]");
  3555. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3556. } else if (devName.equals("UI순서")) {
  3557. SplitedMSG = devData.split("[(]");
  3558. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3559. String[] UseStr = SplitedMSG[2].split("[)]");
  3560. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3561. } else {
  3562. Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
  3563. Log.w("iMAP", "Return true");
  3564. return true;
  3565. }
  3566. } catch (RuntimeException re) {
  3567. LogUtil.errorLogInfo("", TAG, re);
  3568. return false;
  3569. } catch (Exception e) {
  3570. //e.printStackTrace();
  3571. LogUtil.errorLogInfo("", TAG, e);
  3572. return false;
  3573. }
  3574. return true;
  3575. }
  3576. public String ProcSetsetup(Document ele) {
  3577. Common.DebugLog("ProcSetsetup------------------------->");
  3578. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3579. NodeList items = ele.getElementsByTagName("setting");
  3580. Node item;
  3581. String itemname = null;
  3582. String dateData = null;
  3583. String heartbeatP = null;
  3584. String Versions = null;
  3585. String SdbAccInit_Str = null;
  3586. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3587. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3588. if (!SettManager.StartTransaction()) {
  3589. ResetFlag = false;
  3590. RetVal += "\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3591. SettManager.EndTransaction(false);
  3592. SettManager.closeDB();
  3593. return RetVal;
  3594. }
  3595. try {
  3596. for (int i = 0; i < items.getLength(); i++) {
  3597. item = items.item(i);
  3598. itemname = GetAttributeVal(item, "name");
  3599. if (itemname != null) {
  3600. if (itemname.equals("beat_time")) {
  3601. heartbeatP = GetAttributeVal(item, "value");
  3602. } else if (itemname.equals("ver_setting")) {
  3603. Versions = GetAttributeVal(item, "value");
  3604. } else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3605. Element guardlist = (Element) item;
  3606. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3607. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3608. else continue;
  3609. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3610. Node GuardListitem = GuardCTList.item(j);
  3611. String guardname = GetAttributeVal(GuardListitem, "name");
  3612. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3613. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3614. }
  3615. } else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3616. Element subdevList = (Element) item;
  3617. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3618. for (int j = 0; j < SubDevList.getLength(); j++) {
  3619. Node subdevListitem = SubDevList.item(j);
  3620. String devname = GetAttributeVal(subdevListitem, "name");
  3621. String devval = GetAttributeVal(subdevListitem, "value");
  3622. if (devname != null && devval != null) {
  3623. devname = devname.replaceAll("\\p{Z}", "");
  3624. devval = devval.replaceAll("\\p{Z}", "");
  3625. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  3626. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3627. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3628. }
  3629. if (CheckSubdevData(devname, devval) == false) {
  3630. ResetFlag = false;
  3631. Log.w("iMAP", "Set Setup Fail name : " + devname + " Value : " + devval);
  3632. SettManager.EndTransaction(false);
  3633. SettManager.closeDB();
  3634. return MakeFailMessage(devname);
  3635. }
  3636. String[] SettingDBValue = SettManager.GetSettingData(devname);
  3637. if (SettingDBValue != null) {
  3638. String devInfo = SettingDBValue[1];
  3639. if (devInfo.equals(devval) == false) {
  3640. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3641. Log.w("iMAP", "DB Setup Value : " + devInfo);
  3642. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3643. ResetFlag = true;
  3644. }
  3645. } else {
  3646. Log.w("iMAP", "DB No Setup Name and Value");
  3647. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3648. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3649. ResetFlag = true;
  3650. }
  3651. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3652. if (devname.equals("로고설정")) {
  3653. String devInfo = devval;
  3654. devInfo = devInfo.replace('(', '_');
  3655. devInfo = devInfo.replace(':', '_');
  3656. devInfo = devInfo.replace(')', '_');
  3657. String[] DetailInfo = devInfo.split("_");
  3658. int LogoType = 0;
  3659. if (DetailInfo[5].equals("표시안함") == true) {
  3660. LogoType = 0;
  3661. } else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3662. LogoType = 1;
  3663. } else if (DetailInfo[5].equals("양우내안애") == true) {
  3664. LogoType = 2;
  3665. } else if (DetailInfo[5].equals("GSITM") == true) {
  3666. LogoType = 3;
  3667. } else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3668. LogoType = 4;
  3669. } else if (DetailInfo[5].equals("거실조명표시") == true) {
  3670. LogoType = 5;
  3671. } else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3672. LogoType = 6;
  3673. } else if (DetailInfo[5].equals("기타1") == true) {
  3674. LogoType = 7;
  3675. } else if (DetailInfo[5].equals("기타2") == true) {
  3676. LogoType = 8;
  3677. }
  3678. if ((LogoType >= 0) && (LogoType <= 8)) {
  3679. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3680. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3681. }
  3682. } else if (devname.equals("엘리베이터위젯복구")) {
  3683. String devInfo = devval;
  3684. devInfo = devInfo.replace('(', '_');
  3685. devInfo = devInfo.replace(':', '_');
  3686. devInfo = devInfo.replace(')', '_');
  3687. String[] DetailInfo = devInfo.split("_");
  3688. if (DetailInfo[3].equals("사용함") == true) {
  3689. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3690. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3691. }
  3692. } else if (devname.equals("분전반알람설정")) {
  3693. try {
  3694. String devInfo = devval;
  3695. devInfo = devInfo.replace('(', '_');
  3696. devInfo = devInfo.replace(':', '_');
  3697. devInfo = devInfo.replace(')', '_');
  3698. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3699. //[0] - 기기번호
  3700. //[1] - 회로수
  3701. //[2] - 기기이름
  3702. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3703. //[4] - 명칭
  3704. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3705. String[] DetailInfo = devInfo.split("_");
  3706. for (int a = 0; a < DetailInfo.length; a++) {
  3707. if (DetailInfo[a].equals("누적전력초기화")) {
  3708. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3709. if ((a + 1) <= DetailInfo.length) {
  3710. // 설정정보가 존재해야 인식하도록 함
  3711. if (DetailInfo[a + 1].equals("1")) {
  3712. // 1(사용함) 일때
  3713. if (sdbAPI != null) {
  3714. if (sdbAPI.Set_AccPwReset() >= 0) {
  3715. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3716. } else {
  3717. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3718. }
  3719. }
  3720. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3721. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3722. }
  3723. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3724. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3725. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3726. }
  3727. }
  3728. }
  3729. } catch (RuntimeException re) {
  3730. LogUtil.errorLogInfo("", TAG, re);
  3731. } catch (Exception e) {
  3732. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3733. //e.printStackTrace();
  3734. LogUtil.errorLogInfo("", TAG, e);
  3735. }
  3736. } else if (devname.equals("욕실폰통화음량값")) {
  3737. Intent Iintent = new Intent();
  3738. Iintent.setAction(define.NOTIFY_ACNAME);
  3739. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3740. sendBroadcast(Iintent);
  3741. } else if (devname.equals("주방TV통화음량값")) {
  3742. Intent Iintent = new Intent();
  3743. Iintent.setAction(define.NOTIFY_ACNAME);
  3744. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3745. sendBroadcast(Iintent);
  3746. } else if (devname.equals("현관카메라")) {
  3747. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  3748. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3749. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3750. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  3751. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3752. String devInfo = devval;
  3753. if (devInfo != null) {
  3754. devInfo = devInfo.replace('(', '_');
  3755. devInfo = devInfo.replace(':', '_');
  3756. devInfo = devInfo.replace(')', '_');
  3757. String[] DetailInfo = devInfo.split("_");
  3758. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3759. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  3760. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3761. if (mIOInterface != null)
  3762. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3763. } else {
  3764. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  3765. if (mIOInterface != null)
  3766. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3767. }
  3768. }
  3769. }
  3770. }
  3771. } else if (devname.equals("거동수상자녹화")) {
  3772. String devInfo = devval;
  3773. devInfo = devInfo.replace('(', '_');
  3774. devInfo = devInfo.replace(':', '_');
  3775. devInfo = devInfo.replace(')', '_');
  3776. String[] DetailInfo = devInfo.split("_");
  3777. } else if (devname.equals("스마트현관카메라좌우반전")) {
  3778. String devInfo = devval;
  3779. if (devInfo != null) {
  3780. devInfo = devInfo.replace('(', '_');
  3781. devInfo = devInfo.replace(':', '_');
  3782. devInfo = devInfo.replace(')', '_');
  3783. }
  3784. String[] DetailInfo = devInfo.split("_");
  3785. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3786. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3787. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3788. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3789. } else {
  3790. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  3791. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  3792. }
  3793. }
  3794. } else {
  3795. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3796. }
  3797. }
  3798. }
  3799. } else if (itemname.equals("datetime")) {
  3800. dateData = GetAttributeVal(item, "value");
  3801. } else {
  3802. String GetVal = GetAttributeVal(item, "value");
  3803. if (GetVal != null) {
  3804. if (!GetVal.equals("list")) {
  3805. if (itemname.equals("site_code")) {
  3806. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3807. if (Existing_SiteCode_Array == null) {
  3808. ResetFlag = true;
  3809. } else {
  3810. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3811. if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
  3812. ResetFlag = true;
  3813. }
  3814. }
  3815. }
  3816. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3817. } else {
  3818. String GetCNT = GetAttributeVal(item, "count");
  3819. if (Integer.parseInt(GetCNT) <= 0) continue;
  3820. Element SettingItem = (Element) item;
  3821. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3822. for (int j = 0; j < SettingList.getLength(); j++) {
  3823. Node subdevListitem = SettingList.item(j);
  3824. String devname = GetAttributeVal(subdevListitem, "name");
  3825. String devval = GetAttributeVal(subdevListitem, "value");
  3826. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3827. }
  3828. }
  3829. }
  3830. }
  3831. }
  3832. }
  3833. } catch (RuntimeException re) {
  3834. LogUtil.errorLogInfo("", TAG, re);
  3835. ResetFlag = false;
  3836. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3837. SettManager.EndTransaction(false);
  3838. SettManager.closeDB();
  3839. return RetVal;
  3840. } catch (Exception e) {
  3841. ResetFlag = false;
  3842. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3843. //e.printStackTrace();
  3844. LogUtil.errorLogInfo("", TAG, e);
  3845. SettManager.EndTransaction(false);
  3846. SettManager.closeDB();
  3847. return RetVal;
  3848. }
  3849. SettManager.EndTransaction(true);
  3850. SettManager.closeDB();
  3851. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3852. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3853. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3854. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3855. }
  3856. if (AfterTransactionTodoList != null) {
  3857. if (AfterTransactionTodoList.size() > 0) {
  3858. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3859. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3860. if (afterTransactionTodoListData != null) {
  3861. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3862. WallpadSalesSampleData mWallpadSalesSampleData;
  3863. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3864. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3865. mWallpadSalesSampleData.closeDB();
  3866. } else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3867. //ifdb에 있는지
  3868. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3869. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3870. int result = devSet.Get_Elevator_Info();
  3871. devSet.closeDB();
  3872. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3873. // 엘리베이터가 사용함이면
  3874. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3875. boolean result_get_restoreUseOrNot;
  3876. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3877. if (wdb != null) {
  3878. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3879. if (result_get_restoreUseOrNot == false) {
  3880. wdb.SetElevator_Widget_Restore(true);
  3881. //위젯 DB 초기화
  3882. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3883. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3884. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3885. devSet2.initWidgetData();
  3886. devSet2.closeDB();
  3887. }
  3888. }
  3889. wdb.closeDB();
  3890. }
  3891. }
  3892. }
  3893. }
  3894. }
  3895. }
  3896. }
  3897. if (dateData != null) {
  3898. try {
  3899. int year = Integer.parseInt(dateData.substring(0, 4));
  3900. int month = Integer.parseInt(dateData.substring(4, 6));
  3901. int day = Integer.parseInt(dateData.substring(6, 8));
  3902. int hour = Integer.parseInt(dateData.substring(8, 10));
  3903. int min = Integer.parseInt(dateData.substring(10, 12));
  3904. int sec = Integer.parseInt(dateData.substring(12, 14));
  3905. Calendar nowdate = new GregorianCalendar();
  3906. long settedtime = nowdate.getTimeInMillis();
  3907. nowdate.set(Calendar.YEAR, year);
  3908. nowdate.set(Calendar.MONTH, month);
  3909. nowdate.set(Calendar.DAY_OF_MONTH, day);
  3910. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  3911. nowdate.set(Calendar.MINUTE, min);
  3912. nowdate.set(Calendar.SECOND, sec);
  3913. long bootupmil = nowdate.getTimeInMillis();
  3914. if (Math.abs(bootupmil - settedtime) > 5000) {
  3915. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3916. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  3917. DBMGR.closeDB();
  3918. Intent Iintent = new Intent();
  3919. Iintent.setAction(define.NOTIFY_ACNAME);
  3920. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  3921. sendBroadcast(Iintent);
  3922. }
  3923. } catch (RuntimeException re) {
  3924. LogUtil.errorLogInfo("", TAG, re);
  3925. } catch (Exception e) {
  3926. //e.printStackTrace();
  3927. LogUtil.errorLogInfo("", TAG, e);
  3928. }
  3929. }
  3930. if (heartbeatP != null) {
  3931. try {
  3932. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3933. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  3934. DBMGR.closeDB();
  3935. } catch (RuntimeException re) {
  3936. LogUtil.errorLogInfo("", TAG, re);
  3937. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3938. SettManager.closeDB();
  3939. return RetVal;
  3940. } catch (Exception e) {
  3941. //e.printStackTrace();
  3942. LogUtil.errorLogInfo("", TAG, e);
  3943. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  3944. SettManager.closeDB();
  3945. return RetVal;
  3946. }
  3947. }
  3948. if (Versions != null) {
  3949. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  3950. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  3951. DBMGR.SetSettingVer(Versions);
  3952. DBMGR.closeDB();
  3953. }
  3954. Intent intent = new Intent();
  3955. intent.setAction(define.NOTIFY_ACNAME);
  3956. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  3957. getApplicationContext().sendBroadcast(intent);
  3958. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3959. return RetVal;
  3960. }
  3961. public String ProcNotifyparcel(Document doc) {
  3962. String moveInfo = "null";
  3963. String boxNo = "null";
  3964. String serviceInfo = "null";
  3965. String receiverInfo = "null";
  3966. String message = "null";
  3967. int remainCnt = 0;
  3968. try {
  3969. NodeList param = doc.getElementsByTagName("move_info");
  3970. Node item = param.item(0);
  3971. moveInfo = trimquotation(item.getTextContent());
  3972. param = doc.getElementsByTagName("params");
  3973. item = param.item(0);
  3974. if (item != null) {
  3975. boxNo = GetAttributeVal(item, "box_num");
  3976. serviceInfo = GetAttributeVal(item, "service_info");
  3977. receiverInfo = GetAttributeVal(item, "receiver_info");
  3978. message = GetAttributeVal(item, "message");
  3979. if (message != null) {
  3980. String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
  3981. if (msgList[0].equalsIgnoreCase("remains")) {
  3982. remainCnt = Integer.parseInt(msgList[1]);
  3983. if (remainCnt > 0) {
  3984. wakeupLCD();
  3985. Intent intent = new Intent();
  3986. intent.setAction(define.NOTIFY_ACNAME);
  3987. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  3988. intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
  3989. intent.putExtra("BOX_NO", boxNo);
  3990. intent.putExtra("SERVICE_INFO", serviceInfo);
  3991. intent.putExtra("RECEIVER_INFO", receiverInfo);
  3992. intent.putExtra("REMAIN_CNT", remainCnt);
  3993. getApplicationContext().sendBroadcast(intent);
  3994. }
  3995. }
  3996. }
  3997. }
  3998. String retVal = XMLHeader +
  3999. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n" +
  4000. "</imap>\r\n";
  4001. return retVal;
  4002. } catch (RuntimeException re) {
  4003. LogUtil.errorLogInfo("", TAG, re);
  4004. String retVal = XMLHeader +
  4005. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4006. "</imap>\r\n";
  4007. return retVal;
  4008. } catch (Exception e) {
  4009. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4010. //e.printStackTrace();
  4011. LogUtil.errorLogInfo("", TAG, e);
  4012. String retVal = XMLHeader +
  4013. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4014. "</imap>\r\n";
  4015. return retVal;
  4016. }
  4017. }
  4018. public String ProcNotiPostInfo(Document doc) {
  4019. NodeList param = doc.getElementsByTagName("move_info");
  4020. Node item = param.item(0);
  4021. String aa = item.getTextContent();
  4022. aa = trimquotation(aa);
  4023. if (item != null) {
  4024. String info = item.getTextContent();
  4025. if (info != null) {
  4026. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4027. if (info.contains("post_in")) { // 우편물 보관
  4028. wakeupLCD();
  4029. int itemCount = -1;
  4030. param = doc.getElementsByTagName("params");
  4031. item = param.item(0);
  4032. if (item != null) {
  4033. String devname = GetAttributeVal(item, "message");
  4034. if (devname != null) {
  4035. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4036. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4037. if (msgList[0].equalsIgnoreCase("remains")) {
  4038. itemCount = Integer.parseInt(msgList[1]);
  4039. }
  4040. }
  4041. }
  4042. }
  4043. if (itemCount > 0) {
  4044. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4045. Intent intent = new Intent();
  4046. intent.setAction(define.NOTIFY_ACNAME);
  4047. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4048. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4049. intent.putExtra("ITEM", itemCount);
  4050. getApplicationContext().sendBroadcast(intent);
  4051. }
  4052. }
  4053. }
  4054. }
  4055. String retVal = XMLHeader +
  4056. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n" +
  4057. "</imap>\r\n";
  4058. return retVal;
  4059. }
  4060. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4061. public String ProcNotifypark(Document doc)
  4062. {
  4063. String MoveInfo = "none";
  4064. NodeList param = doc.getElementsByTagName("destination");
  4065. Node item = param.item(0);
  4066. if (item != null)
  4067. {
  4068. String dong = GetAttributeVal(item, "id_high").trim();
  4069. String ho = GetAttributeVal(item, "id_low").trim();
  4070. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4071. return (XMLHeader +
  4072. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4073. "</imap>\r\n");
  4074. }
  4075. param = doc.getElementsByTagName("move_info");
  4076. item = param.item(0);
  4077. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4078. param = doc.getElementsByTagName("params");
  4079. item = param.item(0);
  4080. if (item != null)
  4081. {
  4082. String carnum = GetAttributeVal(item, "car_num");
  4083. String locinfo = GetAttributeVal(item, "loc_info");
  4084. String msg = GetAttributeVal(item, "message");
  4085. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4086. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4087. parkdb.closeDB();Intent intent = new Intent();
  4088. intent.setAction(define.NOTIFY_ACNAME);
  4089. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4090. getApplicationContext().sendBroadcast(intent);
  4091. }
  4092. String retVal = XMLHeader +
  4093. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4094. "</imap>\r\n";
  4095. return retVal;
  4096. }
  4097. */
  4098. public String ProcGetsetup(Document doc) {
  4099. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4100. NodeList items = doc.getElementsByTagName("variable");
  4101. String RetVal = XMLHeader + "<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n" +
  4102. " <guidemap devtype=\"homedev\" count=\"" + items.getLength() + "\">\r\n";
  4103. Node item;
  4104. try {
  4105. for (int i = 0; i < items.getLength(); i++) {
  4106. item = items.item(i);
  4107. //String mRealTimeMeterData = item.getNodeValue();
  4108. String data = trimquotation(item.getTextContent());
  4109. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4110. if (gData.size() == 1) {
  4111. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + gData.get(0)[1] + "\" />\r\n";
  4112. } else if (gData.size() > 1) {
  4113. RetVal += " <setting name=\"" + data + "\" count=\"" + gData.size() + "\" value=\"list\" >\r\n";
  4114. RetVal += " <list name=\"DeviceInfo\" value=\"" + Build.MODEL + "/" + getAOSVerCode() + "\" />\r\n";
  4115. for (int k = 0; k < gData.size(); k++) {
  4116. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4117. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4118. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4119. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4120. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4121. }
  4122. RetVal += " <list name=\"" + gData.get(k)[0] + "\" value=\"" + gData.get(k)[1] + "\" />\r\n";
  4123. }
  4124. if (bAirQualityEnable) {
  4125. RetVal += " <list name=\"공기질센서버전\" value=\"" + getAirQualityInfo() + "\" />\r\n";
  4126. }
  4127. RetVal += " </setting>\r\n";
  4128. } else {
  4129. if (data.equals("beat_time")) {
  4130. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4131. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4132. DBMGR.closeDB();
  4133. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + heartbeatP + "\" />\r\n";
  4134. } else if (data.equals("ver_setting")) {
  4135. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4136. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + DBMGR.GetSettingVer() + "\" />\r\n";
  4137. DBMGR.closeDB();
  4138. } else if (data.equals("datetime")) {
  4139. Calendar cal = new GregorianCalendar();
  4140. 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";
  4141. } else if (data.equals("security_state")) {
  4142. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4143. int alarmST = DBMGR.GetAlarmStatus();
  4144. String SEC_ST;
  4145. if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
  4146. else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
  4147. else SEC_ST = "normal";
  4148. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + SEC_ST + "\" />\r\n";
  4149. DBMGR.closeDB();
  4150. } else if (data.equals("sensor_state")) {
  4151. int senIDX = 0;
  4152. String resultStr = "";
  4153. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4154. int BugSensor = DBMGR.Get_Sensor_Set();
  4155. WallPadInterface wpifc = new WallPadInterface();
  4156. if (BugSensor > 0) {
  4157. if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4158. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4159. String Senret;
  4160. if (outSen > 0) Senret = "detect";
  4161. else Senret = "undetect";
  4162. resultStr += " <list name=\"in_move\" count=\"0\" value=\"" + Senret + "\" />\r\n";
  4163. senIDX++;
  4164. } else {
  4165. if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4166. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4167. String Senret;
  4168. if (outSen > 0) Senret = "detect";
  4169. else Senret = "undetect";
  4170. resultStr += " <list name=\"in_move\" value=\"" + Senret + "\" />\r\n";
  4171. senIDX++;
  4172. }
  4173. if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4174. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4175. String Senret;
  4176. if (outSen > 0) Senret = "detect";
  4177. else Senret = "undetect";
  4178. resultStr += " <list name=\"out_move\" value=\"" + Senret + "\" />\r\n";
  4179. senIDX++;
  4180. }
  4181. }
  4182. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4183. String Senret;
  4184. if (outSen > 0) Senret = "detect";
  4185. else Senret = "undetect";
  4186. resultStr += " <list name=\"magnetic\" value=\"" + Senret + "\" />\r\n";
  4187. senIDX++;
  4188. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4189. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4190. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4191. if (outSen > 0) Senret = "detect";
  4192. else Senret = "undetect";
  4193. resultStr += " <list name=\"emergency\" value=\"" + Senret + "\" />\r\n";
  4194. senIDX++;
  4195. }
  4196. DBMGR.closeDB();
  4197. }
  4198. if (senIDX > 0) {
  4199. RetVal += " <setting name = \"sensor_state\" count = \"" + senIDX + "\" value = \"list\" >\r\n";
  4200. RetVal += resultStr;
  4201. RetVal += " </setting>\r\n";
  4202. }
  4203. } else if (data.equals("statusbeat_time")) {
  4204. } else {
  4205. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"\" />\r\n";
  4206. }
  4207. }
  4208. }
  4209. } catch (RuntimeException re) {
  4210. LogUtil.errorLogInfo("", TAG, re);
  4211. } catch (Exception e) {
  4212. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4213. //e.printStackTrace();
  4214. LogUtil.errorLogInfo("", TAG, e);
  4215. }
  4216. SettManager.closeDB();
  4217. RetVal += " </guidemap>\r\n </service>\r\n</imap>";
  4218. return RetVal;
  4219. }
  4220. public void ProcElevatorinfo(Element ele) {
  4221. try {
  4222. String floor;
  4223. String move_dir;
  4224. /*
  4225. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4226. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4227. Node info = evinfo.item(0);
  4228. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4229. if (info != null)
  4230. {
  4231. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4232. }
  4233. */
  4234. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4235. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
  4236. Node iinfo = ievinfo.item(0);
  4237. if (iinfo == null) {
  4238. Log.d("iMapServer", "func ProcElevatorinfo info == null");
  4239. return;
  4240. }
  4241. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4242. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4243. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4244. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4245. if (move_dir != null) {
  4246. if (move_dir.equalsIgnoreCase("up")) {
  4247. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4248. } else if (move_dir.equalsIgnoreCase("down")) {
  4249. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4250. } else if (move_dir.equalsIgnoreCase("stop")) {
  4251. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4252. } else if (move_dir.equalsIgnoreCase("wrong")) {
  4253. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4254. } else if (move_dir.equalsIgnoreCase("finish")) {
  4255. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4256. }
  4257. Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
  4258. }
  4259. byte updown = 0x00;
  4260. if (ievinfo != null) {
  4261. boolean downCall = false;
  4262. boolean upCall = false;
  4263. for (int i = 0; i < ievinfo.getLength(); i++) {
  4264. Node valItem = ievinfo.item(i);
  4265. if (valItem != null) {
  4266. if (downCall == false) {
  4267. String val = GetAttributeVal(valItem, "ev_call_dir");
  4268. if (val != null)
  4269. downCall = val.equalsIgnoreCase("down");
  4270. }
  4271. if (upCall == false) {
  4272. String val = GetAttributeVal(valItem, "ev_call_dir");
  4273. if (val != null) {
  4274. upCall = val.equalsIgnoreCase("up");
  4275. }
  4276. }
  4277. }
  4278. }
  4279. Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
  4280. if (downCall == true && upCall == true) updown = 0x02;
  4281. else if (downCall == false && upCall == true) updown = 0x01;
  4282. }
  4283. Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  4284. Intent intent = new Intent();
  4285. intent.setAction(define.NOTIFY_ACNAME);
  4286. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  4287. intent.putExtra(define.NOTIBR_FLOOR, floor);
  4288. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  4289. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  4290. getApplicationContext().sendBroadcast(intent);
  4291. } catch (RuntimeException re) {
  4292. LogUtil.errorLogInfo("", TAG, re);
  4293. } catch (Exception e) {
  4294. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  4295. //e.printStackTrace();
  4296. LogUtil.errorLogInfo("", TAG, e);
  4297. }
  4298. }
  4299. private String MakeTargetStr(WallpadiCMDParser data) {
  4300. return " <target name=\"" + data.target + "\" id = \"" + data.tid + "\" msg_no=\"" + data.msgno + "\"/>\r\n";
  4301. }
  4302. public String iCMDProcVentilControl(Document doc) {
  4303. try {
  4304. String unit_status = "null", mode = "null", unit_mode = "null";
  4305. String retStr = CheckiCMDProc("remote_access_ventil");
  4306. if (retStr != null) return retStr;
  4307. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  4308. String target = "null", tid = "null", msgno = "null";
  4309. NodeList items = doc.getElementsByTagName("target");
  4310. Node item = items.item(0);
  4311. if (item != null) {
  4312. NamedNodeMap attrs = item.getAttributes();
  4313. for (int j = 0; j < attrs.getLength(); j++) {
  4314. Node attr = attrs.item(j);
  4315. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4316. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4317. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4318. msgno = attr.getNodeValue();
  4319. }
  4320. }
  4321. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4322. if (NewServerUse()) {
  4323. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4324. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4325. return ServerCheckResult;
  4326. }
  4327. boolean procSucc = true;
  4328. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  4329. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  4330. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  4331. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4332. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  4333. boolean OnOff = false;
  4334. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  4335. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  4336. else procSucc = false;
  4337. } else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  4338. byte strength = 0;
  4339. if (ventilParser.ctraction.equalsIgnoreCase("low"))
  4340. strength = VentiAPI.WIND.LOW;
  4341. else if (ventilParser.ctraction.equalsIgnoreCase("mid"))
  4342. strength = VentiAPI.WIND.MID;
  4343. else strength = VentiAPI.WIND.HI;
  4344. if (VentilCTR.data.OnOff) {
  4345. // 환기가 On인 경우
  4346. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4347. else procSucc = false;
  4348. } else {
  4349. // 환기가 Off인 경우
  4350. if (VentilCTR.SetOnOff(true) >= 0) {
  4351. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4352. else procSucc = false;
  4353. } else {
  4354. procSucc = false;
  4355. }
  4356. }
  4357. }
  4358. if (VentilCTR.Refresh(true) == 0) {
  4359. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4360. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4361. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4362. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4363. else unit_status = "unknown";
  4364. if (VentilCTR.data.Support.AutoDriving) {
  4365. mode = "normal/auto";
  4366. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4367. else unit_mode = "normal";
  4368. } else {
  4369. mode = "normal";
  4370. unit_mode = "normal";
  4371. }
  4372. } else {
  4373. procSucc = false;
  4374. }
  4375. } else {
  4376. procSucc = false;
  4377. }
  4378. } else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4379. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4380. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4381. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4382. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4383. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4384. else unit_status = "unknown";
  4385. if (VentilCTR.data.Support.AutoDriving) {
  4386. mode = "normal/auto";
  4387. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4388. else unit_mode = "normal";
  4389. } else {
  4390. mode = "normal";
  4391. unit_mode = "normal";
  4392. }
  4393. } else {
  4394. procSucc = false;
  4395. }
  4396. } else {
  4397. procSucc = false;
  4398. }
  4399. if (procSucc == false) {
  4400. retStr += (" result=\"fail\" >\r\n");
  4401. unit_status = "unknown";
  4402. } else {
  4403. retStr += (" result=\"ok\" >\r\n");
  4404. }
  4405. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4406. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4407. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4408. // retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4409. retStr += " <status_info unit_num=\"ventil\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4410. return retStr;
  4411. } catch (RuntimeException re) {
  4412. LogUtil.errorLogInfo("", TAG, re);
  4413. return null;
  4414. } catch (Exception e) {
  4415. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4416. //e.printStackTrace();
  4417. LogUtil.errorLogInfo("", TAG, e);
  4418. return null;
  4419. }
  4420. }
  4421. public String iCMDProcTemperControl(Document doc) {
  4422. try {
  4423. String target = "null", tid = "null", msgno = "null";
  4424. String retStr = CheckiCMDProc("remote_access_temper");
  4425. if (retStr != null) return retStr;
  4426. else
  4427. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4428. NodeList items = doc.getElementsByTagName("target");
  4429. Node item = items.item(0);
  4430. if (item != null) {
  4431. NamedNodeMap attrs = item.getAttributes();
  4432. for (int j = 0; j < attrs.getLength(); j++) {
  4433. Node attr = attrs.item(j);
  4434. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4435. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4436. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4437. }
  4438. }
  4439. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4440. if (NewServerUse()) {
  4441. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4442. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4443. return ServerCheckResult;
  4444. }
  4445. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4446. //String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4447. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4448. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_HEATING);
  4449. if(knxRoomNameList==null) knxRoomNameList = mDefaultRoomNameList_Heating;
  4450. // 난방 종류를 얻어온다.
  4451. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4452. HeatingV1API heatingV1API = null;
  4453. HeatingV2API heatingV2API = null;
  4454. // 종류별 API를 로딩한다.
  4455. if (HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4456. else if (HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4457. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4458. if (tempercmd.actionTXT.equals("control")) {
  4459. String[] CtrList;
  4460. byte ctrl = 0;
  4461. byte roomNum = (byte) 0xFF;
  4462. double temp = 0;
  4463. if (tempercmd.unitnum.equals("all")) {
  4464. if (tempercmd.ctraction.equals("on")) {
  4465. ctrl = 1;
  4466. } else if (tempercmd.ctraction.equals("off")) {
  4467. ctrl = 0;
  4468. } else {
  4469. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\" />\r\n </service>\r\n</imap> ";
  4470. return retStr;
  4471. }
  4472. } else {
  4473. CtrList = tempercmd.ctraction.split("/");
  4474. if (CtrList[0].equals("on")) ctrl = 1;
  4475. else ctrl = 0;
  4476. roomNum = (byte) 0xFF;
  4477. temp = Double.parseDouble(CtrList[1]);
  4478. }
  4479. if (HeatingKind == 1) {
  4480. boolean OnOff = false;
  4481. if (ctrl == 1) OnOff = true;
  4482. if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
  4483. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4484. if (ret != APIErrorCode.C_SUCCESS) {
  4485. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4486. return retStr;
  4487. }
  4488. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4489. } else {
  4490. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4491. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4492. roomNum = i;
  4493. break;
  4494. }
  4495. }
  4496. if (roomNum == (byte) 0xFF) {
  4497. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4498. return retStr;
  4499. }
  4500. if (heatingV1API != null) {
  4501. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
  4502. if (ret != APIErrorCode.C_SUCCESS) {
  4503. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4504. return retStr;
  4505. }
  4506. heatingV1API.Refresh(roomNum, false);
  4507. }
  4508. }
  4509. }
  4510. else if (HeatingKind == 2) {
  4511. byte Mode = HeatingV2.MODE.HeatingOFF;
  4512. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4513. if (tempercmd.unitnum.equals("all")) {
  4514. if (heatingV2API != null) {
  4515. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4516. if (ret != APIErrorCode.C_SUCCESS) {
  4517. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4518. return retStr;
  4519. }
  4520. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4521. }
  4522. } else {
  4523. int nDevNum = Integer.parseInt(tempercmd.devnum)-1;
  4524. if (heatingV2API != null) {
  4525. int ret = heatingV2API.SetEachRoomStatus((byte) nDevNum, Mode, temp);
  4526. if (ret != APIErrorCode.C_SUCCESS) {
  4527. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4528. return retStr;
  4529. }
  4530. heatingV2API.Refresh((byte) nDevNum, false);
  4531. }
  4532. }
  4533. }
  4534. else {
  4535. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4536. return retStr;
  4537. }
  4538. }
  4539. String resultStr = " <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4540. if (HeatingKind == 1) {
  4541. try {
  4542. if (heatingV1API == null) {
  4543. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4544. return retStr;
  4545. }
  4546. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4547. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4548. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount + "\"/>\r\n";
  4549. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4550. String drvmode = "off";
  4551. for (byte i = 0; i < RoomCount; i++) {
  4552. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4553. if (roomData.bOnOff) drvmode = "on";
  4554. else drvmode = "off";
  4555. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4556. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4557. }
  4558. resultStr += " </service>\r\n</imap>\r\n";
  4559. retStr += ("\"ok\">\r\n" + resultStr);
  4560. return retStr;
  4561. } else {
  4562. String drvmode = "off";
  4563. byte roomNum = (byte) 0xFF;
  4564. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4565. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4566. roomNum = i;
  4567. break;
  4568. }
  4569. }
  4570. if (roomNum == (byte) 0xFF) {
  4571. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4572. return retStr;
  4573. }
  4574. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4575. if (roomData.bOnOff) drvmode = "on";
  4576. else drvmode = "off";
  4577. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4578. resultStr += " <status_info unit_num=\"" + knxRoomNameList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4579. resultStr += " </service>\r\n</imap>\r\n";
  4580. retStr += ("\"ok\">\r\n" + resultStr);
  4581. return retStr;
  4582. }
  4583. } catch (RuntimeException re) {
  4584. LogUtil.errorLogInfo("", TAG, re);
  4585. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4586. return retStr;
  4587. } catch (Exception e) {
  4588. //e.printStackTrace();
  4589. LogUtil.errorLogInfo("", TAG, e);
  4590. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4591. return retStr;
  4592. }
  4593. }
  4594. else if (HeatingKind == 2) {
  4595. try {
  4596. if (heatingV2API == null) {
  4597. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4598. return retStr;
  4599. }
  4600. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4601. resultStr += " <action> \"" + tempercmd.actionTXT + "\"</action>\r\n";
  4602. //resultStr += " <status_map dev_num=\"1\" unit_cnt = \"" + RoomCount + "\" />\r\n";
  4603. if ((tempercmd.devnum.equals("all"))) {
  4604. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
  4605. String drvmode = "off";
  4606. for (byte i = 0; i < RoomCount; i++) {
  4607. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4608. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4609. else drvmode = "off";
  4610. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4611. resultStr += " <status_map dev_num=\"" + (i+1) + "\" unit_cnt = \"1\"/>\r\n";
  4612. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4613. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + knxRoomNameList[i] + "\"/>\r\n";
  4614. } else {
  4615. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4616. }
  4617. }
  4618. resultStr += " </service>\r\n</imap>\r\n";
  4619. retStr += ("\"ok\">\r\n" + resultStr);
  4620. return retStr;
  4621. }
  4622. else {
  4623. String drvmode = "off";
  4624. int nDevNum = Integer.parseInt(tempercmd.devnum);
  4625. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum-1];
  4626. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4627. else drvmode = "off";
  4628. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4629. resultStr += " <status_map dev_num=\"" + (nDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  4630. resultStr += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4631. resultStr += " </service>\r\n</imap>\r\n";
  4632. retStr += ("\"ok\">\r\n" + resultStr);
  4633. return retStr;
  4634. }
  4635. } catch (RuntimeException re) {
  4636. LogUtil.errorLogInfo("", TAG, re);
  4637. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4638. return retStr;
  4639. } catch (Exception e) {
  4640. //e.printStackTrace();
  4641. LogUtil.errorLogInfo("", TAG, e);
  4642. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4643. return retStr;
  4644. }
  4645. } else {
  4646. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
  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. }
  4650. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4651. // return retStr;
  4652. } catch (RuntimeException re) {
  4653. LogUtil.errorLogInfo("", TAG, re);
  4654. return null;
  4655. } catch (Exception e) {
  4656. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4657. //e.printStackTrace();
  4658. LogUtil.errorLogInfo("", TAG, e);
  4659. return null;
  4660. }
  4661. }
  4662. public String iCMDProcDoorlockControl(Document doc) {
  4663. try {
  4664. String DLStatus = "none";
  4665. String strResult = CheckiCMDProc("remote_access_doorlock");
  4666. if (strResult != null) return strResult;
  4667. else
  4668. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4669. String target = "null", tid = "null", msgno = "null";
  4670. NodeList items = doc.getElementsByTagName("target");
  4671. Node item = items.item(0);
  4672. if (item != null) {
  4673. NamedNodeMap attrs = item.getAttributes();
  4674. for (int j = 0; j < attrs.getLength(); j++) {
  4675. Node attr = attrs.item(j);
  4676. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4677. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4678. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4679. msgno = attr.getNodeValue();
  4680. }
  4681. }
  4682. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4683. if (NewServerUse()) {
  4684. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4685. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4686. return ServerCheckResult;
  4687. }
  4688. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4689. try {
  4690. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4691. if (doorStatus != null) {
  4692. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4693. DLStatus = "unknown";
  4694. } else {
  4695. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce)
  4696. DLStatus = "close";
  4697. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce)
  4698. DLStatus = "open";
  4699. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation)
  4700. DLStatus = "ing";
  4701. else DLStatus = "unknown";
  4702. }
  4703. }
  4704. } catch (RuntimeException re) {
  4705. LogUtil.errorLogInfo("", TAG, re);
  4706. DLStatus = "unknown";
  4707. } catch (Exception e) {
  4708. //e.printStackTrace();
  4709. LogUtil.errorLogInfo("", TAG, e);
  4710. DLStatus = "unknown";
  4711. }
  4712. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n" +
  4713. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n" +
  4714. " <action>\"status\"</action>\r\n" +
  4715. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n" +
  4716. " <status_info unit_num=\"doorlock1\" unit_status=\"" + DLStatus + "\"/>\r\n </service>\r\n</imap>";
  4717. return retXML;
  4718. } catch (RuntimeException re) {
  4719. LogUtil.errorLogInfo("", TAG, re);
  4720. return null;
  4721. } catch (Exception e) {
  4722. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4723. //e.printStackTrace();
  4724. LogUtil.errorLogInfo("", TAG, e);
  4725. return null;
  4726. }
  4727. }
  4728. /*
  4729. protected String iCMDProcsavelog(Document doc)
  4730. {
  4731. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4732. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4733. NodeList items = doc.getElementsByTagName("guidemap");
  4734. Node item = items.item(0);
  4735. NamedNodeMap attrsParam = item.getAttributes();
  4736. for(int j=0; j< attrsParam.getLength();j++)
  4737. {
  4738. Node attr = attrsParam.item(j);
  4739. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4740. {
  4741. String enable = attr.getNodeValue();
  4742. if (enable == null) return FailretStr;
  4743. if (enable.equals("false"))
  4744. {
  4745. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4746. logSet.SetLogDoing(0);
  4747. logSet.closeDB();
  4748. return SucretStr;
  4749. }
  4750. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4751. logSet.SetLogDoing(1);
  4752. logSet.closeDB();
  4753. }
  4754. }
  4755. items = doc.getElementsByTagName("setting");
  4756. item = items.item(0);
  4757. attrsParam = item.getAttributes();
  4758. String SaveType = "";
  4759. String FtpLoc = "";
  4760. String Ftpuser = "";
  4761. String FtpPW= "";
  4762. String period = "";
  4763. String FileSize = "";
  4764. for(int j=0; j< attrsParam.getLength();j++)
  4765. {
  4766. Node attr = attrsParam.item(j);
  4767. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4768. SaveType = attr.getNodeValue();
  4769. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4770. FtpLoc = attr.getNodeValue();
  4771. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4772. Ftpuser = attr.getNodeValue();
  4773. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4774. FtpPW = attr.getNodeValue();
  4775. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4776. period = attr.getNodeValue();
  4777. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4778. FileSize = attr.getNodeValue();
  4779. }
  4780. if (SaveType.equalsIgnoreCase("now"))
  4781. {
  4782. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4783. LogUpThread.start();
  4784. return SucretStr;
  4785. }
  4786. else if (SaveType.equalsIgnoreCase("periodic"))
  4787. {
  4788. try
  4789. {
  4790. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4791. period = period.trim();
  4792. String[] logperiod = period.split("[-]");
  4793. String StartDate = logperiod[0].replace(".", "_");
  4794. String EndDate = logperiod[1].replace(".", "_");
  4795. logSet.SetLogDoing(1);
  4796. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4797. if (FileSize.equalsIgnoreCase("null"))
  4798. logSet.SetLogLogFileSize(0);
  4799. else
  4800. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4801. logSet.SetLogStartDate(StartDate);
  4802. logSet.SetLogEndDate(EndDate);
  4803. logSet.closeDB();
  4804. return SucretStr;
  4805. }
  4806. catch (RuntimeException re) {
  4807. LogUtil.errorLogInfo("", TAG, re);
  4808. }
  4809. catch (Exception e)
  4810. {
  4811. e.printStackTrace();
  4812. return FailretStr;
  4813. }
  4814. }
  4815. else
  4816. {
  4817. return FailretStr;
  4818. }
  4819. }
  4820. */
  4821. protected void SendLogSaved(String ftploc, String fname, String size) {
  4822. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n" +
  4823. " <device_info devtype=\"homedev\" id_high=\"" + AddrDong + "\" id_low=\"" + AddrHo + "\"/>\r\n" +
  4824. " <file_info path=\"" + ftploc + "\" name=\"" + fname + "\" size=\"" + size + "\"/>\r\n</service>\r\n</imap>";
  4825. SendToServer(SendMsg);
  4826. }
  4827. public final static int FTPLOGTRSUCC = 1110;
  4828. public final static int FTPLOGTRFAIL = 1120;
  4829. Handler FileTrHandler = new Handler() {
  4830. public void handleMessage(Message msg) {
  4831. switch (msg.what) {
  4832. case FTPLOGTRSUCC:
  4833. String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4834. File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
  4835. int size = (int) (fileinfo.length() / 1024);
  4836. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4837. imapsvrlog("FTPLOGTRSUCC");
  4838. break;
  4839. case FTPLOGTRFAIL:
  4840. imapsvrlog("FTPLOGTRFAIL");
  4841. break;
  4842. }
  4843. }
  4844. };
  4845. class LogUploader extends Thread {
  4846. int fileidx = 0;
  4847. boolean TRing = false;
  4848. String FtpLoc;
  4849. String FtpID;
  4850. String FtpPasswd;
  4851. class ftpuploader extends WallPadFTPUploader {
  4852. String filename;
  4853. public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
  4854. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
  4855. filename = LocalFile;
  4856. }
  4857. protected void ProcUploadFail() {
  4858. Message TrResult = FileTrHandler.obtainMessage();
  4859. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4860. TrResult.what = FTPLOGTRFAIL;
  4861. TRing = false;
  4862. imapsvrlog("Send Log Fail Message");
  4863. FileTrHandler.sendMessage(TrResult);
  4864. }
  4865. protected void ProcUploadSuccess() {
  4866. Message TrResult = FileTrHandler.obtainMessage();
  4867. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4868. TrResult.what = FTPLOGTRSUCC;
  4869. TRing = false;
  4870. imapsvrlog("Send Log success Message");
  4871. FileTrHandler.sendMessage(TrResult);
  4872. }
  4873. }
  4874. public LogUploader(String loc, String user, String pw) {
  4875. FtpLoc = loc;
  4876. FtpID = user;
  4877. FtpPasswd = pw;
  4878. }
  4879. public void run() {
  4880. File LogLoc = new File(define.LOG_FILE_LOCATION);
  4881. String[] LogFileList = LogLoc.list();
  4882. while (true) {
  4883. if (TRing == false) {
  4884. if (LogFileList != null && fileidx < LogFileList.length) {
  4885. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
  4886. fileidx++;
  4887. TRing = true;
  4888. uploader.start();
  4889. } else
  4890. return;
  4891. }
  4892. try {
  4893. Thread.sleep(500);
  4894. } catch (RuntimeException re) {
  4895. LogUtil.errorLogInfo("", TAG, re);
  4896. } catch (Exception e) {
  4897. LogUtil.errorLogInfo("", TAG, e);
  4898. }
  4899. }
  4900. }
  4901. }
  4902. public String iCMDProcDevList(Document ele) {
  4903. try {
  4904. String strResult = CheckiCMDProc("remote_get_home_devices");
  4905. if (strResult != null) return strResult;
  4906. else
  4907. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" ";
  4908. String target = "null", tid = "null", msgno = "null";
  4909. NodeList items = ele.getElementsByTagName("target");
  4910. Node item = items.item(0);
  4911. if (item != null) {
  4912. NamedNodeMap attrs = item.getAttributes();
  4913. for (int j = 0; j < attrs.getLength(); j++) {
  4914. Node attr = attrs.item(j);
  4915. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4916. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4917. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4918. msgno = attr.getNodeValue();
  4919. }
  4920. }
  4921. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4922. if (NewServerUse()) {
  4923. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  4924. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4925. return ServerCheckResult;
  4926. }
  4927. GasAPI mGasAPI = null;
  4928. CooktopAPI mCooktopAPI = null;
  4929. if (mWallPadAPI.GetGasKind() == 1) {
  4930. mGasAPI = mWallPadAPI.Get_GasController();
  4931. } else if (mWallPadAPI.GetGasKind() == 2) {
  4932. mCooktopAPI = mWallPadAPI.Get_CookTopController();
  4933. }
  4934. Log.i(TAG, "[iCMDProcDevList] bLightCMDUseAsSmartLight: " + bLightCMDUseAsSmartLight);
  4935. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  4936. int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  4937. String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
  4938. int nConcentEnable = mWallpadDeviceSet.Get_Concent_Info(); // 콘센트 사용 유무
  4939. mWallpadDeviceSet.closeDB();
  4940. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  4941. String[] devlist;
  4942. if(nConcentEnable==1){
  4943. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
  4944. } else {
  4945. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "smartlight", "cooktop", "sysaircon"};
  4946. }
  4947. strResult += "result=\"ok\">\r\n";
  4948. strResult += " <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
  4949. strResult += " <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
  4950. //strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  4951. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  4952. String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
  4953. String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
  4954. String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
  4955. strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
  4956. strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
  4957. strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
  4958. for (int i = 0; i < devlist.length; i++) {
  4959. if (devlist[i].equals("cooktop")) {
  4960. if (mWallPadAPI.GetGasKind() == 1) {
  4961. // 가스밸브
  4962. int Gasinfo = devSet.Get_GAS_Info();
  4963. if (Gasinfo == 1) {
  4964. // 사용함
  4965. if (bGasAsCooktopOutlet) {
  4966. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4967. strResult += " <devinfo name=\"cooktop\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4968. } else {
  4969. strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4970. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4971. }
  4972. } else {
  4973. // 사용안함
  4974. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4975. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4976. }
  4977. } else if (mWallPadAPI.GetGasKind() == 2) {
  4978. // 하이브리드 쿡탑
  4979. if (mCooktopAPI != null) {
  4980. int nGas = 0;
  4981. int nOutlet = 0;
  4982. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  4983. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  4984. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
  4985. nGas++;
  4986. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
  4987. nOutlet++;
  4988. }
  4989. }
  4990. strResult += " <devinfo name=\"gas\" value=\"" + nGas + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4991. strResult += " <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4992. }
  4993. } else {
  4994. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4995. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  4996. }
  4997. }
  4998. else if (devlist[i].equals("doorlock")) {
  4999. try {
  5000. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5001. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5002. strResult += " <devinfo name=\"doorlock\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5003. } else {
  5004. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5005. }
  5006. } catch (RuntimeException re) {
  5007. LogUtil.errorLogInfo("", TAG, re);
  5008. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5009. } catch (Exception e) {
  5010. //e.printStackTrace();
  5011. LogUtil.errorLogInfo("", TAG, e);
  5012. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5013. }
  5014. }
  5015. else if (devlist[i].equals("light")) {
  5016. try {
  5017. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5018. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5019. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5020. if (bLightCMDUseAsSmartLight) {
  5021. if (mSdbAPI != null) {
  5022. strResult += " <devinfo name=\"light\" value=\"" + mSdbAPI.data.BadRoom_Em_Count + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5023. } else {
  5024. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5025. }
  5026. } else {
  5027. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5028. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5029. }
  5030. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5031. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5032. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5033. strResult += " <devinfo name=\"light\" value=\"" + energymeter.data.RoomCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5034. } else {
  5035. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5036. }
  5037. } else {
  5038. int[] lightinfo = devSet.Get_Light_info();
  5039. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5040. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5041. } else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5042. strResult += " <devinfo name=\"light\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5043. } else {
  5044. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5045. int ret = multisw.Refresh((byte) 0xFF, false);
  5046. if (ret < 0 || multisw.data.DeviceCnt < 1)
  5047. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5048. else
  5049. strResult += " <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5050. }
  5051. }
  5052. } catch (RuntimeException re) {
  5053. LogUtil.errorLogInfo("", TAG, re);
  5054. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5055. } catch (Exception e) {
  5056. //e.printStackTrace();
  5057. LogUtil.errorLogInfo("", TAG, e);
  5058. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5059. }
  5060. }
  5061. else if (devlist[i].equals("livinglight")) {
  5062. try {
  5063. int[] lightinfo = devSet.Get_Light_info();
  5064. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5065. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5066. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5067. if (bLightCMDUseAsSmartLight) {
  5068. if (mSdb_LivingRoomLightAPI != null) {
  5069. strResult += " <devinfo name=\"livinglight\" value=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5070. } else {
  5071. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5072. }
  5073. } else {
  5074. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5075. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5076. }
  5077. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5078. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5079. } else {
  5080. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5081. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5082. } else {
  5083. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5084. }
  5085. }
  5086. } catch (RuntimeException re) {
  5087. LogUtil.errorLogInfo("", TAG, re);
  5088. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5089. } catch (Exception e) {
  5090. //e.printStackTrace();
  5091. LogUtil.errorLogInfo("", TAG, e);
  5092. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5093. }
  5094. }
  5095. else if (devlist[i].equals("ventil")) {
  5096. try {
  5097. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5098. if (Ventilinfo[0] == 0)
  5099. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5100. else
  5101. strResult += " <devinfo name=\"ventil\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5102. } catch (RuntimeException re) {
  5103. LogUtil.errorLogInfo("", TAG, re);
  5104. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5105. } catch (Exception e) {
  5106. //e.printStackTrace();
  5107. LogUtil.errorLogInfo("", TAG, e);
  5108. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5109. }
  5110. }
  5111. else if (devlist[i].equals("thermostat")) {
  5112. try {
  5113. int Temperinfo = devSet.Get_Temper_Info();
  5114. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5115. HeatingV1API heatingV1API = null;
  5116. HeatingV2API heatingV2API = null;
  5117. byte RoomCount = 0;
  5118. // 종류별 API를 로딩한다.
  5119. if (HeatingKind == 1) {
  5120. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5121. if (heatingV1API != null) {
  5122. RoomCount = heatingV1API.data.Device.RoomCount;
  5123. }
  5124. } else if (HeatingKind == 2) {
  5125. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5126. if (heatingV2API != null) {
  5127. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5128. }
  5129. }
  5130. if (Temperinfo == 0)
  5131. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5132. else
  5133. strResult += " <devinfo name=\"thermostat\" value=\"" + RoomCount + "\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5134. } catch (RuntimeException re) {
  5135. LogUtil.errorLogInfo("", TAG, re);
  5136. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5137. } catch (Exception e) {
  5138. //e.printStackTrace();
  5139. LogUtil.errorLogInfo("", TAG, e);
  5140. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5141. }
  5142. }
  5143. else if (devlist[i].equals("curtain")) {
  5144. try {
  5145. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5146. if (Curtaininfo[0] == 0)
  5147. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5148. else
  5149. strResult += " <devinfo name=\"curtain\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5150. } catch (RuntimeException re) {
  5151. LogUtil.errorLogInfo("", TAG, re);
  5152. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5153. } catch (Exception e) {
  5154. //e.printStackTrace();
  5155. LogUtil.errorLogInfo("", TAG, e);
  5156. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5157. }
  5158. }
  5159. else if (devlist[i].equals("electric")) {
  5160. try {
  5161. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5162. // 청담 콘센트 처리
  5163. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5164. int BadConcentCount = 0;
  5165. if (KnxApi != null) {
  5166. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5167. if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
  5168. BadConcentCount = 1;
  5169. }
  5170. int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  5171. for (int k = 0; k < BadConCount; k++) {
  5172. if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
  5173. BadConcentCount++;
  5174. }
  5175. Log.d(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
  5176. strResult += " <devinfo name=\"electric\" value=\"" + BadConcentCount + "\" floor=\"" + ho + "\"/>\r\n";
  5177. }
  5178. } else {
  5179. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5180. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5181. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5182. int nOutlet = 0;
  5183. if (mSdb_LivingRoomLightAPI != null) {
  5184. if (mSdbAPI != null) {
  5185. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5186. } else {
  5187. nOutlet = 1;
  5188. }
  5189. } else {
  5190. if (mSdbAPI != null) {
  5191. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5192. } else {
  5193. nOutlet = 0;
  5194. }
  5195. }
  5196. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"" + ho + "\"/>\r\n";
  5197. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5198. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5199. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5200. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"" + ho + "\"/>\r\n";
  5201. } else {
  5202. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5203. }
  5204. } else {
  5205. int[] lightinfo = devSet.Get_Light_info();
  5206. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5207. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5208. } else {
  5209. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5210. int ret = multisw.Refresh((byte) 0xFF, false);
  5211. if (ret < 0 || multisw.data.DeviceCnt < 1) {
  5212. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5213. } else {
  5214. int DeviceCount = 0;
  5215. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5216. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5217. DeviceCount++;
  5218. }
  5219. }
  5220. strResult += " <devinfo name=\"electric\" value=\"" + DeviceCount + "\" floor=\"" + ho + "\"/>\r\n";
  5221. }
  5222. }
  5223. }
  5224. }
  5225. } catch (RuntimeException re) {
  5226. LogUtil.errorLogInfo("", TAG, re);
  5227. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5228. } catch (Exception e) {
  5229. //e.printStackTrace();
  5230. LogUtil.errorLogInfo("", TAG, e);
  5231. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5232. }
  5233. }
  5234. else if (devlist[i].equals("smartlight")) {
  5235. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5236. // KNX 조명 처리
  5237. try {
  5238. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5239. if (KnxApi != null) {
  5240. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5241. if (KnxApi.data == null)
  5242. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
  5243. if (KnxApi.data.MasterController == null)
  5244. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
  5245. if (ret >= 0) {
  5246. int LivingLightCount = 0;
  5247. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  5248. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  5249. } else {
  5250. if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  5251. LivingLightCount = 1;
  5252. }
  5253. int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount + KnxApi.data.MasterController.Info.Light_SwitchCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
  5254. strResult += " <devinfo name=\"smartlight\" value=\"" + AllEMcount + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5255. }
  5256. }
  5257. } catch (Exception ek) {
  5258. strResult += " <devinfo name=\"smartlight\" value=\"" + 0 + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5259. }
  5260. } else {
  5261. if (!bLightCMDUseAsSmartLight) {
  5262. int nSmartLight = 0;
  5263. if (mSdb_LivingRoomLightAPI != null) {
  5264. if (mSdbAPI != null) {
  5265. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5266. } else {
  5267. nSmartLight = 1;
  5268. }
  5269. } else {
  5270. if (mSdbAPI != null) {
  5271. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5272. } else {
  5273. nSmartLight = 0;
  5274. }
  5275. }
  5276. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5277. }
  5278. }
  5279. }
  5280. else if (devlist[i].equals("sysaircon")) {
  5281. // 에어컨 처리
  5282. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5283. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  5284. if (airconAPI != null) {
  5285. int nCount = airconAPI.data.Device.info.InsideAirconCount;
  5286. Log.d(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
  5287. // 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
  5288. strResult += " <devinfo name=\"sysaircon\" value=\"" + nCount + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5289. } else {
  5290. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5291. }
  5292. } else {
  5293. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5294. }
  5295. }
  5296. }
  5297. //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
  5298. strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5299. strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5300. if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
  5301. strResult += remote_get_home_devices1;
  5302. }
  5303. if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
  5304. strResult += remote_get_home_devices2;
  5305. }
  5306. if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
  5307. strResult += remote_get_home_devices3;
  5308. }
  5309. /*
  5310. for (int i = 0; i < devlist.length; i++) {
  5311. if (devlist[i].equals("cooktop")) {
  5312. if (mWallPadAPI.GetGasKind() == 1) {
  5313. // 가스밸브
  5314. int Gasinfo = devSet.Get_GAS_Info();
  5315. if (Gasinfo == 1) {
  5316. // 사용함
  5317. if (bGasAsCooktopOutlet) {
  5318. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5319. strResult +=" <devinfo name=\"cooktop\" value=\"1\" floor=\"2\"/>\r\n";
  5320. }
  5321. else {
  5322. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n";
  5323. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5324. }
  5325. }
  5326. else {
  5327. // 사용안함
  5328. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5329. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5330. }
  5331. }
  5332. else if (mWallPadAPI.GetGasKind() == 2) {
  5333. // 하이브리드 쿡탑
  5334. if (mCooktopAPI != null) {
  5335. int nGas = 0; int nOutlet = 0;
  5336. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5337. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5338. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5339. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5340. }
  5341. }
  5342. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"2\"/>\r\n";
  5343. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5344. }
  5345. }
  5346. else {
  5347. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5348. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5349. }
  5350. }
  5351. else if (devlist[i].equals("doorlock")) {
  5352. try {
  5353. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5354. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5355. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"2\"/>\r\n";
  5356. }
  5357. else {
  5358. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5359. }
  5360. } catch (RuntimeException re) {
  5361. LogUtil.errorLogInfo("", TAG, re);
  5362. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5363. }
  5364. catch (Exception e) {
  5365. //e.printStackTrace();
  5366. LogUtil.errorLogInfo("", TAG, e);
  5367. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5368. }
  5369. }
  5370. else if (devlist[i].equals("light")) {
  5371. try {
  5372. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5373. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5374. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5375. if (bLightCMDUseAsSmartLight) {
  5376. if (mSdbAPI != null) {
  5377. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"2\"/>\r\n";
  5378. }
  5379. else {
  5380. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5381. }
  5382. }
  5383. else {
  5384. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5385. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5386. }
  5387. }
  5388. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5389. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5390. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5391. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"2\"/>\r\n";
  5392. }
  5393. else {
  5394. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5395. }
  5396. }
  5397. else {
  5398. int[] lightinfo = devSet.Get_Light_info();
  5399. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5400. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5401. }
  5402. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5403. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"2\"/>\r\n";
  5404. }
  5405. else {
  5406. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5407. int ret = multisw.Refresh((byte)0xFF, false);
  5408. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5409. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"2\"/>\r\n";
  5410. }
  5411. }
  5412. } catch (RuntimeException re) {
  5413. LogUtil.errorLogInfo("", TAG, re);
  5414. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5415. }
  5416. catch (Exception e) {
  5417. //e.printStackTrace();
  5418. LogUtil.errorLogInfo("", TAG, e);
  5419. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5420. }
  5421. }
  5422. else if (devlist[i].equals("livinglight")) {
  5423. try {
  5424. int[] lightinfo = devSet.Get_Light_info();
  5425. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5426. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5427. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5428. if (bLightCMDUseAsSmartLight) {
  5429. if (mSdb_LivingRoomLightAPI != null) {
  5430. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"2\"/>\r\n";
  5431. }
  5432. else {
  5433. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5434. }
  5435. }
  5436. else {
  5437. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5438. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5439. }
  5440. }
  5441. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5442. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5443. }
  5444. else {
  5445. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5446. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5447. }
  5448. else {
  5449. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5450. }
  5451. }
  5452. } catch (RuntimeException re) {
  5453. LogUtil.errorLogInfo("", TAG, re);
  5454. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5455. }
  5456. catch (Exception e) {
  5457. //e.printStackTrace();
  5458. LogUtil.errorLogInfo("", TAG, e);
  5459. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5460. }
  5461. }
  5462. else if (devlist[i].equals("ventil")) {
  5463. try {
  5464. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5465. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5466. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n";
  5467. } catch (RuntimeException re) {
  5468. LogUtil.errorLogInfo("", TAG, re);
  5469. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5470. }
  5471. catch (Exception e) {
  5472. //e.printStackTrace();
  5473. LogUtil.errorLogInfo("", TAG, e);
  5474. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5475. }
  5476. }
  5477. else if (devlist[i].equals("thermostat")) {
  5478. try {
  5479. int Temperinfo = devSet.Get_Temper_Info();
  5480. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5481. HeatingV1API heatingV1API = null;
  5482. HeatingV2API heatingV2API = null;
  5483. byte RoomCount = 0;
  5484. // 종류별 API를 로딩한다.
  5485. if (HeatingKind == 1) {
  5486. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5487. if (heatingV1API != null) {
  5488. RoomCount = heatingV1API.data.Device.RoomCount;
  5489. }
  5490. }
  5491. else if (HeatingKind == 2) {
  5492. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5493. if (heatingV2API != null) {
  5494. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5495. }
  5496. }
  5497. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5498. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"2\"/>\r\n";
  5499. } catch (RuntimeException re) {
  5500. LogUtil.errorLogInfo("", TAG, re);
  5501. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5502. }
  5503. catch (Exception e) {
  5504. //e.printStackTrace();
  5505. LogUtil.errorLogInfo("", TAG, e);
  5506. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5507. }
  5508. }
  5509. else if (devlist[i].equals("curtain")) {
  5510. try {
  5511. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5512. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5513. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"2\"/>\r\n";
  5514. } catch (RuntimeException re) {
  5515. LogUtil.errorLogInfo("", TAG, re);
  5516. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5517. }
  5518. catch (Exception e) {
  5519. //e.printStackTrace();
  5520. LogUtil.errorLogInfo("", TAG, e);
  5521. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5522. }
  5523. }
  5524. else if (devlist[i].equals("electric")) {
  5525. try {
  5526. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5527. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5528. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5529. int nOutlet = 0;
  5530. if (mSdb_LivingRoomLightAPI != null) {
  5531. if (mSdbAPI != null) {
  5532. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5533. }
  5534. else {
  5535. nOutlet = 1;
  5536. }
  5537. }
  5538. else {
  5539. if (mSdbAPI != null) {
  5540. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5541. }
  5542. else {
  5543. nOutlet = 0;
  5544. }
  5545. }
  5546. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5547. }
  5548. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5549. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5550. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5551. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"2\"/>\r\n";
  5552. }
  5553. else {
  5554. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5555. }
  5556. }
  5557. else {
  5558. int[] lightinfo = devSet.Get_Light_info();
  5559. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5560. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5561. }
  5562. else {
  5563. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5564. int ret = multisw.Refresh((byte)0xFF, false);
  5565. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5566. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5567. }
  5568. else {
  5569. int DeviceCount = 0;
  5570. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5571. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5572. DeviceCount++;
  5573. }
  5574. }
  5575. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"2\"/>\r\n";
  5576. }
  5577. }
  5578. }
  5579. } catch (RuntimeException re) {
  5580. LogUtil.errorLogInfo("", TAG, re);
  5581. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5582. }
  5583. catch (Exception e) {
  5584. //e.printStackTrace();
  5585. LogUtil.errorLogInfo("", TAG, e);
  5586. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5587. }
  5588. }
  5589. else if (devlist[i].equals("smartlight")) {
  5590. if (!bLightCMDUseAsSmartLight) {
  5591. int nSmartLight = 0;
  5592. if (mSdb_LivingRoomLightAPI != null) {
  5593. if (mSdbAPI != null) {
  5594. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5595. }
  5596. else {
  5597. nSmartLight = 1;
  5598. }
  5599. }
  5600. else {
  5601. if (mSdbAPI != null) {
  5602. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5603. }
  5604. else {
  5605. nSmartLight = 0;
  5606. }
  5607. }
  5608. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"2\"/>\r\n";
  5609. }
  5610. }
  5611. }
  5612. for (int i = 0; i < devlist.length; i++) {
  5613. if (devlist[i].equals("cooktop")) {
  5614. if (mWallPadAPI.GetGasKind() == 1) {
  5615. // 가스밸브
  5616. int Gasinfo = devSet.Get_GAS_Info();
  5617. if (Gasinfo == 1) {
  5618. // 사용함
  5619. if (bGasAsCooktopOutlet) {
  5620. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5621. strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5622. }
  5623. else {
  5624. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n";
  5625. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5626. }
  5627. }
  5628. else {
  5629. // 사용안함
  5630. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5631. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5632. }
  5633. }
  5634. else if (mWallPadAPI.GetGasKind() == 2) {
  5635. // 하이브리드 쿡탑
  5636. if (mCooktopAPI != null) {
  5637. int nGas = 0; int nOutlet = 0;
  5638. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5639. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5640. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5641. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5642. }
  5643. }
  5644. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"3\"/>\r\n";
  5645. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5646. }
  5647. }
  5648. else {
  5649. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5650. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5651. }
  5652. }
  5653. else if (devlist[i].equals("doorlock")) {
  5654. try {
  5655. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5656. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5657. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"3\"/>\r\n";
  5658. }
  5659. else {
  5660. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5661. }
  5662. } catch (RuntimeException re) {
  5663. LogUtil.errorLogInfo("", TAG, re);
  5664. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5665. }
  5666. catch (Exception e) {
  5667. //e.printStackTrace();
  5668. LogUtil.errorLogInfo("", TAG, e);
  5669. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5670. }
  5671. }
  5672. else if (devlist[i].equals("light")) {
  5673. try {
  5674. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5675. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5676. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5677. if (bLightCMDUseAsSmartLight) {
  5678. if (mSdbAPI != null) {
  5679. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"3\"/>\r\n";
  5680. }
  5681. else {
  5682. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5683. }
  5684. }
  5685. else {
  5686. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5687. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5688. }
  5689. }
  5690. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5691. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5692. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5693. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"3\"/>\r\n";
  5694. }
  5695. else {
  5696. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5697. }
  5698. }
  5699. else {
  5700. int[] lightinfo = devSet.Get_Light_info();
  5701. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5702. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5703. }
  5704. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5705. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"3\"/>\r\n";
  5706. }
  5707. else {
  5708. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5709. int ret = multisw.Refresh((byte)0xFF, false);
  5710. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5711. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"3\"/>\r\n";
  5712. }
  5713. }
  5714. } catch (RuntimeException re) {
  5715. LogUtil.errorLogInfo("", TAG, re);
  5716. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5717. }
  5718. catch (Exception e) {
  5719. //e.printStackTrace();
  5720. LogUtil.errorLogInfo("", TAG, e);
  5721. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5722. }
  5723. }
  5724. else if (devlist[i].equals("livinglight")) {
  5725. try {
  5726. int[] lightinfo = devSet.Get_Light_info();
  5727. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5728. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5729. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5730. if (bLightCMDUseAsSmartLight) {
  5731. if (mSdb_LivingRoomLightAPI != null) {
  5732. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"3\"/>\r\n";
  5733. }
  5734. else {
  5735. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5736. }
  5737. }
  5738. else {
  5739. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5740. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5741. }
  5742. }
  5743. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5744. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5745. }
  5746. else {
  5747. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5748. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5749. }
  5750. else {
  5751. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5752. }
  5753. }
  5754. } catch (RuntimeException re) {
  5755. LogUtil.errorLogInfo("", TAG, re);
  5756. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5757. }
  5758. catch (Exception e) {
  5759. //e.printStackTrace();
  5760. LogUtil.errorLogInfo("", TAG, e);
  5761. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5762. }
  5763. }
  5764. else if (devlist[i].equals("ventil")) {
  5765. try {
  5766. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5767. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5768. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n";
  5769. } catch (RuntimeException re) {
  5770. LogUtil.errorLogInfo("", TAG, re);
  5771. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5772. }
  5773. catch (Exception e) {
  5774. //e.printStackTrace();
  5775. LogUtil.errorLogInfo("", TAG, e);
  5776. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5777. }
  5778. }
  5779. else if (devlist[i].equals("thermostat")) {
  5780. try {
  5781. int Temperinfo = devSet.Get_Temper_Info();
  5782. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5783. HeatingV1API heatingV1API = null;
  5784. HeatingV2API heatingV2API = null;
  5785. byte RoomCount = 0;
  5786. // 종류별 API를 로딩한다.
  5787. if (HeatingKind == 1) {
  5788. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5789. if (heatingV1API != null) {
  5790. RoomCount = heatingV1API.data.Device.RoomCount;
  5791. }
  5792. }
  5793. else if (HeatingKind == 2) {
  5794. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5795. if (heatingV2API != null) {
  5796. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5797. }
  5798. }
  5799. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5800. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"3\"/>\r\n";
  5801. } catch (RuntimeException re) {
  5802. LogUtil.errorLogInfo("", TAG, re);
  5803. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5804. }
  5805. catch (Exception e) {
  5806. //e.printStackTrace();
  5807. LogUtil.errorLogInfo("", TAG, e);
  5808. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5809. }
  5810. }
  5811. else if (devlist[i].equals("curtain")) {
  5812. try {
  5813. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5814. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5815. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"3\"/>\r\n";
  5816. } catch (RuntimeException re) {
  5817. LogUtil.errorLogInfo("", TAG, re);
  5818. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5819. }
  5820. catch (Exception e) {
  5821. //e.printStackTrace();
  5822. LogUtil.errorLogInfo("", TAG, e);
  5823. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5824. }
  5825. }
  5826. else if (devlist[i].equals("electric")) {
  5827. try {
  5828. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5829. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5830. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5831. int nOutlet = 0;
  5832. if (mSdb_LivingRoomLightAPI != null) {
  5833. if (mSdbAPI != null) {
  5834. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5835. }
  5836. else {
  5837. nOutlet = 1;
  5838. }
  5839. }
  5840. else {
  5841. if (mSdbAPI != null) {
  5842. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5843. }
  5844. else {
  5845. nOutlet = 0;
  5846. }
  5847. }
  5848. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5849. }
  5850. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5851. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5852. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5853. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"3\"/>\r\n";
  5854. }
  5855. else {
  5856. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5857. }
  5858. }
  5859. else {
  5860. int[] lightinfo = devSet.Get_Light_info();
  5861. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5862. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5863. }
  5864. else {
  5865. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5866. int ret = multisw.Refresh((byte)0xFF, false);
  5867. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5868. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5869. }
  5870. else {
  5871. int DeviceCount = 0;
  5872. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5873. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5874. DeviceCount++;
  5875. }
  5876. }
  5877. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"3\"/>\r\n";
  5878. }
  5879. }
  5880. }
  5881. } catch (RuntimeException re) {
  5882. LogUtil.errorLogInfo("", TAG, re);
  5883. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5884. }
  5885. catch (Exception e) {
  5886. //e.printStackTrace();
  5887. LogUtil.errorLogInfo("", TAG, e);
  5888. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5889. }
  5890. }
  5891. else if (devlist[i].equals("smartlight")) {
  5892. if (!bLightCMDUseAsSmartLight) {
  5893. int nSmartLight = 0;
  5894. if (mSdb_LivingRoomLightAPI != null) {
  5895. if (mSdbAPI != null) {
  5896. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5897. }
  5898. else {
  5899. nSmartLight = 1;
  5900. }
  5901. }
  5902. else {
  5903. if (mSdbAPI != null) {
  5904. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5905. }
  5906. else {
  5907. nSmartLight = 0;
  5908. }
  5909. }
  5910. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"3\"/>\r\n";
  5911. }
  5912. }
  5913. }
  5914. */
  5915. strResult += " </service>\r\n</imap>\r\n";
  5916. devSet.closeDB();
  5917. return strResult;
  5918. } catch (RuntimeException re) {
  5919. LogUtil.errorLogInfo("", TAG, re);
  5920. return null;
  5921. } catch (Exception e) {
  5922. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  5923. //e.printStackTrace();
  5924. LogUtil.errorLogInfo("", TAG, e);
  5925. return null;
  5926. }
  5927. }
  5928. public String iCMDProcMultiSWControl(Document ele) {
  5929. try {
  5930. String retStr = CheckiCMDProc(MULTISW_CTR);
  5931. if (retStr != null) return retStr;
  5932. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\"";
  5933. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  5934. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5935. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  5936. int devNum = Integer.parseInt(multiswcmd.devnum);
  5937. if (multisw != null) {
  5938. int ret = multisw.Refresh((byte) 0xFF, false);
  5939. String result;
  5940. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  5941. else result = "fail";
  5942. retStr += (" result=\"" + result + "\" >\r\n");
  5943. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5944. retStr += MakeTargetStr(multiswcmd);
  5945. retStr += " <action>\"status\"</action>\r\n";
  5946. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5947. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5948. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  5949. 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";
  5950. } else {
  5951. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  5952. }
  5953. } else {
  5954. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5955. }
  5956. String unitStr;
  5957. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5958. Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
  5959. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5960. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5961. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5962. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  5963. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  5964. }
  5965. }
  5966. retStr += " </service>\r\n</imap>\r\n";
  5967. }
  5968. } else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  5969. int devNum = Integer.parseInt(multiswcmd.devnum);
  5970. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  5971. {
  5972. if (multisw != null) {
  5973. multisw.Refresh((byte) 0xFF, false);
  5974. String result;
  5975. int ret = -1;
  5976. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  5977. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
  5978. } else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  5979. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
  5980. } else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
  5981. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
  5982. } else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
  5983. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
  5984. }
  5985. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  5986. else result = "fail";
  5987. if (ret == APIErrorCode.C_SUCCESS) {
  5988. ret = multisw.Refresh((byte) 0xFF, false);
  5989. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  5990. retStr += (" result=\"" + result + "\" > \r\n");
  5991. retStr += MakeTargetStr(multiswcmd);
  5992. retStr += " <action>\"control\"</action>\r\n";
  5993. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  5994. String unitStr;
  5995. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  5996. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  5997. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  5998. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  5999. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
  6000. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  6001. }
  6002. } else {
  6003. retStr += (" result=\"fail\"> \r\n");
  6004. }
  6005. } else {
  6006. retStr += (" result=\"fail\"> \r\n");
  6007. }
  6008. retStr += " </service>\r\n</imap>\r\n";
  6009. }
  6010. }
  6011. }
  6012. return retStr;
  6013. } catch (RuntimeException re) {
  6014. LogUtil.errorLogInfo("", TAG, re);
  6015. return null;
  6016. } catch (Exception e) {
  6017. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  6018. //e.printStackTrace();
  6019. LogUtil.errorLogInfo("", TAG, e);
  6020. return null;
  6021. }
  6022. }
  6023. public String iCMDProcSDPConcentControl(Document ele) {
  6024. try {
  6025. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  6026. String retStr = CheckiCMDProc("remote_access_electric");
  6027. if (retStr != null) return retStr;
  6028. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  6029. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6030. if (NewServerUse()) {
  6031. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  6032. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6033. return ServerCheckResult;
  6034. }
  6035. if (mSdbAPI == null) {
  6036. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6037. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  6038. return retStr;
  6039. }
  6040. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6041. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6042. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6043. return retStr;
  6044. }
  6045. int nTotalLightCnt = 0;
  6046. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  6047. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6048. } else {
  6049. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  6050. }
  6051. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  6052. int nDevNo = 0;
  6053. try {
  6054. nDevNo = Integer.parseInt(concentcmd.devnum);
  6055. } catch (RuntimeException re) {
  6056. LogUtil.errorLogInfo("", TAG, re);
  6057. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6058. return retStr;
  6059. } catch (Exception e) {
  6060. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  6061. //e.printStackTrace();
  6062. LogUtil.errorLogInfo("", TAG, e);
  6063. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6064. return retStr;
  6065. }
  6066. if (nDevNo < 1 && 12 < nDevNo) {
  6067. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6068. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  6069. return retStr;
  6070. }
  6071. String strAction = trimquotation(concentcmd.actionTXT);
  6072. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  6073. String dev_num = "null", unit_num = "null", ctrl_action = "null";
  6074. int nRet_Mode = -99, nRet_OnOff = -99;
  6075. boolean Set = false, OnOff = false; // 제어요청 상태
  6076. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  6077. if (strAction.equalsIgnoreCase("status")) {
  6078. retStr += " result=\"ok\">\r\n";
  6079. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6080. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6081. if (nDevNo == 1) {
  6082. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6083. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  6084. } else {
  6085. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6086. }
  6087. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6088. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6089. status_mode = "unset";
  6090. else status_mode = "set";
  6091. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6092. status_onoff = "on";
  6093. else status_onoff = "off";
  6094. unit_status = status_mode + "/" + status_onoff;
  6095. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6096. }
  6097. // retStr += " </status_map>\r\n";
  6098. retStr += " </service>\r\n</imap>\r\n";
  6099. } else if (nDevNo > 1) {
  6100. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6101. 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";
  6102. } else {
  6103. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6104. }
  6105. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6106. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6107. status_mode = "unset";
  6108. else status_mode = "set";
  6109. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6110. status_onoff = "on";
  6111. else status_onoff = "off";
  6112. unit_status = status_mode + "/" + status_onoff;
  6113. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6114. }
  6115. // retStr += " </status_map>\r\n";
  6116. retStr += " </service>\r\n</imap>\r\n";
  6117. }
  6118. } else if (strAction.equalsIgnoreCase("control")) {
  6119. NodeList items = ele.getElementsByTagName("params");
  6120. Node item = items.item(0);
  6121. if (item != null) {
  6122. NamedNodeMap attrs = item.getAttributes();
  6123. for (int i = 0; i < attrs.getLength(); i++) {
  6124. Node attr = attrs.item(i);
  6125. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  6126. dev_num = attr.getNodeValue();
  6127. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  6128. unit_num = attr.getNodeValue();
  6129. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6130. ctrl_action = attr.getNodeValue();
  6131. }
  6132. } else {
  6133. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  6134. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6135. return retStr;
  6136. }
  6137. try {
  6138. nDevNo = Integer.parseInt(dev_num);
  6139. } catch (RuntimeException re) {
  6140. LogUtil.errorLogInfo("", TAG, re);
  6141. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6142. return retStr;
  6143. } catch (Exception e) {
  6144. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  6145. //e.printStackTrace();
  6146. LogUtil.errorLogInfo("", TAG, e);
  6147. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6148. return retStr;
  6149. }
  6150. if (nDevNo < 1 && 12 < nDevNo) {
  6151. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6152. return retStr;
  6153. }
  6154. int nUnitNo = 0;
  6155. if (!unit_num.equalsIgnoreCase("all")) {
  6156. try {
  6157. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  6158. } catch (RuntimeException re) {
  6159. LogUtil.errorLogInfo("", TAG, re);
  6160. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6161. return retStr;
  6162. } catch (Exception e) {
  6163. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  6164. //e.printStackTrace();
  6165. LogUtil.errorLogInfo("", TAG, e);
  6166. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6167. return retStr;
  6168. }
  6169. }
  6170. if (ctrl_action.contains("/")) {
  6171. String[] strParsed = ctrl_action.split("/");
  6172. if (strParsed[0].equals("set")) {
  6173. Set = true;
  6174. bCtrl_Set = true;
  6175. } else if (strParsed[0].equals("unset")) {
  6176. Set = false;
  6177. bCtrl_Set = true;
  6178. }
  6179. if (strParsed[1].equals("on")) {
  6180. OnOff = true;
  6181. bCtrl_OnOff = true;
  6182. } else if (strParsed[1].equals("off")) {
  6183. OnOff = false;
  6184. bCtrl_OnOff = true;
  6185. }
  6186. } else {
  6187. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  6188. if (ctrl_action.equalsIgnoreCase("set")) {
  6189. Set = true;
  6190. bCtrl_Set = true;
  6191. } else if (ctrl_action.equalsIgnoreCase("unset")) {
  6192. Set = false;
  6193. bCtrl_Set = true;
  6194. }
  6195. }
  6196. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  6197. if (ctrl_action.equalsIgnoreCase("on")) {
  6198. OnOff = true;
  6199. bCtrl_OnOff = true;
  6200. } else if (ctrl_action.equalsIgnoreCase("off")) {
  6201. OnOff = false;
  6202. bCtrl_OnOff = true;
  6203. }
  6204. }
  6205. }
  6206. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  6207. if (nDevNo == 1) {
  6208. if (unit_num.equalsIgnoreCase("all")) {
  6209. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6210. if (bCtrl_Set)
  6211. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  6212. if (bCtrl_OnOff)
  6213. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  6214. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6215. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6216. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6217. return retStr;
  6218. }
  6219. }
  6220. } else {
  6221. if (bCtrl_Set)
  6222. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  6223. if (bCtrl_OnOff)
  6224. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  6225. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6226. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6227. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6228. return retStr;
  6229. }
  6230. }
  6231. } else {
  6232. if (unit_num.equalsIgnoreCase("all")) {
  6233. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6234. if (bCtrl_Set)
  6235. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  6236. if (bCtrl_OnOff)
  6237. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  6238. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6239. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6240. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6241. return retStr;
  6242. }
  6243. }
  6244. } else {
  6245. if (bCtrl_Set)
  6246. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  6247. if (bCtrl_OnOff)
  6248. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  6249. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6250. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6251. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6252. return retStr;
  6253. }
  6254. }
  6255. }
  6256. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6257. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6258. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6259. return retStr;
  6260. }
  6261. retStr += " result=\"ok\">\r\n";
  6262. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6263. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6264. if (nDevNo == 1) {
  6265. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6266. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6267. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6268. status_mode = "unset";
  6269. else status_mode = "set";
  6270. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6271. status_onoff = "on";
  6272. else status_onoff = "off";
  6273. unit_status = status_mode + "/" + status_onoff;
  6274. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6275. }
  6276. // retStr += " </status_map>\r\n";
  6277. retStr += " </service>\r\n</imap>\r\n";
  6278. } else if (nDevNo > 1) {
  6279. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6280. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6281. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6282. status_mode = "unset";
  6283. else status_mode = "set";
  6284. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6285. status_onoff = "on";
  6286. else status_onoff = "off";
  6287. unit_status = status_mode + "/" + status_onoff;
  6288. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6289. }
  6290. // retStr += " </status_map>\r\n";
  6291. retStr += " </service>\r\n</imap>\r\n";
  6292. }
  6293. } else {
  6294. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  6295. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6296. }
  6297. return retStr;
  6298. } catch (RuntimeException re) {
  6299. LogUtil.errorLogInfo("", TAG, re);
  6300. return null;
  6301. } catch (Exception e) {
  6302. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  6303. //e.printStackTrace();
  6304. LogUtil.errorLogInfo("", TAG, e);
  6305. return null;
  6306. }
  6307. }
  6308. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  6309. try {
  6310. String retStr = CheckiCMDProc(MULTISW_CTR);
  6311. if (retStr != null) return retStr;
  6312. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\" ";
  6313. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6314. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6315. if (energymetercmd == null) return null;
  6316. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6317. if (energymeter == null) return null;
  6318. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6319. int ret = energymeter.Refresh((byte) 0xFF, false);
  6320. String result;
  6321. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  6322. else result = "fail";
  6323. retStr += (" result=\"" + result + "\" >\r\n");
  6324. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6325. retStr += MakeTargetStr(energymetercmd);
  6326. retStr += " <action>\"status\"</action>\r\n";
  6327. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6328. String unitStr;
  6329. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6330. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6331. if (i == 2) {
  6332. unitStr += "on";
  6333. } else {
  6334. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6335. }
  6336. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6337. }
  6338. }
  6339. retStr += " </service>\r\n</imap>\r\n";
  6340. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6341. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6342. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
  6343. byte cmd = 0;
  6344. int ret = 0;
  6345. String result;
  6346. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  6347. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  6348. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  6349. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  6350. if (cmd > 0) {
  6351. if (energymeter != null) {
  6352. energymeter.Refresh((byte) 0xFF, false);
  6353. if (cmd == 1) {
  6354. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  6355. } else if (cmd == 2) {
  6356. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  6357. } else if (cmd == 3) {
  6358. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
  6359. } else if (cmd == 4) {
  6360. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
  6361. }
  6362. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6363. else result = "fail";
  6364. retStr += (" result=\"" + result + "\" >\r\n");
  6365. if (ret == APIErrorCode.C_SUCCESS) {
  6366. ret = energymeter.Refresh((byte) 0xFF, false);
  6367. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6368. retStr += MakeTargetStr(energymetercmd);
  6369. retStr += " <action>\"control\"</action>\r\n";
  6370. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6371. String unitStr;
  6372. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6373. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6374. if (i == 2) {
  6375. unitStr += "on";
  6376. } else {
  6377. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6378. }
  6379. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6380. }
  6381. } else {
  6382. retStr += (" result=\"fail\"> \r\n");
  6383. }
  6384. } else {
  6385. retStr += (" result=\"fail\"> \r\n");
  6386. }
  6387. retStr += " </service>\r\n</imap>\r\n";
  6388. }
  6389. }
  6390. }
  6391. return retStr;
  6392. } catch (RuntimeException re) {
  6393. LogUtil.errorLogInfo("", TAG, re);
  6394. return null;
  6395. } catch (Exception e) {
  6396. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  6397. //e.printStackTrace();
  6398. LogUtil.errorLogInfo("", TAG, e);
  6399. return null;
  6400. }
  6401. }
  6402. public String iCMDProcModeControl(Document doc) {
  6403. try {
  6404. String status = "unknown";
  6405. boolean SendBR = false;
  6406. String retStr = CheckiCMDProc("remote_access_mode");
  6407. if (retStr != null) return retStr;
  6408. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  6409. String target = "null", tid = "null", msgno = "null";
  6410. NodeList items = doc.getElementsByTagName("target");
  6411. Node item = items.item(0);
  6412. if (item != null) {
  6413. NamedNodeMap attrs = item.getAttributes();
  6414. for (int j = 0; j < attrs.getLength(); j++) {
  6415. Node attr = attrs.item(j);
  6416. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6417. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6418. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6419. msgno = attr.getNodeValue();
  6420. }
  6421. }
  6422. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6423. if (NewServerUse()) {
  6424. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  6425. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6426. return ServerCheckResult;
  6427. }
  6428. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  6429. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  6430. int curState = SetData.GetAlarmStatus();
  6431. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  6432. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  6433. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  6434. switch (curState) {
  6435. case WallpadStatusData.GUARD_IN:
  6436. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  6437. Intent intent = new Intent();
  6438. intent.setAction(define.NOTIFY_ACNAME);
  6439. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6440. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  6441. getApplicationContext().sendBroadcast(intent);
  6442. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  6443. SendBR = true;
  6444. break;
  6445. case WallpadStatusData.GUARD_OUT:
  6446. break;
  6447. }
  6448. } else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  6449. switch (curState) {
  6450. case WallpadStatusData.ALARM_NONE:
  6451. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6452. if (mIGW200.checkSensorforInmode()) {
  6453. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6454. Intent intent = new Intent();
  6455. intent.setAction(define.NOTIFY_ACNAME);
  6456. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6457. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6458. getApplicationContext().sendBroadcast(intent);
  6459. SendBR = true;
  6460. } else {
  6461. SendBR = false;
  6462. }
  6463. } 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
  6464. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6465. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6466. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6467. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6468. if (mIGW300.checkSensorforInmode()) {
  6469. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6470. Intent intent = new Intent();
  6471. intent.setAction(define.NOTIFY_ACNAME);
  6472. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6473. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6474. getApplicationContext().sendBroadcast(intent);
  6475. SendBR = true;
  6476. } else {
  6477. SendBR = false;
  6478. }
  6479. } else {
  6480. if (checkSensorforInmode()) {
  6481. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6482. Intent intent = new Intent();
  6483. intent.setAction(define.NOTIFY_ACNAME);
  6484. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6485. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6486. getApplicationContext().sendBroadcast(intent);
  6487. Sound().PlayMent(SND.mode.INMODE_SETTING);
  6488. SendBR = true;
  6489. } else {
  6490. SendBR = false;
  6491. }
  6492. }
  6493. break;
  6494. default:
  6495. break;
  6496. }
  6497. } else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  6498. if (GetUseIlgalControlForAdmin() == false) {
  6499. // 관리자용 일괄소등 원격제어 사용안할 시
  6500. switch (curState) {
  6501. case WallpadStatusData.ALARM_NONE:
  6502. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6503. if (mIGW200.checkSensorforOutmode()) {
  6504. Common.SendAppFinishReqBR(getApplicationContext());
  6505. Intent intent = new Intent();
  6506. intent.setAction(define.NOTIFY_ACNAME);
  6507. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6508. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6509. getApplicationContext().sendBroadcast(intent);
  6510. SendBR = true;
  6511. } else {
  6512. SendBR = false;
  6513. }
  6514. } 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
  6515. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6516. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6517. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6518. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6519. if (mIGW300.checkSensorforOutmode()) {
  6520. Common.SendAppFinishReqBR(getApplicationContext());
  6521. Intent intent = new Intent();
  6522. intent.setAction(define.NOTIFY_ACNAME);
  6523. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6524. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6525. getApplicationContext().sendBroadcast(intent);
  6526. SendBR = true;
  6527. } else {
  6528. SendBR = false;
  6529. }
  6530. } else {
  6531. if (checkSensorforOutmode()) {
  6532. Common.SendAppFinishReqBR(getApplicationContext());
  6533. Intent intent = new Intent();
  6534. intent.setAction(define.NOTIFY_ACNAME);
  6535. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6536. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6537. getApplicationContext().sendBroadcast(intent);
  6538. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  6539. SendBR = true;
  6540. } else {
  6541. SendBR = false;
  6542. }
  6543. }
  6544. break;
  6545. default:
  6546. break;
  6547. }
  6548. } else {
  6549. // 관리자용 일괄소등 원격제어 사용 시
  6550. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6551. SendBR = true;
  6552. }
  6553. }
  6554. } else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  6555. int getStatus = SetData.GetAlarmStatus();
  6556. switch (getStatus) {
  6557. case WallpadStatusData.GUARD_IN:
  6558. status = "occupied";
  6559. break;
  6560. case WallpadStatusData.GUARD_OUT:
  6561. status = "unoccupied";
  6562. break;
  6563. case WallpadStatusData.ALARM_NONE:
  6564. status = "normal";
  6565. break;
  6566. case WallpadStatusData.ALARM_ARISE:
  6567. status = "emergency";
  6568. break;
  6569. default:
  6570. break;
  6571. }
  6572. retStr += ("\"ok\">\r\n ");
  6573. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6574. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6575. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6576. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6577. return retStr;
  6578. }
  6579. if (!SendBR) {
  6580. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6581. SetData.closeDB();
  6582. return retStr;
  6583. } else {
  6584. try {
  6585. Thread.sleep(1000);
  6586. } catch (RuntimeException re) {
  6587. LogUtil.errorLogInfo("", TAG, re);
  6588. } catch (Exception e) {
  6589. LogUtil.errorLogInfo("", TAG, e);
  6590. }
  6591. int getStatus = SetData.GetAlarmStatus();
  6592. switch (getStatus) {
  6593. case WallpadStatusData.GUARD_IN:
  6594. status = "occupied";
  6595. break;
  6596. case WallpadStatusData.GUARD_OUT:
  6597. status = "unoccupied";
  6598. break;
  6599. case WallpadStatusData.ALARM_NONE:
  6600. status = "normal";
  6601. break;
  6602. case WallpadStatusData.ALARM_ARISE:
  6603. status = "emergency";
  6604. break;
  6605. }
  6606. }
  6607. retStr += "\"ok\">\r\n";
  6608. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6609. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6610. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6611. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6612. SetData.closeDB();
  6613. return retStr;
  6614. } catch (RuntimeException re) {
  6615. LogUtil.errorLogInfo("", TAG, re);
  6616. return null;
  6617. } catch (Exception e) {
  6618. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6619. //e.printStackTrace();
  6620. LogUtil.errorLogInfo("", TAG, e);
  6621. return null;
  6622. }
  6623. }
  6624. public String iCMDProcCurtainControl(Document ele) {
  6625. return " ";
  6626. }
  6627. public String iCMDProcSDPLightControl(Document ele) {
  6628. try {
  6629. String retStr = CheckiCMDProc("remote_access_light");
  6630. if (retStr != null) return retStr;
  6631. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6632. String target = "null", tid = "null", msgno = "null";
  6633. NodeList items = ele.getElementsByTagName("target");
  6634. Node item = items.item(0);
  6635. if (item != null) {
  6636. NamedNodeMap attrs = item.getAttributes();
  6637. for (int j = 0; j < attrs.getLength(); j++) {
  6638. Node attr = attrs.item(j);
  6639. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6640. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6641. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6642. msgno = attr.getNodeValue();
  6643. }
  6644. }
  6645. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6646. if (NewServerUse()) {
  6647. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6648. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6649. return ServerCheckResult;
  6650. }
  6651. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6652. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6653. if (energymetercmd == null) return null;
  6654. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6655. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6656. if (energymeter == null) return null;
  6657. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6658. retStr += "result=\"ok\">\r\n" +
  6659. " <action>\"status\"</action>\r\n" +
  6660. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6661. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6662. 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");
  6663. }
  6664. retStr += "\r\n</service>\r\n</imap>";
  6665. } else {
  6666. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6667. }
  6668. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6669. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6670. num--;
  6671. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6672. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6673. if (energymeter == null) return null;
  6674. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6675. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6676. retStr += "result=\"ok\">\r\n" +
  6677. " <action>\"control\"</action>\r\n" +
  6678. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6679. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6680. 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");
  6681. }
  6682. retStr += "\r\n</service>\r\n</imap>";
  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. } else {
  6690. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6691. }
  6692. energymetercmd = null;
  6693. return retStr;
  6694. } catch (RuntimeException re) {
  6695. LogUtil.errorLogInfo("", TAG, re);
  6696. return null;
  6697. } catch (Exception e) {
  6698. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6699. //e.printStackTrace();
  6700. LogUtil.errorLogInfo("", TAG, e);
  6701. return null;
  6702. }
  6703. }
  6704. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6705. try {
  6706. String retStr = CheckiCMDProc("remote_access_light");
  6707. if (retStr != null) return retStr;
  6708. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6709. String target = "null", tid = "null", msgno = "null";
  6710. NodeList items = ele.getElementsByTagName("target");
  6711. Node item = items.item(0);
  6712. if (item != null) {
  6713. NamedNodeMap attrs = item.getAttributes();
  6714. for (int j = 0; j < attrs.getLength(); j++) {
  6715. Node attr = attrs.item(j);
  6716. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6717. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6718. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6719. msgno = attr.getNodeValue();
  6720. }
  6721. }
  6722. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6723. if (NewServerUse()) {
  6724. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6725. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6726. return ServerCheckResult;
  6727. }
  6728. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6729. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6730. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6731. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6732. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6733. retStr += "result=\"ok\">\r\n" +
  6734. " <action>\"status\"</action>\r\n" +
  6735. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6736. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6737. 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");
  6738. }
  6739. retStr += "\r\n</service>\r\n</imap>";
  6740. } else {
  6741. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6742. }
  6743. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6744. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6745. num--;
  6746. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6747. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6748. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6749. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6750. retStr += "result=\"ok\">\r\n" +
  6751. " <action>\"control\"</action>\r\n" +
  6752. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6753. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6754. 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");
  6755. }
  6756. retStr += "\r\n</service>\r\n</imap>";
  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. } else {
  6764. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6765. }
  6766. energymetercmd = null;
  6767. return retStr;
  6768. } catch (RuntimeException re) {
  6769. LogUtil.errorLogInfo("", TAG, re);
  6770. return null;
  6771. } catch (Exception e) {
  6772. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6773. //e.printStackTrace();
  6774. LogUtil.errorLogInfo("", TAG, e);
  6775. return null;
  6776. }
  6777. }
  6778. public String iCMDProcLightControl(Document ele) {
  6779. try {
  6780. String retStr = CheckiCMDProc("remote_access_light");
  6781. if (retStr != null) return retStr;
  6782. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6783. String target = "null", tid = "null", msgno = "null";
  6784. NodeList items = ele.getElementsByTagName("target");
  6785. Node item = items.item(0);
  6786. if (item != null) {
  6787. NamedNodeMap attrs = item.getAttributes();
  6788. for (int j = 0; j < attrs.getLength(); j++) {
  6789. Node attr = attrs.item(j);
  6790. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6791. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6792. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6793. msgno = attr.getNodeValue();
  6794. }
  6795. }
  6796. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6797. if (NewServerUse()) {
  6798. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6799. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6800. return ServerCheckResult;
  6801. }
  6802. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6803. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6804. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6805. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6806. if (bLightCMDUseAsSmartLight) {
  6807. if (mSdbAPI != null) {
  6808. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6809. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6810. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6811. retStr += "result=\"ok\">\r\n" +
  6812. " <action>\"status\"</action>\r\n";
  6813. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6814. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6815. } else {
  6816. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6817. }
  6818. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6819. 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");
  6820. }
  6821. retStr += " </service>\r\n</imap>";
  6822. } else {
  6823. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6824. }
  6825. } else {
  6826. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6827. }
  6828. } else {
  6829. if (mMultiSwitchAPI != null) {
  6830. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6831. if (nResult == 0) {
  6832. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6833. retStr += "result=\"ok\">\r\n" +
  6834. " <action>\"status\"</action>\r\n";
  6835. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6836. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6837. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6838. } else {
  6839. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6840. }
  6841. } else {
  6842. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6843. }
  6844. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6845. 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");
  6846. }
  6847. retStr += " </service>\r\n</imap>";
  6848. } else {
  6849. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6850. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6851. }
  6852. } else {
  6853. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6854. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6855. }
  6856. } else {
  6857. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  6858. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6859. }
  6860. }
  6861. } else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  6862. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6863. boolean OnOff = false;
  6864. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6865. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  6866. if (bLightCMDUseAsSmartLight) {
  6867. if (mSdbAPI != null) {
  6868. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6869. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  6870. if (ret >= 0) {
  6871. retStr += "result=\"ok\">\r\n" +
  6872. " <action>\"status\"</action>\r\n" +
  6873. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6874. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6875. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6876. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6877. 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");
  6878. }
  6879. retStr += " </service>\r\n</imap>";
  6880. } else {
  6881. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6882. }
  6883. } else {
  6884. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6885. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  6886. if (ret >= 0) {
  6887. retStr += "result=\"ok\">\r\n" +
  6888. " <action>\"status\"</action>\r\n" +
  6889. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6890. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6891. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6892. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6893. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  6894. 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");
  6895. }
  6896. retStr += " </service>\r\n</imap>";
  6897. } else {
  6898. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6899. }
  6900. }
  6901. } else {
  6902. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6903. }
  6904. } else {
  6905. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  6906. if (mMultiSwitchAPI != null) {
  6907. int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6908. if (nResultRefresh == 0) {
  6909. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6910. if (nCtrlResult == 0) {
  6911. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6912. if (nResult == 0) {
  6913. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6914. retStr += "result=\"ok\">\r\n" +
  6915. " <action>\"status\"</action>\r\n" +
  6916. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6917. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  6918. 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");
  6919. }
  6920. retStr += " </service>\r\n</imap>";
  6921. } else {
  6922. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6923. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6924. }
  6925. } else {
  6926. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6927. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6928. }
  6929. } else {
  6930. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6931. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6932. }
  6933. } else {
  6934. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6935. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6936. }
  6937. }
  6938. } else {
  6939. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  6940. if (mMultiSwitchAPI != null) {
  6941. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  6942. if (nCtrlResult == 0) {
  6943. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6944. if (nResult == 0) {
  6945. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6946. retStr += "result=\"ok\">\r\n" +
  6947. " <action>\"status\"</action>\r\n" +
  6948. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6949. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6950. 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");
  6951. }
  6952. retStr += " </service>\r\n</imap>";
  6953. } else {
  6954. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6955. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6956. }
  6957. } else {
  6958. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6959. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6960. }
  6961. } else {
  6962. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  6963. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6964. }
  6965. }
  6966. }
  6967. }
  6968. } else {
  6969. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6970. }
  6971. } else {
  6972. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  6973. }
  6974. MSlightcmd = null;
  6975. return retStr;
  6976. } catch (RuntimeException re) {
  6977. LogUtil.errorLogInfo("", TAG, re);
  6978. return null;
  6979. } catch (Exception e) {
  6980. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  6981. //e.printStackTrace();
  6982. LogUtil.errorLogInfo("", TAG, e);
  6983. return null;
  6984. }
  6985. }
  6986. public String iCMDProcSDPSmartLightControl(Document ele) {
  6987. try {
  6988. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  6989. String retStr = CheckiCMDProc("remote_access_smartlight");
  6990. if (retStr != null) return retStr;
  6991. else
  6992. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  6993. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6994. if (NewServerUse()) {
  6995. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  6996. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6997. return ServerCheckResult;
  6998. }
  6999. if (mSdb_LivingRoomLightAPI == null) {
  7000. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7001. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  7002. return retStr;
  7003. }
  7004. if (mSdbAPI == null) {
  7005. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7006. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  7007. return retStr;
  7008. }
  7009. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7010. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7011. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7012. return retStr;
  7013. }
  7014. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7015. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
  7016. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7017. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7018. return retStr;
  7019. }
  7020. }
  7021. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  7022. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7023. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7024. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7025. retStr += " result=\"ok\">\r\n";
  7026. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7027. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7028. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7029. for (int i = 0; i < nTotalLightCnt; i++) {
  7030. if (i == 0) {
  7031. 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";
  7032. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7033. String status_power = "off", status_dim = "null", status_color = "null";
  7034. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7035. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7036. } else {
  7037. status_power = "null";
  7038. }
  7039. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7040. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7041. } else {
  7042. status_dim = "null";
  7043. }
  7044. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7045. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7046. } else {
  7047. status_color = "null";
  7048. }
  7049. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7050. }
  7051. retStr += " </status_map>\r\n";
  7052. } else {
  7053. 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";
  7054. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7055. String status_power = "off", status_dim = "null", status_color = "null";
  7056. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7057. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7058. } else {
  7059. status_power = "null";
  7060. }
  7061. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7062. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7063. } else {
  7064. status_dim = "null";
  7065. }
  7066. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7067. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7068. } else {
  7069. status_color = "null";
  7070. }
  7071. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7072. }
  7073. retStr += " </status_map>\r\n";
  7074. }
  7075. }
  7076. retStr += " </service>\r\n</imap>\r\n";
  7077. } else {
  7078. int nDevNo = 0;
  7079. try {
  7080. nDevNo = Integer.parseInt(lightcmd.devnum);
  7081. } catch (RuntimeException re) {
  7082. LogUtil.errorLogInfo("", TAG, re);
  7083. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7084. return retStr;
  7085. } catch (Exception e) {
  7086. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  7087. //e.printStackTrace();
  7088. LogUtil.errorLogInfo("", TAG, e);
  7089. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7090. return retStr;
  7091. }
  7092. if ((nDevNo - 1) > nTotalLightCnt) {
  7093. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7094. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7095. return retStr;
  7096. }
  7097. retStr += " result=\"ok\">\r\n";
  7098. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7099. retStr += " <action>\"status\"</action>\r\n";
  7100. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7101. if (nDevNo == 1) {
  7102. 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";
  7103. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7104. String status_power = "off", status_dim = "null", status_color = "null";
  7105. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7106. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7107. } else {
  7108. status_power = "null";
  7109. }
  7110. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7111. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7112. } else {
  7113. status_dim = "null";
  7114. }
  7115. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7116. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7117. } else {
  7118. status_color = "null";
  7119. }
  7120. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7121. }
  7122. retStr += " </status_map>\r\n";
  7123. } else {
  7124. 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";
  7125. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7126. String status_power = "off", status_dim = "null", status_color = "null";
  7127. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7128. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7129. } else {
  7130. status_power = "null";
  7131. }
  7132. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7133. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7134. } else {
  7135. status_dim = "null";
  7136. }
  7137. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7138. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7139. } else {
  7140. status_color = "null";
  7141. }
  7142. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7143. }
  7144. retStr += " </status_map>\r\n";
  7145. }
  7146. retStr += " </service>\r\n</imap>\r\n";
  7147. }
  7148. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7149. int nResult = -99;
  7150. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7151. NodeList items = ele.getElementsByTagName("params");
  7152. Node item = items.item(0);
  7153. if (item != null) {
  7154. NamedNodeMap attrs = item.getAttributes();
  7155. for (int j = 0; j < attrs.getLength(); j++) {
  7156. Node attr = attrs.item(j);
  7157. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7158. dev_num = attr.getNodeValue();
  7159. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7160. dev_mode = attr.getNodeValue();
  7161. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7162. unit_num = attr.getNodeValue();
  7163. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7164. unit_status = attr.getNodeValue();
  7165. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7166. unit_dimming = attr.getNodeValue();
  7167. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7168. unit_color = attr.getNodeValue();
  7169. }
  7170. }
  7171. if (dev_num.equalsIgnoreCase("all")) {
  7172. nResult = 0;
  7173. for (int i = 0; i < nTotalLightCnt; i++) {
  7174. if (i == 0) {
  7175. nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7176. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7177. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7178. } else {
  7179. nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7180. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7181. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7182. }
  7183. }
  7184. if (nResult != 0) {
  7185. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7186. Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
  7187. return retStr;
  7188. } else {
  7189. retStr += " result=\"ok\">\r\n";
  7190. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7191. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7192. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7193. }
  7194. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7195. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7196. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7197. return retStr;
  7198. }
  7199. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
  7200. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7201. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7202. return retStr;
  7203. }
  7204. for (int i = 0; i < nTotalLightCnt; i++) {
  7205. if (i == 0) {
  7206. 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";
  7207. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7208. String status_power = "off", status_dim = "null", status_color = "null";
  7209. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7210. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7211. } else {
  7212. status_power = "null";
  7213. }
  7214. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7215. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7216. } else {
  7217. status_dim = "null";
  7218. }
  7219. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7220. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7221. } else {
  7222. status_color = "null";
  7223. }
  7224. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7225. }
  7226. retStr += " </status_map>\r\n";
  7227. } else {
  7228. 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";
  7229. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7230. String status_power = "off", status_dim = "null", status_color = "null";
  7231. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7232. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7233. } else {
  7234. status_power = "null";
  7235. }
  7236. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7237. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7238. } else {
  7239. status_dim = "null";
  7240. }
  7241. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7242. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7243. } else {
  7244. status_color = "null";
  7245. }
  7246. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7247. }
  7248. retStr += " </status_map>\r\n";
  7249. }
  7250. }
  7251. retStr += " </service>\r\n</imap>\r\n";
  7252. } else {
  7253. int nDevNo = 0;
  7254. int nUnitNo = 0;
  7255. try {
  7256. nDevNo = Integer.parseInt(dev_num);
  7257. } catch (RuntimeException re) {
  7258. LogUtil.errorLogInfo("", TAG, re);
  7259. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7260. return retStr;
  7261. } catch (Exception e) {
  7262. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7263. //e.printStackTrace();
  7264. LogUtil.errorLogInfo("", TAG, e);
  7265. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7266. return retStr;
  7267. }
  7268. if ((nDevNo - 1) > nTotalLightCnt) {
  7269. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7270. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7271. return retStr;
  7272. }
  7273. nResult = -99;
  7274. if (unit_num.equalsIgnoreCase("all")) {
  7275. if (nDevNo == 1) {
  7276. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7277. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7278. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7279. } else {
  7280. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7281. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7282. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7283. }
  7284. if (nResult != 0) {
  7285. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7286. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7287. return retStr;
  7288. }
  7289. } else {
  7290. try {
  7291. nUnitNo = Integer.parseInt(unit_num);
  7292. } catch (RuntimeException re) {
  7293. LogUtil.errorLogInfo("", TAG, re);
  7294. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7295. return retStr;
  7296. } catch (Exception e) {
  7297. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7298. //e.printStackTrace();
  7299. LogUtil.errorLogInfo("", TAG, e);
  7300. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7301. return retStr;
  7302. }
  7303. nResult = -99;
  7304. if (nDevNo == 1) {
  7305. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7306. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7307. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7308. } else {
  7309. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7310. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7311. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7312. }
  7313. if (nResult != 0) {
  7314. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7315. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7316. return retStr;
  7317. }
  7318. }
  7319. if (nDevNo == 1) {
  7320. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7321. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7322. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7323. return retStr;
  7324. } else {
  7325. retStr += " result=\"ok\">\r\n";
  7326. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7327. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7328. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7329. }
  7330. 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";
  7331. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7332. String status_power = "off", status_dim = "null", status_color = "null";
  7333. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7334. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7335. } else {
  7336. status_power = "null";
  7337. }
  7338. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7339. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7340. } else {
  7341. status_dim = "null";
  7342. }
  7343. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7344. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7345. } else {
  7346. status_color = "null";
  7347. }
  7348. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7349. }
  7350. retStr += " </status_map>\r\n";
  7351. } else {
  7352. int nRealDevNo = (byte) (nDevNo - 2);
  7353. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
  7354. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7355. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7356. return retStr;
  7357. } else {
  7358. retStr += " result=\"ok\">\r\n";
  7359. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7360. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7361. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7362. }
  7363. 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";
  7364. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
  7365. String status_power = "off", status_dim = "null", status_color = "null";
  7366. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
  7367. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7368. } else {
  7369. status_power = "null";
  7370. }
  7371. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
  7372. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
  7373. } else {
  7374. status_dim = "null";
  7375. }
  7376. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
  7377. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
  7378. } else {
  7379. status_color = "null";
  7380. }
  7381. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7382. }
  7383. retStr += " </status_map>\r\n";
  7384. }
  7385. retStr += " </service>\r\n</imap>\r\n";
  7386. }
  7387. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  7388. int nResult = 0;
  7389. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7390. NodeList items = ele.getElementsByTagName("params");
  7391. Node item = items.item(0);
  7392. if (item != null) {
  7393. NamedNodeMap attrs = item.getAttributes();
  7394. for (int j = 0; j < attrs.getLength(); j++) {
  7395. Node attr = attrs.item(j);
  7396. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7397. dev_num = attr.getNodeValue();
  7398. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7399. dev_mode = attr.getNodeValue();
  7400. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7401. unit_num = attr.getNodeValue();
  7402. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7403. unit_status = attr.getNodeValue();
  7404. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7405. unit_dimming = attr.getNodeValue();
  7406. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7407. unit_color = attr.getNodeValue();
  7408. }
  7409. }
  7410. if (dev_num.equalsIgnoreCase("all")) {
  7411. if (!dev_mode.equals("null")) {
  7412. nResult = -99;
  7413. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7414. if (nResult != 0) {
  7415. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7416. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7417. return retStr;
  7418. }
  7419. } else {
  7420. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7421. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7422. return retStr;
  7423. }
  7424. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7425. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7426. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7427. return retStr;
  7428. } else {
  7429. retStr += " result=\"ok\">\r\n";
  7430. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7431. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7432. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7433. }
  7434. 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";
  7435. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  7436. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7437. } else {
  7438. int nDevNo = 0;
  7439. try {
  7440. nDevNo = Integer.parseInt(dev_num);
  7441. } catch (RuntimeException re) {
  7442. LogUtil.errorLogInfo("", TAG, re);
  7443. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7444. return retStr;
  7445. } catch (Exception e) {
  7446. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7447. //e.printStackTrace();
  7448. LogUtil.errorLogInfo("", TAG, e);
  7449. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7450. return retStr;
  7451. }
  7452. if (nDevNo != 1) {
  7453. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  7454. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7455. return retStr;
  7456. }
  7457. if (!dev_mode.equals("null")) {
  7458. nResult = -99;
  7459. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7460. if (nResult != 0) {
  7461. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7462. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7463. return retStr;
  7464. }
  7465. } else {
  7466. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7467. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7468. return retStr;
  7469. }
  7470. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7471. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7472. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7473. return retStr;
  7474. } else {
  7475. retStr += " result=\"ok\">\r\n";
  7476. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7477. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7478. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7479. }
  7480. 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";
  7481. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7482. String status_power = "off", status_dim = "null", status_color = "null";
  7483. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7484. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7485. } else {
  7486. status_power = "null";
  7487. }
  7488. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7489. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7490. } else {
  7491. status_dim = "null";
  7492. }
  7493. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7494. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7495. } else {
  7496. status_color = "null";
  7497. }
  7498. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7499. }
  7500. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7501. }
  7502. } else {
  7503. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7504. }
  7505. lightcmd = null;
  7506. return retStr;
  7507. } catch (RuntimeException re) {
  7508. LogUtil.errorLogInfo("", TAG, re);
  7509. return null;
  7510. } catch (Exception e) {
  7511. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7512. //e.printStackTrace();
  7513. LogUtil.errorLogInfo("", TAG, e);
  7514. return null;
  7515. }
  7516. }
  7517. private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
  7518. byte type = 0;
  7519. //각 스위치 개수는 4개임
  7520. switch (lightIndex) {
  7521. case 0:
  7522. type = benEm.Info.LightType_1;
  7523. break;
  7524. case 1:
  7525. type = benEm.Info.LightType_2;
  7526. break;
  7527. case 2:
  7528. type = benEm.Info.LightType_3;
  7529. break;
  7530. case 3:
  7531. type = benEm.Info.LightType_4;
  7532. break;
  7533. default:
  7534. break;
  7535. }
  7536. return type;
  7537. }
  7538. public String iCMDProcChumDamSmartLightControl(Document ele) {
  7539. try {
  7540. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7541. String retStr = CheckiCMDProc("remote_access_smartlight");
  7542. if (retStr != null) return retStr;
  7543. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7544. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7545. if (NewServerUse()) {
  7546. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7547. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7548. }
  7549. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  7550. if (KnxApi == null) {
  7551. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7552. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
  7553. return retStr;
  7554. }
  7555. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7556. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7557. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7558. return retStr;
  7559. }
  7560. int LivingLightCount = 0;
  7561. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  7562. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  7563. } else {
  7564. if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  7565. LivingLightCount = 1;
  7566. }
  7567. //기준층 명칭
  7568. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  7569. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  7570. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_LIGHT);
  7571. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  7572. int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  7573. int SwitchCount = KnxApi.data.MasterController.Info.Light_SwitchCount;
  7574. int totalLightCount = LivingLightCount + BadLightCount + SwitchCount;
  7575. int emCount = LivingLightCount + BadLightCount;
  7576. //mData.MasterController.Info.Light_SwitchCount
  7577. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
  7578. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
  7579. {
  7580. retStr += " result=\"ok\">\r\n";
  7581. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7582. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7583. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7584. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7585. for (int i = 0; i < totalLightCount; i++) {
  7586. if (i == 0) {
  7587. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7588. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7589. String status_power = "off", status_dim = "null", status_color = "null";
  7590. 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);
  7591. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7592. 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);
  7593. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7594. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7595. }
  7596. retStr += " </status_map>\r\n";
  7597. } else if(i>0 && i<emCount){
  7598. 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";
  7599. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7600. String status_power = "off", status_dim = "null", status_color = "null";
  7601. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7602. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7603. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7604. status_dim ="null";
  7605. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7606. }
  7607. retStr += " </status_map>\r\n";
  7608. } else{
  7609. 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";
  7610. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7611. String status_power = "off", status_dim = "null", status_color = "null";
  7612. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7613. status_dim ="null";
  7614. // zzz
  7615. //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
  7616. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7617. }
  7618. retStr += " </status_map>\r\n";
  7619. }
  7620. }
  7621. }
  7622. else
  7623. {
  7624. int nResult = 0;
  7625. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7626. NodeList items = ele.getElementsByTagName("params");
  7627. Node item = items.item(0);
  7628. if (item != null) {
  7629. NamedNodeMap attrs = item.getAttributes();
  7630. for (int j = 0; j< attrs.getLength(); j++) {
  7631. Node attr = attrs.item(j);
  7632. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7633. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7634. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7635. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7636. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7637. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7638. }
  7639. }
  7640. int nDevNo = Integer.parseInt(dev_num);
  7641. if (nDevNo == 1) {
  7642. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7643. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7644. String status_power = "off", status_dim = "null", status_color = "null";
  7645. 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);
  7646. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7647. 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);
  7648. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7649. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7650. }
  7651. retStr += " </status_map>\r\n";
  7652. } else if(nDevNo>1 && nDevNo<emCount+1){
  7653. 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";
  7654. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
  7655. String status_power = "off", status_dim = "null", status_color = "null";
  7656. status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7657. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
  7658. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
  7659. status_dim ="null";
  7660. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7661. }
  7662. retStr += " </status_map>\r\n";
  7663. } else{
  7664. 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";
  7665. for (int j = 0; j < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount; j++) {
  7666. String status_power = "off", status_dim = "null", status_color = "null";
  7667. status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7668. status_dim ="null";
  7669. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7670. }
  7671. retStr += " </status_map>\r\n";
  7672. }
  7673. }
  7674. retStr += " </service>\r\n</imap>\r\n";
  7675. }
  7676. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7677. int nResult = 0;
  7678. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7679. NodeList items = ele.getElementsByTagName("params");
  7680. Node item = items.item(0);
  7681. if (item != null) {
  7682. NamedNodeMap attrs = item.getAttributes();
  7683. for (int j = 0; j< attrs.getLength(); j++) {
  7684. Node attr = attrs.item(j);
  7685. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7686. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7687. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7688. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7689. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7690. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7691. }
  7692. }
  7693. if (dev_num.equalsIgnoreCase("ALL")) {
  7694. // 일괄소등 실행/해제
  7695. if (!unit_status.equalsIgnoreCase("null")) {
  7696. KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
  7697. }
  7698. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7699. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7700. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7701. return retStr;
  7702. }
  7703. retStr += " result=\"ok\">\r\n";
  7704. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7705. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7706. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7707. for (int i = 0; i < totalLightCount; i++) {
  7708. if (i == 0) {
  7709. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ "null" + "\" dev_name=\""+ knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7710. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7711. String status_power = "off", status_dim = "null", status_color = "null";
  7712. 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);
  7713. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7714. 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);
  7715. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7716. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7717. }
  7718. retStr += " </status_map>\r\n";
  7719. }
  7720. else if(i>0 && i<emCount){
  7721. 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";
  7722. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7723. String status_power = "off", status_dim = "null", status_color = "null";
  7724. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7725. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7726. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7727. status_dim ="null";
  7728. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7729. }
  7730. retStr += " </status_map>\r\n";
  7731. } else {
  7732. 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";
  7733. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7734. String status_power = "off", status_dim = "null", status_color = "null";
  7735. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7736. status_dim ="null";
  7737. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7738. }
  7739. retStr += " </status_map>\r\n";
  7740. }
  7741. }
  7742. retStr += " </service>\r\n</imap>\r\n";
  7743. }
  7744. else {
  7745. int nDevNo = 0;
  7746. int nUnitNo = 0;
  7747. try {
  7748. nDevNo = Integer.parseInt(dev_num);
  7749. } catch (Exception e) {
  7750. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7751. e.printStackTrace();
  7752. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7753. return retStr;
  7754. }
  7755. if ((nDevNo - 1) > totalLightCount) {
  7756. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
  7757. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7758. return retStr;
  7759. }
  7760. // retStr += " result=\"ok\">\r\n";
  7761. // retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7762. // retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7763. // retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7764. if (unit_num.equalsIgnoreCase("all")) {
  7765. if (nDevNo == 1) {
  7766. // 거실 조명 일괄제어일 경우
  7767. if (!unit_status.equalsIgnoreCase("null")) {
  7768. int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7769. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7770. }
  7771. if (!unit_dimming.equalsIgnoreCase("null")) {
  7772. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7773. }
  7774. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7775. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7776. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7777. return retStr;
  7778. }
  7779. retStr += " result=\"ok\">\r\n";
  7780. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7781. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7782. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7783. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7784. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7785. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7786. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7787. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7788. }
  7789. }
  7790. else if(nDevNo>1 && nDevNo<emCount+1){
  7791. // 각각 EM 조명 일괄제어일 경우
  7792. if (!unit_status.equalsIgnoreCase("null")) {
  7793. KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7794. }
  7795. if (!unit_dimming.equalsIgnoreCase("null")) {
  7796. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : ");
  7797. if( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_2 == 0x0F
  7798. || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_3 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_4 == 0x0F)
  7799. {
  7800. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] ==> Fan : " + nDevNo );
  7801. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7802. // 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
  7803. int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
  7804. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7805. }
  7806. }
  7807. else {
  7808. int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7809. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7810. }
  7811. //KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
  7812. }
  7813. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7814. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7815. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7816. return retStr;
  7817. }
  7818. retStr += " result=\"ok\">\r\n";
  7819. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7820. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7821. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7822. 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";
  7823. nDevNo = Integer.parseInt(dev_num);
  7824. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7825. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7826. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7827. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7828. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7829. status_dim ="null";
  7830. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7831. }
  7832. } else {
  7833. // 각각 EM 스위치 일괄제어일 경우
  7834. if (!unit_status.equalsIgnoreCase("null")) {
  7835. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7836. }
  7837. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7838. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7839. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7840. return retStr;
  7841. }
  7842. retStr += " result=\"ok\">\r\n";
  7843. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7844. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7845. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7846. 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";
  7847. nDevNo = Integer.parseInt(dev_num);
  7848. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7849. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7850. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7851. String status_dim ="null";
  7852. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7853. }
  7854. }
  7855. // retStr += " </status_map>\r\n";
  7856. // retStr += " </service>\r\n</imap>\r\n";
  7857. }
  7858. else {
  7859. // 회로별 제어일경우
  7860. try {
  7861. nUnitNo = Integer.parseInt(unit_num);
  7862. } catch (Exception e) {
  7863. Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7864. e.printStackTrace();
  7865. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7866. return retStr;
  7867. }
  7868. if (nDevNo == 1) {
  7869. if (!unit_status.equalsIgnoreCase("null")) {
  7870. int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
  7871. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7872. }
  7873. if (!unit_dimming.equalsIgnoreCase("null")) {
  7874. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7875. //mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  7876. }
  7877. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7878. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7879. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7880. return retStr;
  7881. }
  7882. retStr += " result=\"ok\">\r\n";
  7883. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7884. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7885. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7886. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7887. nDevNo = Integer.parseInt(dev_num);
  7888. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7889. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7890. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7891. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7892. }
  7893. }
  7894. else if(nDevNo>1 && nDevNo<emCount+1){
  7895. if (!unit_status.equalsIgnoreCase("null")) {
  7896. KnxApi.SetLightOnOff((byte) (nDevNo -2), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7897. //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7898. //회로별 제어는 On/Off 만 가능함
  7899. }
  7900. if (!unit_dimming.equalsIgnoreCase("null")) {
  7901. KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)(nUnitNo-1),(byte) Integer.parseInt(unit_dimming));
  7902. //일괄제어라 회로별 제어기능은 없음
  7903. // 시험 2021.05.12
  7904. }
  7905. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7906. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7907. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7908. return retStr;
  7909. }
  7910. retStr += " result=\"ok\">\r\n";
  7911. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7912. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7913. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7914. 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";
  7915. nDevNo = Integer.parseInt(dev_num);
  7916. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7917. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7918. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7919. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7920. status_dim ="null";
  7921. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7922. }
  7923. } else{
  7924. if (!unit_status.equalsIgnoreCase("null")) {
  7925. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  7926. }
  7927. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7928. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7929. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7930. return retStr;
  7931. }
  7932. retStr += " result=\"ok\">\r\n";
  7933. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7934. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7935. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7936. 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";
  7937. nDevNo = Integer.parseInt(dev_num);
  7938. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7939. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7940. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7941. String status_dim ="null";
  7942. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7943. }
  7944. }
  7945. }
  7946. retStr += " </status_map>\r\n";
  7947. retStr += " </service>\r\n</imap>\r\n";
  7948. }
  7949. }
  7950. else {
  7951. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7952. }
  7953. return retStr;
  7954. } catch (Exception e) {
  7955. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7956. e.printStackTrace();
  7957. return null;
  7958. }
  7959. }
  7960. public String iCMDProcLivingLightControl(Document ele) {
  7961. try {
  7962. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7963. String retStr = CheckiCMDProc("remote_access_livinglight");
  7964. if (retStr != null) return retStr;
  7965. else
  7966. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  7967. String target = "null", tid = "null", msgno = "null";
  7968. NodeList items = ele.getElementsByTagName("target");
  7969. Node item = items.item(0);
  7970. if (item != null) {
  7971. NamedNodeMap attrs = item.getAttributes();
  7972. for (int j = 0; j < attrs.getLength(); j++) {
  7973. Node attr = attrs.item(j);
  7974. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7975. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7976. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  7977. msgno = attr.getNodeValue();
  7978. }
  7979. }
  7980. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7981. if (NewServerUse()) {
  7982. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7983. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  7984. return ServerCheckResult;
  7985. }
  7986. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7987. if (bLightCMDUseAsSmartLight) {
  7988. if (mSdb_LivingRoomLightAPI != null) {
  7989. mSdb_LivingRoomLightAPI.Refresh();
  7990. 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";
  7991. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7992. 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");
  7993. }
  7994. retStr += " </service>\r\n</imap>\r\n";
  7995. } else {
  7996. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7997. }
  7998. } else {
  7999. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8000. if (lightCTR != null) {
  8001. if (lightCTR.Refresh(false) == 0) {
  8002. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8003. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8004. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8005. }
  8006. retStr += " </service>\r\n</imap>\r\n";
  8007. } else {
  8008. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  8009. }
  8010. }
  8011. }
  8012. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8013. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  8014. boolean OnOff = false;
  8015. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  8016. if (bLightCMDUseAsSmartLight) {
  8017. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8018. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  8019. if (ret >= 0) {
  8020. ret = mSdb_LivingRoomLightAPI.Refresh();
  8021. if (ret >= 0) {
  8022. 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";
  8023. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8024. 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");
  8025. }
  8026. retStr += " </service>\r\n</imap>\r\n";
  8027. } else {
  8028. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8029. }
  8030. } else {
  8031. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8032. }
  8033. } else {
  8034. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8035. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  8036. if (ret >= 0) {
  8037. ret = mSdb_LivingRoomLightAPI.Refresh();
  8038. if (ret >= 0) {
  8039. 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";
  8040. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8041. 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");
  8042. }
  8043. retStr += " </service>\r\n</imap>\r\n";
  8044. } else {
  8045. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8046. }
  8047. } else {
  8048. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8049. }
  8050. }
  8051. } else {
  8052. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8053. if (lightCTR != null) {
  8054. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8055. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  8056. if (ret >= 0) {
  8057. ret = lightCTR.Refresh(false);
  8058. if (ret >= 0) {
  8059. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8060. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8061. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8062. }
  8063. retStr += " </service>\r\n</imap>\r\n";
  8064. } else {
  8065. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8066. }
  8067. } else {
  8068. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8069. }
  8070. } else {
  8071. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8072. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  8073. if (ret >= 0) {
  8074. ret = lightCTR.Refresh(false);
  8075. if (ret >= 0) {
  8076. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8077. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8078. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8079. }
  8080. retStr += " </service>\r\n</imap>\r\n";
  8081. } else {
  8082. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8083. }
  8084. } else {
  8085. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8086. }
  8087. }
  8088. }
  8089. }
  8090. } else {
  8091. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8092. }
  8093. } else {
  8094. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  8095. }
  8096. lightcmd = null;
  8097. return retStr;
  8098. } catch (RuntimeException re) {
  8099. LogUtil.errorLogInfo("", TAG, re);
  8100. return null;
  8101. } catch (Exception e) {
  8102. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  8103. //e.printStackTrace();
  8104. LogUtil.errorLogInfo("", TAG, e);
  8105. return null;
  8106. }
  8107. }
  8108. public String iCMDProc_I_LightControl(Document ele) {
  8109. try {
  8110. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  8111. String retStr = CheckiCMDProc("remote_access_livinglight");
  8112. if (retStr != null) return retStr;
  8113. else
  8114. retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  8115. String target = "null", tid = "null", msgno = "null";
  8116. NodeList items = ele.getElementsByTagName("target");
  8117. Node item = items.item(0);
  8118. if (item != null) {
  8119. NamedNodeMap attrs = item.getAttributes();
  8120. for (int j = 0; j < attrs.getLength(); j++) {
  8121. Node attr = attrs.item(j);
  8122. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8123. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8124. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8125. msgno = attr.getNodeValue();
  8126. }
  8127. }
  8128. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8129. if (NewServerUse()) {
  8130. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8131. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8132. return ServerCheckResult;
  8133. }
  8134. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  8135. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8136. if (lightCTR != null && lightCTR.Refresh(false) == 0) {
  8137. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8138. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8139. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8140. }
  8141. retStr += " </service>\r\n</imap>\r\n";
  8142. } else {
  8143. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  8144. }
  8145. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8146. if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  8147. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  8148. int result = -999;
  8149. if (lightCTR != null) {
  8150. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  8151. result = lightCTR.LightProgramControl((byte) num, (byte) 1);
  8152. } else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  8153. result = lightCTR.LightProgramControl((byte) num, (byte) 0);
  8154. }
  8155. if (result >= 0) {
  8156. // 제어 성공
  8157. try {
  8158. Thread.sleep(1000);
  8159. } catch (RuntimeException re) {
  8160. LogUtil.errorLogInfo("", TAG, re);
  8161. } catch (Exception e) {
  8162. LogUtil.errorLogInfo("", TAG, e);
  8163. }
  8164. lightCTR.Refresh(false);
  8165. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8166. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8167. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8168. }
  8169. retStr += " </service>\r\n</imap>";
  8170. } else {
  8171. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8172. }
  8173. } else {
  8174. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8175. }
  8176. } else {
  8177. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8178. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  8179. if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  8180. try {
  8181. Thread.sleep(1000);
  8182. } catch (RuntimeException re) {
  8183. LogUtil.errorLogInfo("", TAG, re);
  8184. } catch (Exception e) {
  8185. LogUtil.errorLogInfo("", TAG, e);
  8186. }
  8187. lightCTR.Refresh(false);
  8188. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8189. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8190. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8191. }
  8192. retStr += " </service>\r\n</imap>\r\n";
  8193. } else {
  8194. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8195. }
  8196. }
  8197. } else {
  8198. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  8199. }
  8200. lightcmd = null;
  8201. return retStr;
  8202. } catch (RuntimeException re) {
  8203. LogUtil.errorLogInfo("", TAG, re);
  8204. return null;
  8205. } catch (Exception e) {
  8206. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  8207. //e.printStackTrace();
  8208. LogUtil.errorLogInfo("", TAG, e);
  8209. return null;
  8210. }
  8211. }
  8212. public String iCMDProcGASControl(Element ele) {
  8213. try {
  8214. String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
  8215. String strResult = CheckiCMDProc("remote_access_gas");
  8216. if (strResult != null) return strResult;
  8217. else
  8218. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  8219. NodeList items = ele.getElementsByTagName("target");
  8220. Node item = items.item(0);
  8221. if (item != null) {
  8222. NamedNodeMap attrs = item.getAttributes();
  8223. for (int j = 0; j < attrs.getLength(); j++) {
  8224. Node attr = attrs.item(j);
  8225. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8226. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8227. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8228. msgno = attr.getNodeValue();
  8229. }
  8230. }
  8231. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8232. if (NewServerUse()) {
  8233. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  8234. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8235. return ServerCheckResult;
  8236. }
  8237. NodeList itemsParam = ele.getElementsByTagName("params");
  8238. Node itemParam = itemsParam.item(0);
  8239. if (itemParam != null) {
  8240. NamedNodeMap attrsParam = itemParam.getAttributes();
  8241. for (int j = 0; j < attrsParam.getLength(); j++) {
  8242. Node attr = attrsParam.item(j);
  8243. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8244. devnum = attr.getNodeValue();
  8245. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  8246. //unitnum = attr.getNodeValue();
  8247. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8248. ctraction = attr.getNodeValue();
  8249. }
  8250. }
  8251. NodeList itemsaction = ele.getElementsByTagName("action");
  8252. Node itemaction = itemsaction.item(0);
  8253. Node text = itemaction.getFirstChild();
  8254. String actionTXT = text.getNodeValue();
  8255. //수정
  8256. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  8257. actionTXT = trimquotation(actionTXT);
  8258. GasAPI GasValveCTR = null;
  8259. CooktopAPI HybridCookTopCTR = null;
  8260. if (mWallPadAPI.GetGasKind() == 2) {
  8261. //하이브리드
  8262. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  8263. } else {
  8264. GasValveCTR = mWallPadAPI.Get_GasController();
  8265. }
  8266. if (actionTXT.equalsIgnoreCase("status")) {
  8267. // 가스밸브 상태 조회
  8268. if (mWallPadAPI.GetGasKind() == 2) {
  8269. //하이브리드
  8270. if (HybridCookTopCTR != null) {
  8271. //전체 정보가져오기
  8272. int ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8273. if (ret < 0) {
  8274. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8275. return strResult;
  8276. }
  8277. int OnOpenCount = 0;
  8278. int OperationCount = 0;
  8279. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8280. // 콘센트 ON/OFF 업데이트
  8281. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8282. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8283. OnOpenCount++;
  8284. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8285. OperationCount++;
  8286. }
  8287. }
  8288. }
  8289. if (OperationCount > 0) {
  8290. valvestatus = "ing";
  8291. } else if (OnOpenCount > 0) {
  8292. valvestatus = "open";
  8293. } else {
  8294. valvestatus = "close";
  8295. }
  8296. }
  8297. } else {
  8298. if (GasValveCTR != null) {
  8299. int ret = GasValveCTR.Refresh((byte) 0, false);
  8300. if (ret < 0) {
  8301. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8302. return strResult;
  8303. }
  8304. if (GasValveCTR.data.DeviceCnt == 2) {
  8305. GasValveCTR.Refresh((byte) 1, false);
  8306. }
  8307. byte GasStatus = GasAPI.GASSTATUS.Close;
  8308. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8309. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8310. GasStatus = GasAPI.GASSTATUS.Operation;
  8311. break;
  8312. }
  8313. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8314. GasStatus = GasAPI.GASSTATUS.Open;
  8315. break;
  8316. }
  8317. }
  8318. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8319. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8320. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8321. else valvestatus = "unknown";
  8322. }
  8323. }
  8324. } else if (actionTXT.equalsIgnoreCase("control")) {
  8325. // 가스밸브 콘트롤
  8326. if (mWallPadAPI.GetGasKind() == 2) {
  8327. //하이브리드
  8328. if (HybridCookTopCTR != null) {
  8329. int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
  8330. if (ret < 0) {
  8331. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8332. return strResult;
  8333. }
  8334. ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8335. if (ret < 0) {
  8336. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8337. return strResult;
  8338. }
  8339. int OnOpenCount = 0;
  8340. int OperationCount = 0;
  8341. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8342. // 콘센트 ON/OFF 업데이트
  8343. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8344. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8345. OnOpenCount++;
  8346. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8347. OperationCount++;
  8348. }
  8349. }
  8350. }
  8351. if (OperationCount > 0) {
  8352. valvestatus = "ing";
  8353. } else if (OnOpenCount > 0) {
  8354. valvestatus = "open";
  8355. } else {
  8356. valvestatus = "close";
  8357. }
  8358. }
  8359. } else {
  8360. if (GasValveCTR != null) {
  8361. int ret = GasValveCTR.SetClose((byte) 0xFF);
  8362. if (ret < 0) {
  8363. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8364. return strResult;
  8365. }
  8366. ret = GasValveCTR.Refresh((byte) 0, false);
  8367. if (ret < 0) {
  8368. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8369. return strResult;
  8370. }
  8371. if (GasValveCTR.data.DeviceCnt == 2) {
  8372. GasValveCTR.Refresh((byte) 1, false);
  8373. }
  8374. byte GasStatus = GasAPI.GASSTATUS.Close;
  8375. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8376. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8377. GasStatus = GasAPI.GASSTATUS.Operation;
  8378. break;
  8379. }
  8380. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8381. GasStatus = GasAPI.GASSTATUS.Open;
  8382. break;
  8383. }
  8384. }
  8385. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8386. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8387. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8388. else valvestatus = "unknown";
  8389. }
  8390. }
  8391. } else {
  8392. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8393. return strResult;
  8394. }
  8395. strResult += "\"ok\" >\r\n";
  8396. strResult += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8397. strResult += " <action>\"" + actionTXT + "\"</action>\r\n";
  8398. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  8399. strResult += " <status_info unit_num=\"gas1\" unit_status=\"" + valvestatus + "\"/>\r\n";
  8400. strResult += " </service>\r\n";
  8401. strResult += "</imap> ";
  8402. return strResult;
  8403. } catch (RuntimeException re) {
  8404. LogUtil.errorLogInfo("", TAG, re);
  8405. return null;
  8406. } catch (Exception e) {
  8407. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  8408. //e.printStackTrace();
  8409. LogUtil.errorLogInfo("", TAG, e);
  8410. return null;
  8411. }
  8412. }
  8413. private String iCMDProcLightBatchControl(Element ele) {
  8414. try {
  8415. String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
  8416. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  8417. if (retStr != null) return retStr;
  8418. NodeList items = ele.getElementsByTagName("target");
  8419. Node item = items.item(0);
  8420. if (item != null) {
  8421. NamedNodeMap attrs = item.getAttributes();
  8422. for (int j = 0; j < attrs.getLength(); j++) {
  8423. Node attr = attrs.item(j);
  8424. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8425. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8426. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8427. msgno = attr.getNodeValue();
  8428. }
  8429. }
  8430. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8431. if (NewServerUse()) {
  8432. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8433. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8434. return ServerCheckResult;
  8435. }
  8436. NodeList itemsParam = ele.getElementsByTagName("params");
  8437. Node itemParam = itemsParam.item(0);
  8438. if (itemParam != null) {
  8439. NamedNodeMap attrsParam = itemParam.getAttributes();
  8440. for (int j = 0; j < attrsParam.getLength(); j++) {
  8441. Node attr = attrsParam.item(j);
  8442. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8443. ctraction = attr.getNodeValue();
  8444. }
  8445. }
  8446. }
  8447. NodeList itemsaction = ele.getElementsByTagName("action");
  8448. Node itemaction = itemsaction.item(0);
  8449. Node text = itemaction.getFirstChild();
  8450. String actionTXT = text.getNodeValue();
  8451. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  8452. actionTXT = trimquotation(actionTXT);
  8453. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8454. if (actionTXT.equalsIgnoreCase("status")) {
  8455. // 일괄소등 상태 조회
  8456. int ret = mWallPadAPI.GetBatchSwitchStatus();
  8457. if (ret > 1) {
  8458. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8459. return retStr;
  8460. }
  8461. if (ret == 0) {
  8462. ilgalstatus = "on";
  8463. } else if (ret == 1) {
  8464. ilgalstatus = "off";
  8465. } else {
  8466. ilgalstatus = "error";
  8467. }
  8468. } else if (actionTXT.equalsIgnoreCase("control")) {
  8469. // 일괄소등 제어
  8470. int ret = -1;
  8471. int status = -1;
  8472. if (ctraction.equals("on") == true) {
  8473. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  8474. status = 0;
  8475. } else if (ctraction.equals("off") == true) {
  8476. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  8477. status = 1;
  8478. }
  8479. if (ret < 0) {
  8480. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8481. return retStr;
  8482. }
  8483. if (status == 0) {
  8484. ilgalstatus = "on";
  8485. } else if (status == 1) {
  8486. ilgalstatus = "off";
  8487. } else {
  8488. ilgalstatus = "error";
  8489. }
  8490. } else {
  8491. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8492. return retStr;
  8493. }
  8494. retStr += "\"ok\" >\r\n";
  8495. retStr += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8496. retStr += " <action>\"" + actionTXT + "\"</action>\r\n";
  8497. retStr += " <status_info unit_status=\"" + ilgalstatus + "\"/>\r\n </service>\r\n</imap> ";
  8498. return retStr;
  8499. } catch (RuntimeException re) {
  8500. LogUtil.errorLogInfo("", TAG, re);
  8501. return null;
  8502. } catch (Exception e) {
  8503. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  8504. //e.printStackTrace();
  8505. LogUtil.errorLogInfo("", TAG, e);
  8506. return null;
  8507. }
  8508. }
  8509. private boolean airconTestMode = false;
  8510. private boolean [] airconTestModeOnOff = {false, true, false, true, false, true, false, true, false, true, false};
  8511. private String getTextSysAirconMode(byte in)
  8512. {
  8513. if( in == DataClasses.KnxSystemAircon.MODE.Auto)
  8514. return "auto";
  8515. else if( in == DataClasses.KnxSystemAircon.MODE.Cold)
  8516. return "cool";
  8517. else if( in == DataClasses.KnxSystemAircon.MODE.Dry)
  8518. return "dehum";
  8519. else if( in == DataClasses.KnxSystemAircon.MODE.Venti)
  8520. return "blow";
  8521. else if( in == DataClasses.KnxSystemAircon.MODE.Heat)
  8522. return "heat";
  8523. else
  8524. return "null";
  8525. }
  8526. private String iCMDProcSysairconControl(Element ele) {
  8527. try {
  8528. String target= "null", tid= "null", msgno= "null", devnum = "null",ctraction = "null", ilgalstatus = "null";
  8529. String retStr = CheckiCMDProc("remote_access_sysaircon");
  8530. if (retStr != null) return retStr;
  8531. NodeList items = ele.getElementsByTagName("target");
  8532. Node item = items.item(0);
  8533. if (item != null) {
  8534. NamedNodeMap attrs = item.getAttributes();
  8535. for (int j = 0; j < attrs.getLength(); j++) {
  8536. Node attr = attrs.item(j);
  8537. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8538. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8539. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  8540. }
  8541. }
  8542. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8543. if (NewServerUse()) {
  8544. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8545. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  8546. }
  8547. NodeList itemsParam = ele.getElementsByTagName("params");
  8548. Node itemParam = itemsParam.item(0);
  8549. if (itemParam != null) {
  8550. NamedNodeMap attrsParam = itemParam.getAttributes();
  8551. for (int j = 0; j < attrsParam.getLength(); j++) {
  8552. Node attr = attrsParam.item(j);
  8553. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  8554. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8555. ctraction = attr.getNodeValue();
  8556. }
  8557. }
  8558. }
  8559. NodeList itemsaction = ele.getElementsByTagName("action");
  8560. Node itemaction = itemsaction.item(0);
  8561. Node text = itemaction.getFirstChild();
  8562. String actionTXT = text.getNodeValue();
  8563. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_sysaircon\" result=";
  8564. actionTXT = trimquotation(actionTXT);
  8565. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8566. int ndeviceCount = 0;
  8567. String sMode = "auto/cool/dehum/blow/heat"; // 자동, 냉방, 제습, 송풍, 난방
  8568. String [] aMode = {"auto","cool","dehum","blow","heat"};
  8569. String strResultStatus = "";
  8570. //기준층 명칭
  8571. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  8572. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  8573. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_SYSTEMAIRCON);
  8574. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  8575. String [] mTextWindType = {"자동", "약", "중", "강"};
  8576. String m_TextWindRange = "자동/약/중/강";
  8577. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  8578. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  8579. mWallpadDeviceSet.closeDB();
  8580. if (nResult != Version.DISTRIBUTION_MODEL.KNX_DIST) {
  8581. String[] mAirconNmae = new String[]{"에어컨1", "에어컨2", "에어컨3", "에어컨4", "에어컨5", "에어컨6", "에어컨7", "에어컨8"};
  8582. knxRoomNameList = mAirconNmae;
  8583. }
  8584. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  8585. int nCount = 7;
  8586. if( airconAPI != null )
  8587. nCount = airconAPI.data.Device.info.InsideAirconCount;
  8588. if( airconTestMode == true )nCount = 7;
  8589. if( actionTXT.equalsIgnoreCase("status") ) {
  8590. // 에어컨 상태조회
  8591. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8592. if (devnum.equalsIgnoreCase("all")) {
  8593. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : airconTestMode : " + airconTestMode + " nCount : " + nCount );
  8594. if (airconTestMode == false && ret < 0) {
  8595. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8596. return retStr;
  8597. } else {
  8598. for (int i = 0; i < nCount; i++) {
  8599. String sOnOff = "off";
  8600. if( airconTestMode == true )
  8601. {
  8602. if( airconTestModeOnOff[i] == true )sOnOff = "on";
  8603. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8604. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8605. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8606. }
  8607. else {
  8608. if (airconAPI.data.Device.Aircon[i].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8609. sOnOff = "on";
  8610. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8611. 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";
  8612. }
  8613. }
  8614. }
  8615. }
  8616. else
  8617. {
  8618. // 개별 상태 조회
  8619. if (airconTestMode == false && ret < 0) {
  8620. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8621. return retStr;
  8622. } else {
  8623. int reqDevNum = Integer.parseInt(devnum);
  8624. String sOnOff = "off";
  8625. if( airconTestMode == true )
  8626. {
  8627. if( airconTestModeOnOff[reqDevNum-1] == true )sOnOff = "on";
  8628. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8629. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8630. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8631. }
  8632. else {
  8633. if (airconAPI.data.Device.Aircon[reqDevNum-1].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8634. sOnOff = "on";
  8635. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8636. 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";
  8637. }
  8638. }
  8639. }
  8640. }
  8641. else if (actionTXT.equalsIgnoreCase("control")) {
  8642. // 에어컨 제어
  8643. String[] CtrList;
  8644. CtrList = ctraction.split("/");
  8645. for( int k = 0 ; k < CtrList.length; k++)
  8646. {
  8647. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : CtrList[k] : " + k + " CtrList[k] : " + CtrList[k]);
  8648. }
  8649. strResultStatus = "";
  8650. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8651. if (devnum.equalsIgnoreCase("all")) {
  8652. // 일괄제어는 Off 밖에 없음
  8653. if( airconTestMode == true )
  8654. {
  8655. for (int i = 0; i < nCount; i++) {
  8656. String sOnOff = "off";
  8657. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8658. if(CtrList[0].equalsIgnoreCase("off"))
  8659. {
  8660. airconTestModeOnOff[i] = false;
  8661. }
  8662. else
  8663. {
  8664. airconTestModeOnOff[i] = true;
  8665. sOnOff = "on";
  8666. }
  8667. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8668. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8669. }
  8670. }
  8671. else
  8672. {
  8673. for (int i = 0; i < nCount; i++) {
  8674. String sOnOff = "off";
  8675. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8676. byte hOnOff = 0x00;
  8677. if(CtrList[0].equalsIgnoreCase("off"))
  8678. {
  8679. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8680. sOnOff = "off";
  8681. }
  8682. else
  8683. {
  8684. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8685. sOnOff = "on";
  8686. }
  8687. double setTemp = airconAPI.data.Device.Aircon[i].SetTemp;
  8688. byte volume = airconAPI.data.Device.Aircon[i].Volume;
  8689. byte mode = airconAPI.data.Device.Aircon[i].Mode;
  8690. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8691. ret = airconAPI.SetEachRoomStatus((byte)i, hMode, setTemp);
  8692. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8693. 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";
  8694. }
  8695. }
  8696. }
  8697. else
  8698. {
  8699. // 개별 제어
  8700. int nDevNum = Integer.parseInt(devnum);
  8701. if( airconTestMode == true )
  8702. {
  8703. String sOnOff = "off";
  8704. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8705. if(CtrList[0].equalsIgnoreCase("off"))
  8706. {
  8707. airconTestModeOnOff[nDevNum-1] = false;
  8708. }
  8709. else
  8710. {
  8711. airconTestModeOnOff[nDevNum-1] = true;
  8712. sOnOff = "on";
  8713. }
  8714. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8715. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8716. }
  8717. else
  8718. {
  8719. String sOnOff = "off";
  8720. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8721. byte hOnOff = 0x00;
  8722. if(CtrList[0].equalsIgnoreCase("off"))
  8723. {
  8724. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8725. sOnOff = "off";
  8726. }
  8727. else
  8728. {
  8729. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8730. sOnOff = "on";
  8731. }
  8732. //String [] aMode = {"auto","cool","dehum","blow","heat"};
  8733. byte mode = 0x00;
  8734. if(CtrList[1].equalsIgnoreCase("auto"))
  8735. mode = DataClasses.KnxSystemAircon.MODE.Auto;
  8736. else if(CtrList[1].equalsIgnoreCase("cool"))
  8737. mode = DataClasses.KnxSystemAircon.MODE.Cold;
  8738. else if(CtrList[1].equalsIgnoreCase("dehum"))
  8739. mode = DataClasses.KnxSystemAircon.MODE.Dry;
  8740. else if(CtrList[1].equalsIgnoreCase("blow"))
  8741. mode = DataClasses.KnxSystemAircon.MODE.Venti;
  8742. else if(CtrList[1].equalsIgnoreCase("heat"))
  8743. mode = DataClasses.KnxSystemAircon.MODE.Heat;
  8744. else
  8745. mode = airconAPI.data.Device.Aircon[nDevNum-1].Mode;
  8746. byte volume = 0x00;
  8747. if(CtrList[2].equalsIgnoreCase(mTextWindType[0]))
  8748. volume = DataClasses.KnxSystemAircon.VOLUME.Auto;
  8749. else if(CtrList[2].equalsIgnoreCase(mTextWindType[1]))
  8750. volume = DataClasses.KnxSystemAircon.VOLUME.Weak;
  8751. else if(CtrList[2].equalsIgnoreCase(mTextWindType[2]))
  8752. volume = DataClasses.KnxSystemAircon.VOLUME.Medium;
  8753. else if(CtrList[2].equalsIgnoreCase(mTextWindType[3]))
  8754. volume = DataClasses.KnxSystemAircon.VOLUME.Strong;
  8755. else
  8756. volume = airconAPI.data.Device.Aircon[nDevNum-1].Volume;
  8757. double setTemp = 0;
  8758. if( CtrList[3].equalsIgnoreCase("null"))
  8759. setTemp = airconAPI.data.Device.Aircon[nDevNum-1].SetTemp;
  8760. else
  8761. setTemp = Double.parseDouble(CtrList[3]);
  8762. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8763. ret = airconAPI.SetEachRoomStatus((byte)(nDevNum-1), hMode, setTemp);
  8764. if( ret >= 0 ) {
  8765. ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8766. }
  8767. double curTemp = airconAPI.data.Device.Aircon[nDevNum-1].NowTemp;
  8768. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8769. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume] + "/" + setTemp + "/" + curTemp + "\"/>\r\n";
  8770. }
  8771. }
  8772. }
  8773. else {
  8774. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8775. return retStr;
  8776. }
  8777. retStr += "\"ok\" >\r\n";
  8778. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  8779. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  8780. retStr += strResultStatus;
  8781. retStr += " </service>\r\n";
  8782. retStr += "</imap> ";
  8783. return retStr;
  8784. } catch (Exception e) {
  8785. Log.e(TAG, "[Exception] iCMDProcSysairconControl(Document ele)");
  8786. e.printStackTrace();
  8787. return null;
  8788. }
  8789. }
  8790. private String iCMDProcEntireLightControl(Document ele) {
  8791. try {
  8792. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  8793. if (retStr != null) return retStr;
  8794. else
  8795. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  8796. String sDong = null;
  8797. String sHo = null;
  8798. String sDevice_Num = null;
  8799. String sSelCtrl_Action = null;
  8800. String sUnselCtrl_Action = null;
  8801. NodeList items = ele.getElementsByTagName("home_info");
  8802. Node item = items.item(0);
  8803. NamedNodeMap attrsParam = item.getAttributes();
  8804. for (int i = 0; i < attrsParam.getLength(); i++) {
  8805. Node attr = attrsParam.item(i);
  8806. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8807. sDong = trimquotation(attr.getNodeValue());
  8808. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8809. sHo = trimquotation(attr.getNodeValue());
  8810. }
  8811. WallpadStatusData DBMGR = null;
  8812. DBMGR = new WallpadStatusData(getApplicationContext());
  8813. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8814. DBMGR.closeDB();
  8815. if (mSdb_LivingRoomLightAPI == null) {
  8816. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  8817. retStr += " result=\"fail\" >\r\n";
  8818. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8819. retStr += " </service>\r\n</imap>";
  8820. return retStr;
  8821. }
  8822. if (mSdbAPI == null) {
  8823. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  8824. retStr += " result=\"fail\" >\r\n";
  8825. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8826. retStr += " </service>\r\n</imap>";
  8827. return retStr;
  8828. }
  8829. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
  8830. items = ele.getElementsByTagName("sel_ctrlinfo");
  8831. item = items.item(0);
  8832. attrsParam = item.getAttributes();
  8833. for (int i = 0; i < attrsParam.getLength(); i++) {
  8834. Node attr = attrsParam.item(i);
  8835. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8836. sDevice_Num = trimquotation(attr.getNodeValue());
  8837. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8838. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  8839. }
  8840. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  8841. int result = -1; // 조명 제어 결과
  8842. boolean bLivingLightSel = false; // 거실조명 선택 여부
  8843. // ============================== 선택된 조명 ==============================
  8844. String[] sel_devNum = null;
  8845. if (sDevice_Num != null && sDevice_Num.contains("light")) {
  8846. if (sDevice_Num.contains("/"))
  8847. sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  8848. else {
  8849. sel_devNum = new String[1];
  8850. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  8851. }
  8852. }
  8853. if (sel_devNum == null) sel_devNum = new String[0];
  8854. for (int i = 0; i < sel_devNum.length; i++) {
  8855. if (sel_devNum[i].equals("1")) {
  8856. bLivingLightSel = true;
  8857. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  8858. if (sSelCtrl_Action != null) {
  8859. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8860. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8861. } else {
  8862. int nColor = 0;
  8863. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8864. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8865. if (nColor > 0) {
  8866. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8867. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8868. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8869. }
  8870. }
  8871. // 거실조명 제어 결과
  8872. if (result < 0) {
  8873. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  8874. retStr += " result=\"fail\" >\r\n";
  8875. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8876. retStr += " </service>\r\n</imap>";
  8877. return retStr;
  8878. }
  8879. }
  8880. } else {
  8881. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  8882. if (sSelCtrl_Action != null) {
  8883. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8884. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  8885. } else {
  8886. int nColor = 0;
  8887. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8888. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8889. if (nColor > 0) {
  8890. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  8891. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  8892. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  8893. }
  8894. }
  8895. }
  8896. // 그 외 방 조명 제어 결과
  8897. if (result < 0) {
  8898. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  8899. retStr += " result=\"fail\" >\r\n";
  8900. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8901. retStr += " </service>\r\n</imap>";
  8902. return retStr;
  8903. }
  8904. }
  8905. }
  8906. // ============================== 선택안된 조명 ==============================
  8907. items = ele.getElementsByTagName("unsel_ctrlinfo");
  8908. item = items.item(0);
  8909. attrsParam = item.getAttributes();
  8910. for (int i = 0; i < attrsParam.getLength(); i++) {
  8911. Node attr = attrsParam.item(i);
  8912. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8913. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  8914. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  8915. }
  8916. if (!bLivingLightSel) {
  8917. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  8918. if (sUnselCtrl_Action != null) {
  8919. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8920. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8921. } else {
  8922. int nColor = 0;
  8923. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8924. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8925. if (nColor > 0) {
  8926. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8927. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8928. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8929. }
  8930. }
  8931. }
  8932. if (result < 0) {
  8933. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  8934. retStr += " result=\"fail\" >\r\n";
  8935. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8936. retStr += " </service>\r\n</imap>";
  8937. return retStr;
  8938. }
  8939. }
  8940. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  8941. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  8942. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  8943. unsel_devNum.add(i + 1);
  8944. }
  8945. for (int i = 0; i < unsel_devNum.size(); i++) {
  8946. for (int j = 0; j < sel_devNum.length; j++) {
  8947. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
  8948. unsel_devNum.remove(i);
  8949. }
  8950. }
  8951. for (int i = 0; i < unsel_devNum.size(); i++) {
  8952. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
  8953. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8954. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  8955. } else {
  8956. int nColor = 0;
  8957. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8958. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8959. if (nColor > 0) {
  8960. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  8961. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  8962. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  8963. }
  8964. }
  8965. if (result < 0) {
  8966. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  8967. retStr += " result=\"fail\" >\r\n";
  8968. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8969. retStr += " </service>\r\n</imap>";
  8970. return retStr;
  8971. }
  8972. }
  8973. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  8974. retStr += " result=\"ok\">\r\n";
  8975. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8976. retStr += " </service>\r\n</imap>";
  8977. return retStr;
  8978. } else {
  8979. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  8980. retStr += " result=\"fail\" >\r\n";
  8981. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8982. retStr += " </service>\r\n</imap>";
  8983. return retStr;
  8984. }
  8985. } catch (RuntimeException re) {
  8986. LogUtil.errorLogInfo("", TAG, re);
  8987. return null;
  8988. } catch (Exception e) {
  8989. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  8990. //e.printStackTrace();
  8991. LogUtil.errorLogInfo("", TAG, e);
  8992. return null;
  8993. }
  8994. }
  8995. // 월패드에 원격제어 사용 여부를 확인하다.
  8996. private String CheckiCMDProc(String CMDStr) {
  8997. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  8998. try {
  8999. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  9000. mWallpadStatusData.closeDB();
  9001. if (!bRemoteCtrlEnabled) {
  9002. String retXML = XMLHeader + "<service type=\"reply\" name=\"" + CMDStr + "\" result=\"deny\">\r\n" +
  9003. " </service>\r\n</imap>";
  9004. return retXML;
  9005. }
  9006. return null;
  9007. } catch (RuntimeException re) {
  9008. LogUtil.errorLogInfo("", TAG, re);
  9009. mWallpadStatusData.closeDB();
  9010. return null;
  9011. } catch (Exception e) {
  9012. mWallpadStatusData.closeDB();
  9013. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  9014. //e.printStackTrace();
  9015. LogUtil.errorLogInfo("", TAG, e);
  9016. return null;
  9017. }
  9018. }
  9019. //메인으로 공지 해야 할 노티 사항을 처리
  9020. public String ProcEventNotify(Element ele) {
  9021. try {
  9022. NodeList items = ele.getElementsByTagName("event");
  9023. Node item = items.item(0);
  9024. Node text = item.getFirstChild();
  9025. String eventTXT = trimquotation(text.getNodeValue());
  9026. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  9027. // 새로운 공지사항 존재
  9028. wakeupLCD();
  9029. Intent intent = new Intent();
  9030. intent.setAction(define.NOTIFY_ACNAME);
  9031. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9032. getApplicationContext().sendBroadcast(intent);
  9033. } else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  9034. // 택배 도착
  9035. wakeupLCD();
  9036. Intent intent = new Intent();
  9037. intent.setAction(define.NOTIFY_ACNAME);
  9038. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9039. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  9040. intent.putExtra("REMAIN_CNT", 1);
  9041. getApplicationContext().sendBroadcast(intent);
  9042. } else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  9043. // 택배 반출
  9044. wakeupLCD();
  9045. Intent intent = new Intent();
  9046. intent.setAction(define.NOTIFY_ACNAME);
  9047. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9048. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  9049. intent.putExtra("REMAIN_CNT", 0);
  9050. getApplicationContext().sendBroadcast(intent);
  9051. } else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  9052. // 등록된 차량 도착
  9053. wakeupLCD();
  9054. // 팝업을 띄우도록 하자
  9055. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9056. Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
  9057. } else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  9058. // 내려가는 방향의 엘리베이터가 도착함
  9059. if (ElevatorDown != null) {
  9060. ElevatorDown.TimeOutCancel();
  9061. ElevatorDown.ClearElevator();
  9062. }
  9063. Intent intent = new Intent();
  9064. intent.setAction(define.NOTIFY_ACNAME);
  9065. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  9066. getApplicationContext().sendBroadcast(intent);
  9067. } else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  9068. // 올라가는 방향의 엘리베이터가 도착함
  9069. if (ElevatorUp != null) {
  9070. ElevatorUp.TimeOutCancel();
  9071. ElevatorUp.ClearElevator();
  9072. }
  9073. Intent intent = new Intent();
  9074. intent.setAction(define.NOTIFY_ACNAME);
  9075. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  9076. getApplicationContext().sendBroadcast(intent);
  9077. } else {
  9078. }
  9079. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  9080. "<event> \"" + eventTXT + "\" </event>\r\n" + " </service>\r\n </imap> ";
  9081. return returnStr;
  9082. } catch (RuntimeException re) {
  9083. LogUtil.errorLogInfo("", TAG, re);
  9084. return null;
  9085. } catch (Exception e) {
  9086. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  9087. //e.printStackTrace();
  9088. LogUtil.errorLogInfo("", TAG, e);
  9089. return null;
  9090. }
  9091. }
  9092. public String GetAttributeVal(Node node, String attname) {
  9093. NamedNodeMap attrs = node.getAttributes();
  9094. for (int j = 0; j < attrs.getLength(); j++) {
  9095. Node attr = attrs.item(j);
  9096. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  9097. }
  9098. return null;
  9099. }
  9100. public class imageFileFilter implements FilenameFilter {
  9101. public boolean accept(File dir, String name) {
  9102. 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"))
  9103. return true;
  9104. else return false;
  9105. }
  9106. }
  9107. public String ProcCheckEpiceUpload(Document ele) {
  9108. try {
  9109. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  9110. NodeList items = ele.getElementsByTagName("filename");
  9111. Node item = items.item(0);
  9112. Node text = item.getFirstChild();
  9113. String filename = trimquotation(text.getNodeValue());
  9114. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  9115. String duplicate = null;
  9116. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  9117. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  9118. if (!dirInternal.exists()) dirInternal.mkdir();
  9119. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9120. AddressSet addr = SetData.getAddressMGR();
  9121. if (!dirInternal.exists()) {
  9122. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9123. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + define.MAX_ALBUM_PICTURE + "\" available=\"0\" duplicate=\"new\"/>\r\n" +
  9124. " </service>\r\n</imap>";
  9125. return returnStr;
  9126. }
  9127. imageFileFilter jpegfilter = new imageFileFilter();
  9128. String[] subfile = dirInternal.list(jpegfilter);
  9129. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  9130. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  9131. if (checkFile.exists()) duplicate = "exist";
  9132. else duplicate = "new";
  9133. if (subfile != null) {
  9134. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9135. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + subfile.length + "\" available=\"" + (define.MAX_ALBUM_PICTURE - subfile.length) + "\" duplicate=\"" + duplicate + "\"/>\r\n" +
  9136. " </service>\r\n</imap>";
  9137. }
  9138. SetData.closeDB();
  9139. return returnStr;
  9140. } catch (RuntimeException re) {
  9141. LogUtil.errorLogInfo("", TAG, re);
  9142. return null;
  9143. } catch (Exception e) {
  9144. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  9145. //e.printStackTrace();
  9146. LogUtil.errorLogInfo("", TAG, e);
  9147. return null;
  9148. }
  9149. }
  9150. private void playNotifySound(int nSoundID) {
  9151. try {
  9152. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9153. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9154. if (getCompareBSPVersion()) {
  9155. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  9156. } else {
  9157. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9158. }
  9159. boolean NeedPlay = false;
  9160. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9161. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  9162. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  9163. } else {
  9164. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  9165. }
  9166. SetData.closeDB();
  9167. if (NeedPlay) Sound().PlayMent(nSoundID);
  9168. } catch (RuntimeException re) {
  9169. LogUtil.errorLogInfo("", TAG, re);
  9170. } catch (Exception e) {
  9171. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  9172. //e.printStackTrace();
  9173. LogUtil.errorLogInfo("", TAG, e);
  9174. }
  9175. }
  9176. private void wakeupLCD() {
  9177. try {
  9178. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9179. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9180. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9181. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  9182. int AlarmStatus = WsDB.GetAlarmStatus();
  9183. WsDB.closeDB();
  9184. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  9185. Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
  9186. return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
  9187. } else {
  9188. Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
  9189. mIOInterface.ctrlLcdWakeUp();
  9190. }
  9191. } catch (RuntimeException re) {
  9192. LogUtil.errorLogInfo("", TAG, re);
  9193. } catch (Exception e) {
  9194. Log.e(TAG, "[Exception] wakeupLCD()");
  9195. //e.printStackTrace();
  9196. LogUtil.errorLogInfo("", TAG, e);
  9197. }
  9198. }
  9199. /**
  9200. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  9201. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  9202. * Jeff, 2020.09.07
  9203. *
  9204. * @return true: LCD backlight On, false: LCD backlight Off
  9205. */
  9206. public boolean checkLCDOnByCMD() {
  9207. try {
  9208. Runtime mRuntime = Runtime.getRuntime();
  9209. Process mProcess;
  9210. String cmd = "getprop persist.sys.lcdcon";
  9211. mProcess = mRuntime.exec(cmd);
  9212. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  9213. String line;
  9214. String strResult = null;
  9215. while ((line = br.readLine()) != null) {
  9216. strResult = line;
  9217. }
  9218. if (strResult != null) {
  9219. if (strResult.equals("0")) {
  9220. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  9221. return true;
  9222. } else if (strResult.equals("1")) {
  9223. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  9224. return false;
  9225. } else {
  9226. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  9227. return false;
  9228. }
  9229. } else
  9230. return false;
  9231. } catch (RuntimeException re) {
  9232. LogUtil.errorLogInfo("", TAG, re);
  9233. return false;
  9234. } catch (Exception e) {
  9235. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  9236. //e.printStackTrace();
  9237. LogUtil.errorLogInfo("", TAG, e);
  9238. return false;
  9239. }
  9240. }
  9241. /**
  9242. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  9243. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  9244. *
  9245. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  9246. */
  9247. public boolean getCompareBSPVersion() {
  9248. try {
  9249. StringBuilder strBSPVersion = new StringBuilder();
  9250. StringBuffer sysInfoBuffer = new StringBuffer();
  9251. sysInfoBuffer.append(Build.DISPLAY);
  9252. strBSPVersion.append(sysInfoBuffer.toString());
  9253. String result = strBSPVersion.toString();
  9254. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  9255. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  9256. Date date = simpleDateFormat.parse(result);
  9257. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  9258. if (date.compareTo(standardDate) >= 0) {
  9259. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  9260. return true;
  9261. }
  9262. } catch (RuntimeException re) {
  9263. LogUtil.errorLogInfo("", TAG, re);
  9264. } catch (Exception e) {
  9265. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  9266. //e.printStackTrace();
  9267. LogUtil.errorLogInfo("", TAG, e);
  9268. }
  9269. return false;
  9270. }
  9271. public String ProcUpdateWeather(Document ele) {
  9272. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  9273. String nowloc = "";
  9274. String nowlcode = "";
  9275. String nowdate = "";
  9276. String nowtext = "";
  9277. String nowcode = "";
  9278. String nowtemp = "";
  9279. String nowlo = "", nowhigh = "";
  9280. NodeList items = ele.getElementsByTagName("now");
  9281. Node item = items.item(0);
  9282. if (item == null)
  9283. return resultstr += "\"fail\"/> \r\n </imap>";
  9284. NamedNodeMap attrsParam = item.getAttributes();
  9285. for (int j = 0; j < attrsParam.getLength(); j++) {
  9286. Node attr = attrsParam.item(j);
  9287. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  9288. else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
  9289. nowlcode = attr.getNodeValue();
  9290. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  9291. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  9292. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  9293. else if (attr.getNodeName().equalsIgnoreCase("temperature"))
  9294. nowtemp = attr.getNodeValue();
  9295. }
  9296. items = ele.getElementsByTagName("week");
  9297. String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
  9298. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9299. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  9300. Weathertbl.InitWeatherTable();
  9301. for (int i = 0; i < items.getLength(); i++) {
  9302. item = items.item(i);
  9303. attrsParam = item.getAttributes();
  9304. for (int j = 0; j < attrsParam.getLength(); j++) {
  9305. Node attr = attrsParam.item(j);
  9306. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  9307. else if (attr.getNodeName().equalsIgnoreCase("text"))
  9308. weektext = attr.getNodeValue();
  9309. else if (attr.getNodeName().equalsIgnoreCase("code"))
  9310. weekcode = attr.getNodeValue();
  9311. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  9312. else if (attr.getNodeName().equalsIgnoreCase("high"))
  9313. weekhigh = attr.getNodeValue();
  9314. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  9315. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  9316. }
  9317. if (i == 0) {
  9318. nowlo = weeklow;
  9319. nowhigh = weekhigh;
  9320. }
  9321. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  9322. }
  9323. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  9324. Intent intent = new Intent();
  9325. intent.setAction(define.NOTIFY_ACNAME);
  9326. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  9327. intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
  9328. getApplicationContext().sendBroadcast(intent);
  9329. String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
  9330. 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);
  9331. //air
  9332. items = ele.getElementsByTagName("air");
  9333. String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
  9334. item = items.item(0);
  9335. if (item != null) {
  9336. attrsParam = item.getAttributes();
  9337. for (int j = 0; j < attrsParam.getLength(); j++) {
  9338. Node attr = attrsParam.item(j);
  9339. if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
  9340. else if (attr.getNodeName().equalsIgnoreCase("pm25"))
  9341. airpm25 = attr.getNodeValue();
  9342. else if (attr.getNodeName().equalsIgnoreCase("co2"))
  9343. airco2 = attr.getNodeValue();
  9344. else if (attr.getNodeName().equalsIgnoreCase("ozone"))
  9345. airozone = attr.getNodeValue();
  9346. else if (attr.getNodeName().equalsIgnoreCase("air_index"))
  9347. air_index = attr.getNodeValue();
  9348. }
  9349. Intent intentAir = new Intent();
  9350. intentAir.setAction(define.NOTIFY_ACNAME);
  9351. intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
  9352. getApplicationContext().sendBroadcast(intentAir);
  9353. DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
  9354. }
  9355. DBMGR.closeDB();
  9356. return resultstr += "\"ok\"/> \r\n </imap>";
  9357. }
  9358. //iMAP update_news 처리
  9359. public String ProcUpdateNews(Document ele) {
  9360. NodeList items = ele.getElementsByTagName("ver_news");
  9361. Node item = items.item(0);
  9362. String strNewsVer = item.getTextContent();
  9363. strNewsVer = trimquotation(strNewsVer);
  9364. String retXML = XMLHeader + "<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n" +
  9365. " <ver_news>\"" + strNewsVer + "\"</ver_news>\r\n<service/>\r\n</imap>";
  9366. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9367. String NotiVer = DBMGR.GetNoticeVer();
  9368. int noticeCNT = DBMGR.GetNoticeCNT();
  9369. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  9370. String[] spdt = strNewsVer.split("[.]");
  9371. noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
  9372. } else {
  9373. String[] spdt = strNewsVer.split("[.]");
  9374. int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
  9375. spdt = NotiVer.split("[.]");
  9376. newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
  9377. noticeCNT += newcnt;
  9378. }
  9379. Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
  9380. DBMGR.SetNoticeVer(strNewsVer);
  9381. DBMGR.SetNoticeCNT(noticeCNT);
  9382. DBMGR.closeDB();
  9383. if (NotiVer.compareTo(strNewsVer) != 0) {
  9384. Intent intent = new Intent();
  9385. intent.setAction(define.NOTIFY_ACNAME);
  9386. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9387. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  9388. getApplicationContext().sendBroadcast(intent);
  9389. }
  9390. return retXML;
  9391. }
  9392. //iMAP check_lobby_passwd 처리
  9393. public String CheckPassword(Document doc) {
  9394. NodeList items = doc.getElementsByTagName("inpasswd");
  9395. Node item = items.item(0);
  9396. Node text = item.getFirstChild();
  9397. String passwd = trimquotation(text.getNodeValue());
  9398. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9399. String settedpasswd = DBMGR.GetUserPW();
  9400. DBMGR.closeDB();
  9401. String retString = XMLHeader;
  9402. Common.DebugLog("================ CheckPassword ================ ");
  9403. Common.DebugLog("Saved Password :" + settedpasswd);
  9404. Common.DebugLog("Input Password :" + passwd);
  9405. Common.DebugLog("================ CheckPassword ================ ");
  9406. if (settedpasswd.equals(passwd)) {
  9407. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  9408. } else {
  9409. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>" + passwd + "</wrongpasswd>\r\n</service>";
  9410. }
  9411. retString += "</imap>";
  9412. return retString;
  9413. }
  9414. //schedule_renew 처리
  9415. protected String ProcSchduleRenew(Document doc) {
  9416. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n " +
  9417. "<homeaddr dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" /> \r\n </service> \r\n </imap>";
  9418. WallpadScheduleData schedulDB = null;
  9419. try {
  9420. NodeList items = doc.getElementsByTagName("renew_info");
  9421. schedulDB = new WallpadScheduleData(getApplicationContext());
  9422. for (int i = 0; i < items.getLength(); i++) {
  9423. Node item = items.item(i);
  9424. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  9425. NamedNodeMap attrsParam = item.getAttributes();
  9426. String Type = "none";
  9427. for (int j = 0; j < attrsParam.getLength(); j++) {
  9428. Node attr = attrsParam.item(j);
  9429. String name = attr.getNodeName();
  9430. String Val = attr.getNodeValue();
  9431. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  9432. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  9433. else if (name.equalsIgnoreCase("rn_type"))
  9434. Type = Val;
  9435. else if (name.equalsIgnoreCase("rn_t_type"))
  9436. SCdata.inqttype = Val;
  9437. else if (name.equalsIgnoreCase("rn_c_type"))
  9438. SCdata.inqctype = Val;
  9439. else if (name.equalsIgnoreCase("rn_a_type"))
  9440. SCdata.inqatype = Val;
  9441. else if (name.equalsIgnoreCase("rn_i_type"))
  9442. SCdata.inqitype = Val;
  9443. else if (name.equalsIgnoreCase("rn_year"))
  9444. SCdata.inqyear = Integer.parseInt(Val);
  9445. else if (name.equalsIgnoreCase("rn_month"))
  9446. SCdata.inqmonth = Integer.parseInt(Val);
  9447. else if (name.equalsIgnoreCase("rn_day"))
  9448. SCdata.inqday = Integer.parseInt(Val);
  9449. else if (name.equalsIgnoreCase("rn_hour"))
  9450. SCdata.inqhour = Integer.parseInt(Val);
  9451. else if (name.equalsIgnoreCase("rn_message"))
  9452. SCdata.inqmsg = Val;
  9453. }
  9454. if (Type.equals("delete")) {
  9455. schedulDB.DeleteSchedule(SCdata);
  9456. } else if (Type.equals("add")) {
  9457. schedulDB.AddSchedule(SCdata);
  9458. } else if (Type.equals("change")) {
  9459. schedulDB.UpdateSchedule(SCdata);
  9460. }
  9461. }
  9462. schedulDB.closeDB();
  9463. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  9464. // Intent intent = new Intent();
  9465. // intent.setAction(define.NOTIFY_ACNAME);
  9466. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9467. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  9468. // getApplicationContext().sendBroadcast(intent);
  9469. } catch (RuntimeException re) {
  9470. LogUtil.errorLogInfo("", TAG, re);
  9471. if (schedulDB != null) schedulDB.closeDB();
  9472. } catch (Exception e) {
  9473. //e.printStackTrace();
  9474. LogUtil.errorLogInfo("", TAG, e);
  9475. if (schedulDB != null) schedulDB.closeDB();
  9476. }
  9477. return retXML;
  9478. }
  9479. //schedule_inquiry 처리
  9480. @SuppressWarnings("unused")
  9481. public String ProcSchduleInquiry(Document doc) {
  9482. WallpadScheduleData schedulDB = null;
  9483. String retXML;
  9484. int QYear = 0;
  9485. int QMonth = 0;
  9486. try {
  9487. NodeList items = doc.getElementsByTagName("inquiry_time");
  9488. schedulDB = new WallpadScheduleData(getApplicationContext());
  9489. Node item = items.item(0);
  9490. NamedNodeMap attrsParam = item.getAttributes();
  9491. for (int j = 0; j < attrsParam.getLength(); j++) {
  9492. Node attr = attrsParam.item(j);
  9493. if (attr.getNodeName().equalsIgnoreCase("year"))
  9494. QYear = Integer.parseInt(attr.getNodeValue());
  9495. else if (attr.getNodeName().equalsIgnoreCase("month"))
  9496. QMonth = Integer.parseInt(attr.getNodeValue());
  9497. }
  9498. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  9499. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9500. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9501. " <inquiry_time year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9502. " <inquiry_count>" + SCData.size() + "</inquiry_count>\r\n";
  9503. if (SCData != null) {
  9504. if (SCData.size() > 0) {
  9505. for (int i = 0; i < SCData.size(); i++) {
  9506. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  9507. 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=\"" +
  9508. SCINQDATA.inqyear + "\" inq_month=\"" + SCINQDATA.inqmonth + "\" inq_day=\"" + SCINQDATA.inqday + "\" inq_hour=\"" + SCINQDATA.inqhour + "\" inq_message=\"" + SCINQDATA.inqmsg + "\"/>\r\n";
  9509. }
  9510. }
  9511. retXML += "</service>\r\n</imap>";
  9512. } else {
  9513. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9514. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9515. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9516. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9517. }
  9518. } catch (RuntimeException re) {
  9519. LogUtil.errorLogInfo("", TAG, re);
  9520. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9521. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9522. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9523. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9524. } catch (Exception e) {
  9525. //e.printStackTrace();
  9526. LogUtil.errorLogInfo("", TAG, e);
  9527. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9528. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9529. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9530. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9531. }
  9532. schedulDB.closeDB();
  9533. return retXML;
  9534. }
  9535. public String ProcUpdateSchedule(Element ele, String type) {
  9536. String retXML = "";
  9537. return retXML;
  9538. }
  9539. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  9540. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  9541. private void setDefaultLauncher() {
  9542. try {
  9543. PackageManager pm = getPackageManager();
  9544. IntentFilter filter = new IntentFilter();
  9545. filter.addAction(Intent.ACTION_MAIN);
  9546. filter.addCategory(Intent.CATEGORY_HOME);
  9547. filter.addCategory(Intent.CATEGORY_DEFAULT);
  9548. Context context = getApplicationContext();
  9549. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  9550. ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  9551. pm.clearPackagePreferredActivities("com.android.launcher");
  9552. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  9553. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  9554. try {
  9555. Thread.sleep(300);
  9556. } catch (RuntimeException re) {
  9557. LogUtil.errorLogInfo("", TAG, re);
  9558. } catch (Exception e) {
  9559. LogUtil.errorLogInfo("", TAG, e);
  9560. }
  9561. // 리셋코드 추가
  9562. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  9563. try {
  9564. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9565. powerMg.reboot(null);
  9566. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  9567. } catch (RuntimeException re) {
  9568. LogUtil.errorLogInfo("", TAG, re);
  9569. } catch (Exception e) {
  9570. //e.printStackTrace();
  9571. LogUtil.errorLogInfo("", TAG, e);
  9572. }
  9573. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  9574. } catch (RuntimeException re) {
  9575. LogUtil.errorLogInfo("", TAG, re);
  9576. } catch (Exception e) {
  9577. //e.printStackTrace();
  9578. LogUtil.errorLogInfo("", TAG, e);
  9579. }
  9580. }
  9581. public String ProcDeviceReset(Element ele) {
  9582. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  9583. "</imap>\r\n";
  9584. NodeList resettype = ele.getElementsByTagName("guidemap");
  9585. Node resettypeItem = resettype.item(0);
  9586. String type = GetAttributeVal(resettypeItem, "type");
  9587. if (type != null) {
  9588. if (type.equals("now")) {
  9589. setDefaultLauncher();
  9590. Intent intent = new Intent();
  9591. intent.setAction(define.NOTIFY_ACNAME);
  9592. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  9593. getApplicationContext().sendBroadcast(intent);
  9594. } else if (type.equals("disable")) {
  9595. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9596. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
  9597. SetReset.closeDB();
  9598. } else if (type.equals("week") || type.equals("month")) {
  9599. int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
  9600. NodeList periodList = ele.getElementsByTagName("period");
  9601. Node perioditem = periodList.item(0);
  9602. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  9603. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  9604. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9605. SetReset.SetResetSchedule(Resettype, cycle, time);
  9606. SetReset.closeDB();
  9607. }
  9608. }
  9609. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  9610. // Intent intent = new Intent();
  9611. // intent.setAction(define.NOTIFY_ACNAME);
  9612. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9613. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  9614. // getApplicationContext().sendBroadcast(intent);
  9615. return retXML;
  9616. }
  9617. public String ProcDeviceLiveCheck() {
  9618. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  9619. return retXML;
  9620. }
  9621. public String ProcPairingHdevSyncAlarm(Element ele) {
  9622. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  9623. return retXML;
  9624. }
  9625. public String ProcPairingHdevSyncSecurity(Element ele) {
  9626. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  9627. return retXML;
  9628. }
  9629. public String ProcParkInformation(Element ele) {
  9630. try {
  9631. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  9632. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  9633. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  9634. NodeList items = ele.getElementsByTagName("destination");
  9635. Node item = items.item(0);
  9636. Node text;
  9637. NamedNodeMap attrsParam = item.getAttributes();
  9638. for (int j = 0; j < attrsParam.getLength(); j++) {
  9639. Node attr = attrsParam.item(j);
  9640. if (attr.getNodeName().equalsIgnoreCase("name"))
  9641. strName = trimquotation(attr.getNodeValue());
  9642. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9643. strDong = trimquotation(attr.getNodeValue());
  9644. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9645. strHo = trimquotation(attr.getNodeValue());
  9646. }
  9647. items = ele.getElementsByTagName("move_info");
  9648. item = items.item(0);
  9649. text = item.getFirstChild();
  9650. strCarMove = trimquotation(text.getNodeValue());
  9651. items = ele.getElementsByTagName("params");
  9652. item = items.item(0);
  9653. attrsParam = item.getAttributes();
  9654. for (int j = 0; j < attrsParam.getLength(); j++) {
  9655. Node attr = attrsParam.item(j);
  9656. if (attr.getNodeName().equalsIgnoreCase("car_num"))
  9657. strCarNo = trimquotation(attr.getNodeValue());
  9658. else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
  9659. strCarLocation = trimquotation(attr.getNodeValue());
  9660. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9661. strMsg = trimquotation(attr.getNodeValue());
  9662. }
  9663. if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
  9664. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  9665. try {
  9666. int iTempDong = Integer.parseInt(AddrDong);
  9667. String sTempDong = Integer.toString(iTempDong);
  9668. int iTempHo = Integer.parseInt(AddrHo);
  9669. String sTempHo = Integer.toString(iTempHo);
  9670. if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  9671. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9672. } else {
  9673. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9674. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9675. return retXML;
  9676. }
  9677. } catch (RuntimeException re) {
  9678. LogUtil.errorLogInfo("", TAG, re);
  9679. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9680. return retXML;
  9681. } catch (Exception e) {
  9682. //e.printStackTrace();
  9683. LogUtil.errorLogInfo("", TAG, e);
  9684. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9685. return retXML;
  9686. }
  9687. //DB정보 업데이트!
  9688. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9689. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  9690. CarDB.closeDB();
  9691. //DB정보 업데이트!
  9692. if (strCarMove.equalsIgnoreCase("in")) {
  9693. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9694. // 팝업을 띄우도록 하자
  9695. wakeupLCD();
  9696. if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
  9697. Intent iIntent = new Intent();
  9698. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9699. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9700. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  9701. getApplicationContext().sendBroadcast(iIntent);
  9702. } else {
  9703. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9704. }
  9705. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  9706. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  9707. }
  9708. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  9709. if (strCarMove.equalsIgnoreCase("park")) {
  9710. //주차정보 얻어오도록 intent 알림
  9711. SendGetParkingInfoIntent();
  9712. }
  9713. } else {
  9714. //주차정보 얻어오도록 intent 알림
  9715. SendGetParkingInfoIntent();
  9716. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  9717. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  9718. }
  9719. return retXML;
  9720. } catch (RuntimeException re) {
  9721. LogUtil.errorLogInfo("", TAG, re);
  9722. return null;
  9723. } catch (Exception e) {
  9724. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  9725. //e.printStackTrace();
  9726. LogUtil.errorLogInfo("", TAG, e);
  9727. return null;
  9728. }
  9729. }
  9730. /**
  9731. * 스마트키 이벤트 수신시 처리
  9732. **/
  9733. public String ProcSmartKeyEvent(Element ele) {
  9734. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  9735. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  9736. String strName = null, strDong = null, strHo = null, strCnt = null;
  9737. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  9738. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  9739. NodeList items = ele.getElementsByTagName("destination");
  9740. Node item = items.item(0);
  9741. NamedNodeMap attrsParam = item.getAttributes();
  9742. for (int j = 0; j < attrsParam.getLength(); j++) {
  9743. Node attr = attrsParam.item(j);
  9744. if (attr.getNodeName().equalsIgnoreCase("name"))
  9745. strName = trimquotation(attr.getNodeValue());
  9746. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9747. strDong = trimquotation(attr.getNodeValue());
  9748. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9749. strHo = trimquotation(attr.getNodeValue());
  9750. }
  9751. items = ele.getElementsByTagName("event_info");
  9752. item = items.item(0);
  9753. attrsParam = item.getAttributes();
  9754. for (int j = 0; j < attrsParam.getLength(); j++) {
  9755. Node attr = attrsParam.item(j);
  9756. if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
  9757. strCnt = trimquotation(attr.getNodeValue());
  9758. }
  9759. items = ele.getElementsByTagName("event");
  9760. item = items.item(0);
  9761. attrsParam = item.getAttributes();
  9762. for (int j = 0; j < attrsParam.getLength(); j++) {
  9763. Node attr = attrsParam.item(j);
  9764. if (attr.getNodeName().equalsIgnoreCase("event_type"))
  9765. strEventType = trimquotation(attr.getNodeValue());
  9766. else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
  9767. strEventTriggerType = trimquotation(attr.getNodeValue());
  9768. else if (attr.getNodeName().equalsIgnoreCase("uid"))
  9769. strEventUID = trimquotation(attr.getNodeValue());
  9770. else if (attr.getNodeName().equalsIgnoreCase("sn"))
  9771. strEventSN = trimquotation(attr.getNodeValue());
  9772. else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
  9773. strEventSitecode = trimquotation(attr.getNodeValue());
  9774. else if (attr.getNodeName().equalsIgnoreCase("dong"))
  9775. strEventDong = trimquotation(attr.getNodeValue());
  9776. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9777. strEventHo = trimquotation(attr.getNodeValue());
  9778. else if (attr.getNodeName().equalsIgnoreCase("card_num"))
  9779. strEventCardNo = trimquotation(attr.getNodeValue());
  9780. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
  9781. strEventIssueCnt = trimquotation(attr.getNodeValue());
  9782. else if (attr.getNodeName().equalsIgnoreCase("card_type"))
  9783. strEventCardType = trimquotation(attr.getNodeValue());
  9784. else if (attr.getNodeName().equalsIgnoreCase("location"))
  9785. strEventLocation = trimquotation(attr.getNodeValue());
  9786. }
  9787. if (strName != null && strDong != null && strHo != null && strCnt != null)
  9788. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  9789. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  9790. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  9791. if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
  9792. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  9793. } else {
  9794. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  9795. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9796. return retXML;
  9797. }
  9798. //데이터가 null인지 확인
  9799. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  9800. return retXML;
  9801. }
  9802. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  9803. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9804. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9805. wakeupLCD();
  9806. // 팝업을 띄우도록 하자
  9807. String CardNum = "";
  9808. try {
  9809. int iEvent_Dong = Integer.parseInt(strEventDong);
  9810. CardNum += String.format("%04d", iEvent_Dong);
  9811. int iEvent_Ho = Integer.parseInt(strEventHo);
  9812. CardNum += String.format("%04d", iEvent_Ho);
  9813. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  9814. CardNum += String.format("%03d", iEvent_CardNum);
  9815. } catch (RuntimeException re) {
  9816. LogUtil.errorLogInfo("", TAG, re);
  9817. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9818. return retXML;
  9819. } catch (Exception e) {
  9820. //e.printStackTrace();
  9821. LogUtil.errorLogInfo("", TAG, e);
  9822. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9823. return retXML;
  9824. }
  9825. Intent iIntent = new Intent();
  9826. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9827. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  9828. iIntent.putExtra("LOCATION", strEventLocation);
  9829. iIntent.putExtra("CARD_NO", CardNum);
  9830. getApplicationContext().sendBroadcast(iIntent);
  9831. }
  9832. }
  9833. } else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  9834. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9835. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9836. int nCardNum;
  9837. try {
  9838. nCardNum = Integer.parseInt(strEventCardNo);
  9839. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  9840. } catch (RuntimeException re) {
  9841. LogUtil.errorLogInfo("", TAG, re);
  9842. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9843. return retXML;
  9844. } catch (Exception e) {
  9845. //e.printStackTrace();
  9846. LogUtil.errorLogInfo("", TAG, e);
  9847. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9848. return retXML;
  9849. }
  9850. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9851. boolean bBandUse = deviceSet.getBandLocationUsage();
  9852. deviceSet.closeDB();
  9853. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  9854. wakeupLCD();
  9855. Intent iIntent = new Intent();
  9856. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9857. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  9858. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  9859. getApplicationContext().sendBroadcast(iIntent);
  9860. }
  9861. }
  9862. }
  9863. }
  9864. return retXML;
  9865. }
  9866. public String ProcParkInformation_cham_upis(Element ele) {
  9867. Log.d(TAG, "ProcParkInformation_cham_upis START");
  9868. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  9869. String infoName = null;
  9870. String infoDong = null;
  9871. String infoHo = null;
  9872. String infoCarMove = null;
  9873. String infoCarnum = null;
  9874. String infoCarLocation = null;
  9875. String infoMessage = null;
  9876. NodeList items = ele.getElementsByTagName("home_info");
  9877. Node item = items.item(0);
  9878. Node text;
  9879. NamedNodeMap attrsParam = item.getAttributes();
  9880. for (int j = 0; j < attrsParam.getLength(); j++) {
  9881. Node attr = attrsParam.item(j);
  9882. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9883. infoDong = trimquotation(attr.getNodeValue());
  9884. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9885. infoHo = trimquotation(attr.getNodeValue());
  9886. }
  9887. items = ele.getElementsByTagName("park_info");
  9888. item = items.item(0);
  9889. attrsParam = item.getAttributes();
  9890. for (int j = 0; j < attrsParam.getLength(); j++) {
  9891. Node attr = attrsParam.item(j);
  9892. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  9893. infoCarnum = trimquotation(attr.getNodeValue());
  9894. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  9895. infoCarLocation = trimquotation(attr.getNodeValue());
  9896. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9897. infoMessage = trimquotation(attr.getNodeValue());
  9898. }
  9899. Log.d(TAG, "ProcParkInformation infoName :" + infoName);
  9900. if (infoDong != null)
  9901. Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
  9902. Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
  9903. Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
  9904. Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
  9905. Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
  9906. Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
  9907. if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  9908. (infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
  9909. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9910. } else {
  9911. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9912. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  9913. return retXML;
  9914. }
  9915. infoCarMove = "park";
  9916. //DB정보 업데이트!
  9917. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9918. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  9919. CarDB.closeDB();
  9920. //DB정보 업데이트!
  9921. Intent iIntent = new Intent();
  9922. iIntent.setAction(define.NOTIFY_ACNAME);
  9923. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  9924. this.sendBroadcast(iIntent);
  9925. /*
  9926. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  9927. {
  9928. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9929. // 팝업을 띄우도록 하자
  9930. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9931. }
  9932. */
  9933. return retXML;
  9934. }
  9935. public String ProcGetSmartKeyInfo(Element ele) {
  9936. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  9937. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  9938. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  9939. NodeList items = ele.getElementsByTagName("info_type");
  9940. Node item = items.item(0);
  9941. Node text = item.getFirstChild();
  9942. String sInfo_type = trimquotation(text.getNodeValue());
  9943. String sCard_info = null;
  9944. String sMessage = null;
  9945. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  9946. {
  9947. items = ele.getElementsByTagName("uid_info");
  9948. item = items.item(0);
  9949. text = item.getFirstChild();
  9950. sCard_info = trimquotation(text.getNodeValue());
  9951. //==============================================//
  9952. items = ele.getElementsByTagName("message");
  9953. item = items.item(0);
  9954. text = item.getFirstChild();
  9955. sMessage = trimquotation(text.getNodeValue());
  9956. //==============================================//
  9957. //쿼리문 작성
  9958. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9959. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9960. for (int i = 0; i < SyncData.size(); i++) {
  9961. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  9962. NewData.add(SyncData.get(i));
  9963. }
  9964. }
  9965. wallpadSmartKeyRegData.closeDB();
  9966. } else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  9967. {
  9968. items = ele.getElementsByTagName("sn_info");
  9969. item = items.item(0);
  9970. text = item.getFirstChild();
  9971. sCard_info = trimquotation(text.getNodeValue());
  9972. //==============================================//
  9973. items = ele.getElementsByTagName("message");
  9974. item = items.item(0);
  9975. text = item.getFirstChild();
  9976. sMessage = trimquotation(text.getNodeValue());
  9977. //==============================================//
  9978. //쿼리문 작성
  9979. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9980. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9981. for (int i = 0; i < SyncData.size(); i++) {
  9982. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  9983. NewData.add(SyncData.get(i));
  9984. }
  9985. }
  9986. wallpadSmartKeyRegData.closeDB();
  9987. } else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  9988. {
  9989. items = ele.getElementsByTagName("uid_info");
  9990. item = items.item(0);
  9991. text = item.getFirstChild();
  9992. sCard_info = trimquotation(text.getNodeValue());
  9993. //==============================================//
  9994. items = ele.getElementsByTagName("message");
  9995. item = items.item(0);
  9996. text = item.getFirstChild();
  9997. sMessage = trimquotation(text.getNodeValue());
  9998. //==============================================//
  9999. //쿼리문 작성
  10000. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10001. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10002. for (int i = 0; i < SyncData.size(); i++) {
  10003. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  10004. NewData.add(SyncData.get(i));
  10005. }
  10006. }
  10007. if (NewData.size() > 0) {
  10008. NewData = SyncData;
  10009. }
  10010. wallpadSmartKeyRegData.closeDB();
  10011. } else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  10012. {
  10013. items = ele.getElementsByTagName("sn_info");
  10014. item = items.item(0);
  10015. text = item.getFirstChild();
  10016. sCard_info = trimquotation(text.getNodeValue());
  10017. //==============================================//
  10018. items = ele.getElementsByTagName("message");
  10019. item = items.item(0);
  10020. text = item.getFirstChild();
  10021. sMessage = trimquotation(text.getNodeValue());
  10022. //==============================================//
  10023. //쿼리문 작성
  10024. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10025. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10026. for (int i = 0; i < SyncData.size(); i++) {
  10027. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  10028. NewData.add(SyncData.get(i));
  10029. }
  10030. }
  10031. if (NewData.size() > 0) {
  10032. NewData = SyncData;
  10033. }
  10034. wallpadSmartKeyRegData.closeDB();
  10035. } else if (sInfo_type.equalsIgnoreCase("hkey")) {
  10036. String dong = "";
  10037. String ho = "";
  10038. String Num = "all";
  10039. //==============================================//
  10040. items = ele.getElementsByTagName("message");
  10041. item = items.item(0);
  10042. text = item.getFirstChild();
  10043. sMessage = trimquotation(text.getNodeValue());
  10044. //==============================================//
  10045. items = ele.getElementsByTagName("hkey_info");
  10046. item = items.item(0);
  10047. if (item == null)
  10048. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10049. NamedNodeMap attrsParam = item.getAttributes();
  10050. for (int j = 0; j < attrsParam.getLength(); j++) {
  10051. Node attr = attrsParam.item(j);
  10052. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10053. dong = attr.getNodeValue();
  10054. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10055. ho = attr.getNodeValue();
  10056. else if (attr.getNodeName().equalsIgnoreCase("num"))
  10057. Num = attr.getNodeValue();
  10058. }
  10059. if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
  10060. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
  10061. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10062. }
  10063. //쿼리문 작성
  10064. int intNum = 0;
  10065. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10066. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10067. for (int i = 0; i < SyncData.size(); i++) {
  10068. if (Num.equalsIgnoreCase("all") == true) {
  10069. NewData.add(SyncData.get(i));
  10070. } else {
  10071. try {
  10072. intNum = Integer.parseInt(Num);
  10073. } catch (RuntimeException re) {
  10074. LogUtil.errorLogInfo("", TAG, re);
  10075. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10076. } catch (Exception e) {
  10077. //e.printStackTrace();
  10078. LogUtil.errorLogInfo("", TAG, e);
  10079. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10080. }
  10081. if (SyncData.get(i).id == intNum) {
  10082. NewData.add(SyncData.get(i));
  10083. }
  10084. }
  10085. }
  10086. wallpadSmartKeyRegData.closeDB();
  10087. } else if (sInfo_type.equalsIgnoreCase("dkey")) {
  10088. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10089. } else if (sInfo_type.equalsIgnoreCase("mkey")) {
  10090. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10091. }
  10092. if (NewData.size() == 0) {
  10093. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  10094. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10095. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10096. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  10097. retXML += " </service>\r\n</imap>";
  10098. return retXML;
  10099. }
  10100. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10101. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10102. for (int i = 0; i < NewData.size(); i++) {
  10103. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  10104. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  10105. String strFormat = sFormat.format(date);
  10106. retXML += " <key_info index = \"" + NewData.get(i).id + "\" "
  10107. + "sn = \"" + NewData.get(i).SerialNumber + "\" "
  10108. + "uid = \"" + NewData.get(i).Uid + "\" "
  10109. + "key_num = \"" + NewData.get(i).id + "\" "
  10110. + "issue_cnt = \"" + 1 + "\" "
  10111. + "issued_date = \"" + strFormat + "\" "
  10112. + "message = \"" + "null" + "\" "
  10113. + "/>\r\n";
  10114. }
  10115. retXML += " </service>\r\n</imap>";
  10116. return retXML;
  10117. }
  10118. public void ProcMobileDevice_AuthNumber(Element ele) {
  10119. String sDong = null;
  10120. String sHo = null;
  10121. String sIP = null;
  10122. String sType = null;
  10123. String sDevice_Name = null;
  10124. String sTwinID = null;
  10125. String sAuthNumber = null;
  10126. try {
  10127. NodeList items = ele.getElementsByTagName("home_info");
  10128. Node item = items.item(0);
  10129. NamedNodeMap attrsParam = item.getAttributes();
  10130. for (int i = 0; i < attrsParam.getLength(); i++) {
  10131. Node attr = attrsParam.item(i);
  10132. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10133. sDong = trimquotation(attr.getNodeValue());
  10134. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10135. sHo = trimquotation(attr.getNodeValue());
  10136. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10137. sIP = trimquotation(attr.getNodeValue());
  10138. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10139. sType = trimquotation(attr.getNodeValue());
  10140. }
  10141. WallpadStatusData DBMGR = null;
  10142. DBMGR = new WallpadStatusData(getApplicationContext());
  10143. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10144. DBMGR.closeDB();
  10145. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10146. items = ele.getElementsByTagName("device_info");
  10147. item = items.item(0);
  10148. attrsParam = item.getAttributes();
  10149. for (int i = 0; i < attrsParam.getLength(); i++) {
  10150. Node attr = attrsParam.item(i);
  10151. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10152. sDevice_Name = trimquotation(attr.getNodeValue());
  10153. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10154. sTwinID = trimquotation(attr.getNodeValue());
  10155. else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
  10156. sAuthNumber = trimquotation(attr.getNodeValue());
  10157. }
  10158. /**데이터 전달**/
  10159. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10160. Log.d(TAG, "sTwinID :" + sTwinID);
  10161. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  10162. Intent intent = new Intent();
  10163. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10164. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  10165. intent.putExtra("AuthNumber", sAuthNumber);
  10166. if (NewServerUse()) {
  10167. getApplicationContext().sendBroadcast(intent);
  10168. }
  10169. } else {
  10170. }
  10171. } catch (RuntimeException re) {
  10172. LogUtil.errorLogInfo("", TAG, re);
  10173. } catch (Exception e) {
  10174. //e.printStackTrace();
  10175. LogUtil.errorLogInfo("", TAG, e);
  10176. }
  10177. }
  10178. public String ProcMobileDevice_ADD_Finish(Element ele) {
  10179. String retXML = "";
  10180. String sDong = null;
  10181. String sHo = null;
  10182. String sIP = null;
  10183. String sType = null;
  10184. String sDevice_Name = null;
  10185. String sTwinID = null;
  10186. try {
  10187. NodeList items = ele.getElementsByTagName("home_info");
  10188. Node item = items.item(0);
  10189. NamedNodeMap attrsParam = item.getAttributes();
  10190. for (int i = 0; i < attrsParam.getLength(); i++) {
  10191. Node attr = attrsParam.item(i);
  10192. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10193. sDong = trimquotation(attr.getNodeValue());
  10194. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10195. sHo = trimquotation(attr.getNodeValue());
  10196. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10197. sIP = trimquotation(attr.getNodeValue());
  10198. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10199. sType = trimquotation(attr.getNodeValue());
  10200. }
  10201. WallpadStatusData DBMGR = null;
  10202. DBMGR = new WallpadStatusData(getApplicationContext());
  10203. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10204. DBMGR.closeDB();
  10205. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10206. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10207. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10208. items = ele.getElementsByTagName("device_info");
  10209. item = items.item(0);
  10210. attrsParam = item.getAttributes();
  10211. for (int i = 0; i < attrsParam.getLength(); i++) {
  10212. Node attr = attrsParam.item(i);
  10213. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10214. sDevice_Name = trimquotation(attr.getNodeValue());
  10215. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10216. sTwinID = trimquotation(attr.getNodeValue());
  10217. }
  10218. /**데이터 전달**/
  10219. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10220. Log.d(TAG, "sTwinID :" + sTwinID);
  10221. Intent intent = new Intent();
  10222. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10223. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  10224. if (NewServerUse()) {
  10225. getApplicationContext().sendBroadcast(intent);
  10226. } else {
  10227. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10228. retXML += " </service>\r\n</imap>";
  10229. return retXML;
  10230. }
  10231. String tempType = "main";
  10232. //DB에 저장 필요
  10233. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10234. if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  10235. {
  10236. wallpadMobileDeviceData.closeDB();
  10237. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10238. retXML += " </service>\r\n</imap>";
  10239. return retXML;
  10240. }
  10241. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  10242. wallpadMobileDeviceData.closeDB();
  10243. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  10244. retXML += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" ip=\"" + addc.IPAddress + "\" type=\"" + tempType + "\"/>\r\n";
  10245. retXML += " <device_info alias=\"" + sDevice_Name + "\" twinid=\"" + sTwinID + "\" />\r\n";
  10246. retXML += " </service>\r\n</imap>";
  10247. return retXML;
  10248. } else {
  10249. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10250. retXML += " </service>\r\n</imap>";
  10251. return retXML;
  10252. }
  10253. } catch (RuntimeException re) {
  10254. LogUtil.errorLogInfo("", TAG, re);
  10255. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10256. retXML += " </service>\r\n</imap>";
  10257. return retXML;
  10258. } catch (Exception e) {
  10259. //e.printStackTrace();
  10260. LogUtil.errorLogInfo("", TAG, e);
  10261. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10262. retXML += " </service>\r\n</imap>";
  10263. return retXML;
  10264. }
  10265. }
  10266. public void ProcMobileDevice_Delete(Element ele) {
  10267. String sDong = null;
  10268. String sHo = null;
  10269. String sIP = null;
  10270. String sType = null;
  10271. String sDevice_Name = null;
  10272. String sTwinID = null;
  10273. Log.d(TAG, "ProcMobileDevice_Delete");
  10274. try {
  10275. NodeList items = ele.getElementsByTagName("home_info");
  10276. Node item = items.item(0);
  10277. NamedNodeMap attrsParam = item.getAttributes();
  10278. for (int i = 0; i < attrsParam.getLength(); i++) {
  10279. Node attr = attrsParam.item(i);
  10280. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10281. sDong = trimquotation(attr.getNodeValue());
  10282. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10283. sHo = trimquotation(attr.getNodeValue());
  10284. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10285. sIP = trimquotation(attr.getNodeValue());
  10286. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10287. sType = trimquotation(attr.getNodeValue());
  10288. }
  10289. WallpadStatusData DBMGR = null;
  10290. DBMGR = new WallpadStatusData(getApplicationContext());
  10291. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10292. DBMGR.closeDB();
  10293. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10294. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10295. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10296. if (NewServerUse()) {
  10297. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10298. items = ele.getElementsByTagName("device_info");
  10299. for (int i = 0; i < items.getLength(); i++) {
  10300. item = items.item(i);
  10301. attrsParam = item.getAttributes();
  10302. for (int j = 0; j < attrsParam.getLength(); j++) {
  10303. Node attr = attrsParam.item(j);
  10304. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10305. sDevice_Name = trimquotation(attr.getNodeValue());
  10306. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10307. sTwinID = trimquotation(attr.getNodeValue());
  10308. }
  10309. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10310. Log.d(TAG, "sTwinID :" + sTwinID);
  10311. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  10312. }
  10313. wallpadMobileDeviceData.closeDB();
  10314. Intent intent = new Intent();
  10315. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  10316. getApplicationContext().sendBroadcast(intent);
  10317. }
  10318. } else {
  10319. }
  10320. } catch (RuntimeException re) {
  10321. LogUtil.errorLogInfo("", TAG, re);
  10322. } catch (Exception e) {
  10323. //e.printStackTrace();
  10324. LogUtil.errorLogInfo("", TAG, e);
  10325. }
  10326. }
  10327. public String ProcGetAppVersionInfo() {
  10328. String retXML = "";
  10329. MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
  10330. int AppCount;
  10331. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  10332. retXML = XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  10333. retXML += " <home_info dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\" platform=\"Android\" count=\"" + AppCount + "\" />\r\n";
  10334. for (int i = 0; i < AppCount; i++) {
  10335. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
  10336. if (getString != null) {
  10337. retXML += " <app_list name=\"" + getString[0] + "\" version=\"" + getString[1] + "\" />\r\n";
  10338. }
  10339. }
  10340. retXML += " </service>\r\n</imap>";
  10341. return retXML;
  10342. }
  10343. public String ProcIgateInitInfo(Element ele) {
  10344. String retXML = "";
  10345. String ctrl_baudrate = "";
  10346. String ctrl_open = "";
  10347. String ctrl_framecheck = "";
  10348. String ctrl_message = "";
  10349. String eth_mode = "";
  10350. String eth_ip = "";
  10351. String eth_mac = "";
  10352. String eth_gw = "";
  10353. String eth_sm = "";
  10354. String noti_send = "";
  10355. String noti_level = "";
  10356. String noti_ip = "";
  10357. String noti_port = "";
  10358. try {
  10359. NodeList items = ele.getElementsByTagName("ctrl_param");
  10360. Node item = items.item(0);
  10361. NamedNodeMap attrsParam = item.getAttributes();
  10362. for (int i = 0; i < attrsParam.getLength(); i++) {
  10363. Node attr = attrsParam.item(i);
  10364. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  10365. ctrl_baudrate = trimquotation(attr.getNodeValue());
  10366. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  10367. ctrl_open = trimquotation(attr.getNodeValue());
  10368. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  10369. ctrl_framecheck = trimquotation(attr.getNodeValue());
  10370. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  10371. ctrl_message = trimquotation(attr.getNodeValue());
  10372. }
  10373. items = ele.getElementsByTagName("eth_param");
  10374. item = items.item(0);
  10375. attrsParam = item.getAttributes();
  10376. for (int i = 0; i < attrsParam.getLength(); i++) {
  10377. Node attr = attrsParam.item(i);
  10378. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  10379. eth_mode = trimquotation(attr.getNodeValue());
  10380. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  10381. eth_ip = trimquotation(attr.getNodeValue());
  10382. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  10383. eth_mac = trimquotation(attr.getNodeValue());
  10384. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  10385. eth_gw = trimquotation(attr.getNodeValue());
  10386. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  10387. eth_sm = trimquotation(attr.getNodeValue());
  10388. }
  10389. items = ele.getElementsByTagName("noti_param");
  10390. item = items.item(0);
  10391. attrsParam = item.getAttributes();
  10392. for (int i = 0; i < attrsParam.getLength(); i++) {
  10393. Node attr = attrsParam.item(i);
  10394. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  10395. noti_send = trimquotation(attr.getNodeValue());
  10396. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  10397. noti_level = trimquotation(attr.getNodeValue());
  10398. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  10399. noti_ip = trimquotation(attr.getNodeValue());
  10400. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  10401. noti_port = trimquotation(attr.getNodeValue());
  10402. }
  10403. wallpaddbmgr WallpadDBMGR = null;
  10404. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  10405. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  10406. if (RowCount_GatewayData > 100) {
  10407. WallpadDBMGR.DeleteLH_GatewayData("50");
  10408. }
  10409. 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);
  10410. WallpadDBMGR.closeDB();
  10411. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  10412. retXML += " </service>\r\n</imap>";
  10413. return retXML;
  10414. } catch (RuntimeException re) {
  10415. LogUtil.errorLogInfo("", TAG, re);
  10416. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10417. retXML += " </service>\r\n</imap>";
  10418. return retXML;
  10419. } catch (Exception e) {
  10420. //e.printStackTrace();
  10421. LogUtil.errorLogInfo("", TAG, e);
  10422. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10423. retXML += " </service>\r\n</imap>";
  10424. return retXML;
  10425. }
  10426. }
  10427. public String ProcElecCarChargeEventInfo(Element ele) {
  10428. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  10429. String retXML = "";
  10430. String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  10431. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  10432. try {
  10433. NodeList items = ele.getElementsByTagName("destination");
  10434. Node item = items.item(0);
  10435. NamedNodeMap attrsParam = item.getAttributes();
  10436. for (int i = 0; i < attrsParam.getLength(); i++) {
  10437. Node attr = attrsParam.item(i);
  10438. if (attr.getNodeName().equalsIgnoreCase("name"))
  10439. sName = trimquotation(attr.getNodeValue());
  10440. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10441. sId_High = trimquotation(attr.getNodeValue());
  10442. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10443. sId_Low = trimquotation(attr.getNodeValue());
  10444. }
  10445. WallpadStatusData DBMGR = null;
  10446. DBMGR = new WallpadStatusData(getApplicationContext());
  10447. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10448. DBMGR.closeDB();
  10449. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  10450. items = ele.getElementsByTagName("charging_info");
  10451. item = items.item(0);
  10452. attrsParam = item.getAttributes();
  10453. for (int i = 0; i < attrsParam.getLength(); i++) {
  10454. Node attr = attrsParam.item(i);
  10455. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  10456. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  10457. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  10458. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  10459. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  10460. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  10461. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  10462. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  10463. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  10464. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  10465. )) {
  10466. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10467. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10468. retXML += " </service>\r\n</imap>";
  10469. return retXML;
  10470. }
  10471. if (attr.getNodeName().equalsIgnoreCase("card_num"))
  10472. sCard_Num = trimquotation(attr.getNodeValue());
  10473. else if (attr.getNodeName().equalsIgnoreCase("car_num"))
  10474. sCar_Num = trimquotation(attr.getNodeValue());
  10475. else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
  10476. sCharger_Num = trimquotation(attr.getNodeValue());
  10477. else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
  10478. sCharger_Loc = trimquotation(attr.getNodeValue());
  10479. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  10480. sCharging_Status = trimquotation(attr.getNodeValue());
  10481. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  10482. (sCharging_Status.equalsIgnoreCase("charging")) ||
  10483. (sCharging_Status.equalsIgnoreCase("full")) ||
  10484. (sCharging_Status.equalsIgnoreCase("charged")) ||
  10485. (sCharging_Status.equalsIgnoreCase("stop")) ||
  10486. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  10487. (sCharging_Status.equalsIgnoreCase("check")) ||
  10488. (sCharging_Status.equalsIgnoreCase("commerror"))
  10489. )) {
  10490. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  10491. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10492. retXML += " </service>\r\n</imap>";
  10493. return retXML;
  10494. }
  10495. } else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  10496. sCharger_sort = trimquotation(attr.getNodeValue());
  10497. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  10498. (sCharger_sort.equalsIgnoreCase("fast")) ||
  10499. (sCharger_sort.equalsIgnoreCase("no_info"))
  10500. )) {
  10501. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  10502. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10503. retXML += " </service>\r\n</imap>";
  10504. return retXML;
  10505. }
  10506. } else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
  10507. sCharging_Ratio = trimquotation(attr.getNodeValue());
  10508. else if (attr.getNodeName().equalsIgnoreCase("start_time"))
  10509. sStart_Time = trimquotation(attr.getNodeValue());
  10510. else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
  10511. sRemain_Time = trimquotation(attr.getNodeValue());
  10512. }
  10513. items = ele.getElementsByTagName("message");
  10514. item = items.item(0);
  10515. Node text = item.getFirstChild();
  10516. sMessage = trimquotation(text.getNodeValue());
  10517. /**데이터 전달**/
  10518. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  10519. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  10520. Intent intent = new Intent();
  10521. intent.setAction(define.NOTIFY_ACNAME);
  10522. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  10523. intent.putExtra("sCard_Num", sCard_Num);
  10524. intent.putExtra("sCar_Num", sCar_Num);
  10525. intent.putExtra("sCharger_Num", sCharger_Num);
  10526. intent.putExtra("sCharger_Loc", sCharger_Loc);
  10527. intent.putExtra("sCharging_Status", sCharging_Status);
  10528. intent.putExtra("sCharger_sort", sCharger_sort);
  10529. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  10530. intent.putExtra("sStart_Time", sStart_Time);
  10531. intent.putExtra("sRemain_Time", sRemain_Time);
  10532. intent.putExtra("sMessage", sMessage);
  10533. WallpadDeviceSet devDB = null;
  10534. devDB = new WallpadDeviceSet(getApplicationContext());
  10535. int retInt = -1;
  10536. retInt = devDB.GetDeviceSetted("전기차충전");
  10537. devDB.closeDB();
  10538. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10539. getApplicationContext().sendBroadcast(intent);
  10540. }
  10541. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  10542. retXML += " <source name=\"homedev\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" />\r\n";
  10543. retXML += " </service>\r\n</imap>";
  10544. return retXML;
  10545. } else {
  10546. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10547. retXML += " </service>\r\n</imap>";
  10548. return retXML;
  10549. }
  10550. } catch (RuntimeException re) {
  10551. LogUtil.errorLogInfo("", TAG, re);
  10552. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10553. retXML += " </service>\r\n</imap>";
  10554. return retXML;
  10555. } catch (Exception e) {
  10556. //e.printStackTrace();
  10557. LogUtil.errorLogInfo("", TAG, e);
  10558. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10559. retXML += " </service>\r\n</imap>";
  10560. return retXML;
  10561. }
  10562. }
  10563. public String ProcEnergyTargetInfoAlarm(Element ele) {
  10564. String retXML = "";
  10565. String sName = "";
  10566. String sId_High = "";
  10567. String sId_Low = "";
  10568. String vName[];
  10569. String vTarget[];
  10570. String vTarget_Cost[];
  10571. String vUsed[];
  10572. String vUsed_Cost[];
  10573. String vPredict[];
  10574. String vPredict_Cost[];
  10575. String vAlarm_info[];
  10576. String vRead_Date[];
  10577. String vRead_Day[];
  10578. String vV_Msg[];
  10579. String sMessage = "";
  10580. try {
  10581. NodeList items = ele.getElementsByTagName("source");
  10582. Node item = items.item(0);
  10583. NamedNodeMap attrsParam = item.getAttributes();
  10584. for (int i = 0; i < attrsParam.getLength(); i++) {
  10585. Node attr = attrsParam.item(i);
  10586. if (attr.getNodeName().equalsIgnoreCase("name"))
  10587. sName = trimquotation(attr.getNodeValue());
  10588. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10589. sId_High = trimquotation(attr.getNodeValue());
  10590. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10591. sId_Low = trimquotation(attr.getNodeValue());
  10592. }
  10593. WallpadStatusData DBMGR = null;
  10594. DBMGR = new WallpadStatusData(getApplicationContext());
  10595. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10596. DBMGR.closeDB();
  10597. if ((sName.equalsIgnoreCase("home") == true) &&
  10598. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  10599. (sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
  10600. items = ele.getElementsByTagName("valuelist");
  10601. Log.d(TAG, "items.getLength() :" + items.getLength());
  10602. vName = new String[items.getLength()];
  10603. vTarget = new String[items.getLength()];
  10604. vTarget_Cost = new String[items.getLength()];
  10605. vUsed = new String[items.getLength()];
  10606. vUsed_Cost = new String[items.getLength()];
  10607. vPredict = new String[items.getLength()];
  10608. vPredict_Cost = new String[items.getLength()];
  10609. vAlarm_info = new String[items.getLength()];
  10610. vRead_Date = new String[items.getLength()];
  10611. vRead_Day = new String[items.getLength()];
  10612. vV_Msg = new String[items.getLength()];
  10613. for (int j = 0; j < items.getLength(); j++) {
  10614. Log.d(TAG, "j :" + j);
  10615. item = items.item(j);
  10616. attrsParam = item.getAttributes();
  10617. Log.d(TAG, "attrsParam :" + attrsParam);
  10618. for (int i = 0; i < attrsParam.getLength(); i++) {
  10619. Node attr = attrsParam.item(i);
  10620. if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  10621. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  10622. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  10623. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  10624. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  10625. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  10626. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  10627. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  10628. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  10629. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  10630. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  10631. )) {
  10632. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10633. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10634. retXML += " </service>\r\n</imap>";
  10635. return retXML;
  10636. }
  10637. if (attr.getNodeName().equalsIgnoreCase("name")) {
  10638. vName[j] = trimquotation(attr.getNodeValue());
  10639. if (!((vName[j].equalsIgnoreCase("elect") == true) ||
  10640. (vName[j].equalsIgnoreCase("water") == true) ||
  10641. (vName[j].equalsIgnoreCase("gas") == true) ||
  10642. (vName[j].equalsIgnoreCase("heating") == true) ||
  10643. (vName[j].equalsIgnoreCase("hotwater") == true)
  10644. )) {
  10645. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  10646. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10647. retXML += " </service>\r\n</imap>";
  10648. return retXML;
  10649. }
  10650. } else if (attr.getNodeName().equalsIgnoreCase("target"))
  10651. vTarget[j] = trimquotation(attr.getNodeValue());
  10652. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  10653. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  10654. else if (attr.getNodeName().equalsIgnoreCase("used"))
  10655. vUsed[j] = trimquotation(attr.getNodeValue());
  10656. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  10657. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  10658. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  10659. vPredict[j] = trimquotation(attr.getNodeValue());
  10660. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  10661. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  10662. else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
  10663. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  10664. if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  10665. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  10666. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  10667. )) {
  10668. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  10669. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10670. retXML += " </service>\r\n</imap>";
  10671. return retXML;
  10672. }
  10673. } else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
  10674. vRead_Date[j] = trimquotation(attr.getNodeValue());
  10675. if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  10676. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  10677. )) {
  10678. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  10679. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10680. retXML += " </service>\r\n</imap>";
  10681. return retXML;
  10682. }
  10683. } else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  10684. vRead_Day[j] = trimquotation(attr.getNodeValue());
  10685. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  10686. vV_Msg[j] = trimquotation(attr.getNodeValue());
  10687. }
  10688. }
  10689. items = ele.getElementsByTagName("message");
  10690. item = items.item(0);
  10691. Node text = item.getFirstChild();
  10692. sMessage = trimquotation(text.getNodeValue());
  10693. /**데이터 전달**/
  10694. for (int i = 0; i < vName.length; i++) {
  10695. Log.d(TAG, "vName[" + i + "]: " + vName[i]);
  10696. Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
  10697. Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
  10698. Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
  10699. Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
  10700. Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
  10701. Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
  10702. Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
  10703. Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
  10704. Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
  10705. Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
  10706. }
  10707. Intent intent = new Intent();
  10708. intent.setAction(define.NOTIFY_ACNAME);
  10709. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  10710. for (int i = 0; i < vName.length; i++) {
  10711. if (vName[i].equals("elect")) {
  10712. intent.putExtra("elect_target", vTarget[i]);
  10713. intent.putExtra("elect_used", vUsed[i]);
  10714. intent.putExtra("elect_info", vAlarm_info[i]);
  10715. } else if (vName[i].equals("water")) {
  10716. intent.putExtra("water_target", vTarget[i]);
  10717. intent.putExtra("water_used", vUsed[i]);
  10718. intent.putExtra("water_info", vAlarm_info[i]);
  10719. } else if (vName[i].equals("gas")) {
  10720. intent.putExtra("gas_target", vTarget[i]);
  10721. intent.putExtra("gas_used", vUsed[i]);
  10722. intent.putExtra("gas_info", vAlarm_info[i]);
  10723. } else if (vName[i].equals("heating")) {
  10724. intent.putExtra("heating_target", vTarget[i]);
  10725. intent.putExtra("heating_used", vUsed[i]);
  10726. intent.putExtra("heating_info", vAlarm_info[i]);
  10727. } else if (vName[i].equals("hotwater")) {
  10728. intent.putExtra("hotwater_target", vTarget[i]);
  10729. intent.putExtra("hotwater_used", vUsed[i]);
  10730. intent.putExtra("hotwater_info", vAlarm_info[i]);
  10731. }
  10732. }
  10733. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  10734. retXML += " <source name=\"home\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" count=\"" + vName.length + "\"" + " s_msg=\"null\" />\r\n";
  10735. for (int i = 0; i < vName.length; i++) {
  10736. retXML += " <valuelist name=\"" + vName[i] + "\" alarm_info=\"" + vAlarm_info[i] + "\" v_msg=\"null\" />\r\n";
  10737. }
  10738. retXML += " <message>\"null\"</message>\r\n";
  10739. retXML += " </service>\r\n</imap>";
  10740. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10741. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  10742. devSet.closeDB();
  10743. if (MetringDB != null) {
  10744. try {
  10745. String devInfo = MetringDB[1];
  10746. devInfo = devInfo.replace('(', '_');
  10747. devInfo = devInfo.replace(':', '_');
  10748. devInfo = devInfo.replace(')', '_');
  10749. String[] MetringInfo = devInfo.split("_");
  10750. // MetringInfo[1] -> 회로수
  10751. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  10752. // MetringInfo[4] -> IP
  10753. // MetringInfo[5] -> IP정보
  10754. // MetringInfo[6] -> 검침일사용자설정
  10755. // MetringInfo[7] -> 사용함 또는 사용안함
  10756. if (MetringInfo[3].equals("사용함") == true) {
  10757. getApplicationContext().sendBroadcast(intent);
  10758. }
  10759. } catch (RuntimeException re) {
  10760. LogUtil.errorLogInfo("", TAG, re);
  10761. } catch (Exception e) {
  10762. //e.printStackTrace();
  10763. LogUtil.errorLogInfo("", TAG, e);
  10764. }
  10765. } else {
  10766. }
  10767. return retXML;
  10768. } else {
  10769. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10770. retXML += " </service>\r\n</imap>";
  10771. return retXML;
  10772. }
  10773. } catch (RuntimeException re) {
  10774. LogUtil.errorLogInfo("", TAG, re);
  10775. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10776. retXML += " </service>\r\n</imap>";
  10777. return retXML;
  10778. } catch (Exception e) {
  10779. //e.printStackTrace();
  10780. LogUtil.errorLogInfo("", TAG, e);
  10781. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10782. retXML += " </service>\r\n</imap>";
  10783. return retXML;
  10784. }
  10785. }
  10786. public String ProcCheckCallOption() {
  10787. int[] resultDB = {0, 0};
  10788. String retXML = "";
  10789. String sOption = "sip";
  10790. String sMessage = "null";
  10791. try {
  10792. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10793. resultDB = devSet.Get_Handicapped_Mode();
  10794. devSet.closeDB();
  10795. if (resultDB[0] == 0) {
  10796. //장애인모드 사용 안함
  10797. } else if (resultDB[0] == 1) {
  10798. //장애인모드 사용함
  10799. }
  10800. switch (resultDB[1]) {
  10801. case 0: //일반모드
  10802. sOption = "sip";
  10803. break;
  10804. case 1: //청각장애인
  10805. sOption = "deaf";
  10806. break;
  10807. case 2: //시각장애인
  10808. sOption = "blind";
  10809. break;
  10810. default:
  10811. break;
  10812. }
  10813. if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  10814. {
  10815. //본 구문에 들어올수 없음
  10816. sOption = "none";
  10817. }
  10818. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  10819. retXML += " <option>\"" + sOption + "\"</option>\r\n";
  10820. retXML += " <message>\"" + sMessage + "\"</message>\r\n";
  10821. retXML += " </service>\r\n</imap>";
  10822. return retXML;
  10823. } catch (RuntimeException re) {
  10824. LogUtil.errorLogInfo("", TAG, re);
  10825. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10826. retXML += " </service>\r\n</imap>";
  10827. return retXML;
  10828. } catch (Exception e) {
  10829. //e.printStackTrace();
  10830. LogUtil.errorLogInfo("", TAG, e);
  10831. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10832. retXML += " </service>\r\n</imap>";
  10833. return retXML;
  10834. }
  10835. }
  10836. public String ProcChatSequence(Element ele) {
  10837. String retXML = "";
  10838. String sFrom = "error";
  10839. String sTo = "error";
  10840. String sContact = "error";
  10841. String sSequence = "error";
  10842. String sStatus = "error";
  10843. String sMessage = "error";
  10844. String reply_Sequence = "error";
  10845. String reply_Status = "error";
  10846. String reply_Message = "null";
  10847. try {
  10848. NodeList items = ele.getElementsByTagName("sequence");
  10849. Node item = items.item(0);
  10850. NamedNodeMap attrsParam = item.getAttributes();
  10851. sSequence = trimquotation(item.getTextContent());
  10852. ///////////////////////////////////////////////
  10853. items = ele.getElementsByTagName("status");
  10854. item = items.item(0);
  10855. attrsParam = item.getAttributes();
  10856. sStatus = trimquotation(item.getTextContent());
  10857. ///////////////////////////////////////////////
  10858. items = ele.getElementsByTagName("message");
  10859. item = items.item(0);
  10860. attrsParam = item.getAttributes();
  10861. sMessage = trimquotation(item.getTextContent());
  10862. ///////////////////////////////////////////////
  10863. items = ele.getElementsByTagName("from");
  10864. item = items.item(0);
  10865. attrsParam = item.getAttributes();
  10866. sFrom = trimquotation(item.getTextContent());
  10867. ///////////////////////////////////////////////
  10868. items = ele.getElementsByTagName("to");
  10869. item = items.item(0);
  10870. attrsParam = item.getAttributes();
  10871. sTo = trimquotation(item.getTextContent());
  10872. ///////////////////////////////////////////////
  10873. items = ele.getElementsByTagName("contact");
  10874. item = items.item(0);
  10875. attrsParam = item.getAttributes();
  10876. sContact = trimquotation(item.getTextContent());
  10877. ///////////////////////////////////////////////
  10878. if (!((sSequence.equalsIgnoreCase("try") == true) ||
  10879. (sSequence.equalsIgnoreCase("start") == true) ||
  10880. (sSequence.equalsIgnoreCase("quit") == true) ||
  10881. (sSequence.equalsIgnoreCase("cancel") == true) ||
  10882. (sSequence.equalsIgnoreCase("ok") == true) ||
  10883. (sSequence.equalsIgnoreCase("busy") == true) ||
  10884. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  10885. (sSequence.equalsIgnoreCase("reject") == true)
  10886. )) {
  10887. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  10888. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10889. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10890. retXML += " </service>\r\n</imap>";
  10891. return retXML;
  10892. }
  10893. if (!((sStatus.equalsIgnoreCase("idle") == true) ||
  10894. (sStatus.equalsIgnoreCase("ringing") == true) ||
  10895. (sStatus.equalsIgnoreCase("talking") == true)
  10896. )) {
  10897. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  10898. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10899. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10900. retXML += " </service>\r\n</imap>";
  10901. return retXML;
  10902. }
  10903. //입력값 처리 필요!!
  10904. //김용성 과장님 작업필요
  10905. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  10906. //확인 하시고 위 정보 확인해주세요.
  10907. Log.d(TAG, "sFrom:" + sFrom);
  10908. Log.d(TAG, "sTo:" + sTo);
  10909. Log.d(TAG, "Contact:" + sContact);
  10910. Log.d(TAG, "sSequence:" + sSequence);
  10911. Log.d(TAG, "sStatus:" + sStatus);
  10912. if (sSequence.equalsIgnoreCase("try") == true) {
  10913. //채팅 요청
  10914. } else if (sSequence.equalsIgnoreCase("start") == true) {
  10915. //채팅 시작
  10916. } else if (sSequence.equalsIgnoreCase("quit") == true) {
  10917. //채팅 종료
  10918. } else if (sSequence.equalsIgnoreCase("cancel") == true) {
  10919. //취소
  10920. } else if (sSequence.equalsIgnoreCase("ok") == true) {
  10921. //요청확인
  10922. } else if (sSequence.equalsIgnoreCase("busy") == true) {
  10923. //통화중
  10924. } else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
  10925. //SIP 통화중
  10926. } else if (sSequence.equalsIgnoreCase("reject") == true) {
  10927. //거절
  10928. }
  10929. if (sStatus.equalsIgnoreCase("idle") == true) {
  10930. //대기
  10931. } else if (sStatus.equalsIgnoreCase("ringing") == true) {
  10932. //연결중
  10933. } else if (sStatus.equalsIgnoreCase("talking") == true) {
  10934. //통화중
  10935. }
  10936. //응답값 입력 필요!!
  10937. //김용성 과장님 작업필요
  10938. reply_Message = "null";
  10939. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  10940. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10941. retXML += " </service>\r\n</imap>";
  10942. return retXML;
  10943. } catch (RuntimeException re) {
  10944. LogUtil.errorLogInfo("", TAG, re);
  10945. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10946. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10947. retXML += " </service>\r\n</imap>";
  10948. return retXML;
  10949. } catch (Exception e) {
  10950. //e.printStackTrace();
  10951. LogUtil.errorLogInfo("", TAG, e);
  10952. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10953. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  10954. retXML += " </service>\r\n</imap>";
  10955. return retXML;
  10956. }
  10957. }
  10958. public String ProcChatMessage(Element ele) {
  10959. String retXML = "";
  10960. String sChatMessage = "error";
  10961. String sMessage = "error";
  10962. try {
  10963. NodeList items = ele.getElementsByTagName("chat");
  10964. Node item = items.item(0);
  10965. NamedNodeMap attrsParam = item.getAttributes();
  10966. sChatMessage = trimquotation(item.getTextContent());
  10967. ///////////////////////////////////////////////
  10968. items = ele.getElementsByTagName("message");
  10969. item = items.item(0);
  10970. attrsParam = item.getAttributes();
  10971. sMessage = trimquotation(item.getTextContent());
  10972. ///////////////////////////////////////////////
  10973. //test
  10974. Log.d(TAG, "sChatMessage is " + sChatMessage);
  10975. Log.d(TAG, "sMessage is " + sMessage);
  10976. //test
  10977. Intent intent = new Intent();
  10978. intent.setAction(define.NOTIFY_ACNAME);
  10979. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  10980. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  10981. intent.putExtra("ADD_MESSAGE", sMessage);
  10982. getApplicationContext().sendBroadcast(intent);
  10983. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  10984. retXML += " <message>\"" + "null" + "\"</message>\r\n";
  10985. retXML += " </service>\r\n</imap>";
  10986. return retXML;
  10987. } catch (RuntimeException re) {
  10988. LogUtil.errorLogInfo("", TAG, re);
  10989. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10990. retXML += " </service>\r\n</imap>";
  10991. return retXML;
  10992. } catch (Exception e) {
  10993. //e.printStackTrace();
  10994. LogUtil.errorLogInfo("", TAG, e);
  10995. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10996. retXML += " </service>\r\n</imap>";
  10997. return retXML;
  10998. }
  10999. }
  11000. public String ProcEvacuationLadderOpen(Element ele) {
  11001. String retXML = "";
  11002. try {
  11003. String sDong = null;
  11004. String sHo = null;
  11005. NodeList items = ele.getElementsByTagName("home_info");
  11006. Node item = items.item(0);
  11007. NamedNodeMap attrsParam = item.getAttributes();
  11008. for (int i = 0; i < attrsParam.getLength(); i++) {
  11009. Node attr = attrsParam.item(i);
  11010. if (attr.getNodeName().equalsIgnoreCase("dong"))
  11011. sDong = trimquotation(attr.getNodeValue());
  11012. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  11013. sHo = trimquotation(attr.getNodeValue());
  11014. }
  11015. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  11016. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  11017. deviceSet.closeDB();
  11018. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  11019. WallpadStatusData DBMGR = null;
  11020. DBMGR = new WallpadStatusData(getApplicationContext());
  11021. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  11022. DBMGR.closeDB();
  11023. String myIP = addc.IPAddress;
  11024. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  11025. String[] SplitedString = myIP.split("\\.");
  11026. if (SplitedString != null) {
  11027. if (SplitedString.length == 4) {
  11028. int temp = Integer.parseInt(SplitedString[2]);
  11029. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11030. temp = temp - 1;
  11031. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11032. temp = temp + 1;
  11033. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  11034. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  11035. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  11036. DestStair = String.valueOf(temp);
  11037. }
  11038. }
  11039. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
  11040. /**
  11041. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  11042. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  11043. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  11044. * **/
  11045. WallpadDeviceSet devset;
  11046. devset = new WallpadDeviceSet(getApplicationContext());
  11047. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11048. devset.closeDB();
  11049. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11050. /**
  11051. * 피난사다리 알림!!!
  11052. * **/
  11053. ReceiveNetworkLadderBr(ladderDownSend);
  11054. }
  11055. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  11056. retXML += " </service>\r\n</imap>";
  11057. return retXML;
  11058. } else {
  11059. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11060. retXML += " </service>\r\n</imap>";
  11061. return retXML;
  11062. }
  11063. } catch (RuntimeException re) {
  11064. LogUtil.errorLogInfo("", TAG, re);
  11065. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11066. retXML += " </service>\r\n</imap>";
  11067. return retXML;
  11068. } catch (Exception e) {
  11069. //e.printStackTrace();
  11070. LogUtil.errorLogInfo("", TAG, e);
  11071. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11072. retXML += " </service>\r\n</imap>";
  11073. return retXML;
  11074. }
  11075. }
  11076. private void ReceiveNetworkLadderBr(int val) {
  11077. int base = 7000;
  11078. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  11079. int Menu_Start_Option = 1;
  11080. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  11081. int AlarmStatus = wdb.GetAlarmStatus();
  11082. wdb.closeDB();
  11083. boolean MgrAppRun = false;
  11084. final String packageNameMgr = "com.artncore.managersetting";
  11085. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  11086. if (MgrAppRun)
  11087. return;
  11088. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  11089. return;
  11090. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11091. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11092. devset.closeDB();
  11093. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11094. Common.SendAppFinishReqBR(getApplicationContext());
  11095. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11096. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11097. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  11098. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11099. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11100. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  11101. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11102. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  11103. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11104. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11105. getApplicationContext().startActivity(newintent);
  11106. }
  11107. }
  11108. /**
  11109. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  11110. *
  11111. * @param ele Element Xml 데이터
  11112. * @return String 타입의 응답 메시지 생성
  11113. **/
  11114. public String SmartLightDetailInfo(Element ele) {
  11115. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  11116. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  11117. }
  11118. /**
  11119. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  11120. *
  11121. * @param ele Element Xml 데이터
  11122. * @return String 타입의 응답 메시지 생성
  11123. **/
  11124. public String KNXDeviceDetailInfo(Element ele) {
  11125. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  11126. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  11127. }
  11128. public String ProcSetServerChange(Element ele) {
  11129. String retXML = "";
  11130. String versionTXT = null;
  11131. try {
  11132. boolean bRet = false;
  11133. NodeList items = ele.getElementsByTagName("ver_server");
  11134. Node item = items.item(0);
  11135. Node text = item.getFirstChild();
  11136. versionTXT = trimquotation(text.getNodeValue());
  11137. if (versionTXT.equalsIgnoreCase("1.0")) {
  11138. bRet = true;
  11139. } else if (versionTXT.indexOf("2.") >= 0) {
  11140. bRet = true;
  11141. }
  11142. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11143. if (SetData != null && bRet == true) {
  11144. SetData.SetServerVer(versionTXT);
  11145. SetData.closeDB();
  11146. }
  11147. if (bRet == true) {
  11148. try {
  11149. iMapSverReload tSock = new iMapSverReload();
  11150. tSock.start();
  11151. } catch (IOException e) {
  11152. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  11153. //e.printStackTrace();
  11154. LogUtil.errorLogInfo("", TAG, e);
  11155. }
  11156. }
  11157. // 버전 체크해서
  11158. // 응답하고 나서
  11159. // 수신부 쓰레드 재 로딩..
  11160. if (versionTXT != null && bRet == true) {
  11161. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  11162. retXML += " </service>\r\n</imap>";
  11163. return retXML;
  11164. } else {
  11165. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11166. retXML += " </service>\r\n</imap>";
  11167. return retXML;
  11168. }
  11169. } catch (RuntimeException re) {
  11170. LogUtil.errorLogInfo("", TAG, re);
  11171. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11172. retXML += " </service>\r\n</imap>";
  11173. return retXML;
  11174. } catch (Exception e) {
  11175. //e.printStackTrace();
  11176. LogUtil.errorLogInfo("", TAG, e);
  11177. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11178. retXML += " </service>\r\n</imap>";
  11179. return retXML;
  11180. }
  11181. }
  11182. // 메인 서버 소켓 클래스
  11183. public class iMapSverReload extends Thread {
  11184. ServerSocket svr;
  11185. public iMapSverReload() throws IOException {
  11186. /////////////////////////////////////////////////////////////////////
  11187. // 신형 단지서버 사용 유무를 가져온다.
  11188. /////////////////////////////////////////////////////////////////////
  11189. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11190. if (SetData != null) {
  11191. String serverVesionInfo = SetData.GetServerVer();
  11192. SetData.closeDB();
  11193. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  11194. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11195. boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
  11196. devset.closeDB();
  11197. } else {
  11198. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11199. boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
  11200. devset.closeDB();
  11201. }
  11202. }
  11203. try {
  11204. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11205. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11206. wallpadDeviceSet.closeDB();
  11207. } catch (RuntimeException re) {
  11208. LogUtil.errorLogInfo("", TAG, re);
  11209. mNewDanjiServer = false;
  11210. } catch (Exception e) {
  11211. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  11212. //e.printStackTrace();
  11213. LogUtil.errorLogInfo("", TAG, e);
  11214. mNewDanjiServer = false;
  11215. }
  11216. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
  11217. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  11218. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  11219. // 관리 PC IP도 변경하도록 한다.
  11220. if (mNewDanjiServer == true) {
  11221. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11222. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  11223. wallpadStatusData.closeDB();
  11224. } else {
  11225. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11226. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  11227. wallpadStatusData.closeDB();
  11228. }
  11229. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  11230. }
  11231. public void run() {
  11232. try {
  11233. try {
  11234. Thread.sleep(400);
  11235. } catch (RuntimeException re) {
  11236. LogUtil.errorLogInfo("", TAG, re);
  11237. } catch (Exception e) {
  11238. LogUtil.errorLogInfo("", TAG, e);
  11239. }
  11240. SvrSock.destoryThread();
  11241. for (int i = 0; i < 20; i++) {
  11242. if (SvrSock.isAlive() == false) {
  11243. Log.d(TAG, " Receive Socket Reload i = : " + i);
  11244. break;
  11245. } else {
  11246. Log.d(TAG, " is Live Socket Reload i = : " + i);
  11247. }
  11248. try {
  11249. Thread.sleep(100);
  11250. } catch (RuntimeException re) {
  11251. LogUtil.errorLogInfo("", TAG, re);
  11252. } catch (Exception e) {
  11253. LogUtil.errorLogInfo("", TAG, e);
  11254. }
  11255. }
  11256. SvrSock = new iMapSverSocket();
  11257. SvrSock.start();
  11258. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  11259. try {
  11260. Thread.sleep(3000);
  11261. } catch (RuntimeException re) {
  11262. LogUtil.errorLogInfo("", TAG, re);
  11263. } catch (Exception e) {
  11264. LogUtil.errorLogInfo("", TAG, e);
  11265. }
  11266. try {
  11267. Intent intent = new Intent();
  11268. intent.setAction(define.NOTIFY_ACNAME);
  11269. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  11270. getApplicationContext().sendBroadcast(intent);
  11271. } catch (RuntimeException re) {
  11272. LogUtil.errorLogInfo("", TAG, re);
  11273. } catch (Exception e) {
  11274. //e.printStackTrace();
  11275. LogUtil.errorLogInfo("", TAG, e);
  11276. }
  11277. } catch (IOException e) {
  11278. //e.printStackTrace();
  11279. LogUtil.errorLogInfo("", TAG, e);
  11280. }
  11281. }
  11282. }
  11283. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  11284. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  11285. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  11286. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  11287. public static final int SCHEDULE_START_CALLAPP = 30004;
  11288. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  11289. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  11290. public class SchedulerThread extends Thread {
  11291. boolean doRun;
  11292. AddressSet addr;
  11293. String AddressStr;
  11294. String IPaddr;
  11295. String VerBSP = "";
  11296. String VerAPP;
  11297. String VerSetting;
  11298. String VerNews;
  11299. String VerWeather;
  11300. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  11301. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  11302. private jni mGleInterface = null;
  11303. private final int LIVE_SIGNAL_TIME = 20;
  11304. private int m_LiveSignalCount = 0;
  11305. private int m_MainAppLiveCount = 0;
  11306. Handler ScheDuleHandler = new Handler() {
  11307. public void handleMessage(Message msg) {
  11308. switch (msg.what) {
  11309. case SCHEDULE_START_HEARTBEAT: {
  11310. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  11311. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11312. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11313. DBMGR.closeDB();
  11314. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11315. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11316. }
  11317. break;
  11318. case SCHEDULE_CHANGE_HEARTBEAT:
  11319. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  11320. synchronized (ScheduleList) {
  11321. ScheduleData CheckData;
  11322. for (int i = 0; i < ScheduleList.size(); i++) {
  11323. CheckData = ScheduleList.get(i);
  11324. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11325. Calendar cal = new GregorianCalendar();
  11326. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11327. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11328. DBMGR.closeDB();
  11329. cal.add(Calendar.MINUTE, heartbeatP);
  11330. CheckData.TData = cal;
  11331. ScheduleList.set(i, CheckData);
  11332. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11333. return;
  11334. }
  11335. }
  11336. }
  11337. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11338. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11339. break;
  11340. case SCHEDULE_START_STATUSBEAT:
  11341. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  11342. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11343. break;
  11344. case SCHEDULE_CHANGE_STATUSBEAT:
  11345. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  11346. synchronized (ScheduleList) {
  11347. ScheduleData CheckData;
  11348. for (int i = 0; i < ScheduleList.size(); i++) {
  11349. CheckData = ScheduleList.get(i);
  11350. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11351. Calendar cal = new GregorianCalendar();
  11352. cal.add(Calendar.MINUTE, heartbeatP);
  11353. CheckData.TData = cal;
  11354. ScheduleList.set(i, CheckData);
  11355. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11356. return;
  11357. }
  11358. }
  11359. }
  11360. break;
  11361. case SCHEDULE_START_CALLAPP:
  11362. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  11363. // Bundle bundle = new Bundle();
  11364. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  11365. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  11366. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  11367. // .putExtra(ITEM_CALL_DATA, bundle);
  11368. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11369. // iMAPstartActivity(intent);
  11370. break;
  11371. }
  11372. }
  11373. };
  11374. Handler GetHandler() {
  11375. return ScheDuleHandler;
  11376. }
  11377. public class ScheduleData {
  11378. Calendar TData;
  11379. String ActionSTR;
  11380. public ScheduleData(Calendar tdata, String ActionStr) {
  11381. TData = tdata;
  11382. ActionSTR = ActionStr;
  11383. }
  11384. }
  11385. public SchedulerThread() {
  11386. doRun = true;
  11387. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11388. addr = DBMGR.getAddressMGR();
  11389. VerAPP = DBMGR.GetAPPVer();
  11390. VerSetting = DBMGR.GetSettingVer();
  11391. VerNews = DBMGR.GetNoticeVer();
  11392. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11393. DBMGR.closeDB();
  11394. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  11395. try {
  11396. mGleInterface = new jni();
  11397. } catch (RuntimeException re) {
  11398. LogUtil.errorLogInfo("", TAG, re);
  11399. } catch (Exception e) {
  11400. Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
  11401. }
  11402. }
  11403. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
  11404. VerAPP = GetAppVersion();
  11405. }
  11406. AddressStr = addr.Dong + "동" + addr.Ho + "호";
  11407. IPaddr = addr.IPAddress;
  11408. ScheDulerHandler = ScheDuleHandler;
  11409. }
  11410. public void reg_schedule(int min, String Action) {
  11411. for (int i = 0; i < ScheduleList.size(); i++) {
  11412. ScheduleData scdata = ScheduleList.get(i);
  11413. if (scdata.ActionSTR.equals(Action)) {
  11414. ScheduleList.remove(i);
  11415. break;
  11416. }
  11417. }
  11418. Calendar cal = new GregorianCalendar();
  11419. cal.add(Calendar.MINUTE, min);
  11420. ScheduleData regData = new ScheduleData(cal, Action);
  11421. synchronized (ScheduleList) {
  11422. ScheduleList.add(regData);
  11423. }
  11424. }
  11425. private void doSchedule(String doing) {
  11426. String[] doingData = doing.split(";");
  11427. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11428. try {
  11429. String SendingStr = MakeHeartbeat();
  11430. SendToServer(SendingStr);
  11431. Calendar cal = new GregorianCalendar();
  11432. 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));
  11433. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11434. DBMGR.SetLastHeartbeat(timedata);
  11435. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11436. DBMGR.closeDB();
  11437. } catch (RuntimeException re) {
  11438. LogUtil.errorLogInfo("", TAG, re);
  11439. } catch (Exception e) {
  11440. //e.printStackTrace();
  11441. LogUtil.errorLogInfo("", TAG, e);
  11442. }
  11443. } else if (doingData[0].equals("UPDATETIME")) {
  11444. } else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11445. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  11446. if (!Common.getDeviceServeiceLoadComplite()) return;
  11447. String SendingStr = MakeStatusReport();
  11448. if (SendingStr == null) return;
  11449. SendToServer(SendingStr);
  11450. Calendar cal = new GregorianCalendar();
  11451. 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));
  11452. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11453. DBMGR.SetLastStatusbeat(timedata);
  11454. DBMGR.closeDB();
  11455. int StatusP = 720;
  11456. try {
  11457. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11458. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11459. devset.closeDB();
  11460. if (StatusVal == null) StatusP = 720;
  11461. else StatusP = Integer.parseInt(StatusVal[1]);
  11462. } catch (RuntimeException re) {
  11463. LogUtil.errorLogInfo("", TAG, re);
  11464. } catch (Exception e) {
  11465. //e.printStackTrace();
  11466. LogUtil.errorLogInfo("", TAG, e);
  11467. }
  11468. reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
  11469. }
  11470. }
  11471. private String MakeHeartbeat() {
  11472. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11473. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11474. VerNews = DBMGR.GetNoticeVer();
  11475. VerSetting = DBMGR.GetSettingVer();
  11476. String VerServer = DBMGR.GetServerVer();
  11477. DBMGR.closeDB();
  11478. if (VerServer == null) {
  11479. Log.d(TAG, "VerServer null");
  11480. VerServer = "1.0";
  11481. }
  11482. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11483. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  11484. wallpadDeviceSet.closeDB();
  11485. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  11486. // 스마트 분전반
  11487. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  11488. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  11489. String retStr = XMLHeader +
  11490. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11491. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11492. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11493. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11494. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11495. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11496. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11497. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11498. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11499. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11500. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11501. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n" +
  11502. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n" +
  11503. "</service>\r\n</imap>";
  11504. return retStr;
  11505. } else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  11506. // TODO KNX 분전반
  11507. // String retStr = XMLHeader+
  11508. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  11509. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  11510. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  11511. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  11512. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  11513. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  11514. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  11515. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  11516. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  11517. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  11518. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11519. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  11520. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  11521. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  11522. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  11523. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  11524. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  11525. // "</service>\r\n</imap>";
  11526. String retStr = XMLHeader +
  11527. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11528. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11529. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11530. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11531. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11532. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11533. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11534. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11535. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11536. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11537. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11538. "</service>\r\n</imap>";
  11539. return retStr;
  11540. } else {
  11541. String retStr = XMLHeader +
  11542. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11543. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11544. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11545. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11546. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11547. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11548. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11549. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11550. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11551. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11552. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11553. "</service>\r\n</imap>";
  11554. return retStr;
  11555. }
  11556. }
  11557. public String GetAppVersion() {
  11558. PackageInfo pi = null;
  11559. try {
  11560. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  11561. } catch (RuntimeException re) {
  11562. LogUtil.errorLogInfo("", TAG, re);
  11563. } catch (Exception e) {
  11564. LogUtil.errorLogInfo("", TAG, e);
  11565. }
  11566. return pi.versionName;
  11567. }
  11568. boolean isAlawaysrun = true;
  11569. public void run() {
  11570. while (/*doRun*/ isAlawaysrun) {
  11571. //Common.DebugLog("SchedulerThread ------ 10Sec");
  11572. CheckHeartBeat();
  11573. CheckStatusBeat();
  11574. CheckWallPadLiveSignal();
  11575. LiveCheckRebooting();
  11576. 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
  11577. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  11578. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  11579. //다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
  11580. if(skipCount==0) {
  11581. sendMsgToActivity(1234);
  11582. Log.d(TAG, "sendMsgToActivity!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
  11583. }
  11584. skipCount++;
  11585. if(skipCount==6) skipCount = 0 ;
  11586. }
  11587. try {
  11588. Thread.sleep(10000);
  11589. } catch (RuntimeException re) {
  11590. LogUtil.errorLogInfo("", TAG, re);
  11591. } catch (Exception e) {
  11592. LogUtil.errorLogInfo("", TAG, e);
  11593. }
  11594. }
  11595. }
  11596. public void SetLive() {
  11597. m_MainAppLiveCount++;
  11598. }
  11599. private int CheckTime30Sec = 0;
  11600. private void LiveCheckRebooting() {
  11601. try {
  11602. CheckTime30Sec++;
  11603. if (CheckTime30Sec % 20 == 0) {
  11604. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  11605. // // 10초마다 수행되는 함수이니....
  11606. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  11607. // if (m_MainAppLiveCount == 0) {
  11608. // //리셋
  11609. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  11610. // {
  11611. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  11612. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  11613. // pm.userActivity(8, true);
  11614. // }
  11615. // else
  11616. // {
  11617. // Log.d(TAG, "Main App Down Reset IHN_750");
  11618. // WallPadInterface wpdifc = new WallPadInterface();
  11619. // wpdifc.WachdogSystemReset();
  11620. // }
  11621. // }
  11622. // }
  11623. CheckTime30Sec = 0;
  11624. }
  11625. if (CheckTime30Sec >= 30000) {
  11626. CheckTime30Sec = 0;
  11627. }
  11628. } catch (RuntimeException re) {
  11629. LogUtil.errorLogInfo("", TAG, re);
  11630. } catch (Exception e) {
  11631. //e.printStackTrace();
  11632. LogUtil.errorLogInfo("", TAG, e);
  11633. }
  11634. }
  11635. private void CheckWallPadLiveSignal() {
  11636. try {
  11637. int nTime = LIVE_SIGNAL_TIME / 10;
  11638. m_LiveSignalCount++;
  11639. if (m_LiveSignalCount >= nTime) {
  11640. m_LiveSignalCount = 0;
  11641. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  11642. }
  11643. } catch (RuntimeException re) {
  11644. LogUtil.errorLogInfo("", TAG, re);
  11645. } catch (Exception e) {
  11646. Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
  11647. }
  11648. }
  11649. protected void CheckStatusBeat() {
  11650. try {
  11651. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11652. String statusbeatdata = WPD.GetLastStatusbeat();
  11653. WPD.closeDB();
  11654. int StatusP = 720;
  11655. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11656. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11657. if (StatusVal == null) StatusP = 720;
  11658. else
  11659. StatusP = Integer.parseInt(StatusVal[1]);
  11660. devset.closeDB();
  11661. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11662. } catch (RuntimeException re) {
  11663. LogUtil.errorLogInfo("", TAG, re);
  11664. } catch (Exception e) {
  11665. //e.printStackTrace();
  11666. LogUtil.errorLogInfo("", TAG, e);
  11667. }
  11668. }
  11669. protected void CheckHeartBeat() {
  11670. try {
  11671. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11672. String heartbeatdata = WPD.GetLastHeartbeat();
  11673. int heartbeatPer = WPD.GetHeartbeatPeriod();
  11674. WPD.closeDB();
  11675. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11676. } catch (RuntimeException re) {
  11677. LogUtil.errorLogInfo("", TAG, re);
  11678. } catch (Exception e) {
  11679. //e.printStackTrace();
  11680. LogUtil.errorLogInfo("", TAG, e);
  11681. }
  11682. }
  11683. protected boolean CheckTime(String CheckT, int period) {
  11684. Calendar last = new GregorianCalendar();
  11685. String[] timedata = CheckT.split("[.]");
  11686. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  11687. last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
  11688. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  11689. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  11690. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  11691. last.add(Calendar.MINUTE, period);
  11692. Calendar checkCal = new GregorianCalendar();
  11693. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  11694. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  11695. return true;
  11696. return false;
  11697. }
  11698. }
  11699. class SendMSGToSVR extends Thread {
  11700. String sendmsg;
  11701. public SendMSGToSVR(String msg) {
  11702. sendmsg = msg;
  11703. }
  11704. public void run() {
  11705. Socket sock = null;
  11706. DataOutputStream outstream = null;
  11707. try {
  11708. // 신형 단지서버 사용 유무를 가져온다.
  11709. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11710. boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11711. wallpadDeviceSet.closeDB();
  11712. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11713. SVRIP = DBMGR.GetServerIP();
  11714. port = DBMGR.GetServerPort();
  11715. DBMGR.closeDB();
  11716. /////////////////////////////////////////////////////////////////////
  11717. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  11718. // 사용중일 경우 암호화 소켓을 생성한다.
  11719. /////////////////////////////////////////////////////////////////////
  11720. if (!bNewDanjiServer) {
  11721. sock = new Socket(SVRIP, port);
  11722. } else {
  11723. int setport = port + 1000;
  11724. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  11725. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  11726. sock = sslClientSocket.getSocket();
  11727. }
  11728. /////////////////////////////////////////////////////////////////////
  11729. if (sock != null) {
  11730. sock.setSoLinger(true, 1000);
  11731. outstream = new DataOutputStream(sock.getOutputStream());
  11732. byte[] outBF = sendmsg.getBytes("euc-kr");
  11733. outstream.write(outBF);
  11734. outstream.flush();
  11735. }
  11736. } catch (RuntimeException re) {
  11737. LogUtil.errorLogInfo("", TAG, re);
  11738. } catch (Exception e) {
  11739. //e.printStackTrace();
  11740. LogUtil.errorLogInfo("", TAG, e);
  11741. } finally {
  11742. if (outstream != null) {
  11743. try {
  11744. outstream.close();
  11745. } catch (IOException e) {
  11746. LogUtil.errorLogInfo("", TAG, e);
  11747. }
  11748. }
  11749. outstream = null;
  11750. if (sock != null) {
  11751. try {
  11752. sock.close();
  11753. } catch (IOException e) {
  11754. LogUtil.errorLogInfo("", TAG, e);
  11755. }
  11756. }
  11757. sock = null;
  11758. }
  11759. }
  11760. }
  11761. private void SendToServer(String msg) {
  11762. SendMSGToSVR msan = new SendMSGToSVR(msg);
  11763. msan.start();
  11764. }
  11765. boolean StatusBeatRequested = false;
  11766. private String MakeStatusReport() {
  11767. try {
  11768. String ServiceType = StatusBeatRequested ? "requested" : "notice";
  11769. StatusBeatRequested = false;
  11770. String RetData = XMLHeader + "<service type=\"" + ServiceType + "\" name=\"statusbeat\"> \r\n";
  11771. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  11772. String[] typeList = SettManager.GetTypeList();
  11773. if (typeList == null || typeList.length == 0) {
  11774. DefaultProcauscultateReq(SettManager);
  11775. typeList = SettManager.GetTypeList();
  11776. }
  11777. SettManager.closeDB();
  11778. String[] ControlList;
  11779. String Vender = "null";
  11780. String devid = "null";
  11781. String Model = "null";
  11782. String subunitcnt = "null";
  11783. String statusRate = "null";
  11784. String statusType = "null";
  11785. String message = "null";
  11786. int itemCNT = 0;
  11787. int totalGroup = 0;
  11788. int totalItem = 0;
  11789. String ControlDEVList;
  11790. String ContentList = " ";
  11791. if (typeList != null) {
  11792. for (int i = 0; i < typeList.length; i++) {
  11793. if (typeList[i].equals("ctrl_device")) {
  11794. SettManager = new WallpadDevStatus(getApplicationContext());
  11795. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  11796. SettManager.closeDB();
  11797. ControlDEVList = "";
  11798. if (ControlList != null) {
  11799. for (int k = 0; k < ControlList.length; k++) {
  11800. if (ControlList[k].equals("light")) {
  11801. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11802. int[] lightinfo = devSet.Get_Light_info();
  11803. devSet.closeDB();
  11804. if (lightinfo[0] == 1) {
  11805. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  11806. subunitcnt = String.valueOf(lightinfo[2]);
  11807. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  11808. devid = "0x11";
  11809. Vender = "null";
  11810. Model = "null";
  11811. if (lightCTR != null) {
  11812. lightCTR.TRInfo.GetTransactionList(0);
  11813. statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
  11814. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  11815. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11816. message = "null";
  11817. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11818. itemCNT++;
  11819. }
  11820. } else {
  11821. subunitcnt = String.valueOf(lightinfo[2]);
  11822. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  11823. if (MultiSW != null) {
  11824. MultiSW.Refresh((byte) 0xFF, false);
  11825. byte Bdevid = 0x51;
  11826. for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
  11827. devid = String.format("0x%02X", Bdevid + j);
  11828. Vender = "null";
  11829. Model = "null";
  11830. MultiSW.TRInfo.GetTransactionList(j);
  11831. statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
  11832. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  11833. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11834. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11835. itemCNT++;
  11836. }
  11837. }
  11838. }
  11839. } else {
  11840. Vender = "null";
  11841. devid = "null";
  11842. Model = "null";
  11843. subunitcnt = "null";
  11844. statusRate = "null";
  11845. message = "null";
  11846. }
  11847. } else if (ControlList[k].equals("thermostat")) {
  11848. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11849. int ret = devSet.Get_Temper_Info();
  11850. devSet.closeDB();
  11851. if (ret == 1) {
  11852. // 난방 종류를 얻어온다.
  11853. int HeatingKind = mWallPadAPI.GetHeatingKind();
  11854. HeatingV1API heatingV1API = null;
  11855. HeatingV2API heatingV2API = null;
  11856. // 종류별 API를 로딩한다.
  11857. if (HeatingKind == 1) {
  11858. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  11859. if (heatingV1API != null) {
  11860. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  11861. devid = "0x21";
  11862. Vender = "null";
  11863. Model = "null";
  11864. heatingV1API.TRInfo.GetTransactionList(0);
  11865. statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
  11866. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  11867. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11868. message = "null";
  11869. }
  11870. } else if (HeatingKind == 2) {
  11871. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  11872. if (heatingV2API != null) {
  11873. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  11874. devid = "0x28";
  11875. Vender = "null";
  11876. Model = "null";
  11877. heatingV2API.TRInfo.GetTransactionList(0);
  11878. statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
  11879. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  11880. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11881. message = "null";
  11882. }
  11883. } else {
  11884. subunitcnt = "null";
  11885. devid = "null";
  11886. Vender = "null";
  11887. Model = "null";
  11888. statusRate = "0/0";
  11889. statusType = "bad";
  11890. message = "null";
  11891. }
  11892. ControlDEVList += " <unit type=\"thermostat\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11893. itemCNT++;
  11894. } else {
  11895. }
  11896. } else if (ControlList[k].equals("gas")) {
  11897. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11898. if (devSet.Get_GAS_Info() == 1) {
  11899. //여기서 신우전자확인이 더 필요함
  11900. GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
  11901. CooktopAPI HybridCookTopCTR = null;
  11902. subunitcnt = "1";
  11903. devid = "0x31";
  11904. Vender = "null";
  11905. Model = "null";
  11906. if (mWallPadAPI.GetGasKind() == 2) {
  11907. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  11908. if (HybridCookTopCTR != null) {
  11909. HybridCookTopCTR.TRInfo.GetTransactionList(0);
  11910. statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
  11911. double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
  11912. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11913. message = "null";
  11914. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11915. itemCNT++;
  11916. }
  11917. } else {
  11918. GasCTR = mWallPadAPI.Get_GasController();
  11919. if (GasCTR != null) {
  11920. GasCTR.TRInfo.GetTransactionList(0);
  11921. statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
  11922. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  11923. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11924. message = "null";
  11925. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11926. itemCNT++;
  11927. }
  11928. }
  11929. } else {
  11930. }
  11931. devSet.closeDB();
  11932. } else if (ControlList[k].equals("doorlock")) {
  11933. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11934. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  11935. if (doorlockInfo[0] == 1) {
  11936. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  11937. subunitcnt = "1";
  11938. devid = "0x41";
  11939. Vender = "null";
  11940. Model = "null";
  11941. if (DoorCTR != null) {
  11942. DoorCTR.TRInfo.GetTransactionList(0);
  11943. statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
  11944. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  11945. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11946. message = "null";
  11947. ControlDEVList += " <unit type=\"doorlock\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11948. itemCNT++;
  11949. }
  11950. } else {
  11951. }
  11952. devSet.closeDB();
  11953. } else if (ControlList[k].equals("ventil")) {
  11954. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11955. int[] ventilInfo = devSet.Get_Ventil_Info();
  11956. if (ventilInfo[0] == 1) {
  11957. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  11958. subunitcnt = "1";
  11959. devid = "0x61";
  11960. Vender = "null";
  11961. Model = "null";
  11962. if (VentilCTR != null) {
  11963. VentilCTR.TRInfo.GetTransactionList(0);
  11964. statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
  11965. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  11966. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  11967. message = "null";
  11968. ControlDEVList += " <unit type=\"ventil\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  11969. itemCNT++;
  11970. }
  11971. } else {
  11972. }
  11973. devSet.closeDB();
  11974. } else if (ControlList[k].equals("aircon")) {
  11975. } else if (ControlList[k].equals("curtain")) {
  11976. }
  11977. }
  11978. if (itemCNT > 0) {
  11979. ContentList += "<group type=\"ctrl_device\" count=\"" + itemCNT + "\">\r\n";
  11980. ContentList += ControlDEVList;
  11981. ContentList += "</group>\r\n";
  11982. totalGroup++;
  11983. totalItem += itemCNT;
  11984. }
  11985. }
  11986. } else if (typeList[i].equals("talk_device")) {
  11987. SettManager = new WallpadDevStatus(getApplicationContext());
  11988. ControlList = SettManager.GetSettingGroupData("talk_device");
  11989. SettManager.closeDB();
  11990. itemCNT = 0;
  11991. ControlDEVList = "";
  11992. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  11993. if (testAPI != null)
  11994. testAPI.GetVersion();
  11995. if (ControlList != null) {
  11996. for (int k = 0; k < ControlList.length; k++) {
  11997. if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
  11998. 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";
  11999. itemCNT++;
  12000. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  12001. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  12002. } else if (ControlList[k].equals("bath_phone") && testAPI != null) {
  12003. 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";
  12004. itemCNT++;
  12005. } else if (ControlList[k].equals("subhome_dev")) {
  12006. }
  12007. }
  12008. if (itemCNT > 0) {
  12009. ContentList += "<group type=\"talk_device\" count=\"" + itemCNT + "\">\r\n";
  12010. ContentList += ControlDEVList;
  12011. ContentList += "</group>\r\n";
  12012. totalGroup++;
  12013. totalItem += itemCNT;
  12014. }
  12015. }
  12016. } else if (typeList[i].equals("sensor")) {
  12017. SettManager = new WallpadDevStatus(getApplicationContext());
  12018. ControlList = SettManager.GetSettingGroupData("sensor");
  12019. SettManager.closeDB();
  12020. itemCNT = 0;
  12021. ControlDEVList = "";
  12022. if (ControlList != null) {
  12023. for (int k = 0; k < ControlList.length; k++) {
  12024. if (ControlList[k].equals("magnetic")) {
  12025. WallPadInterface wpifc = new WallPadInterface();
  12026. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  12027. String SenStateCom;
  12028. String SenStateType;
  12029. if (MagSen == 1) {
  12030. SenStateCom = "1/1";
  12031. SenStateType = "";
  12032. } else {
  12033. SenStateCom = "0/1";
  12034. SenStateType = "perfect";
  12035. }
  12036. ControlDEVList += " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12037. itemCNT++;
  12038. } else if (ControlList[k].equals("bugout")) {
  12039. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12040. int sensor = devSet.Get_Sensor_Set();
  12041. devSet.closeDB();
  12042. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  12043. WallPadInterface wpifc = new WallPadInterface();
  12044. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12045. String SenStateCom;
  12046. String SenStateType;
  12047. if (outSen == 1) {
  12048. SenStateCom = "1/1";
  12049. SenStateType = "bad";
  12050. } else {
  12051. SenStateCom = "0/1";
  12052. SenStateType = "perfect";
  12053. }
  12054. ControlDEVList += " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12055. itemCNT++;
  12056. }
  12057. } else if (ControlList[k].equals("bugin")) {
  12058. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12059. int sensor = devSet.Get_Sensor_Set();
  12060. devSet.closeDB();
  12061. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  12062. WallPadInterface wpifc = new WallPadInterface();
  12063. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12064. String SenStateCom;
  12065. String SenStateType;
  12066. if (InSen == 1) {
  12067. SenStateCom = "1/1";
  12068. SenStateType = "bad";
  12069. } else {
  12070. SenStateCom = "0/1";
  12071. SenStateType = "perfect";
  12072. }
  12073. ControlDEVList += " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12074. itemCNT++;
  12075. }
  12076. } else if (ControlList[k].equals("fire")) {
  12077. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12078. } else if (ControlList[k].equals("gas")) {
  12079. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12080. }
  12081. }
  12082. if (itemCNT > 0) {
  12083. ContentList += "<group type=\"sensor\" count=\"" + itemCNT + "\">\r\n";
  12084. ContentList += ControlDEVList;
  12085. ContentList += "</group>\r\n";
  12086. totalGroup++;
  12087. totalItem += itemCNT;
  12088. }
  12089. }
  12090. } else if (typeList[i].equals("extended")) {
  12091. SettManager = new WallpadDevStatus(getApplicationContext());
  12092. ControlList = SettManager.GetSettingGroupData("extended");
  12093. SettManager.closeDB();
  12094. itemCNT = 0;
  12095. ControlDEVList = "";
  12096. if (ControlList != null) {
  12097. for (int k = 0; k < ControlList.length; k++) {
  12098. if (ControlList[k].equals("gateway")) {
  12099. } else if (ControlList[k].equals("handy")) {
  12100. } else if (ControlList[k].equals("smartswitch")) {
  12101. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12102. int[] BatchInfo = devSet.Get_BatchSW_Info();
  12103. devSet.closeDB();
  12104. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
  12105. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  12106. SmartSWCTR.TRInfo.GetTransactionList(0);
  12107. subunitcnt = "1";
  12108. statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
  12109. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  12110. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12111. message = "null";
  12112. ControlDEVList += " <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12113. itemCNT++;
  12114. } else {
  12115. }
  12116. } else if (ControlList[k].equals("energymeter")) {
  12117. }
  12118. }
  12119. if (itemCNT > 0) {
  12120. ContentList += "<group type=\"extended\" count=\"" + itemCNT + "\">\r\n";
  12121. ContentList += ControlDEVList;
  12122. ContentList += "</group>\r\n";
  12123. totalGroup++;
  12124. totalItem += itemCNT;
  12125. }
  12126. }
  12127. }
  12128. }
  12129. SettManager.closeDB();
  12130. ContentList += "</guidemap> \r\n";
  12131. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\"" + totalGroup + "\" device_cnt=\"" + totalItem + "\">\r\n";
  12132. RetData += ContentList;
  12133. String LogSet;
  12134. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  12135. RetData += LogSet;
  12136. try {
  12137. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  12138. String[] ResetData = WsDB.GetResetSchedule();
  12139. WsDB.closeDB();
  12140. if (!ResetData[0].equals("NONE")) {
  12141. int type = Integer.parseInt(ResetData[0]);
  12142. if (type == WallpadStatusData.RESET_MONTH)
  12143. LogSet = "<reset_info enable=\"true\" type=\"month\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12144. else if (type == WallpadStatusData.RESET_WEEK)
  12145. LogSet = "<reset_info enable=\"true\" type=\"week\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12146. else
  12147. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12148. } else
  12149. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12150. } catch (RuntimeException re) {
  12151. LogUtil.errorLogInfo("", TAG, re);
  12152. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12153. } catch (Exception e) {
  12154. //e.printStackTrace();
  12155. LogUtil.errorLogInfo("", TAG, e);
  12156. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12157. }
  12158. RetData += LogSet;
  12159. RetData += "</service>\r\n</imap>\r\n";
  12160. }
  12161. return RetData;
  12162. } catch (RuntimeException re) {
  12163. LogUtil.errorLogInfo("", TAG, re);
  12164. return null;
  12165. } catch (Exception e) {
  12166. //e.printStackTrace();
  12167. LogUtil.errorLogInfo("", TAG, e);
  12168. return null;
  12169. }
  12170. }
  12171. private String getKNXDeviceStatus(int device) {
  12172. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12173. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12174. String status = knxHeartbeat.getStatus();
  12175. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  12176. return status;
  12177. }
  12178. private String getKNXDeviceCause(int device) {
  12179. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12180. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12181. String cause = knxHeartbeat.getCause();
  12182. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  12183. return cause;
  12184. }
  12185. //mWallPadAPI
  12186. // private String TAG = "*yskim*";
  12187. //private IGW200dAPI iGW200dAPI = null;
  12188. /**
  12189. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12190. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12191. * 본 딜레이 코드를 임시로 적용한다.
  12192. */
  12193. @SuppressLint("HandlerLeak")
  12194. protected Handler IGW200APICheckHandler = new Handler() {
  12195. @SuppressLint("HandlerLeak")
  12196. @Override
  12197. public void handleMessage(Message msg) {
  12198. if (msg.what == 0) {
  12199. if (mWallPadAPI != null) {
  12200. Common.DebugLog("handleMessage what 0 ");
  12201. if (mWallPadAPI.Check_Connect())
  12202. IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12203. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12204. }
  12205. } else if (msg.what == 1) {
  12206. Common.DebugLog("handleMessage what 1 ");
  12207. setIGE200Interface();
  12208. }
  12209. }
  12210. };
  12211. public void setIGE200Interface() {
  12212. try {
  12213. Common.DebugLog("setIGE200Interface");
  12214. mIGW200 = new IGW200(this, mWallPadAPI);
  12215. } catch (RuntimeException re) {
  12216. LogUtil.errorLogInfo("", TAG, re);
  12217. } catch (Exception e) {
  12218. Log.e(TAG, "[Exception] setIGE200Interface()");
  12219. //e.printStackTrace();
  12220. LogUtil.errorLogInfo("", TAG, e);
  12221. }
  12222. }
  12223. /**
  12224. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12225. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12226. * 본 딜레이 코드를 임시로 적용한다.
  12227. */
  12228. @SuppressLint("HandlerLeak")
  12229. protected Handler IGW300APICheckHandler = new Handler() {
  12230. @SuppressLint("HandlerLeak")
  12231. @Override
  12232. public void handleMessage(Message msg) {
  12233. if (msg.what == 0) {
  12234. if (mWallPadAPI != null) {
  12235. Common.DebugLog("handleMessage what 0 ");
  12236. if (mWallPadAPI.Check_Connect())
  12237. IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12238. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12239. }
  12240. } else if (msg.what == 1) {
  12241. Common.DebugLog("handleMessage what 1 ");
  12242. setIGE300Interface();
  12243. }
  12244. }
  12245. };
  12246. public void setIGE300Interface() {
  12247. try {
  12248. Common.DebugLog("setIGE300Interface");
  12249. mIGW300 = new IGW300(this, mWallPadAPI);
  12250. } catch (RuntimeException re) {
  12251. LogUtil.errorLogInfo("", TAG, re);
  12252. } catch (Exception e) {
  12253. Log.e(TAG, "[Exception] setIGE300Interface()");
  12254. //e.printStackTrace();
  12255. LogUtil.errorLogInfo("", TAG, e);
  12256. }
  12257. }
  12258. // 외출모드 연동
  12259. private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
  12260. try {
  12261. bSmartSwitch485ComebackMode = false;
  12262. String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
  12263. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12264. String outLinkCtrl = wd.GetOutModeLinkDevice();
  12265. if (BedMode == true)
  12266. outLinkCtrl = wd.GetInBedLinkDevice();
  12267. wd.closeDB();
  12268. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  12269. if (WallpadUI == false) {
  12270. if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
  12271. {
  12272. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
  12273. CallElevatorBtn(false);
  12274. }
  12275. }
  12276. if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
  12277. {
  12278. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
  12279. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  12280. }
  12281. if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  12282. {
  12283. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
  12284. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  12285. }
  12286. if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  12287. {
  12288. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
  12289. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  12290. }
  12291. if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
  12292. {
  12293. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
  12294. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  12295. }
  12296. } catch (RuntimeException re) {
  12297. LogUtil.errorLogInfo("", TAG, re);
  12298. } catch (Exception e) {
  12299. Log.e("YSKIM", e.toString());
  12300. }
  12301. }
  12302. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  12303. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  12304. private boolean bSmartSwitch485ComebackMode = false;
  12305. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  12306. try {
  12307. if (bSmartSwitch485ComebackMode == true) return;
  12308. String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
  12309. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12310. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  12311. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  12312. wd.closeDB();
  12313. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  12314. // 일괄소등 해제
  12315. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
  12316. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  12317. }
  12318. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
  12319. // 환기동작
  12320. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
  12321. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  12322. }
  12323. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  12324. // 난방 외출모드 해제
  12325. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
  12326. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  12327. }
  12328. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  12329. // 웰컴조명 켜기
  12330. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
  12331. // 웰컴조명 Handler 실행
  12332. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  12333. }
  12334. } catch (RuntimeException re) {
  12335. LogUtil.errorLogInfo("", TAG, re);
  12336. } catch (Exception e) {
  12337. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  12338. //e.printStackTrace();
  12339. LogUtil.errorLogInfo("", TAG, e);
  12340. }
  12341. }
  12342. private Handler WelcomeLightHandler = new Handler() {
  12343. int LightOnCount = 0;
  12344. @Override
  12345. public void handleMessage(Message msg) {
  12346. if (msg.what == 0) {
  12347. try {
  12348. if (LightOnCount == 0) {
  12349. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  12350. }
  12351. // 일괄소등 해제이면
  12352. if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
  12353. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  12354. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  12355. } else {
  12356. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  12357. LightOnCount++;
  12358. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  12359. if (LightOnCount > 10) {
  12360. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  12361. LightOnCount = 0;
  12362. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  12363. }
  12364. }
  12365. } catch (RuntimeException re) {
  12366. LogUtil.errorLogInfo("", TAG, re);
  12367. } catch (Exception e1) {
  12368. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  12369. //e1.printStackTrace();
  12370. LogUtil.errorLogInfo("", TAG, e1);
  12371. }
  12372. } else if (msg.what == 1) {
  12373. try {
  12374. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  12375. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  12376. LightOnCount = 0;
  12377. } catch (RuntimeException re) {
  12378. LogUtil.errorLogInfo("", TAG, re);
  12379. } catch (Exception e1) {
  12380. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  12381. //e1.printStackTrace();
  12382. LogUtil.errorLogInfo("", TAG, e1);
  12383. }
  12384. } else if (msg.what == 2) {
  12385. // Do Nothing
  12386. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  12387. WelcomeLightHandler.removeMessages(0);
  12388. }
  12389. }
  12390. };
  12391. //방범 및 알람 상태 확인 Resume 시 처리
  12392. private void CheckMainStatus() {
  12393. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  12394. try {
  12395. final String packageName = "com.artncore.apps.ic_wallpad";
  12396. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  12397. //CallAppRun = getForegroundAPK().equals(packageName);
  12398. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  12399. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12400. int alarmstate = SetData.GetAlarmStatus();
  12401. SetData.closeDB();
  12402. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
  12403. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  12404. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
  12405. return;
  12406. } else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  12407. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  12408. int base = 7000;
  12409. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
  12410. int Menu_Start_Id = 0;
  12411. SetData = new WallpadStatusData(getApplicationContext());
  12412. int alarmtype = SetData.GetAlarmType();
  12413. SetData.closeDB();
  12414. switch (alarmtype) {
  12415. case WallpadStatusData.ALARM_ALERT:
  12416. Menu_Start_Id = Menu_Id_List[1];
  12417. break;
  12418. case WallpadStatusData.ALARM_EMM:
  12419. Menu_Start_Id = Menu_Id_List[0];
  12420. break;
  12421. case WallpadStatusData.ALARM_EVAC:
  12422. Menu_Start_Id = Menu_Id_List[3];
  12423. break;
  12424. case WallpadStatusData.ALARM_INVADE:
  12425. Menu_Start_Id = Menu_Id_List[2];
  12426. break;
  12427. case WallpadStatusData.ALARM_HEATING_LEAK:
  12428. Menu_Start_Id = Menu_Id_List[4];
  12429. break;
  12430. default:
  12431. Menu_Start_Id = Menu_Id_List[1];
  12432. break;
  12433. }
  12434. if (Menu_Start_Id > 0) {
  12435. /*
  12436. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  12437. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  12438. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  12439. * "RESUME"을 전달한다.
  12440. */
  12441. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12442. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12443. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12444. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  12445. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  12446. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12447. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12448. startActivity(newintent);
  12449. return;
  12450. }
  12451. } else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  12452. if (OutModeRunAppRun == true) {
  12453. Log.d(TAG, "already outmoderun app running !!!!");
  12454. return;
  12455. }
  12456. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12457. int sensor = devset.Get_Sensor_Set();
  12458. devset.closeDB();
  12459. int base = 7000;
  12460. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12461. int Menu_Start_Id = 0;
  12462. int Menu_Start_Option = 1;
  12463. if (sensor > 0) {
  12464. WallPadInterface wpifc = new WallPadInterface();
  12465. int[] SensorInfoDB;
  12466. int inSen = 0;
  12467. int outSen = 0;
  12468. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12469. if (SensorInfoDB[0] == 1) {
  12470. // 내부동체가 사용함이면 상태 검사
  12471. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12472. }
  12473. if (SensorInfoDB[1] == 1) {
  12474. // 외부동체가 사용함이면 상태 검사
  12475. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12476. }
  12477. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12478. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12479. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
  12480. ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  12481. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12482. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12483. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12484. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12485. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12486. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
  12487. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12488. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12489. startActivity(newintent);
  12490. return;
  12491. }
  12492. }
  12493. base = 8000;
  12494. Menu_Id_List = new int[]{base + 11};
  12495. Menu_Start_Id = base + 11;
  12496. Menu_Start_Option = -1;
  12497. Intent intent = new Intent(Intent.ACTION_MAIN);
  12498. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12499. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12500. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12501. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  12502. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12503. startActivity(intent);
  12504. } else if (alarmstate == WallpadStatusData.GUARD_IN) {
  12505. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12506. int sensor = devset.Get_Sensor_Set();
  12507. devset.closeDB();
  12508. int base = 7000;
  12509. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12510. int Menu_Start_Option = 1;
  12511. if (sensor > 0) {
  12512. WallPadInterface wpifc = new WallPadInterface();
  12513. int[] SensorInfoDB;
  12514. int outSen = 0;
  12515. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12516. if (SensorInfoDB[1] == 1) {
  12517. // 외부동체가 사용함이면 상태 검사
  12518. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12519. }
  12520. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12521. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
  12522. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12523. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12524. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12525. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12526. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12527. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  12528. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12529. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12530. startActivity(newintent);
  12531. return;
  12532. }
  12533. }
  12534. } else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  12535. WallPadInterface wpifc = new WallPadInterface();
  12536. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  12537. return;
  12538. } else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  12539. int base = 4000;
  12540. int Menu_Start_Id = 0;
  12541. int[] Menu_Id_List = new int[]{base + 11, base + 21};
  12542. Menu_Start_Id = base + 11;
  12543. Intent intent = new Intent(Intent.ACTION_MAIN);
  12544. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12545. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12546. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  12547. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  12548. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12549. startActivity(intent);
  12550. return;
  12551. }
  12552. } catch (RuntimeException re) {
  12553. LogUtil.errorLogInfo("", TAG, re);
  12554. } catch (Exception e) {
  12555. Log.e(TAG, "[Exception] CheckMainStatus()");
  12556. //e.printStackTrace();
  12557. LogUtil.errorLogInfo("", TAG, e);
  12558. }
  12559. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12560. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  12561. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12562. // {
  12563. // WallPadInterface wpifc = new WallPadInterface();
  12564. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  12565. //
  12566. // if (fleeSensor > 0)
  12567. // {
  12568. // int base = 7000;
  12569. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12570. // int Menu_Start_Option = 1;
  12571. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12572. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12573. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  12574. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12575. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  12576. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12577. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12578. // startActivity(newintent);
  12579. // devset.closeDB();
  12580. // return;
  12581. // }
  12582. // }
  12583. //
  12584. // StatusVal = devset.GetDeviceSetted("알람발생");
  12585. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12586. // {
  12587. // WallPadInterface wpifc = new WallPadInterface();
  12588. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  12589. //
  12590. // if (AlarmSensor > 0)
  12591. // {
  12592. // int base = 7000;
  12593. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12594. // int Menu_Start_Option = 1;
  12595. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12596. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12597. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  12598. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12599. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  12600. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12601. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12602. // startActivity(newintent);
  12603. // devset.closeDB();
  12604. // return;
  12605. // }
  12606. //
  12607. // }
  12608. // devset.closeDB();
  12609. }
  12610. /**
  12611. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  12612. *
  12613. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  12614. */
  12615. public boolean GetUseIlgalControlForAdmin() {
  12616. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12617. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  12618. devSet.closeDB();
  12619. boolean result = false;
  12620. if (MetringDB != null) {
  12621. try {
  12622. String devInfo = MetringDB[1];
  12623. devInfo = devInfo.replace('(', '_');
  12624. devInfo = devInfo.replace(':', '_');
  12625. devInfo = devInfo.replace(')', '_');
  12626. String[] MetringInfo = devInfo.split("_");
  12627. if (MetringInfo[3].equals("사용함") == true) {
  12628. result = true;
  12629. }
  12630. } catch (RuntimeException re) {
  12631. LogUtil.errorLogInfo("", TAG, re);
  12632. } catch (Exception e) {
  12633. //e.printStackTrace();
  12634. LogUtil.errorLogInfo("", TAG, e);
  12635. }
  12636. }
  12637. return result;
  12638. }
  12639. class SendLHGWCheck extends Thread {
  12640. private iMAP_hn_config_read m_HnGWConfigRead = null;
  12641. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  12642. private boolean retSucces = false;
  12643. private int retryCount = 0;
  12644. public SendLHGWCheck() {
  12645. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  12646. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  12647. retryCount = 0;
  12648. }
  12649. public void run() {
  12650. try {
  12651. try {
  12652. Thread.sleep(2000);
  12653. } catch (RuntimeException re) {
  12654. LogUtil.errorLogInfo("", TAG, re);
  12655. } catch (Exception e) {
  12656. LogUtil.errorLogInfo("", TAG, e);
  12657. }
  12658. for (int i = 0; i < 10; i++) {
  12659. m_HnGWConfigRead.DoWork();
  12660. m_HnGWConfigRead.SetRetCtr(new RetProci() {
  12661. @Override
  12662. public void ProcSuccess() {
  12663. retSucces = true;
  12664. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
  12665. }
  12666. @Override
  12667. public void ProcError() {
  12668. }
  12669. @Override
  12670. public void ProcDoing() {
  12671. // TODO Auto-generated method stub
  12672. }
  12673. });
  12674. if (retSucces == true)
  12675. break;
  12676. retryCount++;
  12677. try {
  12678. Thread.sleep(3000);
  12679. } catch (RuntimeException re) {
  12680. LogUtil.errorLogInfo("", TAG, re);
  12681. } catch (Exception e) {
  12682. LogUtil.errorLogInfo("", TAG, e);
  12683. }
  12684. }
  12685. m_HnGWEmptyMsg.DoWork();
  12686. m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
  12687. @Override
  12688. public void ProcSuccess() {
  12689. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
  12690. }
  12691. @Override
  12692. public void ProcError() {
  12693. Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
  12694. }
  12695. @Override
  12696. public void ProcDoing() {
  12697. // TODO Auto-generated method stub
  12698. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
  12699. }
  12700. });
  12701. } catch (RuntimeException re) {
  12702. LogUtil.errorLogInfo("", TAG, re);
  12703. } catch (Exception e) {
  12704. //e.printStackTrace();
  12705. LogUtil.errorLogInfo("", TAG, e);
  12706. }
  12707. }
  12708. }
  12709. //Reset Handler
  12710. private Handler mResetHandler = new Handler() {
  12711. @Override
  12712. public void handleMessage(Message msg) {
  12713. if (msg.what == 0) {
  12714. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  12715. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  12716. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  12717. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  12718. if (NowMainStatus == false) {
  12719. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12720. ResetCount = 1;
  12721. }
  12722. ResetCount++;
  12723. NowMainStatus = true;
  12724. if (ResetCount == 30) {
  12725. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12726. } else {
  12727. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12728. }
  12729. } else {
  12730. if (NowMainStatus == true) {
  12731. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12732. ResetCount = 1;
  12733. }
  12734. ResetCount++;
  12735. NowMainStatus = false;
  12736. if (ResetCount == 180) {
  12737. // 3분
  12738. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12739. } else {
  12740. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12741. }
  12742. }
  12743. } else if (msg.what == 1) {
  12744. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  12745. setDefaultLauncher();
  12746. Intent intent = new Intent();
  12747. intent.setAction(define.NOTIFY_ACNAME);
  12748. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12749. getApplicationContext().sendBroadcast(intent);
  12750. }
  12751. }
  12752. };
  12753. // 통화주체를 다루는 enum
  12754. public enum CALLOWNER {
  12755. NONE,
  12756. WALLPAD,
  12757. SUB_WALLPAD,
  12758. KITCHEN_TV,
  12759. BATH_PHONE,
  12760. BATH_TV,
  12761. UNIVERSAL_DEVICE,
  12762. ERROR;
  12763. }
  12764. public enum CALLEVENTTYPE {
  12765. RECEIVE_CALL, // 호출 수신 (호출 수신)
  12766. TRYING_CALL, // 호출 시도중 (호출 발신)
  12767. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  12768. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  12769. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  12770. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  12771. CONNECT_CALL, // 통화 시작
  12772. TERMINATE_CALL, // 통화 종료
  12773. CANCEL_CALL, // 호출 취소
  12774. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  12775. REJECT_CALL, // 호출수신 거절
  12776. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  12777. FORWARD_CALL, // 착신전환 설정
  12778. CALLERID, // Caller ID
  12779. TIMEOUT_1STCALL, // 1st Call Timeout
  12780. TIMEOUT_2NDCALL, // 2nd Call Timeout
  12781. TIMEOUT_3RDCALL, // 3rd Call Timeout
  12782. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  12783. DOOR_OPEN, // 문열림 설정
  12784. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  12785. PSTN_DTMF, // PSTN DTMF 수신
  12786. DETECT_STRANGER, // 거동수상자 발생
  12787. NONE;
  12788. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  12789. try {
  12790. if (value.equals(RECEIVE_CALL.toString())) {
  12791. return RECEIVE_CALL;
  12792. } else if (value.equals(TRYING_CALL.toString())) {
  12793. return TRYING_CALL;
  12794. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  12795. return RECEIVE_CALL_2ND;
  12796. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  12797. return RECEIVE_CALL_ACK;
  12798. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  12799. return REQUEST_FRONT_MONITORING;
  12800. } else if (value.equals(CONNECT_CALL.toString())) {
  12801. return CONNECT_CALL;
  12802. } else if (value.equals(TERMINATE_CALL.toString())) {
  12803. return TERMINATE_CALL;
  12804. } else if (value.equals(CANCEL_CALL.toString())) {
  12805. return CANCEL_CALL;
  12806. } else if (value.equals(REJECT_CALL.toString())) {
  12807. return REJECT_CALL;
  12808. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  12809. return REJECT_BUSY_CALL;
  12810. } else if (value.equals(FORWARD_CALL.toString())) {
  12811. return FORWARD_CALL;
  12812. } else if (value.equals(CALLERID.toString())) {
  12813. return CALLERID;
  12814. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  12815. return TIMEOUT_1STCALL;
  12816. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  12817. return TIMEOUT_2NDCALL;
  12818. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  12819. return TIMEOUT_3RDCALL;
  12820. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  12821. return MOIP_VIDEO_SET;
  12822. } else if (value.equals(DOOR_OPEN.toString())) {
  12823. return DOOR_OPEN;
  12824. } else if (value.equals(PSTN_RING.toString())) {
  12825. return PSTN_RING;
  12826. } else if (value.equals(PSTN_DTMF.toString())) {
  12827. return PSTN_DTMF;
  12828. } else if (value.equals(DETECT_STRANGER.toString())) {
  12829. return DETECT_STRANGER;
  12830. } else if (value.equals(NONE.toString())) {
  12831. return NONE;
  12832. } else {
  12833. return null;
  12834. }
  12835. } catch (RuntimeException re) {
  12836. LogUtil.errorLogInfo("", "", re);
  12837. return null;
  12838. } catch (Exception e) {
  12839. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  12840. //e.printStackTrace();
  12841. LogUtil.errorLogInfo("", "", e);
  12842. return null;
  12843. }
  12844. }
  12845. }
  12846. public enum CALLTYPE {
  12847. NONE,
  12848. FRONT,
  12849. RESIDENCE,
  12850. LOBBY,
  12851. GUARD,
  12852. PSTN,
  12853. IHUB,
  12854. ERROR,
  12855. }
  12856. public static class CALLTRIGGER {
  12857. public static String CALLOWNER = "CALLOWNER";
  12858. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  12859. public static String CALLTYPE = "CALLTYPE";
  12860. public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
  12861. public enum SOURCE {
  12862. USER,
  12863. CALL_RECEIVE,
  12864. SUBPHONE
  12865. }
  12866. public enum TYPE {
  12867. MENU,
  12868. FRONT,
  12869. LOBBY,
  12870. GUARD,
  12871. RESIDENCE,
  12872. PSTN
  12873. }
  12874. }
  12875. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  12876. int TAB_TALKFRONT = 130011;
  12877. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  12878. try {
  12879. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
  12880. if (!bWallPadCallLive) {
  12881. sendLCDBacklightStatus(true);
  12882. // 통화어플을 실행시킨다.
  12883. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12884. Common.SendAppFinishReqBR(getApplicationContext());
  12885. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12886. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12887. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  12888. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12889. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12890. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12891. mIntent.setComponent(mComponentName);
  12892. startActivity(mIntent);
  12893. playFrontBell(eCallOwner, eEventType, eCallType);
  12894. } else {
  12895. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  12896. // if (getUseSmartDoorCam()) {
  12897. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  12898. // }
  12899. }
  12900. } catch (RuntimeException re) {
  12901. LogUtil.errorLogInfo("", TAG, re);
  12902. } catch (Exception e) {
  12903. Log.e(TAG, "[Exception] runCallMainActivity()");
  12904. //e.printStackTrace();
  12905. LogUtil.errorLogInfo("", TAG, e);
  12906. }
  12907. }
  12908. //add KSJ 2021.11.02
  12909. public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
  12910. try {
  12911. if (!bWallPadCallLive || m_bWallpadCallScreen) {
  12912. // 통화어플을 실행시킨다.
  12913. Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
  12914. sendLCDBacklightStatus(true);
  12915. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  12916. int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
  12917. mWallpadStatusData.closeDB();
  12918. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  12919. Common.SendAppFinishReqBR(getApplicationContext());
  12920. if(m_bWallpadCallScreen)
  12921. Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  12922. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12923. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12924. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  12925. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12926. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12927. mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
  12928. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12929. mIntent.setComponent(mComponentName);
  12930. startActivity(mIntent);
  12931. Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  12932. } else {
  12933. Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
  12934. }
  12935. } catch (RuntimeException re) {
  12936. LogUtil.errorLogInfo("", TAG, re);
  12937. } catch (Exception e) {
  12938. Log.e(TAG, "[Exception] runCallMainActivity()");
  12939. //e.printStackTrace();
  12940. LogUtil.errorLogInfo("", TAG, e);
  12941. }
  12942. }
  12943. //~add KSJ
  12944. private String getTopActivity() {
  12945. try {
  12946. ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  12947. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  12948. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  12949. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  12950. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  12951. return mComponentName.getPackageName();
  12952. } catch (RuntimeException re) {
  12953. LogUtil.errorLogInfo("", TAG, re);
  12954. return null;
  12955. } catch (Exception e) {
  12956. Log.e(TAG, "[Exception] getTopActivity()");
  12957. //e.printStackTrace();
  12958. LogUtil.errorLogInfo("", TAG, e);
  12959. return null;
  12960. }
  12961. }
  12962. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  12963. try {
  12964. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  12965. WallPadInterface Wiface = new WallPadInterface();
  12966. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  12967. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  12968. }
  12969. } catch (RuntimeException re) {
  12970. LogUtil.errorLogInfo("", TAG, re);
  12971. } catch (Exception e) {
  12972. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  12973. //e.printStackTrace();
  12974. LogUtil.errorLogInfo("", TAG, e);
  12975. }
  12976. }
  12977. private class AfterTransactionTodoListData {
  12978. String Title;
  12979. int Valueint;
  12980. String ValueString;
  12981. private AfterTransactionTodoListData(String title, int valueint, String valueString) {
  12982. Title = title;
  12983. Valueint = valueint;
  12984. ValueString = valueString;
  12985. }
  12986. }
  12987. /**
  12988. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  12989. **/
  12990. public void SendGetParkingInfoIntent() {
  12991. Intent iIntent = new Intent();
  12992. iIntent.setAction(define.NOTIFY_ACNAME);
  12993. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  12994. this.sendBroadcast(iIntent);
  12995. }
  12996. /**
  12997. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  12998. **/
  12999. public Handler SendParkingInfoIntentAfter20min = new Handler() {
  13000. @SuppressLint("HandlerLeak")
  13001. @Override
  13002. public void handleMessage(Message msg) {
  13003. if (msg.what == 0) {
  13004. SendGetParkingInfoIntent();
  13005. }
  13006. }
  13007. };
  13008. /**
  13009. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  13010. **/
  13011. public Handler mWallPadOutmodeSleepHandler = new Handler() {
  13012. @SuppressLint("HandlerLeak")
  13013. @Override
  13014. public void handleMessage(Message msg) {
  13015. if (msg.what == 0) {
  13016. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  13017. }
  13018. }
  13019. };
  13020. // Handler
  13021. public final class HANDLERMSG {
  13022. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  13023. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  13024. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  13025. public final static int CALLAPP_FINISHING_END = 300;
  13026. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  13027. }
  13028. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  13029. public void handleMessage(Message msg) {
  13030. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  13031. switch (msg.what) {
  13032. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  13033. bGlobalScreenRun = true;
  13034. break;
  13035. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  13036. bGlobalScreenRun = false;
  13037. break;
  13038. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  13039. break;
  13040. case HANDLERMSG.CALLAPP_FINISHING_END:
  13041. // bBlockCallEvent = false;
  13042. break;
  13043. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  13044. int time = Sound().PlayMent(SND.call.DINGDONG);
  13045. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  13046. if (time < 0) time = 2088;
  13047. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  13048. break;
  13049. default:
  13050. Log.v(TAG, "iMAPServerHandler : " + msg.what);
  13051. break;
  13052. }
  13053. }
  13054. };
  13055. public void sendHandlerMsg(int what, int arg1, int arg2) {
  13056. try {
  13057. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  13058. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13059. HandleMsg.what = what;
  13060. HandleMsg.arg1 = arg1;
  13061. HandleMsg.arg2 = arg2;
  13062. iMAPServerHandler.sendMessage(HandleMsg);
  13063. } catch (RuntimeException re) {
  13064. LogUtil.errorLogInfo("", TAG, re);
  13065. } catch (Exception e) {
  13066. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  13067. //e.printStackTrace();
  13068. LogUtil.errorLogInfo("", TAG, e);
  13069. }
  13070. }
  13071. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  13072. try {
  13073. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  13074. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13075. HandleMsg.what = what;
  13076. HandleMsg.arg1 = arg1;
  13077. HandleMsg.arg2 = arg2;
  13078. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  13079. } catch (RuntimeException re) {
  13080. LogUtil.errorLogInfo("", TAG, re);
  13081. } catch (Exception e) {
  13082. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  13083. //e.printStackTrace();
  13084. LogUtil.errorLogInfo("", TAG, e);
  13085. }
  13086. }
  13087. int mSensitivity = 0, mDuration = 0;
  13088. int MIN_SENSOR_SENSITIVITY = 1;
  13089. int MAX_SENSOR_SENSITIVITY = 5;
  13090. int MIN_SENSOR_DURATION = 30;
  13091. int MAX_SENSOR_DURATION = 250;
  13092. int DEFAULT_SENSOR_SENSITIVITY = 3;
  13093. int DEFAULT_SENSOR_DURATION = 60;
  13094. private final int COMPONENT_USE = 1;
  13095. /**
  13096. * 스마트현관카메라 사용여부 판별
  13097. */
  13098. private boolean getUseSmartDoorCam() {
  13099. try {
  13100. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13101. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13102. mWallpadDeviceSet.closeDB();
  13103. if (nFrontCam[0] == COMPONENT_USE) {
  13104. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  13105. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  13106. return true;
  13107. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  13108. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  13109. return true;
  13110. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13111. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  13112. return true;
  13113. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  13114. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  13115. return true;
  13116. } else {
  13117. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  13118. return false;
  13119. }
  13120. } else {
  13121. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  13122. return false;
  13123. }
  13124. } catch (RuntimeException re) {
  13125. LogUtil.errorLogInfo("", TAG, re);
  13126. return false;
  13127. } catch (Exception e) {
  13128. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  13129. //e.printStackTrace();
  13130. LogUtil.errorLogInfo("", TAG, e);
  13131. return false;
  13132. }
  13133. }
  13134. private int getSmartDoorCamType() {
  13135. try {
  13136. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13137. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13138. mWallpadDeviceSet.closeDB();
  13139. if (nFrontCam[0] == COMPONENT_USE) {
  13140. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13141. return nFrontCam[1];
  13142. }
  13143. }
  13144. } catch (RuntimeException re) {
  13145. LogUtil.errorLogInfo("", TAG, re);
  13146. } catch (Exception e) {
  13147. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  13148. //e.printStackTrace();
  13149. LogUtil.errorLogInfo("", TAG, e);
  13150. }
  13151. return -1;
  13152. }
  13153. /**
  13154. * 방문객원격통화 솔루션 사용여부 판별
  13155. */
  13156. private boolean getRemoteCallUseInfo() {
  13157. try {
  13158. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13159. if (mWallpadDeviceSet != null) {
  13160. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  13161. if (astrRemoteCall != null) {
  13162. if (astrRemoteCall[1].contains("사용함")) return true;
  13163. } else {
  13164. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  13165. }
  13166. }
  13167. mWallpadDeviceSet.closeDB();
  13168. } catch (RuntimeException re) {
  13169. LogUtil.errorLogInfo("", TAG, re);
  13170. } catch (Exception e) {
  13171. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  13172. //e.printStackTrace();
  13173. LogUtil.errorLogInfo("", TAG, e);
  13174. }
  13175. return false;
  13176. }
  13177. /*
  13178. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  13179. */
  13180. private RealTimeMeterAPI mRealTimeMeterAPI;
  13181. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  13182. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  13183. public Thread saveRealmeterDataThread = null;
  13184. private void startRealtimemeterInfo() {
  13185. try {
  13186. // 영업샘플 모드 판단
  13187. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13188. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  13189. } else {
  13190. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  13191. // 실시간 검침기 사용유무 판단
  13192. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13193. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13194. mWallpadDeviceSet.closeDB();
  13195. boolean bRealtimemeterUsage = false;
  13196. int nRealtimemeterCntDB = -99;
  13197. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  13198. // 실시간 검침 사용함
  13199. bRealtimemeterUsage = true;
  13200. nRealtimemeterCntDB = naRealtimemtInfo[1];
  13201. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  13202. } else {
  13203. // 실시간 검침 사용하지 않음
  13204. bRealtimemeterUsage = false;
  13205. }
  13206. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
  13207. }
  13208. } catch (RuntimeException re) {
  13209. LogUtil.errorLogInfo("", TAG, re);
  13210. } catch (Exception e) {
  13211. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  13212. //e.printStackTrace();
  13213. LogUtil.errorLogInfo("", TAG, e);
  13214. }
  13215. }
  13216. private void startSmartIoTCamInfo() {
  13217. try {
  13218. // 영업샘플 모드 판단
  13219. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13220. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  13221. } else {
  13222. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  13223. if (getUseSmartDoorCam()) {
  13224. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  13225. } else {
  13226. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  13227. }
  13228. }
  13229. } catch (RuntimeException re) {
  13230. LogUtil.errorLogInfo("", TAG, re);
  13231. } catch (Exception e) {
  13232. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  13233. //e.printStackTrace();
  13234. LogUtil.errorLogInfo("", TAG, e);
  13235. }
  13236. }
  13237. private void startDistributionPanel() {
  13238. try {
  13239. // 영업샘플 모드 판단
  13240. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  13241. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  13242. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  13243. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  13244. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13245. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  13246. mWallpadDeviceSet.closeDB();
  13247. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
  13248. initSmartDistributionPanelHandler.sendEmptyMessage(0);
  13249. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
  13250. initKNXDistributionPanelHandler.sendEmptyMessage(0);
  13251. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  13252. } else {
  13253. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  13254. }
  13255. } catch (RuntimeException re) {
  13256. LogUtil.errorLogInfo("", TAG, re);
  13257. } catch (Exception e) {
  13258. Log.e(TAG, "[Exception] startDistributionPanel()");
  13259. //e.printStackTrace();
  13260. LogUtil.errorLogInfo("", TAG, e);
  13261. }
  13262. }
  13263. // =================================================================================================
  13264. // [[ Device ]] region
  13265. // =================================================================================================
  13266. /**
  13267. * 디바이스 API 를 Load 한다.
  13268. *
  13269. * @param wpapi - 생성시 전달받은 WallPadAPI
  13270. * @return (int) - >=0 : 성공, <0 : 실패
  13271. */
  13272. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  13273. // 1. Mode Check
  13274. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13275. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  13276. return -1;
  13277. }
  13278. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  13279. // 2. wpapi Check
  13280. if (wpapi == null) {
  13281. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  13282. return -2;
  13283. }
  13284. // 3. Load API
  13285. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  13286. try {
  13287. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  13288. } catch (RuntimeException re) {
  13289. LogUtil.errorLogInfo("", TAG, re);
  13290. return -100;
  13291. } catch (Exception e) {
  13292. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  13293. //e.printStackTrace();
  13294. LogUtil.errorLogInfo("", TAG, e);
  13295. return -100;
  13296. }
  13297. if (mRealTimeMeterAPI == null) {
  13298. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  13299. return -4;
  13300. }
  13301. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  13302. return 0;
  13303. }
  13304. /**
  13305. * 제어기 상태를 가져온다.
  13306. *
  13307. * @param real - (boolean) true : 실시간 , false : 가장최근
  13308. * @return (int) - >=0 : 성공, <0 : 실패
  13309. */
  13310. @SuppressWarnings("unused")
  13311. private int updateRealtimemeterData(boolean real) {
  13312. try {
  13313. // 1. Api Load Check
  13314. if (mRealTimeMeterAPI == null) {
  13315. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  13316. return -1;
  13317. }
  13318. // 2. reflash
  13319. try {
  13320. int ret = mRealTimeMeterAPI.Refresh(real);
  13321. if (ret < 0) {
  13322. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  13323. return -2;
  13324. }
  13325. } catch (RuntimeException re) {
  13326. LogUtil.errorLogInfo("", TAG, re);
  13327. return -100;
  13328. } catch (Exception e) {
  13329. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  13330. //e.printStackTrace();
  13331. LogUtil.errorLogInfo("", TAG, e);
  13332. return -100;
  13333. }
  13334. // 3. Range Check
  13335. if (mRealTimeMeterAPI.data == null) {
  13336. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  13337. return -9;
  13338. }
  13339. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  13340. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  13341. return -10;
  13342. }
  13343. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  13344. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  13345. return -11;
  13346. }
  13347. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  13348. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  13349. return -12;
  13350. }
  13351. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  13352. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  13353. return -13;
  13354. }
  13355. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  13356. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  13357. return -14;
  13358. }
  13359. // 4. Data Copy
  13360. mRealTimeMeterData = mRealTimeMeterAPI.data;
  13361. // 5. Debug msg
  13362. if (DEBUG_REALMETER_DATA_LOG_ON) {
  13363. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  13364. Log.i(TAG, "[updateRealtimemeterData] - OK");
  13365. }
  13366. return 0;
  13367. } catch (RuntimeException re) {
  13368. LogUtil.errorLogInfo("", TAG, re);
  13369. return -99;
  13370. } catch (Exception e) {
  13371. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  13372. //e.printStackTrace();
  13373. LogUtil.errorLogInfo("", TAG, e);
  13374. return -99;
  13375. }
  13376. }
  13377. /**
  13378. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  13379. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  13380. * 본 딜레이 코드를 임시로 적용한다.
  13381. */
  13382. @SuppressLint("HandlerLeak")
  13383. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  13384. @SuppressLint("HandlerLeak")
  13385. @Override
  13386. public void handleMessage(Message msg) {
  13387. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  13388. if (msg.what == 0) {
  13389. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  13390. if (updateRealtimemeterData(false) == 0) {
  13391. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13392. } else {
  13393. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13394. }
  13395. } else {
  13396. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  13397. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13398. }
  13399. } else if (msg.what == 1) {
  13400. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  13401. if (mRealTimeMeterAPI != null) {
  13402. // Device_BrRegistration(true);
  13403. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13404. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13405. mWallpadDeviceSet.closeDB();
  13406. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  13407. saveRealmeterDataThread = new saveRealmeterData();
  13408. saveRealmeterDataThread.start();
  13409. }
  13410. // RemoveUsedData();
  13411. // ShowUsedDataGraph();
  13412. }
  13413. }
  13414. }
  13415. };
  13416. protected Handler initSmartDistributionPanelHandler = new Handler() {
  13417. @SuppressLint("HandlerLeak")
  13418. @Override
  13419. public void handleMessage(Message msg) {
  13420. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  13421. if (msg.what == 0) {
  13422. if (mWallPadAPI.Check_Connect())
  13423. initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13424. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13425. } else if (msg.what == 1) {
  13426. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  13427. mSdbAPI = mWallPadAPI.Get_SdbController();
  13428. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  13429. mSdb_LivingRoomLightAPI.Refresh();
  13430. }
  13431. }
  13432. };
  13433. protected Handler initKNXDistributionPanelHandler = new Handler() {
  13434. @SuppressLint("HandlerLeak")
  13435. @Override
  13436. public void handleMessage(Message msg) {
  13437. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  13438. if (msg.what == 0) {
  13439. if (mWallPadAPI.Check_Connect())
  13440. initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13441. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13442. } else if (msg.what == 1) {
  13443. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  13444. mKnxAPI = mWallPadAPI.Get_KnxController();
  13445. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  13446. mKnx_LivingRoomLightAPI.Refresh();
  13447. }
  13448. }
  13449. };
  13450. protected Handler initSmartIoTFunctionHandler = new Handler() {
  13451. @SuppressLint("HandlerLeak")
  13452. @Override
  13453. public void handleMessage(Message msg) {
  13454. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  13455. if (msg.what == 0) {
  13456. if (mWallPadAPI.Check_Connect())
  13457. initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13458. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  13459. } else if (msg.what == 1) {
  13460. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  13461. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  13462. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
  13463. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
  13464. Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
  13465. // 거동수상자 녹화를 위한 자동 On 기능 비활성화
  13466. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  13467. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  13468. }
  13469. }
  13470. };
  13471. // 스마트현관카메라 MODE 제어
  13472. private void ctrlSmartIOTCamStatusMode(byte mode) {
  13473. try {
  13474. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  13475. if (mSmartKeyRfDoorAPI != null) {
  13476. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  13477. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  13478. } else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  13479. } catch (RuntimeException re) {
  13480. LogUtil.errorLogInfo("", TAG, re);
  13481. } catch (Exception e) {
  13482. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  13483. //e.printStackTrace();
  13484. LogUtil.errorLogInfo("", TAG, e);
  13485. }
  13486. }
  13487. // 스마트현관카메라 LED 상태 제어
  13488. private void ctrlSmartIOTCamLEDMode(byte mode) {
  13489. try {
  13490. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  13491. if (mSmartKeyRfDoorAPI != null) {
  13492. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  13493. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  13494. } else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  13495. } catch (RuntimeException re) {
  13496. LogUtil.errorLogInfo("", TAG, re);
  13497. } catch (Exception e) {
  13498. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  13499. //e.printStackTrace();
  13500. LogUtil.errorLogInfo("", TAG, e);
  13501. }
  13502. }
  13503. // 현관카메라 거동수상자 감지시간
  13504. private byte getSmartDoorCamDuration() {
  13505. try {
  13506. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
  13507. byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
  13508. wallpadDeviceSet.closeDB();
  13509. Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
  13510. return duration;
  13511. } catch (RuntimeException re) {
  13512. LogUtil.errorLogInfo("", TAG, re);
  13513. } catch (Exception e) {
  13514. Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
  13515. //e.printStackTrace();
  13516. LogUtil.errorLogInfo("", TAG, e);
  13517. }
  13518. return (byte) 0x05;
  13519. }
  13520. // =================================================================================================
  13521. // [[ Thread ]] region
  13522. // =================================================================================================
  13523. /**
  13524. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  13525. * 10분에 한번씩 저장
  13526. */
  13527. @SuppressLint("UseValueOf")
  13528. class saveRealmeterData extends Thread {
  13529. @Override
  13530. public void run() {
  13531. super.run();
  13532. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  13533. int ret;
  13534. wallpaddbmgr WallpadDBMGRforThread = null;
  13535. while (true) {
  13536. try {
  13537. Thread.sleep(1000 * 60 * 3); //3분마다
  13538. if (mRealTimeMeterAPI != null) {
  13539. ret = mRealTimeMeterAPI.Refresh(false);
  13540. if (ret == 0) {
  13541. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  13542. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
  13543. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  13544. WallpadDBMGRforThread.InsertRealTimeMeterData(
  13545. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  13546. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  13547. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  13548. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  13549. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  13550. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  13551. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  13552. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  13553. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  13554. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  13555. );
  13556. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  13557. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
  13558. if (tempInt > 6000) {
  13559. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  13560. }
  13561. WallpadDBMGRforThread.closeDB();
  13562. } else {
  13563. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  13564. }
  13565. } else {
  13566. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  13567. }
  13568. } catch (InterruptedException e1) {
  13569. // TODO Auto-generated catch block
  13570. if (WallpadDBMGRforThread != null) {
  13571. WallpadDBMGRforThread.closeDB();
  13572. }
  13573. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  13574. //e1.printStackTrace();
  13575. LogUtil.errorLogInfo("", TAG, e1);
  13576. }
  13577. }
  13578. }
  13579. }
  13580. /**
  13581. * 단지서버 2.0 사용여부
  13582. *
  13583. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  13584. **/
  13585. public boolean NewServerUse() {
  13586. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  13587. if (SetData != null) {
  13588. String serverVesionInfo = SetData.GetServerVer();
  13589. SetData.closeDB();
  13590. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  13591. return true;
  13592. }
  13593. }
  13594. return false;
  13595. }
  13596. /**
  13597. * 단지서버2.0 적용시에만 사용한다.
  13598. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  13599. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  13600. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  13601. **/
  13602. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  13603. String REMOTETYPE_SVR2WEB = "danji_web_control";
  13604. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  13605. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  13606. try {
  13607. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13608. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13609. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13610. NodeList mNodeList = doc.getElementsByTagName("device_info");
  13611. Node mNode = mNodeList.item(0);
  13612. if (mNode != null) {
  13613. String alias = "null", twinid = "null";
  13614. NamedNodeMap attrsParam = mNode.getAttributes();
  13615. for (int j = 0; j < attrsParam.getLength(); j++) {
  13616. Node attr = attrsParam.item(j);
  13617. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13618. alias = attr.getNodeValue();
  13619. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13620. twinid = attr.getNodeValue();
  13621. }
  13622. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13623. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13624. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  13625. return MOBILE_USER_AUTH_PASSED;
  13626. }
  13627. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13628. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13629. mWallpadMobileDeviceData.closeDB();
  13630. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13631. else {
  13632. //Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  13633. //닫은 DB에 접근하여서 수정.
  13634. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + nCheckResult + "]");
  13635. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13636. return strReplyMsg;
  13637. }
  13638. } else {
  13639. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13640. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13641. return strReplyMsg;
  13642. }
  13643. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13644. NodeList mNodeList = doc.getElementsByTagName("password_info");
  13645. Node mNode = mNodeList.item(0);
  13646. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13647. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13648. mWallpadStatusData.closeDB();
  13649. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
  13650. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13651. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13652. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13653. return strReplyMsg;
  13654. }
  13655. if (mNode != null) {
  13656. String strReceivedPW = "000000";
  13657. NamedNodeMap attrsParam = mNode.getAttributes();
  13658. for (int j = 0; j < attrsParam.getLength(); j++) {
  13659. Node attr = attrsParam.item(j);
  13660. if (attr.getNodeName().equalsIgnoreCase("password"))
  13661. strReceivedPW = attr.getNodeValue();
  13662. }
  13663. if (!checkPWValidation(strReceivedPW)) {
  13664. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13665. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13666. return strReplyMsg;
  13667. }
  13668. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13669. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13670. return WEB_USER_AUTH_PASSED;
  13671. } else {
  13672. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13673. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13674. return strReplyMsg;
  13675. }
  13676. } else {
  13677. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13678. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13679. return strReplyMsg;
  13680. }
  13681. } else {
  13682. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13683. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13684. return strReplyMsg;
  13685. }
  13686. } catch (RuntimeException re) {
  13687. LogUtil.errorLogInfo("", TAG, re);
  13688. return null;
  13689. } catch (Exception e) {
  13690. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  13691. //e.printStackTrace();
  13692. LogUtil.errorLogInfo("", TAG, e);
  13693. return null;
  13694. }
  13695. }
  13696. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  13697. try {
  13698. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13699. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13700. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13701. NodeList mNodeList = ele.getElementsByTagName("device_info");
  13702. Node mNode = mNodeList.item(0);
  13703. if (mNode != null) {
  13704. String alias = "null", twinid = "null";
  13705. NamedNodeMap attrsParam = mNode.getAttributes();
  13706. for (int j = 0; j < attrsParam.getLength(); j++) {
  13707. Node attr = attrsParam.item(j);
  13708. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13709. alias = attr.getNodeValue();
  13710. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13711. twinid = attr.getNodeValue();
  13712. }
  13713. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13714. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13715. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  13716. return MOBILE_USER_AUTH_PASSED;
  13717. }
  13718. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13719. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13720. mWallpadMobileDeviceData.closeDB();
  13721. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13722. else {
  13723. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  13724. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  13725. return strReplyMsg;
  13726. }
  13727. } else {
  13728. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13729. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13730. return strReplyMsg;
  13731. }
  13732. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13733. NodeList mNodeList = ele.getElementsByTagName("password_info");
  13734. Node mNode = mNodeList.item(0);
  13735. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13736. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13737. mWallpadStatusData.closeDB();
  13738. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13739. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13740. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13741. return strReplyMsg;
  13742. }
  13743. if (mNode != null) {
  13744. String strReceivedPW = "000000";
  13745. NamedNodeMap attrsParam = mNode.getAttributes();
  13746. for (int j = 0; j < attrsParam.getLength(); j++) {
  13747. Node attr = attrsParam.item(j);
  13748. if (attr.getNodeName().equalsIgnoreCase("password"))
  13749. strReceivedPW = attr.getNodeValue();
  13750. }
  13751. if (!checkPWValidation(strReceivedPW)) {
  13752. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13753. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13754. return strReplyMsg;
  13755. }
  13756. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13757. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13758. return WEB_USER_AUTH_PASSED;
  13759. } else {
  13760. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13761. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13762. return strReplyMsg;
  13763. }
  13764. } else {
  13765. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13766. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13767. return strReplyMsg;
  13768. }
  13769. } else {
  13770. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13771. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13772. return strReplyMsg;
  13773. }
  13774. } catch (RuntimeException re) {
  13775. LogUtil.errorLogInfo("", TAG, re);
  13776. return null;
  13777. } catch (Exception e) {
  13778. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  13779. //e.printStackTrace();
  13780. LogUtil.errorLogInfo("", TAG, e);
  13781. return null;
  13782. }
  13783. }
  13784. String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
  13785. private boolean checkPWValidation(String strPW) {
  13786. try {
  13787. // null 확인
  13788. if (strPW == null) {
  13789. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  13790. return false;
  13791. }
  13792. // 입력된 비밀번호 길이 확인
  13793. if (strPW.length() != 6) {
  13794. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  13795. return false;
  13796. }
  13797. // 사전 금지된 비밀번호 확인
  13798. for (int i = 0; i < astrPreventedPWs.length; i++) {
  13799. if (strPW.contains(astrPreventedPWs[i])) {
  13800. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  13801. return false;
  13802. }
  13803. }
  13804. /*// 연속된 비밀번호 확인
  13805. int nSerialNoCnt = 0;
  13806. int nCompareNo = 0;
  13807. int[] naPW = new int[strPW.length()];
  13808. for (int i = 0; i < naPW.length; i++)
  13809. {
  13810. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  13811. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  13812. if (i ==0) {
  13813. nCompareNo = naPW[i];
  13814. nCompareNo++;
  13815. }
  13816. else if (0 < i && i < 6) {
  13817. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  13818. nCompareNo++;
  13819. }
  13820. else {
  13821. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  13822. }
  13823. }
  13824. if (nSerialNoCnt > 3) {
  13825. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  13826. return false;
  13827. }*/
  13828. // 동일한 번호 5회이상 입력 확인
  13829. int nSameNoCnt = 0;
  13830. for (int i = 0; i < strPW.length() - 1; i++) {
  13831. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  13832. nSameNoCnt++;
  13833. }
  13834. }
  13835. if (nSameNoCnt > 4) {
  13836. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  13837. return false;
  13838. }
  13839. // 동, 호정보 확인
  13840. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  13841. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  13842. DBMGR.closeDB();
  13843. String strDong = addr.Dong;
  13844. String strHo = addr.Ho;
  13845. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  13846. if (strPW.substring(0, 4).contains(strDong)) {
  13847. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  13848. return false;
  13849. }
  13850. if (strPW.substring(0, 4).contains(strHo)) {
  13851. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  13852. return false;
  13853. }
  13854. return true;
  13855. } catch (RuntimeException re) {
  13856. LogUtil.errorLogInfo("", TAG, re);
  13857. return false;
  13858. } catch (Exception e) {
  13859. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  13860. //e.printStackTrace();
  13861. LogUtil.errorLogInfo("", TAG, e);
  13862. return false;
  13863. }
  13864. }
  13865. public String iCMDProcOnePass(Element ele) {
  13866. String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
  13867. String[] strDeviceInfo = {"null", "null"}; // alias, twinid
  13868. String strAction = "null", strTargetLobbyIP = "null";
  13869. try {
  13870. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  13871. String retStr = CheckiCMDProc("remote_access_onepass");
  13872. if (retStr != null)
  13873. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13874. // 단지서버 2.0 사용여부 확인
  13875. if (!NewServerUse()) {
  13876. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13877. }
  13878. // 메시지 송신지 구분
  13879. NodeList items = ele.getElementsByTagName("target");
  13880. Node item = items.item(0);
  13881. if (item != null) {
  13882. NamedNodeMap attrs = item.getAttributes();
  13883. for (int j = 0; j < attrs.getLength(); j++) {
  13884. Node attr = attrs.item(j);
  13885. if (attr.getNodeName().equalsIgnoreCase("name"))
  13886. strTarget[0] = attr.getNodeValue();
  13887. else if (attr.getNodeName().equalsIgnoreCase("id"))
  13888. strTarget[1] = attr.getNodeValue();
  13889. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  13890. strTarget[2] = attr.getNodeValue();
  13891. }
  13892. }
  13893. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  13894. if (NewServerUse()) {
  13895. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  13896. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  13897. if (ServerCheckResult.contains("fail"))
  13898. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13899. else if (ServerCheckResult.contains("deny"))
  13900. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13901. else if (ServerCheckResult.contains("none"))
  13902. return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  13903. else
  13904. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13905. }
  13906. }
  13907. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  13908. Node itemDeviceParam = itemsDeviceParam.item(0);
  13909. if (itemDeviceParam != null) {
  13910. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  13911. for (int j = 0; j < attrsParam.getLength(); j++) {
  13912. Node attr = attrsParam.item(j);
  13913. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13914. strDeviceInfo[0] = attr.getNodeValue();
  13915. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13916. strDeviceInfo[1] = attr.getNodeValue();
  13917. }
  13918. } else {
  13919. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13920. }
  13921. // 명령어 구분
  13922. NodeList itemsaction = ele.getElementsByTagName("action");
  13923. Node itemaction = itemsaction.item(0);
  13924. Node text = itemaction.getFirstChild();
  13925. strAction = text.getNodeValue();
  13926. strAction = trimquotation(strAction);
  13927. // 문열림 타겟 로비폰 IP
  13928. NodeList itemsParam = ele.getElementsByTagName("params");
  13929. Node itemParam = itemsParam.item(0);
  13930. if (itemParam != null) {
  13931. NamedNodeMap attrsParam = itemParam.getAttributes();
  13932. for (int j = 0; j < attrsParam.getLength(); j++) {
  13933. Node attr = attrsParam.item(j);
  13934. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  13935. strTargetLobbyIP = attr.getNodeValue();
  13936. }
  13937. }
  13938. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  13939. if (strAction.equalsIgnoreCase("authorize_request")) {
  13940. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  13941. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  13942. } else {
  13943. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13944. }
  13945. } catch (RuntimeException re) {
  13946. LogUtil.errorLogInfo("", TAG, re);
  13947. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13948. } catch (Exception e) {
  13949. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  13950. //e.printStackTrace();
  13951. LogUtil.errorLogInfo("", TAG, e);
  13952. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13953. }
  13954. }
  13955. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  13956. try {
  13957. String strReplyXml = XMLHeader;
  13958. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  13959. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  13960. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  13961. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  13962. strReplyXml += " </service>\n";
  13963. strReplyXml += "</imap>";
  13964. return strReplyXml;
  13965. } catch (RuntimeException re) {
  13966. LogUtil.errorLogInfo("", TAG, re);
  13967. return "ERROR";
  13968. } catch (Exception e) {
  13969. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  13970. //e.printStackTrace();
  13971. LogUtil.errorLogInfo("", TAG, e);
  13972. return "ERROR";
  13973. }
  13974. }
  13975. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  13976. try {
  13977. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
  13978. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  13979. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  13980. miMAPLobbyOnePass.SetRetCtr(new RetProci() {
  13981. @Override
  13982. public void ProcSuccess() {
  13983. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  13984. }
  13985. @Override
  13986. public void ProcError() {
  13987. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  13988. }
  13989. @Override
  13990. public void ProcDoing() {
  13991. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  13992. }
  13993. });
  13994. } catch (RuntimeException re) {
  13995. LogUtil.errorLogInfo("", TAG, re);
  13996. } catch (Exception e) {
  13997. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  13998. //e.printStackTrace();
  13999. LogUtil.errorLogInfo("", TAG, e);
  14000. }
  14001. }
  14002. public String iCMDProcResidentSafety(Element ele) {
  14003. try {
  14004. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  14005. String retStr = CheckiCMDProc("check_resident_safety");
  14006. if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
  14007. // 단지서버 2.0 사용여부 확인
  14008. if (!NewServerUse()) {
  14009. return makeReply_check_resident_safety("deny", null, null, null);
  14010. }
  14011. // 거주자 안전 확인 사용 여부
  14012. if (!bEnableResidentSafetyCheck) {
  14013. return makeReply_check_resident_safety("deny", null, null, null);
  14014. }
  14015. String strSecurity = getSecurityMode();
  14016. String strTouch = getTimeStamp_ScreenTouched();
  14017. String strMagnetic = getTimeStamp_Magnetic();
  14018. return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
  14019. } catch (RuntimeException re) {
  14020. LogUtil.errorLogInfo("", TAG, re);
  14021. return makeReply_check_resident_safety("fail", null, null, null);
  14022. } catch (Exception e) {
  14023. Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
  14024. //e.printStackTrace();
  14025. LogUtil.errorLogInfo("", TAG, e);
  14026. return makeReply_check_resident_safety("fail", null, null, null);
  14027. }
  14028. }
  14029. public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
  14030. try {
  14031. String strReplyXml = XMLHeader;
  14032. strReplyXml += " <service type=\"reply\" name=\"check_resident_safety\" result=\"" + strResult + "\">\n";
  14033. if (strResult.equalsIgnoreCase("ok")) {
  14034. strReplyXml += " <security>\"" + strSecurity + "\"</security>\n";
  14035. strReplyXml += " <touch>\"" + strTouch + "\"</touch>\n";
  14036. strReplyXml += " <magnetic>\"" + magnetic + "\"</magnetic>\n";
  14037. }
  14038. strReplyXml += " <message>\"null\"</message>\n";
  14039. strReplyXml += " </service>\n";
  14040. strReplyXml += "</imap>";
  14041. return strReplyXml;
  14042. } catch (RuntimeException re) {
  14043. LogUtil.errorLogInfo("", TAG, re);
  14044. return "ERROR";
  14045. } catch (Exception e) {
  14046. Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
  14047. //e.printStackTrace();
  14048. LogUtil.errorLogInfo("", TAG, e);
  14049. return "ERROR";
  14050. }
  14051. }
  14052. private void saveBlackoutStatus(boolean bOccurred) {
  14053. try {
  14054. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  14055. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14056. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14057. mEditor.putBoolean("status", bOccurred);
  14058. mEditor.commit();
  14059. } catch (RuntimeException re) {
  14060. LogUtil.errorLogInfo("", TAG, re);
  14061. } catch (Exception e) {
  14062. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  14063. //e.printStackTrace();
  14064. LogUtil.errorLogInfo("", TAG, e);
  14065. }
  14066. }
  14067. private boolean getBlackoutStatus() {
  14068. try {
  14069. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14070. return mSharedPreferences.getBoolean("status", false);
  14071. } catch (RuntimeException re) {
  14072. LogUtil.errorLogInfo("", TAG, re);
  14073. return false;
  14074. } catch (Exception e) {
  14075. Log.e(TAG, "[Exception] getBlackoutStatus()");
  14076. //e.printStackTrace();
  14077. LogUtil.errorLogInfo("", TAG, e);
  14078. return false;
  14079. }
  14080. }
  14081. /**
  14082. * JEFF, 2019.12.25
  14083. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  14084. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  14085. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  14086. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  14087. */
  14088. int MAX_WALLPADCALL_LIVE_CNT = 2;
  14089. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  14090. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  14091. public static boolean bWallPadCallLive_old = false;
  14092. public static boolean m_bWallpadCallScreen = false;
  14093. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  14094. Handler handlerCheckWallPadCallLive = new Handler() {
  14095. public void handleMessage(Message msg) {
  14096. super.handleMessage(msg);
  14097. sendWallPadCallLiveBR_Request();
  14098. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  14099. }
  14100. };
  14101. private void sendWallPadCallLiveBR_Request() {
  14102. try {
  14103. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  14104. Intent mIntent = new Intent();
  14105. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  14106. getApplicationContext().sendBroadcast(mIntent);
  14107. if (nWallPadCallACKCnt >= 0) {
  14108. nWallPadCallACKCnt--;
  14109. } else {
  14110. bWallPadCallLive = false;
  14111. Common.bWallPadCallLive = bWallPadCallLive;
  14112. }
  14113. if (bWallPadCallLive != bWallPadCallLive_old) {
  14114. if (bWallPadCallLive != getCallAppRunning()) {
  14115. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14116. setCallAppRunning(bWallPadCallLive);
  14117. }
  14118. }
  14119. bWallPadCallLive_old = bWallPadCallLive;
  14120. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14121. } catch (RuntimeException re) {
  14122. LogUtil.errorLogInfo("", TAG, re);
  14123. } catch (Exception e) {
  14124. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  14125. //e.printStackTrace();
  14126. LogUtil.errorLogInfo("", TAG, e);
  14127. }
  14128. }
  14129. public boolean getWallpadCallScrean(int iScreen)
  14130. {
  14131. boolean bRet = false;
  14132. try {
  14133. switch (iScreen) {
  14134. case API_Menu.SubMenuCall.Door:
  14135. bRet = false;
  14136. break;
  14137. case API_Menu.SubMenuCall.Lobby:
  14138. bRet = false;
  14139. break;
  14140. case API_Menu.SubMenuCall.Guard:
  14141. bRet = false;
  14142. break;
  14143. case API_Menu.SubMenuCall.Neighbor:
  14144. bRet = false;
  14145. break;
  14146. case API_Menu.SubMenuCall.PSTN:
  14147. bRet = false;
  14148. break;
  14149. case API_Menu.SubMenuCall.CallList:
  14150. bRet = true;
  14151. break;
  14152. case API_Menu.SubMenuCall.Visitor:
  14153. bRet = true;
  14154. break;
  14155. default:
  14156. bRet = false;
  14157. break;
  14158. }
  14159. } catch (RuntimeException re) {
  14160. LogUtil.errorLogInfo("", TAG, re);
  14161. return false;
  14162. } catch (Exception e) {
  14163. Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
  14164. //e.printStackTrace();
  14165. LogUtil.errorLogInfo("", TAG, e);
  14166. return false;
  14167. }
  14168. return bRet;
  14169. }
  14170. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  14171. @Override
  14172. public void onReceive(Context context, Intent intent) {
  14173. try {
  14174. String strActionName = intent.getAction();
  14175. int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
  14176. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  14177. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  14178. bWallPadCallLive = true;
  14179. Common.bWallPadCallLive = bWallPadCallLive;
  14180. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  14181. m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
  14182. Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
  14183. } else {
  14184. Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  14185. }
  14186. } catch (RuntimeException re) {
  14187. LogUtil.errorLogInfo("", TAG, re);
  14188. } catch (Exception e) {
  14189. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  14190. //e.printStackTrace();
  14191. LogUtil.errorLogInfo("", TAG, e);
  14192. }
  14193. }
  14194. };
  14195. static class CALLCTRLHANDLERMSG {
  14196. static final int RELEASE_BLOCK_FRONTCALL = 100;
  14197. }
  14198. boolean bBlockFrontCall = false;
  14199. Handler handlerCallCtrl = new Handler() {
  14200. public void handleMessage(Message msg) {
  14201. super.handleMessage(msg);
  14202. int nMSG = msg.what;
  14203. switch (nMSG) {
  14204. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  14205. bBlockFrontCall = false;
  14206. break;
  14207. }
  14208. }
  14209. };
  14210. /**
  14211. * JEFF, 2019.12.31
  14212. * WallPadCall 실행여부를 DB에 저장한다.
  14213. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  14214. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  14215. */
  14216. public void setCallAppRunning(boolean bRunning) {
  14217. try {
  14218. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14219. mWallpadStatusData.SetCallAPKStatus(bRunning);
  14220. mWallpadStatusData.closeDB();
  14221. } catch (RuntimeException re) {
  14222. LogUtil.errorLogInfo("", TAG, re);
  14223. } catch (Exception e) {
  14224. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  14225. //e.printStackTrace();
  14226. LogUtil.errorLogInfo("", TAG, e);
  14227. }
  14228. }
  14229. private boolean getCallAppRunning() {
  14230. boolean bRunning = false;
  14231. try {
  14232. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14233. bRunning = wallpadStatusData.GetCallAPKStatusRunning();
  14234. wallpadStatusData.closeDB();
  14235. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  14236. return bRunning;
  14237. } catch (RuntimeException re) {
  14238. LogUtil.errorLogInfo("", TAG, re);
  14239. return false;
  14240. } catch (Exception e) {
  14241. Log.d(TAG, "[Exception] getCallAppRunning()");
  14242. //e.printStackTrace();
  14243. LogUtil.errorLogInfo("", TAG, e);
  14244. return false;
  14245. }
  14246. }
  14247. /**
  14248. * 통화앱 종료코드
  14249. */
  14250. public void killWallPadCall() {
  14251. try {
  14252. Log.i(TAG, "[killWallPadCall] ===== START =====");
  14253. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  14254. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14255. Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  14256. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  14257. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14258. // android.os.Process.killProcess(nWallPadCallPID);
  14259. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  14260. // if(list != null){
  14261. // for(int i=0;i<list.size();++i){
  14262. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  14263. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14264. // android.os.Process.killProcess(pid);
  14265. // }
  14266. // }
  14267. // }
  14268. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  14269. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14270. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  14271. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14272. // android.os.Process.killProcess(pid);
  14273. } catch (RuntimeException re) {
  14274. LogUtil.errorLogInfo("", TAG, re);
  14275. } catch (Exception e) {
  14276. Log.e(TAG, "[Exception] killWallPadCall()");
  14277. //e.printStackTrace();
  14278. LogUtil.errorLogInfo("", TAG, e);
  14279. }
  14280. }
  14281. private void checkForegroundActivity() {
  14282. try {
  14283. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  14284. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  14285. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  14286. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  14287. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  14288. } catch (RuntimeException re) {
  14289. LogUtil.errorLogInfo("", TAG, re);
  14290. } catch (Exception e) {
  14291. Log.e(TAG, "[Exception] checkForegroundActivity()");
  14292. //e.printStackTrace();
  14293. LogUtil.errorLogInfo("", TAG, e);
  14294. }
  14295. }
  14296. /**
  14297. * JEFF, 2020.01.04
  14298. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  14299. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  14300. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  14301. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  14302. */
  14303. static long lConnectionPeriod = 0;
  14304. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  14305. boolean bRingGeneratorRun = false;
  14306. private void startIGW300RingGenerator() {
  14307. try {
  14308. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14309. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  14310. bRingGeneratorRun = true;
  14311. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  14312. mIGW300RingGeneratorThread.start();
  14313. } else
  14314. Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  14315. } catch (RuntimeException re) {
  14316. LogUtil.errorLogInfo("", TAG, re);
  14317. } catch (Exception e) {
  14318. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  14319. //e.printStackTrace();
  14320. LogUtil.errorLogInfo("", TAG, e);
  14321. }
  14322. }
  14323. private void stopIGW300RingGenerator() {
  14324. try {
  14325. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14326. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  14327. lConnectionPeriod = -999;
  14328. bRingGeneratorRun = false;
  14329. mIGW300RingGeneratorThread = null;
  14330. } else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  14331. } catch (RuntimeException re) {
  14332. LogUtil.errorLogInfo("", TAG, re);
  14333. } catch (Exception e) {
  14334. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  14335. //e.printStackTrace();
  14336. LogUtil.errorLogInfo("", TAG, e);
  14337. }
  14338. }
  14339. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  14340. private class IGW300RingGeneratorThread extends Thread {
  14341. public IGW300RingGeneratorThread() {
  14342. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  14343. }
  14344. public void run() {
  14345. try {
  14346. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14347. if (bRingGeneratorRun)
  14348. Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  14349. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  14350. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  14351. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  14352. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  14353. try {
  14354. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  14355. } catch (InterruptedException e) {
  14356. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  14357. //e.printStackTrace();
  14358. LogUtil.errorLogInfo("", TAG, e);
  14359. }
  14360. }
  14361. bRingGeneratorRun = false;
  14362. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  14363. } catch (RuntimeException re) {
  14364. LogUtil.errorLogInfo("", TAG, re);
  14365. } catch (Exception e) {
  14366. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  14367. //e.printStackTrace();
  14368. LogUtil.errorLogInfo("", TAG, e);
  14369. }
  14370. }
  14371. }
  14372. private void sendPSTNRingEvent(int nKeyCode) {
  14373. try {
  14374. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  14375. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  14376. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  14377. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  14378. intent.putExtra("keycode", nKeyCode);
  14379. getApplicationContext().sendBroadcast(intent);
  14380. } catch (RuntimeException re) {
  14381. LogUtil.errorLogInfo("", TAG, re);
  14382. } catch (Exception e) {
  14383. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  14384. //e.printStackTrace();
  14385. LogUtil.errorLogInfo("", TAG, e);
  14386. }
  14387. }
  14388. /**
  14389. * 월패드 타입 판별
  14390. *
  14391. * @return bResult
  14392. * false: 메인월패드
  14393. * true: 서브월패드
  14394. */
  14395. public boolean getIsSubWallpad() {
  14396. boolean bResult = false;
  14397. try {
  14398. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14399. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  14400. mWallpadDeviceSet.closeDB();
  14401. if (DBinfo != null) {
  14402. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  14403. else bResult = false;
  14404. }
  14405. } catch (RuntimeException re) {
  14406. LogUtil.errorLogInfo("", TAG, re);
  14407. } catch (Exception e) {
  14408. Log.e(TAG, "[Exception] getIsSubWallpad()");
  14409. //e.printStackTrace();
  14410. LogUtil.errorLogInfo("", TAG, e);
  14411. }
  14412. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  14413. return bResult;
  14414. }
  14415. /**
  14416. * JEFF, 2020.02.05
  14417. * 월패드 비상접점 신호 사용 여부 확인
  14418. */
  14419. public boolean getEmergencyIOUsage() {
  14420. boolean bResult = false;
  14421. try {
  14422. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14423. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  14424. mWallpadDeviceSet.closeDB();
  14425. } catch (RuntimeException re) {
  14426. LogUtil.errorLogInfo("", TAG, re);
  14427. } catch (Exception e) {
  14428. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  14429. //e.printStackTrace();
  14430. LogUtil.errorLogInfo("", TAG, e);
  14431. }
  14432. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  14433. return bResult;
  14434. }
  14435. /**
  14436. * JEFF, 2020.02.05
  14437. * 거동수상자 녹화기능 활성화 확인
  14438. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  14439. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  14440. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  14441. */
  14442. public boolean getStrangerRecordingManagerSetting() {
  14443. boolean bResult = false;
  14444. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14445. try {
  14446. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14447. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  14448. mWallpadDeviceSet.closeDB();
  14449. if (nFrontCam[0] == COMPONENT_USE) {
  14450. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  14451. if (bRecord) bResult = true;
  14452. else bResult = false;
  14453. } else bResult = false;
  14454. } else bResult = false;
  14455. } catch (RuntimeException re) {
  14456. LogUtil.errorLogInfo("", TAG, re);
  14457. mWallpadDeviceSet.closeDB();
  14458. } catch (Exception e) {
  14459. mWallpadDeviceSet.closeDB();
  14460. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  14461. //e.printStackTrace();
  14462. LogUtil.errorLogInfo("", TAG, e);
  14463. }
  14464. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  14465. return bResult;
  14466. }
  14467. /**
  14468. * Edited by jeff (2020.06.22)
  14469. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  14470. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  14471. *
  14472. * @param bOn
  14473. */
  14474. private void sendLCDBacklightStatus(boolean bOn) {
  14475. try {
  14476. Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
  14477. Intent mIntent = new Intent();
  14478. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  14479. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  14480. getApplicationContext().sendBroadcast(mIntent);
  14481. } catch (RuntimeException re) {
  14482. LogUtil.errorLogInfo("", TAG, re);
  14483. } catch (Exception e) {
  14484. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  14485. //e.printStackTrace();
  14486. LogUtil.errorLogInfo("", TAG, e);
  14487. }
  14488. }
  14489. // 명칭 관련
  14490. boolean bRoomNameLog = true;
  14491. public static final int HEATING = 1;
  14492. public static final int LIGHT = 2;
  14493. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  14494. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14495. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  14496. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
  14497. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14498. /**
  14499. * DB 에서 룸이름 정보를 가져온다.
  14500. *
  14501. * @return (String []) null - 실패, not null
  14502. */
  14503. private String[] getDBRoomName() {
  14504. try {
  14505. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14506. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  14507. wallpadStatusData.closeDB();
  14508. if (strRoomNameList == null) {
  14509. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  14510. return null;
  14511. }
  14512. if (bRoomNameLog) {
  14513. for (int i = 0; i < strRoomNameList.length; i++)
  14514. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14515. }
  14516. return strRoomNameList;
  14517. } catch (RuntimeException re) {
  14518. LogUtil.errorLogInfo("", TAG, re);
  14519. } catch (Exception e) {
  14520. Log.e(TAG, "[Exception] getDBRoomName()");
  14521. //e.printStackTrace();
  14522. LogUtil.errorLogInfo("", TAG, e);
  14523. }
  14524. return null;
  14525. }
  14526. /**
  14527. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  14528. *
  14529. * @param nDeviceType - int
  14530. * @return (String []) null - 실패, not null
  14531. */
  14532. private String[] getDBRoomName(int nDeviceType) {
  14533. try {
  14534. String[] strRoomNameList = null;
  14535. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14536. if (nDeviceType == HEATING) {
  14537. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  14538. } else {
  14539. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  14540. }
  14541. wallpadStatusData.closeDB();
  14542. if (strRoomNameList == null) {
  14543. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  14544. return null;
  14545. }
  14546. if (bRoomNameLog) {
  14547. for (int i = 0; i < strRoomNameList.length; i++)
  14548. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14549. }
  14550. return strRoomNameList;
  14551. } catch (RuntimeException re) {
  14552. LogUtil.errorLogInfo("", TAG, re);
  14553. } catch (Exception e) {
  14554. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  14555. //e.printStackTrace();
  14556. LogUtil.errorLogInfo("", TAG, e);
  14557. }
  14558. return null;
  14559. }
  14560. /**
  14561. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  14562. **/
  14563. private void getRoomName() {
  14564. try {
  14565. Log.i(TAG, "[getRoomName] ====================");
  14566. } catch (RuntimeException re) {
  14567. LogUtil.errorLogInfo("", TAG, re);
  14568. } catch (Exception e) {
  14569. Log.e(TAG, "[Exception] getRoomName()");
  14570. //e.printStackTrace();
  14571. LogUtil.errorLogInfo("", TAG, e);
  14572. }
  14573. }
  14574. public boolean getEasyModeUXUsage() {
  14575. try {
  14576. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  14577. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  14578. deviceSet.closeDB();
  14579. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  14580. boolean bUse = data.GetEasyModeUxUse();
  14581. data.closeDB();
  14582. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  14583. return bSupport & bUse;
  14584. } catch (RuntimeException re) {
  14585. LogUtil.errorLogInfo("", TAG, re);
  14586. } catch (Exception e) {
  14587. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  14588. //e.printStackTrace();
  14589. LogUtil.errorLogInfo("", TAG, e);
  14590. }
  14591. return false;
  14592. }
  14593. /**
  14594. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  14595. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  14596. * 재설정 5초 후 월패드 재부팅을 실행한다.
  14597. * 2020.11.18 SEULKI
  14598. */
  14599. public void checkDoorCamConfig() {
  14600. try {
  14601. if (Build.VERSION.SDK_INT > 23) {
  14602. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  14603. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  14604. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  14605. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  14606. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  14607. if (!checkAvailableBSPDoorCamConfig()) {
  14608. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  14609. return;
  14610. }
  14611. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  14612. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  14613. if (mIOInterface != null)
  14614. mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  14615. // 재부팅
  14616. setDefaultLauncher();
  14617. Intent intent = new Intent();
  14618. if (intent != null) {
  14619. intent.setAction(define.NOTIFY_ACNAME);
  14620. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  14621. getApplicationContext().sendBroadcast(intent);
  14622. }
  14623. }
  14624. }
  14625. }
  14626. } catch (RuntimeException re) {
  14627. LogUtil.errorLogInfo("", "", re);
  14628. } catch (Exception e) {
  14629. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  14630. LogUtil.errorLogInfo("", "", e);
  14631. }
  14632. }
  14633. /**
  14634. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  14635. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  14636. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  14637. *
  14638. * @return true: 지원, false: 미지원
  14639. */
  14640. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  14641. private boolean checkAvailableBSPDoorCamConfig() {
  14642. try {
  14643. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  14644. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  14645. if (nCurrentVer >= nCriterionVer) {
  14646. return true;
  14647. } else return false;
  14648. } catch (RuntimeException re) {
  14649. LogUtil.errorLogInfo("", TAG, re);
  14650. return false;
  14651. } catch (Exception e) {
  14652. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  14653. //e.printStackTrace();
  14654. LogUtil.errorLogInfo("", TAG, e);
  14655. return false;
  14656. }
  14657. }
  14658. /**
  14659. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14660. *
  14661. * @return 0 - 스마트현관카메라
  14662. * 2 - 스마트현관카메라 좌우반전
  14663. * 1 - 일반현관카메라
  14664. * 2020.11.18 SEULKI
  14665. */
  14666. public int getBSPDoorCamConfig() {
  14667. InputStreamReader is = null;
  14668. try {
  14669. Runtime mRuntime = Runtime.getRuntime();
  14670. String cmd = "getprop camera.setting.value";
  14671. if (mRuntime != null) {
  14672. Process mProcess = mRuntime.exec(cmd);
  14673. is = new InputStreamReader(mProcess.getInputStream());
  14674. BufferedReader br = new BufferedReader(is);
  14675. String line;
  14676. String strResult = null;
  14677. if (br != null) {
  14678. while ((line = br.readLine()) != null) {
  14679. strResult = line;
  14680. }
  14681. if (strResult != null) {
  14682. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  14683. if (strResult.equals("0")) {
  14684. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  14685. return 0;
  14686. } else if (strResult.equals("1")) {
  14687. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  14688. return 1;
  14689. } else if (strResult.equals("2")) {
  14690. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  14691. return 2;
  14692. } else {
  14693. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  14694. return -1;
  14695. }
  14696. }
  14697. }
  14698. }
  14699. return -1;
  14700. } catch (Exception e) {
  14701. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  14702. e.printStackTrace();
  14703. return -1;
  14704. } finally {
  14705. if (is != null) {
  14706. try {
  14707. is.close();
  14708. } catch (IOException e) {
  14709. LogUtil.errorLogInfo("", TAG, e);
  14710. }
  14711. is = null;
  14712. }
  14713. }
  14714. }
  14715. /**
  14716. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14717. *
  14718. * @return 0 - 스마트현관카메라
  14719. * 2 - 스마트현관카메라 좌우반전
  14720. * 1 - 일반현관카메라
  14721. * 2020.11.18 SEULKI
  14722. */
  14723. public int getDBDoorCamConfig() {
  14724. try {
  14725. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14726. if (mWallpadDeviceSet != null) {
  14727. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14728. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  14729. mWallpadDeviceSet.closeDB();
  14730. if (nType != null) {
  14731. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  14732. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
  14733. // Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14734. if (bFlip) {
  14735. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14736. return 0;
  14737. } else {
  14738. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
  14739. return 2;
  14740. }
  14741. } else {
  14742. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  14743. return 1;
  14744. }
  14745. }
  14746. }
  14747. return -1;
  14748. } catch (Exception e) {
  14749. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  14750. e.printStackTrace();
  14751. return -1;
  14752. }
  14753. }
  14754. /**
  14755. * 공기질 센서 사용여부 확인
  14756. *
  14757. * @return true - 사용함, false: 사용안함
  14758. */
  14759. boolean bAirQualityEnable = false;
  14760. private boolean getAirQualityUsage() {
  14761. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14762. try {
  14763. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  14764. mWallpadDeviceSet.closeDB();
  14765. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  14766. bAirQualityEnable = true;
  14767. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14768. } else {
  14769. bAirQualityEnable = false;
  14770. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14771. }
  14772. return bAirQualityEnable;
  14773. } catch (RuntimeException re) {
  14774. LogUtil.errorLogInfo("", TAG, re);
  14775. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14776. return false;
  14777. } catch (Exception e) {
  14778. Log.e(TAG, "[Exception] getAirQualityUsage()");
  14779. //e.printStackTrace();
  14780. LogUtil.errorLogInfo("", TAG, e);
  14781. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14782. return false;
  14783. }
  14784. }
  14785. String strAirQualityFWVer = "";
  14786. String strAirQualityProtocolVer = "";
  14787. String strAirQualityInfo = "";
  14788. private String getAirQualityInfo() {
  14789. try {
  14790. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  14791. if (mAirQualitySensorAPI != null) {
  14792. int nRet = mAirQualitySensorAPI.Refresh(false);
  14793. if (nRet >= 0) {
  14794. Log.i(TAG, "[getAirQualityInfo] ");
  14795. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  14796. strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  14797. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  14798. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  14799. return strAirQualityInfo;
  14800. } else return "FAIL";
  14801. } else return "NULL";
  14802. } catch (RuntimeException re) {
  14803. LogUtil.errorLogInfo("", TAG, re);
  14804. return "ERROR";
  14805. } catch (Exception e) {
  14806. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14807. //e.printStackTrace();
  14808. LogUtil.errorLogInfo("", TAG, e);
  14809. return "ERROR";
  14810. }
  14811. }
  14812. private String getAOSVerCode() {
  14813. try {
  14814. int nOSVer = Build.VERSION.SDK_INT;
  14815. switch (nOSVer) {
  14816. case Build.VERSION_CODES.BASE:
  14817. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  14818. case Build.VERSION_CODES.BASE_1_1:
  14819. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  14820. case Build.VERSION_CODES.CUPCAKE:
  14821. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  14822. case Build.VERSION_CODES.DONUT:
  14823. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  14824. case Build.VERSION_CODES.ECLAIR:
  14825. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  14826. case Build.VERSION_CODES.ECLAIR_0_1:
  14827. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  14828. case Build.VERSION_CODES.ECLAIR_MR1:
  14829. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  14830. case Build.VERSION_CODES.FROYO:
  14831. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  14832. case Build.VERSION_CODES.GINGERBREAD:
  14833. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  14834. case Build.VERSION_CODES.GINGERBREAD_MR1:
  14835. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  14836. case Build.VERSION_CODES.HONEYCOMB:
  14837. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  14838. case Build.VERSION_CODES.HONEYCOMB_MR1:
  14839. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  14840. case Build.VERSION_CODES.HONEYCOMB_MR2:
  14841. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  14842. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  14843. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  14844. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  14845. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  14846. case Build.VERSION_CODES.JELLY_BEAN:
  14847. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  14848. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  14849. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  14850. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  14851. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  14852. case Build.VERSION_CODES.KITKAT:
  14853. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  14854. case Build.VERSION_CODES.KITKAT_WATCH:
  14855. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  14856. case Build.VERSION_CODES.LOLLIPOP:
  14857. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  14858. case Build.VERSION_CODES.LOLLIPOP_MR1:
  14859. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  14860. case Build.VERSION_CODES.M:
  14861. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  14862. case Build.VERSION_CODES.N:
  14863. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  14864. case Build.VERSION_CODES.N_MR1:
  14865. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  14866. case Build.VERSION_CODES.O:
  14867. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  14868. case Build.VERSION_CODES.O_MR1:
  14869. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  14870. case Build.VERSION_CODES.P:
  14871. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  14872. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  14873. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  14874. default:
  14875. return "SDK(" + nOSVer + ")/UNKNOWN";
  14876. }
  14877. } catch (RuntimeException re) {
  14878. LogUtil.errorLogInfo("", TAG, re);
  14879. return "ERROR";
  14880. } catch (Exception e) {
  14881. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14882. //e.printStackTrace();
  14883. LogUtil.errorLogInfo("", TAG, e);
  14884. return "ERROR";
  14885. }
  14886. }
  14887. /**
  14888. * 조명 ON/OFF 상태
  14889. */
  14890. public static class LIGHT_ONOFF {
  14891. /**
  14892. * ON
  14893. */
  14894. public static byte ON = (byte) 0x01;
  14895. /**
  14896. * OFF
  14897. */
  14898. public static byte OFF = (byte) 0x02;
  14899. /**
  14900. * OFF
  14901. */
  14902. public static byte DONTCARE = (byte) 0xFF;
  14903. }
  14904. private byte convertSmartLightPowerValue(String cmd) {
  14905. try {
  14906. if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
  14907. else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
  14908. else return LIGHT_ONOFF.DONTCARE;
  14909. } catch (RuntimeException re) {
  14910. LogUtil.errorLogInfo("", TAG, re);
  14911. return -1;
  14912. } catch (Exception e) {
  14913. Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
  14914. //e.printStackTrace();
  14915. LogUtil.errorLogInfo("", TAG, e);
  14916. return -1;
  14917. }
  14918. }
  14919. /** 거주자 안정 확인 서비스용 코드 시작 */
  14920. /**
  14921. * Edited by Jeff, 2021.06.15
  14922. */
  14923. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  14924. public boolean bEnableResidentSafetyCheck = false;
  14925. private void getResidentSafetyCheckSetting() {
  14926. try {
  14927. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14928. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  14929. mWallpadDeviceSet.closeDB();
  14930. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  14931. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
  14932. bEnableResidentSafetyCheck = true;
  14933. else bEnableResidentSafetyCheck = false;
  14934. } catch (RuntimeException re) {
  14935. LogUtil.errorLogInfo("", TAG, re);
  14936. } catch (Exception e) {
  14937. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  14938. //e.printStackTrace();
  14939. LogUtil.errorLogInfo("", TAG, e);
  14940. }
  14941. }
  14942. private String getSecurityMode() {
  14943. try {
  14944. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14945. int nStatus = mWallpadStatusData.GetAlarmStatus();
  14946. mWallpadStatusData.closeDB();
  14947. String strSecurity = "null";
  14948. if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
  14949. else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
  14950. else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
  14951. else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
  14952. else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
  14953. else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
  14954. return strSecurity;
  14955. } catch (Exception e) {
  14956. Log.e(TAG, "[Exception] getSecurityMode()");
  14957. //e.printStackTrace();
  14958. LogUtil.errorLogInfo("", TAG, e);
  14959. return null;
  14960. }
  14961. }
  14962. String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
  14963. String Touch = "Touch";
  14964. String Magnetic = "Magnetic";
  14965. private void setTimeStamp_ScreenTouched() {
  14966. try {
  14967. Calendar mCal = Calendar.getInstance();
  14968. String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  14969. // Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
  14970. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14971. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14972. mEditor.putString(Touch, strTouchTime);
  14973. mEditor.apply();
  14974. } catch (Exception e) {
  14975. Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
  14976. //e.printStackTrace();
  14977. LogUtil.errorLogInfo("", TAG, e);
  14978. }
  14979. }
  14980. private String getTimeStamp_ScreenTouched() {
  14981. try {
  14982. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14983. String strTouchTime = mSharedPreferences.getString(Touch, null);
  14984. // Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
  14985. return strTouchTime;
  14986. } catch (Exception e) {
  14987. Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
  14988. //e.printStackTrace();
  14989. LogUtil.errorLogInfo("", TAG, e);
  14990. return null;
  14991. }
  14992. }
  14993. private void setTimeStamp_Magnetic() {
  14994. try {
  14995. Calendar mCal = Calendar.getInstance();
  14996. String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  14997. // Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
  14998. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  14999. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  15000. mEditor.putString(Magnetic, strMagneticTime);
  15001. mEditor.apply();
  15002. } catch (Exception e) {
  15003. Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
  15004. //e.printStackTrace();
  15005. LogUtil.errorLogInfo("", TAG, e);
  15006. }
  15007. }
  15008. private String getTimeStamp_Magnetic() {
  15009. try {
  15010. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15011. String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
  15012. // Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
  15013. return strMagneticTime;
  15014. } catch (Exception e) {
  15015. Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
  15016. //e.printStackTrace();
  15017. LogUtil.errorLogInfo("", TAG, e);
  15018. return null;
  15019. }
  15020. }
  15021. /** 거주자 안정 확인 서비스용 코드 종료 */
  15022. /**
  15023. * 가스밸브를 쿡탑콘센트로 사용
  15024. */
  15025. private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
  15026. /** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
  15027. /** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
  15028. /**
  15029. * false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
  15030. */
  15031. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  15032. private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
  15033. /**
  15034. * 기기 연동 제어 옵션 설정 확인
  15035. */
  15036. // 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
  15037. // 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
  15038. private void getDeviceCtrlOption() {
  15039. int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
  15040. boolean bUserSetting_SmartLightEnable = false;
  15041. int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
  15042. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  15043. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  15044. try {
  15045. bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
  15046. nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
  15047. nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
  15048. mWallpadDeviceSet.closeDB();
  15049. bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
  15050. mWallpadStatusData.closeDB();
  15051. if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  15052. // 스마트 분전반을 사용하는 경우에만
  15053. // 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
  15054. if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
  15055. // 사용자선택인 경우
  15056. if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
  15057. else bLightCMDUseAsSmartLight = true;
  15058. } else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
  15059. // 스마트조명을 사용하는 경우
  15060. bLightCMDUseAsSmartLight = false;
  15061. } else {
  15062. // 스마트조명을 사용하지 않는 경우
  15063. bLightCMDUseAsSmartLight = true;
  15064. }
  15065. } else {
  15066. // 스마트분전반을 사용하지 않는 경우
  15067. bLightCMDUseAsSmartLight = true;
  15068. }
  15069. Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
  15070. } catch (Exception e) {
  15071. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  15072. if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
  15073. Log.e(TAG, "[Exception] getDeviceCtrlOption()");
  15074. //e.printStackTrace();
  15075. LogUtil.errorLogInfo("", TAG, e);
  15076. }
  15077. }
  15078. private String[] getRoomNameFromDBV2(String strDeviceType) {
  15079. try {
  15080. String[] RoomNameList = null;
  15081. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  15082. RoomNameList = wallpadStatusData.GetDevRoomNameList(strDeviceType);
  15083. wallpadStatusData.closeDB();
  15084. if (RoomNameList == null) {
  15085. Log.e(TAG, "[getRoomNameFromDBV2] - RoomNameList is null !!!");
  15086. return null;
  15087. }
  15088. Log.i(TAG, "[getRoomNameFromDBV2] RoomNameList " + Arrays.toString(RoomNameList));
  15089. return RoomNameList;
  15090. } catch (RuntimeException re) {
  15091. LogUtil.errorLogInfo("", TAG, re);
  15092. } catch (Exception e) {
  15093. Log.e(TAG, "[Exception] getRoomNameFromDBV2(int Device)");
  15094. //e.printStackTrace();
  15095. LogUtil.errorLogInfo("", TAG, e);
  15096. }
  15097. return null;
  15098. }
  15099. // private void demoPushMsg()
  15100. // {
  15101. // String urlStr1 = "";
  15102. //
  15103. // if(android.os.Build.VERSION.SDK_INT > 9 )
  15104. // {
  15105. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  15106. // StrictMode.setThreadPolicy(policy);
  15107. // }
  15108. //
  15109. // String Msg ="";
  15110. // try {
  15111. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  15112. // } catch (UnsupportedEncodingException e1) {
  15113. // // TODO Auto-generated catch block
  15114. // e1.printStackTrace();
  15115. // }
  15116. //
  15117. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  15118. // Log.d(TAG , "################ : " + urlStr1);
  15119. // try
  15120. // {
  15121. // //URLEncoder.encode(s)
  15122. // HttpClient client = new DefaultHttpClient();
  15123. //
  15124. // HttpGet get = new HttpGet();
  15125. // //get.setURI(new URI("http://www.google.com/"));
  15126. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  15127. // HttpResponse resp = client.execute(get);
  15128. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  15129. // String str = null;
  15130. // StringBuilder sb = new StringBuilder();
  15131. // while((str = br.readLine()) != null)
  15132. // {
  15133. // sb.append(str).append("\n");
  15134. // }
  15135. // br.close();
  15136. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  15137. // //txt.setText(sb.toString());
  15138. // }catch(Exception e)
  15139. // {
  15140. //
  15141. // e.printStackTrace();
  15142. //
  15143. // }
  15144. //
  15145. //
  15146. // }
  15147. //
  15148. //
  15149. // public static boolean checkForExternal(String str) {
  15150. // int length = str.length();
  15151. // for (int i = 0; i < length; i++) {
  15152. // if (str.charAt(i) > 0x7F) {
  15153. // return true;
  15154. // }
  15155. // }
  15156. // return false;
  15157. // }
  15158. //
  15159. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  15160. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  15161. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  15162. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  15163. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  15164. //
  15165. // public static String encodeUrl(String url) {
  15166. // if (checkForExternal(url)) {
  15167. // try {
  15168. // String value = URLEncoder.encode(url, "UTF-8");
  15169. // value = COLON.matcher(value).replaceAll(":");
  15170. // value = SLASH.matcher(value).replaceAll("/");
  15171. // value = QUEST_MARK.matcher(value).replaceAll("?");
  15172. // value = EQUAL.matcher(value).replaceAll("=");
  15173. // return AMP.matcher(value).replaceAll("&");
  15174. // } catch (UnsupportedEncodingException e) {
  15175. // //throw LOGGER.getIllegalStateException(e);
  15176. // return null;
  15177. // }
  15178. // } else {
  15179. // return url;
  15180. // }
  15181. // }
  15182. }