iMapServer.java 900 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279
  1. package kr.co.icontrols.wallpadmain.util;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningTaskInfo;
  5. import android.app.Service;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.media.AudioManager;
  15. import android.os.Build;
  16. import android.os.Bundle;
  17. import android.os.CountDownTimer;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Looper;
  21. import android.os.Message;
  22. import android.os.Messenger;
  23. import android.os.PowerManager;
  24. import android.os.RemoteException;
  25. import android.os.SystemClock;
  26. import android.provider.Settings;
  27. import android.util.Log;
  28. import android.view.KeyEvent;
  29. import android.view.View;
  30. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  31. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  32. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  33. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  34. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  35. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  36. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  37. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  38. import com.artncore.WallPadDataMgr.WallpadStatusData;
  39. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  40. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  41. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  42. import com.artncore.WallPadKNXSystem.WallPadKNX;
  43. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  44. import com.artncore.commons.APIErrorCode;
  45. import com.artncore.commons.API_Menu;
  46. import com.artncore.commons.DataClasses;
  47. import com.artncore.commons.DataClasses.HeatingV1;
  48. import com.artncore.commons.DataClasses.HeatingV2;
  49. import com.artncore.commons.DataClasses.MultiSwitch;
  50. import com.artncore.commons.KNX_DataClasses;
  51. import com.artncore.commons.define;
  52. import com.artncore.deviceinterface.WallPadInterface;
  53. import com.artncore.wallpadapi.AirQualitySensorAPI;
  54. import com.artncore.wallpadapi.CooktopAPI;
  55. import com.artncore.wallpadapi.DLockAPI;
  56. import com.artncore.wallpadapi.EnergyMeterAPI;
  57. import com.artncore.wallpadapi.GasAPI;
  58. import com.artncore.wallpadapi.HeatingV1API;
  59. import com.artncore.wallpadapi.HeatingV2API;
  60. import com.artncore.wallpadapi.IGW200dAPI;
  61. import com.artncore.wallpadapi.IGW300API;
  62. import com.artncore.wallpadapi.IntLightAPI;
  63. import com.artncore.wallpadapi.KnxAPI;
  64. import com.artncore.wallpadapi.KnxSystemAirconAPI;
  65. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  66. import com.artncore.wallpadapi.LightAPI;
  67. import com.artncore.wallpadapi.MultiSwitchAPI;
  68. import com.artncore.wallpadapi.PhonNRemocon;
  69. import com.artncore.wallpadapi.RealTimeMeterAPI;
  70. import com.artncore.wallpadapi.SdbAPI;
  71. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  72. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  73. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  74. import com.artncore.wallpadapi.VentiAPI;
  75. import com.artncore.wallpadapi.WallPadAPI;
  76. import com.artncore.wallpadimap.RetProci;
  77. import com.artncore.wallpadimap.WallPadFTPUploader;
  78. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  79. import com.artncore.wallpadimap.WallpadiCMDParser;
  80. import com.util.LogUtil;
  81. import org.apache.commons.net.ftp.FTP;
  82. import org.w3c.dom.Document;
  83. import org.w3c.dom.Element;
  84. import org.w3c.dom.NamedNodeMap;
  85. import org.w3c.dom.Node;
  86. import org.w3c.dom.NodeList;
  87. import java.io.BufferedReader;
  88. import java.io.ByteArrayInputStream;
  89. import java.io.DataOutputStream;
  90. import java.io.File;
  91. import java.io.FilenameFilter;
  92. import java.io.IOException;
  93. import java.io.InputStream;
  94. import java.io.InputStreamReader;
  95. import java.net.ServerSocket;
  96. import java.net.Socket;
  97. import java.text.SimpleDateFormat;
  98. import java.util.ArrayList;
  99. import java.util.Arrays;
  100. import java.util.Calendar;
  101. import java.util.Date;
  102. import java.util.GregorianCalendar;
  103. import java.util.LinkedList;
  104. import java.util.List;
  105. import java.util.Queue;
  106. import javax.net.ssl.SSLServerSocket;
  107. import javax.xml.parsers.DocumentBuilder;
  108. import javax.xml.parsers.DocumentBuilderFactory;
  109. import de.re.easymodbus.exceptions.ModbusException;
  110. import de.re.easymodbus.modbusclient.ModbusClient;
  111. import kr.co.icontrols.gledeviceinterface.jni;
  112. import kr.co.icontrols.hdcftp.HDCFTPManager;
  113. import kr.co.icontrols.sslapi.SSLClient;
  114. import kr.co.icontrols.sslapi.SSLServer;
  115. import kr.co.icontrols.wallpadmain.IOInterface;
  116. import kr.co.icontrols.wallpadmain.MainActivity;
  117. import kr.co.icontrols.wallpadmain.R;
  118. import kr.co.icontrols.wallpadmain.declare.Common;
  119. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  120. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  121. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  122. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  123. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  124. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  125. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  126. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  127. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  128. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  129. import kr.co.icontrols.wallpadsupport.Version;
  130. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  131. import kr.co.icontrols.wallpadsupport.WpadSound;
  132. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  133. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  134. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  135. public class iMapServer extends Service {
  136. private String TAG = "iMapServer";
  137. //
  138. static final int EVENTTIMELIMITE = 2000;
  139. iMapSverSocket SvrSock;
  140. int port = 10000;
  141. String StrAddr = "";
  142. String IPaddr;
  143. String AddrDong;
  144. String AddrHo;
  145. boolean m_CallAppRunDelay = false; //add KSJ
  146. int ho;
  147. boolean log_sw = true;
  148. String SVRIP = "";
  149. static WallPadAPI mWallPadAPI;
  150. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  151. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  152. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  153. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  154. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  155. private IGW200 mIGW200;
  156. private IGW300 mIGW300;
  157. PhonNRemocon PnRCtr;
  158. boolean CallConnected = false;
  159. long ALERTTIME = 0;
  160. long CALLTIME = 0;
  161. long OPENDOORTIME = 0;
  162. long currentTime = 0;
  163. long DoorDelayTime = 0;
  164. static Handler ScheDulerHandler;
  165. static final boolean iMAPDOORCTR = true;
  166. private jni mGleInterface = null;
  167. IOInterface mIOInterface = null;
  168. private boolean ResetFlag = false;
  169. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  170. private int ResetCount = 0;
  171. private boolean NowMainStatus = false;
  172. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  173. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  174. public iMapServer() {
  175. Log.i(TAG, "[iMapServer] ========== START ==========");
  176. }
  177. public static final int SENSOR_MAG = 0x01;
  178. public static final int SENSOR_IN = 0x02;
  179. public static final int SENSOR_OUT = 0x04;
  180. static int PORT_NUM_iMAP = 10000;
  181. static int SOCKET_WAIT_TIME = 40;
  182. static long lSocketConnectionPeriod = 0;
  183. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  184. static int SOCKET_BUFFER_SIZE_READ = 50;
  185. public static final String ITEM_MENU_TYPE = "call_menu";
  186. static final int DOOR_DELAY_TIME = 3000;
  187. static final String MULTISW_CTR = "remote_access_electric";
  188. String XMLHeader;
  189. SchedulerThread ScheServer;
  190. int OutGoingSensorWaiting = 0;
  191. private int ModelType = Version.getModelType();
  192. private WpadSound mSound;
  193. private WpadSound Sound() {
  194. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  195. return mSound;
  196. }
  197. /**
  198. * 신형 단지서버 사용 유무
  199. */
  200. private boolean mNewDanjiServer = false;
  201. /**
  202. * 방범 앱 재실행 여부
  203. */
  204. private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
  205. /**
  206. * JEFF, 2019.12.31
  207. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  208. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  209. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  210. * 통화앱 종료 BR을 삭제하면 안됨
  211. */
  212. // 통화어플이 종료중인 경우에는 호출 무시
  213. // private boolean bBlockCallEvent = false;
  214. ////////////////////////////////////////////////////////////////////////////////
  215. // 엘리베이터관련
  216. ////////////////////////////////////////////////////////////////////////////////
  217. /**
  218. * 엘리베이터 호출관련 class
  219. * <p>
  220. * shkang
  221. */
  222. private class ElevatorClass {
  223. /**
  224. * 엘리베이터 호출 타임아웃 (단위:초)
  225. */
  226. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
  227. /**
  228. * 상향/하향 플레그 true:상향UP, false:하향DN
  229. */
  230. private boolean mUpDn = false;
  231. /**
  232. * 엘리베이터 호출중
  233. */
  234. private boolean mCallElevator = false;
  235. /**
  236. * 엘리베이터 호출 API
  237. */
  238. private WallPadiMAPNotifyAPI mElevatorAPI;
  239. /**
  240. * 엘리베이터 호출 타이머
  241. */
  242. private CountDownTimer mElevatorTimer;
  243. /**
  244. * 엘리베이터 호출중 상태 가져오기
  245. */
  246. public boolean getElevatorCalling() {
  247. return mCallElevator;
  248. }
  249. /**
  250. * 엘리베이터 호출 상태 클리어
  251. */
  252. public void ClearElevator() {
  253. mCallElevator = false;
  254. }
  255. /**
  256. * 생성자
  257. *
  258. * @param Up - (boolean) true:상향, false:하향
  259. */
  260. private ElevatorClass(boolean Up) {
  261. try {
  262. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
  263. // 1. Input Param
  264. mUpDn = Up;
  265. mCallElevator = false;
  266. // 2. Create API
  267. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  268. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  269. @Override
  270. public void ProcDoing() {
  271. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  272. }
  273. @Override
  274. public void ProcError() {
  275. Log.i(TAG, "[ElevatorClass] ProcError()");
  276. mCallElevator = false;
  277. // 엘리베이터 호출 에러 알림
  278. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  279. }
  280. @Override
  281. public void ProcSuccess() {
  282. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  283. mCallElevator = true;
  284. // 엘리베이터 호출 성공 알림
  285. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  286. // "엘리베이터를 호출하였습니다" 멘트출력
  287. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  288. Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
  289. if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
  290. Sound().PlayMent(WpadSound.SND.elevator.CALL);
  291. bOutModeRestart = false;
  292. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  293. // 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
  294. // 타임아웃 시작
  295. TimeOutStart();
  296. }
  297. });
  298. // 3. Create Timer
  299. mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  300. @Override
  301. public void onFinish() {
  302. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  303. mCallElevator = false;
  304. // 호출 타임아웃 알림
  305. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  306. }
  307. @Override
  308. public void onTick(long arg0) {
  309. int RemainingTime = (int) (arg0 / 1000);
  310. if (RemainingTime <= 10) {
  311. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  312. }
  313. }
  314. };
  315. } catch (RuntimeException re) {
  316. LogUtil.errorLogInfo("", TAG, re);
  317. } catch (Exception e) {
  318. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  319. //e.printStackTrace();
  320. LogUtil.errorLogInfo("", TAG, e);
  321. }
  322. }
  323. /**
  324. * 엘리베이터 호출을 한다.
  325. */
  326. public void CallElevator() {
  327. try {
  328. if (mElevatorAPI == null) return;
  329. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  330. mCallElevator = true;
  331. } catch (RuntimeException re) {
  332. LogUtil.errorLogInfo("", TAG, re);
  333. } catch (Exception e) {
  334. Log.e(TAG, "[Exception] CallElevator()");
  335. //e.printStackTrace();
  336. LogUtil.errorLogInfo("", TAG, e);
  337. }
  338. }
  339. /**
  340. * 엘리베이터 상향호출 타임아웃을 취소한다.
  341. */
  342. public void TimeOutCancel() {
  343. try {
  344. if (mElevatorTimer == null) return;
  345. mElevatorTimer.cancel();
  346. } catch (RuntimeException re) {
  347. LogUtil.errorLogInfo("", TAG, re);
  348. } catch (Exception e) {
  349. Log.e(TAG, "[Exception] TimeOutCancel()");
  350. //e.printStackTrace();
  351. LogUtil.errorLogInfo("", TAG, e);
  352. }
  353. }
  354. /**
  355. * 엘리베이터 상향호출 타임아웃을 시작한다.
  356. */
  357. private void TimeOutStart() {
  358. try {
  359. if (mElevatorTimer == null) return;
  360. mElevatorTimer.cancel();
  361. mElevatorTimer.start();
  362. } catch (RuntimeException re) {
  363. LogUtil.errorLogInfo("", TAG, re);
  364. } catch (Exception e) {
  365. Log.e(TAG, "[Exception] TimeOutStart()");
  366. //e.printStackTrace();
  367. LogUtil.errorLogInfo("", TAG, e);
  368. }
  369. }
  370. /**
  371. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  372. *
  373. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  374. */
  375. private void SendNotifyKindBR(int kind) {
  376. try {
  377. Intent notiIntent = new Intent();
  378. notiIntent.setAction(define.NOTIFY_ACNAME);
  379. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  380. getApplicationContext().sendBroadcast(notiIntent);
  381. } catch (RuntimeException re) {
  382. LogUtil.errorLogInfo("", TAG, re);
  383. } catch (Exception e) {
  384. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  385. //e.printStackTrace();
  386. LogUtil.errorLogInfo("", TAG, e);
  387. }
  388. }
  389. }
  390. /**
  391. * 엘리베이터 상향호출 Class
  392. */
  393. private ElevatorClass ElevatorUp;
  394. /**
  395. * 엘리베이터 하향호출 Class
  396. */
  397. private ElevatorClass ElevatorDown;
  398. /**
  399. * 엘리베이터 호출한다.
  400. *
  401. * @param Up (boolean) true : 상향, false : 하향
  402. */
  403. private void CallElevatorBtn(boolean Up) {
  404. try {
  405. Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
  406. if (Up) {
  407. // 상향호출
  408. if (ElevatorUp == null) {
  409. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  410. return;
  411. }
  412. ElevatorUp.CallElevator();
  413. } else {
  414. // 하향호출
  415. if (ElevatorDown == null) {
  416. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  417. return;
  418. }
  419. ElevatorDown.CallElevator();
  420. }
  421. } catch (RuntimeException re) {
  422. LogUtil.errorLogInfo("", TAG, re);
  423. } catch (Exception e) {
  424. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  425. //e.printStackTrace();
  426. LogUtil.errorLogInfo("", TAG, e);
  427. }
  428. }
  429. ////////////////////////////////////////////////////////////////////////////////
  430. ////////////////////////////////////////////////////////////////////////////////
  431. @Override
  432. public void onCreate() {
  433. try {
  434. super.onCreate();
  435. Log.i(TAG, "[onCreate] ========== START ==========");
  436. setGlobalScreenAppRunningStatus(false);
  437. ModelType = Version.getModelType();
  438. mSound = new WpadSound(getApplicationContext());
  439. ElevatorUp = new ElevatorClass(true);
  440. ElevatorDown = new ElevatorClass(false);
  441. } catch (RuntimeException re) {
  442. Log.e(TAG, "[Exception] onCreate()");
  443. //e.printStackTrace();
  444. LogUtil.errorLogInfo("", TAG, re);
  445. } catch (Exception e) {
  446. Log.e(TAG, "[Exception] onCreate()");
  447. //e.printStackTrace();
  448. LogUtil.errorLogInfo("", TAG, e);
  449. }
  450. }
  451. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  452. try {
  453. Intent notiIntent = new Intent();
  454. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  455. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  456. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  457. getApplicationContext().sendBroadcast(notiIntent);
  458. } catch (RuntimeException re) {
  459. LogUtil.errorLogInfo("", TAG, re);
  460. } catch (Exception e) {
  461. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  462. //e.printStackTrace();
  463. LogUtil.errorLogInfo("", TAG, e);
  464. }
  465. }
  466. protected String GetForegroundAPP() {
  467. try {
  468. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  469. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  470. ComponentName topActivity = taskInfo.get(0).topActivity;
  471. String str = topActivity.getPackageName();
  472. return str;
  473. } catch (RuntimeException re) {
  474. LogUtil.errorLogInfo("", TAG, re);
  475. return " ";
  476. } catch (Exception e) {
  477. Log.e(TAG, "[Exception] GetForegroundAPP()");
  478. //e.printStackTrace();
  479. LogUtil.errorLogInfo("", TAG, e);
  480. return " ";
  481. }
  482. }
  483. long lSavedTimestamp = 0;
  484. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  485. public void onReceive(Context context, Intent intent) {
  486. try {
  487. String strActionName = intent.getAction();
  488. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
  489. if (strActionName.equals(define.NOTIFY_DAIL)) {
  490. long lTimestamp = System.currentTimeMillis();
  491. long lInterval = lTimestamp - lSavedTimestamp;
  492. if (lInterval < 1000) return;
  493. else
  494. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
  495. lSavedTimestamp = lTimestamp;
  496. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  497. if (mSdb_LivingRoomLightAPI == null) {
  498. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  499. return;
  500. }
  501. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  502. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  503. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  504. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  505. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  506. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  507. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  508. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  509. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  510. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  511. mSdb_LivingRoomLightAPI.SetControlMode(false);
  512. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  513. }
  514. return;
  515. }
  516. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  517. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  518. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  519. return;
  520. }
  521. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  522. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  523. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  524. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  525. } else {
  526. setGlobalScreenAppRunningStatus(false);
  527. }
  528. } else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  529. if (mKnx_LivingRoomLightAPI == null) {
  530. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  531. return;
  532. }
  533. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  534. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  535. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  536. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  537. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  538. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  539. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  540. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  541. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  542. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  543. mKnx_LivingRoomLightAPI.SetControlMode(false);
  544. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  545. }
  546. return;
  547. }
  548. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  549. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  550. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  551. return;
  552. }
  553. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  554. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] LIV_Lights[" + i + "] -> OnOff [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.OnOff + "], Dimming [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.Dimming + "], Color [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.Color + "]");
  555. }
  556. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  557. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  558. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  559. } else {
  560. setGlobalScreenAppRunningStatus(false);
  561. }
  562. } else {
  563. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  564. }
  565. } else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  566. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  567. } else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
  568. int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
  569. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
  570. switch (kind) {
  571. case define.NOTIFY_SCREEN_TOUCHED:
  572. setTimeStamp_ScreenTouched();
  573. break;
  574. case define.NOTIFY_DOOR_OPENED:
  575. setTimeStamp_Magnetic();
  576. break;
  577. }
  578. } else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  579. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
  580. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  581. switch (kind) {
  582. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  583. procUploadMissedVisitorPic(intent);
  584. break;
  585. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  586. // bBlockCallEvent = true;
  587. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  588. break;
  589. case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
  590. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
  591. Sound().Play(SND.mode.OUTMODE_SETTING);
  592. break;
  593. case Common.BR_MAIN_NOTI.SOUND_INMODE:
  594. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
  595. Sound().Play(SND.mode.INMODE_SETTING);
  596. break;
  597. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  598. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  599. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  600. break;
  601. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
  602. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  603. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  604. break;
  605. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
  606. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  607. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  608. break;
  609. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  610. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  611. CallElevatorBtn(false);
  612. break;
  613. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  614. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  615. CallElevatorBtn(true);
  616. break;
  617. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
  618. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  619. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  620. int CalledWallPadUI = intent.getIntExtra("Called", 0);
  621. if (CalledWallPadUI == 1) {
  622. ModeRunCtrlWorking(true, false);
  623. } else {
  624. ModeRunCtrlWorking(false, false);
  625. }
  626. break;
  627. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
  628. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  629. ModeReleaseCtrlWorking(false);
  630. break;
  631. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
  632. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  633. CheckMainStatus();
  634. break;
  635. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
  636. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  637. ModeRunCtrlWorking(false, false);
  638. break;
  639. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
  640. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  641. ModeReleaseCtrlWorking(false);
  642. break;
  643. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
  644. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  645. if (ElevatorUp != null && ElevatorDown != null) {
  646. boolean UpCalling = ElevatorUp.getElevatorCalling();
  647. boolean DownCalling = ElevatorDown.getElevatorCalling();
  648. Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
  649. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  650. if (UpCalling && DownCalling)
  651. Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  652. else if (UpCalling && !DownCalling)
  653. Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  654. else if (!UpCalling && DownCalling)
  655. Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  656. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  657. Log.d(TAG, " ElvCallState : " + ElvCallState);
  658. SendBRElevatorCallState(ElvCallState);
  659. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  660. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  661. // sendIntent.putExtra("ELV", ElvCallState);
  662. // getApplicationContext().sendBroadcast(sendIntent);
  663. }
  664. break;
  665. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  666. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  667. try {
  668. if (ScheServer != null) {
  669. ScheServer.SetLive();
  670. }
  671. } catch (RuntimeException re) {
  672. LogUtil.errorLogInfo("", TAG, re);
  673. } catch (Exception e) {
  674. //e.printStackTrace();
  675. LogUtil.errorLogInfo("", TAG, e);
  676. }
  677. break;
  678. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  679. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  680. stopIGW300RingGenerator();
  681. break;
  682. }
  683. } else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  684. int kind = intent.getIntExtra("KIND", 0);
  685. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
  686. switch (kind) {
  687. case define.NOTIFY_SERVER_VERSION:
  688. try {
  689. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  690. iMapSverReload tSock = new iMapSverReload();
  691. tSock.start();
  692. } catch (IOException e) {
  693. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  694. //e.printStackTrace();
  695. LogUtil.errorLogInfo("", TAG, e);
  696. }
  697. break;
  698. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  699. // 제어기기 엘리베이터 상향 호출 요청
  700. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  701. CallElevatorBtn(true);
  702. break;
  703. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  704. // 제어기기에서 엘리베이터 하향 호출 요청
  705. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  706. CallElevatorBtn(false);
  707. break;
  708. case define.NOTIFY_SUBDEVCALLBUSY:
  709. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  710. CallConnected = true;
  711. break;
  712. case define.NOTIFY_SUBDEVCALLEND:
  713. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  714. CallConnected = false;
  715. break;
  716. case define.NOTIFY_STARTHEARTBEAT:
  717. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  718. {
  719. Message msg = ScheDulerHandler.obtainMessage();
  720. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  721. ScheDulerHandler.sendMessage(msg);
  722. }
  723. break;
  724. case define.NOTIFY_STARTSTATUSBEAT:
  725. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  726. {
  727. Message msg = ScheDulerHandler.obtainMessage();
  728. msg.what = SCHEDULE_START_STATUSBEAT;
  729. ScheDulerHandler.sendMessage(msg);
  730. }
  731. break;
  732. case define.NOTIFY_OUTGOINGSETTED:
  733. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  734. OutGoingSensorWaiting = 0;
  735. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  736. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  737. sdata.closeDB();
  738. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  739. return;
  740. WallPadInterface wpifc = new WallPadInterface();
  741. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
  742. OutGoingSensorWaiting |= SENSOR_MAG;
  743. int[] SensorInfoDB;
  744. int sensorIn = 0;
  745. int sensorOut = 0;
  746. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  747. if (SensorInfoDB[0] == 1) {
  748. // 내부동체가 사용함이면 상태 검사
  749. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
  750. OutGoingSensorWaiting |= SENSOR_IN;
  751. }
  752. if (SensorInfoDB[1] == 1) {
  753. // 외부동체가 사용함이면 상태 검사
  754. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
  755. OutGoingSensorWaiting |= SENSOR_OUT;
  756. }
  757. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  758. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  759. if (OutGoingSensorWaiting > 0) {
  760. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  761. SensorThread.start();
  762. }
  763. break;
  764. case define.NOTIFY_DOOR_SET_DELAY:
  765. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  766. DoorDelayTime = System.currentTimeMillis();
  767. imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
  768. break;
  769. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  770. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  771. Common.setDeviceServeiceLoadComplite();
  772. startRealtimemeterInfo(); // 실시간 검침기 확인
  773. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  774. startDistributionPanel(); // 분전반 확인
  775. getRoomName();
  776. break;
  777. case define.NOTIFY_DLOCK_SET_OUTING:
  778. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  779. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  780. try {
  781. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  782. int AlarmStatus = DBMGR.GetAlarmStatus();
  783. DBMGR.closeDB();
  784. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  785. // 센서 체크하고
  786. // 현관폰으로 사운드 출력하고
  787. boolean bSensorOk = false;
  788. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  789. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  790. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  791. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  792. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  793. bSensorOk = mIGW300.checkSensorforOutmode();
  794. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  795. bSensorOk = mIGW200.checkSensorforOutmode();
  796. } else {
  797. bSensorOk = checkSensorforOutmode();
  798. }
  799. if (bSensorOk) {
  800. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
  801. CallOutModeRunActivity();
  802. } else {
  803. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  804. }
  805. }
  806. } catch (RuntimeException re) {
  807. LogUtil.errorLogInfo("", TAG, re);
  808. } catch (Exception e) {
  809. //e.printStackTrace();
  810. LogUtil.errorLogInfo("", TAG, e);
  811. }
  812. break;
  813. case define.NOTIFY_DLOCK_FREE_OUTING:
  814. // 도어락 외출모드 해제
  815. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  816. try {
  817. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  818. int AlarmStatus = DBMGR.GetAlarmStatus();
  819. DBMGR.closeDB();
  820. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  821. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  822. Common.SendAppFinishReqBR(getApplicationContext());
  823. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  824. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  825. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  826. devDB.closeDB();
  827. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  828. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  829. }
  830. }
  831. } catch (RuntimeException re) {
  832. LogUtil.errorLogInfo("", TAG, re);
  833. } catch (Exception e) {
  834. //e.printStackTrace();
  835. LogUtil.errorLogInfo("", TAG, e);
  836. }
  837. break;
  838. case define.NOTIFY_SMARTSW_SET_OUTING:
  839. // 485 대외향 스마트스위치 외출모드
  840. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  841. setUnoccupiedModeByNotHDCSmartSwitch();
  842. break;
  843. case define.NOTIFY_SMARTSW_FREE_OUTING:
  844. //대외향 485 스마트스위치 외출모드 해제
  845. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  846. releaseUnoccupiedModeByNotHDCSmartSwitch();
  847. break;
  848. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  849. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  850. String Type = intent.getStringExtra("TYPE");
  851. String Device = intent.getStringExtra("DEVICE");
  852. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  853. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  854. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  855. iMAPSmartLightEvent imapSmartLightEvent;
  856. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  857. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  858. imapSmartLightEvent.SetRetCtr(new RetProci() {
  859. @Override
  860. public void ProcSuccess() {
  861. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  862. }
  863. @Override
  864. public void ProcError() {
  865. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  866. }
  867. @Override
  868. public void ProcDoing() {
  869. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  870. }
  871. });
  872. break;
  873. case define.NOTIFY_KNX_DEVICE_EVENT:
  874. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  875. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  876. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  877. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  878. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  879. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  880. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  881. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  882. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  883. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  884. @Override
  885. public void ProcSuccess() {
  886. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  887. }
  888. @Override
  889. public void ProcError() {
  890. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  891. }
  892. @Override
  893. public void ProcDoing() {
  894. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  895. }
  896. });
  897. break;
  898. case define.NOTIFY_SMART_DCAM_DETECT:
  899. // 스마트현관카메라 거동수상자 발생
  900. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  901. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  902. if (!bWallPadCallLive && !bBlockFrontCall) {
  903. if (getStrangerRecordingManagerSetting()) {
  904. if (getStrangerRecordingUserSetting()) {
  905. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  906. Intent Newintent = new Intent();
  907. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  908. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  909. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  910. getApplicationContext().sendBroadcast(Newintent);
  911. } else {
  912. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  913. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  914. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  915. }
  916. } else {
  917. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  918. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  919. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  920. }
  921. } else {
  922. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  923. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  924. Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  925. }
  926. break;
  927. case define.NOTIFY_SMART_DCAM_RELEASE:
  928. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  929. break;
  930. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  931. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  932. if (getStrangerRecordingManagerSetting()) {
  933. if (getStrangerRecordingUserSetting()) {
  934. // 알람 상태 확인
  935. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  936. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  937. mWallpadStatusData.closeDB();
  938. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  939. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  940. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  941. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  942. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  943. } else {
  944. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  945. Intent Newintent = new Intent();
  946. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  947. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  948. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  949. getApplicationContext().sendBroadcast(Newintent);
  950. }
  951. } else {
  952. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  953. }
  954. } else {
  955. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  956. }
  957. break;
  958. case define.NOTIFY_REJECT_RECORD_STRANGER:
  959. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  960. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  961. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  962. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  963. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  964. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  965. }
  966. break;
  967. case define.NOTIFY_ROOMNAME_CHANGED:
  968. getRoomName();
  969. break;
  970. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  971. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  972. break;
  973. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  974. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  975. break;
  976. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  977. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  978. break;
  979. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  980. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  981. break;
  982. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  983. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  984. break;
  985. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  986. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  987. break;
  988. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  989. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  990. break;
  991. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  992. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  993. break;
  994. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  995. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  996. break;
  997. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  998. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  999. break;
  1000. case define.NOTIFY_FINISH_RECORD_STRANGER:
  1001. // 녹화 종료 알림
  1002. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1003. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1004. mWallpadStatusData.closeDB();
  1005. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
  1006. if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
  1007. break;
  1008. case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
  1009. // 사용자 설정화면에서 원격제어시 조명제어 타입 변경
  1010. getDeviceCtrlOption();
  1011. break;
  1012. default:
  1013. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  1014. break;
  1015. }
  1016. }
  1017. } catch (RuntimeException re) {
  1018. LogUtil.errorLogInfo("", TAG, re);
  1019. } catch (Exception e) {
  1020. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1021. //e.printStackTrace();
  1022. LogUtil.errorLogInfo("", TAG, e);
  1023. }
  1024. }
  1025. };
  1026. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1027. try {
  1028. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1029. // 485 대외향 스마트스위치 외출모드
  1030. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1031. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1032. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1033. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1034. mWallpadStatusData.closeDB();
  1035. if (UseGuardSensorCheck == false) {
  1036. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1037. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1038. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1039. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
  1040. mWallpadStatusData.closeDB();
  1041. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1042. //메인화면 업데이트
  1043. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1044. getApplicationContext().sendBroadcast(newIntent);
  1045. ModeRunCtrlWorking(false, false);
  1046. }
  1047. } else {
  1048. // 실제 외출 방범 모드를 설정하도록 한다.
  1049. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1050. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1051. // 센서 체크하고
  1052. // 센서 체크하는 부분이 들어가야 함
  1053. Common.SendAppFinishReqBR(getApplicationContext());
  1054. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  1055. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1056. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1057. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1058. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1059. if (mIGW300.checkSensorforOutmode()) {
  1060. CallOutModeWaitingActivity(AlarmStatus);
  1061. } else {
  1062. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1063. }
  1064. } else {
  1065. if (checkSensorforOutmode()) {
  1066. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1067. CallOutModeWaitingActivity(AlarmStatus);
  1068. } else {
  1069. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
  1070. }
  1071. }
  1072. }
  1073. }
  1074. } catch (RuntimeException re) {
  1075. LogUtil.errorLogInfo("", TAG, re);
  1076. } catch (Exception e) {
  1077. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1078. //e.printStackTrace();
  1079. LogUtil.errorLogInfo("", TAG, e);
  1080. }
  1081. }
  1082. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1083. try {
  1084. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1085. //대외향 485 스마트스위치 외출모드 해제
  1086. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1087. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1088. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1089. mWallpadStatusData.closeDB();
  1090. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
  1091. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1092. if (OutModePwRelease) {
  1093. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1094. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1095. // 요청하여도 해제 되지 않으며
  1096. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1097. Intent notiIntent = new Intent();
  1098. notiIntent.setAction(define.NOTIFY_ACNAME);
  1099. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1100. getApplicationContext().sendBroadcast(notiIntent);
  1101. } else {
  1102. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1103. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1104. // 처리하고.
  1105. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1106. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1107. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1108. mWallpadStatusData.closeDB();
  1109. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1110. Common.SendAppFinishReqBR(getApplicationContext());
  1111. }
  1112. } else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1113. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1114. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1115. ModeReleaseCtrlWorking(false);
  1116. bSmartSwitch485ComebackMode = true;
  1117. Intent notiIntent = new Intent();
  1118. notiIntent.setAction(define.NOTIFY_ACNAME);
  1119. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1120. getApplicationContext().sendBroadcast(notiIntent);
  1121. } else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1122. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1123. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1124. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1125. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1126. mWallpadStatusData.closeDB();
  1127. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1128. //메인화면 업데이트
  1129. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1130. getApplicationContext().sendBroadcast(newIntent);
  1131. ModeReleaseCtrlWorking(false);
  1132. }
  1133. } catch (RuntimeException re) {
  1134. LogUtil.errorLogInfo("", TAG, re);
  1135. } catch (Exception e) {
  1136. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1137. //e.printStackTrace();
  1138. LogUtil.errorLogInfo("", TAG, e);
  1139. }
  1140. }
  1141. /**
  1142. * 스마트현관카메라 녹화 여부 판별
  1143. * 사용자 화면에서 설정
  1144. */
  1145. private boolean getStrangerRecordingUserSetting() {
  1146. boolean bResult = false;
  1147. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1148. try {
  1149. bResult = DBMGR.GetStrangerRecordingOnOff();
  1150. DBMGR.closeDB();
  1151. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1152. } catch (RuntimeException re) {
  1153. LogUtil.errorLogInfo("", TAG, re);
  1154. DBMGR.closeDB();
  1155. bResult = false;
  1156. } catch (Exception e) {
  1157. DBMGR.closeDB();
  1158. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1159. //e.printStackTrace();
  1160. LogUtil.errorLogInfo("", TAG, e);
  1161. bResult = false;
  1162. }
  1163. return bResult;
  1164. }
  1165. private boolean getStrangerTakePic() {
  1166. try {
  1167. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1168. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1169. DBMGR.closeDB();
  1170. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1171. return bResult;
  1172. } catch (RuntimeException re) {
  1173. LogUtil.errorLogInfo("", TAG, re);
  1174. return false;
  1175. } catch (Exception e) {
  1176. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1177. //e.printStackTrace();
  1178. LogUtil.errorLogInfo("", TAG, e);
  1179. return false;
  1180. }
  1181. }
  1182. // 관리자 설정 항목에 있음
  1183. private boolean getStrangerRecordUsage() {
  1184. try {
  1185. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1186. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1187. mWallpadDeviceSet.closeDB();
  1188. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1189. return bResult;
  1190. } catch (RuntimeException re) {
  1191. LogUtil.errorLogInfo("", TAG, re);
  1192. return false;
  1193. } catch (Exception e) {
  1194. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1195. //e.printStackTrace();
  1196. LogUtil.errorLogInfo("", TAG, e);
  1197. return false;
  1198. }
  1199. }
  1200. private boolean checkSensorforOutmode() {
  1201. try {
  1202. WallPadInterface wallPadInterface = new WallPadInterface();
  1203. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1204. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1205. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1206. int[] SensorInfoDB;
  1207. int sensorIn = 0;
  1208. int sensorOut = 0;
  1209. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1210. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1211. if (SensorInfoDB[0] == 1) {
  1212. // 내부동체가 사용함이면 상태 검사
  1213. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1214. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1215. }
  1216. if (SensorInfoDB[1] == 1) {
  1217. // 외부동체가 사용함이면 상태 검사
  1218. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1219. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1220. }
  1221. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1222. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1223. // 동체 사용 설정 체크..
  1224. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1225. int sensor = devSet.Get_Sensor_Set();
  1226. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1227. devSet.closeDB();
  1228. int OtherInSensor = 0;
  1229. // 내부동체 사용안함 이면
  1230. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1231. // 외부동체 사용안함 이면
  1232. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1233. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1234. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1235. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1236. return true;
  1237. } else {
  1238. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1239. return false;
  1240. }
  1241. } catch (RuntimeException re) {
  1242. LogUtil.errorLogInfo("", TAG, re);
  1243. return false;
  1244. } catch (Exception e) {
  1245. //e.printStackTrace();
  1246. LogUtil.errorLogInfo("", TAG, e);
  1247. return false;
  1248. }
  1249. }
  1250. private boolean checkSensorforInmode() {
  1251. try {
  1252. WallPadInterface wallPadInterface = new WallPadInterface();
  1253. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1254. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1255. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1256. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1257. if (sensorMag == 0) {
  1258. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1259. return true;
  1260. } else {
  1261. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1262. return false;
  1263. }
  1264. } catch (RuntimeException re) {
  1265. LogUtil.errorLogInfo("", TAG, re);
  1266. return false;
  1267. } catch (Exception e) {
  1268. Log.e(TAG, e.toString());
  1269. //e.printStackTrace();
  1270. LogUtil.errorLogInfo("", TAG, e);
  1271. return false;
  1272. }
  1273. }
  1274. /////////////////////
  1275. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1276. //////////////
  1277. /////////////////////
  1278. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1279. //////////////
  1280. public void playSoundthroughDoorphone(int SoundIdx) {
  1281. try {
  1282. WallPadInterface Wiface = new WallPadInterface();
  1283. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1284. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  1285. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1286. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1287. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1288. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1289. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1290. if (getUseSmartDoorCam()) {
  1291. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1292. }
  1293. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1294. /*
  1295. JEFF (2019.01.14)
  1296. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1297. 강신구입니다.
  1298. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1299. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1300. 내용 공유합니다.
  1301. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1302. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1303. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1304. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1305. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1306. 문제 없습니다.
  1307. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1308. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1309. 문의사항은 하기 연락바랍니다.
  1310. 감사합니다.
  1311. */
  1312. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1313. } else {
  1314. // 대외향 모델 처리
  1315. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
  1316. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1317. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1318. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1319. }
  1320. try {
  1321. Thread.sleep(100);
  1322. } catch (RuntimeException re) {
  1323. LogUtil.errorLogInfo("", TAG, re);
  1324. } catch (Exception e) {
  1325. LogUtil.errorLogInfo("", TAG, e);
  1326. }
  1327. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1328. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1329. try {
  1330. Thread.sleep(1500);
  1331. } catch (RuntimeException re) {
  1332. LogUtil.errorLogInfo("", TAG, re);
  1333. } catch (Exception e) {
  1334. LogUtil.errorLogInfo("", TAG, e);
  1335. }
  1336. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1337. int SLevel = Wdb.GetDoorSoundLevel();
  1338. Wdb.closeDB();
  1339. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1340. if (SLevel != -1) {
  1341. /**
  1342. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1343. * **/
  1344. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1345. } else {
  1346. // 사용안함이면
  1347. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1348. }
  1349. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1350. int time = Sound().PlayMent(SoundIdx);
  1351. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1352. if (0 > time) {
  1353. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1354. time = 1000;
  1355. }
  1356. try {
  1357. Thread.sleep(time + 1000);
  1358. } catch (RuntimeException re) {
  1359. LogUtil.errorLogInfo("", TAG, re);
  1360. } catch (Exception e) {
  1361. LogUtil.errorLogInfo("", TAG, e);
  1362. }
  1363. amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1364. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1365. try {
  1366. Thread.sleep(100);
  1367. } catch (RuntimeException re) {
  1368. LogUtil.errorLogInfo("", TAG, re);
  1369. } catch (Exception e) {
  1370. LogUtil.errorLogInfo("", TAG, e);
  1371. }
  1372. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  1373. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1374. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1375. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1376. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1377. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1378. if (getUseSmartDoorCam()) {
  1379. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1380. }
  1381. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1382. /*
  1383. JEFF (2019.01.14)
  1384. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1385. 강신구입니다.
  1386. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1387. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1388. 내용 공유합니다.
  1389. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1390. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1391. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1392. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1393. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1394. 문제 없습니다.
  1395. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1396. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1397. 문의사항은 하기 연락바랍니다.
  1398. 감사합니다.
  1399. */
  1400. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1401. } else {
  1402. // 대외향 모델 처리
  1403. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1404. if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1405. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1406. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1407. }
  1408. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1409. } catch (RuntimeException re) {
  1410. LogUtil.errorLogInfo("", TAG, re);
  1411. } catch (Exception e) {
  1412. //e.printStackTrace();
  1413. LogUtil.errorLogInfo("", TAG, e);
  1414. }
  1415. }
  1416. public void CallOutModeRunActivity() {
  1417. int base = 8000;
  1418. int[] Menu_Id_List = {base + 11};
  1419. int Menu_StartId = base + 11;
  1420. int Menu_Option = -1;
  1421. Intent intent = new Intent(Intent.ACTION_MAIN);
  1422. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1423. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1424. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1425. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1426. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1427. startActivity(intent);
  1428. }
  1429. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1430. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1431. int base = 4000;
  1432. int[] Menu_Id_List = {base + 11, base + 21};
  1433. int Menu_StartId = base + 11;
  1434. int Menu_Option = 1000;
  1435. Intent intent = new Intent(Intent.ACTION_MAIN);
  1436. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1437. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1438. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1439. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1440. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  1441. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1442. startActivity(intent);
  1443. }
  1444. private boolean getGlobalScreenAppRunningStatus() {
  1445. boolean bRunning = false;
  1446. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1447. try {
  1448. bRunning = DBMGR.getGlobalScreenAPKRun();
  1449. DBMGR.closeDB();
  1450. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1451. return bRunning;
  1452. } catch (RuntimeException re) {
  1453. LogUtil.errorLogInfo("", TAG, re);
  1454. DBMGR.closeDB();
  1455. } catch (Exception e) {
  1456. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1457. //e.printStackTrace();
  1458. LogUtil.errorLogInfo("", TAG, e);
  1459. DBMGR.closeDB();
  1460. }
  1461. return bRunning;
  1462. }
  1463. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1464. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1465. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1466. try {
  1467. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1468. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1469. DBMGR.closeDB();
  1470. } catch (RuntimeException re) {
  1471. LogUtil.errorLogInfo("", TAG, re);
  1472. DBMGR.closeDB();
  1473. } catch (Exception e) {
  1474. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1475. //e.printStackTrace();
  1476. LogUtil.errorLogInfo("", TAG, e);
  1477. DBMGR.closeDB();
  1478. }
  1479. }
  1480. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1481. boolean bGlobalScreenRun = false;
  1482. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1483. try {
  1484. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1485. wakeupLCD();
  1486. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1487. setGlobalScreenAppRunningStatus(true);
  1488. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1489. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1490. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1491. mIntent.putExtra("ONOFF", hOnOff);
  1492. mIntent.putExtra("DIAL", hDial);
  1493. mIntent.putExtra("LEVEL", hLevel);
  1494. mIntent.putExtra("COLOR", hColor);
  1495. mIntent.putExtra("CONTROL", hControl);
  1496. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1497. mIntent.setComponent(mComponentName);
  1498. startActivity(mIntent);
  1499. } else {
  1500. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1501. }
  1502. } catch (RuntimeException re) {
  1503. LogUtil.errorLogInfo("", TAG, re);
  1504. } catch (Exception e) {
  1505. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1506. //e.printStackTrace();
  1507. LogUtil.errorLogInfo("", TAG, e);
  1508. }
  1509. }
  1510. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1511. try {
  1512. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
  1513. wakeupLCD();
  1514. if (!getGlobalScreenAppRunningStatus()) {
  1515. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1516. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1517. return;
  1518. }
  1519. setGlobalScreenAppRunningStatus(true);
  1520. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1521. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1522. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1523. mIntent.putExtra("SCREENID", nScreenID);
  1524. mIntent.putExtra("ONOFF", hOnOff);
  1525. mIntent.putExtra("DIAL", hDial);
  1526. mIntent.putExtra("LEVEL", hLevel);
  1527. mIntent.putExtra("COLOR", hColor);
  1528. mIntent.putExtra("CONTROL", hControl);
  1529. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1530. mIntent.setComponent(mComponentName);
  1531. startActivity(mIntent);
  1532. } else {
  1533. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1534. }
  1535. } catch (RuntimeException re) {
  1536. LogUtil.errorLogInfo("", TAG, re);
  1537. } catch (Exception e) {
  1538. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1539. //e.printStackTrace();
  1540. LogUtil.errorLogInfo("", TAG, e);
  1541. }
  1542. }
  1543. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1544. public void sendBlackoutReleasedBR() {
  1545. try {
  1546. Intent notiIntent = new Intent();
  1547. notiIntent.setAction(strBLACKOUT_RELEASED);
  1548. getApplicationContext().sendBroadcast(notiIntent);
  1549. } catch (RuntimeException re) {
  1550. LogUtil.errorLogInfo("", TAG, re);
  1551. } catch (Exception e) {
  1552. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1553. //e.printStackTrace();
  1554. LogUtil.errorLogInfo("", TAG, e);
  1555. }
  1556. }
  1557. private int getCurrentScreen() {
  1558. int nScreenID = 0;
  1559. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1560. try {
  1561. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1562. DBMGR.closeDB();
  1563. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1564. return nScreenID;
  1565. } catch (RuntimeException re) {
  1566. LogUtil.errorLogInfo("", TAG, re);
  1567. DBMGR.closeDB();
  1568. } catch (Exception e) {
  1569. Log.e(TAG, "[Exception] getCurrentScreen()");
  1570. //e.printStackTrace();
  1571. LogUtil.errorLogInfo("", TAG, e);
  1572. DBMGR.closeDB();
  1573. }
  1574. return nScreenID;
  1575. }
  1576. private void setCurrentScreen(int nScreenID) {
  1577. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1578. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1579. try {
  1580. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1581. DBMGR.closeDB();
  1582. } catch (RuntimeException re) {
  1583. LogUtil.errorLogInfo("", TAG, re);
  1584. DBMGR.closeDB();
  1585. } catch (Exception e) {
  1586. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1587. //e.printStackTrace();
  1588. LogUtil.errorLogInfo("", TAG, e);
  1589. DBMGR.closeDB();
  1590. }
  1591. }
  1592. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1593. private void procUploadMissedVisitorPic(Intent intent) {
  1594. try {
  1595. String strDong = intent.getStringExtra("DONG");
  1596. String strHo = intent.getStringExtra("HO");
  1597. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1598. int nCnt = intent.getIntExtra("CNT", 0);
  1599. String[] strMissedPicURI = new String[nCnt];
  1600. strArrayMissedPicURI.clear();
  1601. for (int i = 0; i < nCnt; i++) {
  1602. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1603. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1604. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1605. }
  1606. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1607. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1608. }
  1609. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1610. } catch (RuntimeException re) {
  1611. LogUtil.errorLogInfo("", TAG, re);
  1612. } catch (Exception e) {
  1613. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1614. //e.printStackTrace();
  1615. LogUtil.errorLogInfo("", TAG, e);
  1616. }
  1617. }
  1618. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1619. try {
  1620. String strURI = "", strFileName = "", strTime = "", strType = "";
  1621. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1622. // strURI = strArrayMissedPicURI.get(i).toString();
  1623. // strFileName = extractFileName(strURI);
  1624. // strTime = extractFileTime(strURI);
  1625. // strType = extractCallType(strFileName);
  1626. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1627. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1628. // }
  1629. if (strArrayMissedPicURI.size() > 0) {
  1630. strURI = strArrayMissedPicURI.get(0).toString();
  1631. strFileName = extractFileName(strURI);
  1632. strTime = extractFileTime(strFileName);
  1633. strType = extractCallType(strFileName);
  1634. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1635. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1636. } else {
  1637. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1638. }
  1639. } catch (RuntimeException re) {
  1640. LogUtil.errorLogInfo("", TAG, re);
  1641. } catch (Exception e) {
  1642. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1643. //e.printStackTrace();
  1644. LogUtil.errorLogInfo("", TAG, e);
  1645. }
  1646. }
  1647. public class uploadVisitorPicture extends Thread {
  1648. HDCFTPManager mFTPManager;
  1649. boolean bMainServer2dot0 = false;
  1650. String strRemoteIP = "10.0.1.1";
  1651. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1652. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1653. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1654. try {
  1655. strDong = dong;
  1656. strHo = ho;
  1657. strType = type;
  1658. strTime = time;
  1659. strFileName = filename;
  1660. strUploadFile = uploadfile;
  1661. bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1662. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1663. wallpadDeviceSet.closeDB();
  1664. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
  1665. } catch (RuntimeException re) {
  1666. LogUtil.errorLogInfo("", TAG, re);
  1667. } catch (Exception e) {
  1668. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1669. //e.printStackTrace();
  1670. LogUtil.errorLogInfo("", TAG, e);
  1671. }
  1672. }
  1673. public void run() {
  1674. try {
  1675. mFTPManager = new HDCFTPManager();
  1676. if (!mFTPManager.isFTPConnected()) {
  1677. if (!mFTPManager.connectFTP(strRemoteIP)) {
  1678. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1679. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1680. return;
  1681. }
  1682. }
  1683. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1684. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1685. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1686. return;
  1687. }
  1688. if (!bMainServer2dot0) {
  1689. if (!mFTPManager.setPassiveMode()) {
  1690. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1691. disconnectFTP();
  1692. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1693. return;
  1694. }
  1695. }
  1696. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1697. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1698. disconnectFTP();
  1699. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1700. return;
  1701. }
  1702. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1703. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1704. disconnectFTP();
  1705. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1706. return;
  1707. }
  1708. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1709. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1710. disconnectFTP();
  1711. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1712. return;
  1713. }
  1714. disconnectFTP();
  1715. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1716. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1717. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1718. } catch (RuntimeException re) {
  1719. LogUtil.errorLogInfo("", TAG, re);
  1720. } catch (Exception e) {
  1721. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1722. //e.printStackTrace();
  1723. LogUtil.errorLogInfo("", TAG, e);
  1724. }
  1725. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1726. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1727. }
  1728. public boolean disconnectFTP() {
  1729. try {
  1730. if (mFTPManager.logoutFTP()) {
  1731. if (mFTPManager.disconnectFTP()) {
  1732. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1733. return true;
  1734. }
  1735. }
  1736. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1737. return false;
  1738. } catch (RuntimeException re) {
  1739. LogUtil.errorLogInfo("", TAG, re);
  1740. return false;
  1741. } catch (Exception e) {
  1742. Log.e(TAG, "[Exception] disconnectFTP()");
  1743. //e.printStackTrace();
  1744. LogUtil.errorLogInfo("", TAG, e);
  1745. return false;
  1746. }
  1747. }
  1748. }
  1749. private String extractCallType(String strFileName) {
  1750. try {
  1751. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1752. String[] strParse_01 = strFileName.split("_");
  1753. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1754. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1755. else return "none";
  1756. } catch (RuntimeException re) {
  1757. LogUtil.errorLogInfo("", TAG, re);
  1758. return null;
  1759. } catch (Exception e) {
  1760. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1761. //e.printStackTrace();
  1762. LogUtil.errorLogInfo("", TAG, e);
  1763. return null;
  1764. }
  1765. }
  1766. private String extractFileName(String strTargetFile) {
  1767. try {
  1768. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1769. String[] strParse_01 = strTargetFile.split("/");
  1770. return strParse_01[strParse_01.length - 1];
  1771. } catch (RuntimeException re) {
  1772. LogUtil.errorLogInfo("", TAG, re);
  1773. return null;
  1774. } catch (Exception e) {
  1775. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1776. //e.printStackTrace();
  1777. LogUtil.errorLogInfo("", TAG, e);
  1778. return null;
  1779. }
  1780. }
  1781. private String extractFileTime(String strFileName) {
  1782. try {
  1783. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1784. String[] strParse_01 = strFileName.split("\\.");
  1785. String[] strParse_02 = strParse_01[0].split("_");
  1786. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1787. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1788. // strTime = strParse_03[5].substring(0, 4) + "." + strParse_03[5].substring(4, 6) + "." + strParse_03[5].substring(6) + "." + strParse_03[6].substring(0, 2) + "." + strParse_03[6].substring(2, 4) + "." + strParse_03[6].substring(4);
  1789. return strParse_02[5] + "_" + strParse_02[6];
  1790. } catch (RuntimeException re) {
  1791. LogUtil.errorLogInfo("", TAG, re);
  1792. return null;
  1793. } catch (Exception e) {
  1794. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1795. //e.printStackTrace();
  1796. LogUtil.errorLogInfo("", TAG, e);
  1797. return null;
  1798. }
  1799. }
  1800. String strRemoteURI, strUserID, strPW, strPath;
  1801. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1802. String strKey_Pass = "passwd";
  1803. public boolean send_visitor_access_info_request(final String strDong, final String strHo, final String strType, final String strTime, final String strFileName, String strMessage, final String strFilePath) {
  1804. try {
  1805. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1806. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1807. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1808. visitor_access_info.setResultCtrl(new RetProci() {
  1809. @Override
  1810. public void ProcSuccess() {
  1811. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1812. visitor_access_info.SetItem("ftp_info");
  1813. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1814. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1815. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1816. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1817. strUserID = strReply_User;
  1818. strPW = strReply_PW;
  1819. strPath = strReply_Path;
  1820. strRemoteURI = strPath + "/" + strFileName;
  1821. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1822. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1823. mUploadVisitorPicture.start();
  1824. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1825. // mUploadVisitorPicture.start();
  1826. }
  1827. @Override
  1828. public void ProcError() {
  1829. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1830. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1831. sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
  1832. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1833. }
  1834. @Override
  1835. public void ProcDoing() {
  1836. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1837. }
  1838. });
  1839. return true;
  1840. }
  1841. } catch (RuntimeException re) {
  1842. LogUtil.errorLogInfo("", TAG, re);
  1843. } catch (Exception e) {
  1844. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1845. //e.printStackTrace();
  1846. LogUtil.errorLogInfo("", TAG, e);
  1847. }
  1848. return false;
  1849. }
  1850. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1851. try {
  1852. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1853. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1854. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1855. visitor_upload_complete.setResultCtrl(new RetProci() {
  1856. @Override
  1857. public void ProcSuccess() {
  1858. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1859. }
  1860. @Override
  1861. public void ProcError() {
  1862. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1863. }
  1864. @Override
  1865. public void ProcDoing() {
  1866. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1867. }
  1868. });
  1869. return true;
  1870. }
  1871. } catch (RuntimeException re) {
  1872. LogUtil.errorLogInfo("", TAG, re);
  1873. } catch (Exception e) {
  1874. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1875. //e.printStackTrace();
  1876. LogUtil.errorLogInfo("", TAG, e);
  1877. }
  1878. return false;
  1879. }
  1880. /**
  1881. * 이통사 연동 서비스를 위한 BR
  1882. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1883. *
  1884. * @param kind (String) "lobby" or "home"
  1885. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1886. */
  1887. public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
  1888. try {
  1889. Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
  1890. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1891. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1892. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1893. Intent mIntent = new Intent();
  1894. mIntent.setAction(BR_VISITOR_EVENT);
  1895. mIntent.putExtra("KIND", kind);
  1896. mIntent.putExtra("TIME", datetime);
  1897. mIntent.putExtra("FILENAME", filename);
  1898. getApplicationContext().sendBroadcast(mIntent);
  1899. } catch (RuntimeException re) {
  1900. LogUtil.errorLogInfo("", TAG, re);
  1901. } catch (Exception e) {
  1902. Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
  1903. //e.printStackTrace();
  1904. LogUtil.errorLogInfo("", TAG, e);
  1905. }
  1906. }
  1907. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1908. public void onReceive(Context context, Intent intent) {
  1909. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1910. Bundle bundle;
  1911. WallpadDeviceSet devset;
  1912. Intent newintent;
  1913. boolean CallAppRun = false;
  1914. boolean MgrAppRun = false;
  1915. final String packageName = "com.artncore.apps.ic_wallpad";
  1916. final String packageNameMgr = "com.artncore.managersetting";
  1917. //CallAppRun = getForegroundAPK().equals(packageName);
  1918. // CallAppRun = getCallAppRunning();
  1919. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1920. int base = 7000;
  1921. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  1922. int Menu_Start_Option = 1;
  1923. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1924. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  1925. int keyevt = ReceiveEvt.getKeyCode();
  1926. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  1927. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1928. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  1929. sdata.closeDB();
  1930. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1931. return;
  1932. }
  1933. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1934. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  1935. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1936. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  1937. mWallpadStatusData.closeDB();
  1938. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  1939. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  1940. sdata.closeDB();
  1941. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  1942. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  1943. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  1944. int nModelType = Version.getModelType();
  1945. switch (ReceiveEvt.getKeyCode()) {
  1946. case 251: // 현산향 비상버튼 다운 업 처리
  1947. try {
  1948. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  1949. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  1950. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  1951. } else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  1952. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  1953. }
  1954. }
  1955. } catch (RuntimeException re) {
  1956. LogUtil.errorLogInfo("", TAG, re);
  1957. } catch (Exception e) {
  1958. //e.printStackTrace();
  1959. LogUtil.errorLogInfo("", TAG, e);
  1960. }
  1961. break;
  1962. case WallPadInterface.EVT_RING:
  1963. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  1964. Log.w(TAG, "########## PSTN EVT_RING ##########");
  1965. // 전화 수신 링 수신
  1966. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1967. if (Version.getGatewayUsage()) {
  1968. // 국선 시작만 올라온다.
  1969. startIGW300RingGenerator();
  1970. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1971. } else {
  1972. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  1973. }
  1974. break;
  1975. case WallPadInterface.EVT_END_RING:
  1976. // 전화 수신 링 종료
  1977. // Jeff added below codes for call app (2018.01.25)
  1978. // This event is managed by WallPadCall
  1979. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  1980. if (Version.getGatewayUsage()) {
  1981. stopIGW300RingGenerator();
  1982. }
  1983. break;
  1984. case WallPadInterface.BTN_EMR:
  1985. case WallPadInterface.BTN_EMR_IHN1010:
  1986. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  1987. // 월패드 비상버튼 입력 SA 와 GLE 공통
  1988. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  1989. if (MgrAppRun) return;
  1990. if (Common.DIAGNOSTIC_MODE) return;
  1991. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  1992. return;
  1993. //currentTime = System.currentTimeMillis();
  1994. //if (ALERTTIME > currentTime) break;
  1995. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  1996. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  1997. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  1998. break;
  1999. devset = new WallpadDeviceSet(getApplicationContext());
  2000. int StatusVal = devset.GetDeviceSetted("알람발생");
  2001. devset.closeDB();
  2002. Log.d("imap", "StatusVal : " + StatusVal);
  2003. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2004. // 보안 처리가 필요함..
  2005. // 지속적으로 이벤트가 들어올 경우 대비
  2006. Common.SendAppFinishReqBR(getApplicationContext());
  2007. newintent = new Intent(Intent.ACTION_MAIN);
  2008. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2009. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2010. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2011. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2012. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2013. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2014. iMAPstartActivity(newintent);
  2015. }
  2016. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2017. if (getIsSubWallpad()) {
  2018. Intent notiIntent = new Intent();
  2019. notiIntent.setAction(define.NOTIFY_ACNAME);
  2020. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2021. getApplicationContext().sendBroadcast(notiIntent);
  2022. }
  2023. break;
  2024. case WallPadInterface.BTN_CALL:
  2025. case WallPadInterface.BTN_CALL_IHN1010:
  2026. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2027. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2028. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2029. // Jeff added below codes for call app (2018.01.25)
  2030. try {
  2031. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2032. if (getIsSubWallpad()) {
  2033. // 서브월패드
  2034. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2035. } else {
  2036. // 메인월패드
  2037. if (MainActivity.bRecordStatus) {
  2038. // 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2039. Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2040. Intent iIntent = new Intent();
  2041. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2042. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
  2043. getApplicationContext().sendBroadcast(iIntent);
  2044. }
  2045. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2046. }
  2047. } catch (RuntimeException re) {
  2048. LogUtil.errorLogInfo("", TAG, re);
  2049. } catch (Exception e) {
  2050. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2051. //e.printStackTrace();
  2052. LogUtil.errorLogInfo("", TAG, e);
  2053. }
  2054. break;
  2055. case WallPadInterface.BTN_OPEN:
  2056. // 월패드 문여림 버튼 입력 상태 SA
  2057. break;
  2058. case WallPadInterface.BTN_DOOR:
  2059. case WallPadInterface.BTN_DOOR_IHN1010:
  2060. // 현관 도어폰 벨 눌림 입력 상태
  2061. // Jeff added below codes for call app (2018.01.25)
  2062. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2063. if (!bWallPadCallLive && !bBlockFrontCall) {
  2064. if (MainActivity.bRecordStatus) {
  2065. // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2066. Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
  2067. Intent iIntent = new Intent();
  2068. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2069. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
  2070. getApplicationContext().sendBroadcast(iIntent);
  2071. }
  2072. bBlockFrontCall = true;
  2073. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2074. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2075. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2076. try {
  2077. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2078. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2079. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2080. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  2081. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2082. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2083. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2084. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2085. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2086. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2087. }
  2088. if (!Version.getGatewayUsage()) {
  2089. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2090. }
  2091. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2092. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2093. } catch (RuntimeException re) {
  2094. LogUtil.errorLogInfo("", TAG, re);
  2095. } catch (Exception e) {
  2096. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2097. //e.printStackTrace();
  2098. LogUtil.errorLogInfo("", TAG, e);
  2099. }
  2100. } else {
  2101. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2102. }
  2103. break;
  2104. case WallPadInterface.BTN_CAMERA_SET:
  2105. Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
  2106. Intent iIntent = new Intent();
  2107. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2108. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
  2109. getApplicationContext().sendBroadcast(iIntent);
  2110. break;
  2111. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2112. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
  2113. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2114. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
  2115. && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
  2116. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2117. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2118. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2119. if (MgrAppRun) return;
  2120. if (Common.DIAGNOSTIC_MODE) return;
  2121. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  2122. return;
  2123. //currentTime = System.currentTimeMillis();
  2124. //if (ALERTTIME > currentTime) break;
  2125. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2126. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2127. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2128. break;
  2129. devset = new WallpadDeviceSet(getApplicationContext());
  2130. StatusVal = devset.GetDeviceSetted("알람발생");
  2131. devset.closeDB();
  2132. Log.d("imap", "StatusVal : " + StatusVal);
  2133. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2134. // 보안 처리가 필요함..
  2135. // 지속적으로 이벤트가 들어올 경우 대비
  2136. Common.SendAppFinishReqBR(getApplicationContext());
  2137. newintent = new Intent(Intent.ACTION_MAIN);
  2138. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2139. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2140. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2141. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2142. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2143. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2144. iMAPstartActivity(newintent);
  2145. }
  2146. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2147. if (getIsSubWallpad()) {
  2148. Intent notiIntent = new Intent();
  2149. notiIntent.setAction(define.NOTIFY_ACNAME);
  2150. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2151. getApplicationContext().sendBroadcast(notiIntent);
  2152. }
  2153. } else {
  2154. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2155. if (!getEmergencyIOUsage()) {
  2156. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2157. return;
  2158. }
  2159. if (MgrAppRun) {
  2160. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2161. return;
  2162. }
  2163. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2164. break;
  2165. devset = new WallpadDeviceSet(getApplicationContext());
  2166. StatusVal = devset.GetDeviceSetted("알람발생");
  2167. devset.closeDB();
  2168. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2169. Common.SendAppFinishReqBR(getApplicationContext());
  2170. newintent = new Intent(Intent.ACTION_MAIN);
  2171. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2172. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2173. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2174. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2175. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2176. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2177. iMAPstartActivity(newintent);
  2178. }
  2179. }
  2180. break;
  2181. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2182. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2183. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2184. // 대외향의 경우 여기에서 마그네틱이 감지된다.
  2185. if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
  2186. if (MgrAppRun) return;
  2187. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2188. WallPadInterface mWallPadInterface = new WallPadInterface();
  2189. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2190. if (sensorMag == 0) return;
  2191. }
  2192. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2193. break;
  2194. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2195. break;
  2196. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2197. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2198. if (OutGoingSensorWaiting == 0) {
  2199. // wakeupLCD();
  2200. mIOInterface.ctrlLcdWakeUp();
  2201. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2202. SensorThread.start();
  2203. }
  2204. OutGoingSensorWaiting |= SENSOR_MAG;
  2205. } else {
  2206. Common.SendAppFinishReqBR(getApplicationContext());
  2207. newintent = new Intent(Intent.ACTION_MAIN);
  2208. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2209. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2210. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2211. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2212. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2213. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2214. iMAPstartActivity(newintent);
  2215. }
  2216. break;
  2217. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2218. saveBlackoutStatus(true);
  2219. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2220. break;
  2221. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2222. saveBlackoutStatus(false);
  2223. sendBlackoutReleasedBR();
  2224. break;
  2225. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2226. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2227. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2228. if (MgrAppRun) return;
  2229. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2230. break;
  2231. devset = new WallpadDeviceSet(getApplicationContext());
  2232. StatusVal = devset.GetDeviceSetted("피난사다리");
  2233. int LadderSend = devset.getEscapeLadderDownSend();
  2234. String pentHouseHo = devset.getPentHouseHoEscapeLadder();
  2235. devset.closeDB();
  2236. Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
  2237. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2238. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2239. Common.SendAppFinishReqBR(getApplicationContext());
  2240. newintent = new Intent(Intent.ACTION_MAIN);
  2241. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2242. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2243. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2244. if (!pentHouseHo.equals("")) {
  2245. // 윗집이 펜트하우스인 경우
  2246. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2247. } else {
  2248. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  2249. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2250. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  2251. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2252. }
  2253. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2254. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2255. iMAPstartActivity(newintent);
  2256. }
  2257. break;
  2258. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2259. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2260. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2261. {
  2262. // 내부동체가 상태가 변경된 경우
  2263. int[] SensorInfoDB;
  2264. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2265. if (SensorInfoDB[0] != 1) {
  2266. //내부동체가 사용함이면 상태 검사
  2267. return;
  2268. }
  2269. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2270. WallPadInterface mWallPadInterface = new WallPadInterface();
  2271. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2272. if (sensorMag == 0) return;
  2273. }
  2274. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2275. int sensor = devSet.Get_Sensor_Set();
  2276. devSet.closeDB();
  2277. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2278. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2279. break;
  2280. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2281. if (OutGoingSensorWaiting == 0) {
  2282. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2283. SensorThread.start();
  2284. }
  2285. OutGoingSensorWaiting |= SENSOR_IN;
  2286. }
  2287. break;
  2288. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2289. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2290. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2291. {
  2292. // 외부동체가 상태가 변경된 경우
  2293. int[] SensorInfoDB;
  2294. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2295. if (SensorInfoDB[1] != 1) {
  2296. // 외부동체가 사용함이면 상태 검사
  2297. return;
  2298. }
  2299. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
  2300. WallPadInterface mWallPadInterface = new WallPadInterface();
  2301. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2302. if (sensorMag == 0) return;
  2303. }
  2304. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2305. int sensor = devSet.Get_Sensor_Set();
  2306. devSet.closeDB();
  2307. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2308. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2309. break;
  2310. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
  2311. break;
  2312. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2313. break;
  2314. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2315. {
  2316. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2317. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2318. break;
  2319. }*/
  2320. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2321. if (OutGoingSensorWaiting == 0) {
  2322. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2323. SensorThread.start();
  2324. }
  2325. OutGoingSensorWaiting |= SENSOR_OUT;
  2326. } else {
  2327. Common.SendAppFinishReqBR(getApplicationContext());
  2328. newintent = new Intent(Intent.ACTION_MAIN);
  2329. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2330. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2331. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2332. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
  2333. newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2334. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2335. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2336. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2337. iMAPstartActivity(newintent);
  2338. }
  2339. }
  2340. break;
  2341. }
  2342. } else {
  2343. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2344. }
  2345. }
  2346. };
  2347. protected void iMAPstartActivity(Intent intent) {
  2348. try {
  2349. startActivity(intent);
  2350. } catch (RuntimeException re) {
  2351. LogUtil.errorLogInfo("", TAG, re);
  2352. } catch (Exception e) {
  2353. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2354. //e.printStackTrace();
  2355. LogUtil.errorLogInfo("", TAG, e);
  2356. }
  2357. }
  2358. /**
  2359. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2360. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2361. * 1. 현관카메라 키이벤트 수신
  2362. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2363. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2364. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2365. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2366. * 6. 시스템 볼륨 원복
  2367. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2368. */
  2369. AudioManager mAudioManager;
  2370. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2371. Handler mDingDongHandler = new Handler() {
  2372. public void handleMessage(Message msg) {
  2373. try {
  2374. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2375. if (msg.what == 0) {
  2376. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2377. int nVolume = 10;
  2378. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
  2379. nVolume = 12;
  2380. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2381. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2382. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2383. mDingDongHandler.sendEmptyMessage(1);
  2384. } else if (msg.what == 1) {
  2385. // 띵똥 패스 체크
  2386. check1++;
  2387. if (check1 > 200) {
  2388. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2389. finishDingDongHandler();
  2390. check1 = 0;
  2391. return;
  2392. } else {
  2393. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2394. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2395. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2396. }
  2397. } else if (msg.what == 2) {
  2398. // 띵똥 음원 재생
  2399. mIOInterface.ctrlSetTalkPathDoor();
  2400. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2401. } else if (msg.what == 3) {
  2402. mIOInterface.ctrlSetTalkPathNormal();
  2403. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2404. mDingDongHandler.sendEmptyMessage(4);
  2405. } else if (msg.what == 4) {
  2406. // Normal 패스 체크
  2407. check2++;
  2408. if (check2 > 200) {
  2409. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2410. finishDingDongHandler();
  2411. check2 = 0;
  2412. return;
  2413. } else {
  2414. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2415. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2416. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2417. }
  2418. } else if (msg.what == 5) {
  2419. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2420. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2421. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2422. wdb.closeDB();
  2423. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2424. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2425. intent.setAction(define.NOTIFY_ACNAME);
  2426. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2427. sendBroadcast(intent);
  2428. }
  2429. } catch (RuntimeException re) {
  2430. LogUtil.errorLogInfo("", TAG, re);
  2431. finishDingDongHandler();
  2432. } catch (Exception e) {
  2433. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2434. //e.printStackTrace();
  2435. LogUtil.errorLogInfo("", TAG, e);
  2436. finishDingDongHandler();
  2437. }
  2438. }
  2439. };
  2440. private void finishDingDongHandler() {
  2441. try {
  2442. Log.d(TAG, "[finishDingDongHandler]");
  2443. if (mDingDongHandler != null) {
  2444. mDingDongHandler.removeMessages(0);
  2445. mDingDongHandler.removeMessages(1);
  2446. mDingDongHandler.removeMessages(2);
  2447. mDingDongHandler.removeMessages(3);
  2448. mDingDongHandler.removeMessages(4);
  2449. mDingDongHandler.removeMessages(5);
  2450. }
  2451. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2452. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2453. wdb.closeDB();
  2454. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2455. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2456. mIOInterface.ctrlSetTalkPathNormal();
  2457. } catch (RuntimeException re) {
  2458. LogUtil.errorLogInfo("", TAG, re);
  2459. } catch (Exception e) {
  2460. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2461. //e.printStackTrace();
  2462. LogUtil.errorLogInfo("", TAG, e);
  2463. }
  2464. }
  2465. // 외출방범 대기 모드 중 사운드와 센서 체크
  2466. class OutgoingCheckSensor extends Thread {
  2467. public OutgoingCheckSensor() {
  2468. }
  2469. public void run() {
  2470. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2471. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2472. WallPadInterface wpifc = new WallPadInterface();
  2473. mWallpadStatusData.closeDB();
  2474. int checkcount = timedata / 5;
  2475. int i;
  2476. for (i = checkcount; i > 0; i--) {
  2477. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2478. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2479. mWallpadStatusData.closeDB();
  2480. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2481. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2482. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2483. try {
  2484. Thread.sleep(5000);
  2485. } catch (RuntimeException re) {
  2486. LogUtil.errorLogInfo("", TAG, re);
  2487. } catch (Exception e) {
  2488. LogUtil.errorLogInfo("", TAG, e);
  2489. }
  2490. }
  2491. if (i == 0) {
  2492. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2493. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2494. mWallpadStatusData.closeDB();
  2495. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2496. Common.SendAppFinishReqBR(getApplicationContext());
  2497. int base = 7000;
  2498. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  2499. int Menu_Start_Option = 1;
  2500. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2501. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2502. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2503. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2504. String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
  2505. if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
  2506. else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
  2507. else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
  2508. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2509. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2510. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2511. iMAPstartActivity(mIntent);
  2512. }
  2513. }
  2514. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2515. OutGoingSensorWaiting = 0;
  2516. }
  2517. }
  2518. @Override
  2519. public IBinder onBind(Intent arg0) {
  2520. return mMessenger.getBinder();
  2521. //return null;
  2522. }
  2523. public void imapsvrlog(String msg) {
  2524. if (!log_sw) return;
  2525. Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
  2526. }
  2527. public int onStartCommand(Intent intent, int flags, int startID) {
  2528. try {
  2529. try {
  2530. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2531. } catch (RuntimeException re) {
  2532. LogUtil.errorLogInfo("", TAG, re);
  2533. } catch (Exception e) {
  2534. //e.printStackTrace();
  2535. LogUtil.errorLogInfo("", TAG, e);
  2536. }
  2537. getDeviceCtrlOption();
  2538. SvrSock = new iMapSverSocket();
  2539. SvrSock.start();
  2540. } catch (IOException e) {
  2541. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2542. //e.printStackTrace();
  2543. LogUtil.errorLogInfo("", TAG, e);
  2544. }
  2545. try {
  2546. mGleInterface = new jni();
  2547. } catch (RuntimeException re) {
  2548. LogUtil.errorLogInfo("", TAG, re);
  2549. } catch (Exception e) {
  2550. Log.e(TAG, "[Exception] mGleInterface init...");
  2551. //e.printStackTrace();
  2552. LogUtil.errorLogInfo("", TAG, e);
  2553. }
  2554. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2555. AddressSet addr = DBMGR.getAddressMGR();
  2556. DBMGR.closeDB();
  2557. String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
  2558. AddrDong = addr.Dong;
  2559. AddrHo = addr.Ho;
  2560. ho = Integer.valueOf(AddrHo.substring(0, 1));
  2561. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  2562. "<imap ver=\"1.0\" address=\"" + addr.IPAddress + "\" sender=\"" + AddressStr + "\">\r\n";
  2563. Log.d(TAG, "*****************************************");
  2564. Log.d(TAG, "****************SchedulerThread**********");
  2565. Log.d(TAG, "*****************************************");
  2566. ScheServer = new SchedulerThread();
  2567. ScheServer.start();
  2568. // BR 등록 시작
  2569. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2570. IntentFilter mIntentFilter = new IntentFilter();
  2571. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2572. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2573. mIntentFilter = new IntentFilter();
  2574. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2575. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2576. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2577. mIntentFilter = new IntentFilter();
  2578. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2579. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2580. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2581. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2582. mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
  2583. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2584. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2585. // BR 등록 완료
  2586. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2587. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
  2588. IGW200APICheckHandler.sendEmptyMessage(0);
  2589. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  2590. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2591. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2592. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2593. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2594. IGW300APICheckHandler.sendEmptyMessage(0);
  2595. }
  2596. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2597. mIOInterface.setEmergencyType();
  2598. Intent notiIntent = new Intent();
  2599. notiIntent.setAction(define.NOTIFY_ACNAME);
  2600. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2601. getApplicationContext().sendBroadcast(notiIntent);
  2602. CheckMainStatus();
  2603. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2604. getAirQualityUsage();
  2605. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2606. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2607. GwCheckThread.start();
  2608. }
  2609. getResidentSafetyCheckSetting();
  2610. return START_STICKY;
  2611. }
  2612. //멀티기기 정보 전송을 위한 추가
  2613. public static final int MSG_REGISTER_CLIENT = 1;
  2614. //public static final int MSG_UNREGISTER_CLIENT = 2;
  2615. public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
  2616. public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
  2617. public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
  2618. public static final int MSG_SEND_TO_ACTIVITY = 4;
  2619. private Messenger mClient = null; // Activity 에서 가져온 Messenger
  2620. String remote_get_home_devices1;
  2621. String remote_get_home_devices2;
  2622. String remote_get_home_devices3;
  2623. int skipCount = 0;
  2624. /**
  2625. * activity로부터 binding 된 Messenger
  2626. */
  2627. private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
  2628. @Override
  2629. public boolean handleMessage(Message msg) {
  2630. switch (msg.what) {
  2631. case MSG_REGISTER_CLIENT:
  2632. mClient = msg.replyTo; // activity로부터 가져온
  2633. break;
  2634. case MSG_SEND_TO_SERVICE_DEVICES1:
  2635. remote_get_home_devices1 = (String) msg.obj; // activity로부터 가져온
  2636. break;
  2637. case MSG_SEND_TO_SERVICE_DEVICES2:
  2638. remote_get_home_devices2 = (String) msg.obj; // activity로부터 가져온
  2639. break;
  2640. case MSG_SEND_TO_SERVICE_DEVICES3:
  2641. remote_get_home_devices3 = (String) msg.obj; // activity로부터 가져온
  2642. break;
  2643. default:
  2644. break;
  2645. }
  2646. return false;
  2647. }
  2648. }));
  2649. private void sendMsgToActivity(int sendValue) {
  2650. try {
  2651. Bundle bundle = new Bundle();
  2652. bundle.putInt("fromService", sendValue);
  2653. Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
  2654. msg.setData(bundle);
  2655. if(mClient!=null) {
  2656. mClient.send(msg); // msg 보내기
  2657. }
  2658. } catch (Exception e) {
  2659. }
  2660. }
  2661. // 메인 서버 소켓 클래스
  2662. public class iMapSverSocket extends Thread {
  2663. ServerSocket svr;
  2664. private SSLServerSocket sslsvr;
  2665. boolean receiveSocketRun = true;
  2666. public iMapSverSocket() throws IOException {
  2667. /////////////////////////////////////////////////////////////////////
  2668. // 신형 단지서버 사용 유무를 가져온다.
  2669. /////////////////////////////////////////////////////////////////////
  2670. try {
  2671. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2672. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2673. wallpadDeviceSet.closeDB();
  2674. } catch (RuntimeException re) {
  2675. LogUtil.errorLogInfo("", TAG, re);
  2676. mNewDanjiServer = false;
  2677. } catch (Exception e) {
  2678. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2679. //e.printStackTrace();
  2680. LogUtil.errorLogInfo("", TAG, e);
  2681. mNewDanjiServer = false;
  2682. }
  2683. //////////////////////////////////////////////////
  2684. /////////////////////////////////////////////////////////////////////
  2685. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2686. /////////////////////////////////////////////////////////////////////
  2687. if (!mNewDanjiServer) {
  2688. svr = new ServerSocket(port);
  2689. } else {
  2690. int svrport = port + 1000;
  2691. Log.i(TAG, "============================================");
  2692. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2693. Log.i(TAG, "============================================");
  2694. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2695. sslsvr = sslServerSocket.getServerSocket();
  2696. }
  2697. }
  2698. public void run() {
  2699. while (receiveSocketRun) {
  2700. try {
  2701. Socket sock = null;
  2702. /////////////////////////////////////////////////////////////////////
  2703. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2704. /////////////////////////////////////////////////////////////////////
  2705. if (!mNewDanjiServer) {
  2706. sock = svr.accept();
  2707. } else {
  2708. sock = sslsvr.accept();
  2709. }
  2710. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2711. ProciMap.start();
  2712. } catch (IOException e) {
  2713. //e.printStackTrace();
  2714. LogUtil.errorLogInfo("", TAG, e);
  2715. }
  2716. }
  2717. }
  2718. public void destoryThread() {
  2719. receiveSocketRun = false;
  2720. try {
  2721. if (svr != null) {
  2722. svr.close();
  2723. svr = null;
  2724. }
  2725. if (sslsvr != null) {
  2726. sslsvr.close();
  2727. sslsvr = null;
  2728. }
  2729. } catch (RuntimeException re) {
  2730. LogUtil.errorLogInfo("", TAG, re);
  2731. } catch (Exception e) {
  2732. //e.printStackTrace();
  2733. LogUtil.errorLogInfo("", TAG, e);
  2734. }
  2735. }
  2736. }
  2737. public String getRemoteIPAddress(Socket Sock) {
  2738. try {
  2739. // Log.i(TAG, "[getRemoteIPAddress] == START ==");
  2740. if (Sock == null) return "10.0.1.1";
  2741. String strRemoteIP = Sock.getRemoteSocketAddress().toString();
  2742. String[] strSplited_01 = strRemoteIP.split(":");
  2743. String[] strSplited_02 = strSplited_01[0].split("/");
  2744. strRemoteIP = strSplited_02[1];
  2745. return strRemoteIP;
  2746. } catch (Exception e) {
  2747. Log.e(TAG, "[Exception] getRemoteIPAddress(Sock)");
  2748. e.printStackTrace();
  2749. return "10.0.1.1";
  2750. }
  2751. }
  2752. // iMAP 서버 소켓 처리
  2753. public class iMapSverSocketThread extends Thread {
  2754. private final Socket iMAPSock;
  2755. String strRcvMSG;
  2756. WallPadiMAPUpgrade upgradeProc;
  2757. Document doc;
  2758. public iMapSverSocketThread(Socket sock) {
  2759. iMAPSock = sock;
  2760. }
  2761. public void run() {
  2762. try {
  2763. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2764. InputStream InStm = iMAPSock.getInputStream();
  2765. iMAPSock.setSoLinger(true, 3000);
  2766. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2767. strRcvMSG = "";
  2768. String InBuffer;
  2769. int i = 0;
  2770. boolean bRcvOK = false;
  2771. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2772. /////////////////////////////////////////////////////////////////////
  2773. // 신형단지서버 미사용중일 경우 기존 코드로,
  2774. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2775. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2776. /////////////////////////////////////////////////////////////////////
  2777. if (!mNewDanjiServer) {
  2778. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2779. try {
  2780. if (MsgReader.ready()) {
  2781. try {
  2782. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2783. InBuffer = "";
  2784. while (MsgReader.ready()) {
  2785. long charCnt = MsgReader.read(ReadData);
  2786. InBuffer += new String(ReadData, 0, (int) charCnt);
  2787. }
  2788. if (InBuffer != null) strRcvMSG += InBuffer;
  2789. if (0 < InBuffer.indexOf("</imap>")) {
  2790. bRcvOK = true;
  2791. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2792. break;
  2793. }
  2794. } catch (RuntimeException re) {
  2795. LogUtil.errorLogInfo("", TAG, re);
  2796. return;
  2797. } catch (Exception e) {
  2798. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2799. //e.printStackTrace();
  2800. LogUtil.errorLogInfo("", TAG, e);
  2801. return;
  2802. }
  2803. } else {
  2804. Thread.sleep(100);
  2805. }
  2806. } catch (RuntimeException re) {
  2807. LogUtil.errorLogInfo("", TAG, re);
  2808. iMAPSock.close();
  2809. return;
  2810. } catch (Exception e) {
  2811. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  2812. iMAPSock.close();
  2813. //e.printStackTrace();
  2814. LogUtil.errorLogInfo("", TAG, e);
  2815. return;
  2816. }
  2817. }
  2818. } else {
  2819. // SSL 암호화 데이터 수신부
  2820. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  2821. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2822. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2823. try {
  2824. InBuffer = "";
  2825. long charCnt = MsgReader.read(ReadData);
  2826. if (charCnt > 0) {
  2827. InBuffer += new String(ReadData, 0, (int) charCnt);
  2828. strRcvMSG += InBuffer;
  2829. if (-1 < InBuffer.indexOf("</imap>")) {
  2830. bRcvOK = true;
  2831. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  2832. break;
  2833. }
  2834. } else {
  2835. Thread.sleep(100);
  2836. }
  2837. } catch (RuntimeException re) {
  2838. LogUtil.errorLogInfo("", TAG, re);
  2839. iMAPSock.close();
  2840. return;
  2841. } catch (Exception e) {
  2842. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  2843. iMAPSock.close();
  2844. //e.printStackTrace();
  2845. LogUtil.errorLogInfo("", TAG, e);
  2846. return;
  2847. }
  2848. }
  2849. }
  2850. if (!bRcvOK) {
  2851. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  2852. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  2853. Log.i(TAG, strRcvMSG);
  2854. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  2855. iMAPSock.close();
  2856. return;
  2857. }
  2858. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  2859. imapsvrlog("Socket read end accept </imap>\n" + strRcvMSG);
  2860. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2861. DocumentBuilder builder = factory.newDocumentBuilder();
  2862. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  2863. doc = builder.parse(istream);
  2864. Element elelist = doc.getDocumentElement();
  2865. NodeList items = elelist.getElementsByTagName("service");
  2866. Node item = items.item(0);
  2867. NamedNodeMap attrs = item.getAttributes();
  2868. String retXML = "";
  2869. for (int j = 0; j < attrs.getLength(); j++) {
  2870. Node attr = attrs.item(j);
  2871. String cmd;
  2872. if (attr.getNodeName().equalsIgnoreCase("type")) {
  2873. cmd = attr.getNodeValue();
  2874. if (cmd.equalsIgnoreCase("notice")) {
  2875. iMAPSock.close();
  2876. }
  2877. } else if (attr.getNodeName().equalsIgnoreCase("name")) {
  2878. cmd = attr.getNodeValue();
  2879. if (cmd.equalsIgnoreCase("event_notify")) {
  2880. retXML = ProcEventNotify(elelist);
  2881. } else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  2882. ProcElevatorinfo(elelist);
  2883. retXML = null;
  2884. } else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  2885. retXML = ProcCheckEpiceUpload(doc);
  2886. } else if (cmd.equalsIgnoreCase("update_news")) {
  2887. retXML = ProcUpdateNews(doc);
  2888. } else if (cmd.equalsIgnoreCase("update_weather")) {
  2889. retXML = ProcUpdateWeather(doc);
  2890. } else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  2891. retXML = ProcSchduleInquiry(doc);
  2892. } else if (cmd.equalsIgnoreCase("schedule_renew")) {
  2893. retXML = ProcSchduleRenew(doc);
  2894. } else if (cmd.equalsIgnoreCase("schdule")) {
  2895. String SvcType = "";
  2896. int k;
  2897. for (k = j + 1; k < attrs.getLength(); k++) {
  2898. Node attr1 = attrs.item(k);
  2899. SvcType = attr1.getNodeName();
  2900. if (SvcType.equalsIgnoreCase("shc_type")) {
  2901. SvcType = attr1.getNodeValue();
  2902. break;
  2903. }
  2904. }
  2905. retXML = ProcUpdateSchedule(elelist, SvcType);
  2906. } else if (cmd.equalsIgnoreCase("device_reset")) {
  2907. retXML = ProcDeviceReset(elelist);
  2908. } else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  2909. retXML = ProcNotifyparcel(doc);
  2910. } else if (cmd.equalsIgnoreCase("notify_post_info")) {
  2911. // 스마트우편함 연동 여부
  2912. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  2913. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  2914. DevSet.closeDB();
  2915. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  2916. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  2917. } else if (cmd.equalsIgnoreCase("get_security_mode")) {
  2918. String Dong = null;
  2919. String Ho = null;
  2920. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  2921. String result;
  2922. String modeStr = null;
  2923. int status = statusDB.GetAlarmStatus();
  2924. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  2925. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  2926. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  2927. else if (status == WallpadStatusData.GUARD_OUT)
  2928. modeStr = "unoccupied";
  2929. else if (status == WallpadStatusData.GUARD_OUT_WAIT)
  2930. modeStr = "waitunoccupied";
  2931. result = "ok";
  2932. } else {
  2933. modeStr = "null";
  2934. result = "fail";
  2935. }
  2936. try {
  2937. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  2938. Node GSM_item = GSM_items.item(0);
  2939. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  2940. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  2941. Node GSM_attr = GSM_attrsParam.item(k);
  2942. if (GSM_attr.getNodeName().equalsIgnoreCase("dong"))
  2943. Dong = trimquotation(GSM_attr.getNodeValue());
  2944. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho"))
  2945. Ho = trimquotation(GSM_attr.getNodeValue());
  2946. }
  2947. WallpadStatusData DBMGR = null;
  2948. DBMGR = new WallpadStatusData(getApplicationContext());
  2949. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  2950. DBMGR.closeDB();
  2951. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  2952. result = "fail";
  2953. }
  2954. } catch (RuntimeException re) {
  2955. LogUtil.errorLogInfo("", TAG, re);
  2956. result = "fail";
  2957. } catch (Exception e) {
  2958. result = "fail";
  2959. }
  2960. retXML = XMLHeader +
  2961. " <service type=\"reply\" name=\"get_security_mode\" result=\"" + result + "\">\r\n" +
  2962. " <home_info dong=\"" + AddrDong + "\" ho=\"" + AddrHo + "\" mode=\"" + modeStr + "\"/>\r\n" +
  2963. " </service>\r\n" +
  2964. "</imap>\r\n";
  2965. statusDB.closeDB();
  2966. } else if (cmd.equalsIgnoreCase("set_setup_info")) {
  2967. retXML = ProcSetsetup(doc);
  2968. } else if (cmd.equalsIgnoreCase("get_setup_info")) {
  2969. retXML = ProcGetsetup(doc);
  2970. } else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  2971. retXML = CheckPassword(doc);
  2972. } else if (cmd.equalsIgnoreCase("device_live_check")) {
  2973. retXML = ProcDeviceLiveCheck();
  2974. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  2975. retXML = ProcPairingHdevSyncAlarm(elelist);
  2976. } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  2977. retXML = ProcPairingHdevSyncSecurity(elelist);
  2978. } else if (cmd.equalsIgnoreCase("notify_car_event")) {
  2979. retXML = ProcParkInformation(elelist);
  2980. } else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  2981. retXML = ProcSmartKeyEvent(elelist);
  2982. } else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  2983. retXML = ProcParkInformation_cham_upis(elelist);
  2984. } else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  2985. retXML = ProcauscultateReq(doc);
  2986. } else if (cmd.equalsIgnoreCase("upgrade")) {
  2987. imapsvrlog("Enter Upgrade");
  2988. procUpgrade();
  2989. retXML = null;
  2990. } else if (cmd.equals("check_sip_activation")) {
  2991. String sip_result = "fail";
  2992. ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  2993. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  2994. //add KSJ 2021.11.02 socket addr 가져오기 위해 추가
  2995. String strIP = getRemoteIPAddress(iMAPSock);
  2996. //~add KSJ
  2997. // Jeff added below codes for call app (2018.01.25)
  2998. String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
  2999. for (int k = 0; k < rsi.size(); k++) {
  3000. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  3001. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  3002. sip_result = "ok";
  3003. break;
  3004. }
  3005. }
  3006. if(bWallPadCallLive && m_bWallpadCallScreen == false)
  3007. {
  3008. sip_result = "fail";
  3009. }
  3010. if(m_CallAppRunDelay == false)
  3011. {
  3012. retXML = XMLHeader + "<service type=\"reply\" name=\"check_sip_activation\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  3013. //add KSJ 2021.11.02 check_sip_activation msg recv 이후 wallpadcall app start
  3014. String[] IP_Parse = strIP.split("\\.");
  3015. Log.d(TAG, "1" + strIP);
  3016. //Log.d(TAG, "2" + strSplit[1]);
  3017. //Log.d(TAG, "3" + strSplit[2]);
  3018. //Log.d(TAG, "4" + strSplit[3]);
  3019. CALLTYPE eCallType = CALLTYPE.LOBBY;
  3020. if (IP_Parse[2].equals("0")) {
  3021. eCallType = CALLTYPE.LOBBY;
  3022. if (IP_Parse[3].equals("11"))
  3023. eCallType = CALLTYPE.FRONT;
  3024. } else if (IP_Parse[2].equals("129")) {
  3025. eCallType = CALLTYPE.FRONT;
  3026. } else {
  3027. eCallType = CALLTYPE.RESIDENCE;
  3028. }
  3029. if ((eCallType == CALLTYPE.LOBBY) || (eCallType == CALLTYPE.FRONT)) {
  3030. m_CallAppRunDelay = true;
  3031. runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
  3032. }
  3033. }
  3034. else
  3035. {
  3036. sip_result = "fail";
  3037. retXML = XMLHeader + "<service type=\"reply\" name=\"check_sip_activation\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  3038. }
  3039. }
  3040. //add KSJ 2021.11.02 stop_talking msg 추가 (wallpadcall 종료)
  3041. else if (cmd.equals("stop_talking")) {
  3042. String sip_result = "ok";
  3043. //sip_result = "ok";
  3044. retXML = XMLHeader + "<service type=\"reply\" name=\"stop_talking\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  3045. Common.SendAppFinishReqBR(getApplicationContext());
  3046. }
  3047. //~add KSJ
  3048. //add 2022.03.02 front_open msg 추가 (현관에서 문열림 요청)
  3049. else if (cmd.equals("front_open")) {
  3050. retXML = ProcFrontOpen();
  3051. }
  3052. //~add
  3053. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3054. retXML = iCMDProcDevList(doc);
  3055. } else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3056. retXML = iCMDProcGASControl(elelist);
  3057. } else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3058. // 현대건설 더펜트하우스 와 구분하여 처리
  3059. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  3060. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  3061. mWallpadDeviceSet.closeDB();
  3062. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  3063. retXML = iCMDProcChumDamSmartLightControl(doc);
  3064. }
  3065. else {
  3066. retXML = iCMDProcSDPSmartLightControl(doc);
  3067. }
  3068. } else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3069. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3070. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3071. retXML = iCMDProc_I_LightControl(doc);
  3072. } else {
  3073. retXML = iCMDProcLivingLightControl(doc);
  3074. }
  3075. } else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3076. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  3077. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
  3078. || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
  3079. retXML = iCMDProcSDPConcentControl(doc);
  3080. } else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3081. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3082. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3083. } else {
  3084. retXML = iCMDProcMultiSWControl(doc);
  3085. }
  3086. } else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3087. retXML = iCMDProcDoorlockControl(doc);
  3088. } else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3089. retXML = iCMDProcTemperControl(doc);
  3090. } else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3091. retXML = iCMDProcModeControl(doc);
  3092. } else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3093. retXML = iCMDProcVentilControl(doc);
  3094. } else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3095. retXML = iCMDProcCurtainControl(doc);
  3096. } else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3097. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3098. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3099. retXML = iCMDProcEnergyMeterLightControl(doc);
  3100. } else {
  3101. retXML = iCMDProcLightControl(doc);
  3102. }
  3103. } else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3104. retXML = iCMDProcLightBatchControl(elelist);
  3105. }
  3106. else if (cmd.equalsIgnoreCase("remote_access_sysaircon")) {
  3107. retXML = iCMDProcSysairconControl(elelist);
  3108. }
  3109. //모바일 사용자 인증 관련 메시지
  3110. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3111. ProcMobileDevice_AuthNumber(elelist);
  3112. } else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3113. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3114. } else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3115. ProcMobileDevice_Delete(elelist);
  3116. } else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3117. retXML = ProcGetSmartKeyInfo(elelist);
  3118. } else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3119. retXML = ProcGetAppVersionInfo();
  3120. } else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3121. retXML = ProcIgateInitInfo(elelist);
  3122. } else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3123. retXML = ProcElecCarChargeEventInfo(elelist);
  3124. } else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3125. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3126. } else if (cmd.equalsIgnoreCase("check_call_option")) {
  3127. retXML = ProcCheckCallOption();
  3128. } else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3129. retXML = ProcChatSequence(elelist);
  3130. } else if (cmd.equalsIgnoreCase("chat_message")) {
  3131. retXML = ProcChatMessage(elelist);
  3132. } else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3133. retXML = ProcEvacuationLadderOpen(elelist);
  3134. } else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3135. retXML = SmartLightDetailInfo(elelist);
  3136. } else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3137. retXML = KNXDeviceDetailInfo(elelist);
  3138. } else if (cmd.equalsIgnoreCase("set_server_version")) {
  3139. retXML = ProcSetServerChange(elelist);
  3140. } else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
  3141. retXML = iCMDProcOnePass(elelist);
  3142. } else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3143. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
  3144. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3145. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3146. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3147. }
  3148. } else if (cmd.equalsIgnoreCase("check_resident_safety")) {
  3149. retXML = iCMDProcResidentSafety(elelist);
  3150. }
  3151. break;
  3152. }
  3153. }
  3154. if (retXML != null) {
  3155. imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
  3156. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3157. byte[] outBF = retXML.getBytes("euc-kr");
  3158. outstream.write(outBF);
  3159. outstream.flush();
  3160. try {
  3161. Thread.sleep(3000);
  3162. } catch (RuntimeException re) {
  3163. LogUtil.errorLogInfo("", TAG, re);
  3164. } catch (Exception e) {
  3165. LogUtil.errorLogInfo("", TAG, e);
  3166. }
  3167. iMAPSock.close();
  3168. } else {
  3169. try {
  3170. iMAPSock.close();
  3171. } catch (RuntimeException re) {
  3172. LogUtil.errorLogInfo("", TAG, re);
  3173. } catch (Exception e) {
  3174. LogUtil.errorLogInfo("", TAG, e);
  3175. }
  3176. }
  3177. } catch (RuntimeException re) {
  3178. LogUtil.errorLogInfo("", TAG, re);
  3179. } catch (Exception e) {
  3180. try {
  3181. iMAPSock.close();
  3182. } catch (RuntimeException re) {
  3183. LogUtil.errorLogInfo("", TAG, re);
  3184. } catch (Exception E) {
  3185. LogUtil.errorLogInfo("", TAG, E);
  3186. }
  3187. LogUtil.errorLogInfo("", TAG, e);
  3188. }
  3189. }
  3190. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3191. private void procUpgrade() {
  3192. imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
  3193. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3194. String[] getstate = sdb.GetSystemUpdateStatus();
  3195. sdb.closeDB();
  3196. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3197. for (int i = 0; i < getstate.length; i++) {
  3198. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3199. }
  3200. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3201. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3202. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3203. }
  3204. }
  3205. // " 제거
  3206. private String trimquotation(String sen) {
  3207. sen = sen.replaceAll("\"", "");
  3208. return sen.trim();
  3209. }
  3210. //remote_auscultate 처리
  3211. public String ProcauscultateReq(Document Doc) {
  3212. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3213. NodeList items = Doc.getElementsByTagName("group");
  3214. Node item;
  3215. String itemname = null;
  3216. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3217. SettManager.DeleteSettingData();
  3218. SettManager.DropTable();
  3219. try {
  3220. for (int i = 0; i < items.getLength(); i++) {
  3221. item = items.item(i);
  3222. itemname = GetAttributeVal(item, "type");
  3223. String GetCNT = GetAttributeVal(item, "count");
  3224. if (Integer.parseInt(GetCNT) <= 0)
  3225. continue;
  3226. Element SettingItem = (Element) item;
  3227. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3228. for (int j = 0; j < SettingList.getLength(); j++) {
  3229. Node subdevListitem = SettingList.item(j);
  3230. String devname = trimquotation(subdevListitem.getTextContent());
  3231. SettManager.InsertSettingData(itemname, devname, j);
  3232. }
  3233. }
  3234. } catch (RuntimeException re) {
  3235. LogUtil.errorLogInfo("", TAG, re);
  3236. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3237. SettManager.closeDB();
  3238. return RetVal;
  3239. } catch (Exception e) {
  3240. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3241. //e.printStackTrace();
  3242. LogUtil.errorLogInfo("", TAG, e);
  3243. SettManager.closeDB();
  3244. return RetVal;
  3245. }
  3246. SettManager.closeDB();
  3247. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  3248. StatusBeatRequested = true;
  3249. Intent intent = new Intent();
  3250. intent.setAction(define.NOTIFY_ACNAME);
  3251. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
  3252. sendBroadcast(intent);
  3253. return RetVal;
  3254. }
  3255. public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
  3256. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  3257. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n" +
  3258. "<service type=\"request\" name=\"remote_auscultate\">\r\n" +
  3259. " <guidemap devtype=\"homedev\" count=\"4\">\r\n" +
  3260. " <group type=\"ctrl_device\" count=\"5\">\r\n" +
  3261. " <unit>\"light\"</unit>\r\n" +
  3262. " <unit>\"thermostat\"</unit>\r\n" +
  3263. " <unit>\"gas\"</unit>\r\n" +
  3264. " <unit>\"doorlock\"</unit>\r\n" +
  3265. " <unit>\"ventil\"</unit>\r\n" +
  3266. " </group>\r\n" +
  3267. " <group type=\"talk_device\" count=\"4\">\r\n" +
  3268. " <unit>\"sub_homedev\"</unit>\r\n" +
  3269. " <unit>\"kitchen_tv\"</unit>\r\n" +
  3270. " <unit>\"bath_tv\"</unit>\r\n" +
  3271. " <unit>\"bath_phone\"</unit>\r\n" +
  3272. " </group>\r\n" +
  3273. " <group type=\"sensor\" count=\"6\">\r\n" +
  3274. " <unit>\"magnetic\"</unit>\r\n" +
  3275. " <unit>\"bugout\"</unit>\r\n" +
  3276. " <unit>\"bugin\"</unit>\r\n" +
  3277. " <unit>\"fire\"</unit>\r\n" +
  3278. " <unit>\"gas\"</unit>\r\n" +
  3279. " <unit>\"emergency\"</unit>\r\n" +
  3280. " </group>\r\n" +
  3281. " <group type=\"extended\" count=\"4\">\r\n" +
  3282. " <unit>\"gateway\"</unit>\r\n" +
  3283. " <unit>\"smartswitch\"</unit>\r\n" +
  3284. " <unit>\"handy\"</unit>\r\n" +
  3285. " <unit>\"energymeter\"</unit>\r\n" +
  3286. " </group>\r\n" +
  3287. " </guidemap>\r\n" +
  3288. "</service>\r\n" +
  3289. "</imap>\r\n";
  3290. try {
  3291. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3292. DocumentBuilder builder = factory.newDocumentBuilder();
  3293. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3294. Document doc = builder.parse(istream);
  3295. NodeList items = doc.getElementsByTagName("group");
  3296. Node item;
  3297. String itemname = null;
  3298. SettManager.DeleteSettingData();
  3299. SettManager.DropTable();
  3300. for (int i = 0; i < items.getLength(); i++) {
  3301. item = items.item(i);
  3302. itemname = GetAttributeVal(item, "type");
  3303. String GetCNT = GetAttributeVal(item, "count");
  3304. if (Integer.parseInt(GetCNT) <= 0)
  3305. continue;
  3306. Element SettingItem = (Element) item;
  3307. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3308. for (int j = 0; j < SettingList.getLength(); j++) {
  3309. Node subdevListitem = SettingList.item(j);
  3310. String devname = trimquotation(subdevListitem.getTextContent());
  3311. SettManager.InsertSettingData(itemname, devname, j);
  3312. }
  3313. }
  3314. } catch (RuntimeException re) {
  3315. LogUtil.errorLogInfo("", TAG, re);
  3316. } catch (Exception e) {
  3317. //e.printStackTrace();
  3318. LogUtil.errorLogInfo("", TAG, e);
  3319. }
  3320. }
  3321. String MakeFailMessage(String msg) {
  3322. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\"" + msg + "\"</first_failed>\r\n</service>\r\n</imap>";
  3323. }
  3324. //SetInfo의 각 항목들의 무결성 확인
  3325. final String isUse = "사용함";
  3326. final String isNotUse = "사용안함";
  3327. boolean CheckSubdevData(String devName, String devData) {
  3328. String[] SplitedMSG;
  3329. try {
  3330. if (devName.equals("가스밸브")) {
  3331. SplitedMSG = devData.split("[(]");
  3332. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3333. String UseStr = SplitedMSG[2].split("[)]")[0];
  3334. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3335. } else if (devName.equals("디지털도어락")) {
  3336. SplitedMSG = devData.split("[(]");
  3337. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3338. String[] UseStr = SplitedMSG[2].split("[)]");
  3339. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3340. if (!UseStr[1].equals("종류")) return false;
  3341. UseStr = SplitedMSG[3].split("[)]");
  3342. if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
  3343. } else if (devName.equals("온도조절기")) {
  3344. SplitedMSG = devData.split("[(]");
  3345. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3346. String[] UseStr = SplitedMSG[2].split("[)]");
  3347. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3348. } else if (devName.equals("조명제어기")) {
  3349. SplitedMSG = devData.split("[(]");
  3350. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3351. String[] UseStr = SplitedMSG[2].split("[)]");
  3352. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3353. /*
  3354. if (!UseStr[1].equals("종류"))
  3355. return false;
  3356. UseStr = SplitedMSG[3].split("[)]");
  3357. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3358. return false;
  3359. */
  3360. } else if (devName.equals("환기시스템")) {
  3361. SplitedMSG = devData.split("[(]");
  3362. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3363. String[] UseStr = SplitedMSG[2].split("[)]");
  3364. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3365. /*
  3366. if (!UseStr[1].equals("종류"))
  3367. return false;
  3368. UseStr = SplitedMSG[3].split("[)]");
  3369. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  3370. return false;
  3371. */
  3372. } else if (devName.equals("시스템에어컨")) {
  3373. SplitedMSG = devData.split("[(]");
  3374. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3375. String[] UseStr = SplitedMSG[2].split("[)]");
  3376. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3377. } else if (devName.equals("전동커튼")) {
  3378. SplitedMSG = devData.split("[(]");
  3379. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3380. String[] UseStr = SplitedMSG[2].split("[)]");
  3381. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3382. /*
  3383. if (!UseStr[1].equals("종류"))
  3384. return false;
  3385. UseStr = SplitedMSG[3].split("[)]");
  3386. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  3387. return false;
  3388. */
  3389. } else if (devName.equals("실시간검침기")) {
  3390. SplitedMSG = devData.split("[(]");
  3391. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3392. String[] UseStr = SplitedMSG[2].split("[)]");
  3393. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3394. } else if (devName.equals("스마트스위치&일괄소등")) {
  3395. SplitedMSG = devData.split("[(]");
  3396. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3397. String[] UseStr = SplitedMSG[2].split("[)]");
  3398. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3399. /*
  3400. if (!UseStr[1].equals("종류"))
  3401. return false;
  3402. UseStr = SplitedMSG[3].split("[)]");
  3403. if (!UseStr[0].equals("대외향스마트스위치")&&
  3404. !UseStr[0].equals("대외향일괄소등제어기")&&
  3405. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  3406. !UseStr[0].equals("현산향스마트스위치")&&
  3407. !UseStr[0].equals("현산향LCD스마트스위치"))
  3408. return false;
  3409. */
  3410. } else if (devName.equals("무선리모컨")) {
  3411. SplitedMSG = devData.split("[(]");
  3412. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3413. String[] UseStr = SplitedMSG[2].split("[)]");
  3414. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3415. } else if (devName.equals("현관카메라")) {
  3416. SplitedMSG = devData.split("[(]");
  3417. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3418. String[] UseStr = SplitedMSG[2].split("[)]");
  3419. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3420. /*
  3421. if (!UseStr[1].equals("종류"))
  3422. return false;
  3423. UseStr = SplitedMSG[3].split("[)]");
  3424. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  3425. return false;
  3426. */
  3427. } else if (devName.equals("공지사항")) {
  3428. SplitedMSG = devData.split("[(]");
  3429. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3430. String[] UseStr = SplitedMSG[2].split("[)]");
  3431. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3432. } else if (devName.equals("날씨")) {
  3433. SplitedMSG = devData.split("[(]");
  3434. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3435. String[] UseStr = SplitedMSG[2].split("[)]");
  3436. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3437. } else if (devName.equals("메모")) {
  3438. SplitedMSG = devData.split("[(]");
  3439. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3440. String[] UseStr = SplitedMSG[2].split("[)]");
  3441. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3442. } else if (devName.equals("전자액자")) {
  3443. SplitedMSG = devData.split("[(]");
  3444. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3445. String[] UseStr = SplitedMSG[2].split("[)]");
  3446. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3447. } else if (devName.equals("일정표")) {
  3448. SplitedMSG = devData.split("[(]");
  3449. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3450. String[] UseStr = SplitedMSG[2].split("[)]");
  3451. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3452. } else if (devName.equals("주차확인")) {
  3453. SplitedMSG = devData.split("[(]");
  3454. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3455. String[] UseStr = SplitedMSG[2].split("[)]");
  3456. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3457. /*
  3458. UseStr = SplitedMSG[3].split("[)]");
  3459. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  3460. return false;
  3461. */
  3462. } else if (devName.equals("시간설정")) {
  3463. SplitedMSG = devData.split("[(]");
  3464. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3465. String[] UseStr = SplitedMSG[2].split("[)]");
  3466. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3467. } else if (devName.equals("원격검침")) {
  3468. SplitedMSG = devData.split("[(]");
  3469. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3470. String[] UseStr = SplitedMSG[2].split("[)]");
  3471. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3472. } else if (devName.equals("뮤직")) {
  3473. SplitedMSG = devData.split("[(]");
  3474. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3475. String[] UseStr = SplitedMSG[2].split("[)]");
  3476. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3477. } else if (devName.equals("영상재생")) {
  3478. SplitedMSG = devData.split("[(]");
  3479. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3480. String[] UseStr = SplitedMSG[2].split("[)]");
  3481. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3482. } else if (devName.equals("CCTV")) {
  3483. SplitedMSG = devData.split("[(]");
  3484. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3485. String[] UseStr = SplitedMSG[2].split("[)]");
  3486. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3487. /*
  3488. UseStr = SplitedMSG[3].split("[)]");
  3489. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  3490. return false;
  3491. */
  3492. } else if (devName.equals("명칭설정")) {
  3493. SplitedMSG = devData.split("[(]");
  3494. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3495. String[] UseStr = SplitedMSG[2].split("[)]");
  3496. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3497. } else if (devName.equals("출동경비")) {
  3498. SplitedMSG = devData.split("[(]");
  3499. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3500. String[] UseStr = SplitedMSG[2].split("[)]");
  3501. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3502. } else if (devName.equals("경비실영상통화")) {
  3503. SplitedMSG = devData.split("[(]");
  3504. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3505. String[] UseStr = SplitedMSG[2].split("[)]");
  3506. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3507. } else if (devName.equals("엘리베이터")) {
  3508. SplitedMSG = devData.split("[(]");
  3509. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3510. String[] UseStr = SplitedMSG[2].split("[)]");
  3511. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3512. /*
  3513. UseStr = SplitedMSG[3].split("[)]");
  3514. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  3515. return false;
  3516. */
  3517. } else if (devName.equals("현장특화기능")) {
  3518. SplitedMSG = devData.split("[(]");
  3519. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3520. String[] UseStr = SplitedMSG[2].split("[)]");
  3521. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3522. /*
  3523. UseStr = SplitedMSG[3].split("[)]");
  3524. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  3525. return false;
  3526. */
  3527. } else if (devName.equals("월패드카메라")) {
  3528. SplitedMSG = devData.split("[(]");
  3529. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3530. String[] UseStr = SplitedMSG[2].split("[)]");
  3531. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3532. } else if (devName.equals("무드등")) {
  3533. SplitedMSG = devData.split("[(]");
  3534. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3535. String[] UseStr = SplitedMSG[2].split("[)]");
  3536. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3537. /*
  3538. UseStr = SplitedMSG[3].split("[)]");
  3539. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  3540. return false;
  3541. */
  3542. } else if (devName.equals("피난사다리")) {
  3543. SplitedMSG = devData.split("[(]");
  3544. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3545. String[] UseStr = SplitedMSG[2].split("[)]");
  3546. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3547. } else if (devName.equals("동체설정")) {
  3548. return true;
  3549. /*
  3550. SplitedMSG = devData.split("[(]");
  3551. if (!SplitedMSG[1].split(":")[1].equals(devName))
  3552. return false;
  3553. String[] UseStr = SplitedMSG[2].split("[)]");
  3554. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3555. return false;
  3556. if (UseStr[0].equals(isNotUse)) return true;
  3557. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3558. return false;
  3559. for (int i=3; i < SplitedMSG.length; i++)
  3560. {
  3561. UseStr = SplitedMSG[i].split("[)]");
  3562. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  3563. return false;
  3564. if (i != SplitedMSG.length-1)
  3565. {
  3566. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  3567. return false;
  3568. }
  3569. }
  3570. */
  3571. } else if (devName.equals("알람발생")) {
  3572. SplitedMSG = devData.split("[(]");
  3573. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3574. String[] UseStr = SplitedMSG[2].split("[)]");
  3575. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3576. } else if (devName.equals("UI순서")) {
  3577. SplitedMSG = devData.split("[(]");
  3578. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3579. String[] UseStr = SplitedMSG[2].split("[)]");
  3580. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3581. } else {
  3582. Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
  3583. Log.w("iMAP", "Return true");
  3584. return true;
  3585. }
  3586. } catch (RuntimeException re) {
  3587. LogUtil.errorLogInfo("", TAG, re);
  3588. return false;
  3589. } catch (Exception e) {
  3590. //e.printStackTrace();
  3591. LogUtil.errorLogInfo("", TAG, e);
  3592. return false;
  3593. }
  3594. return true;
  3595. }
  3596. ArrayList<String> roomNameList_light = null;
  3597. ArrayList<String> roomNameList_concent = null;
  3598. ArrayList<String> roomNameList_heating = null;
  3599. ArrayList<String> roomNameList_systemaircon = null;
  3600. ArrayList<String> roomNameList_purity = null;
  3601. ArrayList<String> roomNameList_shading = null;
  3602. public String ProcSetsetup(Document ele) {
  3603. Common.DebugLog("ProcSetsetup------------------------->");
  3604. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  3605. NodeList items = ele.getElementsByTagName("setting");
  3606. Node item;
  3607. String itemname = null;
  3608. String dateData = null;
  3609. String heartbeatP = null;
  3610. String Versions = null;
  3611. String SdbAccInit_Str = null;
  3612. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  3613. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  3614. if (!SettManager.StartTransaction()) {
  3615. ResetFlag = false;
  3616. RetVal += "\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  3617. SettManager.EndTransaction(false);
  3618. SettManager.closeDB();
  3619. return RetVal;
  3620. }
  3621. try {
  3622. for (int i = 0; i < items.getLength(); i++) {
  3623. item = items.item(i);
  3624. itemname = GetAttributeVal(item, "name");
  3625. if (itemname != null) {
  3626. if (itemname.equals("beat_time")) {
  3627. heartbeatP = GetAttributeVal(item, "value");
  3628. } else if (itemname.equals("ver_setting")) {
  3629. Versions = GetAttributeVal(item, "value");
  3630. } else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  3631. Element guardlist = (Element) item;
  3632. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  3633. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  3634. else continue;
  3635. for (int j = 0; j < GuardCTList.getLength(); j++) {
  3636. Node GuardListitem = GuardCTList.item(j);
  3637. String guardname = GetAttributeVal(GuardListitem, "name");
  3638. String guardvalue = GetAttributeVal(GuardListitem, "value");
  3639. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  3640. }
  3641. } else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  3642. Element subdevList = (Element) item;
  3643. NodeList SubDevList = subdevList.getElementsByTagName("list");
  3644. for (int j = 0; j < SubDevList.getLength(); j++) {
  3645. Node subdevListitem = SubDevList.item(j);
  3646. String devname = GetAttributeVal(subdevListitem, "name");
  3647. String devval = GetAttributeVal(subdevListitem, "value");
  3648. if (devname != null && devval != null) {
  3649. devname = devname.replaceAll("\\p{Z}", "");
  3650. devval = devval.replaceAll("\\p{Z}", "");
  3651. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  3652. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3653. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  3654. }
  3655. if (CheckSubdevData(devname, devval) == false) {
  3656. ResetFlag = false;
  3657. Log.w("iMAP", "Set Setup Fail name : " + devname + " Value : " + devval);
  3658. SettManager.EndTransaction(false);
  3659. SettManager.closeDB();
  3660. return MakeFailMessage(devname);
  3661. }
  3662. String[] SettingDBValue = SettManager.GetSettingData(devname);
  3663. if (SettingDBValue != null) {
  3664. String devInfo = SettingDBValue[1];
  3665. if (devInfo.equals(devval) == false) {
  3666. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3667. Log.w("iMAP", "DB Setup Value : " + devInfo);
  3668. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3669. ResetFlag = true;
  3670. }
  3671. } else {
  3672. Log.w("iMAP", "DB No Setup Name and Value");
  3673. Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
  3674. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3675. ResetFlag = true;
  3676. }
  3677. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  3678. if (devname.equals("로고설정")) {
  3679. String devInfo = devval;
  3680. devInfo = devInfo.replace('(', '_');
  3681. devInfo = devInfo.replace(':', '_');
  3682. devInfo = devInfo.replace(')', '_');
  3683. String[] DetailInfo = devInfo.split("_");
  3684. int LogoType = 0;
  3685. if (DetailInfo[5].equals("표시안함") == true) {
  3686. LogoType = 0;
  3687. } else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  3688. LogoType = 1;
  3689. } else if (DetailInfo[5].equals("양우내안애") == true) {
  3690. LogoType = 2;
  3691. } else if (DetailInfo[5].equals("GSITM") == true) {
  3692. LogoType = 3;
  3693. } else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  3694. LogoType = 4;
  3695. } else if (DetailInfo[5].equals("거실조명표시") == true) {
  3696. LogoType = 5;
  3697. } else if (DetailInfo[5].equals("거실조명삭제") == true) {
  3698. LogoType = 6;
  3699. } else if (DetailInfo[5].equals("기타1") == true) {
  3700. LogoType = 7;
  3701. } else if (DetailInfo[5].equals("기타2") == true) {
  3702. LogoType = 8;
  3703. }
  3704. if ((LogoType >= 0) && (LogoType <= 8)) {
  3705. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  3706. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3707. }
  3708. } else if (devname.equals("엘리베이터위젯복구")) {
  3709. String devInfo = devval;
  3710. devInfo = devInfo.replace('(', '_');
  3711. devInfo = devInfo.replace(':', '_');
  3712. devInfo = devInfo.replace(')', '_');
  3713. String[] DetailInfo = devInfo.split("_");
  3714. if (DetailInfo[3].equals("사용함") == true) {
  3715. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  3716. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3717. }
  3718. } else if (devname.equals("분전반알람설정")) {
  3719. try {
  3720. String devInfo = devval;
  3721. devInfo = devInfo.replace('(', '_');
  3722. devInfo = devInfo.replace(':', '_');
  3723. devInfo = devInfo.replace(')', '_');
  3724. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  3725. //[0] - 기기번호
  3726. //[1] - 회로수
  3727. //[2] - 기기이름
  3728. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  3729. //[4] - 명칭
  3730. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  3731. String[] DetailInfo = devInfo.split("_");
  3732. for (int a = 0; a < DetailInfo.length; a++) {
  3733. if (DetailInfo[a].equals("누적전력초기화")) {
  3734. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  3735. if ((a + 1) <= DetailInfo.length) {
  3736. // 설정정보가 존재해야 인식하도록 함
  3737. if (DetailInfo[a + 1].equals("1")) {
  3738. // 1(사용함) 일때
  3739. if (sdbAPI != null) {
  3740. if (sdbAPI.Set_AccPwReset() >= 0) {
  3741. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  3742. } else {
  3743. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  3744. }
  3745. }
  3746. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  3747. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  3748. }
  3749. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  3750. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  3751. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  3752. }
  3753. }
  3754. }
  3755. } catch (RuntimeException re) {
  3756. LogUtil.errorLogInfo("", TAG, re);
  3757. } catch (Exception e) {
  3758. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  3759. //e.printStackTrace();
  3760. LogUtil.errorLogInfo("", TAG, e);
  3761. }
  3762. } else if (devname.equals("욕실폰통화음량값")) {
  3763. Intent Iintent = new Intent();
  3764. Iintent.setAction(define.NOTIFY_ACNAME);
  3765. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  3766. sendBroadcast(Iintent);
  3767. } else if (devname.equals("주방TV통화음량값")) {
  3768. Intent Iintent = new Intent();
  3769. Iintent.setAction(define.NOTIFY_ACNAME);
  3770. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  3771. sendBroadcast(Iintent);
  3772. } else if (devname.equals("현관카메라")) {
  3773. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  3774. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3775. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3776. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  3777. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3778. String devInfo = devval;
  3779. if (devInfo != null) {
  3780. devInfo = devInfo.replace('(', '_');
  3781. devInfo = devInfo.replace(':', '_');
  3782. devInfo = devInfo.replace(')', '_');
  3783. String[] DetailInfo = devInfo.split("_");
  3784. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3785. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  3786. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3787. if (mIOInterface != null)
  3788. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3789. } else {
  3790. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  3791. if (mIOInterface != null)
  3792. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  3793. }
  3794. }
  3795. }
  3796. }
  3797. } else if (devname.equals("거동수상자녹화")) {
  3798. String devInfo = devval;
  3799. devInfo = devInfo.replace('(', '_');
  3800. devInfo = devInfo.replace(':', '_');
  3801. devInfo = devInfo.replace(')', '_');
  3802. String[] DetailInfo = devInfo.split("_");
  3803. } else if (devname.equals("스마트현관카메라좌우반전")) {
  3804. String devInfo = devval;
  3805. if (devInfo != null) {
  3806. devInfo = devInfo.replace('(', '_');
  3807. devInfo = devInfo.replace(':', '_');
  3808. devInfo = devInfo.replace(')', '_');
  3809. }
  3810. String[] DetailInfo = devInfo.split("_");
  3811. if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
  3812. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  3813. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  3814. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  3815. } else {
  3816. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  3817. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  3818. }
  3819. }
  3820. } else {
  3821. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  3822. }
  3823. }
  3824. }
  3825. } else if (itemname.equals("datetime")) {
  3826. dateData = GetAttributeVal(item, "value");
  3827. } else {
  3828. String GetVal = GetAttributeVal(item, "value");
  3829. if (GetVal != null) {
  3830. if (!GetVal.equals("list")) {
  3831. if (itemname.equals("site_code")) {
  3832. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  3833. if (Existing_SiteCode_Array == null) {
  3834. ResetFlag = true;
  3835. } else {
  3836. String Existing_SiteCode = Existing_SiteCode_Array[1];
  3837. if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
  3838. ResetFlag = true;
  3839. }
  3840. }
  3841. }
  3842. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  3843. } else {
  3844. String GetCNT = GetAttributeVal(item, "count");
  3845. if (Integer.parseInt(GetCNT) <= 0) continue;
  3846. Element SettingItem = (Element) item;
  3847. NodeList SettingList = SettingItem.getElementsByTagName("list");
  3848. for (int j = 0; j < SettingList.getLength(); j++) {
  3849. Node subdevListitem = SettingList.item(j);
  3850. String devname = GetAttributeVal(subdevListitem, "name");
  3851. String devval = GetAttributeVal(subdevListitem, "value");
  3852. SettManager.UpdateSettingData(itemname, devname, j, devval);
  3853. }
  3854. }
  3855. }
  3856. }
  3857. }
  3858. }
  3859. } catch (RuntimeException re) {
  3860. LogUtil.errorLogInfo("", TAG, re);
  3861. ResetFlag = false;
  3862. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3863. SettManager.EndTransaction(false);
  3864. SettManager.closeDB();
  3865. return RetVal;
  3866. } catch (Exception e) {
  3867. ResetFlag = false;
  3868. RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
  3869. //e.printStackTrace();
  3870. LogUtil.errorLogInfo("", TAG, e);
  3871. SettManager.EndTransaction(false);
  3872. SettManager.closeDB();
  3873. return RetVal;
  3874. }
  3875. SettManager.EndTransaction(true);
  3876. SettManager.closeDB();
  3877. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  3878. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  3879. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  3880. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  3881. }
  3882. if (AfterTransactionTodoList != null) {
  3883. if (AfterTransactionTodoList.size() > 0) {
  3884. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  3885. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  3886. if (afterTransactionTodoListData != null) {
  3887. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  3888. WallpadSalesSampleData mWallpadSalesSampleData;
  3889. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  3890. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  3891. mWallpadSalesSampleData.closeDB();
  3892. } else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  3893. //ifdb에 있는지
  3894. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  3895. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  3896. int result = devSet.Get_Elevator_Info();
  3897. devSet.closeDB();
  3898. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  3899. // 엘리베이터가 사용함이면
  3900. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  3901. boolean result_get_restoreUseOrNot;
  3902. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3903. if (wdb != null) {
  3904. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  3905. if (result_get_restoreUseOrNot == false) {
  3906. wdb.SetElevator_Widget_Restore(true);
  3907. //위젯 DB 초기화
  3908. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  3909. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  3910. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  3911. devSet2.initWidgetData();
  3912. devSet2.closeDB();
  3913. }
  3914. }
  3915. wdb.closeDB();
  3916. }
  3917. }
  3918. else if (afterTransactionTodoListData.Title.equals("방명칭편집_조명") || afterTransactionTodoListData.Title.equals("방명칭편집_콘센트") || afterTransactionTodoListData.Title.equals("방명칭편집_난방")
  3919. || afterTransactionTodoListData.Title.equals("방명칭편집_시스템에어컨") || afterTransactionTodoListData.Title.equals("방명칭편집_청정환기") || afterTransactionTodoListData.Title.equals("방명칭편집_차광")) {
  3920. String deviceType = afterTransactionTodoListData.ValueString;
  3921. Log.d(TAG, "[ProcSetsetup] deviceType [" + deviceType + "]");
  3922. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  3923. if (wdb != null) {
  3924. if (deviceType.equals(define.ROOM_NAME_LIGHT)) {
  3925. if (!wdb.GetRoomNameChangeByUser(deviceType)) {
  3926. Log.w(TAG, "[ProcSetsetup] Change LIGHT roomname by Manager!!! deviceType [" + deviceType + "]");
  3927. if (roomNameList_light != null) {
  3928. Log.d(TAG, "[ProcSetsetup] roomNameList_light = " + roomNameList_light.toString()); // debugging
  3929. String[] roomNameArr = roomNameList_light.toArray(new String[roomNameList_light.size()]);
  3930. wdb.SetDevRoomNameList(roomNameArr, deviceType);
  3931. wdb.SetRoomNameChangeByManager(1, deviceType);
  3932. if (roomNameList_light != null) roomNameList_light = null;
  3933. }
  3934. }
  3935. else {
  3936. Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
  3937. }
  3938. }
  3939. else if (deviceType.equals(define.ROOM_NAME_CONCENT)) {
  3940. if (!wdb.GetRoomNameChangeByUser(deviceType)) {
  3941. Log.w(TAG, "[ProcSetsetup] Change CONCENT roomname by Manager!!! deviceType [" + deviceType + "]");
  3942. if (roomNameList_concent != null) {
  3943. Log.d(TAG, "[ProcSetsetup] roomNameList_concent = " + roomNameList_concent.toString()); // debugging
  3944. String[] roomNameArr = roomNameList_concent.toArray(new String[roomNameList_concent.size()]);
  3945. wdb.SetDevRoomNameList(roomNameArr, deviceType);
  3946. wdb.SetRoomNameChangeByManager(1, deviceType);
  3947. if (roomNameList_concent != null) roomNameList_concent = null;
  3948. }
  3949. }
  3950. else {
  3951. Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
  3952. }
  3953. }
  3954. else if (deviceType.equals(define.ROOM_NAME_HEATING)) {
  3955. if (!wdb.GetRoomNameChangeByUser(deviceType)) {
  3956. Log.w(TAG, "[ProcSetsetup] Change HEATING roomname by Manager!!! deviceType [" + deviceType + "]");
  3957. if (roomNameList_heating != null) {
  3958. Log.d(TAG, "[ProcSetsetup] roomNameList_heating = " + roomNameList_heating.toString()); // debugging
  3959. String[] roomNameArr = roomNameList_heating.toArray(new String[roomNameList_heating.size()]);
  3960. wdb.SetDevRoomNameList(roomNameArr, deviceType);
  3961. wdb.SetRoomNameChangeByManager(1, deviceType);
  3962. if (roomNameList_heating != null) roomNameList_heating = null;
  3963. }
  3964. }
  3965. else {
  3966. Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
  3967. }
  3968. }
  3969. else if (deviceType.equals(define.ROOM_NAME_SYSTEMAIRCON)) {
  3970. if (!wdb.GetRoomNameChangeByUser(deviceType)) {
  3971. Log.w(TAG, "[ProcSetsetup] Change SYSTEM AIRCON roomname by Manager!!! deviceType [" + deviceType + "]");
  3972. if (roomNameList_systemaircon != null) {
  3973. Log.d(TAG, "[ProcSetsetup] roomNameList_systemaircon = " + roomNameList_systemaircon.toString()); // debugging
  3974. String[] roomNameArr = roomNameList_systemaircon.toArray(new String[roomNameList_systemaircon.size()]);
  3975. wdb.SetDevRoomNameList(roomNameArr, deviceType);
  3976. wdb.SetRoomNameChangeByManager(1, deviceType);
  3977. if (roomNameList_systemaircon != null) roomNameList_systemaircon = null;
  3978. }
  3979. }
  3980. else {
  3981. Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
  3982. }
  3983. }
  3984. else if (deviceType.equals(define.ROOM_NAME_PURITY)) {
  3985. if (!wdb.GetRoomNameChangeByUser(deviceType)) {
  3986. Log.w(TAG, "[ProcSetsetup] Change PURITY roomname by Manager!!! deviceType [" + deviceType + "]");
  3987. if (roomNameList_purity != null) {
  3988. Log.d(TAG, "[ProcSetsetup] roomNameList_purity = " + roomNameList_purity.toString()); // debugging
  3989. String[] roomNameArr = roomNameList_purity.toArray(new String[roomNameList_purity.size()]);
  3990. wdb.SetDevRoomNameList(roomNameArr, deviceType);
  3991. wdb.SetRoomNameChangeByManager(1, deviceType);
  3992. if (roomNameList_purity != null) roomNameList_purity = null;
  3993. }
  3994. }
  3995. else {
  3996. Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
  3997. }
  3998. }
  3999. else if (deviceType.equals(define.ROOM_NAME_SHADING)) {
  4000. if (!wdb.GetRoomNameChangeByUser(deviceType)) {
  4001. Log.w(TAG, "[ProcSetsetup] Change SHADING roomname by Manager!!! deviceType [" + deviceType + "]");
  4002. if (roomNameList_shading != null) {
  4003. Log.d(TAG, "[ProcSetsetup] roomNameList_shading = " + roomNameList_shading.toString()); // debugging
  4004. String[] roomNameArr = roomNameList_shading.toArray(new String[roomNameList_shading.size()]);
  4005. wdb.SetDevRoomNameList(roomNameArr, deviceType);
  4006. wdb.SetRoomNameChangeByManager(1, deviceType);
  4007. if (roomNameList_shading != null) roomNameList_shading = null;
  4008. }
  4009. }
  4010. else {
  4011. Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
  4012. }
  4013. }
  4014. }
  4015. wdb.closeDB();
  4016. }
  4017. }
  4018. }
  4019. }
  4020. }
  4021. }
  4022. if (dateData != null) {
  4023. try {
  4024. int year = Integer.parseInt(dateData.substring(0, 4));
  4025. int month = Integer.parseInt(dateData.substring(4, 6));
  4026. int day = Integer.parseInt(dateData.substring(6, 8));
  4027. int hour = Integer.parseInt(dateData.substring(8, 10));
  4028. int min = Integer.parseInt(dateData.substring(10, 12));
  4029. int sec = Integer.parseInt(dateData.substring(12, 14));
  4030. Calendar nowdate = new GregorianCalendar();
  4031. long settedtime = nowdate.getTimeInMillis();
  4032. nowdate.set(Calendar.YEAR, year);
  4033. nowdate.set(Calendar.MONTH, month);
  4034. nowdate.set(Calendar.DAY_OF_MONTH, day);
  4035. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  4036. nowdate.set(Calendar.MINUTE, min);
  4037. nowdate.set(Calendar.SECOND, sec);
  4038. long bootupmil = nowdate.getTimeInMillis();
  4039. if (Math.abs(bootupmil - settedtime) > 5000) {
  4040. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4041. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  4042. DBMGR.closeDB();
  4043. Intent Iintent = new Intent();
  4044. Iintent.setAction(define.NOTIFY_ACNAME);
  4045. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  4046. sendBroadcast(Iintent);
  4047. }
  4048. } catch (RuntimeException re) {
  4049. LogUtil.errorLogInfo("", TAG, re);
  4050. } catch (Exception e) {
  4051. //e.printStackTrace();
  4052. LogUtil.errorLogInfo("", TAG, e);
  4053. }
  4054. }
  4055. if (heartbeatP != null) {
  4056. try {
  4057. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4058. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  4059. DBMGR.closeDB();
  4060. } catch (RuntimeException re) {
  4061. LogUtil.errorLogInfo("", TAG, re);
  4062. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  4063. SettManager.closeDB();
  4064. return RetVal;
  4065. } catch (Exception e) {
  4066. //e.printStackTrace();
  4067. LogUtil.errorLogInfo("", TAG, e);
  4068. RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  4069. SettManager.closeDB();
  4070. return RetVal;
  4071. }
  4072. }
  4073. if (Versions != null) {
  4074. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4075. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  4076. DBMGR.SetSettingVer(Versions);
  4077. DBMGR.closeDB();
  4078. }
  4079. Intent intent = new Intent();
  4080. intent.setAction(define.NOTIFY_ACNAME);
  4081. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  4082. getApplicationContext().sendBroadcast(intent);
  4083. RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
  4084. return RetVal;
  4085. }
  4086. public String ProcNotifyparcel(Document doc) {
  4087. String moveInfo = "null";
  4088. String boxNo = "null";
  4089. String serviceInfo = "null";
  4090. String receiverInfo = "null";
  4091. String message = "null";
  4092. int remainCnt = 0;
  4093. try {
  4094. NodeList param = doc.getElementsByTagName("move_info");
  4095. Node item = param.item(0);
  4096. moveInfo = trimquotation(item.getTextContent());
  4097. param = doc.getElementsByTagName("params");
  4098. item = param.item(0);
  4099. if (item != null) {
  4100. boxNo = GetAttributeVal(item, "box_num");
  4101. serviceInfo = GetAttributeVal(item, "service_info");
  4102. receiverInfo = GetAttributeVal(item, "receiver_info");
  4103. message = GetAttributeVal(item, "message");
  4104. if (message != null) {
  4105. String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
  4106. if (msgList[0].equalsIgnoreCase("remains")) {
  4107. remainCnt = Integer.parseInt(msgList[1]);
  4108. if (remainCnt > 0) {
  4109. wakeupLCD();
  4110. Intent intent = new Intent();
  4111. intent.setAction(define.NOTIFY_ACNAME);
  4112. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  4113. intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
  4114. intent.putExtra("BOX_NO", boxNo);
  4115. intent.putExtra("SERVICE_INFO", serviceInfo);
  4116. intent.putExtra("RECEIVER_INFO", receiverInfo);
  4117. intent.putExtra("REMAIN_CNT", remainCnt);
  4118. getApplicationContext().sendBroadcast(intent);
  4119. }
  4120. }
  4121. }
  4122. }
  4123. String retVal = XMLHeader +
  4124. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n" +
  4125. "</imap>\r\n";
  4126. return retVal;
  4127. } catch (RuntimeException re) {
  4128. LogUtil.errorLogInfo("", TAG, re);
  4129. String retVal = XMLHeader +
  4130. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4131. "</imap>\r\n";
  4132. return retVal;
  4133. } catch (Exception e) {
  4134. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4135. //e.printStackTrace();
  4136. LogUtil.errorLogInfo("", TAG, e);
  4137. String retVal = XMLHeader +
  4138. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
  4139. "</imap>\r\n";
  4140. return retVal;
  4141. }
  4142. }
  4143. public String ProcNotiPostInfo(Document doc) {
  4144. NodeList param = doc.getElementsByTagName("move_info");
  4145. Node item = param.item(0);
  4146. String aa = item.getTextContent();
  4147. aa = trimquotation(aa);
  4148. if (item != null) {
  4149. String info = item.getTextContent();
  4150. if (info != null) {
  4151. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4152. if (info.contains("post_in")) { // 우편물 보관
  4153. wakeupLCD();
  4154. int itemCount = -1;
  4155. param = doc.getElementsByTagName("params");
  4156. item = param.item(0);
  4157. if (item != null) {
  4158. String devname = GetAttributeVal(item, "message");
  4159. if (devname != null) {
  4160. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4161. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4162. if (msgList[0].equalsIgnoreCase("remains")) {
  4163. itemCount = Integer.parseInt(msgList[1]);
  4164. }
  4165. }
  4166. }
  4167. }
  4168. if (itemCount > 0) {
  4169. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4170. Intent intent = new Intent();
  4171. intent.setAction(define.NOTIFY_ACNAME);
  4172. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4173. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4174. intent.putExtra("ITEM", itemCount);
  4175. getApplicationContext().sendBroadcast(intent);
  4176. }
  4177. }
  4178. }
  4179. }
  4180. String retVal = XMLHeader +
  4181. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n" +
  4182. "</imap>\r\n";
  4183. return retVal;
  4184. }
  4185. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4186. public String ProcNotifypark(Document doc)
  4187. {
  4188. String MoveInfo = "none";
  4189. NodeList param = doc.getElementsByTagName("destination");
  4190. Node item = param.item(0);
  4191. if (item != null)
  4192. {
  4193. String dong = GetAttributeVal(item, "id_high").trim();
  4194. String ho = GetAttributeVal(item, "id_low").trim();
  4195. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4196. return (XMLHeader +
  4197. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4198. "</imap>\r\n");
  4199. }
  4200. param = doc.getElementsByTagName("move_info");
  4201. item = param.item(0);
  4202. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4203. param = doc.getElementsByTagName("params");
  4204. item = param.item(0);
  4205. if (item != null)
  4206. {
  4207. String carnum = GetAttributeVal(item, "car_num");
  4208. String locinfo = GetAttributeVal(item, "loc_info");
  4209. String msg = GetAttributeVal(item, "message");
  4210. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4211. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4212. parkdb.closeDB();Intent intent = new Intent();
  4213. intent.setAction(define.NOTIFY_ACNAME);
  4214. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4215. getApplicationContext().sendBroadcast(intent);
  4216. }
  4217. String retVal = XMLHeader +
  4218. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4219. "</imap>\r\n";
  4220. return retVal;
  4221. }
  4222. */
  4223. public String ProcGetsetup(Document doc) {
  4224. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4225. NodeList items = doc.getElementsByTagName("variable");
  4226. String RetVal = XMLHeader + "<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n" +
  4227. " <guidemap devtype=\"homedev\" count=\"" + items.getLength() + "\">\r\n";
  4228. Node item;
  4229. try {
  4230. for (int i = 0; i < items.getLength(); i++) {
  4231. item = items.item(i);
  4232. //String mRealTimeMeterData = item.getNodeValue();
  4233. String data = trimquotation(item.getTextContent());
  4234. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4235. if (gData.size() == 1) {
  4236. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + gData.get(0)[1] + "\" />\r\n";
  4237. } else if (gData.size() > 1) {
  4238. RetVal += " <setting name=\"" + data + "\" count=\"" + gData.size() + "\" value=\"list\" >\r\n";
  4239. RetVal += " <list name=\"DeviceInfo\" value=\"" + Build.MODEL + "/" + getAOSVerCode() + "\" />\r\n";
  4240. for (int k = 0; k < gData.size(); k++) {
  4241. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4242. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4243. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4244. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4245. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4246. }
  4247. RetVal += " <list name=\"" + gData.get(k)[0] + "\" value=\"" + gData.get(k)[1] + "\" />\r\n";
  4248. }
  4249. if (bAirQualityEnable) {
  4250. RetVal += " <list name=\"공기질센서버전\" value=\"" + getAirQualityInfo() + "\" />\r\n";
  4251. }
  4252. RetVal += " </setting>\r\n";
  4253. } else {
  4254. if (data.equals("beat_time")) {
  4255. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4256. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4257. DBMGR.closeDB();
  4258. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + heartbeatP + "\" />\r\n";
  4259. } else if (data.equals("ver_setting")) {
  4260. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4261. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + DBMGR.GetSettingVer() + "\" />\r\n";
  4262. DBMGR.closeDB();
  4263. } else if (data.equals("datetime")) {
  4264. Calendar cal = new GregorianCalendar();
  4265. 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";
  4266. } else if (data.equals("security_state")) {
  4267. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4268. int alarmST = DBMGR.GetAlarmStatus();
  4269. String SEC_ST;
  4270. if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
  4271. else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
  4272. else SEC_ST = "normal";
  4273. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + SEC_ST + "\" />\r\n";
  4274. DBMGR.closeDB();
  4275. } else if (data.equals("sensor_state")) {
  4276. int senIDX = 0;
  4277. String resultStr = "";
  4278. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4279. int BugSensor = DBMGR.Get_Sensor_Set();
  4280. WallPadInterface wpifc = new WallPadInterface();
  4281. if (BugSensor > 0) {
  4282. if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4283. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4284. String Senret;
  4285. if (outSen > 0) Senret = "detect";
  4286. else Senret = "undetect";
  4287. resultStr += " <list name=\"in_move\" count=\"0\" value=\"" + Senret + "\" />\r\n";
  4288. senIDX++;
  4289. } else {
  4290. if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4291. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4292. String Senret;
  4293. if (outSen > 0) Senret = "detect";
  4294. else Senret = "undetect";
  4295. resultStr += " <list name=\"in_move\" value=\"" + Senret + "\" />\r\n";
  4296. senIDX++;
  4297. }
  4298. if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4299. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4300. String Senret;
  4301. if (outSen > 0) Senret = "detect";
  4302. else Senret = "undetect";
  4303. resultStr += " <list name=\"out_move\" value=\"" + Senret + "\" />\r\n";
  4304. senIDX++;
  4305. }
  4306. }
  4307. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4308. String Senret;
  4309. if (outSen > 0) Senret = "detect";
  4310. else Senret = "undetect";
  4311. resultStr += " <list name=\"magnetic\" value=\"" + Senret + "\" />\r\n";
  4312. senIDX++;
  4313. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4314. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4315. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4316. if (outSen > 0) Senret = "detect";
  4317. else Senret = "undetect";
  4318. resultStr += " <list name=\"emergency\" value=\"" + Senret + "\" />\r\n";
  4319. senIDX++;
  4320. }
  4321. DBMGR.closeDB();
  4322. }
  4323. if (senIDX > 0) {
  4324. RetVal += " <setting name = \"sensor_state\" count = \"" + senIDX + "\" value = \"list\" >\r\n";
  4325. RetVal += resultStr;
  4326. RetVal += " </setting>\r\n";
  4327. }
  4328. } else if (data.equals("statusbeat_time")) {
  4329. } else {
  4330. RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"\" />\r\n";
  4331. }
  4332. }
  4333. }
  4334. } catch (RuntimeException re) {
  4335. LogUtil.errorLogInfo("", TAG, re);
  4336. } catch (Exception e) {
  4337. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4338. //e.printStackTrace();
  4339. LogUtil.errorLogInfo("", TAG, e);
  4340. }
  4341. SettManager.closeDB();
  4342. RetVal += " </guidemap>\r\n </service>\r\n</imap>";
  4343. return RetVal;
  4344. }
  4345. public void ProcElevatorinfo(Element ele) {
  4346. try {
  4347. String floor;
  4348. String move_dir;
  4349. /*
  4350. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4351. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4352. Node info = evinfo.item(0);
  4353. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4354. if (info != null)
  4355. {
  4356. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4357. }
  4358. */
  4359. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4360. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
  4361. Node iinfo = ievinfo.item(0);
  4362. if (iinfo == null) {
  4363. Log.d("iMapServer", "func ProcElevatorinfo info == null");
  4364. return;
  4365. }
  4366. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4367. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4368. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4369. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4370. if (move_dir != null) {
  4371. if (move_dir.equalsIgnoreCase("up")) {
  4372. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4373. } else if (move_dir.equalsIgnoreCase("down")) {
  4374. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4375. } else if (move_dir.equalsIgnoreCase("stop")) {
  4376. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4377. } else if (move_dir.equalsIgnoreCase("wrong")) {
  4378. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4379. } else if (move_dir.equalsIgnoreCase("finish")) {
  4380. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4381. }
  4382. Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
  4383. }
  4384. byte updown = 0x00;
  4385. if (ievinfo != null) {
  4386. boolean downCall = false;
  4387. boolean upCall = false;
  4388. for (int i = 0; i < ievinfo.getLength(); i++) {
  4389. Node valItem = ievinfo.item(i);
  4390. if (valItem != null) {
  4391. if (downCall == false) {
  4392. String val = GetAttributeVal(valItem, "ev_call_dir");
  4393. if (val != null)
  4394. downCall = val.equalsIgnoreCase("down");
  4395. }
  4396. if (upCall == false) {
  4397. String val = GetAttributeVal(valItem, "ev_call_dir");
  4398. if (val != null) {
  4399. upCall = val.equalsIgnoreCase("up");
  4400. }
  4401. }
  4402. }
  4403. }
  4404. Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
  4405. if (downCall == true && upCall == true) updown = 0x02;
  4406. else if (downCall == false && upCall == true) updown = 0x01;
  4407. }
  4408. Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  4409. Intent intent = new Intent();
  4410. intent.setAction(define.NOTIFY_ACNAME);
  4411. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  4412. intent.putExtra(define.NOTIBR_FLOOR, floor);
  4413. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  4414. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  4415. getApplicationContext().sendBroadcast(intent);
  4416. } catch (RuntimeException re) {
  4417. LogUtil.errorLogInfo("", TAG, re);
  4418. } catch (Exception e) {
  4419. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  4420. //e.printStackTrace();
  4421. LogUtil.errorLogInfo("", TAG, e);
  4422. }
  4423. }
  4424. private String MakeTargetStr(WallpadiCMDParser data) {
  4425. return " <target name=\"" + data.target + "\" id = \"" + data.tid + "\" msg_no=\"" + data.msgno + "\"/>\r\n";
  4426. }
  4427. public String iCMDProcVentilControl(Document doc) {
  4428. try {
  4429. String unit_status = "null", mode = "null", unit_mode = "null";
  4430. String retStr = CheckiCMDProc("remote_access_ventil");
  4431. if (retStr != null) return retStr;
  4432. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  4433. String target = "null", tid = "null", msgno = "null";
  4434. NodeList items = doc.getElementsByTagName("target");
  4435. Node item = items.item(0);
  4436. if (item != null) {
  4437. NamedNodeMap attrs = item.getAttributes();
  4438. for (int j = 0; j < attrs.getLength(); j++) {
  4439. Node attr = attrs.item(j);
  4440. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4441. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4442. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4443. msgno = attr.getNodeValue();
  4444. }
  4445. }
  4446. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4447. if (NewServerUse()) {
  4448. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4449. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4450. return ServerCheckResult;
  4451. }
  4452. boolean procSucc = true;
  4453. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  4454. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  4455. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  4456. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4457. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  4458. boolean OnOff = false;
  4459. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  4460. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  4461. else procSucc = false;
  4462. } else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  4463. byte strength = 0;
  4464. if (ventilParser.ctraction.equalsIgnoreCase("low"))
  4465. strength = VentiAPI.WIND.LOW;
  4466. else if (ventilParser.ctraction.equalsIgnoreCase("mid"))
  4467. strength = VentiAPI.WIND.MID;
  4468. else strength = VentiAPI.WIND.HI;
  4469. if (VentilCTR.data.OnOff) {
  4470. // 환기가 On인 경우
  4471. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4472. else procSucc = false;
  4473. } else {
  4474. // 환기가 Off인 경우
  4475. if (VentilCTR.SetOnOff(true) >= 0) {
  4476. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  4477. else procSucc = false;
  4478. } else {
  4479. procSucc = false;
  4480. }
  4481. }
  4482. }
  4483. if (VentilCTR.Refresh(true) == 0) {
  4484. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4485. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4486. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4487. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4488. else unit_status = "unknown";
  4489. if (VentilCTR.data.Support.AutoDriving) {
  4490. mode = "normal/auto";
  4491. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4492. else unit_mode = "normal";
  4493. } else {
  4494. mode = "normal";
  4495. unit_mode = "normal";
  4496. }
  4497. } else {
  4498. procSucc = false;
  4499. }
  4500. } else {
  4501. procSucc = false;
  4502. }
  4503. } else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  4504. if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
  4505. if (VentilCTR.data.OnOff == false) unit_status = "off";
  4506. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  4507. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  4508. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  4509. else unit_status = "unknown";
  4510. if (VentilCTR.data.Support.AutoDriving) {
  4511. mode = "normal/auto";
  4512. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  4513. else unit_mode = "normal";
  4514. } else {
  4515. mode = "normal";
  4516. unit_mode = "normal";
  4517. }
  4518. } else {
  4519. procSucc = false;
  4520. }
  4521. } else {
  4522. procSucc = false;
  4523. }
  4524. if (procSucc == false) {
  4525. retStr += (" result=\"fail\" >\r\n");
  4526. unit_status = "unknown";
  4527. } else {
  4528. retStr += (" result=\"ok\" >\r\n");
  4529. }
  4530. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  4531. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  4532. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  4533. // retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4534. retStr += " <status_info unit_num=\"ventil\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  4535. return retStr;
  4536. } catch (RuntimeException re) {
  4537. LogUtil.errorLogInfo("", TAG, re);
  4538. return null;
  4539. } catch (Exception e) {
  4540. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  4541. //e.printStackTrace();
  4542. LogUtil.errorLogInfo("", TAG, e);
  4543. return null;
  4544. }
  4545. }
  4546. public String iCMDProcTemperControl(Document doc) {
  4547. try {
  4548. String target = "null", tid = "null", msgno = "null";
  4549. String retStr = CheckiCMDProc("remote_access_temper");
  4550. if (retStr != null) return retStr;
  4551. else
  4552. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  4553. NodeList items = doc.getElementsByTagName("target");
  4554. Node item = items.item(0);
  4555. if (item != null) {
  4556. NamedNodeMap attrs = item.getAttributes();
  4557. for (int j = 0; j < attrs.getLength(); j++) {
  4558. Node attr = attrs.item(j);
  4559. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4560. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4561. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  4562. }
  4563. }
  4564. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4565. if (NewServerUse()) {
  4566. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  4567. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4568. return ServerCheckResult;
  4569. }
  4570. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  4571. //String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  4572. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  4573. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_HEATING);
  4574. if(knxRoomNameList==null) knxRoomNameList = mDefaultRoomNameList_Heating;
  4575. // 난방 종류를 얻어온다.
  4576. int HeatingKind = mWallPadAPI.GetHeatingKind();
  4577. HeatingV1API heatingV1API = null;
  4578. HeatingV2API heatingV2API = null;
  4579. // 종류별 API를 로딩한다.
  4580. if (HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  4581. else if (HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  4582. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  4583. if (tempercmd.actionTXT.equals("control")) {
  4584. String[] CtrList;
  4585. byte ctrl = 0;
  4586. byte roomNum = (byte) 0xFF;
  4587. double temp = 0;
  4588. if (tempercmd.unitnum.equals("all")) {
  4589. if (tempercmd.ctraction.equals("on")) {
  4590. ctrl = 1;
  4591. } else if (tempercmd.ctraction.equals("off")) {
  4592. ctrl = 0;
  4593. } else {
  4594. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\" />\r\n </service>\r\n</imap> ";
  4595. return retStr;
  4596. }
  4597. } else {
  4598. CtrList = tempercmd.ctraction.split("/");
  4599. if (CtrList[0].equals("on")) ctrl = 1;
  4600. else ctrl = 0;
  4601. roomNum = (byte) 0xFF;
  4602. temp = Double.parseDouble(CtrList[1]);
  4603. }
  4604. if (HeatingKind == 1) {
  4605. boolean OnOff = false;
  4606. if (ctrl == 1) OnOff = true;
  4607. if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
  4608. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  4609. if (ret != APIErrorCode.C_SUCCESS) {
  4610. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  4611. return retStr;
  4612. }
  4613. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4614. } else {
  4615. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4616. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4617. roomNum = i;
  4618. break;
  4619. }
  4620. }
  4621. if (roomNum == (byte) 0xFF) {
  4622. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4623. return retStr;
  4624. }
  4625. if (heatingV1API != null) {
  4626. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
  4627. if (ret != APIErrorCode.C_SUCCESS) {
  4628. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4629. return retStr;
  4630. }
  4631. heatingV1API.Refresh(roomNum, false);
  4632. }
  4633. }
  4634. }
  4635. else if (HeatingKind == 2) {
  4636. byte Mode = HeatingV2.MODE.HeatingOFF;
  4637. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  4638. if (tempercmd.unitnum.equals("all")) {
  4639. if (heatingV2API != null) {
  4640. int ret_pre = heatingV2API.SetAllRoomStatus(HeatingV2.MODE.PauseRelease);
  4641. int ret = heatingV2API.SetAllRoomStatus(Mode);
  4642. if (ret_pre != APIErrorCode.C_SUCCESS && ret != APIErrorCode.C_SUCCESS) {
  4643. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4644. return retStr;
  4645. }
  4646. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  4647. }
  4648. } else {
  4649. int nDevNum = Integer.parseInt(tempercmd.devnum)-1;
  4650. if (heatingV2API != null) {
  4651. int ret = heatingV2API.SetEachRoomStatus((byte) nDevNum, Mode, temp);
  4652. if (ret != APIErrorCode.C_SUCCESS) {
  4653. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4654. return retStr;
  4655. }
  4656. heatingV2API.Refresh((byte) nDevNum, false);
  4657. }
  4658. }
  4659. }
  4660. else {
  4661. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4662. return retStr;
  4663. }
  4664. }
  4665. String resultStr = " <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  4666. if (HeatingKind == 1) {
  4667. try {
  4668. if (heatingV1API == null) {
  4669. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4670. return retStr;
  4671. }
  4672. byte RoomCount = heatingV1API.data.Device.RoomCount;
  4673. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  4674. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount + "\"/>\r\n";
  4675. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  4676. String drvmode = "off";
  4677. for (byte i = 0; i < RoomCount; i++) {
  4678. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  4679. if (roomData.bOnOff) drvmode = "on";
  4680. else drvmode = "off";
  4681. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4682. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4683. }
  4684. resultStr += " </service>\r\n</imap>\r\n";
  4685. retStr += ("\"ok\">\r\n" + resultStr);
  4686. return retStr;
  4687. } else {
  4688. String drvmode = "off";
  4689. byte roomNum = (byte) 0xFF;
  4690. for (byte i = 0; i < knxRoomNameList.length; i++) {
  4691. if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
  4692. roomNum = i;
  4693. break;
  4694. }
  4695. }
  4696. if (roomNum == (byte) 0xFF) {
  4697. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4698. return retStr;
  4699. }
  4700. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  4701. if (roomData.bOnOff) drvmode = "on";
  4702. else drvmode = "off";
  4703. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4704. resultStr += " <status_info unit_num=\"" + knxRoomNameList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4705. resultStr += " </service>\r\n</imap>\r\n";
  4706. retStr += ("\"ok\">\r\n" + resultStr);
  4707. return retStr;
  4708. }
  4709. } catch (RuntimeException re) {
  4710. LogUtil.errorLogInfo("", TAG, re);
  4711. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4712. return retStr;
  4713. } catch (Exception e) {
  4714. //e.printStackTrace();
  4715. LogUtil.errorLogInfo("", TAG, e);
  4716. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4717. return retStr;
  4718. }
  4719. }
  4720. else if (HeatingKind == 2) {
  4721. try {
  4722. if (heatingV2API == null) {
  4723. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4724. return retStr;
  4725. }
  4726. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  4727. resultStr += " <action> \"" + tempercmd.actionTXT + "\"</action>\r\n";
  4728. //resultStr += " <status_map dev_num=\"1\" unit_cnt = \"" + RoomCount + "\" />\r\n";
  4729. if ((tempercmd.devnum.equals("all"))) {
  4730. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
  4731. String drvmode = "off";
  4732. for (byte i = 0; i < RoomCount; i++) {
  4733. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  4734. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4735. else drvmode = "off";
  4736. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4737. resultStr += " <status_map dev_num=\"" + (i+1) + "\" unit_cnt = \"1\"/>\r\n";
  4738. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  4739. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + knxRoomNameList[i] + "\"/>\r\n";
  4740. } else {
  4741. resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4742. }
  4743. }
  4744. resultStr += " </service>\r\n</imap>\r\n";
  4745. retStr += ("\"ok\">\r\n" + resultStr);
  4746. return retStr;
  4747. }
  4748. else {
  4749. String drvmode = "off";
  4750. int nDevNum = Integer.parseInt(tempercmd.devnum);
  4751. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum-1];
  4752. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  4753. else drvmode = "off";
  4754. drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
  4755. resultStr += " <status_map dev_num=\"" + (nDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  4756. resultStr += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
  4757. resultStr += " </service>\r\n</imap>\r\n";
  4758. retStr += ("\"ok\">\r\n" + resultStr);
  4759. return retStr;
  4760. }
  4761. } catch (RuntimeException re) {
  4762. LogUtil.errorLogInfo("", TAG, re);
  4763. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4764. return retStr;
  4765. } catch (Exception e) {
  4766. //e.printStackTrace();
  4767. LogUtil.errorLogInfo("", TAG, e);
  4768. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4769. return retStr;
  4770. }
  4771. } else {
  4772. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
  4773. retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  4774. return retStr;
  4775. }
  4776. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  4777. // return retStr;
  4778. } catch (RuntimeException re) {
  4779. LogUtil.errorLogInfo("", TAG, re);
  4780. return null;
  4781. } catch (Exception e) {
  4782. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  4783. //e.printStackTrace();
  4784. LogUtil.errorLogInfo("", TAG, e);
  4785. return null;
  4786. }
  4787. }
  4788. public String iCMDProcDoorlockControl(Document doc) {
  4789. try {
  4790. String DLStatus = "none";
  4791. String strResult = CheckiCMDProc("remote_access_doorlock");
  4792. if (strResult != null) return strResult;
  4793. else
  4794. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  4795. String target = "null", tid = "null", msgno = "null";
  4796. NodeList items = doc.getElementsByTagName("target");
  4797. Node item = items.item(0);
  4798. if (item != null) {
  4799. NamedNodeMap attrs = item.getAttributes();
  4800. for (int j = 0; j < attrs.getLength(); j++) {
  4801. Node attr = attrs.item(j);
  4802. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  4803. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  4804. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  4805. msgno = attr.getNodeValue();
  4806. }
  4807. }
  4808. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  4809. if (NewServerUse()) {
  4810. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  4811. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  4812. return ServerCheckResult;
  4813. }
  4814. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  4815. try {
  4816. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  4817. if (doorStatus != null) {
  4818. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  4819. DLStatus = "unknown";
  4820. } else {
  4821. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce)
  4822. DLStatus = "close";
  4823. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce)
  4824. DLStatus = "open";
  4825. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation)
  4826. DLStatus = "ing";
  4827. else DLStatus = "unknown";
  4828. }
  4829. }
  4830. } catch (RuntimeException re) {
  4831. LogUtil.errorLogInfo("", TAG, re);
  4832. DLStatus = "unknown";
  4833. } catch (Exception e) {
  4834. //e.printStackTrace();
  4835. LogUtil.errorLogInfo("", TAG, e);
  4836. DLStatus = "unknown";
  4837. }
  4838. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n" +
  4839. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n" +
  4840. " <action>\"status\"</action>\r\n" +
  4841. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n" +
  4842. " <status_info unit_num=\"doorlock1\" unit_status=\"" + DLStatus + "\"/>\r\n </service>\r\n</imap>";
  4843. return retXML;
  4844. } catch (RuntimeException re) {
  4845. LogUtil.errorLogInfo("", TAG, re);
  4846. return null;
  4847. } catch (Exception e) {
  4848. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  4849. //e.printStackTrace();
  4850. LogUtil.errorLogInfo("", TAG, e);
  4851. return null;
  4852. }
  4853. }
  4854. /*
  4855. protected String iCMDProcsavelog(Document doc)
  4856. {
  4857. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  4858. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  4859. NodeList items = doc.getElementsByTagName("guidemap");
  4860. Node item = items.item(0);
  4861. NamedNodeMap attrsParam = item.getAttributes();
  4862. for(int j=0; j< attrsParam.getLength();j++)
  4863. {
  4864. Node attr = attrsParam.item(j);
  4865. if (attr.getNodeName().equalsIgnoreCase("enable"))
  4866. {
  4867. String enable = attr.getNodeValue();
  4868. if (enable == null) return FailretStr;
  4869. if (enable.equals("false"))
  4870. {
  4871. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4872. logSet.SetLogDoing(0);
  4873. logSet.closeDB();
  4874. return SucretStr;
  4875. }
  4876. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4877. logSet.SetLogDoing(1);
  4878. logSet.closeDB();
  4879. }
  4880. }
  4881. items = doc.getElementsByTagName("setting");
  4882. item = items.item(0);
  4883. attrsParam = item.getAttributes();
  4884. String SaveType = "";
  4885. String FtpLoc = "";
  4886. String Ftpuser = "";
  4887. String FtpPW= "";
  4888. String period = "";
  4889. String FileSize = "";
  4890. for(int j=0; j< attrsParam.getLength();j++)
  4891. {
  4892. Node attr = attrsParam.item(j);
  4893. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  4894. SaveType = attr.getNodeValue();
  4895. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  4896. FtpLoc = attr.getNodeValue();
  4897. else if (attr.getNodeName().equalsIgnoreCase("user"))
  4898. Ftpuser = attr.getNodeValue();
  4899. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  4900. FtpPW = attr.getNodeValue();
  4901. else if (attr.getNodeName().equalsIgnoreCase("period"))
  4902. period = attr.getNodeValue();
  4903. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  4904. FileSize = attr.getNodeValue();
  4905. }
  4906. if (SaveType.equalsIgnoreCase("now"))
  4907. {
  4908. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  4909. LogUpThread.start();
  4910. return SucretStr;
  4911. }
  4912. else if (SaveType.equalsIgnoreCase("periodic"))
  4913. {
  4914. try
  4915. {
  4916. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  4917. period = period.trim();
  4918. String[] logperiod = period.split("[-]");
  4919. String StartDate = logperiod[0].replace(".", "_");
  4920. String EndDate = logperiod[1].replace(".", "_");
  4921. logSet.SetLogDoing(1);
  4922. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  4923. if (FileSize.equalsIgnoreCase("null"))
  4924. logSet.SetLogLogFileSize(0);
  4925. else
  4926. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  4927. logSet.SetLogStartDate(StartDate);
  4928. logSet.SetLogEndDate(EndDate);
  4929. logSet.closeDB();
  4930. return SucretStr;
  4931. }
  4932. catch (RuntimeException re) {
  4933. LogUtil.errorLogInfo("", TAG, re);
  4934. }
  4935. catch (Exception e)
  4936. {
  4937. e.printStackTrace();
  4938. return FailretStr;
  4939. }
  4940. }
  4941. else
  4942. {
  4943. return FailretStr;
  4944. }
  4945. }
  4946. */
  4947. protected void SendLogSaved(String ftploc, String fname, String size) {
  4948. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n" +
  4949. " <device_info devtype=\"homedev\" id_high=\"" + AddrDong + "\" id_low=\"" + AddrHo + "\"/>\r\n" +
  4950. " <file_info path=\"" + ftploc + "\" name=\"" + fname + "\" size=\"" + size + "\"/>\r\n</service>\r\n</imap>";
  4951. SendToServer(SendMsg);
  4952. }
  4953. public final static int FTPLOGTRSUCC = 1110;
  4954. public final static int FTPLOGTRFAIL = 1120;
  4955. Handler FileTrHandler = new Handler() {
  4956. public void handleMessage(Message msg) {
  4957. switch (msg.what) {
  4958. case FTPLOGTRSUCC:
  4959. String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  4960. File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
  4961. int size = (int) (fileinfo.length() / 1024);
  4962. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  4963. imapsvrlog("FTPLOGTRSUCC");
  4964. break;
  4965. case FTPLOGTRFAIL:
  4966. imapsvrlog("FTPLOGTRFAIL");
  4967. break;
  4968. }
  4969. }
  4970. };
  4971. class LogUploader extends Thread {
  4972. int fileidx = 0;
  4973. boolean TRing = false;
  4974. String FtpLoc;
  4975. String FtpID;
  4976. String FtpPasswd;
  4977. class ftpuploader extends WallPadFTPUploader {
  4978. String filename;
  4979. public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
  4980. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
  4981. filename = LocalFile;
  4982. }
  4983. protected void ProcUploadFail() {
  4984. Message TrResult = FileTrHandler.obtainMessage();
  4985. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4986. TrResult.what = FTPLOGTRFAIL;
  4987. TRing = false;
  4988. imapsvrlog("Send Log Fail Message");
  4989. FileTrHandler.sendMessage(TrResult);
  4990. }
  4991. protected void ProcUploadSuccess() {
  4992. Message TrResult = FileTrHandler.obtainMessage();
  4993. TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
  4994. TrResult.what = FTPLOGTRSUCC;
  4995. TRing = false;
  4996. imapsvrlog("Send Log success Message");
  4997. FileTrHandler.sendMessage(TrResult);
  4998. }
  4999. }
  5000. public LogUploader(String loc, String user, String pw) {
  5001. FtpLoc = loc;
  5002. FtpID = user;
  5003. FtpPasswd = pw;
  5004. }
  5005. public void run() {
  5006. File LogLoc = new File(define.LOG_FILE_LOCATION);
  5007. String[] LogFileList = LogLoc.list();
  5008. while (true) {
  5009. if (TRing == false) {
  5010. if (LogFileList != null && fileidx < LogFileList.length) {
  5011. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
  5012. fileidx++;
  5013. TRing = true;
  5014. uploader.start();
  5015. } else
  5016. return;
  5017. }
  5018. try {
  5019. Thread.sleep(500);
  5020. } catch (RuntimeException re) {
  5021. LogUtil.errorLogInfo("", TAG, re);
  5022. } catch (Exception e) {
  5023. LogUtil.errorLogInfo("", TAG, e);
  5024. }
  5025. }
  5026. }
  5027. }
  5028. public String iCMDProcDevList(Document ele) {
  5029. try {
  5030. String strResult = CheckiCMDProc("remote_get_home_devices");
  5031. if (strResult != null) return strResult;
  5032. else
  5033. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" ";
  5034. String target = "null", tid = "null", msgno = "null";
  5035. NodeList items = ele.getElementsByTagName("target");
  5036. Node item = items.item(0);
  5037. if (item != null) {
  5038. NamedNodeMap attrs = item.getAttributes();
  5039. for (int j = 0; j < attrs.getLength(); j++) {
  5040. Node attr = attrs.item(j);
  5041. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5042. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5043. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  5044. msgno = attr.getNodeValue();
  5045. }
  5046. }
  5047. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5048. if (NewServerUse()) {
  5049. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  5050. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  5051. return ServerCheckResult;
  5052. }
  5053. GasAPI mGasAPI = null;
  5054. CooktopAPI mCooktopAPI = null;
  5055. if (mWallPadAPI.GetGasKind() == 1) {
  5056. mGasAPI = mWallPadAPI.Get_GasController();
  5057. } else if (mWallPadAPI.GetGasKind() == 2) {
  5058. mCooktopAPI = mWallPadAPI.Get_CookTopController();
  5059. }
  5060. Log.i(TAG, "[iCMDProcDevList] bLightCMDUseAsSmartLight: " + bLightCMDUseAsSmartLight);
  5061. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  5062. int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  5063. String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
  5064. int nConcentEnable = mWallpadDeviceSet.Get_Concent_Info(); // 콘센트 사용 유무
  5065. mWallpadDeviceSet.closeDB();
  5066. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  5067. String[] devlist;
  5068. if(nConcentEnable==1){
  5069. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
  5070. } else {
  5071. devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "smartlight", "cooktop", "sysaircon"};
  5072. }
  5073. strResult += "result=\"ok\">\r\n";
  5074. strResult += " <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
  5075. strResult += " <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
  5076. //strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  5077. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  5078. String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
  5079. String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
  5080. String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
  5081. strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
  5082. strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
  5083. strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
  5084. for (int i = 0; i < devlist.length; i++) {
  5085. if (devlist[i].equals("cooktop")) {
  5086. if (mWallPadAPI.GetGasKind() == 1) {
  5087. // 가스밸브
  5088. int Gasinfo = devSet.Get_GAS_Info();
  5089. if (Gasinfo == 1) {
  5090. // 사용함
  5091. if (bGasAsCooktopOutlet) {
  5092. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5093. strResult += " <devinfo name=\"cooktop\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5094. } else {
  5095. strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5096. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5097. }
  5098. } else {
  5099. // 사용안함
  5100. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5101. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5102. }
  5103. } else if (mWallPadAPI.GetGasKind() == 2) {
  5104. // 하이브리드 쿡탑
  5105. // 쿡탑 최대로 연동 안됨
  5106. strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5107. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5108. /*
  5109. if (mCooktopAPI != null) {
  5110. int ret = mCooktopAPI.Refresh((byte) 0xFF, false);
  5111. int nGas = 0;
  5112. int nOutlet = 0;
  5113. if (ret >= 0) {
  5114. for (int k = 0; k < mCooktopAPI.data.Device[0].circuit.length; k++) {
  5115. if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
  5116. nGas++;
  5117. else if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
  5118. nOutlet++;
  5119. }
  5120. strResult += " <devinfo name=\"gas\" value=\"" + nGas + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5121. strResult += " <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5122. }
  5123. }
  5124. */
  5125. } else {
  5126. strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5127. strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5128. }
  5129. }
  5130. else if (devlist[i].equals("doorlock")) {
  5131. try {
  5132. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5133. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5134. strResult += " <devinfo name=\"doorlock\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5135. } else {
  5136. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5137. }
  5138. } catch (RuntimeException re) {
  5139. LogUtil.errorLogInfo("", TAG, re);
  5140. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5141. } catch (Exception e) {
  5142. //e.printStackTrace();
  5143. LogUtil.errorLogInfo("", TAG, e);
  5144. strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5145. }
  5146. }
  5147. else if (devlist[i].equals("light")) {
  5148. try {
  5149. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5150. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5151. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5152. if (bLightCMDUseAsSmartLight) {
  5153. if (mSdbAPI != null) {
  5154. strResult += " <devinfo name=\"light\" value=\"" + mSdbAPI.data.BadRoom_Em_Count + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5155. } else {
  5156. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5157. }
  5158. } else {
  5159. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5160. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5161. }
  5162. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5163. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5164. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5165. strResult += " <devinfo name=\"light\" value=\"" + energymeter.data.RoomCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5166. } else {
  5167. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5168. }
  5169. } else {
  5170. int[] lightinfo = devSet.Get_Light_info();
  5171. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5172. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5173. } else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5174. strResult += " <devinfo name=\"light\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5175. } else {
  5176. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5177. int ret = multisw.Refresh((byte) 0xFF, false);
  5178. if (ret < 0 || multisw.data.DeviceCnt < 1)
  5179. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5180. else
  5181. strResult += " <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5182. }
  5183. }
  5184. } catch (RuntimeException re) {
  5185. LogUtil.errorLogInfo("", TAG, re);
  5186. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5187. } catch (Exception e) {
  5188. //e.printStackTrace();
  5189. LogUtil.errorLogInfo("", TAG, e);
  5190. strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5191. }
  5192. }
  5193. else if (devlist[i].equals("livinglight")) {
  5194. try {
  5195. int[] lightinfo = devSet.Get_Light_info();
  5196. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5197. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5198. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5199. if (bLightCMDUseAsSmartLight) {
  5200. if (mSdb_LivingRoomLightAPI != null) {
  5201. strResult += " <devinfo name=\"livinglight\" value=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5202. } else {
  5203. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5204. }
  5205. } else {
  5206. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5207. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5208. }
  5209. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5210. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5211. } else {
  5212. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5213. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5214. } else {
  5215. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5216. }
  5217. }
  5218. } catch (RuntimeException re) {
  5219. LogUtil.errorLogInfo("", TAG, re);
  5220. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5221. } catch (Exception e) {
  5222. //e.printStackTrace();
  5223. LogUtil.errorLogInfo("", TAG, e);
  5224. strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5225. }
  5226. }
  5227. else if (devlist[i].equals("ventil")) {
  5228. try {
  5229. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5230. if (Ventilinfo[0] == 0)
  5231. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5232. else
  5233. strResult += " <devinfo name=\"ventil\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5234. } catch (RuntimeException re) {
  5235. LogUtil.errorLogInfo("", TAG, re);
  5236. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5237. } catch (Exception e) {
  5238. //e.printStackTrace();
  5239. LogUtil.errorLogInfo("", TAG, e);
  5240. strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5241. }
  5242. }
  5243. else if (devlist[i].equals("thermostat")) {
  5244. try {
  5245. int Temperinfo = devSet.Get_Temper_Info();
  5246. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5247. HeatingV1API heatingV1API = null;
  5248. HeatingV2API heatingV2API = null;
  5249. byte RoomCount = 0;
  5250. // 종류별 API를 로딩한다.
  5251. if (HeatingKind == 1) {
  5252. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5253. if (heatingV1API != null) {
  5254. RoomCount = heatingV1API.data.Device.RoomCount;
  5255. }
  5256. } else if (HeatingKind == 2) {
  5257. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5258. if (heatingV2API != null) {
  5259. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5260. }
  5261. }
  5262. if (Temperinfo == 0)
  5263. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5264. else
  5265. strResult += " <devinfo name=\"thermostat\" value=\"" + RoomCount + "\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5266. } catch (RuntimeException re) {
  5267. LogUtil.errorLogInfo("", TAG, re);
  5268. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5269. } catch (Exception e) {
  5270. //e.printStackTrace();
  5271. LogUtil.errorLogInfo("", TAG, e);
  5272. strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
  5273. }
  5274. }
  5275. else if (devlist[i].equals("curtain")) {
  5276. try {
  5277. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5278. if (Curtaininfo[0] == 0)
  5279. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5280. else
  5281. strResult += " <devinfo name=\"curtain\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5282. } catch (RuntimeException re) {
  5283. LogUtil.errorLogInfo("", TAG, re);
  5284. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5285. } catch (Exception e) {
  5286. //e.printStackTrace();
  5287. LogUtil.errorLogInfo("", TAG, e);
  5288. strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
  5289. }
  5290. }
  5291. else if (devlist[i].equals("electric")) {
  5292. try {
  5293. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5294. // 청담 콘센트 처리
  5295. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5296. int BadConcentCount = 0;
  5297. if (KnxApi != null) {
  5298. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5299. if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
  5300. BadConcentCount = 1;
  5301. }
  5302. int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  5303. for (int k = 0; k < BadConCount; k++) {
  5304. if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
  5305. BadConcentCount++;
  5306. }
  5307. Log.d(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
  5308. strResult += " <devinfo name=\"electric\" value=\"" + BadConcentCount + "\" floor=\"" + ho + "\"/>\r\n";
  5309. }
  5310. } else {
  5311. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  5312. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5313. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5314. int nOutlet = 0;
  5315. if (mSdb_LivingRoomLightAPI != null) {
  5316. if (mSdbAPI != null) {
  5317. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5318. } else {
  5319. nOutlet = 1;
  5320. }
  5321. } else {
  5322. if (mSdbAPI != null) {
  5323. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5324. } else {
  5325. nOutlet = 0;
  5326. }
  5327. }
  5328. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"" + ho + "\"/>\r\n";
  5329. } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5330. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5331. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5332. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"" + ho + "\"/>\r\n";
  5333. } else {
  5334. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5335. }
  5336. } else {
  5337. int[] lightinfo = devSet.Get_Light_info();
  5338. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5339. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5340. } else {
  5341. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5342. int ret = multisw.Refresh((byte) 0xFF, false);
  5343. if (ret < 0 || multisw.data.DeviceCnt < 1) {
  5344. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5345. } else {
  5346. int DeviceCount = 0;
  5347. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5348. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5349. DeviceCount++;
  5350. }
  5351. }
  5352. strResult += " <devinfo name=\"electric\" value=\"" + DeviceCount + "\" floor=\"" + ho + "\"/>\r\n";
  5353. }
  5354. }
  5355. }
  5356. }
  5357. } catch (RuntimeException re) {
  5358. LogUtil.errorLogInfo("", TAG, re);
  5359. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5360. } catch (Exception e) {
  5361. //e.printStackTrace();
  5362. LogUtil.errorLogInfo("", TAG, e);
  5363. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
  5364. }
  5365. }
  5366. else if (devlist[i].equals("smartlight")) {
  5367. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5368. // KNX 조명 처리
  5369. try {
  5370. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  5371. if (KnxApi != null) {
  5372. int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
  5373. if (KnxApi.data == null)
  5374. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
  5375. if (KnxApi.data.MasterController == null)
  5376. Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
  5377. if (ret >= 0) {
  5378. int LivingLightCount = 0;
  5379. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  5380. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  5381. } else {
  5382. if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  5383. LivingLightCount = 1;
  5384. }
  5385. int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount + KnxApi.data.MasterController.Info.Light_SwitchCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
  5386. strResult += " <devinfo name=\"smartlight\" value=\"" + AllEMcount + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5387. }
  5388. }
  5389. } catch (Exception ek) {
  5390. strResult += " <devinfo name=\"smartlight\" value=\"" + 0 + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5391. }
  5392. } else {
  5393. if (!bLightCMDUseAsSmartLight) {
  5394. int nSmartLight = 0;
  5395. if (mSdb_LivingRoomLightAPI != null) {
  5396. if (mSdbAPI != null) {
  5397. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5398. } else {
  5399. nSmartLight = 1;
  5400. }
  5401. } else {
  5402. if (mSdbAPI != null) {
  5403. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5404. } else {
  5405. nSmartLight = 0;
  5406. }
  5407. }
  5408. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
  5409. }
  5410. }
  5411. }
  5412. else if (devlist[i].equals("sysaircon")) {
  5413. // 에어컨 처리
  5414. if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  5415. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  5416. if (airconAPI != null) {
  5417. int nCount = airconAPI.data.Device.info.InsideAirconCount;
  5418. Log.d(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
  5419. // 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
  5420. strResult += " <devinfo name=\"sysaircon\" value=\"" + nCount + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5421. } else {
  5422. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5423. }
  5424. } else {
  5425. strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
  5426. }
  5427. }
  5428. }
  5429. //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
  5430. strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5431. strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
  5432. if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
  5433. strResult += remote_get_home_devices1;
  5434. }
  5435. if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
  5436. strResult += remote_get_home_devices2;
  5437. }
  5438. if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
  5439. strResult += remote_get_home_devices3;
  5440. }
  5441. /*
  5442. for (int i = 0; i < devlist.length; i++) {
  5443. if (devlist[i].equals("cooktop")) {
  5444. if (mWallPadAPI.GetGasKind() == 1) {
  5445. // 가스밸브
  5446. int Gasinfo = devSet.Get_GAS_Info();
  5447. if (Gasinfo == 1) {
  5448. // 사용함
  5449. if (bGasAsCooktopOutlet) {
  5450. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5451. strResult +=" <devinfo name=\"cooktop\" value=\"1\" floor=\"2\"/>\r\n";
  5452. }
  5453. else {
  5454. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n";
  5455. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5456. }
  5457. }
  5458. else {
  5459. // 사용안함
  5460. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5461. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5462. }
  5463. }
  5464. else if (mWallPadAPI.GetGasKind() == 2) {
  5465. // 하이브리드 쿡탑
  5466. if (mCooktopAPI != null) {
  5467. int nGas = 0; int nOutlet = 0;
  5468. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5469. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5470. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5471. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5472. }
  5473. }
  5474. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"2\"/>\r\n";
  5475. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5476. }
  5477. }
  5478. else {
  5479. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
  5480. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
  5481. }
  5482. }
  5483. else if (devlist[i].equals("doorlock")) {
  5484. try {
  5485. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5486. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5487. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"2\"/>\r\n";
  5488. }
  5489. else {
  5490. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5491. }
  5492. } catch (RuntimeException re) {
  5493. LogUtil.errorLogInfo("", TAG, re);
  5494. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5495. }
  5496. catch (Exception e) {
  5497. //e.printStackTrace();
  5498. LogUtil.errorLogInfo("", TAG, e);
  5499. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
  5500. }
  5501. }
  5502. else if (devlist[i].equals("light")) {
  5503. try {
  5504. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5505. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5506. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5507. if (bLightCMDUseAsSmartLight) {
  5508. if (mSdbAPI != null) {
  5509. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"2\"/>\r\n";
  5510. }
  5511. else {
  5512. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5513. }
  5514. }
  5515. else {
  5516. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5517. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5518. }
  5519. }
  5520. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5521. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5522. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5523. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"2\"/>\r\n";
  5524. }
  5525. else {
  5526. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5527. }
  5528. }
  5529. else {
  5530. int[] lightinfo = devSet.Get_Light_info();
  5531. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5532. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5533. }
  5534. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5535. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"2\"/>\r\n";
  5536. }
  5537. else {
  5538. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5539. int ret = multisw.Refresh((byte)0xFF, false);
  5540. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5541. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"2\"/>\r\n";
  5542. }
  5543. }
  5544. } catch (RuntimeException re) {
  5545. LogUtil.errorLogInfo("", TAG, re);
  5546. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5547. }
  5548. catch (Exception e) {
  5549. //e.printStackTrace();
  5550. LogUtil.errorLogInfo("", TAG, e);
  5551. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
  5552. }
  5553. }
  5554. else if (devlist[i].equals("livinglight")) {
  5555. try {
  5556. int[] lightinfo = devSet.Get_Light_info();
  5557. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5558. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5559. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5560. if (bLightCMDUseAsSmartLight) {
  5561. if (mSdb_LivingRoomLightAPI != null) {
  5562. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"2\"/>\r\n";
  5563. }
  5564. else {
  5565. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5566. }
  5567. }
  5568. else {
  5569. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5570. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5571. }
  5572. }
  5573. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5574. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5575. }
  5576. else {
  5577. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5578. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5579. }
  5580. else {
  5581. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
  5582. }
  5583. }
  5584. } catch (RuntimeException re) {
  5585. LogUtil.errorLogInfo("", TAG, re);
  5586. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5587. }
  5588. catch (Exception e) {
  5589. //e.printStackTrace();
  5590. LogUtil.errorLogInfo("", TAG, e);
  5591. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
  5592. }
  5593. }
  5594. else if (devlist[i].equals("ventil")) {
  5595. try {
  5596. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5597. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5598. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n";
  5599. } catch (RuntimeException re) {
  5600. LogUtil.errorLogInfo("", TAG, re);
  5601. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5602. }
  5603. catch (Exception e) {
  5604. //e.printStackTrace();
  5605. LogUtil.errorLogInfo("", TAG, e);
  5606. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
  5607. }
  5608. }
  5609. else if (devlist[i].equals("thermostat")) {
  5610. try {
  5611. int Temperinfo = devSet.Get_Temper_Info();
  5612. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5613. HeatingV1API heatingV1API = null;
  5614. HeatingV2API heatingV2API = null;
  5615. byte RoomCount = 0;
  5616. // 종류별 API를 로딩한다.
  5617. if (HeatingKind == 1) {
  5618. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5619. if (heatingV1API != null) {
  5620. RoomCount = heatingV1API.data.Device.RoomCount;
  5621. }
  5622. }
  5623. else if (HeatingKind == 2) {
  5624. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5625. if (heatingV2API != null) {
  5626. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5627. }
  5628. }
  5629. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5630. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"2\"/>\r\n";
  5631. } catch (RuntimeException re) {
  5632. LogUtil.errorLogInfo("", TAG, re);
  5633. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5634. }
  5635. catch (Exception e) {
  5636. //e.printStackTrace();
  5637. LogUtil.errorLogInfo("", TAG, e);
  5638. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
  5639. }
  5640. }
  5641. else if (devlist[i].equals("curtain")) {
  5642. try {
  5643. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5644. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5645. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"2\"/>\r\n";
  5646. } catch (RuntimeException re) {
  5647. LogUtil.errorLogInfo("", TAG, re);
  5648. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5649. }
  5650. catch (Exception e) {
  5651. //e.printStackTrace();
  5652. LogUtil.errorLogInfo("", TAG, e);
  5653. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
  5654. }
  5655. }
  5656. else if (devlist[i].equals("electric")) {
  5657. try {
  5658. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5659. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5660. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5661. int nOutlet = 0;
  5662. if (mSdb_LivingRoomLightAPI != null) {
  5663. if (mSdbAPI != null) {
  5664. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5665. }
  5666. else {
  5667. nOutlet = 1;
  5668. }
  5669. }
  5670. else {
  5671. if (mSdbAPI != null) {
  5672. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5673. }
  5674. else {
  5675. nOutlet = 0;
  5676. }
  5677. }
  5678. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
  5679. }
  5680. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5681. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5682. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5683. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"2\"/>\r\n";
  5684. }
  5685. else {
  5686. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5687. }
  5688. }
  5689. else {
  5690. int[] lightinfo = devSet.Get_Light_info();
  5691. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5692. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5693. }
  5694. else {
  5695. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5696. int ret = multisw.Refresh((byte)0xFF, false);
  5697. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5698. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5699. }
  5700. else {
  5701. int DeviceCount = 0;
  5702. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5703. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5704. DeviceCount++;
  5705. }
  5706. }
  5707. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"2\"/>\r\n";
  5708. }
  5709. }
  5710. }
  5711. } catch (RuntimeException re) {
  5712. LogUtil.errorLogInfo("", TAG, re);
  5713. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5714. }
  5715. catch (Exception e) {
  5716. //e.printStackTrace();
  5717. LogUtil.errorLogInfo("", TAG, e);
  5718. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
  5719. }
  5720. }
  5721. else if (devlist[i].equals("smartlight")) {
  5722. if (!bLightCMDUseAsSmartLight) {
  5723. int nSmartLight = 0;
  5724. if (mSdb_LivingRoomLightAPI != null) {
  5725. if (mSdbAPI != null) {
  5726. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  5727. }
  5728. else {
  5729. nSmartLight = 1;
  5730. }
  5731. }
  5732. else {
  5733. if (mSdbAPI != null) {
  5734. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  5735. }
  5736. else {
  5737. nSmartLight = 0;
  5738. }
  5739. }
  5740. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"2\"/>\r\n";
  5741. }
  5742. }
  5743. }
  5744. for (int i = 0; i < devlist.length; i++) {
  5745. if (devlist[i].equals("cooktop")) {
  5746. if (mWallPadAPI.GetGasKind() == 1) {
  5747. // 가스밸브
  5748. int Gasinfo = devSet.Get_GAS_Info();
  5749. if (Gasinfo == 1) {
  5750. // 사용함
  5751. if (bGasAsCooktopOutlet) {
  5752. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5753. strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5754. }
  5755. else {
  5756. strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n";
  5757. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5758. }
  5759. }
  5760. else {
  5761. // 사용안함
  5762. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5763. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5764. }
  5765. }
  5766. else if (mWallPadAPI.GetGasKind() == 2) {
  5767. // 하이브리드 쿡탑
  5768. if (mCooktopAPI != null) {
  5769. int nGas = 0; int nOutlet = 0;
  5770. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5771. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5772. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5773. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5774. }
  5775. }
  5776. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"3\"/>\r\n";
  5777. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5778. }
  5779. }
  5780. else {
  5781. strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
  5782. strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
  5783. }
  5784. }
  5785. else if (devlist[i].equals("doorlock")) {
  5786. try {
  5787. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5788. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5789. strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"3\"/>\r\n";
  5790. }
  5791. else {
  5792. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5793. }
  5794. } catch (RuntimeException re) {
  5795. LogUtil.errorLogInfo("", TAG, re);
  5796. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5797. }
  5798. catch (Exception e) {
  5799. //e.printStackTrace();
  5800. LogUtil.errorLogInfo("", TAG, e);
  5801. strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
  5802. }
  5803. }
  5804. else if (devlist[i].equals("light")) {
  5805. try {
  5806. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5807. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5808. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5809. if (bLightCMDUseAsSmartLight) {
  5810. if (mSdbAPI != null) {
  5811. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"3\"/>\r\n";
  5812. }
  5813. else {
  5814. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5815. }
  5816. }
  5817. else {
  5818. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5819. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5820. }
  5821. }
  5822. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5823. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5824. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5825. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"3\"/>\r\n";
  5826. }
  5827. else {
  5828. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5829. }
  5830. }
  5831. else {
  5832. int[] lightinfo = devSet.Get_Light_info();
  5833. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5834. strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5835. }
  5836. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5837. strResult += " <devinfo name=\"light\" value=\"1\" floor=\"3\"/>\r\n";
  5838. }
  5839. else {
  5840. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5841. int ret = multisw.Refresh((byte)0xFF, false);
  5842. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5843. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"3\"/>\r\n";
  5844. }
  5845. }
  5846. } catch (RuntimeException re) {
  5847. LogUtil.errorLogInfo("", TAG, re);
  5848. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5849. }
  5850. catch (Exception e) {
  5851. //e.printStackTrace();
  5852. LogUtil.errorLogInfo("", TAG, e);
  5853. strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
  5854. }
  5855. }
  5856. else if (devlist[i].equals("livinglight")) {
  5857. try {
  5858. int[] lightinfo = devSet.Get_Light_info();
  5859. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5860. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5861. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5862. if (bLightCMDUseAsSmartLight) {
  5863. if (mSdb_LivingRoomLightAPI != null) {
  5864. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"3\"/>\r\n";
  5865. }
  5866. else {
  5867. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5868. }
  5869. }
  5870. else {
  5871. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5872. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5873. }
  5874. }
  5875. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5876. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5877. }
  5878. else {
  5879. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5880. strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5881. }
  5882. else {
  5883. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
  5884. }
  5885. }
  5886. } catch (RuntimeException re) {
  5887. LogUtil.errorLogInfo("", TAG, re);
  5888. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5889. }
  5890. catch (Exception e) {
  5891. //e.printStackTrace();
  5892. LogUtil.errorLogInfo("", TAG, e);
  5893. strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
  5894. }
  5895. }
  5896. else if (devlist[i].equals("ventil")) {
  5897. try {
  5898. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5899. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5900. else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n";
  5901. } catch (RuntimeException re) {
  5902. LogUtil.errorLogInfo("", TAG, re);
  5903. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5904. }
  5905. catch (Exception e) {
  5906. //e.printStackTrace();
  5907. LogUtil.errorLogInfo("", TAG, e);
  5908. strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
  5909. }
  5910. }
  5911. else if (devlist[i].equals("thermostat")) {
  5912. try {
  5913. int Temperinfo = devSet.Get_Temper_Info();
  5914. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5915. HeatingV1API heatingV1API = null;
  5916. HeatingV2API heatingV2API = null;
  5917. byte RoomCount = 0;
  5918. // 종류별 API를 로딩한다.
  5919. if (HeatingKind == 1) {
  5920. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5921. if (heatingV1API != null) {
  5922. RoomCount = heatingV1API.data.Device.RoomCount;
  5923. }
  5924. }
  5925. else if (HeatingKind == 2) {
  5926. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5927. if (heatingV2API != null) {
  5928. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5929. }
  5930. }
  5931. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5932. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"3\"/>\r\n";
  5933. } catch (RuntimeException re) {
  5934. LogUtil.errorLogInfo("", TAG, re);
  5935. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5936. }
  5937. catch (Exception e) {
  5938. //e.printStackTrace();
  5939. LogUtil.errorLogInfo("", TAG, e);
  5940. strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
  5941. }
  5942. }
  5943. else if (devlist[i].equals("curtain")) {
  5944. try {
  5945. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5946. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5947. else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"3\"/>\r\n";
  5948. } catch (RuntimeException re) {
  5949. LogUtil.errorLogInfo("", TAG, re);
  5950. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5951. }
  5952. catch (Exception e) {
  5953. //e.printStackTrace();
  5954. LogUtil.errorLogInfo("", TAG, e);
  5955. strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
  5956. }
  5957. }
  5958. else if (devlist[i].equals("electric")) {
  5959. try {
  5960. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5961. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5962. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5963. int nOutlet = 0;
  5964. if (mSdb_LivingRoomLightAPI != null) {
  5965. if (mSdbAPI != null) {
  5966. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5967. }
  5968. else {
  5969. nOutlet = 1;
  5970. }
  5971. }
  5972. else {
  5973. if (mSdbAPI != null) {
  5974. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5975. }
  5976. else {
  5977. nOutlet = 0;
  5978. }
  5979. }
  5980. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
  5981. }
  5982. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5983. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5984. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5985. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"3\"/>\r\n";
  5986. }
  5987. else {
  5988. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5989. }
  5990. }
  5991. else {
  5992. int[] lightinfo = devSet.Get_Light_info();
  5993. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5994. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  5995. }
  5996. else {
  5997. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5998. int ret = multisw.Refresh((byte)0xFF, false);
  5999. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  6000. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  6001. }
  6002. else {
  6003. int DeviceCount = 0;
  6004. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  6005. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  6006. DeviceCount++;
  6007. }
  6008. }
  6009. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"3\"/>\r\n";
  6010. }
  6011. }
  6012. }
  6013. } catch (RuntimeException re) {
  6014. LogUtil.errorLogInfo("", TAG, re);
  6015. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  6016. }
  6017. catch (Exception e) {
  6018. //e.printStackTrace();
  6019. LogUtil.errorLogInfo("", TAG, e);
  6020. strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
  6021. }
  6022. }
  6023. else if (devlist[i].equals("smartlight")) {
  6024. if (!bLightCMDUseAsSmartLight) {
  6025. int nSmartLight = 0;
  6026. if (mSdb_LivingRoomLightAPI != null) {
  6027. if (mSdbAPI != null) {
  6028. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  6029. }
  6030. else {
  6031. nSmartLight = 1;
  6032. }
  6033. }
  6034. else {
  6035. if (mSdbAPI != null) {
  6036. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  6037. }
  6038. else {
  6039. nSmartLight = 0;
  6040. }
  6041. }
  6042. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"3\"/>\r\n";
  6043. }
  6044. }
  6045. }
  6046. */
  6047. strResult += " </service>\r\n</imap>\r\n";
  6048. devSet.closeDB();
  6049. return strResult;
  6050. } catch (RuntimeException re) {
  6051. LogUtil.errorLogInfo("", TAG, re);
  6052. return null;
  6053. } catch (Exception e) {
  6054. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  6055. //e.printStackTrace();
  6056. LogUtil.errorLogInfo("", TAG, e);
  6057. return null;
  6058. }
  6059. }
  6060. public String iCMDProcMultiSWControl(Document ele) {
  6061. try {
  6062. String retStr = CheckiCMDProc(MULTISW_CTR);
  6063. if (retStr != null) return retStr;
  6064. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\"";
  6065. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  6066. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  6067. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  6068. int devNum = Integer.parseInt(multiswcmd.devnum);
  6069. if (multisw != null) {
  6070. int ret = multisw.Refresh((byte) 0xFF, false);
  6071. String result;
  6072. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  6073. else result = "fail";
  6074. retStr += (" result=\"" + result + "\" >\r\n");
  6075. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  6076. retStr += MakeTargetStr(multiswcmd);
  6077. retStr += " <action>\"status\"</action>\r\n";
  6078. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  6079. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6080. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6081. 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";
  6082. } else {
  6083. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  6084. }
  6085. } else {
  6086. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  6087. }
  6088. String unitStr;
  6089. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  6090. Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
  6091. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  6092. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  6093. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  6094. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  6095. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  6096. }
  6097. }
  6098. retStr += " </service>\r\n</imap>\r\n";
  6099. }
  6100. } else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  6101. int devNum = Integer.parseInt(multiswcmd.devnum);
  6102. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  6103. {
  6104. if (multisw != null) {
  6105. multisw.Refresh((byte) 0xFF, false);
  6106. String result;
  6107. int ret = -1;
  6108. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  6109. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
  6110. } else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  6111. ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
  6112. } else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
  6113. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
  6114. } else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
  6115. ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
  6116. }
  6117. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6118. else result = "fail";
  6119. if (ret == APIErrorCode.C_SUCCESS) {
  6120. ret = multisw.Refresh((byte) 0xFF, false);
  6121. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  6122. retStr += (" result=\"" + result + "\" > \r\n");
  6123. retStr += MakeTargetStr(multiswcmd);
  6124. retStr += " <action>\"control\"</action>\r\n";
  6125. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
  6126. String unitStr;
  6127. for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
  6128. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  6129. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  6130. unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  6131. unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
  6132. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
  6133. }
  6134. } else {
  6135. retStr += (" result=\"fail\"> \r\n");
  6136. }
  6137. } else {
  6138. retStr += (" result=\"fail\"> \r\n");
  6139. }
  6140. retStr += " </service>\r\n</imap>\r\n";
  6141. }
  6142. }
  6143. }
  6144. return retStr;
  6145. } catch (RuntimeException re) {
  6146. LogUtil.errorLogInfo("", TAG, re);
  6147. return null;
  6148. } catch (Exception e) {
  6149. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  6150. //e.printStackTrace();
  6151. LogUtil.errorLogInfo("", TAG, e);
  6152. return null;
  6153. }
  6154. }
  6155. public String iCMDProcSDPConcentControl(Document ele) {
  6156. try {
  6157. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  6158. String retStr = CheckiCMDProc("remote_access_electric");
  6159. if (retStr != null) return retStr;
  6160. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  6161. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6162. if (NewServerUse()) {
  6163. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  6164. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6165. return ServerCheckResult;
  6166. }
  6167. if (mSdbAPI == null) {
  6168. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6169. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  6170. return retStr;
  6171. }
  6172. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6173. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6174. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6175. return retStr;
  6176. }
  6177. int nTotalLightCnt = 0;
  6178. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  6179. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6180. } else {
  6181. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  6182. }
  6183. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  6184. int nDevNo = 0;
  6185. try {
  6186. nDevNo = Integer.parseInt(concentcmd.devnum);
  6187. } catch (RuntimeException re) {
  6188. LogUtil.errorLogInfo("", TAG, re);
  6189. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6190. return retStr;
  6191. } catch (Exception e) {
  6192. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  6193. //e.printStackTrace();
  6194. LogUtil.errorLogInfo("", TAG, e);
  6195. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6196. return retStr;
  6197. }
  6198. if (nDevNo < 1 && 12 < nDevNo) {
  6199. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6200. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  6201. return retStr;
  6202. }
  6203. String strAction = trimquotation(concentcmd.actionTXT);
  6204. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  6205. String dev_num = "null", unit_num = "null", ctrl_action = "null";
  6206. int nRet_Mode = -99, nRet_OnOff = -99;
  6207. boolean Set = false, OnOff = false; // 제어요청 상태
  6208. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  6209. if (strAction.equalsIgnoreCase("status")) {
  6210. retStr += " result=\"ok\">\r\n";
  6211. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6212. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6213. if (nDevNo == 1) {
  6214. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6215. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  6216. } else {
  6217. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6218. }
  6219. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6220. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6221. status_mode = "unset";
  6222. else status_mode = "set";
  6223. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6224. status_onoff = "on";
  6225. else status_onoff = "off";
  6226. unit_status = status_mode + "/" + status_onoff;
  6227. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6228. }
  6229. // retStr += " </status_map>\r\n";
  6230. retStr += " </service>\r\n</imap>\r\n";
  6231. } else if (nDevNo > 1) {
  6232. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6233. 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";
  6234. } else {
  6235. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6236. }
  6237. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6238. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6239. status_mode = "unset";
  6240. else status_mode = "set";
  6241. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6242. status_onoff = "on";
  6243. else status_onoff = "off";
  6244. unit_status = status_mode + "/" + status_onoff;
  6245. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6246. }
  6247. // retStr += " </status_map>\r\n";
  6248. retStr += " </service>\r\n</imap>\r\n";
  6249. }
  6250. } else if (strAction.equalsIgnoreCase("control")) {
  6251. NodeList items = ele.getElementsByTagName("params");
  6252. Node item = items.item(0);
  6253. if (item != null) {
  6254. NamedNodeMap attrs = item.getAttributes();
  6255. for (int i = 0; i < attrs.getLength(); i++) {
  6256. Node attr = attrs.item(i);
  6257. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  6258. dev_num = attr.getNodeValue();
  6259. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  6260. unit_num = attr.getNodeValue();
  6261. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  6262. ctrl_action = attr.getNodeValue();
  6263. }
  6264. } else {
  6265. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  6266. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6267. return retStr;
  6268. }
  6269. try {
  6270. nDevNo = Integer.parseInt(dev_num);
  6271. } catch (RuntimeException re) {
  6272. LogUtil.errorLogInfo("", TAG, re);
  6273. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6274. return retStr;
  6275. } catch (Exception e) {
  6276. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  6277. //e.printStackTrace();
  6278. LogUtil.errorLogInfo("", TAG, e);
  6279. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6280. return retStr;
  6281. }
  6282. if (nDevNo < 1 && 12 < nDevNo) {
  6283. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6284. return retStr;
  6285. }
  6286. int nUnitNo = 0;
  6287. if (!unit_num.equalsIgnoreCase("all")) {
  6288. try {
  6289. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  6290. } catch (RuntimeException re) {
  6291. LogUtil.errorLogInfo("", TAG, re);
  6292. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6293. return retStr;
  6294. } catch (Exception e) {
  6295. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  6296. //e.printStackTrace();
  6297. LogUtil.errorLogInfo("", TAG, e);
  6298. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6299. return retStr;
  6300. }
  6301. }
  6302. if (ctrl_action.contains("/")) {
  6303. String[] strParsed = ctrl_action.split("/");
  6304. if (strParsed[0].equals("set")) {
  6305. Set = true;
  6306. bCtrl_Set = true;
  6307. } else if (strParsed[0].equals("unset")) {
  6308. Set = false;
  6309. bCtrl_Set = true;
  6310. }
  6311. if (strParsed[1].equals("on")) {
  6312. OnOff = true;
  6313. bCtrl_OnOff = true;
  6314. } else if (strParsed[1].equals("off")) {
  6315. OnOff = false;
  6316. bCtrl_OnOff = true;
  6317. }
  6318. } else {
  6319. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  6320. if (ctrl_action.equalsIgnoreCase("set")) {
  6321. Set = true;
  6322. bCtrl_Set = true;
  6323. } else if (ctrl_action.equalsIgnoreCase("unset")) {
  6324. Set = false;
  6325. bCtrl_Set = true;
  6326. }
  6327. }
  6328. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  6329. if (ctrl_action.equalsIgnoreCase("on")) {
  6330. OnOff = true;
  6331. bCtrl_OnOff = true;
  6332. } else if (ctrl_action.equalsIgnoreCase("off")) {
  6333. OnOff = false;
  6334. bCtrl_OnOff = true;
  6335. }
  6336. }
  6337. }
  6338. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  6339. if (nDevNo == 1) {
  6340. if (unit_num.equalsIgnoreCase("all")) {
  6341. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6342. if (bCtrl_Set)
  6343. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  6344. if (bCtrl_OnOff)
  6345. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  6346. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6347. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6348. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6349. return retStr;
  6350. }
  6351. }
  6352. } else {
  6353. if (bCtrl_Set)
  6354. nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  6355. if (bCtrl_OnOff)
  6356. nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  6357. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6358. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6359. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6360. return retStr;
  6361. }
  6362. }
  6363. } else {
  6364. if (unit_num.equalsIgnoreCase("all")) {
  6365. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6366. if (bCtrl_Set)
  6367. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  6368. if (bCtrl_OnOff)
  6369. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  6370. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6371. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6372. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6373. return retStr;
  6374. }
  6375. }
  6376. } else {
  6377. if (bCtrl_Set)
  6378. nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  6379. if (bCtrl_OnOff)
  6380. nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  6381. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6382. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6383. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6384. return retStr;
  6385. }
  6386. }
  6387. }
  6388. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6389. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6390. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6391. return retStr;
  6392. }
  6393. retStr += " result=\"ok\">\r\n";
  6394. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6395. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6396. if (nDevNo == 1) {
  6397. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6398. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6399. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6400. status_mode = "unset";
  6401. else status_mode = "set";
  6402. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6403. status_onoff = "on";
  6404. else status_onoff = "off";
  6405. unit_status = status_mode + "/" + status_onoff;
  6406. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6407. }
  6408. // retStr += " </status_map>\r\n";
  6409. retStr += " </service>\r\n</imap>\r\n";
  6410. } else if (nDevNo > 1) {
  6411. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6412. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6413. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
  6414. status_mode = "unset";
  6415. else status_mode = "set";
  6416. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
  6417. status_onoff = "on";
  6418. else status_onoff = "off";
  6419. unit_status = status_mode + "/" + status_onoff;
  6420. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6421. }
  6422. // retStr += " </status_map>\r\n";
  6423. retStr += " </service>\r\n</imap>\r\n";
  6424. }
  6425. } else {
  6426. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  6427. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6428. }
  6429. return retStr;
  6430. } catch (RuntimeException re) {
  6431. LogUtil.errorLogInfo("", TAG, re);
  6432. return null;
  6433. } catch (Exception e) {
  6434. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  6435. //e.printStackTrace();
  6436. LogUtil.errorLogInfo("", TAG, e);
  6437. return null;
  6438. }
  6439. }
  6440. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  6441. try {
  6442. String retStr = CheckiCMDProc(MULTISW_CTR);
  6443. if (retStr != null) return retStr;
  6444. else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\" ";
  6445. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6446. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6447. if (energymetercmd == null) return null;
  6448. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6449. if (energymeter == null) return null;
  6450. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6451. int ret = energymeter.Refresh((byte) 0xFF, false);
  6452. String result;
  6453. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  6454. else result = "fail";
  6455. retStr += (" result=\"" + result + "\" >\r\n");
  6456. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6457. retStr += MakeTargetStr(energymetercmd);
  6458. retStr += " <action>\"status\"</action>\r\n";
  6459. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6460. String unitStr;
  6461. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6462. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6463. if (i == 2) {
  6464. unitStr += "on";
  6465. } else {
  6466. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6467. }
  6468. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6469. }
  6470. }
  6471. retStr += " </service>\r\n</imap>\r\n";
  6472. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6473. int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
  6474. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
  6475. byte cmd = 0;
  6476. int ret = 0;
  6477. String result;
  6478. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  6479. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  6480. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  6481. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  6482. if (cmd > 0) {
  6483. if (energymeter != null) {
  6484. energymeter.Refresh((byte) 0xFF, false);
  6485. if (cmd == 1) {
  6486. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  6487. } else if (cmd == 2) {
  6488. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  6489. } else if (cmd == 3) {
  6490. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
  6491. } else if (cmd == 4) {
  6492. ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
  6493. }
  6494. if (ret == APIErrorCode.C_SUCCESS) result = "ok";
  6495. else result = "fail";
  6496. retStr += (" result=\"" + result + "\" >\r\n");
  6497. if (ret == APIErrorCode.C_SUCCESS) {
  6498. ret = energymeter.Refresh((byte) 0xFF, false);
  6499. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6500. retStr += MakeTargetStr(energymetercmd);
  6501. retStr += " <action>\"control\"</action>\r\n";
  6502. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6503. String unitStr;
  6504. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6505. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6506. if (i == 2) {
  6507. unitStr += "on";
  6508. } else {
  6509. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6510. }
  6511. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
  6512. }
  6513. } else {
  6514. retStr += (" result=\"fail\"> \r\n");
  6515. }
  6516. } else {
  6517. retStr += (" result=\"fail\"> \r\n");
  6518. }
  6519. retStr += " </service>\r\n</imap>\r\n";
  6520. }
  6521. }
  6522. }
  6523. return retStr;
  6524. } catch (RuntimeException re) {
  6525. LogUtil.errorLogInfo("", TAG, re);
  6526. return null;
  6527. } catch (Exception e) {
  6528. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  6529. //e.printStackTrace();
  6530. LogUtil.errorLogInfo("", TAG, e);
  6531. return null;
  6532. }
  6533. }
  6534. public String iCMDProcModeControl(Document doc) {
  6535. try {
  6536. String status = "unknown";
  6537. boolean SendBR = false;
  6538. String retStr = CheckiCMDProc("remote_access_mode");
  6539. if (retStr != null) return retStr;
  6540. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  6541. String target = "null", tid = "null", msgno = "null";
  6542. NodeList items = doc.getElementsByTagName("target");
  6543. Node item = items.item(0);
  6544. if (item != null) {
  6545. NamedNodeMap attrs = item.getAttributes();
  6546. for (int j = 0; j < attrs.getLength(); j++) {
  6547. Node attr = attrs.item(j);
  6548. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6549. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6550. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6551. msgno = attr.getNodeValue();
  6552. }
  6553. }
  6554. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6555. if (NewServerUse()) {
  6556. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  6557. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6558. return ServerCheckResult;
  6559. }
  6560. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  6561. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  6562. int curState = SetData.GetAlarmStatus();
  6563. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  6564. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  6565. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  6566. switch (curState) {
  6567. case WallpadStatusData.GUARD_IN:
  6568. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  6569. Intent intent = new Intent();
  6570. intent.setAction(define.NOTIFY_ACNAME);
  6571. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6572. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  6573. getApplicationContext().sendBroadcast(intent);
  6574. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  6575. SendBR = true;
  6576. break;
  6577. case WallpadStatusData.GUARD_OUT:
  6578. break;
  6579. }
  6580. } else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  6581. switch (curState) {
  6582. case WallpadStatusData.ALARM_NONE:
  6583. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6584. if (mIGW200.checkSensorforInmode()) {
  6585. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6586. Intent intent = new Intent();
  6587. intent.setAction(define.NOTIFY_ACNAME);
  6588. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6589. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6590. getApplicationContext().sendBroadcast(intent);
  6591. SendBR = true;
  6592. } else {
  6593. SendBR = false;
  6594. }
  6595. } 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
  6596. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6597. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6598. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6599. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6600. if (mIGW300.checkSensorforInmode()) {
  6601. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6602. Intent intent = new Intent();
  6603. intent.setAction(define.NOTIFY_ACNAME);
  6604. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6605. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6606. getApplicationContext().sendBroadcast(intent);
  6607. SendBR = true;
  6608. } else {
  6609. SendBR = false;
  6610. }
  6611. } else {
  6612. if (checkSensorforInmode()) {
  6613. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6614. Intent intent = new Intent();
  6615. intent.setAction(define.NOTIFY_ACNAME);
  6616. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6617. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6618. getApplicationContext().sendBroadcast(intent);
  6619. Sound().PlayMent(SND.mode.INMODE_SETTING);
  6620. SendBR = true;
  6621. } else {
  6622. SendBR = false;
  6623. }
  6624. }
  6625. break;
  6626. default:
  6627. break;
  6628. }
  6629. } else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  6630. if (GetUseIlgalControlForAdmin() == false) {
  6631. // 관리자용 일괄소등 원격제어 사용안할 시
  6632. switch (curState) {
  6633. case WallpadStatusData.ALARM_NONE:
  6634. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6635. if (mIGW200.checkSensorforOutmode()) {
  6636. Common.SendAppFinishReqBR(getApplicationContext());
  6637. Intent intent = new Intent();
  6638. intent.setAction(define.NOTIFY_ACNAME);
  6639. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6640. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6641. getApplicationContext().sendBroadcast(intent);
  6642. SendBR = true;
  6643. } else {
  6644. SendBR = false;
  6645. }
  6646. } 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
  6647. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6648. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6649. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6650. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6651. if (mIGW300.checkSensorforOutmode()) {
  6652. Common.SendAppFinishReqBR(getApplicationContext());
  6653. Intent intent = new Intent();
  6654. intent.setAction(define.NOTIFY_ACNAME);
  6655. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6656. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6657. getApplicationContext().sendBroadcast(intent);
  6658. SendBR = true;
  6659. } else {
  6660. SendBR = false;
  6661. }
  6662. } else {
  6663. if (checkSensorforOutmode()) {
  6664. Common.SendAppFinishReqBR(getApplicationContext());
  6665. Intent intent = new Intent();
  6666. intent.setAction(define.NOTIFY_ACNAME);
  6667. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6668. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6669. getApplicationContext().sendBroadcast(intent);
  6670. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  6671. SendBR = true;
  6672. } else {
  6673. SendBR = false;
  6674. }
  6675. }
  6676. break;
  6677. default:
  6678. break;
  6679. }
  6680. } else {
  6681. // 관리자용 일괄소등 원격제어 사용 시
  6682. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6683. SendBR = true;
  6684. }
  6685. }
  6686. } else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  6687. int getStatus = SetData.GetAlarmStatus();
  6688. switch (getStatus) {
  6689. case WallpadStatusData.GUARD_IN:
  6690. status = "occupied";
  6691. break;
  6692. case WallpadStatusData.GUARD_OUT:
  6693. status = "unoccupied";
  6694. break;
  6695. case WallpadStatusData.ALARM_NONE:
  6696. status = "normal";
  6697. break;
  6698. case WallpadStatusData.ALARM_ARISE:
  6699. status = "emergency";
  6700. break;
  6701. default:
  6702. break;
  6703. }
  6704. retStr += ("\"ok\">\r\n ");
  6705. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6706. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6707. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6708. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6709. return retStr;
  6710. }
  6711. if (!SendBR) {
  6712. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6713. SetData.closeDB();
  6714. return retStr;
  6715. } else {
  6716. try {
  6717. Thread.sleep(1000);
  6718. } catch (RuntimeException re) {
  6719. LogUtil.errorLogInfo("", TAG, re);
  6720. } catch (Exception e) {
  6721. LogUtil.errorLogInfo("", TAG, e);
  6722. }
  6723. int getStatus = SetData.GetAlarmStatus();
  6724. switch (getStatus) {
  6725. case WallpadStatusData.GUARD_IN:
  6726. status = "occupied";
  6727. break;
  6728. case WallpadStatusData.GUARD_OUT:
  6729. status = "unoccupied";
  6730. break;
  6731. case WallpadStatusData.ALARM_NONE:
  6732. status = "normal";
  6733. break;
  6734. case WallpadStatusData.ALARM_ARISE:
  6735. status = "emergency";
  6736. break;
  6737. }
  6738. }
  6739. retStr += "\"ok\">\r\n";
  6740. retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6741. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6742. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6743. retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
  6744. SetData.closeDB();
  6745. return retStr;
  6746. } catch (RuntimeException re) {
  6747. LogUtil.errorLogInfo("", TAG, re);
  6748. return null;
  6749. } catch (Exception e) {
  6750. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6751. //e.printStackTrace();
  6752. LogUtil.errorLogInfo("", TAG, e);
  6753. return null;
  6754. }
  6755. }
  6756. public String iCMDProcCurtainControl(Document ele) {
  6757. return " ";
  6758. }
  6759. public String iCMDProcSDPLightControl(Document ele) {
  6760. try {
  6761. String retStr = CheckiCMDProc("remote_access_light");
  6762. if (retStr != null) return retStr;
  6763. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6764. String target = "null", tid = "null", msgno = "null";
  6765. NodeList items = ele.getElementsByTagName("target");
  6766. Node item = items.item(0);
  6767. if (item != null) {
  6768. NamedNodeMap attrs = item.getAttributes();
  6769. for (int j = 0; j < attrs.getLength(); j++) {
  6770. Node attr = attrs.item(j);
  6771. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6772. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6773. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6774. msgno = attr.getNodeValue();
  6775. }
  6776. }
  6777. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6778. if (NewServerUse()) {
  6779. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6780. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6781. return ServerCheckResult;
  6782. }
  6783. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6784. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6785. if (energymetercmd == null) return null;
  6786. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6787. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6788. if (energymeter == null) return null;
  6789. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6790. retStr += "result=\"ok\">\r\n" +
  6791. " <action>\"status\"</action>\r\n" +
  6792. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6793. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6794. 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");
  6795. }
  6796. retStr += "\r\n</service>\r\n</imap>";
  6797. } else {
  6798. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6799. }
  6800. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6801. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6802. num--;
  6803. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6804. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6805. if (energymeter == null) return null;
  6806. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6807. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6808. retStr += "result=\"ok\">\r\n" +
  6809. " <action>\"control\"</action>\r\n" +
  6810. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6811. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6812. 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");
  6813. }
  6814. retStr += "\r\n</service>\r\n</imap>";
  6815. } else {
  6816. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6817. }
  6818. } else {
  6819. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6820. }
  6821. } else {
  6822. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6823. }
  6824. energymetercmd = null;
  6825. return retStr;
  6826. } catch (RuntimeException re) {
  6827. LogUtil.errorLogInfo("", TAG, re);
  6828. return null;
  6829. } catch (Exception e) {
  6830. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6831. //e.printStackTrace();
  6832. LogUtil.errorLogInfo("", TAG, e);
  6833. return null;
  6834. }
  6835. }
  6836. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6837. try {
  6838. String retStr = CheckiCMDProc("remote_access_light");
  6839. if (retStr != null) return retStr;
  6840. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6841. String target = "null", tid = "null", msgno = "null";
  6842. NodeList items = ele.getElementsByTagName("target");
  6843. Node item = items.item(0);
  6844. if (item != null) {
  6845. NamedNodeMap attrs = item.getAttributes();
  6846. for (int j = 0; j < attrs.getLength(); j++) {
  6847. Node attr = attrs.item(j);
  6848. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6849. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6850. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6851. msgno = attr.getNodeValue();
  6852. }
  6853. }
  6854. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6855. if (NewServerUse()) {
  6856. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6857. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6858. return ServerCheckResult;
  6859. }
  6860. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6861. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6862. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6863. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6864. if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6865. retStr += "result=\"ok\">\r\n" +
  6866. " <action>\"status\"</action>\r\n" +
  6867. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6868. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6869. 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");
  6870. }
  6871. retStr += "\r\n</service>\r\n</imap>";
  6872. } else {
  6873. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6874. }
  6875. } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6876. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6877. num--;
  6878. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6879. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6880. if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6881. if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6882. retStr += "result=\"ok\">\r\n" +
  6883. " <action>\"control\"</action>\r\n" +
  6884. " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
  6885. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6886. 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");
  6887. }
  6888. retStr += "\r\n</service>\r\n</imap>";
  6889. } else {
  6890. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6891. }
  6892. } else {
  6893. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6894. }
  6895. } else {
  6896. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6897. }
  6898. energymetercmd = null;
  6899. return retStr;
  6900. } catch (RuntimeException re) {
  6901. LogUtil.errorLogInfo("", TAG, re);
  6902. return null;
  6903. } catch (Exception e) {
  6904. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6905. //e.printStackTrace();
  6906. LogUtil.errorLogInfo("", TAG, e);
  6907. return null;
  6908. }
  6909. }
  6910. public String iCMDProcLightControl(Document ele) {
  6911. try {
  6912. String retStr = CheckiCMDProc("remote_access_light");
  6913. if (retStr != null) return retStr;
  6914. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6915. String target = "null", tid = "null", msgno = "null";
  6916. NodeList items = ele.getElementsByTagName("target");
  6917. Node item = items.item(0);
  6918. if (item != null) {
  6919. NamedNodeMap attrs = item.getAttributes();
  6920. for (int j = 0; j < attrs.getLength(); j++) {
  6921. Node attr = attrs.item(j);
  6922. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6923. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6924. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  6925. msgno = attr.getNodeValue();
  6926. }
  6927. }
  6928. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6929. if (NewServerUse()) {
  6930. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6931. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  6932. return ServerCheckResult;
  6933. }
  6934. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6935. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6936. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6937. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6938. if (bLightCMDUseAsSmartLight) {
  6939. if (mSdbAPI != null) {
  6940. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6941. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6942. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6943. retStr += "result=\"ok\">\r\n" +
  6944. " <action>\"status\"</action>\r\n";
  6945. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6946. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6947. } else {
  6948. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  6949. }
  6950. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6951. 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");
  6952. }
  6953. retStr += " </service>\r\n</imap>";
  6954. } else {
  6955. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6956. }
  6957. } else {
  6958. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6959. }
  6960. } else {
  6961. if (mMultiSwitchAPI != null) {
  6962. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  6963. if (nResult == 0) {
  6964. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6965. retStr += "result=\"ok\">\r\n" +
  6966. " <action>\"status\"</action>\r\n";
  6967. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6968. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6969. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6970. } else {
  6971. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6972. }
  6973. } else {
  6974. retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  6975. }
  6976. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6977. 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");
  6978. }
  6979. retStr += " </service>\r\n</imap>";
  6980. } else {
  6981. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  6982. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6983. }
  6984. } else {
  6985. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  6986. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6987. }
  6988. } else {
  6989. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  6990. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6991. }
  6992. }
  6993. } else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  6994. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6995. boolean OnOff = false;
  6996. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  6997. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  6998. if (bLightCMDUseAsSmartLight) {
  6999. if (mSdbAPI != null) {
  7000. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  7001. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  7002. if (ret >= 0) {
  7003. retStr += "result=\"ok\">\r\n" +
  7004. " <action>\"status\"</action>\r\n" +
  7005. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  7006. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  7007. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  7008. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  7009. 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");
  7010. }
  7011. retStr += " </service>\r\n</imap>";
  7012. } else {
  7013. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7014. }
  7015. } else {
  7016. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  7017. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  7018. if (ret >= 0) {
  7019. retStr += "result=\"ok\">\r\n" +
  7020. " <action>\"status\"</action>\r\n" +
  7021. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  7022. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  7023. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  7024. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  7025. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  7026. 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");
  7027. }
  7028. retStr += " </service>\r\n</imap>";
  7029. } else {
  7030. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7031. }
  7032. }
  7033. } else {
  7034. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7035. }
  7036. } else {
  7037. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  7038. if (mMultiSwitchAPI != null) {
  7039. int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  7040. if (nResultRefresh == 0) {
  7041. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  7042. if (nCtrlResult == 0) {
  7043. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  7044. if (nResult == 0) {
  7045. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  7046. retStr += "result=\"ok\">\r\n" +
  7047. " <action>\"status\"</action>\r\n" +
  7048. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  7049. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  7050. 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");
  7051. }
  7052. retStr += " </service>\r\n</imap>";
  7053. } else {
  7054. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  7055. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7056. }
  7057. } else {
  7058. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7059. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7060. }
  7061. } else {
  7062. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  7063. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7064. }
  7065. } else {
  7066. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7067. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7068. }
  7069. }
  7070. } else {
  7071. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  7072. if (mMultiSwitchAPI != null) {
  7073. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  7074. if (nCtrlResult == 0) {
  7075. int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
  7076. if (nResult == 0) {
  7077. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  7078. retStr += "result=\"ok\">\r\n" +
  7079. " <action>\"status\"</action>\r\n" +
  7080. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  7081. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  7082. 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");
  7083. }
  7084. retStr += " </service>\r\n</imap>";
  7085. } else {
  7086. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  7087. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7088. }
  7089. } else {
  7090. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7091. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7092. }
  7093. } else {
  7094. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  7095. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7096. }
  7097. }
  7098. }
  7099. }
  7100. } else {
  7101. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  7102. }
  7103. } else {
  7104. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  7105. }
  7106. MSlightcmd = null;
  7107. return retStr;
  7108. } catch (RuntimeException re) {
  7109. LogUtil.errorLogInfo("", TAG, re);
  7110. return null;
  7111. } catch (Exception e) {
  7112. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  7113. //e.printStackTrace();
  7114. LogUtil.errorLogInfo("", TAG, e);
  7115. return null;
  7116. }
  7117. }
  7118. public String iCMDProcSDPSmartLightControl(Document ele) {
  7119. try {
  7120. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7121. String retStr = CheckiCMDProc("remote_access_smartlight");
  7122. if (retStr != null) return retStr;
  7123. else
  7124. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7125. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7126. if (NewServerUse()) {
  7127. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7128. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  7129. return ServerCheckResult;
  7130. }
  7131. if (mSdb_LivingRoomLightAPI == null) {
  7132. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7133. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  7134. return retStr;
  7135. }
  7136. if (mSdbAPI == null) {
  7137. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7138. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  7139. return retStr;
  7140. }
  7141. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7142. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7143. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7144. return retStr;
  7145. }
  7146. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7147. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
  7148. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7149. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7150. return retStr;
  7151. }
  7152. }
  7153. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  7154. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7155. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7156. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7157. retStr += " result=\"ok\">\r\n";
  7158. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7159. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7160. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7161. for (int i = 0; i < nTotalLightCnt; i++) {
  7162. if (i == 0) {
  7163. 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";
  7164. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7165. String status_power = "off", status_dim = "null", status_color = "null";
  7166. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7167. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7168. } else {
  7169. status_power = "null";
  7170. }
  7171. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7172. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7173. } else {
  7174. status_dim = "null";
  7175. }
  7176. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7177. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7178. } else {
  7179. status_color = "null";
  7180. }
  7181. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7182. }
  7183. retStr += " </status_map>\r\n";
  7184. } else {
  7185. 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";
  7186. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7187. String status_power = "off", status_dim = "null", status_color = "null";
  7188. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7189. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7190. } else {
  7191. status_power = "null";
  7192. }
  7193. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7194. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7195. } else {
  7196. status_dim = "null";
  7197. }
  7198. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7199. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7200. } else {
  7201. status_color = "null";
  7202. }
  7203. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7204. }
  7205. retStr += " </status_map>\r\n";
  7206. }
  7207. }
  7208. retStr += " </service>\r\n</imap>\r\n";
  7209. } else {
  7210. int nDevNo = 0;
  7211. try {
  7212. nDevNo = Integer.parseInt(lightcmd.devnum);
  7213. } catch (RuntimeException re) {
  7214. LogUtil.errorLogInfo("", TAG, re);
  7215. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7216. return retStr;
  7217. } catch (Exception e) {
  7218. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  7219. //e.printStackTrace();
  7220. LogUtil.errorLogInfo("", TAG, e);
  7221. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7222. return retStr;
  7223. }
  7224. if ((nDevNo - 1) > nTotalLightCnt) {
  7225. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7226. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7227. return retStr;
  7228. }
  7229. retStr += " result=\"ok\">\r\n";
  7230. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7231. retStr += " <action>\"status\"</action>\r\n";
  7232. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7233. if (nDevNo == 1) {
  7234. 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";
  7235. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7236. String status_power = "off", status_dim = "null", status_color = "null";
  7237. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7238. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7239. } else {
  7240. status_power = "null";
  7241. }
  7242. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7243. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7244. } else {
  7245. status_dim = "null";
  7246. }
  7247. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7248. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7249. } else {
  7250. status_color = "null";
  7251. }
  7252. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7253. }
  7254. retStr += " </status_map>\r\n";
  7255. } else {
  7256. 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";
  7257. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7258. String status_power = "off", status_dim = "null", status_color = "null";
  7259. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7260. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7261. } else {
  7262. status_power = "null";
  7263. }
  7264. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7265. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7266. } else {
  7267. status_dim = "null";
  7268. }
  7269. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7270. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7271. } else {
  7272. status_color = "null";
  7273. }
  7274. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7275. }
  7276. retStr += " </status_map>\r\n";
  7277. }
  7278. retStr += " </service>\r\n</imap>\r\n";
  7279. }
  7280. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7281. int nResult = -99;
  7282. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7283. NodeList items = ele.getElementsByTagName("params");
  7284. Node item = items.item(0);
  7285. if (item != null) {
  7286. NamedNodeMap attrs = item.getAttributes();
  7287. for (int j = 0; j < attrs.getLength(); j++) {
  7288. Node attr = attrs.item(j);
  7289. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7290. dev_num = attr.getNodeValue();
  7291. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7292. dev_mode = attr.getNodeValue();
  7293. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7294. unit_num = attr.getNodeValue();
  7295. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7296. unit_status = attr.getNodeValue();
  7297. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7298. unit_dimming = attr.getNodeValue();
  7299. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7300. unit_color = attr.getNodeValue();
  7301. }
  7302. }
  7303. if (dev_num.equalsIgnoreCase("all")) {
  7304. nResult = 0;
  7305. for (int i = 0; i < nTotalLightCnt; i++) {
  7306. if (i == 0) {
  7307. nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7308. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7309. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7310. } else {
  7311. nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7312. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7313. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7314. }
  7315. }
  7316. if (nResult != 0) {
  7317. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7318. Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
  7319. return retStr;
  7320. } else {
  7321. retStr += " result=\"ok\">\r\n";
  7322. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7323. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7324. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7325. }
  7326. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7327. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7328. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7329. return retStr;
  7330. }
  7331. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
  7332. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7333. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7334. return retStr;
  7335. }
  7336. for (int i = 0; i < nTotalLightCnt; i++) {
  7337. if (i == 0) {
  7338. 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";
  7339. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7340. String status_power = "off", status_dim = "null", status_color = "null";
  7341. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7342. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7343. } else {
  7344. status_power = "null";
  7345. }
  7346. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7347. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7348. } else {
  7349. status_dim = "null";
  7350. }
  7351. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7352. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7353. } else {
  7354. status_color = "null";
  7355. }
  7356. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7357. }
  7358. retStr += " </status_map>\r\n";
  7359. } else {
  7360. 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";
  7361. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7362. String status_power = "off", status_dim = "null", status_color = "null";
  7363. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7364. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7365. } else {
  7366. status_power = "null";
  7367. }
  7368. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7369. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7370. } else {
  7371. status_dim = "null";
  7372. }
  7373. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7374. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7375. } else {
  7376. status_color = "null";
  7377. }
  7378. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7379. }
  7380. retStr += " </status_map>\r\n";
  7381. }
  7382. }
  7383. retStr += " </service>\r\n</imap>\r\n";
  7384. } else {
  7385. int nDevNo = 0;
  7386. int nUnitNo = 0;
  7387. try {
  7388. nDevNo = Integer.parseInt(dev_num);
  7389. } catch (RuntimeException re) {
  7390. LogUtil.errorLogInfo("", TAG, re);
  7391. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7392. return retStr;
  7393. } catch (Exception e) {
  7394. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7395. //e.printStackTrace();
  7396. LogUtil.errorLogInfo("", TAG, e);
  7397. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7398. return retStr;
  7399. }
  7400. if ((nDevNo - 1) > nTotalLightCnt) {
  7401. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
  7402. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7403. return retStr;
  7404. }
  7405. nResult = -99;
  7406. if (unit_num.equalsIgnoreCase("all")) {
  7407. if (nDevNo == 1) {
  7408. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7409. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7410. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7411. } else {
  7412. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
  7413. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7414. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7415. }
  7416. if (nResult != 0) {
  7417. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7418. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7419. return retStr;
  7420. }
  7421. } else {
  7422. try {
  7423. nUnitNo = Integer.parseInt(unit_num);
  7424. } catch (RuntimeException re) {
  7425. LogUtil.errorLogInfo("", TAG, re);
  7426. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7427. return retStr;
  7428. } catch (Exception e) {
  7429. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7430. //e.printStackTrace();
  7431. LogUtil.errorLogInfo("", TAG, e);
  7432. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7433. return retStr;
  7434. }
  7435. nResult = -99;
  7436. if (nDevNo == 1) {
  7437. nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7438. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7439. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7440. } else {
  7441. nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7442. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7443. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7444. }
  7445. if (nResult != 0) {
  7446. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7447. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
  7448. return retStr;
  7449. }
  7450. }
  7451. if (nDevNo == 1) {
  7452. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7453. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7454. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7455. return retStr;
  7456. } else {
  7457. retStr += " result=\"ok\">\r\n";
  7458. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7459. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7460. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7461. }
  7462. 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";
  7463. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7464. String status_power = "off", status_dim = "null", status_color = "null";
  7465. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7466. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7467. } else {
  7468. status_power = "null";
  7469. }
  7470. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7471. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7472. } else {
  7473. status_dim = "null";
  7474. }
  7475. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7476. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7477. } else {
  7478. status_color = "null";
  7479. }
  7480. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7481. }
  7482. retStr += " </status_map>\r\n";
  7483. } else {
  7484. int nRealDevNo = (byte) (nDevNo - 2);
  7485. if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
  7486. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7487. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7488. return retStr;
  7489. } else {
  7490. retStr += " result=\"ok\">\r\n";
  7491. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7492. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7493. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7494. }
  7495. 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";
  7496. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
  7497. String status_power = "off", status_dim = "null", status_color = "null";
  7498. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
  7499. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7500. } else {
  7501. status_power = "null";
  7502. }
  7503. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
  7504. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
  7505. } else {
  7506. status_dim = "null";
  7507. }
  7508. if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
  7509. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
  7510. } else {
  7511. status_color = "null";
  7512. }
  7513. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7514. }
  7515. retStr += " </status_map>\r\n";
  7516. }
  7517. retStr += " </service>\r\n</imap>\r\n";
  7518. }
  7519. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  7520. int nResult = 0;
  7521. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7522. NodeList items = ele.getElementsByTagName("params");
  7523. Node item = items.item(0);
  7524. if (item != null) {
  7525. NamedNodeMap attrs = item.getAttributes();
  7526. for (int j = 0; j < attrs.getLength(); j++) {
  7527. Node attr = attrs.item(j);
  7528. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  7529. dev_num = attr.getNodeValue();
  7530. else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
  7531. dev_mode = attr.getNodeValue();
  7532. else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7533. unit_num = attr.getNodeValue();
  7534. else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
  7535. unit_status = attr.getNodeValue();
  7536. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
  7537. unit_dimming = attr.getNodeValue();
  7538. else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
  7539. unit_color = attr.getNodeValue();
  7540. }
  7541. }
  7542. if (dev_num.equalsIgnoreCase("all")) {
  7543. if (!dev_mode.equals("null")) {
  7544. nResult = -99;
  7545. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7546. if (nResult != 0) {
  7547. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7548. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7549. return retStr;
  7550. }
  7551. } else {
  7552. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7553. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7554. return retStr;
  7555. }
  7556. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7557. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7558. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7559. return retStr;
  7560. } else {
  7561. retStr += " result=\"ok\">\r\n";
  7562. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7563. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7564. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7565. }
  7566. 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";
  7567. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  7568. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7569. } else {
  7570. int nDevNo = 0;
  7571. try {
  7572. nDevNo = Integer.parseInt(dev_num);
  7573. } catch (RuntimeException re) {
  7574. LogUtil.errorLogInfo("", TAG, re);
  7575. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7576. return retStr;
  7577. } catch (Exception e) {
  7578. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7579. //e.printStackTrace();
  7580. LogUtil.errorLogInfo("", TAG, e);
  7581. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7582. return retStr;
  7583. }
  7584. if (nDevNo != 1) {
  7585. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  7586. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7587. return retStr;
  7588. }
  7589. if (!dev_mode.equals("null")) {
  7590. nResult = -99;
  7591. nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7592. if (nResult != 0) {
  7593. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7594. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7595. return retStr;
  7596. }
  7597. } else {
  7598. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7599. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7600. return retStr;
  7601. }
  7602. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7603. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7604. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7605. return retStr;
  7606. } else {
  7607. retStr += " result=\"ok\">\r\n";
  7608. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7609. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7610. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7611. }
  7612. 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";
  7613. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7614. String status_power = "off", status_dim = "null", status_color = "null";
  7615. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7616. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7617. } else {
  7618. status_power = "null";
  7619. }
  7620. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7621. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7622. } else {
  7623. status_dim = "null";
  7624. }
  7625. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7626. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7627. } else {
  7628. status_color = "null";
  7629. }
  7630. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7631. }
  7632. retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
  7633. }
  7634. } else {
  7635. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7636. }
  7637. lightcmd = null;
  7638. return retStr;
  7639. } catch (RuntimeException re) {
  7640. LogUtil.errorLogInfo("", TAG, re);
  7641. return null;
  7642. } catch (Exception e) {
  7643. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7644. //e.printStackTrace();
  7645. LogUtil.errorLogInfo("", TAG, e);
  7646. return null;
  7647. }
  7648. }
  7649. private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
  7650. byte type = 0;
  7651. //각 스위치 개수는 4개임
  7652. switch (lightIndex) {
  7653. case 0:
  7654. type = benEm.Info.LightType_1;
  7655. break;
  7656. case 1:
  7657. type = benEm.Info.LightType_2;
  7658. break;
  7659. case 2:
  7660. type = benEm.Info.LightType_3;
  7661. break;
  7662. case 3:
  7663. type = benEm.Info.LightType_4;
  7664. break;
  7665. default:
  7666. break;
  7667. }
  7668. return type;
  7669. }
  7670. public String iCMDProcChumDamSmartLightControl(Document ele) {
  7671. try {
  7672. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7673. String retStr = CheckiCMDProc("remote_access_smartlight");
  7674. if (retStr != null) return retStr;
  7675. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7676. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7677. if (NewServerUse()) {
  7678. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7679. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7680. }
  7681. KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
  7682. if (KnxApi == null) {
  7683. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7684. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
  7685. return retStr;
  7686. }
  7687. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7688. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7689. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7690. return retStr;
  7691. }
  7692. int LivingLightCount = 0;
  7693. if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
  7694. Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
  7695. } else {
  7696. if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
  7697. LivingLightCount = 1;
  7698. }
  7699. //기준층 명칭
  7700. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  7701. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  7702. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_LIGHT);
  7703. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  7704. int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
  7705. int SwitchCount = KnxApi.data.MasterController.Info.Light_SwitchCount;
  7706. int totalLightCount = LivingLightCount + BadLightCount + SwitchCount;
  7707. int emCount = LivingLightCount + BadLightCount;
  7708. //mData.MasterController.Info.Light_SwitchCount
  7709. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
  7710. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
  7711. {
  7712. retStr += " result=\"ok\">\r\n";
  7713. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7714. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7715. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7716. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7717. for (int i = 0; i < totalLightCount; i++) {
  7718. if (i == 0) {
  7719. retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7720. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7721. String status_power = "off", status_dim = "null", status_color = "null";
  7722. 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);
  7723. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7724. 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);
  7725. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7726. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7727. }
  7728. retStr += " </status_map>\r\n";
  7729. } else if(i>0 && i<emCount){
  7730. 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";
  7731. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7732. String status_power = "off", status_dim = "null", status_color = "null";
  7733. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7734. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7735. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  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. } else{
  7741. 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";
  7742. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7743. String status_power = "off", status_dim = "null", status_color = "null";
  7744. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7745. status_dim ="null";
  7746. // zzz
  7747. //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
  7748. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7749. }
  7750. retStr += " </status_map>\r\n";
  7751. }
  7752. }
  7753. }
  7754. else
  7755. {
  7756. int nResult = 0;
  7757. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7758. NodeList items = ele.getElementsByTagName("params");
  7759. Node item = items.item(0);
  7760. if (item != null) {
  7761. NamedNodeMap attrs = item.getAttributes();
  7762. for (int j = 0; j< attrs.getLength(); j++) {
  7763. Node attr = attrs.item(j);
  7764. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7765. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7766. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7767. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7768. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7769. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7770. }
  7771. }
  7772. int nDevNo = Integer.parseInt(dev_num);
  7773. if (nDevNo == 1) {
  7774. retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7775. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7776. String status_power = "off", status_dim = "null", status_color = "null";
  7777. 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);
  7778. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7779. 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);
  7780. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7781. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7782. }
  7783. retStr += " </status_map>\r\n";
  7784. } else if(nDevNo>1 && nDevNo<emCount+1){
  7785. 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";
  7786. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
  7787. String status_power = "off", status_dim = "null", status_color = "null";
  7788. status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7789. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
  7790. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
  7791. status_dim ="null";
  7792. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7793. }
  7794. retStr += " </status_map>\r\n";
  7795. } else{
  7796. 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";
  7797. for (int j = 0; j < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount; j++) {
  7798. String status_power = "off", status_dim = "null", status_color = "null";
  7799. status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7800. status_dim ="null";
  7801. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7802. }
  7803. retStr += " </status_map>\r\n";
  7804. }
  7805. }
  7806. retStr += " </service>\r\n</imap>\r\n";
  7807. }
  7808. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7809. int nResult = 0;
  7810. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7811. NodeList items = ele.getElementsByTagName("params");
  7812. Node item = items.item(0);
  7813. if (item != null) {
  7814. NamedNodeMap attrs = item.getAttributes();
  7815. for (int j = 0; j< attrs.getLength(); j++) {
  7816. Node attr = attrs.item(j);
  7817. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7818. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7819. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7820. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7821. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7822. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7823. }
  7824. }
  7825. if (dev_num.equalsIgnoreCase("ALL")) {
  7826. // 일괄소등 실행/해제
  7827. if (!unit_status.equalsIgnoreCase("null")) {
  7828. KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
  7829. }
  7830. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7831. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7832. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7833. return retStr;
  7834. }
  7835. retStr += " result=\"ok\">\r\n";
  7836. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7837. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7838. retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
  7839. for (int i = 0; i < totalLightCount; i++) {
  7840. if (i == 0) {
  7841. retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ "null" + "\" dev_name=\""+ knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7842. for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
  7843. String status_power = "off", status_dim = "null", status_color = "null";
  7844. 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);
  7845. status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
  7846. 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);
  7847. status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
  7848. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7849. }
  7850. retStr += " </status_map>\r\n";
  7851. }
  7852. else if(i>0 && i<emCount){
  7853. 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";
  7854. for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7855. String status_power = "off", status_dim = "null", status_color = "null";
  7856. status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
  7857. status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
  7858. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
  7859. status_dim ="null";
  7860. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7861. }
  7862. retStr += " </status_map>\r\n";
  7863. } else {
  7864. 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";
  7865. for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
  7866. String status_power = "off", status_dim = "null", status_color = "null";
  7867. status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
  7868. status_dim ="null";
  7869. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7870. }
  7871. retStr += " </status_map>\r\n";
  7872. }
  7873. }
  7874. retStr += " </service>\r\n</imap>\r\n";
  7875. }
  7876. else {
  7877. int nDevNo = 0;
  7878. int nUnitNo = 0;
  7879. try {
  7880. nDevNo = Integer.parseInt(dev_num);
  7881. } catch (Exception e) {
  7882. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7883. e.printStackTrace();
  7884. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7885. return retStr;
  7886. }
  7887. if ((nDevNo - 1) > totalLightCount) {
  7888. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
  7889. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7890. return retStr;
  7891. }
  7892. // retStr += " result=\"ok\">\r\n";
  7893. // retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7894. // retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7895. // retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7896. if (unit_num.equalsIgnoreCase("all")) {
  7897. if (nDevNo == 1) {
  7898. // 거실 조명 일괄제어일 경우
  7899. if (!unit_status.equalsIgnoreCase("null")) {
  7900. int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7901. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7902. }
  7903. if (!unit_dimming.equalsIgnoreCase("null")) {
  7904. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7905. }
  7906. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7907. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7908. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7909. return retStr;
  7910. }
  7911. retStr += " result=\"ok\">\r\n";
  7912. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7913. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7914. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7915. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  7916. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  7917. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  7918. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  7919. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7920. }
  7921. }
  7922. else if(nDevNo>1 && nDevNo<emCount+1){
  7923. // 각각 EM 조명 일괄제어일 경우
  7924. if (!unit_status.equalsIgnoreCase("null")) {
  7925. KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7926. }
  7927. if (!unit_dimming.equalsIgnoreCase("null")) {
  7928. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : ");
  7929. if( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_2 == 0x0F
  7930. || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_3 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_4 == 0x0F)
  7931. {
  7932. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] ==> Fan : " + nDevNo );
  7933. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7934. // 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
  7935. int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
  7936. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7937. }
  7938. }
  7939. else {
  7940. int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  7941. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
  7942. }
  7943. //KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
  7944. }
  7945. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7946. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7947. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7948. return retStr;
  7949. }
  7950. retStr += " result=\"ok\">\r\n";
  7951. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7952. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7953. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7954. 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";
  7955. nDevNo = Integer.parseInt(dev_num);
  7956. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  7957. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7958. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  7959. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  7960. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  7961. status_dim ="null";
  7962. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7963. }
  7964. } else {
  7965. // 각각 EM 스위치 일괄제어일 경우
  7966. if (!unit_status.equalsIgnoreCase("null")) {
  7967. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
  7968. }
  7969. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  7970. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7971. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7972. return retStr;
  7973. }
  7974. retStr += " result=\"ok\">\r\n";
  7975. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7976. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7977. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7978. 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";
  7979. nDevNo = Integer.parseInt(dev_num);
  7980. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  7981. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  7982. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  7983. String status_dim ="null";
  7984. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  7985. }
  7986. }
  7987. // retStr += " </status_map>\r\n";
  7988. // retStr += " </service>\r\n</imap>\r\n";
  7989. }
  7990. else {
  7991. // 회로별 제어일경우
  7992. try {
  7993. nUnitNo = Integer.parseInt(unit_num);
  7994. } catch (Exception e) {
  7995. Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7996. e.printStackTrace();
  7997. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7998. return retStr;
  7999. }
  8000. if (nDevNo == 1) {
  8001. if (!unit_status.equalsIgnoreCase("null")) {
  8002. int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
  8003. //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  8004. }
  8005. if (!unit_dimming.equalsIgnoreCase("null")) {
  8006. KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
  8007. //mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
  8008. }
  8009. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  8010. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8011. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  8012. return retStr;
  8013. }
  8014. retStr += " result=\"ok\">\r\n";
  8015. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  8016. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  8017. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  8018. retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
  8019. nDevNo = Integer.parseInt(dev_num);
  8020. for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
  8021. String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
  8022. String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
  8023. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  8024. }
  8025. }
  8026. else if(nDevNo>1 && nDevNo<emCount+1){
  8027. if (!unit_status.equalsIgnoreCase("null")) {
  8028. KnxApi.SetLightOnOff((byte) (nDevNo -2), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  8029. //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
  8030. //회로별 제어는 On/Off 만 가능함
  8031. }
  8032. if (!unit_dimming.equalsIgnoreCase("null")) {
  8033. KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)(nUnitNo-1),(byte) Integer.parseInt(unit_dimming));
  8034. //일괄제어라 회로별 제어기능은 없음
  8035. // 시험 2021.05.12
  8036. }
  8037. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  8038. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8039. Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  8040. return retStr;
  8041. }
  8042. retStr += " result=\"ok\">\r\n";
  8043. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  8044. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  8045. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  8046. 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";
  8047. nDevNo = Integer.parseInt(dev_num);
  8048. for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
  8049. String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
  8050. String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
  8051. if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
  8052. status_dim ="null";
  8053. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  8054. }
  8055. } else{
  8056. if (!unit_status.equalsIgnoreCase("null")) {
  8057. KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
  8058. }
  8059. if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
  8060. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8061. Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
  8062. return retStr;
  8063. }
  8064. retStr += " result=\"ok\">\r\n";
  8065. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  8066. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  8067. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  8068. 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";
  8069. nDevNo = Integer.parseInt(dev_num);
  8070. for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
  8071. //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
  8072. String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
  8073. String status_dim ="null";
  8074. retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
  8075. }
  8076. }
  8077. }
  8078. retStr += " </status_map>\r\n";
  8079. retStr += " </service>\r\n</imap>\r\n";
  8080. }
  8081. }
  8082. else {
  8083. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  8084. }
  8085. return retStr;
  8086. } catch (Exception e) {
  8087. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  8088. e.printStackTrace();
  8089. return null;
  8090. }
  8091. }
  8092. public String iCMDProcLivingLightControl(Document ele) {
  8093. try {
  8094. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  8095. String retStr = CheckiCMDProc("remote_access_livinglight");
  8096. if (retStr != null) return retStr;
  8097. else
  8098. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  8099. String target = "null", tid = "null", msgno = "null";
  8100. NodeList items = ele.getElementsByTagName("target");
  8101. Node item = items.item(0);
  8102. if (item != null) {
  8103. NamedNodeMap attrs = item.getAttributes();
  8104. for (int j = 0; j < attrs.getLength(); j++) {
  8105. Node attr = attrs.item(j);
  8106. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8107. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8108. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8109. msgno = attr.getNodeValue();
  8110. }
  8111. }
  8112. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8113. if (NewServerUse()) {
  8114. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8115. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8116. return ServerCheckResult;
  8117. }
  8118. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8119. if (bLightCMDUseAsSmartLight) {
  8120. if (mSdb_LivingRoomLightAPI != null) {
  8121. mSdb_LivingRoomLightAPI.Refresh();
  8122. 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";
  8123. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8124. 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");
  8125. }
  8126. retStr += " </service>\r\n</imap>\r\n";
  8127. } else {
  8128. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  8129. }
  8130. } else {
  8131. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8132. if (lightCTR != null) {
  8133. if (lightCTR.Refresh(false) == 0) {
  8134. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8135. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8136. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8137. }
  8138. retStr += " </service>\r\n</imap>\r\n";
  8139. } else {
  8140. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  8141. }
  8142. }
  8143. }
  8144. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8145. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  8146. boolean OnOff = false;
  8147. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  8148. if (bLightCMDUseAsSmartLight) {
  8149. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8150. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  8151. if (ret >= 0) {
  8152. ret = mSdb_LivingRoomLightAPI.Refresh();
  8153. if (ret >= 0) {
  8154. 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";
  8155. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8156. 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");
  8157. }
  8158. retStr += " </service>\r\n</imap>\r\n";
  8159. } else {
  8160. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8161. }
  8162. } else {
  8163. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8164. }
  8165. } else {
  8166. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8167. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  8168. if (ret >= 0) {
  8169. ret = mSdb_LivingRoomLightAPI.Refresh();
  8170. if (ret >= 0) {
  8171. 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";
  8172. for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  8173. 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");
  8174. }
  8175. retStr += " </service>\r\n</imap>\r\n";
  8176. } else {
  8177. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8178. }
  8179. } else {
  8180. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8181. }
  8182. }
  8183. } else {
  8184. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  8185. if (lightCTR != null) {
  8186. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  8187. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  8188. if (ret >= 0) {
  8189. ret = lightCTR.Refresh(false);
  8190. if (ret >= 0) {
  8191. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8192. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8193. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8194. }
  8195. retStr += " </service>\r\n</imap>\r\n";
  8196. } else {
  8197. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8198. }
  8199. } else {
  8200. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8201. }
  8202. } else {
  8203. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8204. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  8205. if (ret >= 0) {
  8206. ret = lightCTR.Refresh(false);
  8207. if (ret >= 0) {
  8208. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8209. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8210. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  8211. }
  8212. retStr += " </service>\r\n</imap>\r\n";
  8213. } else {
  8214. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8215. }
  8216. } else {
  8217. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8218. }
  8219. }
  8220. }
  8221. }
  8222. } else {
  8223. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  8224. }
  8225. } else {
  8226. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  8227. }
  8228. lightcmd = null;
  8229. return retStr;
  8230. } catch (RuntimeException re) {
  8231. LogUtil.errorLogInfo("", TAG, re);
  8232. return null;
  8233. } catch (Exception e) {
  8234. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  8235. //e.printStackTrace();
  8236. LogUtil.errorLogInfo("", TAG, e);
  8237. return null;
  8238. }
  8239. }
  8240. public String iCMDProc_I_LightControl(Document ele) {
  8241. try {
  8242. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  8243. String retStr = CheckiCMDProc("remote_access_livinglight");
  8244. if (retStr != null) return retStr;
  8245. else
  8246. retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  8247. String target = "null", tid = "null", msgno = "null";
  8248. NodeList items = ele.getElementsByTagName("target");
  8249. Node item = items.item(0);
  8250. if (item != null) {
  8251. NamedNodeMap attrs = item.getAttributes();
  8252. for (int j = 0; j < attrs.getLength(); j++) {
  8253. Node attr = attrs.item(j);
  8254. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8255. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8256. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8257. msgno = attr.getNodeValue();
  8258. }
  8259. }
  8260. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8261. if (NewServerUse()) {
  8262. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8263. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8264. return ServerCheckResult;
  8265. }
  8266. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  8267. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  8268. if (lightCTR != null && lightCTR.Refresh(false) == 0) {
  8269. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8270. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8271. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8272. }
  8273. retStr += " </service>\r\n</imap>\r\n";
  8274. } else {
  8275. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  8276. }
  8277. } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  8278. if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  8279. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  8280. int result = -999;
  8281. if (lightCTR != null) {
  8282. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  8283. result = lightCTR.LightProgramControl((byte) num, (byte) 1);
  8284. } else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  8285. result = lightCTR.LightProgramControl((byte) num, (byte) 0);
  8286. }
  8287. if (result >= 0) {
  8288. // 제어 성공
  8289. try {
  8290. Thread.sleep(1000);
  8291. } catch (RuntimeException re) {
  8292. LogUtil.errorLogInfo("", TAG, re);
  8293. } catch (Exception e) {
  8294. LogUtil.errorLogInfo("", TAG, e);
  8295. }
  8296. lightCTR.Refresh(false);
  8297. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8298. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8299. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8300. }
  8301. retStr += " </service>\r\n</imap>";
  8302. } else {
  8303. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8304. }
  8305. } else {
  8306. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8307. }
  8308. } else {
  8309. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  8310. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  8311. if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  8312. try {
  8313. Thread.sleep(1000);
  8314. } catch (RuntimeException re) {
  8315. LogUtil.errorLogInfo("", TAG, re);
  8316. } catch (Exception e) {
  8317. LogUtil.errorLogInfo("", TAG, e);
  8318. }
  8319. lightCTR.Refresh(false);
  8320. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  8321. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  8322. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
  8323. }
  8324. retStr += " </service>\r\n</imap>\r\n";
  8325. } else {
  8326. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  8327. }
  8328. }
  8329. } else {
  8330. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  8331. }
  8332. lightcmd = null;
  8333. return retStr;
  8334. } catch (RuntimeException re) {
  8335. LogUtil.errorLogInfo("", TAG, re);
  8336. return null;
  8337. } catch (Exception e) {
  8338. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  8339. //e.printStackTrace();
  8340. LogUtil.errorLogInfo("", TAG, e);
  8341. return null;
  8342. }
  8343. }
  8344. public String iCMDProcGASControl(Element ele) {
  8345. try {
  8346. String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
  8347. String strResult = CheckiCMDProc("remote_access_gas");
  8348. if (strResult != null) return strResult;
  8349. else
  8350. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  8351. NodeList items = ele.getElementsByTagName("target");
  8352. Node item = items.item(0);
  8353. if (item != null) {
  8354. NamedNodeMap attrs = item.getAttributes();
  8355. for (int j = 0; j < attrs.getLength(); j++) {
  8356. Node attr = attrs.item(j);
  8357. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8358. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8359. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8360. msgno = attr.getNodeValue();
  8361. }
  8362. }
  8363. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8364. if (NewServerUse()) {
  8365. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  8366. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8367. return ServerCheckResult;
  8368. }
  8369. NodeList itemsParam = ele.getElementsByTagName("params");
  8370. Node itemParam = itemsParam.item(0);
  8371. if (itemParam != null) {
  8372. NamedNodeMap attrsParam = itemParam.getAttributes();
  8373. for (int j = 0; j < attrsParam.getLength(); j++) {
  8374. Node attr = attrsParam.item(j);
  8375. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8376. devnum = attr.getNodeValue();
  8377. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  8378. //unitnum = attr.getNodeValue();
  8379. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8380. ctraction = attr.getNodeValue();
  8381. }
  8382. }
  8383. NodeList itemsaction = ele.getElementsByTagName("action");
  8384. Node itemaction = itemsaction.item(0);
  8385. Node text = itemaction.getFirstChild();
  8386. String actionTXT = text.getNodeValue();
  8387. //수정
  8388. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  8389. actionTXT = trimquotation(actionTXT);
  8390. GasAPI GasValveCTR = null;
  8391. CooktopAPI HybridCookTopCTR = null;
  8392. if (mWallPadAPI.GetGasKind() == 2) {
  8393. //하이브리드
  8394. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  8395. } else {
  8396. GasValveCTR = mWallPadAPI.Get_GasController();
  8397. }
  8398. if (actionTXT.equalsIgnoreCase("status")) {
  8399. // 가스밸브 상태 조회
  8400. if (mWallPadAPI.GetGasKind() == 2) {
  8401. //하이브리드
  8402. if (HybridCookTopCTR != null) {
  8403. //전체 정보가져오기
  8404. int ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8405. if (ret < 0) {
  8406. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8407. return strResult;
  8408. }
  8409. int OnOpenCount = 0;
  8410. int OperationCount = 0;
  8411. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8412. // 콘센트 ON/OFF 업데이트
  8413. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8414. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8415. OnOpenCount++;
  8416. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8417. OperationCount++;
  8418. }
  8419. }
  8420. }
  8421. if (OperationCount > 0) {
  8422. valvestatus = "ing";
  8423. } else if (OnOpenCount > 0) {
  8424. valvestatus = "open";
  8425. } else {
  8426. valvestatus = "close";
  8427. }
  8428. }
  8429. } else {
  8430. if (GasValveCTR != null) {
  8431. int ret = GasValveCTR.Refresh((byte) 0, false);
  8432. if (ret < 0) {
  8433. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8434. return strResult;
  8435. }
  8436. if (GasValveCTR.data.DeviceCnt == 2) {
  8437. GasValveCTR.Refresh((byte) 1, false);
  8438. }
  8439. byte GasStatus = GasAPI.GASSTATUS.Close;
  8440. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8441. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8442. GasStatus = GasAPI.GASSTATUS.Operation;
  8443. break;
  8444. }
  8445. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8446. GasStatus = GasAPI.GASSTATUS.Open;
  8447. break;
  8448. }
  8449. }
  8450. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8451. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8452. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8453. else valvestatus = "unknown";
  8454. }
  8455. }
  8456. } else if (actionTXT.equalsIgnoreCase("control")) {
  8457. // 가스밸브 콘트롤
  8458. if (mWallPadAPI.GetGasKind() == 2) {
  8459. //하이브리드
  8460. if (HybridCookTopCTR != null) {
  8461. int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
  8462. if (ret < 0) {
  8463. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8464. return strResult;
  8465. }
  8466. ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
  8467. if (ret < 0) {
  8468. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8469. return strResult;
  8470. }
  8471. int OnOpenCount = 0;
  8472. int OperationCount = 0;
  8473. for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
  8474. // 콘센트 ON/OFF 업데이트
  8475. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8476. if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
  8477. OnOpenCount++;
  8478. } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
  8479. OperationCount++;
  8480. }
  8481. }
  8482. }
  8483. if (OperationCount > 0) {
  8484. valvestatus = "ing";
  8485. } else if (OnOpenCount > 0) {
  8486. valvestatus = "open";
  8487. } else {
  8488. valvestatus = "close";
  8489. }
  8490. }
  8491. } else {
  8492. if (GasValveCTR != null) {
  8493. int ret = GasValveCTR.SetClose((byte) 0xFF);
  8494. if (ret < 0) {
  8495. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8496. return strResult;
  8497. }
  8498. ret = GasValveCTR.Refresh((byte) 0, false);
  8499. if (ret < 0) {
  8500. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8501. return strResult;
  8502. }
  8503. if (GasValveCTR.data.DeviceCnt == 2) {
  8504. GasValveCTR.Refresh((byte) 1, false);
  8505. }
  8506. byte GasStatus = GasAPI.GASSTATUS.Close;
  8507. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8508. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8509. GasStatus = GasAPI.GASSTATUS.Operation;
  8510. break;
  8511. }
  8512. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8513. GasStatus = GasAPI.GASSTATUS.Open;
  8514. break;
  8515. }
  8516. }
  8517. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8518. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8519. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8520. else valvestatus = "unknown";
  8521. }
  8522. }
  8523. } else {
  8524. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8525. return strResult;
  8526. }
  8527. strResult += "\"ok\" >\r\n";
  8528. strResult += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8529. strResult += " <action>\"" + actionTXT + "\"</action>\r\n";
  8530. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  8531. strResult += " <status_info unit_num=\"gas1\" unit_status=\"" + valvestatus + "\"/>\r\n";
  8532. strResult += " </service>\r\n";
  8533. strResult += "</imap> ";
  8534. return strResult;
  8535. } catch (RuntimeException re) {
  8536. LogUtil.errorLogInfo("", TAG, re);
  8537. return null;
  8538. } catch (Exception e) {
  8539. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  8540. //e.printStackTrace();
  8541. LogUtil.errorLogInfo("", TAG, e);
  8542. return null;
  8543. }
  8544. }
  8545. private String iCMDProcLightBatchControl(Element ele) {
  8546. try {
  8547. String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
  8548. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  8549. if (retStr != null) return retStr;
  8550. NodeList items = ele.getElementsByTagName("target");
  8551. Node item = items.item(0);
  8552. if (item != null) {
  8553. NamedNodeMap attrs = item.getAttributes();
  8554. for (int j = 0; j < attrs.getLength(); j++) {
  8555. Node attr = attrs.item(j);
  8556. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8557. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8558. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  8559. msgno = attr.getNodeValue();
  8560. }
  8561. }
  8562. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8563. if (NewServerUse()) {
  8564. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8565. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
  8566. return ServerCheckResult;
  8567. }
  8568. NodeList itemsParam = ele.getElementsByTagName("params");
  8569. Node itemParam = itemsParam.item(0);
  8570. if (itemParam != null) {
  8571. NamedNodeMap attrsParam = itemParam.getAttributes();
  8572. for (int j = 0; j < attrsParam.getLength(); j++) {
  8573. Node attr = attrsParam.item(j);
  8574. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8575. ctraction = attr.getNodeValue();
  8576. }
  8577. }
  8578. }
  8579. NodeList itemsaction = ele.getElementsByTagName("action");
  8580. Node itemaction = itemsaction.item(0);
  8581. Node text = itemaction.getFirstChild();
  8582. String actionTXT = text.getNodeValue();
  8583. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  8584. actionTXT = trimquotation(actionTXT);
  8585. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8586. if (actionTXT.equalsIgnoreCase("status")) {
  8587. // 일괄소등 상태 조회
  8588. int ret = mWallPadAPI.GetBatchSwitchStatus();
  8589. if (ret > 1) {
  8590. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8591. return retStr;
  8592. }
  8593. if (ret == 0) {
  8594. ilgalstatus = "on";
  8595. } else if (ret == 1) {
  8596. ilgalstatus = "off";
  8597. } else {
  8598. ilgalstatus = "error";
  8599. }
  8600. } else if (actionTXT.equalsIgnoreCase("control")) {
  8601. // 일괄소등 제어
  8602. int ret = -1;
  8603. int status = -1;
  8604. if (ctraction.equals("on") == true) {
  8605. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  8606. status = 0;
  8607. } else if (ctraction.equals("off") == true) {
  8608. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  8609. status = 1;
  8610. }
  8611. if (ret < 0) {
  8612. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8613. return retStr;
  8614. }
  8615. if (status == 0) {
  8616. ilgalstatus = "on";
  8617. } else if (status == 1) {
  8618. ilgalstatus = "off";
  8619. } else {
  8620. ilgalstatus = "error";
  8621. }
  8622. } else {
  8623. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8624. return retStr;
  8625. }
  8626. retStr += "\"ok\" >\r\n";
  8627. retStr += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
  8628. retStr += " <action>\"" + actionTXT + "\"</action>\r\n";
  8629. retStr += " <status_info unit_status=\"" + ilgalstatus + "\"/>\r\n </service>\r\n</imap> ";
  8630. return retStr;
  8631. } catch (RuntimeException re) {
  8632. LogUtil.errorLogInfo("", TAG, re);
  8633. return null;
  8634. } catch (Exception e) {
  8635. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  8636. //e.printStackTrace();
  8637. LogUtil.errorLogInfo("", TAG, e);
  8638. return null;
  8639. }
  8640. }
  8641. private boolean airconTestMode = false;
  8642. private boolean [] airconTestModeOnOff = {false, true, false, true, false, true, false, true, false, true, false};
  8643. private String getTextSysAirconMode(byte in)
  8644. {
  8645. if( in == DataClasses.KnxSystemAircon.MODE.Auto)
  8646. return "auto";
  8647. else if( in == DataClasses.KnxSystemAircon.MODE.Cold)
  8648. return "cool";
  8649. else if( in == DataClasses.KnxSystemAircon.MODE.Dry)
  8650. return "dehum";
  8651. else if( in == DataClasses.KnxSystemAircon.MODE.Venti)
  8652. return "blow";
  8653. else if( in == DataClasses.KnxSystemAircon.MODE.Heat)
  8654. return "heat";
  8655. else
  8656. return "null";
  8657. }
  8658. private String iCMDProcSysairconControl(Element ele) {
  8659. try {
  8660. String target= "null", tid= "null", msgno= "null", devnum = "null",ctraction = "null", ilgalstatus = "null";
  8661. String retStr = CheckiCMDProc("remote_access_sysaircon");
  8662. if (retStr != null) return retStr;
  8663. NodeList items = ele.getElementsByTagName("target");
  8664. Node item = items.item(0);
  8665. if (item != null) {
  8666. NamedNodeMap attrs = item.getAttributes();
  8667. for (int j = 0; j < attrs.getLength(); j++) {
  8668. Node attr = attrs.item(j);
  8669. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8670. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8671. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  8672. }
  8673. }
  8674. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8675. if (NewServerUse()) {
  8676. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8677. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  8678. }
  8679. NodeList itemsParam = ele.getElementsByTagName("params");
  8680. Node itemParam = itemsParam.item(0);
  8681. if (itemParam != null) {
  8682. NamedNodeMap attrsParam = itemParam.getAttributes();
  8683. for (int j = 0; j < attrsParam.getLength(); j++) {
  8684. Node attr = attrsParam.item(j);
  8685. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  8686. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8687. ctraction = attr.getNodeValue();
  8688. }
  8689. }
  8690. }
  8691. NodeList itemsaction = ele.getElementsByTagName("action");
  8692. Node itemaction = itemsaction.item(0);
  8693. Node text = itemaction.getFirstChild();
  8694. String actionTXT = text.getNodeValue();
  8695. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_sysaircon\" result=";
  8696. actionTXT = trimquotation(actionTXT);
  8697. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8698. int ndeviceCount = 0;
  8699. String sMode = "auto/cool/dehum/blow/heat"; // 자동, 냉방, 제습, 송풍, 난방
  8700. String [] aMode = {"auto","cool","dehum","blow","heat"};
  8701. String strResultStatus = "";
  8702. //기준층 명칭
  8703. String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  8704. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
  8705. String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_SYSTEMAIRCON);
  8706. if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
  8707. String [] mTextWindType = {"자동", "약", "중", "강"};
  8708. String m_TextWindRange = "자동/약/중/강";
  8709. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  8710. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  8711. mWallpadDeviceSet.closeDB();
  8712. if (nResult != Version.DISTRIBUTION_MODEL.KNX_DIST) {
  8713. String[] mAirconNmae = new String[]{"에어컨1", "에어컨2", "에어컨3", "에어컨4", "에어컨5", "에어컨6", "에어컨7", "에어컨8"};
  8714. knxRoomNameList = mAirconNmae;
  8715. }
  8716. KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
  8717. int nCount = 7;
  8718. if( airconAPI != null )
  8719. nCount = airconAPI.data.Device.info.InsideAirconCount;
  8720. if( airconTestMode == true )nCount = 7;
  8721. if( actionTXT.equalsIgnoreCase("status") ) {
  8722. // 에어컨 상태조회
  8723. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8724. if (devnum.equalsIgnoreCase("all")) {
  8725. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : airconTestMode : " + airconTestMode + " nCount : " + nCount );
  8726. if (airconTestMode == false && ret < 0) {
  8727. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8728. return retStr;
  8729. } else {
  8730. for (int i = 0; i < nCount; i++) {
  8731. String sOnOff = "off";
  8732. if( airconTestMode == true )
  8733. {
  8734. if( airconTestModeOnOff[i] == true )sOnOff = "on";
  8735. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8736. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8737. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8738. }
  8739. else {
  8740. if (airconAPI.data.Device.Aircon[i].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8741. sOnOff = "on";
  8742. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8743. 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";
  8744. }
  8745. }
  8746. }
  8747. }
  8748. else
  8749. {
  8750. // 개별 상태 조회
  8751. if (airconTestMode == false && ret < 0) {
  8752. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8753. return retStr;
  8754. } else {
  8755. int reqDevNum = Integer.parseInt(devnum);
  8756. String sOnOff = "off";
  8757. if( airconTestMode == true )
  8758. {
  8759. if( airconTestModeOnOff[reqDevNum-1] == true )sOnOff = "on";
  8760. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8761. //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8762. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8763. }
  8764. else {
  8765. if (airconAPI.data.Device.Aircon[reqDevNum-1].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
  8766. sOnOff = "on";
  8767. strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
  8768. 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";
  8769. }
  8770. }
  8771. }
  8772. }
  8773. else if (actionTXT.equalsIgnoreCase("control")) {
  8774. // 에어컨 제어
  8775. String[] CtrList;
  8776. CtrList = ctraction.split("/");
  8777. for( int k = 0 ; k < CtrList.length; k++)
  8778. {
  8779. Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : CtrList[k] : " + k + " CtrList[k] : " + CtrList[k]);
  8780. }
  8781. strResultStatus = "";
  8782. int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8783. if (devnum.equalsIgnoreCase("all")) {
  8784. // 일괄제어는 Off 밖에 없음
  8785. if( airconTestMode == true )
  8786. {
  8787. for (int i = 0; i < nCount; i++) {
  8788. String sOnOff = "off";
  8789. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8790. if(CtrList[0].equalsIgnoreCase("off"))
  8791. {
  8792. airconTestModeOnOff[i] = false;
  8793. }
  8794. else
  8795. {
  8796. airconTestModeOnOff[i] = true;
  8797. sOnOff = "on";
  8798. }
  8799. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8800. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8801. }
  8802. }
  8803. else
  8804. {
  8805. for (int i = 0; i < nCount; i++) {
  8806. String sOnOff = "off";
  8807. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8808. byte hOnOff = 0x00;
  8809. if(CtrList[0].equalsIgnoreCase("off"))
  8810. {
  8811. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8812. sOnOff = "off";
  8813. }
  8814. else
  8815. {
  8816. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8817. sOnOff = "on";
  8818. }
  8819. double setTemp = airconAPI.data.Device.Aircon[i].SetTemp;
  8820. byte volume = airconAPI.data.Device.Aircon[i].Volume;
  8821. byte mode = airconAPI.data.Device.Aircon[i].Mode;
  8822. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8823. ret = airconAPI.SetEachRoomStatus((byte)i, hMode, setTemp);
  8824. strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
  8825. 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";
  8826. }
  8827. }
  8828. }
  8829. else
  8830. {
  8831. // 개별 제어
  8832. int nDevNum = Integer.parseInt(devnum);
  8833. if( airconTestMode == true )
  8834. {
  8835. String sOnOff = "off";
  8836. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8837. if(CtrList[0].equalsIgnoreCase("off"))
  8838. {
  8839. airconTestModeOnOff[nDevNum-1] = false;
  8840. }
  8841. else
  8842. {
  8843. airconTestModeOnOff[nDevNum-1] = true;
  8844. sOnOff = "on";
  8845. }
  8846. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8847. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
  8848. }
  8849. else
  8850. {
  8851. String sOnOff = "off";
  8852. //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
  8853. byte hOnOff = 0x00;
  8854. if(CtrList[0].equalsIgnoreCase("off"))
  8855. {
  8856. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
  8857. sOnOff = "off";
  8858. }
  8859. else
  8860. {
  8861. hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
  8862. sOnOff = "on";
  8863. }
  8864. //String [] aMode = {"auto","cool","dehum","blow","heat"};
  8865. byte mode = 0x00;
  8866. if(CtrList[1].equalsIgnoreCase("auto"))
  8867. mode = DataClasses.KnxSystemAircon.MODE.Auto;
  8868. else if(CtrList[1].equalsIgnoreCase("cool"))
  8869. mode = DataClasses.KnxSystemAircon.MODE.Cold;
  8870. else if(CtrList[1].equalsIgnoreCase("dehum"))
  8871. mode = DataClasses.KnxSystemAircon.MODE.Dry;
  8872. else if(CtrList[1].equalsIgnoreCase("blow"))
  8873. mode = DataClasses.KnxSystemAircon.MODE.Venti;
  8874. else if(CtrList[1].equalsIgnoreCase("heat"))
  8875. mode = DataClasses.KnxSystemAircon.MODE.Heat;
  8876. else
  8877. mode = airconAPI.data.Device.Aircon[nDevNum-1].Mode;
  8878. byte volume = 0x00;
  8879. if(CtrList[2].equalsIgnoreCase(mTextWindType[0]))
  8880. volume = DataClasses.KnxSystemAircon.VOLUME.Auto;
  8881. else if(CtrList[2].equalsIgnoreCase(mTextWindType[1]))
  8882. volume = DataClasses.KnxSystemAircon.VOLUME.Weak;
  8883. else if(CtrList[2].equalsIgnoreCase(mTextWindType[2]))
  8884. volume = DataClasses.KnxSystemAircon.VOLUME.Medium;
  8885. else if(CtrList[2].equalsIgnoreCase(mTextWindType[3]))
  8886. volume = DataClasses.KnxSystemAircon.VOLUME.Strong;
  8887. else
  8888. volume = airconAPI.data.Device.Aircon[nDevNum-1].Volume;
  8889. double setTemp = 0;
  8890. if( CtrList[3].equalsIgnoreCase("null"))
  8891. setTemp = airconAPI.data.Device.Aircon[nDevNum-1].SetTemp;
  8892. else
  8893. setTemp = Double.parseDouble(CtrList[3]);
  8894. int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
  8895. ret = airconAPI.SetEachRoomStatus((byte)(nDevNum-1), hMode, setTemp);
  8896. if( ret >= 0 ) {
  8897. ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
  8898. }
  8899. double curTemp = airconAPI.data.Device.Aircon[nDevNum-1].NowTemp;
  8900. strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
  8901. strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume] + "/" + setTemp + "/" + curTemp + "\"/>\r\n";
  8902. }
  8903. }
  8904. }
  8905. else {
  8906. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8907. return retStr;
  8908. }
  8909. retStr += "\"ok\" >\r\n";
  8910. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  8911. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  8912. retStr += strResultStatus;
  8913. retStr += " </service>\r\n";
  8914. retStr += "</imap> ";
  8915. return retStr;
  8916. } catch (Exception e) {
  8917. Log.e(TAG, "[Exception] iCMDProcSysairconControl(Document ele)");
  8918. e.printStackTrace();
  8919. return null;
  8920. }
  8921. }
  8922. private String iCMDProcEntireLightControl(Document ele) {
  8923. try {
  8924. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  8925. if (retStr != null) return retStr;
  8926. else
  8927. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  8928. String sDong = null;
  8929. String sHo = null;
  8930. String sDevice_Num = null;
  8931. String sSelCtrl_Action = null;
  8932. String sUnselCtrl_Action = null;
  8933. NodeList items = ele.getElementsByTagName("home_info");
  8934. Node item = items.item(0);
  8935. NamedNodeMap attrsParam = item.getAttributes();
  8936. for (int i = 0; i < attrsParam.getLength(); i++) {
  8937. Node attr = attrsParam.item(i);
  8938. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8939. sDong = trimquotation(attr.getNodeValue());
  8940. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8941. sHo = trimquotation(attr.getNodeValue());
  8942. }
  8943. WallpadStatusData DBMGR = null;
  8944. DBMGR = new WallpadStatusData(getApplicationContext());
  8945. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8946. DBMGR.closeDB();
  8947. if (mSdb_LivingRoomLightAPI == null) {
  8948. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  8949. retStr += " result=\"fail\" >\r\n";
  8950. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8951. retStr += " </service>\r\n</imap>";
  8952. return retStr;
  8953. }
  8954. if (mSdbAPI == null) {
  8955. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  8956. retStr += " result=\"fail\" >\r\n";
  8957. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8958. retStr += " </service>\r\n</imap>";
  8959. return retStr;
  8960. }
  8961. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
  8962. items = ele.getElementsByTagName("sel_ctrlinfo");
  8963. item = items.item(0);
  8964. attrsParam = item.getAttributes();
  8965. for (int i = 0; i < attrsParam.getLength(); i++) {
  8966. Node attr = attrsParam.item(i);
  8967. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8968. sDevice_Num = trimquotation(attr.getNodeValue());
  8969. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8970. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  8971. }
  8972. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  8973. int result = -1; // 조명 제어 결과
  8974. boolean bLivingLightSel = false; // 거실조명 선택 여부
  8975. // ============================== 선택된 조명 ==============================
  8976. String[] sel_devNum = null;
  8977. if (sDevice_Num != null && sDevice_Num.contains("light")) {
  8978. if (sDevice_Num.contains("/"))
  8979. sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  8980. else {
  8981. sel_devNum = new String[1];
  8982. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  8983. }
  8984. }
  8985. if (sel_devNum == null) sel_devNum = new String[0];
  8986. for (int i = 0; i < sel_devNum.length; i++) {
  8987. if (sel_devNum[i].equals("1")) {
  8988. bLivingLightSel = true;
  8989. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  8990. if (sSelCtrl_Action != null) {
  8991. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8992. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8993. } else {
  8994. int nColor = 0;
  8995. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8996. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8997. if (nColor > 0) {
  8998. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8999. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  9000. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  9001. }
  9002. }
  9003. // 거실조명 제어 결과
  9004. if (result < 0) {
  9005. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  9006. retStr += " result=\"fail\" >\r\n";
  9007. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9008. retStr += " </service>\r\n</imap>";
  9009. return retStr;
  9010. }
  9011. }
  9012. } else {
  9013. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  9014. if (sSelCtrl_Action != null) {
  9015. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  9016. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  9017. } else {
  9018. int nColor = 0;
  9019. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  9020. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  9021. if (nColor > 0) {
  9022. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  9023. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  9024. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  9025. }
  9026. }
  9027. }
  9028. // 그 외 방 조명 제어 결과
  9029. if (result < 0) {
  9030. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  9031. retStr += " result=\"fail\" >\r\n";
  9032. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9033. retStr += " </service>\r\n</imap>";
  9034. return retStr;
  9035. }
  9036. }
  9037. }
  9038. // ============================== 선택안된 조명 ==============================
  9039. items = ele.getElementsByTagName("unsel_ctrlinfo");
  9040. item = items.item(0);
  9041. attrsParam = item.getAttributes();
  9042. for (int i = 0; i < attrsParam.getLength(); i++) {
  9043. Node attr = attrsParam.item(i);
  9044. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  9045. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  9046. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  9047. }
  9048. if (!bLivingLightSel) {
  9049. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  9050. if (sUnselCtrl_Action != null) {
  9051. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  9052. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  9053. } else {
  9054. int nColor = 0;
  9055. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  9056. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  9057. if (nColor > 0) {
  9058. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  9059. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  9060. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  9061. }
  9062. }
  9063. }
  9064. if (result < 0) {
  9065. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  9066. retStr += " result=\"fail\" >\r\n";
  9067. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9068. retStr += " </service>\r\n</imap>";
  9069. return retStr;
  9070. }
  9071. }
  9072. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  9073. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  9074. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  9075. unsel_devNum.add(i + 1);
  9076. }
  9077. for (int i = 0; i < unsel_devNum.size(); i++) {
  9078. for (int j = 0; j < sel_devNum.length; j++) {
  9079. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
  9080. unsel_devNum.remove(i);
  9081. }
  9082. }
  9083. for (int i = 0; i < unsel_devNum.size(); i++) {
  9084. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
  9085. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  9086. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  9087. } else {
  9088. int nColor = 0;
  9089. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  9090. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  9091. if (nColor > 0) {
  9092. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  9093. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  9094. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  9095. }
  9096. }
  9097. if (result < 0) {
  9098. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  9099. retStr += " result=\"fail\" >\r\n";
  9100. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9101. retStr += " </service>\r\n</imap>";
  9102. return retStr;
  9103. }
  9104. }
  9105. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  9106. retStr += " result=\"ok\">\r\n";
  9107. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9108. retStr += " </service>\r\n</imap>";
  9109. return retStr;
  9110. } else {
  9111. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  9112. retStr += " result=\"fail\" >\r\n";
  9113. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  9114. retStr += " </service>\r\n</imap>";
  9115. return retStr;
  9116. }
  9117. } catch (RuntimeException re) {
  9118. LogUtil.errorLogInfo("", TAG, re);
  9119. return null;
  9120. } catch (Exception e) {
  9121. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  9122. //e.printStackTrace();
  9123. LogUtil.errorLogInfo("", TAG, e);
  9124. return null;
  9125. }
  9126. }
  9127. // 월패드에 원격제어 사용 여부를 확인하다.
  9128. private String CheckiCMDProc(String CMDStr) {
  9129. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  9130. try {
  9131. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  9132. mWallpadStatusData.closeDB();
  9133. if (!bRemoteCtrlEnabled) {
  9134. String retXML = XMLHeader + "<service type=\"reply\" name=\"" + CMDStr + "\" result=\"deny\">\r\n" +
  9135. " </service>\r\n</imap>";
  9136. return retXML;
  9137. }
  9138. return null;
  9139. } catch (RuntimeException re) {
  9140. LogUtil.errorLogInfo("", TAG, re);
  9141. mWallpadStatusData.closeDB();
  9142. return null;
  9143. } catch (Exception e) {
  9144. mWallpadStatusData.closeDB();
  9145. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  9146. //e.printStackTrace();
  9147. LogUtil.errorLogInfo("", TAG, e);
  9148. return null;
  9149. }
  9150. }
  9151. //메인으로 공지 해야 할 노티 사항을 처리
  9152. public String ProcEventNotify(Element ele) {
  9153. try {
  9154. NodeList items = ele.getElementsByTagName("event");
  9155. Node item = items.item(0);
  9156. Node text = item.getFirstChild();
  9157. String eventTXT = trimquotation(text.getNodeValue());
  9158. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  9159. // 새로운 공지사항 존재
  9160. wakeupLCD();
  9161. Intent intent = new Intent();
  9162. intent.setAction(define.NOTIFY_ACNAME);
  9163. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9164. getApplicationContext().sendBroadcast(intent);
  9165. } else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  9166. // 택배 도착
  9167. wakeupLCD();
  9168. Intent intent = new Intent();
  9169. intent.setAction(define.NOTIFY_ACNAME);
  9170. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9171. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  9172. intent.putExtra("REMAIN_CNT", 1);
  9173. getApplicationContext().sendBroadcast(intent);
  9174. } else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  9175. // 택배 반출
  9176. wakeupLCD();
  9177. Intent intent = new Intent();
  9178. intent.setAction(define.NOTIFY_ACNAME);
  9179. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  9180. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  9181. intent.putExtra("REMAIN_CNT", 0);
  9182. getApplicationContext().sendBroadcast(intent);
  9183. } else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  9184. // 등록된 차량 도착
  9185. wakeupLCD();
  9186. // 팝업을 띄우도록 하자
  9187. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9188. Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
  9189. } else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  9190. // 내려가는 방향의 엘리베이터가 도착함
  9191. if (ElevatorDown != null) {
  9192. ElevatorDown.TimeOutCancel();
  9193. ElevatorDown.ClearElevator();
  9194. }
  9195. Intent intent = new Intent();
  9196. intent.setAction(define.NOTIFY_ACNAME);
  9197. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  9198. getApplicationContext().sendBroadcast(intent);
  9199. } else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  9200. // 올라가는 방향의 엘리베이터가 도착함
  9201. if (ElevatorUp != null) {
  9202. ElevatorUp.TimeOutCancel();
  9203. ElevatorUp.ClearElevator();
  9204. }
  9205. Intent intent = new Intent();
  9206. intent.setAction(define.NOTIFY_ACNAME);
  9207. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  9208. getApplicationContext().sendBroadcast(intent);
  9209. } else {
  9210. }
  9211. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  9212. "<event> \"" + eventTXT + "\" </event>\r\n" + " </service>\r\n </imap> ";
  9213. return returnStr;
  9214. } catch (RuntimeException re) {
  9215. LogUtil.errorLogInfo("", TAG, re);
  9216. return null;
  9217. } catch (Exception e) {
  9218. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  9219. //e.printStackTrace();
  9220. LogUtil.errorLogInfo("", TAG, e);
  9221. return null;
  9222. }
  9223. }
  9224. public String GetAttributeVal(Node node, String attname) {
  9225. NamedNodeMap attrs = node.getAttributes();
  9226. for (int j = 0; j < attrs.getLength(); j++) {
  9227. Node attr = attrs.item(j);
  9228. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  9229. }
  9230. return null;
  9231. }
  9232. public class imageFileFilter implements FilenameFilter {
  9233. public boolean accept(File dir, String name) {
  9234. 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"))
  9235. return true;
  9236. else return false;
  9237. }
  9238. }
  9239. public String ProcCheckEpiceUpload(Document ele) {
  9240. try {
  9241. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  9242. NodeList items = ele.getElementsByTagName("filename");
  9243. Node item = items.item(0);
  9244. Node text = item.getFirstChild();
  9245. String filename = trimquotation(text.getNodeValue());
  9246. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  9247. String duplicate = null;
  9248. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  9249. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  9250. if (!dirInternal.exists()) dirInternal.mkdir();
  9251. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9252. AddressSet addr = SetData.getAddressMGR();
  9253. if (!dirInternal.exists()) {
  9254. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9255. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + define.MAX_ALBUM_PICTURE + "\" available=\"0\" duplicate=\"new\"/>\r\n" +
  9256. " </service>\r\n</imap>";
  9257. return returnStr;
  9258. }
  9259. imageFileFilter jpegfilter = new imageFileFilter();
  9260. String[] subfile = dirInternal.list(jpegfilter);
  9261. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  9262. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  9263. if (checkFile.exists()) duplicate = "exist";
  9264. else duplicate = "new";
  9265. if (subfile != null) {
  9266. returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
  9267. " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + subfile.length + "\" available=\"" + (define.MAX_ALBUM_PICTURE - subfile.length) + "\" duplicate=\"" + duplicate + "\"/>\r\n" +
  9268. " </service>\r\n</imap>";
  9269. }
  9270. SetData.closeDB();
  9271. return returnStr;
  9272. } catch (RuntimeException re) {
  9273. LogUtil.errorLogInfo("", TAG, re);
  9274. return null;
  9275. } catch (Exception e) {
  9276. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  9277. //e.printStackTrace();
  9278. LogUtil.errorLogInfo("", TAG, e);
  9279. return null;
  9280. }
  9281. }
  9282. private void playNotifySound(int nSoundID) {
  9283. try {
  9284. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9285. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9286. if (getCompareBSPVersion()) {
  9287. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  9288. } else {
  9289. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9290. }
  9291. boolean NeedPlay = false;
  9292. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  9293. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  9294. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  9295. } else {
  9296. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  9297. }
  9298. SetData.closeDB();
  9299. if (NeedPlay) Sound().PlayMent(nSoundID);
  9300. } catch (RuntimeException re) {
  9301. LogUtil.errorLogInfo("", TAG, re);
  9302. } catch (Exception e) {
  9303. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  9304. //e.printStackTrace();
  9305. LogUtil.errorLogInfo("", TAG, e);
  9306. }
  9307. }
  9308. private void wakeupLCD() {
  9309. try {
  9310. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9311. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  9312. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  9313. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  9314. int AlarmStatus = WsDB.GetAlarmStatus();
  9315. WsDB.closeDB();
  9316. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  9317. Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
  9318. return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
  9319. } else {
  9320. Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
  9321. mIOInterface.ctrlLcdWakeUp();
  9322. }
  9323. } catch (RuntimeException re) {
  9324. LogUtil.errorLogInfo("", TAG, re);
  9325. } catch (Exception e) {
  9326. Log.e(TAG, "[Exception] wakeupLCD()");
  9327. //e.printStackTrace();
  9328. LogUtil.errorLogInfo("", TAG, e);
  9329. }
  9330. }
  9331. /**
  9332. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  9333. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  9334. * Jeff, 2020.09.07
  9335. *
  9336. * @return true: LCD backlight On, false: LCD backlight Off
  9337. */
  9338. public boolean checkLCDOnByCMD() {
  9339. try {
  9340. Runtime mRuntime = Runtime.getRuntime();
  9341. Process mProcess;
  9342. String cmd = "getprop persist.sys.lcdcon";
  9343. mProcess = mRuntime.exec(cmd);
  9344. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  9345. String line;
  9346. String strResult = null;
  9347. while ((line = br.readLine()) != null) {
  9348. strResult = line;
  9349. }
  9350. if (strResult != null) {
  9351. if (strResult.equals("0")) {
  9352. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  9353. return true;
  9354. } else if (strResult.equals("1")) {
  9355. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  9356. return false;
  9357. } else {
  9358. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  9359. return false;
  9360. }
  9361. } else
  9362. return false;
  9363. } catch (RuntimeException re) {
  9364. LogUtil.errorLogInfo("", TAG, re);
  9365. return false;
  9366. } catch (Exception e) {
  9367. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  9368. //e.printStackTrace();
  9369. LogUtil.errorLogInfo("", TAG, e);
  9370. return false;
  9371. }
  9372. }
  9373. /**
  9374. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  9375. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  9376. *
  9377. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  9378. */
  9379. public boolean getCompareBSPVersion() {
  9380. try {
  9381. StringBuilder strBSPVersion = new StringBuilder();
  9382. StringBuffer sysInfoBuffer = new StringBuffer();
  9383. sysInfoBuffer.append(Build.DISPLAY);
  9384. strBSPVersion.append(sysInfoBuffer.toString());
  9385. String result = strBSPVersion.toString();
  9386. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  9387. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  9388. Date date = simpleDateFormat.parse(result);
  9389. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  9390. if (date.compareTo(standardDate) >= 0) {
  9391. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  9392. return true;
  9393. }
  9394. } catch (RuntimeException re) {
  9395. LogUtil.errorLogInfo("", TAG, re);
  9396. } catch (Exception e) {
  9397. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  9398. //e.printStackTrace();
  9399. LogUtil.errorLogInfo("", TAG, e);
  9400. }
  9401. return false;
  9402. }
  9403. public String ProcUpdateWeather(Document ele) {
  9404. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  9405. String nowloc = "";
  9406. String nowlcode = "";
  9407. String nowdate = "";
  9408. String nowtext = "";
  9409. String nowcode = "";
  9410. String nowtemp = "";
  9411. String nowlo = "", nowhigh = "";
  9412. NodeList items = ele.getElementsByTagName("now");
  9413. Node item = items.item(0);
  9414. if (item == null)
  9415. return resultstr += "\"fail\"/> \r\n </imap>";
  9416. NamedNodeMap attrsParam = item.getAttributes();
  9417. for (int j = 0; j < attrsParam.getLength(); j++) {
  9418. Node attr = attrsParam.item(j);
  9419. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  9420. else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
  9421. nowlcode = attr.getNodeValue();
  9422. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  9423. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  9424. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  9425. else if (attr.getNodeName().equalsIgnoreCase("temperature"))
  9426. nowtemp = attr.getNodeValue();
  9427. }
  9428. items = ele.getElementsByTagName("week");
  9429. String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
  9430. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9431. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  9432. Weathertbl.InitWeatherTable();
  9433. for (int i = 0; i < items.getLength(); i++) {
  9434. item = items.item(i);
  9435. attrsParam = item.getAttributes();
  9436. for (int j = 0; j < attrsParam.getLength(); j++) {
  9437. Node attr = attrsParam.item(j);
  9438. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  9439. else if (attr.getNodeName().equalsIgnoreCase("text"))
  9440. weektext = attr.getNodeValue();
  9441. else if (attr.getNodeName().equalsIgnoreCase("code"))
  9442. weekcode = attr.getNodeValue();
  9443. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  9444. else if (attr.getNodeName().equalsIgnoreCase("high"))
  9445. weekhigh = attr.getNodeValue();
  9446. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  9447. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  9448. }
  9449. if (i == 0) {
  9450. nowlo = weeklow;
  9451. nowhigh = weekhigh;
  9452. }
  9453. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  9454. }
  9455. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  9456. Intent intent = new Intent();
  9457. intent.setAction(define.NOTIFY_ACNAME);
  9458. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  9459. intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
  9460. getApplicationContext().sendBroadcast(intent);
  9461. String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
  9462. 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);
  9463. //air
  9464. items = ele.getElementsByTagName("air");
  9465. String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
  9466. item = items.item(0);
  9467. if (item != null) {
  9468. attrsParam = item.getAttributes();
  9469. for (int j = 0; j < attrsParam.getLength(); j++) {
  9470. Node attr = attrsParam.item(j);
  9471. if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
  9472. else if (attr.getNodeName().equalsIgnoreCase("pm25"))
  9473. airpm25 = attr.getNodeValue();
  9474. else if (attr.getNodeName().equalsIgnoreCase("co2"))
  9475. airco2 = attr.getNodeValue();
  9476. else if (attr.getNodeName().equalsIgnoreCase("ozone"))
  9477. airozone = attr.getNodeValue();
  9478. else if (attr.getNodeName().equalsIgnoreCase("air_index"))
  9479. air_index = attr.getNodeValue();
  9480. }
  9481. Intent intentAir = new Intent();
  9482. intentAir.setAction(define.NOTIFY_ACNAME);
  9483. intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
  9484. getApplicationContext().sendBroadcast(intentAir);
  9485. DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
  9486. }
  9487. DBMGR.closeDB();
  9488. return resultstr += "\"ok\"/> \r\n </imap>";
  9489. }
  9490. //iMAP update_news 처리
  9491. public String ProcUpdateNews(Document ele) {
  9492. NodeList items = ele.getElementsByTagName("ver_news");
  9493. Node item = items.item(0);
  9494. String strNewsVer = item.getTextContent();
  9495. strNewsVer = trimquotation(strNewsVer);
  9496. String retXML = XMLHeader + "<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n" +
  9497. " <ver_news>\"" + strNewsVer + "\"</ver_news>\r\n<service/>\r\n</imap>";
  9498. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9499. String NotiVer = DBMGR.GetNoticeVer();
  9500. int noticeCNT = DBMGR.GetNoticeCNT();
  9501. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  9502. String[] spdt = strNewsVer.split("[.]");
  9503. noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
  9504. } else {
  9505. String[] spdt = strNewsVer.split("[.]");
  9506. int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
  9507. spdt = NotiVer.split("[.]");
  9508. newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
  9509. noticeCNT += newcnt;
  9510. }
  9511. Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
  9512. DBMGR.SetNoticeVer(strNewsVer);
  9513. DBMGR.SetNoticeCNT(noticeCNT);
  9514. DBMGR.closeDB();
  9515. if (NotiVer.compareTo(strNewsVer) != 0) {
  9516. Intent intent = new Intent();
  9517. intent.setAction(define.NOTIFY_ACNAME);
  9518. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  9519. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  9520. getApplicationContext().sendBroadcast(intent);
  9521. }
  9522. return retXML;
  9523. }
  9524. //iMAP check_lobby_passwd 처리
  9525. public String CheckPassword(Document doc) {
  9526. NodeList items = doc.getElementsByTagName("inpasswd");
  9527. Node item = items.item(0);
  9528. Node text = item.getFirstChild();
  9529. String passwd = trimquotation(text.getNodeValue());
  9530. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  9531. String settedpasswd = DBMGR.GetUserPW();
  9532. DBMGR.closeDB();
  9533. String retString = XMLHeader;
  9534. Common.DebugLog("================ CheckPassword ================ ");
  9535. Common.DebugLog("Saved Password :" + settedpasswd);
  9536. Common.DebugLog("Input Password :" + passwd);
  9537. Common.DebugLog("================ CheckPassword ================ ");
  9538. if (settedpasswd.equals(passwd)) {
  9539. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  9540. } else {
  9541. retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>" + passwd + "</wrongpasswd>\r\n</service>";
  9542. }
  9543. retString += "</imap>";
  9544. return retString;
  9545. }
  9546. //schedule_renew 처리
  9547. protected String ProcSchduleRenew(Document doc) {
  9548. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n " +
  9549. "<homeaddr dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" /> \r\n </service> \r\n </imap>";
  9550. WallpadScheduleData schedulDB = null;
  9551. try {
  9552. NodeList items = doc.getElementsByTagName("renew_info");
  9553. schedulDB = new WallpadScheduleData(getApplicationContext());
  9554. for (int i = 0; i < items.getLength(); i++) {
  9555. Node item = items.item(i);
  9556. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  9557. NamedNodeMap attrsParam = item.getAttributes();
  9558. String Type = "none";
  9559. for (int j = 0; j < attrsParam.getLength(); j++) {
  9560. Node attr = attrsParam.item(j);
  9561. String name = attr.getNodeName();
  9562. String Val = attr.getNodeValue();
  9563. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  9564. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  9565. else if (name.equalsIgnoreCase("rn_type"))
  9566. Type = Val;
  9567. else if (name.equalsIgnoreCase("rn_t_type"))
  9568. SCdata.inqttype = Val;
  9569. else if (name.equalsIgnoreCase("rn_c_type"))
  9570. SCdata.inqctype = Val;
  9571. else if (name.equalsIgnoreCase("rn_a_type"))
  9572. SCdata.inqatype = Val;
  9573. else if (name.equalsIgnoreCase("rn_i_type"))
  9574. SCdata.inqitype = Val;
  9575. else if (name.equalsIgnoreCase("rn_year"))
  9576. SCdata.inqyear = Integer.parseInt(Val);
  9577. else if (name.equalsIgnoreCase("rn_month"))
  9578. SCdata.inqmonth = Integer.parseInt(Val);
  9579. else if (name.equalsIgnoreCase("rn_day"))
  9580. SCdata.inqday = Integer.parseInt(Val);
  9581. else if (name.equalsIgnoreCase("rn_hour"))
  9582. SCdata.inqhour = Integer.parseInt(Val);
  9583. else if (name.equalsIgnoreCase("rn_message"))
  9584. SCdata.inqmsg = Val;
  9585. }
  9586. if (Type.equals("delete")) {
  9587. schedulDB.DeleteSchedule(SCdata);
  9588. } else if (Type.equals("add")) {
  9589. schedulDB.AddSchedule(SCdata);
  9590. } else if (Type.equals("change")) {
  9591. schedulDB.UpdateSchedule(SCdata);
  9592. }
  9593. }
  9594. schedulDB.closeDB();
  9595. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  9596. // Intent intent = new Intent();
  9597. // intent.setAction(define.NOTIFY_ACNAME);
  9598. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9599. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  9600. // getApplicationContext().sendBroadcast(intent);
  9601. } catch (RuntimeException re) {
  9602. LogUtil.errorLogInfo("", TAG, re);
  9603. if (schedulDB != null) schedulDB.closeDB();
  9604. } catch (Exception e) {
  9605. //e.printStackTrace();
  9606. LogUtil.errorLogInfo("", TAG, e);
  9607. if (schedulDB != null) schedulDB.closeDB();
  9608. }
  9609. return retXML;
  9610. }
  9611. //schedule_inquiry 처리
  9612. @SuppressWarnings("unused")
  9613. public String ProcSchduleInquiry(Document doc) {
  9614. WallpadScheduleData schedulDB = null;
  9615. String retXML;
  9616. int QYear = 0;
  9617. int QMonth = 0;
  9618. try {
  9619. NodeList items = doc.getElementsByTagName("inquiry_time");
  9620. schedulDB = new WallpadScheduleData(getApplicationContext());
  9621. Node item = items.item(0);
  9622. NamedNodeMap attrsParam = item.getAttributes();
  9623. for (int j = 0; j < attrsParam.getLength(); j++) {
  9624. Node attr = attrsParam.item(j);
  9625. if (attr.getNodeName().equalsIgnoreCase("year"))
  9626. QYear = Integer.parseInt(attr.getNodeValue());
  9627. else if (attr.getNodeName().equalsIgnoreCase("month"))
  9628. QMonth = Integer.parseInt(attr.getNodeValue());
  9629. }
  9630. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  9631. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9632. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9633. " <inquiry_time year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9634. " <inquiry_count>" + SCData.size() + "</inquiry_count>\r\n";
  9635. if (SCData != null) {
  9636. if (SCData.size() > 0) {
  9637. for (int i = 0; i < SCData.size(); i++) {
  9638. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  9639. 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=\"" +
  9640. SCINQDATA.inqyear + "\" inq_month=\"" + SCINQDATA.inqmonth + "\" inq_day=\"" + SCINQDATA.inqday + "\" inq_hour=\"" + SCINQDATA.inqhour + "\" inq_message=\"" + SCINQDATA.inqmsg + "\"/>\r\n";
  9641. }
  9642. }
  9643. retXML += "</service>\r\n</imap>";
  9644. } else {
  9645. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9646. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9647. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9648. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9649. }
  9650. } catch (RuntimeException re) {
  9651. LogUtil.errorLogInfo("", TAG, re);
  9652. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9653. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9654. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9655. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9656. } catch (Exception e) {
  9657. //e.printStackTrace();
  9658. LogUtil.errorLogInfo("", TAG, e);
  9659. retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
  9660. " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
  9661. " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
  9662. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9663. }
  9664. schedulDB.closeDB();
  9665. return retXML;
  9666. }
  9667. public String ProcUpdateSchedule(Element ele, String type) {
  9668. String retXML = "";
  9669. return retXML;
  9670. }
  9671. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  9672. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  9673. private void setDefaultLauncher() {
  9674. try {
  9675. PackageManager pm = getPackageManager();
  9676. IntentFilter filter = new IntentFilter();
  9677. filter.addAction(Intent.ACTION_MAIN);
  9678. filter.addCategory(Intent.CATEGORY_HOME);
  9679. filter.addCategory(Intent.CATEGORY_DEFAULT);
  9680. Context context = getApplicationContext();
  9681. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  9682. ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  9683. pm.clearPackagePreferredActivities("com.android.launcher");
  9684. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  9685. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  9686. try {
  9687. Thread.sleep(300);
  9688. } catch (RuntimeException re) {
  9689. LogUtil.errorLogInfo("", TAG, re);
  9690. } catch (Exception e) {
  9691. LogUtil.errorLogInfo("", TAG, e);
  9692. }
  9693. // 리셋코드 추가
  9694. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  9695. try {
  9696. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9697. powerMg.reboot(null);
  9698. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  9699. } catch (RuntimeException re) {
  9700. LogUtil.errorLogInfo("", TAG, re);
  9701. } catch (Exception e) {
  9702. //e.printStackTrace();
  9703. LogUtil.errorLogInfo("", TAG, e);
  9704. }
  9705. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  9706. } catch (RuntimeException re) {
  9707. LogUtil.errorLogInfo("", TAG, re);
  9708. } catch (Exception e) {
  9709. //e.printStackTrace();
  9710. LogUtil.errorLogInfo("", TAG, e);
  9711. }
  9712. }
  9713. public String ProcDeviceReset(Element ele) {
  9714. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  9715. "</imap>\r\n";
  9716. NodeList resettype = ele.getElementsByTagName("guidemap");
  9717. Node resettypeItem = resettype.item(0);
  9718. String type = GetAttributeVal(resettypeItem, "type");
  9719. if (type != null) {
  9720. if (type.equals("now")) {
  9721. setDefaultLauncher();
  9722. Intent intent = new Intent();
  9723. intent.setAction(define.NOTIFY_ACNAME);
  9724. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  9725. getApplicationContext().sendBroadcast(intent);
  9726. } else if (type.equals("disable")) {
  9727. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9728. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
  9729. SetReset.closeDB();
  9730. } else if (type.equals("week") || type.equals("month")) {
  9731. int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
  9732. NodeList periodList = ele.getElementsByTagName("period");
  9733. Node perioditem = periodList.item(0);
  9734. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  9735. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  9736. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9737. SetReset.SetResetSchedule(Resettype, cycle, time);
  9738. SetReset.closeDB();
  9739. }
  9740. }
  9741. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  9742. // Intent intent = new Intent();
  9743. // intent.setAction(define.NOTIFY_ACNAME);
  9744. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9745. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  9746. // getApplicationContext().sendBroadcast(intent);
  9747. return retXML;
  9748. }
  9749. public String ProcDeviceLiveCheck() {
  9750. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  9751. return retXML;
  9752. }
  9753. public String ProcPairingHdevSyncAlarm(Element ele) {
  9754. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  9755. return retXML;
  9756. }
  9757. public String ProcPairingHdevSyncSecurity(Element ele) {
  9758. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  9759. return retXML;
  9760. }
  9761. public String ProcParkInformation(Element ele) {
  9762. try {
  9763. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  9764. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  9765. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  9766. NodeList items = ele.getElementsByTagName("destination");
  9767. Node item = items.item(0);
  9768. Node text;
  9769. NamedNodeMap attrsParam = item.getAttributes();
  9770. for (int j = 0; j < attrsParam.getLength(); j++) {
  9771. Node attr = attrsParam.item(j);
  9772. if (attr.getNodeName().equalsIgnoreCase("name"))
  9773. strName = trimquotation(attr.getNodeValue());
  9774. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9775. strDong = trimquotation(attr.getNodeValue());
  9776. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9777. strHo = trimquotation(attr.getNodeValue());
  9778. }
  9779. items = ele.getElementsByTagName("move_info");
  9780. item = items.item(0);
  9781. text = item.getFirstChild();
  9782. strCarMove = trimquotation(text.getNodeValue());
  9783. items = ele.getElementsByTagName("params");
  9784. item = items.item(0);
  9785. attrsParam = item.getAttributes();
  9786. for (int j = 0; j < attrsParam.getLength(); j++) {
  9787. Node attr = attrsParam.item(j);
  9788. if (attr.getNodeName().equalsIgnoreCase("car_num"))
  9789. strCarNo = trimquotation(attr.getNodeValue());
  9790. else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
  9791. strCarLocation = trimquotation(attr.getNodeValue());
  9792. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9793. strMsg = trimquotation(attr.getNodeValue());
  9794. }
  9795. if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
  9796. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  9797. try {
  9798. int iTempDong = Integer.parseInt(AddrDong);
  9799. String sTempDong = Integer.toString(iTempDong);
  9800. int iTempHo = Integer.parseInt(AddrHo);
  9801. String sTempHo = Integer.toString(iTempHo);
  9802. if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  9803. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9804. } else {
  9805. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9806. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9807. return retXML;
  9808. }
  9809. } catch (RuntimeException re) {
  9810. LogUtil.errorLogInfo("", TAG, re);
  9811. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9812. return retXML;
  9813. } catch (Exception e) {
  9814. //e.printStackTrace();
  9815. LogUtil.errorLogInfo("", TAG, e);
  9816. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9817. return retXML;
  9818. }
  9819. //DB정보 업데이트!
  9820. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9821. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  9822. CarDB.closeDB();
  9823. //DB정보 업데이트!
  9824. if (strCarMove.equalsIgnoreCase("in")) {
  9825. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9826. // 팝업을 띄우도록 하자
  9827. wakeupLCD();
  9828. if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
  9829. Intent iIntent = new Intent();
  9830. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9831. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9832. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  9833. getApplicationContext().sendBroadcast(iIntent);
  9834. } else {
  9835. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9836. }
  9837. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  9838. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  9839. }
  9840. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  9841. if (strCarMove.equalsIgnoreCase("park")) {
  9842. //주차정보 얻어오도록 intent 알림
  9843. SendGetParkingInfoIntent();
  9844. }
  9845. } else {
  9846. //주차정보 얻어오도록 intent 알림
  9847. SendGetParkingInfoIntent();
  9848. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  9849. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  9850. }
  9851. return retXML;
  9852. } catch (RuntimeException re) {
  9853. LogUtil.errorLogInfo("", TAG, re);
  9854. return null;
  9855. } catch (Exception e) {
  9856. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  9857. //e.printStackTrace();
  9858. LogUtil.errorLogInfo("", TAG, e);
  9859. return null;
  9860. }
  9861. }
  9862. /**
  9863. * 스마트키 이벤트 수신시 처리
  9864. **/
  9865. public String ProcSmartKeyEvent(Element ele) {
  9866. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  9867. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  9868. String strName = null, strDong = null, strHo = null, strCnt = null;
  9869. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  9870. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  9871. NodeList items = ele.getElementsByTagName("destination");
  9872. Node item = items.item(0);
  9873. NamedNodeMap attrsParam = item.getAttributes();
  9874. for (int j = 0; j < attrsParam.getLength(); j++) {
  9875. Node attr = attrsParam.item(j);
  9876. if (attr.getNodeName().equalsIgnoreCase("name"))
  9877. strName = trimquotation(attr.getNodeValue());
  9878. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  9879. strDong = trimquotation(attr.getNodeValue());
  9880. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  9881. strHo = trimquotation(attr.getNodeValue());
  9882. }
  9883. items = ele.getElementsByTagName("event_info");
  9884. item = items.item(0);
  9885. attrsParam = item.getAttributes();
  9886. for (int j = 0; j < attrsParam.getLength(); j++) {
  9887. Node attr = attrsParam.item(j);
  9888. if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
  9889. strCnt = trimquotation(attr.getNodeValue());
  9890. }
  9891. items = ele.getElementsByTagName("event");
  9892. item = items.item(0);
  9893. attrsParam = item.getAttributes();
  9894. for (int j = 0; j < attrsParam.getLength(); j++) {
  9895. Node attr = attrsParam.item(j);
  9896. if (attr.getNodeName().equalsIgnoreCase("event_type"))
  9897. strEventType = trimquotation(attr.getNodeValue());
  9898. else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
  9899. strEventTriggerType = trimquotation(attr.getNodeValue());
  9900. else if (attr.getNodeName().equalsIgnoreCase("uid"))
  9901. strEventUID = trimquotation(attr.getNodeValue());
  9902. else if (attr.getNodeName().equalsIgnoreCase("sn"))
  9903. strEventSN = trimquotation(attr.getNodeValue());
  9904. else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
  9905. strEventSitecode = trimquotation(attr.getNodeValue());
  9906. else if (attr.getNodeName().equalsIgnoreCase("dong"))
  9907. strEventDong = trimquotation(attr.getNodeValue());
  9908. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9909. strEventHo = trimquotation(attr.getNodeValue());
  9910. else if (attr.getNodeName().equalsIgnoreCase("card_num"))
  9911. strEventCardNo = trimquotation(attr.getNodeValue());
  9912. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
  9913. strEventIssueCnt = trimquotation(attr.getNodeValue());
  9914. else if (attr.getNodeName().equalsIgnoreCase("card_type"))
  9915. strEventCardType = trimquotation(attr.getNodeValue());
  9916. else if (attr.getNodeName().equalsIgnoreCase("location"))
  9917. strEventLocation = trimquotation(attr.getNodeValue());
  9918. }
  9919. if (strName != null && strDong != null && strHo != null && strCnt != null)
  9920. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  9921. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  9922. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  9923. if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
  9924. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  9925. } else {
  9926. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  9927. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9928. return retXML;
  9929. }
  9930. //데이터가 null인지 확인
  9931. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  9932. return retXML;
  9933. }
  9934. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  9935. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9936. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9937. wakeupLCD();
  9938. // 팝업을 띄우도록 하자
  9939. String CardNum = "";
  9940. try {
  9941. int iEvent_Dong = Integer.parseInt(strEventDong);
  9942. CardNum += String.format("%04d", iEvent_Dong);
  9943. int iEvent_Ho = Integer.parseInt(strEventHo);
  9944. CardNum += String.format("%04d", iEvent_Ho);
  9945. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  9946. CardNum += String.format("%03d", iEvent_CardNum);
  9947. } catch (RuntimeException re) {
  9948. LogUtil.errorLogInfo("", TAG, re);
  9949. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9950. return retXML;
  9951. } catch (Exception e) {
  9952. //e.printStackTrace();
  9953. LogUtil.errorLogInfo("", TAG, e);
  9954. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9955. return retXML;
  9956. }
  9957. Intent iIntent = new Intent();
  9958. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9959. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  9960. iIntent.putExtra("LOCATION", strEventLocation);
  9961. iIntent.putExtra("CARD_NO", CardNum);
  9962. getApplicationContext().sendBroadcast(iIntent);
  9963. }
  9964. }
  9965. } else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  9966. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9967. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9968. int nCardNum;
  9969. try {
  9970. nCardNum = Integer.parseInt(strEventCardNo);
  9971. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  9972. } catch (RuntimeException re) {
  9973. LogUtil.errorLogInfo("", TAG, re);
  9974. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9975. return retXML;
  9976. } catch (Exception e) {
  9977. //e.printStackTrace();
  9978. LogUtil.errorLogInfo("", TAG, e);
  9979. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9980. return retXML;
  9981. }
  9982. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9983. boolean bBandUse = deviceSet.getBandLocationUsage();
  9984. deviceSet.closeDB();
  9985. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  9986. wakeupLCD();
  9987. Intent iIntent = new Intent();
  9988. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9989. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  9990. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  9991. getApplicationContext().sendBroadcast(iIntent);
  9992. }
  9993. }
  9994. }
  9995. }
  9996. return retXML;
  9997. }
  9998. public String ProcParkInformation_cham_upis(Element ele) {
  9999. Log.d(TAG, "ProcParkInformation_cham_upis START");
  10000. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  10001. String infoName = null;
  10002. String infoDong = null;
  10003. String infoHo = null;
  10004. String infoCarMove = null;
  10005. String infoCarnum = null;
  10006. String infoCarLocation = null;
  10007. String infoMessage = null;
  10008. NodeList items = ele.getElementsByTagName("home_info");
  10009. Node item = items.item(0);
  10010. Node text;
  10011. NamedNodeMap attrsParam = item.getAttributes();
  10012. for (int j = 0; j < attrsParam.getLength(); j++) {
  10013. Node attr = attrsParam.item(j);
  10014. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10015. infoDong = trimquotation(attr.getNodeValue());
  10016. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10017. infoHo = trimquotation(attr.getNodeValue());
  10018. }
  10019. items = ele.getElementsByTagName("park_info");
  10020. item = items.item(0);
  10021. attrsParam = item.getAttributes();
  10022. for (int j = 0; j < attrsParam.getLength(); j++) {
  10023. Node attr = attrsParam.item(j);
  10024. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  10025. infoCarnum = trimquotation(attr.getNodeValue());
  10026. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  10027. infoCarLocation = trimquotation(attr.getNodeValue());
  10028. else if (attr.getNodeName().equalsIgnoreCase("message"))
  10029. infoMessage = trimquotation(attr.getNodeValue());
  10030. }
  10031. Log.d(TAG, "ProcParkInformation infoName :" + infoName);
  10032. if (infoDong != null)
  10033. Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
  10034. Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
  10035. Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
  10036. Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
  10037. Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
  10038. Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
  10039. if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  10040. (infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
  10041. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  10042. } else {
  10043. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  10044. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  10045. return retXML;
  10046. }
  10047. infoCarMove = "park";
  10048. //DB정보 업데이트!
  10049. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  10050. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  10051. CarDB.closeDB();
  10052. //DB정보 업데이트!
  10053. Intent iIntent = new Intent();
  10054. iIntent.setAction(define.NOTIFY_ACNAME);
  10055. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  10056. this.sendBroadcast(iIntent);
  10057. /*
  10058. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  10059. {
  10060. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  10061. // 팝업을 띄우도록 하자
  10062. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  10063. }
  10064. */
  10065. return retXML;
  10066. }
  10067. public String ProcGetSmartKeyInfo(Element ele) {
  10068. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  10069. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  10070. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  10071. NodeList items = ele.getElementsByTagName("info_type");
  10072. Node item = items.item(0);
  10073. Node text = item.getFirstChild();
  10074. String sInfo_type = trimquotation(text.getNodeValue());
  10075. String sCard_info = null;
  10076. String sMessage = null;
  10077. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  10078. {
  10079. items = ele.getElementsByTagName("uid_info");
  10080. item = items.item(0);
  10081. text = item.getFirstChild();
  10082. sCard_info = trimquotation(text.getNodeValue());
  10083. //==============================================//
  10084. items = ele.getElementsByTagName("message");
  10085. item = items.item(0);
  10086. text = item.getFirstChild();
  10087. sMessage = trimquotation(text.getNodeValue());
  10088. //==============================================//
  10089. //쿼리문 작성
  10090. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10091. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10092. for (int i = 0; i < SyncData.size(); i++) {
  10093. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  10094. NewData.add(SyncData.get(i));
  10095. }
  10096. }
  10097. wallpadSmartKeyRegData.closeDB();
  10098. } else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  10099. {
  10100. items = ele.getElementsByTagName("sn_info");
  10101. item = items.item(0);
  10102. text = item.getFirstChild();
  10103. sCard_info = trimquotation(text.getNodeValue());
  10104. //==============================================//
  10105. items = ele.getElementsByTagName("message");
  10106. item = items.item(0);
  10107. text = item.getFirstChild();
  10108. sMessage = trimquotation(text.getNodeValue());
  10109. //==============================================//
  10110. //쿼리문 작성
  10111. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10112. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10113. for (int i = 0; i < SyncData.size(); i++) {
  10114. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  10115. NewData.add(SyncData.get(i));
  10116. }
  10117. }
  10118. wallpadSmartKeyRegData.closeDB();
  10119. } else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  10120. {
  10121. items = ele.getElementsByTagName("uid_info");
  10122. item = items.item(0);
  10123. text = item.getFirstChild();
  10124. sCard_info = trimquotation(text.getNodeValue());
  10125. //==============================================//
  10126. items = ele.getElementsByTagName("message");
  10127. item = items.item(0);
  10128. text = item.getFirstChild();
  10129. sMessage = trimquotation(text.getNodeValue());
  10130. //==============================================//
  10131. //쿼리문 작성
  10132. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10133. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10134. for (int i = 0; i < SyncData.size(); i++) {
  10135. if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
  10136. NewData.add(SyncData.get(i));
  10137. }
  10138. }
  10139. if (NewData.size() > 0) {
  10140. NewData = SyncData;
  10141. }
  10142. wallpadSmartKeyRegData.closeDB();
  10143. } else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  10144. {
  10145. items = ele.getElementsByTagName("sn_info");
  10146. item = items.item(0);
  10147. text = item.getFirstChild();
  10148. sCard_info = trimquotation(text.getNodeValue());
  10149. //==============================================//
  10150. items = ele.getElementsByTagName("message");
  10151. item = items.item(0);
  10152. text = item.getFirstChild();
  10153. sMessage = trimquotation(text.getNodeValue());
  10154. //==============================================//
  10155. //쿼리문 작성
  10156. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10157. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10158. for (int i = 0; i < SyncData.size(); i++) {
  10159. if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
  10160. NewData.add(SyncData.get(i));
  10161. }
  10162. }
  10163. if (NewData.size() > 0) {
  10164. NewData = SyncData;
  10165. }
  10166. wallpadSmartKeyRegData.closeDB();
  10167. } else if (sInfo_type.equalsIgnoreCase("hkey")) {
  10168. String dong = "";
  10169. String ho = "";
  10170. String Num = "all";
  10171. //==============================================//
  10172. items = ele.getElementsByTagName("message");
  10173. item = items.item(0);
  10174. text = item.getFirstChild();
  10175. sMessage = trimquotation(text.getNodeValue());
  10176. //==============================================//
  10177. items = ele.getElementsByTagName("hkey_info");
  10178. item = items.item(0);
  10179. if (item == null)
  10180. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10181. NamedNodeMap attrsParam = item.getAttributes();
  10182. for (int j = 0; j < attrsParam.getLength(); j++) {
  10183. Node attr = attrsParam.item(j);
  10184. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10185. dong = attr.getNodeValue();
  10186. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10187. ho = attr.getNodeValue();
  10188. else if (attr.getNodeName().equalsIgnoreCase("num"))
  10189. Num = attr.getNodeValue();
  10190. }
  10191. if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
  10192. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
  10193. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10194. }
  10195. //쿼리문 작성
  10196. int intNum = 0;
  10197. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  10198. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  10199. for (int i = 0; i < SyncData.size(); i++) {
  10200. if (Num.equalsIgnoreCase("all") == true) {
  10201. NewData.add(SyncData.get(i));
  10202. } else {
  10203. try {
  10204. intNum = Integer.parseInt(Num);
  10205. } catch (RuntimeException re) {
  10206. LogUtil.errorLogInfo("", TAG, re);
  10207. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10208. } catch (Exception e) {
  10209. //e.printStackTrace();
  10210. LogUtil.errorLogInfo("", TAG, e);
  10211. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  10212. }
  10213. if (SyncData.get(i).id == intNum) {
  10214. NewData.add(SyncData.get(i));
  10215. }
  10216. }
  10217. }
  10218. wallpadSmartKeyRegData.closeDB();
  10219. } else if (sInfo_type.equalsIgnoreCase("dkey")) {
  10220. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10221. } else if (sInfo_type.equalsIgnoreCase("mkey")) {
  10222. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  10223. }
  10224. if (NewData.size() == 0) {
  10225. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  10226. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10227. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10228. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  10229. retXML += " </service>\r\n</imap>";
  10230. return retXML;
  10231. }
  10232. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  10233. retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
  10234. for (int i = 0; i < NewData.size(); i++) {
  10235. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  10236. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  10237. String strFormat = sFormat.format(date);
  10238. retXML += " <key_info index = \"" + NewData.get(i).id + "\" "
  10239. + "sn = \"" + NewData.get(i).SerialNumber + "\" "
  10240. + "uid = \"" + NewData.get(i).Uid + "\" "
  10241. + "key_num = \"" + NewData.get(i).id + "\" "
  10242. + "issue_cnt = \"" + 1 + "\" "
  10243. + "issued_date = \"" + strFormat + "\" "
  10244. + "message = \"" + "null" + "\" "
  10245. + "/>\r\n";
  10246. }
  10247. retXML += " </service>\r\n</imap>";
  10248. return retXML;
  10249. }
  10250. public void ProcMobileDevice_AuthNumber(Element ele) {
  10251. String sDong = null;
  10252. String sHo = null;
  10253. String sIP = null;
  10254. String sType = null;
  10255. String sDevice_Name = null;
  10256. String sTwinID = null;
  10257. String sAuthNumber = null;
  10258. try {
  10259. NodeList items = ele.getElementsByTagName("home_info");
  10260. Node item = items.item(0);
  10261. NamedNodeMap attrsParam = item.getAttributes();
  10262. for (int i = 0; i < attrsParam.getLength(); i++) {
  10263. Node attr = attrsParam.item(i);
  10264. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10265. sDong = trimquotation(attr.getNodeValue());
  10266. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10267. sHo = trimquotation(attr.getNodeValue());
  10268. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10269. sIP = trimquotation(attr.getNodeValue());
  10270. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10271. sType = trimquotation(attr.getNodeValue());
  10272. }
  10273. WallpadStatusData DBMGR = null;
  10274. DBMGR = new WallpadStatusData(getApplicationContext());
  10275. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10276. DBMGR.closeDB();
  10277. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10278. items = ele.getElementsByTagName("device_info");
  10279. item = items.item(0);
  10280. attrsParam = item.getAttributes();
  10281. for (int i = 0; i < attrsParam.getLength(); i++) {
  10282. Node attr = attrsParam.item(i);
  10283. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10284. sDevice_Name = trimquotation(attr.getNodeValue());
  10285. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10286. sTwinID = trimquotation(attr.getNodeValue());
  10287. else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
  10288. sAuthNumber = trimquotation(attr.getNodeValue());
  10289. }
  10290. /**데이터 전달**/
  10291. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10292. Log.d(TAG, "sTwinID :" + sTwinID);
  10293. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  10294. Intent intent = new Intent();
  10295. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10296. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  10297. intent.putExtra("AuthNumber", sAuthNumber);
  10298. if (NewServerUse()) {
  10299. getApplicationContext().sendBroadcast(intent);
  10300. }
  10301. } else {
  10302. }
  10303. } catch (RuntimeException re) {
  10304. LogUtil.errorLogInfo("", TAG, re);
  10305. } catch (Exception e) {
  10306. //e.printStackTrace();
  10307. LogUtil.errorLogInfo("", TAG, e);
  10308. }
  10309. }
  10310. public String ProcMobileDevice_ADD_Finish(Element ele) {
  10311. String retXML = "";
  10312. String sDong = null;
  10313. String sHo = null;
  10314. String sIP = null;
  10315. String sType = null;
  10316. String sDevice_Name = null;
  10317. String sTwinID = null;
  10318. try {
  10319. NodeList items = ele.getElementsByTagName("home_info");
  10320. Node item = items.item(0);
  10321. NamedNodeMap attrsParam = item.getAttributes();
  10322. for (int i = 0; i < attrsParam.getLength(); i++) {
  10323. Node attr = attrsParam.item(i);
  10324. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10325. sDong = trimquotation(attr.getNodeValue());
  10326. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10327. sHo = trimquotation(attr.getNodeValue());
  10328. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10329. sIP = trimquotation(attr.getNodeValue());
  10330. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10331. sType = trimquotation(attr.getNodeValue());
  10332. }
  10333. WallpadStatusData DBMGR = null;
  10334. DBMGR = new WallpadStatusData(getApplicationContext());
  10335. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10336. DBMGR.closeDB();
  10337. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10338. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10339. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10340. items = ele.getElementsByTagName("device_info");
  10341. item = items.item(0);
  10342. attrsParam = item.getAttributes();
  10343. for (int i = 0; i < attrsParam.getLength(); i++) {
  10344. Node attr = attrsParam.item(i);
  10345. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10346. sDevice_Name = trimquotation(attr.getNodeValue());
  10347. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10348. sTwinID = trimquotation(attr.getNodeValue());
  10349. }
  10350. /**데이터 전달**/
  10351. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10352. Log.d(TAG, "sTwinID :" + sTwinID);
  10353. Intent intent = new Intent();
  10354. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  10355. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  10356. if (NewServerUse()) {
  10357. getApplicationContext().sendBroadcast(intent);
  10358. } else {
  10359. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10360. retXML += " </service>\r\n</imap>";
  10361. return retXML;
  10362. }
  10363. String tempType = "main";
  10364. //DB에 저장 필요
  10365. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10366. if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  10367. {
  10368. wallpadMobileDeviceData.closeDB();
  10369. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10370. retXML += " </service>\r\n</imap>";
  10371. return retXML;
  10372. }
  10373. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  10374. wallpadMobileDeviceData.closeDB();
  10375. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  10376. retXML += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" ip=\"" + addc.IPAddress + "\" type=\"" + tempType + "\"/>\r\n";
  10377. retXML += " <device_info alias=\"" + sDevice_Name + "\" twinid=\"" + sTwinID + "\" />\r\n";
  10378. retXML += " </service>\r\n</imap>";
  10379. return retXML;
  10380. } else {
  10381. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10382. retXML += " </service>\r\n</imap>";
  10383. return retXML;
  10384. }
  10385. } catch (RuntimeException re) {
  10386. LogUtil.errorLogInfo("", TAG, re);
  10387. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10388. retXML += " </service>\r\n</imap>";
  10389. return retXML;
  10390. } catch (Exception e) {
  10391. //e.printStackTrace();
  10392. LogUtil.errorLogInfo("", TAG, e);
  10393. retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  10394. retXML += " </service>\r\n</imap>";
  10395. return retXML;
  10396. }
  10397. }
  10398. public void ProcMobileDevice_Delete(Element ele) {
  10399. String sDong = null;
  10400. String sHo = null;
  10401. String sIP = null;
  10402. String sType = null;
  10403. String sDevice_Name = null;
  10404. String sTwinID = null;
  10405. Log.d(TAG, "ProcMobileDevice_Delete");
  10406. try {
  10407. NodeList items = ele.getElementsByTagName("home_info");
  10408. Node item = items.item(0);
  10409. NamedNodeMap attrsParam = item.getAttributes();
  10410. for (int i = 0; i < attrsParam.getLength(); i++) {
  10411. Node attr = attrsParam.item(i);
  10412. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10413. sDong = trimquotation(attr.getNodeValue());
  10414. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10415. sHo = trimquotation(attr.getNodeValue());
  10416. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  10417. sIP = trimquotation(attr.getNodeValue());
  10418. else if (attr.getNodeName().equalsIgnoreCase("type"))
  10419. sType = trimquotation(attr.getNodeValue());
  10420. }
  10421. WallpadStatusData DBMGR = null;
  10422. DBMGR = new WallpadStatusData(getApplicationContext());
  10423. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10424. DBMGR.closeDB();
  10425. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  10426. (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  10427. (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  10428. if (NewServerUse()) {
  10429. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  10430. items = ele.getElementsByTagName("device_info");
  10431. for (int i = 0; i < items.getLength(); i++) {
  10432. item = items.item(i);
  10433. attrsParam = item.getAttributes();
  10434. for (int j = 0; j < attrsParam.getLength(); j++) {
  10435. Node attr = attrsParam.item(j);
  10436. if (attr.getNodeName().equalsIgnoreCase("alias"))
  10437. sDevice_Name = trimquotation(attr.getNodeValue());
  10438. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  10439. sTwinID = trimquotation(attr.getNodeValue());
  10440. }
  10441. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  10442. Log.d(TAG, "sTwinID :" + sTwinID);
  10443. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  10444. }
  10445. wallpadMobileDeviceData.closeDB();
  10446. Intent intent = new Intent();
  10447. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  10448. getApplicationContext().sendBroadcast(intent);
  10449. }
  10450. } else {
  10451. }
  10452. } catch (RuntimeException re) {
  10453. LogUtil.errorLogInfo("", TAG, re);
  10454. } catch (Exception e) {
  10455. //e.printStackTrace();
  10456. LogUtil.errorLogInfo("", TAG, e);
  10457. }
  10458. }
  10459. public String ProcGetAppVersionInfo() {
  10460. String retXML = "";
  10461. MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
  10462. int AppCount;
  10463. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  10464. retXML = XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  10465. retXML += " <home_info dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\" platform=\"Android\" count=\"" + AppCount + "\" />\r\n";
  10466. for (int i = 0; i < AppCount; i++) {
  10467. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
  10468. if (getString != null) {
  10469. retXML += " <app_list name=\"" + getString[0] + "\" version=\"" + getString[1] + "\" />\r\n";
  10470. }
  10471. }
  10472. retXML += " </service>\r\n</imap>";
  10473. return retXML;
  10474. }
  10475. public String ProcIgateInitInfo(Element ele) {
  10476. String retXML = "";
  10477. String ctrl_baudrate = "";
  10478. String ctrl_open = "";
  10479. String ctrl_framecheck = "";
  10480. String ctrl_message = "";
  10481. String eth_mode = "";
  10482. String eth_ip = "";
  10483. String eth_mac = "";
  10484. String eth_gw = "";
  10485. String eth_sm = "";
  10486. String noti_send = "";
  10487. String noti_level = "";
  10488. String noti_ip = "";
  10489. String noti_port = "";
  10490. try {
  10491. NodeList items = ele.getElementsByTagName("ctrl_param");
  10492. Node item = items.item(0);
  10493. NamedNodeMap attrsParam = item.getAttributes();
  10494. for (int i = 0; i < attrsParam.getLength(); i++) {
  10495. Node attr = attrsParam.item(i);
  10496. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  10497. ctrl_baudrate = trimquotation(attr.getNodeValue());
  10498. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  10499. ctrl_open = trimquotation(attr.getNodeValue());
  10500. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  10501. ctrl_framecheck = trimquotation(attr.getNodeValue());
  10502. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  10503. ctrl_message = trimquotation(attr.getNodeValue());
  10504. }
  10505. items = ele.getElementsByTagName("eth_param");
  10506. item = items.item(0);
  10507. attrsParam = item.getAttributes();
  10508. for (int i = 0; i < attrsParam.getLength(); i++) {
  10509. Node attr = attrsParam.item(i);
  10510. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  10511. eth_mode = trimquotation(attr.getNodeValue());
  10512. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  10513. eth_ip = trimquotation(attr.getNodeValue());
  10514. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  10515. eth_mac = trimquotation(attr.getNodeValue());
  10516. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  10517. eth_gw = trimquotation(attr.getNodeValue());
  10518. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  10519. eth_sm = trimquotation(attr.getNodeValue());
  10520. }
  10521. items = ele.getElementsByTagName("noti_param");
  10522. item = items.item(0);
  10523. attrsParam = item.getAttributes();
  10524. for (int i = 0; i < attrsParam.getLength(); i++) {
  10525. Node attr = attrsParam.item(i);
  10526. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  10527. noti_send = trimquotation(attr.getNodeValue());
  10528. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  10529. noti_level = trimquotation(attr.getNodeValue());
  10530. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  10531. noti_ip = trimquotation(attr.getNodeValue());
  10532. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  10533. noti_port = trimquotation(attr.getNodeValue());
  10534. }
  10535. wallpaddbmgr WallpadDBMGR = null;
  10536. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  10537. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  10538. if (RowCount_GatewayData > 100) {
  10539. WallpadDBMGR.DeleteLH_GatewayData("50");
  10540. }
  10541. 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);
  10542. WallpadDBMGR.closeDB();
  10543. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  10544. retXML += " </service>\r\n</imap>";
  10545. return retXML;
  10546. } catch (RuntimeException re) {
  10547. LogUtil.errorLogInfo("", TAG, re);
  10548. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10549. retXML += " </service>\r\n</imap>";
  10550. return retXML;
  10551. } catch (Exception e) {
  10552. //e.printStackTrace();
  10553. LogUtil.errorLogInfo("", TAG, e);
  10554. retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  10555. retXML += " </service>\r\n</imap>";
  10556. return retXML;
  10557. }
  10558. }
  10559. public String ProcElecCarChargeEventInfo(Element ele) {
  10560. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  10561. String retXML = "";
  10562. String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  10563. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  10564. try {
  10565. NodeList items = ele.getElementsByTagName("destination");
  10566. Node item = items.item(0);
  10567. NamedNodeMap attrsParam = item.getAttributes();
  10568. for (int i = 0; i < attrsParam.getLength(); i++) {
  10569. Node attr = attrsParam.item(i);
  10570. if (attr.getNodeName().equalsIgnoreCase("name"))
  10571. sName = trimquotation(attr.getNodeValue());
  10572. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10573. sId_High = trimquotation(attr.getNodeValue());
  10574. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10575. sId_Low = trimquotation(attr.getNodeValue());
  10576. }
  10577. WallpadStatusData DBMGR = null;
  10578. DBMGR = new WallpadStatusData(getApplicationContext());
  10579. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10580. DBMGR.closeDB();
  10581. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  10582. items = ele.getElementsByTagName("charging_info");
  10583. item = items.item(0);
  10584. attrsParam = item.getAttributes();
  10585. for (int i = 0; i < attrsParam.getLength(); i++) {
  10586. Node attr = attrsParam.item(i);
  10587. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  10588. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  10589. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  10590. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  10591. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  10592. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  10593. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  10594. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  10595. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  10596. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  10597. )) {
  10598. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10599. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10600. retXML += " </service>\r\n</imap>";
  10601. return retXML;
  10602. }
  10603. if (attr.getNodeName().equalsIgnoreCase("card_num"))
  10604. sCard_Num = trimquotation(attr.getNodeValue());
  10605. else if (attr.getNodeName().equalsIgnoreCase("car_num"))
  10606. sCar_Num = trimquotation(attr.getNodeValue());
  10607. else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
  10608. sCharger_Num = trimquotation(attr.getNodeValue());
  10609. else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
  10610. sCharger_Loc = trimquotation(attr.getNodeValue());
  10611. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  10612. sCharging_Status = trimquotation(attr.getNodeValue());
  10613. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  10614. (sCharging_Status.equalsIgnoreCase("charging")) ||
  10615. (sCharging_Status.equalsIgnoreCase("full")) ||
  10616. (sCharging_Status.equalsIgnoreCase("charged")) ||
  10617. (sCharging_Status.equalsIgnoreCase("stop")) ||
  10618. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  10619. (sCharging_Status.equalsIgnoreCase("check")) ||
  10620. (sCharging_Status.equalsIgnoreCase("commerror"))
  10621. )) {
  10622. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  10623. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10624. retXML += " </service>\r\n</imap>";
  10625. return retXML;
  10626. }
  10627. } else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  10628. sCharger_sort = trimquotation(attr.getNodeValue());
  10629. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  10630. (sCharger_sort.equalsIgnoreCase("fast")) ||
  10631. (sCharger_sort.equalsIgnoreCase("no_info"))
  10632. )) {
  10633. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  10634. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10635. retXML += " </service>\r\n</imap>";
  10636. return retXML;
  10637. }
  10638. } else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
  10639. sCharging_Ratio = trimquotation(attr.getNodeValue());
  10640. else if (attr.getNodeName().equalsIgnoreCase("start_time"))
  10641. sStart_Time = trimquotation(attr.getNodeValue());
  10642. else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
  10643. sRemain_Time = trimquotation(attr.getNodeValue());
  10644. }
  10645. items = ele.getElementsByTagName("message");
  10646. item = items.item(0);
  10647. Node text = item.getFirstChild();
  10648. sMessage = trimquotation(text.getNodeValue());
  10649. /**데이터 전달**/
  10650. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  10651. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  10652. Intent intent = new Intent();
  10653. intent.setAction(define.NOTIFY_ACNAME);
  10654. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  10655. intent.putExtra("sCard_Num", sCard_Num);
  10656. intent.putExtra("sCar_Num", sCar_Num);
  10657. intent.putExtra("sCharger_Num", sCharger_Num);
  10658. intent.putExtra("sCharger_Loc", sCharger_Loc);
  10659. intent.putExtra("sCharging_Status", sCharging_Status);
  10660. intent.putExtra("sCharger_sort", sCharger_sort);
  10661. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  10662. intent.putExtra("sStart_Time", sStart_Time);
  10663. intent.putExtra("sRemain_Time", sRemain_Time);
  10664. intent.putExtra("sMessage", sMessage);
  10665. WallpadDeviceSet devDB = null;
  10666. devDB = new WallpadDeviceSet(getApplicationContext());
  10667. int retInt = -1;
  10668. retInt = devDB.GetDeviceSetted("전기차충전");
  10669. devDB.closeDB();
  10670. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10671. getApplicationContext().sendBroadcast(intent);
  10672. }
  10673. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  10674. retXML += " <source name=\"homedev\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" />\r\n";
  10675. retXML += " </service>\r\n</imap>";
  10676. return retXML;
  10677. } else {
  10678. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10679. retXML += " </service>\r\n</imap>";
  10680. return retXML;
  10681. }
  10682. } catch (RuntimeException re) {
  10683. LogUtil.errorLogInfo("", TAG, re);
  10684. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10685. retXML += " </service>\r\n</imap>";
  10686. return retXML;
  10687. } catch (Exception e) {
  10688. //e.printStackTrace();
  10689. LogUtil.errorLogInfo("", TAG, e);
  10690. retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10691. retXML += " </service>\r\n</imap>";
  10692. return retXML;
  10693. }
  10694. }
  10695. public String ProcEnergyTargetInfoAlarm(Element ele) {
  10696. String retXML = "";
  10697. String sName = "";
  10698. String sId_High = "";
  10699. String sId_Low = "";
  10700. String vName[];
  10701. String vTarget[];
  10702. String vTarget_Cost[];
  10703. String vUsed[];
  10704. String vUsed_Cost[];
  10705. String vPredict[];
  10706. String vPredict_Cost[];
  10707. String vAlarm_info[];
  10708. String vRead_Date[];
  10709. String vRead_Day[];
  10710. String vV_Msg[];
  10711. String sMessage = "";
  10712. try {
  10713. NodeList items = ele.getElementsByTagName("source");
  10714. Node item = items.item(0);
  10715. NamedNodeMap attrsParam = item.getAttributes();
  10716. for (int i = 0; i < attrsParam.getLength(); i++) {
  10717. Node attr = attrsParam.item(i);
  10718. if (attr.getNodeName().equalsIgnoreCase("name"))
  10719. sName = trimquotation(attr.getNodeValue());
  10720. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10721. sId_High = trimquotation(attr.getNodeValue());
  10722. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10723. sId_Low = trimquotation(attr.getNodeValue());
  10724. }
  10725. WallpadStatusData DBMGR = null;
  10726. DBMGR = new WallpadStatusData(getApplicationContext());
  10727. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10728. DBMGR.closeDB();
  10729. if ((sName.equalsIgnoreCase("home") == true) &&
  10730. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  10731. (sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
  10732. items = ele.getElementsByTagName("valuelist");
  10733. Log.d(TAG, "items.getLength() :" + items.getLength());
  10734. vName = new String[items.getLength()];
  10735. vTarget = new String[items.getLength()];
  10736. vTarget_Cost = new String[items.getLength()];
  10737. vUsed = new String[items.getLength()];
  10738. vUsed_Cost = new String[items.getLength()];
  10739. vPredict = new String[items.getLength()];
  10740. vPredict_Cost = new String[items.getLength()];
  10741. vAlarm_info = new String[items.getLength()];
  10742. vRead_Date = new String[items.getLength()];
  10743. vRead_Day = new String[items.getLength()];
  10744. vV_Msg = new String[items.getLength()];
  10745. for (int j = 0; j < items.getLength(); j++) {
  10746. Log.d(TAG, "j :" + j);
  10747. item = items.item(j);
  10748. attrsParam = item.getAttributes();
  10749. Log.d(TAG, "attrsParam :" + attrsParam);
  10750. for (int i = 0; i < attrsParam.getLength(); i++) {
  10751. Node attr = attrsParam.item(i);
  10752. if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  10753. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  10754. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  10755. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  10756. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  10757. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  10758. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  10759. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  10760. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  10761. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  10762. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  10763. )) {
  10764. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10765. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10766. retXML += " </service>\r\n</imap>";
  10767. return retXML;
  10768. }
  10769. if (attr.getNodeName().equalsIgnoreCase("name")) {
  10770. vName[j] = trimquotation(attr.getNodeValue());
  10771. if (!((vName[j].equalsIgnoreCase("elect") == true) ||
  10772. (vName[j].equalsIgnoreCase("water") == true) ||
  10773. (vName[j].equalsIgnoreCase("gas") == true) ||
  10774. (vName[j].equalsIgnoreCase("heating") == true) ||
  10775. (vName[j].equalsIgnoreCase("hotwater") == true)
  10776. )) {
  10777. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  10778. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10779. retXML += " </service>\r\n</imap>";
  10780. return retXML;
  10781. }
  10782. } else if (attr.getNodeName().equalsIgnoreCase("target"))
  10783. vTarget[j] = trimquotation(attr.getNodeValue());
  10784. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  10785. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  10786. else if (attr.getNodeName().equalsIgnoreCase("used"))
  10787. vUsed[j] = trimquotation(attr.getNodeValue());
  10788. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  10789. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  10790. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  10791. vPredict[j] = trimquotation(attr.getNodeValue());
  10792. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  10793. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  10794. else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
  10795. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  10796. if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  10797. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  10798. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  10799. )) {
  10800. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  10801. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10802. retXML += " </service>\r\n</imap>";
  10803. return retXML;
  10804. }
  10805. } else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
  10806. vRead_Date[j] = trimquotation(attr.getNodeValue());
  10807. if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  10808. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  10809. )) {
  10810. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  10811. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10812. retXML += " </service>\r\n</imap>";
  10813. return retXML;
  10814. }
  10815. } else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  10816. vRead_Day[j] = trimquotation(attr.getNodeValue());
  10817. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  10818. vV_Msg[j] = trimquotation(attr.getNodeValue());
  10819. }
  10820. }
  10821. items = ele.getElementsByTagName("message");
  10822. item = items.item(0);
  10823. Node text = item.getFirstChild();
  10824. sMessage = trimquotation(text.getNodeValue());
  10825. /**데이터 전달**/
  10826. for (int i = 0; i < vName.length; i++) {
  10827. Log.d(TAG, "vName[" + i + "]: " + vName[i]);
  10828. Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
  10829. Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
  10830. Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
  10831. Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
  10832. Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
  10833. Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
  10834. Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
  10835. Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
  10836. Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
  10837. Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
  10838. }
  10839. Intent intent = new Intent();
  10840. intent.setAction(define.NOTIFY_ACNAME);
  10841. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  10842. for (int i = 0; i < vName.length; i++) {
  10843. if (vName[i].equals("elect")) {
  10844. intent.putExtra("elect_target", vTarget[i]);
  10845. intent.putExtra("elect_used", vUsed[i]);
  10846. intent.putExtra("elect_info", vAlarm_info[i]);
  10847. } else if (vName[i].equals("water")) {
  10848. intent.putExtra("water_target", vTarget[i]);
  10849. intent.putExtra("water_used", vUsed[i]);
  10850. intent.putExtra("water_info", vAlarm_info[i]);
  10851. } else if (vName[i].equals("gas")) {
  10852. intent.putExtra("gas_target", vTarget[i]);
  10853. intent.putExtra("gas_used", vUsed[i]);
  10854. intent.putExtra("gas_info", vAlarm_info[i]);
  10855. } else if (vName[i].equals("heating")) {
  10856. intent.putExtra("heating_target", vTarget[i]);
  10857. intent.putExtra("heating_used", vUsed[i]);
  10858. intent.putExtra("heating_info", vAlarm_info[i]);
  10859. } else if (vName[i].equals("hotwater")) {
  10860. intent.putExtra("hotwater_target", vTarget[i]);
  10861. intent.putExtra("hotwater_used", vUsed[i]);
  10862. intent.putExtra("hotwater_info", vAlarm_info[i]);
  10863. }
  10864. }
  10865. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  10866. retXML += " <source name=\"home\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" count=\"" + vName.length + "\"" + " s_msg=\"null\" />\r\n";
  10867. for (int i = 0; i < vName.length; i++) {
  10868. retXML += " <valuelist name=\"" + vName[i] + "\" alarm_info=\"" + vAlarm_info[i] + "\" v_msg=\"null\" />\r\n";
  10869. }
  10870. retXML += " <message>\"null\"</message>\r\n";
  10871. retXML += " </service>\r\n</imap>";
  10872. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10873. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  10874. devSet.closeDB();
  10875. if (MetringDB != null) {
  10876. try {
  10877. String devInfo = MetringDB[1];
  10878. devInfo = devInfo.replace('(', '_');
  10879. devInfo = devInfo.replace(':', '_');
  10880. devInfo = devInfo.replace(')', '_');
  10881. String[] MetringInfo = devInfo.split("_");
  10882. // MetringInfo[1] -> 회로수
  10883. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  10884. // MetringInfo[4] -> IP
  10885. // MetringInfo[5] -> IP정보
  10886. // MetringInfo[6] -> 검침일사용자설정
  10887. // MetringInfo[7] -> 사용함 또는 사용안함
  10888. if (MetringInfo[3].equals("사용함") == true) {
  10889. getApplicationContext().sendBroadcast(intent);
  10890. }
  10891. } catch (RuntimeException re) {
  10892. LogUtil.errorLogInfo("", TAG, re);
  10893. } catch (Exception e) {
  10894. //e.printStackTrace();
  10895. LogUtil.errorLogInfo("", TAG, e);
  10896. }
  10897. } else {
  10898. }
  10899. return retXML;
  10900. } else {
  10901. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10902. retXML += " </service>\r\n</imap>";
  10903. return retXML;
  10904. }
  10905. } catch (RuntimeException re) {
  10906. LogUtil.errorLogInfo("", TAG, re);
  10907. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10908. retXML += " </service>\r\n</imap>";
  10909. return retXML;
  10910. } catch (Exception e) {
  10911. //e.printStackTrace();
  10912. LogUtil.errorLogInfo("", TAG, e);
  10913. retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10914. retXML += " </service>\r\n</imap>";
  10915. return retXML;
  10916. }
  10917. }
  10918. public String ProcCheckCallOption() {
  10919. int[] resultDB = {0, 0};
  10920. String retXML = "";
  10921. String sOption = "sip";
  10922. String sMessage = "null";
  10923. try {
  10924. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10925. resultDB = devSet.Get_Handicapped_Mode();
  10926. devSet.closeDB();
  10927. if (resultDB[0] == 0) {
  10928. //장애인모드 사용 안함
  10929. } else if (resultDB[0] == 1) {
  10930. //장애인모드 사용함
  10931. }
  10932. switch (resultDB[1]) {
  10933. case 0: //일반모드
  10934. sOption = "sip";
  10935. break;
  10936. case 1: //청각장애인
  10937. sOption = "deaf";
  10938. break;
  10939. case 2: //시각장애인
  10940. sOption = "blind";
  10941. break;
  10942. default:
  10943. break;
  10944. }
  10945. if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  10946. {
  10947. //본 구문에 들어올수 없음
  10948. sOption = "none";
  10949. }
  10950. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  10951. retXML += " <option>\"" + sOption + "\"</option>\r\n";
  10952. retXML += " <message>\"" + sMessage + "\"</message>\r\n";
  10953. retXML += " </service>\r\n</imap>";
  10954. return retXML;
  10955. } catch (RuntimeException re) {
  10956. LogUtil.errorLogInfo("", TAG, re);
  10957. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10958. retXML += " </service>\r\n</imap>";
  10959. return retXML;
  10960. } catch (Exception e) {
  10961. //e.printStackTrace();
  10962. LogUtil.errorLogInfo("", TAG, e);
  10963. retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10964. retXML += " </service>\r\n</imap>";
  10965. return retXML;
  10966. }
  10967. }
  10968. public String ProcChatSequence(Element ele) {
  10969. String retXML = "";
  10970. String sFrom = "error";
  10971. String sTo = "error";
  10972. String sContact = "error";
  10973. String sSequence = "error";
  10974. String sStatus = "error";
  10975. String sMessage = "error";
  10976. String reply_Sequence = "error";
  10977. String reply_Status = "error";
  10978. String reply_Message = "null";
  10979. try {
  10980. NodeList items = ele.getElementsByTagName("sequence");
  10981. Node item = items.item(0);
  10982. NamedNodeMap attrsParam = item.getAttributes();
  10983. sSequence = trimquotation(item.getTextContent());
  10984. ///////////////////////////////////////////////
  10985. items = ele.getElementsByTagName("status");
  10986. item = items.item(0);
  10987. attrsParam = item.getAttributes();
  10988. sStatus = trimquotation(item.getTextContent());
  10989. ///////////////////////////////////////////////
  10990. items = ele.getElementsByTagName("message");
  10991. item = items.item(0);
  10992. attrsParam = item.getAttributes();
  10993. sMessage = trimquotation(item.getTextContent());
  10994. ///////////////////////////////////////////////
  10995. items = ele.getElementsByTagName("from");
  10996. item = items.item(0);
  10997. attrsParam = item.getAttributes();
  10998. sFrom = trimquotation(item.getTextContent());
  10999. ///////////////////////////////////////////////
  11000. items = ele.getElementsByTagName("to");
  11001. item = items.item(0);
  11002. attrsParam = item.getAttributes();
  11003. sTo = trimquotation(item.getTextContent());
  11004. ///////////////////////////////////////////////
  11005. items = ele.getElementsByTagName("contact");
  11006. item = items.item(0);
  11007. attrsParam = item.getAttributes();
  11008. sContact = trimquotation(item.getTextContent());
  11009. ///////////////////////////////////////////////
  11010. if (!((sSequence.equalsIgnoreCase("try") == true) ||
  11011. (sSequence.equalsIgnoreCase("start") == true) ||
  11012. (sSequence.equalsIgnoreCase("quit") == true) ||
  11013. (sSequence.equalsIgnoreCase("cancel") == true) ||
  11014. (sSequence.equalsIgnoreCase("ok") == true) ||
  11015. (sSequence.equalsIgnoreCase("busy") == true) ||
  11016. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  11017. (sSequence.equalsIgnoreCase("reject") == true)
  11018. )) {
  11019. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  11020. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  11021. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  11022. retXML += " </service>\r\n</imap>";
  11023. return retXML;
  11024. }
  11025. if (!((sStatus.equalsIgnoreCase("idle") == true) ||
  11026. (sStatus.equalsIgnoreCase("ringing") == true) ||
  11027. (sStatus.equalsIgnoreCase("talking") == true)
  11028. )) {
  11029. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  11030. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  11031. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  11032. retXML += " </service>\r\n</imap>";
  11033. return retXML;
  11034. }
  11035. //입력값 처리 필요!!
  11036. //김용성 과장님 작업필요
  11037. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  11038. //확인 하시고 위 정보 확인해주세요.
  11039. Log.d(TAG, "sFrom:" + sFrom);
  11040. Log.d(TAG, "sTo:" + sTo);
  11041. Log.d(TAG, "Contact:" + sContact);
  11042. Log.d(TAG, "sSequence:" + sSequence);
  11043. Log.d(TAG, "sStatus:" + sStatus);
  11044. if (sSequence.equalsIgnoreCase("try") == true) {
  11045. //채팅 요청
  11046. } else if (sSequence.equalsIgnoreCase("start") == true) {
  11047. //채팅 시작
  11048. } else if (sSequence.equalsIgnoreCase("quit") == true) {
  11049. //채팅 종료
  11050. } else if (sSequence.equalsIgnoreCase("cancel") == true) {
  11051. //취소
  11052. } else if (sSequence.equalsIgnoreCase("ok") == true) {
  11053. //요청확인
  11054. } else if (sSequence.equalsIgnoreCase("busy") == true) {
  11055. //통화중
  11056. } else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
  11057. //SIP 통화중
  11058. } else if (sSequence.equalsIgnoreCase("reject") == true) {
  11059. //거절
  11060. }
  11061. if (sStatus.equalsIgnoreCase("idle") == true) {
  11062. //대기
  11063. } else if (sStatus.equalsIgnoreCase("ringing") == true) {
  11064. //연결중
  11065. } else if (sStatus.equalsIgnoreCase("talking") == true) {
  11066. //통화중
  11067. }
  11068. //응답값 입력 필요!!
  11069. //김용성 과장님 작업필요
  11070. reply_Message = "null";
  11071. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  11072. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  11073. retXML += " </service>\r\n</imap>";
  11074. return retXML;
  11075. } catch (RuntimeException re) {
  11076. LogUtil.errorLogInfo("", TAG, re);
  11077. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  11078. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  11079. retXML += " </service>\r\n</imap>";
  11080. return retXML;
  11081. } catch (Exception e) {
  11082. //e.printStackTrace();
  11083. LogUtil.errorLogInfo("", TAG, e);
  11084. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  11085. retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
  11086. retXML += " </service>\r\n</imap>";
  11087. return retXML;
  11088. }
  11089. }
  11090. public String ProcChatMessage(Element ele) {
  11091. String retXML = "";
  11092. String sChatMessage = "error";
  11093. String sMessage = "error";
  11094. try {
  11095. NodeList items = ele.getElementsByTagName("chat");
  11096. Node item = items.item(0);
  11097. NamedNodeMap attrsParam = item.getAttributes();
  11098. sChatMessage = trimquotation(item.getTextContent());
  11099. ///////////////////////////////////////////////
  11100. items = ele.getElementsByTagName("message");
  11101. item = items.item(0);
  11102. attrsParam = item.getAttributes();
  11103. sMessage = trimquotation(item.getTextContent());
  11104. ///////////////////////////////////////////////
  11105. //test
  11106. Log.d(TAG, "sChatMessage is " + sChatMessage);
  11107. Log.d(TAG, "sMessage is " + sMessage);
  11108. //test
  11109. Intent intent = new Intent();
  11110. intent.setAction(define.NOTIFY_ACNAME);
  11111. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  11112. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  11113. intent.putExtra("ADD_MESSAGE", sMessage);
  11114. getApplicationContext().sendBroadcast(intent);
  11115. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  11116. retXML += " <message>\"" + "null" + "\"</message>\r\n";
  11117. retXML += " </service>\r\n</imap>";
  11118. return retXML;
  11119. } catch (RuntimeException re) {
  11120. LogUtil.errorLogInfo("", TAG, re);
  11121. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  11122. retXML += " </service>\r\n</imap>";
  11123. return retXML;
  11124. } catch (Exception e) {
  11125. //e.printStackTrace();
  11126. LogUtil.errorLogInfo("", TAG, e);
  11127. retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  11128. retXML += " </service>\r\n</imap>";
  11129. return retXML;
  11130. }
  11131. }
  11132. public String ProcEvacuationLadderOpen(Element ele) {
  11133. String retXML = "";
  11134. try {
  11135. String sDong = null;
  11136. String sHo = null;
  11137. NodeList items = ele.getElementsByTagName("home_info");
  11138. Node item = items.item(0);
  11139. NamedNodeMap attrsParam = item.getAttributes();
  11140. for (int i = 0; i < attrsParam.getLength(); i++) {
  11141. Node attr = attrsParam.item(i);
  11142. if (attr.getNodeName().equalsIgnoreCase("dong"))
  11143. sDong = trimquotation(attr.getNodeValue());
  11144. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  11145. sHo = trimquotation(attr.getNodeValue());
  11146. }
  11147. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  11148. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  11149. deviceSet.closeDB();
  11150. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  11151. WallpadStatusData DBMGR = null;
  11152. DBMGR = new WallpadStatusData(getApplicationContext());
  11153. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  11154. DBMGR.closeDB();
  11155. String myIP = addc.IPAddress;
  11156. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  11157. String[] SplitedString = myIP.split("\\.");
  11158. if (SplitedString != null) {
  11159. if (SplitedString.length == 4) {
  11160. int temp = Integer.parseInt(SplitedString[2]);
  11161. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11162. temp = temp - 1;
  11163. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11164. temp = temp + 1;
  11165. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  11166. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  11167. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  11168. DestStair = String.valueOf(temp);
  11169. }
  11170. }
  11171. if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
  11172. /**
  11173. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  11174. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  11175. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  11176. * **/
  11177. WallpadDeviceSet devset;
  11178. devset = new WallpadDeviceSet(getApplicationContext());
  11179. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11180. devset.closeDB();
  11181. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11182. /**
  11183. * 피난사다리 알림!!!
  11184. * **/
  11185. ReceiveNetworkLadderBr(ladderDownSend);
  11186. }
  11187. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  11188. retXML += " </service>\r\n</imap>";
  11189. return retXML;
  11190. } else {
  11191. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11192. retXML += " </service>\r\n</imap>";
  11193. return retXML;
  11194. }
  11195. } catch (RuntimeException re) {
  11196. LogUtil.errorLogInfo("", TAG, re);
  11197. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11198. retXML += " </service>\r\n</imap>";
  11199. return retXML;
  11200. } catch (Exception e) {
  11201. //e.printStackTrace();
  11202. LogUtil.errorLogInfo("", TAG, e);
  11203. retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  11204. retXML += " </service>\r\n</imap>";
  11205. return retXML;
  11206. }
  11207. }
  11208. private void ReceiveNetworkLadderBr(int val) {
  11209. int base = 7000;
  11210. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  11211. int Menu_Start_Option = 1;
  11212. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  11213. int AlarmStatus = wdb.GetAlarmStatus();
  11214. wdb.closeDB();
  11215. boolean MgrAppRun = false;
  11216. final String packageNameMgr = "com.artncore.managersetting";
  11217. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  11218. if (MgrAppRun)
  11219. return;
  11220. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  11221. return;
  11222. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11223. int StatusVal = devset.GetDeviceSetted("피난사다리");
  11224. devset.closeDB();
  11225. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  11226. Common.SendAppFinishReqBR(getApplicationContext());
  11227. Intent newintent = new Intent(Intent.ACTION_MAIN);
  11228. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  11229. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  11230. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  11231. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
  11232. newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  11233. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
  11234. newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  11235. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  11236. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11237. getApplicationContext().startActivity(newintent);
  11238. }
  11239. }
  11240. /**
  11241. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  11242. *
  11243. * @param ele Element Xml 데이터
  11244. * @return String 타입의 응답 메시지 생성
  11245. **/
  11246. public String SmartLightDetailInfo(Element ele) {
  11247. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  11248. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  11249. }
  11250. /**
  11251. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  11252. *
  11253. * @param ele Element Xml 데이터
  11254. * @return String 타입의 응답 메시지 생성
  11255. **/
  11256. public String KNXDeviceDetailInfo(Element ele) {
  11257. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  11258. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  11259. }
  11260. public String ProcSetServerChange(Element ele) {
  11261. String retXML = "";
  11262. String versionTXT = null;
  11263. try {
  11264. boolean bRet = false;
  11265. NodeList items = ele.getElementsByTagName("ver_server");
  11266. Node item = items.item(0);
  11267. Node text = item.getFirstChild();
  11268. versionTXT = trimquotation(text.getNodeValue());
  11269. if (versionTXT.equalsIgnoreCase("1.0")) {
  11270. bRet = true;
  11271. } else if (versionTXT.indexOf("2.") >= 0) {
  11272. bRet = true;
  11273. }
  11274. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11275. if (SetData != null && bRet == true) {
  11276. SetData.SetServerVer(versionTXT);
  11277. SetData.closeDB();
  11278. }
  11279. if (bRet == true) {
  11280. try {
  11281. iMapSverReload tSock = new iMapSverReload();
  11282. tSock.start();
  11283. } catch (IOException e) {
  11284. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  11285. //e.printStackTrace();
  11286. LogUtil.errorLogInfo("", TAG, e);
  11287. }
  11288. }
  11289. // 버전 체크해서
  11290. // 응답하고 나서
  11291. // 수신부 쓰레드 재 로딩..
  11292. if (versionTXT != null && bRet == true) {
  11293. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  11294. retXML += " </service>\r\n</imap>";
  11295. return retXML;
  11296. } else {
  11297. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11298. retXML += " </service>\r\n</imap>";
  11299. return retXML;
  11300. }
  11301. } catch (RuntimeException re) {
  11302. LogUtil.errorLogInfo("", TAG, re);
  11303. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11304. retXML += " </service>\r\n</imap>";
  11305. return retXML;
  11306. } catch (Exception e) {
  11307. //e.printStackTrace();
  11308. LogUtil.errorLogInfo("", TAG, e);
  11309. retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  11310. retXML += " </service>\r\n</imap>";
  11311. return retXML;
  11312. }
  11313. }
  11314. /**
  11315. * 현관 열림 명령을 내린다.
  11316. *
  11317. * @return (String) - > success : 성공, fail : 실패
  11318. */
  11319. private String Device_DoorOpen(final int address) {
  11320. Log.i(TAG, "[Device_DoorOpen] - Start");
  11321. final ModbusClient modbusClient = new ModbusClient("10.0.215.2", 502);
  11322. modbusClient.setConnectionTimeout(5000);
  11323. try {
  11324. new Thread() {
  11325. public void run() {
  11326. try {
  11327. modbusClient.Connect();
  11328. modbusClient.WriteSingleCoil(address, true);
  11329. Thread.sleep(600);
  11330. modbusClient.WriteSingleCoil(address, false);
  11331. modbusClient.Disconnect();
  11332. } catch (IOException | ModbusException | InterruptedException e) {
  11333. e.printStackTrace();
  11334. try {
  11335. modbusClient.Disconnect();
  11336. } catch (IOException ioException) {
  11337. ioException.printStackTrace();
  11338. }
  11339. }
  11340. }
  11341. }.start();
  11342. } catch (RuntimeException re) {
  11343. LogUtil.errorLogInfo("", TAG, re);
  11344. return "fail";
  11345. } catch (Exception e) {
  11346. //e.printStackTrace();
  11347. LogUtil.errorLogInfo("", TAG, e);
  11348. return "fail";
  11349. }
  11350. Log.i(TAG, "[Device_DoorOpen] - OK");
  11351. return "ok";
  11352. }
  11353. /**
  11354. * 현관 문열림 요청에 대한 응답
  11355. * @return String 타입의 응답 메시지 생성
  11356. **/
  11357. private long mLastClickTime = 0;
  11358. private final long MIN_CLICK_INTERVAL = 3000;
  11359. public String ProcFrontOpen() {
  11360. String oepn_result;
  11361. long currentClickTime = SystemClock.uptimeMillis();
  11362. long elapsedTime = currentClickTime - mLastClickTime;
  11363. mLastClickTime = currentClickTime;
  11364. // 연속으로 문열림 요청이 들어오는 경우를 방지하기 위한 처리. 3초안에 문열림 요청이 다시 들어오면 무시하고, fail 처리함.
  11365. if (elapsedTime < MIN_CLICK_INTERVAL) {
  11366. mLastClickTime = 0;
  11367. oepn_result = "fail";
  11368. }else{
  11369. oepn_result = Device_DoorOpen(19);
  11370. }
  11371. String retXML = XMLHeader + "<service type=\"reply\" name=\"front_open\" result=\"" + oepn_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
  11372. return retXML;
  11373. }
  11374. // 메인 서버 소켓 클래스
  11375. public class iMapSverReload extends Thread {
  11376. ServerSocket svr;
  11377. public iMapSverReload() throws IOException {
  11378. /////////////////////////////////////////////////////////////////////
  11379. // 신형 단지서버 사용 유무를 가져온다.
  11380. /////////////////////////////////////////////////////////////////////
  11381. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  11382. if (SetData != null) {
  11383. String serverVesionInfo = SetData.GetServerVer();
  11384. SetData.closeDB();
  11385. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  11386. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11387. boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
  11388. devset.closeDB();
  11389. } else {
  11390. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11391. boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
  11392. devset.closeDB();
  11393. }
  11394. }
  11395. try {
  11396. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11397. mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11398. wallpadDeviceSet.closeDB();
  11399. } catch (RuntimeException re) {
  11400. LogUtil.errorLogInfo("", TAG, re);
  11401. mNewDanjiServer = false;
  11402. } catch (Exception e) {
  11403. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  11404. //e.printStackTrace();
  11405. LogUtil.errorLogInfo("", TAG, e);
  11406. mNewDanjiServer = false;
  11407. }
  11408. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
  11409. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  11410. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  11411. // 관리 PC IP도 변경하도록 한다.
  11412. if (mNewDanjiServer == true) {
  11413. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11414. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  11415. wallpadStatusData.closeDB();
  11416. } else {
  11417. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  11418. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  11419. wallpadStatusData.closeDB();
  11420. }
  11421. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
  11422. }
  11423. public void run() {
  11424. try {
  11425. try {
  11426. Thread.sleep(400);
  11427. } catch (RuntimeException re) {
  11428. LogUtil.errorLogInfo("", TAG, re);
  11429. } catch (Exception e) {
  11430. LogUtil.errorLogInfo("", TAG, e);
  11431. }
  11432. SvrSock.destoryThread();
  11433. for (int i = 0; i < 20; i++) {
  11434. if (SvrSock.isAlive() == false) {
  11435. Log.d(TAG, " Receive Socket Reload i = : " + i);
  11436. break;
  11437. } else {
  11438. Log.d(TAG, " is Live Socket Reload i = : " + i);
  11439. }
  11440. try {
  11441. Thread.sleep(100);
  11442. } catch (RuntimeException re) {
  11443. LogUtil.errorLogInfo("", TAG, re);
  11444. } catch (Exception e) {
  11445. LogUtil.errorLogInfo("", TAG, e);
  11446. }
  11447. }
  11448. SvrSock = new iMapSverSocket();
  11449. SvrSock.start();
  11450. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  11451. try {
  11452. Thread.sleep(3000);
  11453. } catch (RuntimeException re) {
  11454. LogUtil.errorLogInfo("", TAG, re);
  11455. } catch (Exception e) {
  11456. LogUtil.errorLogInfo("", TAG, e);
  11457. }
  11458. try {
  11459. Intent intent = new Intent();
  11460. intent.setAction(define.NOTIFY_ACNAME);
  11461. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  11462. getApplicationContext().sendBroadcast(intent);
  11463. } catch (RuntimeException re) {
  11464. LogUtil.errorLogInfo("", TAG, re);
  11465. } catch (Exception e) {
  11466. //e.printStackTrace();
  11467. LogUtil.errorLogInfo("", TAG, e);
  11468. }
  11469. } catch (IOException e) {
  11470. //e.printStackTrace();
  11471. LogUtil.errorLogInfo("", TAG, e);
  11472. }
  11473. }
  11474. }
  11475. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  11476. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  11477. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  11478. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  11479. public static final int SCHEDULE_START_CALLAPP = 30004;
  11480. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  11481. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  11482. public class SchedulerThread extends Thread {
  11483. boolean doRun;
  11484. AddressSet addr;
  11485. String AddressStr;
  11486. String IPaddr;
  11487. String VerBSP = "";
  11488. String VerAPP;
  11489. String VerSetting;
  11490. String VerNews;
  11491. String VerWeather;
  11492. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  11493. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  11494. private jni mGleInterface = null;
  11495. private final int LIVE_SIGNAL_TIME = 20;
  11496. private int m_LiveSignalCount = 0;
  11497. private int m_MainAppLiveCount = 0;
  11498. Handler ScheDuleHandler = new Handler() {
  11499. public void handleMessage(Message msg) {
  11500. switch (msg.what) {
  11501. case SCHEDULE_START_HEARTBEAT: {
  11502. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  11503. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11504. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11505. DBMGR.closeDB();
  11506. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11507. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11508. }
  11509. break;
  11510. case SCHEDULE_CHANGE_HEARTBEAT:
  11511. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  11512. synchronized (ScheduleList) {
  11513. ScheduleData CheckData;
  11514. for (int i = 0; i < ScheduleList.size(); i++) {
  11515. CheckData = ScheduleList.get(i);
  11516. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11517. Calendar cal = new GregorianCalendar();
  11518. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11519. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11520. DBMGR.closeDB();
  11521. cal.add(Calendar.MINUTE, heartbeatP);
  11522. CheckData.TData = cal;
  11523. ScheduleList.set(i, CheckData);
  11524. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11525. return;
  11526. }
  11527. }
  11528. }
  11529. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11530. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11531. break;
  11532. case SCHEDULE_START_STATUSBEAT:
  11533. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  11534. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11535. break;
  11536. case SCHEDULE_CHANGE_STATUSBEAT:
  11537. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  11538. synchronized (ScheduleList) {
  11539. ScheduleData CheckData;
  11540. for (int i = 0; i < ScheduleList.size(); i++) {
  11541. CheckData = ScheduleList.get(i);
  11542. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11543. Calendar cal = new GregorianCalendar();
  11544. cal.add(Calendar.MINUTE, heartbeatP);
  11545. CheckData.TData = cal;
  11546. ScheduleList.set(i, CheckData);
  11547. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11548. return;
  11549. }
  11550. }
  11551. }
  11552. break;
  11553. case SCHEDULE_START_CALLAPP:
  11554. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  11555. // Bundle bundle = new Bundle();
  11556. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  11557. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  11558. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  11559. // .putExtra(ITEM_CALL_DATA, bundle);
  11560. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11561. // iMAPstartActivity(intent);
  11562. break;
  11563. }
  11564. }
  11565. };
  11566. Handler GetHandler() {
  11567. return ScheDuleHandler;
  11568. }
  11569. public class ScheduleData {
  11570. Calendar TData;
  11571. String ActionSTR;
  11572. public ScheduleData(Calendar tdata, String ActionStr) {
  11573. TData = tdata;
  11574. ActionSTR = ActionStr;
  11575. }
  11576. }
  11577. public SchedulerThread() {
  11578. doRun = true;
  11579. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11580. addr = DBMGR.getAddressMGR();
  11581. VerAPP = DBMGR.GetAPPVer();
  11582. VerSetting = DBMGR.GetSettingVer();
  11583. VerNews = DBMGR.GetNoticeVer();
  11584. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11585. DBMGR.closeDB();
  11586. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  11587. try {
  11588. mGleInterface = new jni();
  11589. } catch (RuntimeException re) {
  11590. LogUtil.errorLogInfo("", TAG, re);
  11591. } catch (Exception e) {
  11592. Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
  11593. }
  11594. }
  11595. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
  11596. VerAPP = GetAppVersion();
  11597. }
  11598. AddressStr = addr.Dong + "동" + addr.Ho + "호";
  11599. IPaddr = addr.IPAddress;
  11600. ScheDulerHandler = ScheDuleHandler;
  11601. }
  11602. public void reg_schedule(int min, String Action) {
  11603. for (int i = 0; i < ScheduleList.size(); i++) {
  11604. ScheduleData scdata = ScheduleList.get(i);
  11605. if (scdata.ActionSTR.equals(Action)) {
  11606. ScheduleList.remove(i);
  11607. break;
  11608. }
  11609. }
  11610. Calendar cal = new GregorianCalendar();
  11611. cal.add(Calendar.MINUTE, min);
  11612. ScheduleData regData = new ScheduleData(cal, Action);
  11613. synchronized (ScheduleList) {
  11614. ScheduleList.add(regData);
  11615. }
  11616. }
  11617. private void doSchedule(String doing) {
  11618. String[] doingData = doing.split(";");
  11619. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11620. try {
  11621. String SendingStr = MakeHeartbeat();
  11622. SendToServer(SendingStr);
  11623. Calendar cal = new GregorianCalendar();
  11624. 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));
  11625. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11626. DBMGR.SetLastHeartbeat(timedata);
  11627. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11628. DBMGR.closeDB();
  11629. } catch (RuntimeException re) {
  11630. LogUtil.errorLogInfo("", TAG, re);
  11631. } catch (Exception e) {
  11632. //e.printStackTrace();
  11633. LogUtil.errorLogInfo("", TAG, e);
  11634. }
  11635. } else if (doingData[0].equals("UPDATETIME")) {
  11636. } else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11637. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  11638. if (!Common.getDeviceServeiceLoadComplite()) return;
  11639. String SendingStr = MakeStatusReport();
  11640. if (SendingStr == null) return;
  11641. SendToServer(SendingStr);
  11642. Calendar cal = new GregorianCalendar();
  11643. 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));
  11644. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11645. DBMGR.SetLastStatusbeat(timedata);
  11646. DBMGR.closeDB();
  11647. int StatusP = 720;
  11648. try {
  11649. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11650. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11651. devset.closeDB();
  11652. if (StatusVal == null) StatusP = 720;
  11653. else StatusP = Integer.parseInt(StatusVal[1]);
  11654. } catch (RuntimeException re) {
  11655. LogUtil.errorLogInfo("", TAG, re);
  11656. } catch (Exception e) {
  11657. //e.printStackTrace();
  11658. LogUtil.errorLogInfo("", TAG, e);
  11659. }
  11660. reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
  11661. }
  11662. }
  11663. private String MakeHeartbeat() {
  11664. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11665. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11666. VerNews = DBMGR.GetNoticeVer();
  11667. VerSetting = DBMGR.GetSettingVer();
  11668. String VerServer = DBMGR.GetServerVer();
  11669. DBMGR.closeDB();
  11670. if (VerServer == null) {
  11671. Log.d(TAG, "VerServer null");
  11672. VerServer = "1.0";
  11673. }
  11674. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11675. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  11676. wallpadDeviceSet.closeDB();
  11677. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  11678. // 스마트 분전반
  11679. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  11680. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  11681. String retStr = XMLHeader +
  11682. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11683. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11684. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11685. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11686. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11687. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11688. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11689. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11690. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11691. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11692. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11693. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n" +
  11694. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n" +
  11695. "</service>\r\n</imap>";
  11696. return retStr;
  11697. } else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  11698. // TODO KNX 분전반
  11699. // String retStr = XMLHeader+
  11700. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  11701. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  11702. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  11703. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  11704. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  11705. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  11706. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  11707. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  11708. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  11709. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  11710. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11711. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  11712. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  11713. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  11714. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  11715. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  11716. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  11717. // "</service>\r\n</imap>";
  11718. String retStr = XMLHeader +
  11719. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11720. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11721. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11722. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11723. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11724. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11725. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11726. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11727. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11728. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11729. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11730. "</service>\r\n</imap>";
  11731. return retStr;
  11732. } else {
  11733. String retStr = XMLHeader +
  11734. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
  11735. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
  11736. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
  11737. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
  11738. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
  11739. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
  11740. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
  11741. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
  11742. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
  11743. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
  11744. "<ver_server>" + VerServer + "</ver_server>\r\n" +
  11745. "</service>\r\n</imap>";
  11746. return retStr;
  11747. }
  11748. }
  11749. public String GetAppVersion() {
  11750. PackageInfo pi = null;
  11751. try {
  11752. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  11753. } catch (RuntimeException re) {
  11754. LogUtil.errorLogInfo("", TAG, re);
  11755. } catch (Exception e) {
  11756. LogUtil.errorLogInfo("", TAG, e);
  11757. }
  11758. return pi.versionName;
  11759. }
  11760. boolean isAlawaysrun = true;
  11761. public void run() {
  11762. while (/*doRun*/ isAlawaysrun) {
  11763. //Common.DebugLog("SchedulerThread ------ 10Sec");
  11764. CheckHeartBeat();
  11765. CheckStatusBeat();
  11766. CheckWallPadLiveSignal();
  11767. LiveCheckRebooting();
  11768. 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
  11769. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  11770. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  11771. //다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
  11772. if(skipCount==0) {
  11773. sendMsgToActivity(1234);
  11774. Log.d(TAG, "sendMsgToActivity!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
  11775. }
  11776. skipCount++;
  11777. if(skipCount==18) skipCount = 0 ;
  11778. }
  11779. try {
  11780. Thread.sleep(10000);
  11781. } catch (RuntimeException re) {
  11782. LogUtil.errorLogInfo("", TAG, re);
  11783. } catch (Exception e) {
  11784. LogUtil.errorLogInfo("", TAG, e);
  11785. }
  11786. }
  11787. }
  11788. public void SetLive() {
  11789. m_MainAppLiveCount++;
  11790. }
  11791. private int CheckTime30Sec = 0;
  11792. private void LiveCheckRebooting() {
  11793. try {
  11794. CheckTime30Sec++;
  11795. if (CheckTime30Sec % 20 == 0) {
  11796. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  11797. // // 10초마다 수행되는 함수이니....
  11798. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  11799. // if (m_MainAppLiveCount == 0) {
  11800. // //리셋
  11801. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  11802. // {
  11803. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  11804. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  11805. // pm.userActivity(8, true);
  11806. // }
  11807. // else
  11808. // {
  11809. // Log.d(TAG, "Main App Down Reset IHN_750");
  11810. // WallPadInterface wpdifc = new WallPadInterface();
  11811. // wpdifc.WachdogSystemReset();
  11812. // }
  11813. // }
  11814. // }
  11815. CheckTime30Sec = 0;
  11816. }
  11817. if (CheckTime30Sec >= 30000) {
  11818. CheckTime30Sec = 0;
  11819. }
  11820. } catch (RuntimeException re) {
  11821. LogUtil.errorLogInfo("", TAG, re);
  11822. } catch (Exception e) {
  11823. //e.printStackTrace();
  11824. LogUtil.errorLogInfo("", TAG, e);
  11825. }
  11826. }
  11827. private void CheckWallPadLiveSignal() {
  11828. try {
  11829. int nTime = LIVE_SIGNAL_TIME / 10;
  11830. m_LiveSignalCount++;
  11831. if (m_LiveSignalCount >= nTime) {
  11832. m_LiveSignalCount = 0;
  11833. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  11834. }
  11835. } catch (RuntimeException re) {
  11836. LogUtil.errorLogInfo("", TAG, re);
  11837. } catch (Exception e) {
  11838. Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
  11839. }
  11840. }
  11841. protected void CheckStatusBeat() {
  11842. try {
  11843. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11844. String statusbeatdata = WPD.GetLastStatusbeat();
  11845. WPD.closeDB();
  11846. int StatusP = 720;
  11847. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11848. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11849. if (StatusVal == null) StatusP = 720;
  11850. else
  11851. StatusP = Integer.parseInt(StatusVal[1]);
  11852. devset.closeDB();
  11853. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11854. } catch (RuntimeException re) {
  11855. LogUtil.errorLogInfo("", TAG, re);
  11856. } catch (Exception e) {
  11857. //e.printStackTrace();
  11858. LogUtil.errorLogInfo("", TAG, e);
  11859. }
  11860. }
  11861. protected void CheckHeartBeat() {
  11862. try {
  11863. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11864. String heartbeatdata = WPD.GetLastHeartbeat();
  11865. int heartbeatPer = WPD.GetHeartbeatPeriod();
  11866. WPD.closeDB();
  11867. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11868. } catch (RuntimeException re) {
  11869. LogUtil.errorLogInfo("", TAG, re);
  11870. } catch (Exception e) {
  11871. //e.printStackTrace();
  11872. LogUtil.errorLogInfo("", TAG, e);
  11873. }
  11874. }
  11875. protected boolean CheckTime(String CheckT, int period) {
  11876. Calendar last = new GregorianCalendar();
  11877. String[] timedata = CheckT.split("[.]");
  11878. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  11879. last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
  11880. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  11881. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  11882. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  11883. last.add(Calendar.MINUTE, period);
  11884. Calendar checkCal = new GregorianCalendar();
  11885. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  11886. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  11887. return true;
  11888. return false;
  11889. }
  11890. }
  11891. class SendMSGToSVR extends Thread {
  11892. String sendmsg;
  11893. public SendMSGToSVR(String msg) {
  11894. sendmsg = msg;
  11895. }
  11896. public void run() {
  11897. Socket sock = null;
  11898. DataOutputStream outstream = null;
  11899. try {
  11900. // 신형 단지서버 사용 유무를 가져온다.
  11901. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11902. boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11903. wallpadDeviceSet.closeDB();
  11904. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11905. SVRIP = DBMGR.GetServerIP();
  11906. port = DBMGR.GetServerPort();
  11907. DBMGR.closeDB();
  11908. /////////////////////////////////////////////////////////////////////
  11909. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  11910. // 사용중일 경우 암호화 소켓을 생성한다.
  11911. /////////////////////////////////////////////////////////////////////
  11912. if (!bNewDanjiServer) {
  11913. sock = new Socket(SVRIP, port);
  11914. } else {
  11915. int setport = port + 1000;
  11916. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  11917. SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
  11918. sock = sslClientSocket.getSocket();
  11919. }
  11920. /////////////////////////////////////////////////////////////////////
  11921. if (sock != null) {
  11922. sock.setSoLinger(true, 1000);
  11923. outstream = new DataOutputStream(sock.getOutputStream());
  11924. byte[] outBF = sendmsg.getBytes("euc-kr");
  11925. outstream.write(outBF);
  11926. outstream.flush();
  11927. }
  11928. } catch (RuntimeException re) {
  11929. LogUtil.errorLogInfo("", TAG, re);
  11930. } catch (Exception e) {
  11931. //e.printStackTrace();
  11932. LogUtil.errorLogInfo("", TAG, e);
  11933. } finally {
  11934. if (outstream != null) {
  11935. try {
  11936. outstream.close();
  11937. } catch (IOException e) {
  11938. LogUtil.errorLogInfo("", TAG, e);
  11939. }
  11940. }
  11941. outstream = null;
  11942. if (sock != null) {
  11943. try {
  11944. sock.close();
  11945. } catch (IOException e) {
  11946. LogUtil.errorLogInfo("", TAG, e);
  11947. }
  11948. }
  11949. sock = null;
  11950. }
  11951. }
  11952. }
  11953. private void SendToServer(String msg) {
  11954. SendMSGToSVR msan = new SendMSGToSVR(msg);
  11955. msan.start();
  11956. }
  11957. boolean StatusBeatRequested = false;
  11958. private String MakeStatusReport() {
  11959. try {
  11960. String ServiceType = StatusBeatRequested ? "requested" : "notice";
  11961. StatusBeatRequested = false;
  11962. String RetData = XMLHeader + "<service type=\"" + ServiceType + "\" name=\"statusbeat\"> \r\n";
  11963. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  11964. String[] typeList = SettManager.GetTypeList();
  11965. if (typeList == null || typeList.length == 0) {
  11966. DefaultProcauscultateReq(SettManager);
  11967. typeList = SettManager.GetTypeList();
  11968. }
  11969. SettManager.closeDB();
  11970. String[] ControlList;
  11971. String Vender = "null";
  11972. String devid = "null";
  11973. String Model = "null";
  11974. String subunitcnt = "null";
  11975. String statusRate = "null";
  11976. String statusType = "null";
  11977. String message = "null";
  11978. int itemCNT = 0;
  11979. int totalGroup = 0;
  11980. int totalItem = 0;
  11981. String ControlDEVList;
  11982. String ContentList = " ";
  11983. if (typeList != null) {
  11984. for (int i = 0; i < typeList.length; i++) {
  11985. if (typeList[i].equals("ctrl_device")) {
  11986. SettManager = new WallpadDevStatus(getApplicationContext());
  11987. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  11988. SettManager.closeDB();
  11989. ControlDEVList = "";
  11990. if (ControlList != null) {
  11991. for (int k = 0; k < ControlList.length; k++) {
  11992. if (ControlList[k].equals("light")) {
  11993. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11994. int[] lightinfo = devSet.Get_Light_info();
  11995. devSet.closeDB();
  11996. if (lightinfo[0] == 1) {
  11997. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  11998. subunitcnt = String.valueOf(lightinfo[2]);
  11999. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  12000. devid = "0x11";
  12001. Vender = "null";
  12002. Model = "null";
  12003. if (lightCTR != null) {
  12004. lightCTR.TRInfo.GetTransactionList(0);
  12005. statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
  12006. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  12007. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12008. message = "null";
  12009. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12010. itemCNT++;
  12011. }
  12012. } else {
  12013. subunitcnt = String.valueOf(lightinfo[2]);
  12014. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  12015. if (MultiSW != null) {
  12016. MultiSW.Refresh((byte) 0xFF, false);
  12017. byte Bdevid = 0x51;
  12018. for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
  12019. devid = String.format("0x%02X", Bdevid + j);
  12020. Vender = "null";
  12021. Model = "null";
  12022. MultiSW.TRInfo.GetTransactionList(j);
  12023. statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
  12024. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  12025. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12026. ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12027. itemCNT++;
  12028. }
  12029. }
  12030. }
  12031. } else {
  12032. Vender = "null";
  12033. devid = "null";
  12034. Model = "null";
  12035. subunitcnt = "null";
  12036. statusRate = "null";
  12037. message = "null";
  12038. }
  12039. } else if (ControlList[k].equals("thermostat")) {
  12040. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12041. int ret = devSet.Get_Temper_Info();
  12042. devSet.closeDB();
  12043. if (ret == 1) {
  12044. // 난방 종류를 얻어온다.
  12045. int HeatingKind = mWallPadAPI.GetHeatingKind();
  12046. HeatingV1API heatingV1API = null;
  12047. HeatingV2API heatingV2API = null;
  12048. // 종류별 API를 로딩한다.
  12049. if (HeatingKind == 1) {
  12050. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  12051. if (heatingV1API != null) {
  12052. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  12053. devid = "0x21";
  12054. Vender = "null";
  12055. Model = "null";
  12056. heatingV1API.TRInfo.GetTransactionList(0);
  12057. statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
  12058. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  12059. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12060. message = "null";
  12061. }
  12062. } else if (HeatingKind == 2) {
  12063. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  12064. if (heatingV2API != null) {
  12065. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  12066. devid = "0x28";
  12067. Vender = "null";
  12068. Model = "null";
  12069. heatingV2API.TRInfo.GetTransactionList(0);
  12070. statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
  12071. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  12072. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12073. message = "null";
  12074. }
  12075. } else {
  12076. subunitcnt = "null";
  12077. devid = "null";
  12078. Vender = "null";
  12079. Model = "null";
  12080. statusRate = "0/0";
  12081. statusType = "bad";
  12082. message = "null";
  12083. }
  12084. ControlDEVList += " <unit type=\"thermostat\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12085. itemCNT++;
  12086. } else {
  12087. }
  12088. } else if (ControlList[k].equals("gas")) {
  12089. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12090. if (devSet.Get_GAS_Info() == 1) {
  12091. //여기서 신우전자확인이 더 필요함
  12092. GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
  12093. CooktopAPI HybridCookTopCTR = null;
  12094. subunitcnt = "1";
  12095. devid = "0x31";
  12096. Vender = "null";
  12097. Model = "null";
  12098. if (mWallPadAPI.GetGasKind() == 2) {
  12099. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  12100. if (HybridCookTopCTR != null) {
  12101. HybridCookTopCTR.TRInfo.GetTransactionList(0);
  12102. statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
  12103. double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
  12104. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12105. message = "null";
  12106. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12107. itemCNT++;
  12108. }
  12109. } else {
  12110. GasCTR = mWallPadAPI.Get_GasController();
  12111. if (GasCTR != null) {
  12112. GasCTR.TRInfo.GetTransactionList(0);
  12113. statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
  12114. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  12115. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12116. message = "null";
  12117. ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12118. itemCNT++;
  12119. }
  12120. }
  12121. } else {
  12122. }
  12123. devSet.closeDB();
  12124. } else if (ControlList[k].equals("doorlock")) {
  12125. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12126. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  12127. if (doorlockInfo[0] == 1) {
  12128. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  12129. subunitcnt = "1";
  12130. devid = "0x41";
  12131. Vender = "null";
  12132. Model = "null";
  12133. if (DoorCTR != null) {
  12134. DoorCTR.TRInfo.GetTransactionList(0);
  12135. statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
  12136. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  12137. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12138. message = "null";
  12139. ControlDEVList += " <unit type=\"doorlock\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12140. itemCNT++;
  12141. }
  12142. } else {
  12143. }
  12144. devSet.closeDB();
  12145. } else if (ControlList[k].equals("ventil")) {
  12146. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12147. int[] ventilInfo = devSet.Get_Ventil_Info();
  12148. if (ventilInfo[0] == 1) {
  12149. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  12150. subunitcnt = "1";
  12151. devid = "0x61";
  12152. Vender = "null";
  12153. Model = "null";
  12154. if (VentilCTR != null) {
  12155. VentilCTR.TRInfo.GetTransactionList(0);
  12156. statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
  12157. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  12158. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12159. message = "null";
  12160. ControlDEVList += " <unit type=\"ventil\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12161. itemCNT++;
  12162. }
  12163. } else {
  12164. }
  12165. devSet.closeDB();
  12166. } else if (ControlList[k].equals("aircon")) {
  12167. } else if (ControlList[k].equals("curtain")) {
  12168. }
  12169. }
  12170. if (itemCNT > 0) {
  12171. ContentList += "<group type=\"ctrl_device\" count=\"" + itemCNT + "\">\r\n";
  12172. ContentList += ControlDEVList;
  12173. ContentList += "</group>\r\n";
  12174. totalGroup++;
  12175. totalItem += itemCNT;
  12176. }
  12177. }
  12178. } else if (typeList[i].equals("talk_device")) {
  12179. SettManager = new WallpadDevStatus(getApplicationContext());
  12180. ControlList = SettManager.GetSettingGroupData("talk_device");
  12181. SettManager.closeDB();
  12182. itemCNT = 0;
  12183. ControlDEVList = "";
  12184. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  12185. if (testAPI != null)
  12186. testAPI.GetVersion();
  12187. if (ControlList != null) {
  12188. for (int k = 0; k < ControlList.length; k++) {
  12189. if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
  12190. 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";
  12191. itemCNT++;
  12192. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  12193. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  12194. } else if (ControlList[k].equals("bath_phone") && testAPI != null) {
  12195. 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";
  12196. itemCNT++;
  12197. } else if (ControlList[k].equals("subhome_dev")) {
  12198. }
  12199. }
  12200. if (itemCNT > 0) {
  12201. ContentList += "<group type=\"talk_device\" count=\"" + itemCNT + "\">\r\n";
  12202. ContentList += ControlDEVList;
  12203. ContentList += "</group>\r\n";
  12204. totalGroup++;
  12205. totalItem += itemCNT;
  12206. }
  12207. }
  12208. } else if (typeList[i].equals("sensor")) {
  12209. SettManager = new WallpadDevStatus(getApplicationContext());
  12210. ControlList = SettManager.GetSettingGroupData("sensor");
  12211. SettManager.closeDB();
  12212. itemCNT = 0;
  12213. ControlDEVList = "";
  12214. if (ControlList != null) {
  12215. for (int k = 0; k < ControlList.length; k++) {
  12216. if (ControlList[k].equals("magnetic")) {
  12217. WallPadInterface wpifc = new WallPadInterface();
  12218. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  12219. String SenStateCom;
  12220. String SenStateType;
  12221. if (MagSen == 1) {
  12222. SenStateCom = "1/1";
  12223. SenStateType = "";
  12224. } else {
  12225. SenStateCom = "0/1";
  12226. SenStateType = "perfect";
  12227. }
  12228. ControlDEVList += " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12229. itemCNT++;
  12230. } else if (ControlList[k].equals("bugout")) {
  12231. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12232. int sensor = devSet.Get_Sensor_Set();
  12233. devSet.closeDB();
  12234. if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  12235. WallPadInterface wpifc = new WallPadInterface();
  12236. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12237. String SenStateCom;
  12238. String SenStateType;
  12239. if (outSen == 1) {
  12240. SenStateCom = "1/1";
  12241. SenStateType = "bad";
  12242. } else {
  12243. SenStateCom = "0/1";
  12244. SenStateType = "perfect";
  12245. }
  12246. ControlDEVList += " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12247. itemCNT++;
  12248. }
  12249. } else if (ControlList[k].equals("bugin")) {
  12250. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12251. int sensor = devSet.Get_Sensor_Set();
  12252. devSet.closeDB();
  12253. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
  12254. WallPadInterface wpifc = new WallPadInterface();
  12255. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12256. String SenStateCom;
  12257. String SenStateType;
  12258. if (InSen == 1) {
  12259. SenStateCom = "1/1";
  12260. SenStateType = "bad";
  12261. } else {
  12262. SenStateCom = "0/1";
  12263. SenStateType = "perfect";
  12264. }
  12265. ControlDEVList += " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
  12266. itemCNT++;
  12267. }
  12268. } else if (ControlList[k].equals("fire")) {
  12269. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12270. } else if (ControlList[k].equals("gas")) {
  12271. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  12272. }
  12273. }
  12274. if (itemCNT > 0) {
  12275. ContentList += "<group type=\"sensor\" count=\"" + itemCNT + "\">\r\n";
  12276. ContentList += ControlDEVList;
  12277. ContentList += "</group>\r\n";
  12278. totalGroup++;
  12279. totalItem += itemCNT;
  12280. }
  12281. }
  12282. } else if (typeList[i].equals("extended")) {
  12283. SettManager = new WallpadDevStatus(getApplicationContext());
  12284. ControlList = SettManager.GetSettingGroupData("extended");
  12285. SettManager.closeDB();
  12286. itemCNT = 0;
  12287. ControlDEVList = "";
  12288. if (ControlList != null) {
  12289. for (int k = 0; k < ControlList.length; k++) {
  12290. if (ControlList[k].equals("gateway")) {
  12291. } else if (ControlList[k].equals("handy")) {
  12292. } else if (ControlList[k].equals("smartswitch")) {
  12293. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12294. int[] BatchInfo = devSet.Get_BatchSW_Info();
  12295. devSet.closeDB();
  12296. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
  12297. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  12298. SmartSWCTR.TRInfo.GetTransactionList(0);
  12299. subunitcnt = "1";
  12300. statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
  12301. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  12302. statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
  12303. message = "null";
  12304. ControlDEVList += " <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
  12305. itemCNT++;
  12306. } else {
  12307. }
  12308. } else if (ControlList[k].equals("energymeter")) {
  12309. }
  12310. }
  12311. if (itemCNT > 0) {
  12312. ContentList += "<group type=\"extended\" count=\"" + itemCNT + "\">\r\n";
  12313. ContentList += ControlDEVList;
  12314. ContentList += "</group>\r\n";
  12315. totalGroup++;
  12316. totalItem += itemCNT;
  12317. }
  12318. }
  12319. }
  12320. }
  12321. SettManager.closeDB();
  12322. ContentList += "</guidemap> \r\n";
  12323. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\"" + totalGroup + "\" device_cnt=\"" + totalItem + "\">\r\n";
  12324. RetData += ContentList;
  12325. String LogSet;
  12326. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  12327. RetData += LogSet;
  12328. try {
  12329. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  12330. String[] ResetData = WsDB.GetResetSchedule();
  12331. WsDB.closeDB();
  12332. if (!ResetData[0].equals("NONE")) {
  12333. int type = Integer.parseInt(ResetData[0]);
  12334. if (type == WallpadStatusData.RESET_MONTH)
  12335. LogSet = "<reset_info enable=\"true\" type=\"month\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12336. else if (type == WallpadStatusData.RESET_WEEK)
  12337. LogSet = "<reset_info enable=\"true\" type=\"week\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
  12338. else
  12339. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12340. } else
  12341. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12342. } catch (RuntimeException re) {
  12343. LogUtil.errorLogInfo("", TAG, re);
  12344. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12345. } catch (Exception e) {
  12346. //e.printStackTrace();
  12347. LogUtil.errorLogInfo("", TAG, e);
  12348. LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12349. }
  12350. RetData += LogSet;
  12351. RetData += "</service>\r\n</imap>\r\n";
  12352. }
  12353. return RetData;
  12354. } catch (RuntimeException re) {
  12355. LogUtil.errorLogInfo("", TAG, re);
  12356. return null;
  12357. } catch (Exception e) {
  12358. //e.printStackTrace();
  12359. LogUtil.errorLogInfo("", TAG, e);
  12360. return null;
  12361. }
  12362. }
  12363. private String getKNXDeviceStatus(int device) {
  12364. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12365. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12366. String status = knxHeartbeat.getStatus();
  12367. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  12368. return status;
  12369. }
  12370. private String getKNXDeviceCause(int device) {
  12371. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12372. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12373. String cause = knxHeartbeat.getCause();
  12374. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  12375. return cause;
  12376. }
  12377. //mWallPadAPI
  12378. // private String TAG = "*yskim*";
  12379. //private IGW200dAPI iGW200dAPI = null;
  12380. /**
  12381. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12382. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12383. * 본 딜레이 코드를 임시로 적용한다.
  12384. */
  12385. @SuppressLint("HandlerLeak")
  12386. protected Handler IGW200APICheckHandler = new Handler() {
  12387. @SuppressLint("HandlerLeak")
  12388. @Override
  12389. public void handleMessage(Message msg) {
  12390. if (msg.what == 0) {
  12391. if (mWallPadAPI != null) {
  12392. Common.DebugLog("handleMessage what 0 ");
  12393. if (mWallPadAPI.Check_Connect())
  12394. IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12395. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12396. }
  12397. } else if (msg.what == 1) {
  12398. Common.DebugLog("handleMessage what 1 ");
  12399. setIGE200Interface();
  12400. }
  12401. }
  12402. };
  12403. public void setIGE200Interface() {
  12404. try {
  12405. Common.DebugLog("setIGE200Interface");
  12406. mIGW200 = new IGW200(this, mWallPadAPI);
  12407. } catch (RuntimeException re) {
  12408. LogUtil.errorLogInfo("", TAG, re);
  12409. } catch (Exception e) {
  12410. Log.e(TAG, "[Exception] setIGE200Interface()");
  12411. //e.printStackTrace();
  12412. LogUtil.errorLogInfo("", TAG, e);
  12413. }
  12414. }
  12415. /**
  12416. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12417. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12418. * 본 딜레이 코드를 임시로 적용한다.
  12419. */
  12420. @SuppressLint("HandlerLeak")
  12421. protected Handler IGW300APICheckHandler = new Handler() {
  12422. @SuppressLint("HandlerLeak")
  12423. @Override
  12424. public void handleMessage(Message msg) {
  12425. if (msg.what == 0) {
  12426. if (mWallPadAPI != null) {
  12427. Common.DebugLog("handleMessage what 0 ");
  12428. if (mWallPadAPI.Check_Connect())
  12429. IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12430. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12431. }
  12432. } else if (msg.what == 1) {
  12433. Common.DebugLog("handleMessage what 1 ");
  12434. setIGE300Interface();
  12435. }
  12436. }
  12437. };
  12438. public void setIGE300Interface() {
  12439. try {
  12440. Common.DebugLog("setIGE300Interface");
  12441. mIGW300 = new IGW300(this, mWallPadAPI);
  12442. } catch (RuntimeException re) {
  12443. LogUtil.errorLogInfo("", TAG, re);
  12444. } catch (Exception e) {
  12445. Log.e(TAG, "[Exception] setIGE300Interface()");
  12446. //e.printStackTrace();
  12447. LogUtil.errorLogInfo("", TAG, e);
  12448. }
  12449. }
  12450. // 외출모드 연동
  12451. private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
  12452. try {
  12453. bSmartSwitch485ComebackMode = false;
  12454. String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
  12455. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12456. String outLinkCtrl = wd.GetOutModeLinkDevice();
  12457. if (BedMode == true)
  12458. outLinkCtrl = wd.GetInBedLinkDevice();
  12459. wd.closeDB();
  12460. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  12461. if (WallpadUI == false) {
  12462. if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
  12463. {
  12464. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
  12465. CallElevatorBtn(false);
  12466. }
  12467. }
  12468. if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
  12469. {
  12470. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
  12471. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  12472. }
  12473. if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  12474. {
  12475. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
  12476. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  12477. }
  12478. if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  12479. {
  12480. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
  12481. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  12482. }
  12483. if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
  12484. {
  12485. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
  12486. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  12487. }
  12488. } catch (RuntimeException re) {
  12489. LogUtil.errorLogInfo("", TAG, re);
  12490. } catch (Exception e) {
  12491. Log.e("YSKIM", e.toString());
  12492. }
  12493. }
  12494. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  12495. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  12496. private boolean bSmartSwitch485ComebackMode = false;
  12497. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  12498. try {
  12499. if (bSmartSwitch485ComebackMode == true) return;
  12500. String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
  12501. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12502. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  12503. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  12504. wd.closeDB();
  12505. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  12506. // 일괄소등 해제
  12507. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
  12508. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  12509. }
  12510. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
  12511. // 환기동작
  12512. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
  12513. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  12514. }
  12515. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  12516. // 난방 외출모드 해제
  12517. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
  12518. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  12519. }
  12520. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  12521. // 웰컴조명 켜기
  12522. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
  12523. // 웰컴조명 Handler 실행
  12524. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  12525. }
  12526. } catch (RuntimeException re) {
  12527. LogUtil.errorLogInfo("", TAG, re);
  12528. } catch (Exception e) {
  12529. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  12530. //e.printStackTrace();
  12531. LogUtil.errorLogInfo("", TAG, e);
  12532. }
  12533. }
  12534. private Handler WelcomeLightHandler = new Handler() {
  12535. int LightOnCount = 0;
  12536. @Override
  12537. public void handleMessage(Message msg) {
  12538. if (msg.what == 0) {
  12539. try {
  12540. if (LightOnCount == 0) {
  12541. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  12542. }
  12543. // 일괄소등 해제이면
  12544. if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
  12545. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  12546. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  12547. } else {
  12548. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  12549. LightOnCount++;
  12550. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  12551. if (LightOnCount > 10) {
  12552. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  12553. LightOnCount = 0;
  12554. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  12555. }
  12556. }
  12557. } catch (RuntimeException re) {
  12558. LogUtil.errorLogInfo("", TAG, re);
  12559. } catch (Exception e1) {
  12560. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  12561. //e1.printStackTrace();
  12562. LogUtil.errorLogInfo("", TAG, e1);
  12563. }
  12564. } else if (msg.what == 1) {
  12565. try {
  12566. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  12567. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  12568. LightOnCount = 0;
  12569. } catch (RuntimeException re) {
  12570. LogUtil.errorLogInfo("", TAG, re);
  12571. } catch (Exception e1) {
  12572. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  12573. //e1.printStackTrace();
  12574. LogUtil.errorLogInfo("", TAG, e1);
  12575. }
  12576. } else if (msg.what == 2) {
  12577. // Do Nothing
  12578. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  12579. WelcomeLightHandler.removeMessages(0);
  12580. }
  12581. }
  12582. };
  12583. //방범 및 알람 상태 확인 Resume 시 처리
  12584. private void CheckMainStatus() {
  12585. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  12586. try {
  12587. final String packageName = "com.artncore.apps.ic_wallpad";
  12588. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  12589. //CallAppRun = getForegroundAPK().equals(packageName);
  12590. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  12591. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12592. int alarmstate = SetData.GetAlarmStatus();
  12593. SetData.closeDB();
  12594. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
  12595. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  12596. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
  12597. return;
  12598. } else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  12599. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  12600. int base = 7000;
  12601. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
  12602. int Menu_Start_Id = 0;
  12603. SetData = new WallpadStatusData(getApplicationContext());
  12604. int alarmtype = SetData.GetAlarmType();
  12605. SetData.closeDB();
  12606. switch (alarmtype) {
  12607. case WallpadStatusData.ALARM_ALERT:
  12608. Menu_Start_Id = Menu_Id_List[1];
  12609. break;
  12610. case WallpadStatusData.ALARM_EMM:
  12611. Menu_Start_Id = Menu_Id_List[0];
  12612. break;
  12613. case WallpadStatusData.ALARM_EVAC:
  12614. Menu_Start_Id = Menu_Id_List[3];
  12615. break;
  12616. case WallpadStatusData.ALARM_INVADE:
  12617. Menu_Start_Id = Menu_Id_List[2];
  12618. break;
  12619. case WallpadStatusData.ALARM_HEATING_LEAK:
  12620. Menu_Start_Id = Menu_Id_List[4];
  12621. break;
  12622. default:
  12623. Menu_Start_Id = Menu_Id_List[1];
  12624. break;
  12625. }
  12626. if (Menu_Start_Id > 0) {
  12627. /*
  12628. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  12629. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  12630. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  12631. * "RESUME"을 전달한다.
  12632. */
  12633. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12634. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12635. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12636. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  12637. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  12638. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12639. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12640. startActivity(newintent);
  12641. return;
  12642. }
  12643. } else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  12644. if (OutModeRunAppRun == true) {
  12645. Log.d(TAG, "already outmoderun app running !!!!");
  12646. return;
  12647. }
  12648. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12649. int sensor = devset.Get_Sensor_Set();
  12650. devset.closeDB();
  12651. int base = 7000;
  12652. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12653. int Menu_Start_Id = 0;
  12654. int Menu_Start_Option = 1;
  12655. if (sensor > 0) {
  12656. WallPadInterface wpifc = new WallPadInterface();
  12657. int[] SensorInfoDB;
  12658. int inSen = 0;
  12659. int outSen = 0;
  12660. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12661. if (SensorInfoDB[0] == 1) {
  12662. // 내부동체가 사용함이면 상태 검사
  12663. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12664. }
  12665. if (SensorInfoDB[1] == 1) {
  12666. // 외부동체가 사용함이면 상태 검사
  12667. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12668. }
  12669. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12670. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12671. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
  12672. ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  12673. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12674. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12675. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12676. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12677. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12678. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
  12679. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12680. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12681. startActivity(newintent);
  12682. return;
  12683. }
  12684. }
  12685. base = 8000;
  12686. Menu_Id_List = new int[]{base + 11};
  12687. Menu_Start_Id = base + 11;
  12688. Menu_Start_Option = -1;
  12689. Intent intent = new Intent(Intent.ACTION_MAIN);
  12690. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12691. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12692. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12693. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  12694. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12695. startActivity(intent);
  12696. } else if (alarmstate == WallpadStatusData.GUARD_IN) {
  12697. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12698. int sensor = devset.Get_Sensor_Set();
  12699. devset.closeDB();
  12700. int base = 7000;
  12701. int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
  12702. int Menu_Start_Option = 1;
  12703. if (sensor > 0) {
  12704. WallPadInterface wpifc = new WallPadInterface();
  12705. int[] SensorInfoDB;
  12706. int outSen = 0;
  12707. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12708. if (SensorInfoDB[1] == 1) {
  12709. // 외부동체가 사용함이면 상태 검사
  12710. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12711. }
  12712. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12713. if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
  12714. ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12715. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12716. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12717. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12718. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12719. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  12720. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12721. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12722. startActivity(newintent);
  12723. return;
  12724. }
  12725. }
  12726. } else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  12727. WallPadInterface wpifc = new WallPadInterface();
  12728. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  12729. return;
  12730. } else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  12731. int base = 4000;
  12732. int Menu_Start_Id = 0;
  12733. int[] Menu_Id_List = new int[]{base + 11, base + 21};
  12734. Menu_Start_Id = base + 11;
  12735. Intent intent = new Intent(Intent.ACTION_MAIN);
  12736. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12737. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12738. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  12739. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
  12740. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12741. startActivity(intent);
  12742. return;
  12743. }
  12744. } catch (RuntimeException re) {
  12745. LogUtil.errorLogInfo("", TAG, re);
  12746. } catch (Exception e) {
  12747. Log.e(TAG, "[Exception] CheckMainStatus()");
  12748. //e.printStackTrace();
  12749. LogUtil.errorLogInfo("", TAG, e);
  12750. }
  12751. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12752. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  12753. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12754. // {
  12755. // WallPadInterface wpifc = new WallPadInterface();
  12756. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  12757. //
  12758. // if (fleeSensor > 0)
  12759. // {
  12760. // int base = 7000;
  12761. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12762. // int Menu_Start_Option = 1;
  12763. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12764. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12765. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  12766. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12767. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  12768. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12769. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12770. // startActivity(newintent);
  12771. // devset.closeDB();
  12772. // return;
  12773. // }
  12774. // }
  12775. //
  12776. // StatusVal = devset.GetDeviceSetted("알람발생");
  12777. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12778. // {
  12779. // WallPadInterface wpifc = new WallPadInterface();
  12780. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  12781. //
  12782. // if (AlarmSensor > 0)
  12783. // {
  12784. // int base = 7000;
  12785. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12786. // int Menu_Start_Option = 1;
  12787. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12788. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12789. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  12790. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12791. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  12792. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12793. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12794. // startActivity(newintent);
  12795. // devset.closeDB();
  12796. // return;
  12797. // }
  12798. //
  12799. // }
  12800. // devset.closeDB();
  12801. }
  12802. /**
  12803. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  12804. *
  12805. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  12806. */
  12807. public boolean GetUseIlgalControlForAdmin() {
  12808. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12809. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  12810. devSet.closeDB();
  12811. boolean result = false;
  12812. if (MetringDB != null) {
  12813. try {
  12814. String devInfo = MetringDB[1];
  12815. devInfo = devInfo.replace('(', '_');
  12816. devInfo = devInfo.replace(':', '_');
  12817. devInfo = devInfo.replace(')', '_');
  12818. String[] MetringInfo = devInfo.split("_");
  12819. if (MetringInfo[3].equals("사용함") == true) {
  12820. result = true;
  12821. }
  12822. } catch (RuntimeException re) {
  12823. LogUtil.errorLogInfo("", TAG, re);
  12824. } catch (Exception e) {
  12825. //e.printStackTrace();
  12826. LogUtil.errorLogInfo("", TAG, e);
  12827. }
  12828. }
  12829. return result;
  12830. }
  12831. class SendLHGWCheck extends Thread {
  12832. private iMAP_hn_config_read m_HnGWConfigRead = null;
  12833. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  12834. private boolean retSucces = false;
  12835. private int retryCount = 0;
  12836. public SendLHGWCheck() {
  12837. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  12838. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  12839. retryCount = 0;
  12840. }
  12841. public void run() {
  12842. try {
  12843. try {
  12844. Thread.sleep(2000);
  12845. } catch (RuntimeException re) {
  12846. LogUtil.errorLogInfo("", TAG, re);
  12847. } catch (Exception e) {
  12848. LogUtil.errorLogInfo("", TAG, e);
  12849. }
  12850. for (int i = 0; i < 10; i++) {
  12851. m_HnGWConfigRead.DoWork();
  12852. m_HnGWConfigRead.SetRetCtr(new RetProci() {
  12853. @Override
  12854. public void ProcSuccess() {
  12855. retSucces = true;
  12856. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
  12857. }
  12858. @Override
  12859. public void ProcError() {
  12860. }
  12861. @Override
  12862. public void ProcDoing() {
  12863. // TODO Auto-generated method stub
  12864. }
  12865. });
  12866. if (retSucces == true)
  12867. break;
  12868. retryCount++;
  12869. try {
  12870. Thread.sleep(3000);
  12871. } catch (RuntimeException re) {
  12872. LogUtil.errorLogInfo("", TAG, re);
  12873. } catch (Exception e) {
  12874. LogUtil.errorLogInfo("", TAG, e);
  12875. }
  12876. }
  12877. m_HnGWEmptyMsg.DoWork();
  12878. m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
  12879. @Override
  12880. public void ProcSuccess() {
  12881. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
  12882. }
  12883. @Override
  12884. public void ProcError() {
  12885. Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
  12886. }
  12887. @Override
  12888. public void ProcDoing() {
  12889. // TODO Auto-generated method stub
  12890. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
  12891. }
  12892. });
  12893. } catch (RuntimeException re) {
  12894. LogUtil.errorLogInfo("", TAG, re);
  12895. } catch (Exception e) {
  12896. //e.printStackTrace();
  12897. LogUtil.errorLogInfo("", TAG, e);
  12898. }
  12899. }
  12900. }
  12901. //Reset Handler
  12902. private Handler mResetHandler = new Handler() {
  12903. @Override
  12904. public void handleMessage(Message msg) {
  12905. if (msg.what == 0) {
  12906. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  12907. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  12908. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  12909. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  12910. if (NowMainStatus == false) {
  12911. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12912. ResetCount = 1;
  12913. }
  12914. ResetCount++;
  12915. NowMainStatus = true;
  12916. if (ResetCount == 30) {
  12917. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12918. } else {
  12919. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12920. }
  12921. } else {
  12922. if (NowMainStatus == true) {
  12923. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12924. ResetCount = 1;
  12925. }
  12926. ResetCount++;
  12927. NowMainStatus = false;
  12928. if (ResetCount == 180) {
  12929. // 3분
  12930. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12931. } else {
  12932. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12933. }
  12934. }
  12935. } else if (msg.what == 1) {
  12936. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  12937. setDefaultLauncher();
  12938. Intent intent = new Intent();
  12939. intent.setAction(define.NOTIFY_ACNAME);
  12940. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12941. getApplicationContext().sendBroadcast(intent);
  12942. }
  12943. }
  12944. };
  12945. // 통화주체를 다루는 enum
  12946. public enum CALLOWNER {
  12947. NONE,
  12948. WALLPAD,
  12949. SUB_WALLPAD,
  12950. KITCHEN_TV,
  12951. BATH_PHONE,
  12952. BATH_TV,
  12953. UNIVERSAL_DEVICE,
  12954. ERROR;
  12955. }
  12956. public enum CALLEVENTTYPE {
  12957. RECEIVE_CALL, // 호출 수신 (호출 수신)
  12958. TRYING_CALL, // 호출 시도중 (호출 발신)
  12959. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  12960. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  12961. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  12962. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  12963. CONNECT_CALL, // 통화 시작
  12964. TERMINATE_CALL, // 통화 종료
  12965. CANCEL_CALL, // 호출 취소
  12966. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  12967. REJECT_CALL, // 호출수신 거절
  12968. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  12969. FORWARD_CALL, // 착신전환 설정
  12970. CALLERID, // Caller ID
  12971. TIMEOUT_1STCALL, // 1st Call Timeout
  12972. TIMEOUT_2NDCALL, // 2nd Call Timeout
  12973. TIMEOUT_3RDCALL, // 3rd Call Timeout
  12974. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  12975. DOOR_OPEN, // 문열림 설정
  12976. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  12977. PSTN_DTMF, // PSTN DTMF 수신
  12978. DETECT_STRANGER, // 거동수상자 발생
  12979. NONE;
  12980. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  12981. try {
  12982. if (value.equals(RECEIVE_CALL.toString())) {
  12983. return RECEIVE_CALL;
  12984. } else if (value.equals(TRYING_CALL.toString())) {
  12985. return TRYING_CALL;
  12986. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  12987. return RECEIVE_CALL_2ND;
  12988. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  12989. return RECEIVE_CALL_ACK;
  12990. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  12991. return REQUEST_FRONT_MONITORING;
  12992. } else if (value.equals(CONNECT_CALL.toString())) {
  12993. return CONNECT_CALL;
  12994. } else if (value.equals(TERMINATE_CALL.toString())) {
  12995. return TERMINATE_CALL;
  12996. } else if (value.equals(CANCEL_CALL.toString())) {
  12997. return CANCEL_CALL;
  12998. } else if (value.equals(REJECT_CALL.toString())) {
  12999. return REJECT_CALL;
  13000. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  13001. return REJECT_BUSY_CALL;
  13002. } else if (value.equals(FORWARD_CALL.toString())) {
  13003. return FORWARD_CALL;
  13004. } else if (value.equals(CALLERID.toString())) {
  13005. return CALLERID;
  13006. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  13007. return TIMEOUT_1STCALL;
  13008. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  13009. return TIMEOUT_2NDCALL;
  13010. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  13011. return TIMEOUT_3RDCALL;
  13012. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  13013. return MOIP_VIDEO_SET;
  13014. } else if (value.equals(DOOR_OPEN.toString())) {
  13015. return DOOR_OPEN;
  13016. } else if (value.equals(PSTN_RING.toString())) {
  13017. return PSTN_RING;
  13018. } else if (value.equals(PSTN_DTMF.toString())) {
  13019. return PSTN_DTMF;
  13020. } else if (value.equals(DETECT_STRANGER.toString())) {
  13021. return DETECT_STRANGER;
  13022. } else if (value.equals(NONE.toString())) {
  13023. return NONE;
  13024. } else {
  13025. return null;
  13026. }
  13027. } catch (RuntimeException re) {
  13028. LogUtil.errorLogInfo("", "", re);
  13029. return null;
  13030. } catch (Exception e) {
  13031. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  13032. //e.printStackTrace();
  13033. LogUtil.errorLogInfo("", "", e);
  13034. return null;
  13035. }
  13036. }
  13037. }
  13038. public enum CALLTYPE {
  13039. NONE,
  13040. FRONT,
  13041. RESIDENCE,
  13042. LOBBY,
  13043. GUARD,
  13044. PSTN,
  13045. IHUB,
  13046. ERROR,
  13047. }
  13048. public static class CALLTRIGGER {
  13049. public static String CALLOWNER = "CALLOWNER";
  13050. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  13051. public static String CALLTYPE = "CALLTYPE";
  13052. public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
  13053. public enum SOURCE {
  13054. USER,
  13055. CALL_RECEIVE,
  13056. SUBPHONE
  13057. }
  13058. public enum TYPE {
  13059. MENU,
  13060. FRONT,
  13061. LOBBY,
  13062. GUARD,
  13063. RESIDENCE,
  13064. PSTN
  13065. }
  13066. }
  13067. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  13068. int TAB_TALKFRONT = 130011;
  13069. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  13070. try {
  13071. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
  13072. if (!bWallPadCallLive) {
  13073. sendLCDBacklightStatus(true);
  13074. // 통화어플을 실행시킨다.
  13075. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  13076. Common.SendAppFinishReqBR(getApplicationContext());
  13077. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  13078. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  13079. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  13080. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  13081. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  13082. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  13083. mIntent.setComponent(mComponentName);
  13084. startActivity(mIntent);
  13085. playFrontBell(eCallOwner, eEventType, eCallType);
  13086. } else {
  13087. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  13088. // if (getUseSmartDoorCam()) {
  13089. // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
  13090. // }
  13091. }
  13092. } catch (RuntimeException re) {
  13093. LogUtil.errorLogInfo("", TAG, re);
  13094. } catch (Exception e) {
  13095. Log.e(TAG, "[Exception] runCallMainActivity()");
  13096. //e.printStackTrace();
  13097. LogUtil.errorLogInfo("", TAG, e);
  13098. }
  13099. }
  13100. //add KSJ 2021.11.02
  13101. public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
  13102. try {
  13103. if (!bWallPadCallLive || m_bWallpadCallScreen) {
  13104. // 통화어플을 실행시킨다.
  13105. Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
  13106. sendLCDBacklightStatus(true);
  13107. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13108. int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
  13109. mWallpadStatusData.closeDB();
  13110. if (nAlramStatus != WallpadStatusData.GUARD_OUT)
  13111. Common.SendAppFinishReqBR(getApplicationContext());
  13112. if(m_bWallpadCallScreen)
  13113. Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  13114. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  13115. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  13116. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  13117. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  13118. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  13119. mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
  13120. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  13121. mIntent.setComponent(mComponentName);
  13122. startActivity(mIntent);
  13123. Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
  13124. new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
  13125. @Override
  13126. public void run() {
  13127. Log.w(TAG, "[runCallMainActivity_moip] m_CallAppRunDelay " + m_CallAppRunDelay);
  13128. m_CallAppRunDelay = false;
  13129. }
  13130. }, 3000);
  13131. } else {
  13132. Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
  13133. m_CallAppRunDelay = false;
  13134. }
  13135. } catch (RuntimeException re) {
  13136. LogUtil.errorLogInfo("", TAG, re);
  13137. } catch (Exception e) {
  13138. Log.e(TAG, "[Exception] runCallMainActivity()");
  13139. //e.printStackTrace();
  13140. LogUtil.errorLogInfo("", TAG, e);
  13141. }
  13142. }
  13143. //~add KSJ
  13144. private String getTopActivity() {
  13145. try {
  13146. ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  13147. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  13148. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  13149. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  13150. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  13151. return mComponentName.getPackageName();
  13152. } catch (RuntimeException re) {
  13153. LogUtil.errorLogInfo("", TAG, re);
  13154. return null;
  13155. } catch (Exception e) {
  13156. Log.e(TAG, "[Exception] getTopActivity()");
  13157. //e.printStackTrace();
  13158. LogUtil.errorLogInfo("", TAG, e);
  13159. return null;
  13160. }
  13161. }
  13162. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  13163. try {
  13164. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  13165. WallPadInterface Wiface = new WallPadInterface();
  13166. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  13167. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  13168. }
  13169. } catch (RuntimeException re) {
  13170. LogUtil.errorLogInfo("", TAG, re);
  13171. } catch (Exception e) {
  13172. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  13173. //e.printStackTrace();
  13174. LogUtil.errorLogInfo("", TAG, e);
  13175. }
  13176. }
  13177. private class AfterTransactionTodoListData {
  13178. String Title;
  13179. int Valueint;
  13180. String ValueString;
  13181. private AfterTransactionTodoListData(String title, int valueint, String valueString) {
  13182. Title = title;
  13183. Valueint = valueint;
  13184. ValueString = valueString;
  13185. }
  13186. }
  13187. /**
  13188. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  13189. **/
  13190. public void SendGetParkingInfoIntent() {
  13191. Intent iIntent = new Intent();
  13192. iIntent.setAction(define.NOTIFY_ACNAME);
  13193. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  13194. this.sendBroadcast(iIntent);
  13195. }
  13196. /**
  13197. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  13198. **/
  13199. public Handler SendParkingInfoIntentAfter20min = new Handler() {
  13200. @SuppressLint("HandlerLeak")
  13201. @Override
  13202. public void handleMessage(Message msg) {
  13203. if (msg.what == 0) {
  13204. SendGetParkingInfoIntent();
  13205. }
  13206. }
  13207. };
  13208. /**
  13209. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  13210. **/
  13211. public Handler mWallPadOutmodeSleepHandler = new Handler() {
  13212. @SuppressLint("HandlerLeak")
  13213. @Override
  13214. public void handleMessage(Message msg) {
  13215. if (msg.what == 0) {
  13216. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  13217. }
  13218. }
  13219. };
  13220. // Handler
  13221. public final class HANDLERMSG {
  13222. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  13223. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  13224. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  13225. public final static int CALLAPP_FINISHING_END = 300;
  13226. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  13227. }
  13228. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  13229. public void handleMessage(Message msg) {
  13230. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  13231. switch (msg.what) {
  13232. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  13233. bGlobalScreenRun = true;
  13234. break;
  13235. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  13236. bGlobalScreenRun = false;
  13237. break;
  13238. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  13239. break;
  13240. case HANDLERMSG.CALLAPP_FINISHING_END:
  13241. // bBlockCallEvent = false;
  13242. break;
  13243. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  13244. int time = Sound().PlayMent(SND.call.DINGDONG);
  13245. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  13246. if (time < 0) time = 2088;
  13247. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  13248. break;
  13249. default:
  13250. Log.v(TAG, "iMAPServerHandler : " + msg.what);
  13251. break;
  13252. }
  13253. }
  13254. };
  13255. public void sendHandlerMsg(int what, int arg1, int arg2) {
  13256. try {
  13257. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  13258. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13259. HandleMsg.what = what;
  13260. HandleMsg.arg1 = arg1;
  13261. HandleMsg.arg2 = arg2;
  13262. iMAPServerHandler.sendMessage(HandleMsg);
  13263. } catch (RuntimeException re) {
  13264. LogUtil.errorLogInfo("", TAG, re);
  13265. } catch (Exception e) {
  13266. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  13267. //e.printStackTrace();
  13268. LogUtil.errorLogInfo("", TAG, e);
  13269. }
  13270. }
  13271. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  13272. try {
  13273. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  13274. Message HandleMsg = iMAPServerHandler.obtainMessage();
  13275. HandleMsg.what = what;
  13276. HandleMsg.arg1 = arg1;
  13277. HandleMsg.arg2 = arg2;
  13278. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  13279. } catch (RuntimeException re) {
  13280. LogUtil.errorLogInfo("", TAG, re);
  13281. } catch (Exception e) {
  13282. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  13283. //e.printStackTrace();
  13284. LogUtil.errorLogInfo("", TAG, e);
  13285. }
  13286. }
  13287. int mSensitivity = 0, mDuration = 0;
  13288. int MIN_SENSOR_SENSITIVITY = 1;
  13289. int MAX_SENSOR_SENSITIVITY = 5;
  13290. int MIN_SENSOR_DURATION = 30;
  13291. int MAX_SENSOR_DURATION = 250;
  13292. int DEFAULT_SENSOR_SENSITIVITY = 3;
  13293. int DEFAULT_SENSOR_DURATION = 60;
  13294. private final int COMPONENT_USE = 1;
  13295. /**
  13296. * 스마트현관카메라 사용여부 판별
  13297. */
  13298. private boolean getUseSmartDoorCam() {
  13299. try {
  13300. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13301. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13302. mWallpadDeviceSet.closeDB();
  13303. if (nFrontCam[0] == COMPONENT_USE) {
  13304. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  13305. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  13306. return true;
  13307. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  13308. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  13309. return true;
  13310. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13311. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  13312. return true;
  13313. } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  13314. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  13315. return true;
  13316. } else {
  13317. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  13318. return false;
  13319. }
  13320. } else {
  13321. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  13322. return false;
  13323. }
  13324. } catch (RuntimeException re) {
  13325. LogUtil.errorLogInfo("", TAG, re);
  13326. return false;
  13327. } catch (Exception e) {
  13328. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  13329. //e.printStackTrace();
  13330. LogUtil.errorLogInfo("", TAG, e);
  13331. return false;
  13332. }
  13333. }
  13334. private int getSmartDoorCamType() {
  13335. try {
  13336. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13337. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13338. mWallpadDeviceSet.closeDB();
  13339. if (nFrontCam[0] == COMPONENT_USE) {
  13340. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13341. return nFrontCam[1];
  13342. }
  13343. }
  13344. } catch (RuntimeException re) {
  13345. LogUtil.errorLogInfo("", TAG, re);
  13346. } catch (Exception e) {
  13347. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  13348. //e.printStackTrace();
  13349. LogUtil.errorLogInfo("", TAG, e);
  13350. }
  13351. return -1;
  13352. }
  13353. /**
  13354. * 방문객원격통화 솔루션 사용여부 판별
  13355. */
  13356. private boolean getRemoteCallUseInfo() {
  13357. try {
  13358. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13359. if (mWallpadDeviceSet != null) {
  13360. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  13361. if (astrRemoteCall != null) {
  13362. if (astrRemoteCall[1].contains("사용함")) return true;
  13363. } else {
  13364. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  13365. }
  13366. }
  13367. mWallpadDeviceSet.closeDB();
  13368. } catch (RuntimeException re) {
  13369. LogUtil.errorLogInfo("", TAG, re);
  13370. } catch (Exception e) {
  13371. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  13372. //e.printStackTrace();
  13373. LogUtil.errorLogInfo("", TAG, e);
  13374. }
  13375. return false;
  13376. }
  13377. /*
  13378. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  13379. */
  13380. private RealTimeMeterAPI mRealTimeMeterAPI;
  13381. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  13382. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  13383. public Thread saveRealmeterDataThread = null;
  13384. private void startRealtimemeterInfo() {
  13385. try {
  13386. // 영업샘플 모드 판단
  13387. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13388. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  13389. } else {
  13390. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  13391. // 실시간 검침기 사용유무 판단
  13392. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13393. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13394. mWallpadDeviceSet.closeDB();
  13395. boolean bRealtimemeterUsage = false;
  13396. int nRealtimemeterCntDB = -99;
  13397. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  13398. // 실시간 검침 사용함
  13399. bRealtimemeterUsage = true;
  13400. nRealtimemeterCntDB = naRealtimemtInfo[1];
  13401. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  13402. } else {
  13403. // 실시간 검침 사용하지 않음
  13404. bRealtimemeterUsage = false;
  13405. }
  13406. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
  13407. }
  13408. } catch (RuntimeException re) {
  13409. LogUtil.errorLogInfo("", TAG, re);
  13410. } catch (Exception e) {
  13411. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  13412. //e.printStackTrace();
  13413. LogUtil.errorLogInfo("", TAG, e);
  13414. }
  13415. }
  13416. private void startSmartIoTCamInfo() {
  13417. try {
  13418. // 영업샘플 모드 판단
  13419. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13420. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  13421. } else {
  13422. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  13423. if (getUseSmartDoorCam()) {
  13424. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  13425. } else {
  13426. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  13427. }
  13428. }
  13429. } catch (RuntimeException re) {
  13430. LogUtil.errorLogInfo("", TAG, re);
  13431. } catch (Exception e) {
  13432. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  13433. //e.printStackTrace();
  13434. LogUtil.errorLogInfo("", TAG, e);
  13435. }
  13436. }
  13437. private void startDistributionPanel() {
  13438. try {
  13439. // 영업샘플 모드 판단
  13440. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  13441. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  13442. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  13443. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  13444. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13445. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  13446. mWallpadDeviceSet.closeDB();
  13447. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
  13448. initSmartDistributionPanelHandler.sendEmptyMessage(0);
  13449. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
  13450. initKNXDistributionPanelHandler.sendEmptyMessage(0);
  13451. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  13452. } else {
  13453. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  13454. }
  13455. } catch (RuntimeException re) {
  13456. LogUtil.errorLogInfo("", TAG, re);
  13457. } catch (Exception e) {
  13458. Log.e(TAG, "[Exception] startDistributionPanel()");
  13459. //e.printStackTrace();
  13460. LogUtil.errorLogInfo("", TAG, e);
  13461. }
  13462. }
  13463. // =================================================================================================
  13464. // [[ Device ]] region
  13465. // =================================================================================================
  13466. /**
  13467. * 디바이스 API 를 Load 한다.
  13468. *
  13469. * @param wpapi - 생성시 전달받은 WallPadAPI
  13470. * @return (int) - >=0 : 성공, <0 : 실패
  13471. */
  13472. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  13473. // 1. Mode Check
  13474. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13475. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  13476. return -1;
  13477. }
  13478. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  13479. // 2. wpapi Check
  13480. if (wpapi == null) {
  13481. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  13482. return -2;
  13483. }
  13484. // 3. Load API
  13485. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  13486. try {
  13487. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  13488. } catch (RuntimeException re) {
  13489. LogUtil.errorLogInfo("", TAG, re);
  13490. return -100;
  13491. } catch (Exception e) {
  13492. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  13493. //e.printStackTrace();
  13494. LogUtil.errorLogInfo("", TAG, e);
  13495. return -100;
  13496. }
  13497. if (mRealTimeMeterAPI == null) {
  13498. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  13499. return -4;
  13500. }
  13501. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  13502. return 0;
  13503. }
  13504. /**
  13505. * 제어기 상태를 가져온다.
  13506. *
  13507. * @param real - (boolean) true : 실시간 , false : 가장최근
  13508. * @return (int) - >=0 : 성공, <0 : 실패
  13509. */
  13510. @SuppressWarnings("unused")
  13511. private int updateRealtimemeterData(boolean real) {
  13512. try {
  13513. // 1. Api Load Check
  13514. if (mRealTimeMeterAPI == null) {
  13515. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  13516. return -1;
  13517. }
  13518. // 2. reflash
  13519. try {
  13520. int ret = mRealTimeMeterAPI.Refresh(real);
  13521. if (ret < 0) {
  13522. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  13523. return -2;
  13524. }
  13525. } catch (RuntimeException re) {
  13526. LogUtil.errorLogInfo("", TAG, re);
  13527. return -100;
  13528. } catch (Exception e) {
  13529. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  13530. //e.printStackTrace();
  13531. LogUtil.errorLogInfo("", TAG, e);
  13532. return -100;
  13533. }
  13534. // 3. Range Check
  13535. if (mRealTimeMeterAPI.data == null) {
  13536. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  13537. return -9;
  13538. }
  13539. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  13540. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  13541. return -10;
  13542. }
  13543. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  13544. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  13545. return -11;
  13546. }
  13547. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  13548. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  13549. return -12;
  13550. }
  13551. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  13552. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  13553. return -13;
  13554. }
  13555. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  13556. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  13557. return -14;
  13558. }
  13559. // 4. Data Copy
  13560. mRealTimeMeterData = mRealTimeMeterAPI.data;
  13561. // 5. Debug msg
  13562. if (DEBUG_REALMETER_DATA_LOG_ON) {
  13563. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  13564. Log.i(TAG, "[updateRealtimemeterData] - OK");
  13565. }
  13566. return 0;
  13567. } catch (RuntimeException re) {
  13568. LogUtil.errorLogInfo("", TAG, re);
  13569. return -99;
  13570. } catch (Exception e) {
  13571. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  13572. //e.printStackTrace();
  13573. LogUtil.errorLogInfo("", TAG, e);
  13574. return -99;
  13575. }
  13576. }
  13577. /**
  13578. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  13579. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  13580. * 본 딜레이 코드를 임시로 적용한다.
  13581. */
  13582. @SuppressLint("HandlerLeak")
  13583. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  13584. @SuppressLint("HandlerLeak")
  13585. @Override
  13586. public void handleMessage(Message msg) {
  13587. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  13588. if (msg.what == 0) {
  13589. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  13590. if (updateRealtimemeterData(false) == 0) {
  13591. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13592. } else {
  13593. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13594. }
  13595. } else {
  13596. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  13597. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13598. }
  13599. } else if (msg.what == 1) {
  13600. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  13601. if (mRealTimeMeterAPI != null) {
  13602. // Device_BrRegistration(true);
  13603. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13604. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13605. mWallpadDeviceSet.closeDB();
  13606. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  13607. saveRealmeterDataThread = new saveRealmeterData();
  13608. saveRealmeterDataThread.start();
  13609. }
  13610. // RemoveUsedData();
  13611. // ShowUsedDataGraph();
  13612. }
  13613. }
  13614. }
  13615. };
  13616. protected Handler initSmartDistributionPanelHandler = new Handler() {
  13617. @SuppressLint("HandlerLeak")
  13618. @Override
  13619. public void handleMessage(Message msg) {
  13620. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  13621. if (msg.what == 0) {
  13622. if (mWallPadAPI.Check_Connect())
  13623. initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13624. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13625. } else if (msg.what == 1) {
  13626. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  13627. mSdbAPI = mWallPadAPI.Get_SdbController();
  13628. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  13629. mSdb_LivingRoomLightAPI.Refresh();
  13630. }
  13631. }
  13632. };
  13633. protected Handler initKNXDistributionPanelHandler = new Handler() {
  13634. @SuppressLint("HandlerLeak")
  13635. @Override
  13636. public void handleMessage(Message msg) {
  13637. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  13638. if (msg.what == 0) {
  13639. if (mWallPadAPI.Check_Connect())
  13640. initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13641. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13642. } else if (msg.what == 1) {
  13643. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  13644. mKnxAPI = mWallPadAPI.Get_KnxController();
  13645. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  13646. mKnx_LivingRoomLightAPI.Refresh();
  13647. }
  13648. }
  13649. };
  13650. protected Handler initSmartIoTFunctionHandler = new Handler() {
  13651. @SuppressLint("HandlerLeak")
  13652. @Override
  13653. public void handleMessage(Message msg) {
  13654. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  13655. if (msg.what == 0) {
  13656. if (mWallPadAPI.Check_Connect())
  13657. initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13658. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  13659. } else if (msg.what == 1) {
  13660. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  13661. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  13662. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
  13663. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
  13664. Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
  13665. // 거동수상자 녹화를 위한 자동 On 기능 비활성화
  13666. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  13667. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  13668. }
  13669. }
  13670. };
  13671. // 스마트현관카메라 MODE 제어
  13672. private void ctrlSmartIOTCamStatusMode(byte mode) {
  13673. try {
  13674. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  13675. if (mSmartKeyRfDoorAPI != null) {
  13676. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  13677. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  13678. } else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  13679. } catch (RuntimeException re) {
  13680. LogUtil.errorLogInfo("", TAG, re);
  13681. } catch (Exception e) {
  13682. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  13683. //e.printStackTrace();
  13684. LogUtil.errorLogInfo("", TAG, e);
  13685. }
  13686. }
  13687. // 스마트현관카메라 LED 상태 제어
  13688. private void ctrlSmartIOTCamLEDMode(byte mode) {
  13689. try {
  13690. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  13691. if (mSmartKeyRfDoorAPI != null) {
  13692. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  13693. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  13694. } else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  13695. } catch (RuntimeException re) {
  13696. LogUtil.errorLogInfo("", TAG, re);
  13697. } catch (Exception e) {
  13698. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  13699. //e.printStackTrace();
  13700. LogUtil.errorLogInfo("", TAG, e);
  13701. }
  13702. }
  13703. // 현관카메라 거동수상자 감지시간
  13704. private byte getSmartDoorCamDuration() {
  13705. try {
  13706. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
  13707. byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
  13708. wallpadDeviceSet.closeDB();
  13709. Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
  13710. return duration;
  13711. } catch (RuntimeException re) {
  13712. LogUtil.errorLogInfo("", TAG, re);
  13713. } catch (Exception e) {
  13714. Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
  13715. //e.printStackTrace();
  13716. LogUtil.errorLogInfo("", TAG, e);
  13717. }
  13718. return (byte) 0x05;
  13719. }
  13720. // =================================================================================================
  13721. // [[ Thread ]] region
  13722. // =================================================================================================
  13723. /**
  13724. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  13725. * 10분에 한번씩 저장
  13726. */
  13727. @SuppressLint("UseValueOf")
  13728. class saveRealmeterData extends Thread {
  13729. @Override
  13730. public void run() {
  13731. super.run();
  13732. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  13733. int ret;
  13734. wallpaddbmgr WallpadDBMGRforThread = null;
  13735. while (true) {
  13736. try {
  13737. Thread.sleep(1000 * 60 * 3); //3분마다
  13738. if (mRealTimeMeterAPI != null) {
  13739. ret = mRealTimeMeterAPI.Refresh(false);
  13740. if (ret == 0) {
  13741. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  13742. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
  13743. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  13744. WallpadDBMGRforThread.InsertRealTimeMeterData(
  13745. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  13746. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  13747. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  13748. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  13749. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  13750. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  13751. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  13752. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  13753. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  13754. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  13755. );
  13756. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  13757. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
  13758. if (tempInt > 6000) {
  13759. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  13760. }
  13761. WallpadDBMGRforThread.closeDB();
  13762. } else {
  13763. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  13764. }
  13765. } else {
  13766. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  13767. }
  13768. } catch (InterruptedException e1) {
  13769. // TODO Auto-generated catch block
  13770. if (WallpadDBMGRforThread != null) {
  13771. WallpadDBMGRforThread.closeDB();
  13772. }
  13773. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  13774. //e1.printStackTrace();
  13775. LogUtil.errorLogInfo("", TAG, e1);
  13776. }
  13777. }
  13778. }
  13779. }
  13780. /**
  13781. * 단지서버 2.0 사용여부
  13782. *
  13783. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  13784. **/
  13785. public boolean NewServerUse() {
  13786. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  13787. if (SetData != null) {
  13788. String serverVesionInfo = SetData.GetServerVer();
  13789. SetData.closeDB();
  13790. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  13791. return true;
  13792. }
  13793. }
  13794. return false;
  13795. }
  13796. /**
  13797. * 단지서버2.0 적용시에만 사용한다.
  13798. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  13799. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  13800. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  13801. **/
  13802. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  13803. String REMOTETYPE_SVR2WEB = "danji_web_control";
  13804. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  13805. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  13806. try {
  13807. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13808. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13809. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13810. NodeList mNodeList = doc.getElementsByTagName("device_info");
  13811. Node mNode = mNodeList.item(0);
  13812. if (mNode != null) {
  13813. String alias = "null", twinid = "null";
  13814. NamedNodeMap attrsParam = mNode.getAttributes();
  13815. for (int j = 0; j < attrsParam.getLength(); j++) {
  13816. Node attr = attrsParam.item(j);
  13817. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13818. alias = attr.getNodeValue();
  13819. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13820. twinid = attr.getNodeValue();
  13821. }
  13822. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13823. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13824. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  13825. return MOBILE_USER_AUTH_PASSED;
  13826. }
  13827. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13828. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13829. mWallpadMobileDeviceData.closeDB();
  13830. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13831. else {
  13832. //Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  13833. //닫은 DB에 접근하여서 수정.
  13834. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + nCheckResult + "]");
  13835. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13836. return strReplyMsg;
  13837. }
  13838. } else {
  13839. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13840. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13841. return strReplyMsg;
  13842. }
  13843. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13844. NodeList mNodeList = doc.getElementsByTagName("password_info");
  13845. Node mNode = mNodeList.item(0);
  13846. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13847. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13848. mWallpadStatusData.closeDB();
  13849. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
  13850. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13851. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13852. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13853. return strReplyMsg;
  13854. }
  13855. if (mNode != null) {
  13856. String strReceivedPW = "000000";
  13857. NamedNodeMap attrsParam = mNode.getAttributes();
  13858. for (int j = 0; j < attrsParam.getLength(); j++) {
  13859. Node attr = attrsParam.item(j);
  13860. if (attr.getNodeName().equalsIgnoreCase("password"))
  13861. strReceivedPW = attr.getNodeValue();
  13862. }
  13863. if (!checkPWValidation(strReceivedPW)) {
  13864. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13865. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13866. return strReplyMsg;
  13867. }
  13868. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13869. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13870. return WEB_USER_AUTH_PASSED;
  13871. } else {
  13872. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13873. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13874. return strReplyMsg;
  13875. }
  13876. } else {
  13877. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13878. strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
  13879. return strReplyMsg;
  13880. }
  13881. } else {
  13882. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13883. strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
  13884. return strReplyMsg;
  13885. }
  13886. } catch (RuntimeException re) {
  13887. LogUtil.errorLogInfo("", TAG, re);
  13888. return null;
  13889. } catch (Exception e) {
  13890. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  13891. //e.printStackTrace();
  13892. LogUtil.errorLogInfo("", TAG, e);
  13893. return null;
  13894. }
  13895. }
  13896. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  13897. try {
  13898. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13899. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13900. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13901. NodeList mNodeList = ele.getElementsByTagName("device_info");
  13902. Node mNode = mNodeList.item(0);
  13903. if (mNode != null) {
  13904. String alias = "null", twinid = "null";
  13905. NamedNodeMap attrsParam = mNode.getAttributes();
  13906. for (int j = 0; j < attrsParam.getLength(); j++) {
  13907. Node attr = attrsParam.item(j);
  13908. if (attr.getNodeName().equalsIgnoreCase("alias"))
  13909. alias = attr.getNodeValue();
  13910. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  13911. twinid = attr.getNodeValue();
  13912. }
  13913. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13914. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13915. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  13916. return MOBILE_USER_AUTH_PASSED;
  13917. }
  13918. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13919. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13920. mWallpadMobileDeviceData.closeDB();
  13921. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13922. else {
  13923. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  13924. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  13925. return strReplyMsg;
  13926. }
  13927. } else {
  13928. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13929. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13930. return strReplyMsg;
  13931. }
  13932. } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13933. NodeList mNodeList = ele.getElementsByTagName("password_info");
  13934. Node mNode = mNodeList.item(0);
  13935. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13936. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13937. mWallpadStatusData.closeDB();
  13938. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13939. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13940. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13941. return strReplyMsg;
  13942. }
  13943. if (mNode != null) {
  13944. String strReceivedPW = "000000";
  13945. NamedNodeMap attrsParam = mNode.getAttributes();
  13946. for (int j = 0; j < attrsParam.getLength(); j++) {
  13947. Node attr = attrsParam.item(j);
  13948. if (attr.getNodeName().equalsIgnoreCase("password"))
  13949. strReceivedPW = attr.getNodeValue();
  13950. }
  13951. if (!checkPWValidation(strReceivedPW)) {
  13952. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13953. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13954. return strReplyMsg;
  13955. }
  13956. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13957. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13958. return WEB_USER_AUTH_PASSED;
  13959. } else {
  13960. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13961. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13962. return strReplyMsg;
  13963. }
  13964. } else {
  13965. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13966. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13967. return strReplyMsg;
  13968. }
  13969. } else {
  13970. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13971. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13972. return strReplyMsg;
  13973. }
  13974. } catch (RuntimeException re) {
  13975. LogUtil.errorLogInfo("", TAG, re);
  13976. return null;
  13977. } catch (Exception e) {
  13978. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  13979. //e.printStackTrace();
  13980. LogUtil.errorLogInfo("", TAG, e);
  13981. return null;
  13982. }
  13983. }
  13984. String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
  13985. private boolean checkPWValidation(String strPW) {
  13986. try {
  13987. // null 확인
  13988. if (strPW == null) {
  13989. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  13990. return false;
  13991. }
  13992. // 입력된 비밀번호 길이 확인
  13993. if (strPW.length() != 6) {
  13994. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  13995. return false;
  13996. }
  13997. // 사전 금지된 비밀번호 확인
  13998. for (int i = 0; i < astrPreventedPWs.length; i++) {
  13999. if (strPW.contains(astrPreventedPWs[i])) {
  14000. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  14001. return false;
  14002. }
  14003. }
  14004. /*// 연속된 비밀번호 확인
  14005. int nSerialNoCnt = 0;
  14006. int nCompareNo = 0;
  14007. int[] naPW = new int[strPW.length()];
  14008. for (int i = 0; i < naPW.length; i++)
  14009. {
  14010. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  14011. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  14012. if (i ==0) {
  14013. nCompareNo = naPW[i];
  14014. nCompareNo++;
  14015. }
  14016. else if (0 < i && i < 6) {
  14017. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  14018. nCompareNo++;
  14019. }
  14020. else {
  14021. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  14022. }
  14023. }
  14024. if (nSerialNoCnt > 3) {
  14025. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  14026. return false;
  14027. }*/
  14028. // 동일한 번호 5회이상 입력 확인
  14029. int nSameNoCnt = 0;
  14030. for (int i = 0; i < strPW.length() - 1; i++) {
  14031. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  14032. nSameNoCnt++;
  14033. }
  14034. }
  14035. if (nSameNoCnt > 4) {
  14036. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  14037. return false;
  14038. }
  14039. // 동, 호정보 확인
  14040. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  14041. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  14042. DBMGR.closeDB();
  14043. String strDong = addr.Dong;
  14044. String strHo = addr.Ho;
  14045. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  14046. if (strPW.substring(0, 4).contains(strDong)) {
  14047. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  14048. return false;
  14049. }
  14050. if (strPW.substring(0, 4).contains(strHo)) {
  14051. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  14052. return false;
  14053. }
  14054. return true;
  14055. } catch (RuntimeException re) {
  14056. LogUtil.errorLogInfo("", TAG, re);
  14057. return false;
  14058. } catch (Exception e) {
  14059. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  14060. //e.printStackTrace();
  14061. LogUtil.errorLogInfo("", TAG, e);
  14062. return false;
  14063. }
  14064. }
  14065. public String iCMDProcOnePass(Element ele) {
  14066. String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
  14067. String[] strDeviceInfo = {"null", "null"}; // alias, twinid
  14068. String strAction = "null", strTargetLobbyIP = "null";
  14069. try {
  14070. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  14071. String retStr = CheckiCMDProc("remote_access_onepass");
  14072. if (retStr != null)
  14073. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  14074. // 단지서버 2.0 사용여부 확인
  14075. if (!NewServerUse()) {
  14076. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  14077. }
  14078. // 메시지 송신지 구분
  14079. NodeList items = ele.getElementsByTagName("target");
  14080. Node item = items.item(0);
  14081. if (item != null) {
  14082. NamedNodeMap attrs = item.getAttributes();
  14083. for (int j = 0; j < attrs.getLength(); j++) {
  14084. Node attr = attrs.item(j);
  14085. if (attr.getNodeName().equalsIgnoreCase("name"))
  14086. strTarget[0] = attr.getNodeValue();
  14087. else if (attr.getNodeName().equalsIgnoreCase("id"))
  14088. strTarget[1] = attr.getNodeValue();
  14089. else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
  14090. strTarget[2] = attr.getNodeValue();
  14091. }
  14092. }
  14093. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  14094. if (NewServerUse()) {
  14095. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  14096. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  14097. if (ServerCheckResult.contains("fail"))
  14098. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14099. else if (ServerCheckResult.contains("deny"))
  14100. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  14101. else if (ServerCheckResult.contains("none"))
  14102. return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  14103. else
  14104. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14105. }
  14106. }
  14107. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  14108. Node itemDeviceParam = itemsDeviceParam.item(0);
  14109. if (itemDeviceParam != null) {
  14110. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  14111. for (int j = 0; j < attrsParam.getLength(); j++) {
  14112. Node attr = attrsParam.item(j);
  14113. if (attr.getNodeName().equalsIgnoreCase("alias"))
  14114. strDeviceInfo[0] = attr.getNodeValue();
  14115. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  14116. strDeviceInfo[1] = attr.getNodeValue();
  14117. }
  14118. } else {
  14119. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14120. }
  14121. // 명령어 구분
  14122. NodeList itemsaction = ele.getElementsByTagName("action");
  14123. Node itemaction = itemsaction.item(0);
  14124. Node text = itemaction.getFirstChild();
  14125. strAction = text.getNodeValue();
  14126. strAction = trimquotation(strAction);
  14127. // 문열림 타겟 로비폰 IP
  14128. NodeList itemsParam = ele.getElementsByTagName("params");
  14129. Node itemParam = itemsParam.item(0);
  14130. if (itemParam != null) {
  14131. NamedNodeMap attrsParam = itemParam.getAttributes();
  14132. for (int j = 0; j < attrsParam.getLength(); j++) {
  14133. Node attr = attrsParam.item(j);
  14134. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  14135. strTargetLobbyIP = attr.getNodeValue();
  14136. }
  14137. }
  14138. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  14139. if (strAction.equalsIgnoreCase("authorize_request")) {
  14140. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  14141. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  14142. } else {
  14143. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14144. }
  14145. } catch (RuntimeException re) {
  14146. LogUtil.errorLogInfo("", TAG, re);
  14147. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14148. } catch (Exception e) {
  14149. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  14150. //e.printStackTrace();
  14151. LogUtil.errorLogInfo("", TAG, e);
  14152. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  14153. }
  14154. }
  14155. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  14156. try {
  14157. String strReplyXml = XMLHeader;
  14158. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  14159. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  14160. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  14161. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  14162. strReplyXml += " </service>\n";
  14163. strReplyXml += "</imap>";
  14164. return strReplyXml;
  14165. } catch (RuntimeException re) {
  14166. LogUtil.errorLogInfo("", TAG, re);
  14167. return "ERROR";
  14168. } catch (Exception e) {
  14169. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  14170. //e.printStackTrace();
  14171. LogUtil.errorLogInfo("", TAG, e);
  14172. return "ERROR";
  14173. }
  14174. }
  14175. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  14176. try {
  14177. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
  14178. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  14179. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  14180. miMAPLobbyOnePass.SetRetCtr(new RetProci() {
  14181. @Override
  14182. public void ProcSuccess() {
  14183. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  14184. }
  14185. @Override
  14186. public void ProcError() {
  14187. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  14188. }
  14189. @Override
  14190. public void ProcDoing() {
  14191. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  14192. }
  14193. });
  14194. } catch (RuntimeException re) {
  14195. LogUtil.errorLogInfo("", TAG, re);
  14196. } catch (Exception e) {
  14197. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  14198. //e.printStackTrace();
  14199. LogUtil.errorLogInfo("", TAG, e);
  14200. }
  14201. }
  14202. public String iCMDProcResidentSafety(Element ele) {
  14203. try {
  14204. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  14205. String retStr = CheckiCMDProc("check_resident_safety");
  14206. if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
  14207. // 단지서버 2.0 사용여부 확인
  14208. if (!NewServerUse()) {
  14209. return makeReply_check_resident_safety("deny", null, null, null);
  14210. }
  14211. // 거주자 안전 확인 사용 여부
  14212. if (!bEnableResidentSafetyCheck) {
  14213. return makeReply_check_resident_safety("deny", null, null, null);
  14214. }
  14215. String strSecurity = getSecurityMode();
  14216. String strTouch = getTimeStamp_ScreenTouched();
  14217. String strMagnetic = getTimeStamp_Magnetic();
  14218. return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
  14219. } catch (RuntimeException re) {
  14220. LogUtil.errorLogInfo("", TAG, re);
  14221. return makeReply_check_resident_safety("fail", null, null, null);
  14222. } catch (Exception e) {
  14223. Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
  14224. //e.printStackTrace();
  14225. LogUtil.errorLogInfo("", TAG, e);
  14226. return makeReply_check_resident_safety("fail", null, null, null);
  14227. }
  14228. }
  14229. public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
  14230. try {
  14231. String strReplyXml = XMLHeader;
  14232. strReplyXml += " <service type=\"reply\" name=\"check_resident_safety\" result=\"" + strResult + "\">\n";
  14233. if (strResult.equalsIgnoreCase("ok")) {
  14234. strReplyXml += " <security>\"" + strSecurity + "\"</security>\n";
  14235. strReplyXml += " <touch>\"" + strTouch + "\"</touch>\n";
  14236. strReplyXml += " <magnetic>\"" + magnetic + "\"</magnetic>\n";
  14237. }
  14238. strReplyXml += " <message>\"null\"</message>\n";
  14239. strReplyXml += " </service>\n";
  14240. strReplyXml += "</imap>";
  14241. return strReplyXml;
  14242. } catch (RuntimeException re) {
  14243. LogUtil.errorLogInfo("", TAG, re);
  14244. return "ERROR";
  14245. } catch (Exception e) {
  14246. Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
  14247. //e.printStackTrace();
  14248. LogUtil.errorLogInfo("", TAG, e);
  14249. return "ERROR";
  14250. }
  14251. }
  14252. private void saveBlackoutStatus(boolean bOccurred) {
  14253. try {
  14254. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  14255. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14256. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  14257. mEditor.putBoolean("status", bOccurred);
  14258. mEditor.commit();
  14259. } catch (RuntimeException re) {
  14260. LogUtil.errorLogInfo("", TAG, re);
  14261. } catch (Exception e) {
  14262. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  14263. //e.printStackTrace();
  14264. LogUtil.errorLogInfo("", TAG, e);
  14265. }
  14266. }
  14267. private boolean getBlackoutStatus() {
  14268. try {
  14269. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  14270. return mSharedPreferences.getBoolean("status", false);
  14271. } catch (RuntimeException re) {
  14272. LogUtil.errorLogInfo("", TAG, re);
  14273. return false;
  14274. } catch (Exception e) {
  14275. Log.e(TAG, "[Exception] getBlackoutStatus()");
  14276. //e.printStackTrace();
  14277. LogUtil.errorLogInfo("", TAG, e);
  14278. return false;
  14279. }
  14280. }
  14281. /**
  14282. * JEFF, 2019.12.25
  14283. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  14284. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  14285. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  14286. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  14287. */
  14288. int MAX_WALLPADCALL_LIVE_CNT = 2;
  14289. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  14290. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  14291. public static boolean bWallPadCallLive_old = false;
  14292. public static boolean m_bWallpadCallScreen = false;
  14293. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  14294. Handler handlerCheckWallPadCallLive = new Handler() {
  14295. public void handleMessage(Message msg) {
  14296. super.handleMessage(msg);
  14297. sendWallPadCallLiveBR_Request();
  14298. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  14299. }
  14300. };
  14301. private void sendWallPadCallLiveBR_Request() {
  14302. try {
  14303. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  14304. Intent mIntent = new Intent();
  14305. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  14306. getApplicationContext().sendBroadcast(mIntent);
  14307. if (nWallPadCallACKCnt >= 0) {
  14308. nWallPadCallACKCnt--;
  14309. } else {
  14310. bWallPadCallLive = false;
  14311. Common.bWallPadCallLive = bWallPadCallLive;
  14312. }
  14313. if (bWallPadCallLive != bWallPadCallLive_old) {
  14314. if (bWallPadCallLive != getCallAppRunning()) {
  14315. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14316. setCallAppRunning(bWallPadCallLive);
  14317. }
  14318. }
  14319. bWallPadCallLive_old = bWallPadCallLive;
  14320. //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  14321. } catch (RuntimeException re) {
  14322. LogUtil.errorLogInfo("", TAG, re);
  14323. } catch (Exception e) {
  14324. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  14325. //e.printStackTrace();
  14326. LogUtil.errorLogInfo("", TAG, e);
  14327. }
  14328. }
  14329. public boolean getWallpadCallScrean(int iScreen)
  14330. {
  14331. boolean bRet = false;
  14332. try {
  14333. switch (iScreen) {
  14334. case API_Menu.SubMenuCall.Door:
  14335. bRet = false;
  14336. break;
  14337. case API_Menu.SubMenuCall.Lobby:
  14338. bRet = false;
  14339. break;
  14340. case API_Menu.SubMenuCall.Guard:
  14341. bRet = false;
  14342. break;
  14343. case API_Menu.SubMenuCall.Neighbor:
  14344. bRet = false;
  14345. break;
  14346. case API_Menu.SubMenuCall.PSTN:
  14347. bRet = false;
  14348. break;
  14349. case API_Menu.SubMenuCall.CallList:
  14350. bRet = true;
  14351. break;
  14352. case API_Menu.SubMenuCall.Visitor:
  14353. bRet = true;
  14354. break;
  14355. default:
  14356. bRet = false;
  14357. break;
  14358. }
  14359. } catch (RuntimeException re) {
  14360. LogUtil.errorLogInfo("", TAG, re);
  14361. return false;
  14362. } catch (Exception e) {
  14363. Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
  14364. //e.printStackTrace();
  14365. LogUtil.errorLogInfo("", TAG, e);
  14366. return false;
  14367. }
  14368. return bRet;
  14369. }
  14370. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  14371. @Override
  14372. public void onReceive(Context context, Intent intent) {
  14373. try {
  14374. String strActionName = intent.getAction();
  14375. int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
  14376. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  14377. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  14378. bWallPadCallLive = true;
  14379. Common.bWallPadCallLive = bWallPadCallLive;
  14380. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  14381. m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
  14382. Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
  14383. } else {
  14384. Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  14385. }
  14386. } catch (RuntimeException re) {
  14387. LogUtil.errorLogInfo("", TAG, re);
  14388. } catch (Exception e) {
  14389. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  14390. //e.printStackTrace();
  14391. LogUtil.errorLogInfo("", TAG, e);
  14392. }
  14393. }
  14394. };
  14395. static class CALLCTRLHANDLERMSG {
  14396. static final int RELEASE_BLOCK_FRONTCALL = 100;
  14397. }
  14398. boolean bBlockFrontCall = false;
  14399. Handler handlerCallCtrl = new Handler() {
  14400. public void handleMessage(Message msg) {
  14401. super.handleMessage(msg);
  14402. int nMSG = msg.what;
  14403. switch (nMSG) {
  14404. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  14405. bBlockFrontCall = false;
  14406. break;
  14407. }
  14408. }
  14409. };
  14410. /**
  14411. * JEFF, 2019.12.31
  14412. * WallPadCall 실행여부를 DB에 저장한다.
  14413. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  14414. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  14415. */
  14416. public void setCallAppRunning(boolean bRunning) {
  14417. try {
  14418. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14419. mWallpadStatusData.SetCallAPKStatus(bRunning);
  14420. mWallpadStatusData.closeDB();
  14421. } catch (RuntimeException re) {
  14422. LogUtil.errorLogInfo("", TAG, re);
  14423. } catch (Exception e) {
  14424. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  14425. //e.printStackTrace();
  14426. LogUtil.errorLogInfo("", TAG, e);
  14427. }
  14428. }
  14429. private boolean getCallAppRunning() {
  14430. boolean bRunning = false;
  14431. try {
  14432. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14433. bRunning = wallpadStatusData.GetCallAPKStatusRunning();
  14434. wallpadStatusData.closeDB();
  14435. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  14436. return bRunning;
  14437. } catch (RuntimeException re) {
  14438. LogUtil.errorLogInfo("", TAG, re);
  14439. return false;
  14440. } catch (Exception e) {
  14441. Log.d(TAG, "[Exception] getCallAppRunning()");
  14442. //e.printStackTrace();
  14443. LogUtil.errorLogInfo("", TAG, e);
  14444. return false;
  14445. }
  14446. }
  14447. /**
  14448. * 통화앱 종료코드
  14449. */
  14450. public void killWallPadCall() {
  14451. try {
  14452. Log.i(TAG, "[killWallPadCall] ===== START =====");
  14453. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  14454. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14455. Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  14456. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  14457. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14458. // android.os.Process.killProcess(nWallPadCallPID);
  14459. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  14460. // if(list != null){
  14461. // for(int i=0;i<list.size();++i){
  14462. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  14463. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14464. // android.os.Process.killProcess(pid);
  14465. // }
  14466. // }
  14467. // }
  14468. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  14469. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14470. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  14471. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14472. // android.os.Process.killProcess(pid);
  14473. } catch (RuntimeException re) {
  14474. LogUtil.errorLogInfo("", TAG, re);
  14475. } catch (Exception e) {
  14476. Log.e(TAG, "[Exception] killWallPadCall()");
  14477. //e.printStackTrace();
  14478. LogUtil.errorLogInfo("", TAG, e);
  14479. }
  14480. }
  14481. private void checkForegroundActivity() {
  14482. try {
  14483. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  14484. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  14485. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  14486. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  14487. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  14488. } catch (RuntimeException re) {
  14489. LogUtil.errorLogInfo("", TAG, re);
  14490. } catch (Exception e) {
  14491. Log.e(TAG, "[Exception] checkForegroundActivity()");
  14492. //e.printStackTrace();
  14493. LogUtil.errorLogInfo("", TAG, e);
  14494. }
  14495. }
  14496. /**
  14497. * JEFF, 2020.01.04
  14498. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  14499. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  14500. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  14501. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  14502. */
  14503. static long lConnectionPeriod = 0;
  14504. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  14505. boolean bRingGeneratorRun = false;
  14506. private void startIGW300RingGenerator() {
  14507. try {
  14508. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14509. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  14510. bRingGeneratorRun = true;
  14511. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  14512. mIGW300RingGeneratorThread.start();
  14513. } else
  14514. Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  14515. } catch (RuntimeException re) {
  14516. LogUtil.errorLogInfo("", TAG, re);
  14517. } catch (Exception e) {
  14518. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  14519. //e.printStackTrace();
  14520. LogUtil.errorLogInfo("", TAG, e);
  14521. }
  14522. }
  14523. private void stopIGW300RingGenerator() {
  14524. try {
  14525. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14526. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  14527. lConnectionPeriod = -999;
  14528. bRingGeneratorRun = false;
  14529. mIGW300RingGeneratorThread = null;
  14530. } else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  14531. } catch (RuntimeException re) {
  14532. LogUtil.errorLogInfo("", TAG, re);
  14533. } catch (Exception e) {
  14534. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  14535. //e.printStackTrace();
  14536. LogUtil.errorLogInfo("", TAG, e);
  14537. }
  14538. }
  14539. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  14540. private class IGW300RingGeneratorThread extends Thread {
  14541. public IGW300RingGeneratorThread() {
  14542. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  14543. }
  14544. public void run() {
  14545. try {
  14546. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14547. if (bRingGeneratorRun)
  14548. Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  14549. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  14550. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  14551. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  14552. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  14553. try {
  14554. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  14555. } catch (InterruptedException e) {
  14556. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  14557. //e.printStackTrace();
  14558. LogUtil.errorLogInfo("", TAG, e);
  14559. }
  14560. }
  14561. bRingGeneratorRun = false;
  14562. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  14563. } catch (RuntimeException re) {
  14564. LogUtil.errorLogInfo("", TAG, re);
  14565. } catch (Exception e) {
  14566. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  14567. //e.printStackTrace();
  14568. LogUtil.errorLogInfo("", TAG, e);
  14569. }
  14570. }
  14571. }
  14572. private void sendPSTNRingEvent(int nKeyCode) {
  14573. try {
  14574. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  14575. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  14576. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  14577. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  14578. intent.putExtra("keycode", nKeyCode);
  14579. getApplicationContext().sendBroadcast(intent);
  14580. } catch (RuntimeException re) {
  14581. LogUtil.errorLogInfo("", TAG, re);
  14582. } catch (Exception e) {
  14583. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  14584. //e.printStackTrace();
  14585. LogUtil.errorLogInfo("", TAG, e);
  14586. }
  14587. }
  14588. /**
  14589. * 월패드 타입 판별
  14590. *
  14591. * @return bResult
  14592. * false: 메인월패드
  14593. * true: 서브월패드
  14594. */
  14595. public boolean getIsSubWallpad() {
  14596. boolean bResult = false;
  14597. try {
  14598. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14599. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  14600. mWallpadDeviceSet.closeDB();
  14601. if (DBinfo != null) {
  14602. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  14603. else bResult = false;
  14604. }
  14605. } catch (RuntimeException re) {
  14606. LogUtil.errorLogInfo("", TAG, re);
  14607. } catch (Exception e) {
  14608. Log.e(TAG, "[Exception] getIsSubWallpad()");
  14609. //e.printStackTrace();
  14610. LogUtil.errorLogInfo("", TAG, e);
  14611. }
  14612. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  14613. return bResult;
  14614. }
  14615. /**
  14616. * JEFF, 2020.02.05
  14617. * 월패드 비상접점 신호 사용 여부 확인
  14618. */
  14619. public boolean getEmergencyIOUsage() {
  14620. boolean bResult = false;
  14621. try {
  14622. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14623. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  14624. mWallpadDeviceSet.closeDB();
  14625. } catch (RuntimeException re) {
  14626. LogUtil.errorLogInfo("", TAG, re);
  14627. } catch (Exception e) {
  14628. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  14629. //e.printStackTrace();
  14630. LogUtil.errorLogInfo("", TAG, e);
  14631. }
  14632. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  14633. return bResult;
  14634. }
  14635. /**
  14636. * JEFF, 2020.02.05
  14637. * 거동수상자 녹화기능 활성화 확인
  14638. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  14639. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  14640. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  14641. */
  14642. public boolean getStrangerRecordingManagerSetting() {
  14643. boolean bResult = false;
  14644. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14645. try {
  14646. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14647. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  14648. mWallpadDeviceSet.closeDB();
  14649. if (nFrontCam[0] == COMPONENT_USE) {
  14650. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  14651. if (bRecord) bResult = true;
  14652. else bResult = false;
  14653. } else bResult = false;
  14654. } else bResult = false;
  14655. } catch (RuntimeException re) {
  14656. LogUtil.errorLogInfo("", TAG, re);
  14657. mWallpadDeviceSet.closeDB();
  14658. } catch (Exception e) {
  14659. mWallpadDeviceSet.closeDB();
  14660. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  14661. //e.printStackTrace();
  14662. LogUtil.errorLogInfo("", TAG, e);
  14663. }
  14664. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  14665. return bResult;
  14666. }
  14667. /**
  14668. * Edited by jeff (2020.06.22)
  14669. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  14670. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  14671. *
  14672. * @param bOn
  14673. */
  14674. private void sendLCDBacklightStatus(boolean bOn) {
  14675. try {
  14676. Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
  14677. Intent mIntent = new Intent();
  14678. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  14679. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  14680. getApplicationContext().sendBroadcast(mIntent);
  14681. } catch (RuntimeException re) {
  14682. LogUtil.errorLogInfo("", TAG, re);
  14683. } catch (Exception e) {
  14684. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  14685. //e.printStackTrace();
  14686. LogUtil.errorLogInfo("", TAG, e);
  14687. }
  14688. }
  14689. // 명칭 관련
  14690. boolean bRoomNameLog = true;
  14691. public static final int HEATING = 1;
  14692. public static final int LIGHT = 2;
  14693. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  14694. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14695. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
  14696. "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
  14697. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14698. /**
  14699. * DB 에서 룸이름 정보를 가져온다.
  14700. *
  14701. * @return (String []) null - 실패, not null
  14702. */
  14703. private String[] getDBRoomName() {
  14704. try {
  14705. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14706. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  14707. wallpadStatusData.closeDB();
  14708. if (strRoomNameList == null) {
  14709. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  14710. return null;
  14711. }
  14712. if (bRoomNameLog) {
  14713. for (int i = 0; i < strRoomNameList.length; i++)
  14714. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14715. }
  14716. return strRoomNameList;
  14717. } catch (RuntimeException re) {
  14718. LogUtil.errorLogInfo("", TAG, re);
  14719. } catch (Exception e) {
  14720. Log.e(TAG, "[Exception] getDBRoomName()");
  14721. //e.printStackTrace();
  14722. LogUtil.errorLogInfo("", TAG, e);
  14723. }
  14724. return null;
  14725. }
  14726. /**
  14727. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  14728. *
  14729. * @param nDeviceType - int
  14730. * @return (String []) null - 실패, not null
  14731. */
  14732. private String[] getDBRoomName(int nDeviceType) {
  14733. try {
  14734. String[] strRoomNameList = null;
  14735. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14736. if (nDeviceType == HEATING) {
  14737. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  14738. } else {
  14739. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  14740. }
  14741. wallpadStatusData.closeDB();
  14742. if (strRoomNameList == null) {
  14743. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  14744. return null;
  14745. }
  14746. if (bRoomNameLog) {
  14747. for (int i = 0; i < strRoomNameList.length; i++)
  14748. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14749. }
  14750. return strRoomNameList;
  14751. } catch (RuntimeException re) {
  14752. LogUtil.errorLogInfo("", TAG, re);
  14753. } catch (Exception e) {
  14754. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  14755. //e.printStackTrace();
  14756. LogUtil.errorLogInfo("", TAG, e);
  14757. }
  14758. return null;
  14759. }
  14760. /**
  14761. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  14762. **/
  14763. private void getRoomName() {
  14764. try {
  14765. Log.i(TAG, "[getRoomName] ====================");
  14766. } catch (RuntimeException re) {
  14767. LogUtil.errorLogInfo("", TAG, re);
  14768. } catch (Exception e) {
  14769. Log.e(TAG, "[Exception] getRoomName()");
  14770. //e.printStackTrace();
  14771. LogUtil.errorLogInfo("", TAG, e);
  14772. }
  14773. }
  14774. public boolean getEasyModeUXUsage() {
  14775. try {
  14776. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  14777. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  14778. deviceSet.closeDB();
  14779. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  14780. boolean bUse = data.GetEasyModeUxUse();
  14781. data.closeDB();
  14782. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  14783. return bSupport & bUse;
  14784. } catch (RuntimeException re) {
  14785. LogUtil.errorLogInfo("", TAG, re);
  14786. } catch (Exception e) {
  14787. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  14788. //e.printStackTrace();
  14789. LogUtil.errorLogInfo("", TAG, e);
  14790. }
  14791. return false;
  14792. }
  14793. /**
  14794. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  14795. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  14796. * 재설정 5초 후 월패드 재부팅을 실행한다.
  14797. * 2020.11.18 SEULKI
  14798. */
  14799. public void checkDoorCamConfig() {
  14800. try {
  14801. if (Build.VERSION.SDK_INT > 23) {
  14802. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
  14803. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  14804. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  14805. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  14806. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  14807. if (!checkAvailableBSPDoorCamConfig()) {
  14808. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  14809. return;
  14810. }
  14811. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  14812. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  14813. if (mIOInterface != null)
  14814. mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  14815. // 재부팅
  14816. setDefaultLauncher();
  14817. Intent intent = new Intent();
  14818. if (intent != null) {
  14819. intent.setAction(define.NOTIFY_ACNAME);
  14820. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  14821. getApplicationContext().sendBroadcast(intent);
  14822. }
  14823. }
  14824. }
  14825. }
  14826. } catch (RuntimeException re) {
  14827. LogUtil.errorLogInfo("", "", re);
  14828. } catch (Exception e) {
  14829. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  14830. LogUtil.errorLogInfo("", "", e);
  14831. }
  14832. }
  14833. /**
  14834. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  14835. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  14836. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  14837. *
  14838. * @return true: 지원, false: 미지원
  14839. */
  14840. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  14841. private boolean checkAvailableBSPDoorCamConfig() {
  14842. try {
  14843. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  14844. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  14845. if (nCurrentVer >= nCriterionVer) {
  14846. return true;
  14847. } else return false;
  14848. } catch (RuntimeException re) {
  14849. LogUtil.errorLogInfo("", TAG, re);
  14850. return false;
  14851. } catch (Exception e) {
  14852. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  14853. //e.printStackTrace();
  14854. LogUtil.errorLogInfo("", TAG, e);
  14855. return false;
  14856. }
  14857. }
  14858. /**
  14859. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14860. *
  14861. * @return 0 - 스마트현관카메라
  14862. * 2 - 스마트현관카메라 좌우반전
  14863. * 1 - 일반현관카메라
  14864. * 2020.11.18 SEULKI
  14865. */
  14866. public int getBSPDoorCamConfig() {
  14867. InputStreamReader is = null;
  14868. try {
  14869. Runtime mRuntime = Runtime.getRuntime();
  14870. String cmd = "getprop camera.setting.value";
  14871. if (mRuntime != null) {
  14872. Process mProcess = mRuntime.exec(cmd);
  14873. is = new InputStreamReader(mProcess.getInputStream());
  14874. BufferedReader br = new BufferedReader(is);
  14875. String line;
  14876. String strResult = null;
  14877. if (br != null) {
  14878. while ((line = br.readLine()) != null) {
  14879. strResult = line;
  14880. }
  14881. if (strResult != null) {
  14882. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  14883. if (strResult.equals("0")) {
  14884. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  14885. return 0;
  14886. } else if (strResult.equals("1")) {
  14887. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  14888. return 1;
  14889. } else if (strResult.equals("2")) {
  14890. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  14891. return 2;
  14892. } else {
  14893. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  14894. return -1;
  14895. }
  14896. }
  14897. }
  14898. }
  14899. return -1;
  14900. } catch (Exception e) {
  14901. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  14902. e.printStackTrace();
  14903. return -1;
  14904. } finally {
  14905. if (is != null) {
  14906. try {
  14907. is.close();
  14908. } catch (IOException e) {
  14909. LogUtil.errorLogInfo("", TAG, e);
  14910. }
  14911. is = null;
  14912. }
  14913. }
  14914. }
  14915. /**
  14916. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14917. *
  14918. * @return 0 - 스마트현관카메라
  14919. * 2 - 스마트현관카메라 좌우반전
  14920. * 1 - 일반현관카메라
  14921. * 2020.11.18 SEULKI
  14922. */
  14923. public int getDBDoorCamConfig() {
  14924. try {
  14925. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14926. if (mWallpadDeviceSet != null) {
  14927. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14928. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  14929. mWallpadDeviceSet.closeDB();
  14930. if (nType != null) {
  14931. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  14932. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
  14933. // Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14934. if (bFlip) {
  14935. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
  14936. return 0;
  14937. } else {
  14938. Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
  14939. return 2;
  14940. }
  14941. } else {
  14942. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  14943. return 1;
  14944. }
  14945. }
  14946. }
  14947. return -1;
  14948. } catch (Exception e) {
  14949. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  14950. e.printStackTrace();
  14951. return -1;
  14952. }
  14953. }
  14954. /**
  14955. * 공기질 센서 사용여부 확인
  14956. *
  14957. * @return true - 사용함, false: 사용안함
  14958. */
  14959. boolean bAirQualityEnable = false;
  14960. private boolean getAirQualityUsage() {
  14961. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14962. try {
  14963. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  14964. mWallpadDeviceSet.closeDB();
  14965. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  14966. bAirQualityEnable = true;
  14967. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14968. } else {
  14969. bAirQualityEnable = false;
  14970. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
  14971. }
  14972. return bAirQualityEnable;
  14973. } catch (RuntimeException re) {
  14974. LogUtil.errorLogInfo("", TAG, re);
  14975. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14976. return false;
  14977. } catch (Exception e) {
  14978. Log.e(TAG, "[Exception] getAirQualityUsage()");
  14979. //e.printStackTrace();
  14980. LogUtil.errorLogInfo("", TAG, e);
  14981. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14982. return false;
  14983. }
  14984. }
  14985. String strAirQualityFWVer = "";
  14986. String strAirQualityProtocolVer = "";
  14987. String strAirQualityInfo = "";
  14988. private String getAirQualityInfo() {
  14989. try {
  14990. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  14991. if (mAirQualitySensorAPI != null) {
  14992. int nRet = mAirQualitySensorAPI.Refresh(false);
  14993. if (nRet >= 0) {
  14994. Log.i(TAG, "[getAirQualityInfo] ");
  14995. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  14996. strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  14997. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  14998. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  14999. return strAirQualityInfo;
  15000. } else return "FAIL";
  15001. } else return "NULL";
  15002. } catch (RuntimeException re) {
  15003. LogUtil.errorLogInfo("", TAG, re);
  15004. return "ERROR";
  15005. } catch (Exception e) {
  15006. Log.e(TAG, "[Exception] getAirQualityInfo()");
  15007. //e.printStackTrace();
  15008. LogUtil.errorLogInfo("", TAG, e);
  15009. return "ERROR";
  15010. }
  15011. }
  15012. private String getAOSVerCode() {
  15013. try {
  15014. int nOSVer = Build.VERSION.SDK_INT;
  15015. switch (nOSVer) {
  15016. case Build.VERSION_CODES.BASE:
  15017. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  15018. case Build.VERSION_CODES.BASE_1_1:
  15019. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  15020. case Build.VERSION_CODES.CUPCAKE:
  15021. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  15022. case Build.VERSION_CODES.DONUT:
  15023. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  15024. case Build.VERSION_CODES.ECLAIR:
  15025. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  15026. case Build.VERSION_CODES.ECLAIR_0_1:
  15027. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  15028. case Build.VERSION_CODES.ECLAIR_MR1:
  15029. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  15030. case Build.VERSION_CODES.FROYO:
  15031. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  15032. case Build.VERSION_CODES.GINGERBREAD:
  15033. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  15034. case Build.VERSION_CODES.GINGERBREAD_MR1:
  15035. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  15036. case Build.VERSION_CODES.HONEYCOMB:
  15037. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  15038. case Build.VERSION_CODES.HONEYCOMB_MR1:
  15039. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  15040. case Build.VERSION_CODES.HONEYCOMB_MR2:
  15041. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  15042. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  15043. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  15044. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  15045. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  15046. case Build.VERSION_CODES.JELLY_BEAN:
  15047. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  15048. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  15049. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  15050. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  15051. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  15052. case Build.VERSION_CODES.KITKAT:
  15053. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  15054. case Build.VERSION_CODES.KITKAT_WATCH:
  15055. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  15056. case Build.VERSION_CODES.LOLLIPOP:
  15057. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  15058. case Build.VERSION_CODES.LOLLIPOP_MR1:
  15059. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  15060. case Build.VERSION_CODES.M:
  15061. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  15062. case Build.VERSION_CODES.N:
  15063. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  15064. case Build.VERSION_CODES.N_MR1:
  15065. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  15066. case Build.VERSION_CODES.O:
  15067. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  15068. case Build.VERSION_CODES.O_MR1:
  15069. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  15070. case Build.VERSION_CODES.P:
  15071. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  15072. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  15073. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  15074. default:
  15075. return "SDK(" + nOSVer + ")/UNKNOWN";
  15076. }
  15077. } catch (RuntimeException re) {
  15078. LogUtil.errorLogInfo("", TAG, re);
  15079. return "ERROR";
  15080. } catch (Exception e) {
  15081. Log.e(TAG, "[Exception] getAirQualityInfo()");
  15082. //e.printStackTrace();
  15083. LogUtil.errorLogInfo("", TAG, e);
  15084. return "ERROR";
  15085. }
  15086. }
  15087. /**
  15088. * 조명 ON/OFF 상태
  15089. */
  15090. public static class LIGHT_ONOFF {
  15091. /**
  15092. * ON
  15093. */
  15094. public static byte ON = (byte) 0x01;
  15095. /**
  15096. * OFF
  15097. */
  15098. public static byte OFF = (byte) 0x02;
  15099. /**
  15100. * OFF
  15101. */
  15102. public static byte DONTCARE = (byte) 0xFF;
  15103. }
  15104. private byte convertSmartLightPowerValue(String cmd) {
  15105. try {
  15106. if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
  15107. else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
  15108. else return LIGHT_ONOFF.DONTCARE;
  15109. } catch (RuntimeException re) {
  15110. LogUtil.errorLogInfo("", TAG, re);
  15111. return -1;
  15112. } catch (Exception e) {
  15113. Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
  15114. //e.printStackTrace();
  15115. LogUtil.errorLogInfo("", TAG, e);
  15116. return -1;
  15117. }
  15118. }
  15119. /** 거주자 안정 확인 서비스용 코드 시작 */
  15120. /**
  15121. * Edited by Jeff, 2021.06.15
  15122. */
  15123. public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
  15124. public boolean bEnableResidentSafetyCheck = false;
  15125. private void getResidentSafetyCheckSetting() {
  15126. try {
  15127. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  15128. nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
  15129. mWallpadDeviceSet.closeDB();
  15130. Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
  15131. if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
  15132. bEnableResidentSafetyCheck = true;
  15133. else bEnableResidentSafetyCheck = false;
  15134. } catch (RuntimeException re) {
  15135. LogUtil.errorLogInfo("", TAG, re);
  15136. } catch (Exception e) {
  15137. Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
  15138. //e.printStackTrace();
  15139. LogUtil.errorLogInfo("", TAG, e);
  15140. }
  15141. }
  15142. private String getSecurityMode() {
  15143. try {
  15144. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  15145. int nStatus = mWallpadStatusData.GetAlarmStatus();
  15146. mWallpadStatusData.closeDB();
  15147. String strSecurity = "null";
  15148. if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
  15149. else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
  15150. else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
  15151. else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
  15152. else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
  15153. else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
  15154. return strSecurity;
  15155. } catch (Exception e) {
  15156. Log.e(TAG, "[Exception] getSecurityMode()");
  15157. //e.printStackTrace();
  15158. LogUtil.errorLogInfo("", TAG, e);
  15159. return null;
  15160. }
  15161. }
  15162. String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
  15163. String Touch = "Touch";
  15164. String Magnetic = "Magnetic";
  15165. private void setTimeStamp_ScreenTouched() {
  15166. try {
  15167. Calendar mCal = Calendar.getInstance();
  15168. String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  15169. // Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
  15170. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15171. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  15172. mEditor.putString(Touch, strTouchTime);
  15173. mEditor.apply();
  15174. } catch (Exception e) {
  15175. Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
  15176. //e.printStackTrace();
  15177. LogUtil.errorLogInfo("", TAG, e);
  15178. }
  15179. }
  15180. private String getTimeStamp_ScreenTouched() {
  15181. try {
  15182. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15183. String strTouchTime = mSharedPreferences.getString(Touch, null);
  15184. // Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
  15185. return strTouchTime;
  15186. } catch (Exception e) {
  15187. Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
  15188. //e.printStackTrace();
  15189. LogUtil.errorLogInfo("", TAG, e);
  15190. return null;
  15191. }
  15192. }
  15193. private void setTimeStamp_Magnetic() {
  15194. try {
  15195. Calendar mCal = Calendar.getInstance();
  15196. String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
  15197. // Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
  15198. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15199. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  15200. mEditor.putString(Magnetic, strMagneticTime);
  15201. mEditor.apply();
  15202. } catch (Exception e) {
  15203. Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
  15204. //e.printStackTrace();
  15205. LogUtil.errorLogInfo("", TAG, e);
  15206. }
  15207. }
  15208. private String getTimeStamp_Magnetic() {
  15209. try {
  15210. SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
  15211. String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
  15212. // Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
  15213. return strMagneticTime;
  15214. } catch (Exception e) {
  15215. Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
  15216. //e.printStackTrace();
  15217. LogUtil.errorLogInfo("", TAG, e);
  15218. return null;
  15219. }
  15220. }
  15221. /** 거주자 안정 확인 서비스용 코드 종료 */
  15222. /**
  15223. * 가스밸브를 쿡탑콘센트로 사용
  15224. */
  15225. private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
  15226. /** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
  15227. /** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
  15228. /**
  15229. * false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
  15230. */
  15231. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  15232. private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
  15233. /**
  15234. * 기기 연동 제어 옵션 설정 확인
  15235. */
  15236. // 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
  15237. // 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
  15238. private void getDeviceCtrlOption() {
  15239. int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
  15240. boolean bUserSetting_SmartLightEnable = false;
  15241. int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
  15242. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  15243. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  15244. try {
  15245. bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
  15246. nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
  15247. nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
  15248. mWallpadDeviceSet.closeDB();
  15249. bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
  15250. mWallpadStatusData.closeDB();
  15251. if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  15252. // 스마트 분전반을 사용하는 경우에만
  15253. // 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
  15254. if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
  15255. // 사용자선택인 경우
  15256. if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
  15257. else bLightCMDUseAsSmartLight = true;
  15258. } else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
  15259. // 스마트조명을 사용하는 경우
  15260. bLightCMDUseAsSmartLight = false;
  15261. } else {
  15262. // 스마트조명을 사용하지 않는 경우
  15263. bLightCMDUseAsSmartLight = true;
  15264. }
  15265. } else {
  15266. // 스마트분전반을 사용하지 않는 경우
  15267. bLightCMDUseAsSmartLight = true;
  15268. }
  15269. Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
  15270. } catch (Exception e) {
  15271. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  15272. if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
  15273. Log.e(TAG, "[Exception] getDeviceCtrlOption()");
  15274. //e.printStackTrace();
  15275. LogUtil.errorLogInfo("", TAG, e);
  15276. }
  15277. }
  15278. private String[] getRoomNameFromDBV2(String strDeviceType) {
  15279. try {
  15280. String[] RoomNameList = null;
  15281. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  15282. RoomNameList = wallpadStatusData.GetDevRoomNameList(strDeviceType);
  15283. wallpadStatusData.closeDB();
  15284. if (RoomNameList == null) {
  15285. Log.e(TAG, "[getRoomNameFromDBV2] - RoomNameList is null !!!");
  15286. return null;
  15287. }
  15288. Log.i(TAG, "[getRoomNameFromDBV2] RoomNameList " + Arrays.toString(RoomNameList));
  15289. return RoomNameList;
  15290. } catch (RuntimeException re) {
  15291. LogUtil.errorLogInfo("", TAG, re);
  15292. } catch (Exception e) {
  15293. Log.e(TAG, "[Exception] getRoomNameFromDBV2(int Device)");
  15294. //e.printStackTrace();
  15295. LogUtil.errorLogInfo("", TAG, e);
  15296. }
  15297. return null;
  15298. }
  15299. // private void demoPushMsg()
  15300. // {
  15301. // String urlStr1 = "";
  15302. //
  15303. // if(android.os.Build.VERSION.SDK_INT > 9 )
  15304. // {
  15305. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  15306. // StrictMode.setThreadPolicy(policy);
  15307. // }
  15308. //
  15309. // String Msg ="";
  15310. // try {
  15311. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  15312. // } catch (UnsupportedEncodingException e1) {
  15313. // // TODO Auto-generated catch block
  15314. // e1.printStackTrace();
  15315. // }
  15316. //
  15317. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  15318. // Log.d(TAG , "################ : " + urlStr1);
  15319. // try
  15320. // {
  15321. // //URLEncoder.encode(s)
  15322. // HttpClient client = new DefaultHttpClient();
  15323. //
  15324. // HttpGet get = new HttpGet();
  15325. // //get.setURI(new URI("http://www.google.com/"));
  15326. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  15327. // HttpResponse resp = client.execute(get);
  15328. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  15329. // String str = null;
  15330. // StringBuilder sb = new StringBuilder();
  15331. // while((str = br.readLine()) != null)
  15332. // {
  15333. // sb.append(str).append("\n");
  15334. // }
  15335. // br.close();
  15336. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  15337. // //txt.setText(sb.toString());
  15338. // }catch(Exception e)
  15339. // {
  15340. //
  15341. // e.printStackTrace();
  15342. //
  15343. // }
  15344. //
  15345. //
  15346. // }
  15347. //
  15348. //
  15349. // public static boolean checkForExternal(String str) {
  15350. // int length = str.length();
  15351. // for (int i = 0; i < length; i++) {
  15352. // if (str.charAt(i) > 0x7F) {
  15353. // return true;
  15354. // }
  15355. // }
  15356. // return false;
  15357. // }
  15358. //
  15359. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  15360. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  15361. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  15362. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  15363. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  15364. //
  15365. // public static String encodeUrl(String url) {
  15366. // if (checkForExternal(url)) {
  15367. // try {
  15368. // String value = URLEncoder.encode(url, "UTF-8");
  15369. // value = COLON.matcher(value).replaceAll(":");
  15370. // value = SLASH.matcher(value).replaceAll("/");
  15371. // value = QUEST_MARK.matcher(value).replaceAll("?");
  15372. // value = EQUAL.matcher(value).replaceAll("=");
  15373. // return AMP.matcher(value).replaceAll("&");
  15374. // } catch (UnsupportedEncodingException e) {
  15375. // //throw LOGGER.getIllegalStateException(e);
  15376. // return null;
  15377. // }
  15378. // } else {
  15379. // return url;
  15380. // }
  15381. // }
  15382. }