iMapServer.java 785 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661
  1. package kr.co.icontrols.wallpadmain.util;
  2. import android.annotation.SuppressLint;
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningTaskInfo;
  5. import android.app.Service;
  6. import android.content.BroadcastReceiver;
  7. import android.content.ComponentName;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.content.IntentFilter;
  11. import android.content.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.media.AudioManager;
  15. import android.os.Build;
  16. import android.os.Bundle;
  17. import android.os.CountDownTimer;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.os.Looper;
  21. import android.os.Message;
  22. import android.os.PowerManager;
  23. import android.util.Log;
  24. import android.view.KeyEvent;
  25. import android.widget.Toast;
  26. import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
  27. import com.artncore.WallPadDataMgr.WallpadDevStatus;
  28. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  29. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  30. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  31. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  32. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
  33. import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
  34. import com.artncore.WallPadDataMgr.WallpadStatusData;
  35. import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
  36. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  37. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  38. import com.artncore.WallPadKNXSystem.WallPadKNX;
  39. import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
  40. import com.artncore.commons.APIErrorCode;
  41. import com.artncore.commons.API_Menu;
  42. import com.artncore.commons.DataClasses;
  43. import com.artncore.commons.DataClasses.HeatingV1;
  44. import com.artncore.commons.DataClasses.HeatingV2;
  45. import com.artncore.commons.DataClasses.MultiSwitch;
  46. import com.artncore.commons.define;
  47. import com.artncore.deviceinterface.WallPadInterface;
  48. import com.artncore.wallpadapi.AirQualitySensorAPI;
  49. import com.artncore.wallpadapi.CooktopAPI;
  50. import com.artncore.wallpadapi.DLockAPI;
  51. import com.artncore.wallpadapi.EnergyMeterAPI;
  52. import com.artncore.wallpadapi.GasAPI;
  53. import com.artncore.wallpadapi.HeatingV1API;
  54. import com.artncore.wallpadapi.HeatingV2API;
  55. import com.artncore.wallpadapi.IGW200dAPI;
  56. import com.artncore.wallpadapi.IGW300API;
  57. import com.artncore.wallpadapi.IntLightAPI;
  58. import com.artncore.wallpadapi.KnxAPI;
  59. import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
  60. import com.artncore.wallpadapi.LightAPI;
  61. import com.artncore.wallpadapi.MultiSwitchAPI;
  62. import com.artncore.wallpadapi.PhonNRemocon;
  63. import com.artncore.wallpadapi.RealTimeMeterAPI;
  64. import com.artncore.wallpadapi.SdbAPI;
  65. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  66. import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
  67. import com.artncore.wallpadapi.SmartSwitchPolAPI;
  68. import com.artncore.wallpadapi.VentiAPI;
  69. import com.artncore.wallpadapi.WallPadAPI;
  70. import com.artncore.wallpadimap.RetProci;
  71. import com.artncore.wallpadimap.WallPadFTPUploader;
  72. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  73. import com.artncore.wallpadimap.WallpadiCMDParser;
  74. import com.util.LogUtil;
  75. import org.apache.commons.net.ftp.FTP;
  76. import org.w3c.dom.Document;
  77. import org.w3c.dom.Element;
  78. import org.w3c.dom.NamedNodeMap;
  79. import org.w3c.dom.Node;
  80. import org.w3c.dom.NodeList;
  81. import java.io.BufferedReader;
  82. import java.io.ByteArrayInputStream;
  83. import java.io.DataOutputStream;
  84. import java.io.File;
  85. import java.io.FilenameFilter;
  86. import java.io.IOException;
  87. import java.io.InputStream;
  88. import java.io.InputStreamReader;
  89. import java.net.ServerSocket;
  90. import java.net.Socket;
  91. import java.text.SimpleDateFormat;
  92. import java.util.ArrayList;
  93. import java.util.Calendar;
  94. import java.util.Date;
  95. import java.util.GregorianCalendar;
  96. import java.util.LinkedList;
  97. import java.util.List;
  98. import java.util.Queue;
  99. import javax.net.ssl.SSLServerSocket;
  100. import javax.xml.parsers.DocumentBuilder;
  101. import javax.xml.parsers.DocumentBuilderFactory;
  102. import kr.co.icontrols.gledeviceinterface.jni;
  103. import kr.co.icontrols.hdcftp.HDCFTPManager;
  104. import kr.co.icontrols.sslapi.SSLClient;
  105. import kr.co.icontrols.sslapi.SSLServer;
  106. import kr.co.icontrols.wallpadmain.IOInterface;
  107. import kr.co.icontrols.wallpadmain.MainActivity;
  108. import kr.co.icontrols.wallpadmain.R;
  109. import kr.co.icontrols.wallpadmain.declare.Common;
  110. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  111. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
  112. import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
  113. import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
  114. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
  115. import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
  116. import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
  117. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
  118. import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
  119. import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
  120. import kr.co.icontrols.wallpadsupport.Version;
  121. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  122. import kr.co.icontrols.wallpadsupport.WpadSound;
  123. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  124. import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
  125. import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
  126. public class iMapServer extends Service {
  127. private String TAG = "iMapServer";
  128. static final int EVENTTIMELIMITE = 2000;
  129. iMapSverSocket SvrSock;
  130. iMapSverSocket_Mix danji_mix = null;
  131. int port =10000;
  132. String StrAddr ="";
  133. String IPaddr;
  134. String AddrDong;
  135. String AddrHo;
  136. boolean log_sw = true;
  137. String SVRIP = "";
  138. static WallPadAPI mWallPadAPI;
  139. private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
  140. private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
  141. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
  142. private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
  143. private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
  144. private IGW200 mIGW200;
  145. private IGW300 mIGW300;
  146. PhonNRemocon PnRCtr;
  147. boolean CallConnected = false;
  148. long ALERTTIME = 0;
  149. long CALLTIME = 0;
  150. long OPENDOORTIME = 0;
  151. long currentTime = 0;
  152. long DoorDelayTime = 0;
  153. static Handler ScheDulerHandler;
  154. static final boolean iMAPDOORCTR = true;
  155. private jni mGleInterface = null;
  156. IOInterface mIOInterface = null;
  157. private boolean ResetFlag = false;
  158. final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
  159. private int ResetCount = 0;
  160. private boolean NowMainStatus = false;
  161. public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
  162. public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
  163. public iMapServer() {
  164. Log.i(TAG, "[iMapServer] ========== START ==========");
  165. }
  166. public static final int SENSOR_MAG = 0x01;
  167. public static final int SENSOR_IN = 0x02;
  168. public static final int SENSOR_OUT = 0x04;
  169. static int PORT_NUM_iMAP = 10000;
  170. static int SOCKET_WAIT_TIME = 40;
  171. static long lSocketConnectionPeriod = 0;
  172. static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
  173. static int SOCKET_BUFFER_SIZE_READ = 50;
  174. public static final String ITEM_MENU_TYPE = "call_menu";
  175. static final int DOOR_DELAY_TIME = 3000;
  176. static final String MULTISW_CTR = "remote_access_electric";
  177. String XMLHeader;
  178. SchedulerThread ScheServer;
  179. int OutGoingSensorWaiting = 0;
  180. private int ModelType = Version.getModelType();
  181. private WpadSound mSound;
  182. private WpadSound Sound() {
  183. if (mSound == null) mSound = new WpadSound(getApplicationContext());
  184. return mSound;
  185. }
  186. /** 신형 단지서버 사용 유무*/
  187. //private boolean mNewDanjiServer = false;
  188. /** 단지서버 타입 1=1.0, 2 = 2.0, 0 = mix*/
  189. private int danjiserverType = 1;
  190. /** 가스밸브를 쿡탑콘센트로 사용 */
  191. private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
  192. /**
  193. * JEFF, 2019.12.31
  194. * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
  195. * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
  196. * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
  197. * 통화앱 종료 BR을 삭제하면 안됨
  198. */
  199. // 통화어플이 종료중인 경우에는 호출 무시
  200. // private boolean bBlockCallEvent = false;
  201. // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
  202. // true : 기존 livinglight/light로 smartlight 제어
  203. // false: livinglight/light로 livinglight/light 제어
  204. private boolean bSmartLightAsNormalLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
  205. ////////////////////////////////////////////////////////////////////////////////
  206. // 엘리베이터관련
  207. ////////////////////////////////////////////////////////////////////////////////
  208. /**
  209. * 엘리베이터 호출관련 class
  210. *
  211. * shkang
  212. */
  213. private class ElevatorClass {
  214. /** 엘리베이터 호출 타임아웃 (단위:초) */
  215. private final int ELEVATOR_CALL_TIMEOUT_SEC = (int)(5 * 60); // 5분
  216. /** 상향/하향 플레그 true:상향UP, false:하향DN */
  217. private boolean mUpDn = false;
  218. /** 엘리베이터 호출중 */
  219. private boolean mCallElevator = false;
  220. /** 엘리베이터 호출 API */
  221. private WallPadiMAPNotifyAPI mElevatorAPI;
  222. /** 엘리베이터 호출 타이머 */
  223. private CountDownTimer mElevatorTimer;
  224. /** 엘리베이터 호출중 상태 가져오기 */
  225. public boolean getElevatorCalling()
  226. {
  227. return mCallElevator;
  228. }
  229. /** 엘리베이터 호출 상태 클리어 */
  230. public void ClearElevator()
  231. {
  232. mCallElevator = false;
  233. }
  234. /**
  235. * 생성자
  236. *
  237. * @param Up - (boolean) true:상향, false:하향
  238. */
  239. private ElevatorClass(boolean Up) {
  240. try {
  241. Log.i(TAG, "[ElevatorClass] Create(" + (Up == true?"UP" : "DOWN") + ")");
  242. // 1. Input Param
  243. mUpDn = Up;
  244. mCallElevator = false;
  245. // 2. Create API
  246. mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  247. mElevatorAPI.SetElevatorRetCtr(new RetProci() {
  248. @Override
  249. public void ProcDoing() {
  250. Log.i(TAG, "[ElevatorClass] ProcDoing()");
  251. }
  252. @Override
  253. public void ProcError() {
  254. Log.i(TAG, "[ElevatorClass] ProcError()");
  255. mCallElevator = false;
  256. // 엘리베이터 호출 에러 알림
  257. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
  258. }
  259. @Override
  260. public void ProcSuccess() {
  261. Log.i(TAG, "[ElevatorClass] ProcSuccess()");
  262. mCallElevator = true;
  263. // 엘리베이터 호출 성공 알림
  264. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
  265. // "엘리베이터를 호출하였습니다" 멘트출력
  266. Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
  267. if (!MainActivity.bKakaoiEnable) Sound().PlayMent(WpadSound.SND.elevator.CALL);
  268. // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
  269. // 타임아웃 시작
  270. TimeOutStart();
  271. }
  272. });
  273. // 3. Create Timer
  274. mElevatorTimer = new CountDownTimer( (long)(ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
  275. @Override
  276. public void onFinish() {
  277. Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
  278. mCallElevator = false;
  279. // 호출 타임아웃 알림
  280. SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
  281. }
  282. @Override
  283. public void onTick(long arg0) {
  284. int RemainingTime = (int) (arg0 / 1000);
  285. if (RemainingTime <= 10) {
  286. Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
  287. }
  288. }
  289. };
  290. } catch (RuntimeException re) {
  291. LogUtil.errorLogInfo("", TAG, re);
  292. }
  293. catch (Exception e) {
  294. Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
  295. //e.printStackTrace();
  296. LogUtil.errorLogInfo("", TAG, e);
  297. }
  298. }
  299. /**
  300. * 엘리베이터 호출을 한다.
  301. */
  302. public void CallElevator() {
  303. try {
  304. if (mElevatorAPI == null) return;
  305. mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
  306. mCallElevator = true;
  307. } catch (RuntimeException re) {
  308. LogUtil.errorLogInfo("", TAG, re);
  309. }
  310. catch (Exception e) {
  311. Log.e(TAG, "[Exception] CallElevator()");
  312. //e.printStackTrace();
  313. LogUtil.errorLogInfo("", TAG, e);
  314. }
  315. }
  316. /**
  317. * 엘리베이터 상향호출 타임아웃을 취소한다.
  318. */
  319. public void TimeOutCancel() {
  320. try {
  321. if (mElevatorTimer == null) return;
  322. mElevatorTimer.cancel();
  323. } catch (RuntimeException re) {
  324. LogUtil.errorLogInfo("", TAG, re);
  325. }
  326. catch (Exception e) {
  327. Log.e(TAG, "[Exception] TimeOutCancel()");
  328. //e.printStackTrace();
  329. LogUtil.errorLogInfo("", TAG, e);
  330. }
  331. }
  332. /**
  333. * 엘리베이터 상향호출 타임아웃을 시작한다.
  334. */
  335. private void TimeOutStart() {
  336. try {
  337. if (mElevatorTimer == null) return;
  338. mElevatorTimer.cancel();
  339. mElevatorTimer.start();
  340. } catch (RuntimeException re) {
  341. LogUtil.errorLogInfo("", TAG, re);
  342. }
  343. catch (Exception e) {
  344. Log.e(TAG, "[Exception] TimeOutStart()");
  345. //e.printStackTrace();
  346. LogUtil.errorLogInfo("", TAG, e);
  347. }
  348. }
  349. /**
  350. * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
  351. *
  352. * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
  353. */
  354. private void SendNotifyKindBR(int kind) {
  355. try {
  356. Intent notiIntent = new Intent();
  357. notiIntent.setAction(define.NOTIFY_ACNAME);
  358. notiIntent.putExtra(define.NOTIBR_KIND, kind);
  359. getApplicationContext().sendBroadcast(notiIntent);
  360. } catch (RuntimeException re) {
  361. LogUtil.errorLogInfo("", TAG, re);
  362. }
  363. catch (Exception e) {
  364. Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
  365. //e.printStackTrace();
  366. LogUtil.errorLogInfo("", TAG, e);
  367. }
  368. }
  369. }
  370. /** 엘리베이터 상향호출 Class */
  371. private ElevatorClass ElevatorUp;
  372. /** 엘리베이터 하향호출 Class */
  373. private ElevatorClass ElevatorDown;
  374. /**
  375. * 엘리베이터 호출한다.
  376. *
  377. * @param Up (boolean) true : 상향, false : 하향
  378. */
  379. private void CallElevatorBtn(boolean Up) {
  380. try {
  381. Log.i(TAG, "[CallElevatorBtn] Up [" + Up +"]");
  382. if (Up) {
  383. // 상향호출
  384. if (ElevatorUp == null) {
  385. Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
  386. return;
  387. }
  388. ElevatorUp.CallElevator();
  389. }
  390. else {
  391. // 하향호출
  392. if (ElevatorDown == null) {
  393. Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
  394. return;
  395. }
  396. ElevatorDown.CallElevator();
  397. }
  398. } catch (RuntimeException re) {
  399. LogUtil.errorLogInfo("", TAG, re);
  400. }
  401. catch (Exception e) {
  402. Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
  403. //e.printStackTrace();
  404. LogUtil.errorLogInfo("", TAG, e);
  405. }
  406. }
  407. ////////////////////////////////////////////////////////////////////////////////
  408. ////////////////////////////////////////////////////////////////////////////////
  409. @Override
  410. public void onCreate() {
  411. try {
  412. super.onCreate();
  413. Log.i(TAG, "[onCreate] ========== START ==========");
  414. setGlobalScreenAppRunningStatus(false);
  415. ModelType = Version.getModelType();
  416. mSound = new WpadSound(getApplicationContext());
  417. ElevatorUp = new ElevatorClass(true);
  418. ElevatorDown = new ElevatorClass(false);
  419. }
  420. catch (RuntimeException re)
  421. {
  422. Log.e(TAG, "[Exception] onCreate()");
  423. //e.printStackTrace();
  424. LogUtil.errorLogInfo("", TAG, re);
  425. }
  426. catch (Exception e) {
  427. Log.e(TAG, "[Exception] onCreate()");
  428. //e.printStackTrace();
  429. LogUtil.errorLogInfo("", TAG, e);
  430. }
  431. }
  432. private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
  433. try {
  434. Intent notiIntent = new Intent();
  435. notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  436. notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  437. notiIntent.putExtra("ElevatorFloor", eStatus.toString());
  438. getApplicationContext().sendBroadcast(notiIntent);
  439. } catch (RuntimeException re) {
  440. LogUtil.errorLogInfo("", TAG, re);
  441. }
  442. catch (Exception e) {
  443. Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
  444. //e.printStackTrace();
  445. LogUtil.errorLogInfo("", TAG, e);
  446. }
  447. }
  448. protected String GetForegroundAPP() {
  449. try {
  450. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  451. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  452. ComponentName topActivity=taskInfo.get(0).topActivity;
  453. String str=topActivity.getPackageName();
  454. return str;
  455. } catch (RuntimeException re) {
  456. LogUtil.errorLogInfo("", TAG, re);
  457. return " ";
  458. }
  459. catch (Exception e) {
  460. Log.e(TAG, "[Exception] GetForegroundAPP()");
  461. //e.printStackTrace();
  462. LogUtil.errorLogInfo("", TAG, e);
  463. return " ";
  464. }
  465. }
  466. long lSavedTimestamp = 0;
  467. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  468. public void onReceive(Context context, Intent intent) {
  469. try {
  470. String strActionName = intent.getAction();
  471. Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName+ "]");
  472. if (strActionName.equals(define.NOTIFY_DAIL)) {
  473. long lTimestamp = System.currentTimeMillis();
  474. long lInterval = lTimestamp - lSavedTimestamp;
  475. if (lInterval <1000) return;
  476. else Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval+ "]");
  477. lSavedTimestamp = lTimestamp;
  478. if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  479. if (mSdb_LivingRoomLightAPI == null) {
  480. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
  481. return;
  482. }
  483. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  484. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  485. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  486. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  487. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  488. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  489. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  490. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  491. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  492. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  493. mSdb_LivingRoomLightAPI.SetControlMode(false);
  494. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  495. }
  496. return;
  497. }
  498. if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
  499. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  500. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  501. return;
  502. }
  503. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
  504. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  505. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  506. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  507. }
  508. else {
  509. setGlobalScreenAppRunningStatus(false);
  510. }
  511. }
  512. else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  513. if (mKnx_LivingRoomLightAPI == null) {
  514. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
  515. return;
  516. }
  517. byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
  518. byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
  519. byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
  520. byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
  521. byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
  522. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
  523. if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
  524. Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
  525. // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
  526. if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
  527. mKnx_LivingRoomLightAPI.SetControlMode(false);
  528. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
  529. }
  530. return;
  531. }
  532. if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
  533. // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
  534. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
  535. return;
  536. }
  537. for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
  538. 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 + "]");
  539. }
  540. if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
  541. Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
  542. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
  543. }
  544. else {
  545. setGlobalScreenAppRunningStatus(false);
  546. }
  547. }
  548. else {
  549. Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
  550. }
  551. }
  552. else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
  553. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  554. }
  555. else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  556. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  557. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind+ "]");
  558. switch (kind) {
  559. case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
  560. procUploadMissedVisitorPic(intent);
  561. break;
  562. case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
  563. // bBlockCallEvent = true;
  564. // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
  565. break;
  566. case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
  567. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
  568. Sound().Play(SND.mode.NORMALMODE_COMEBACK);
  569. break;
  570. case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE :
  571. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
  572. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  573. break;
  574. case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK :
  575. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
  576. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  577. break;
  578. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
  579. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
  580. CallElevatorBtn(false);
  581. break;
  582. case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
  583. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
  584. CallElevatorBtn(true);
  585. break;
  586. case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING :
  587. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
  588. // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
  589. int CalledWallPadUI = intent.getIntExtra("Called",0);
  590. if (CalledWallPadUI == 1) {
  591. ModeRunCtrlWorking(true , false);
  592. }
  593. else {
  594. ModeRunCtrlWorking(false, false);
  595. }
  596. break;
  597. case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING :
  598. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
  599. ModeReleaseCtrlWorking(false);
  600. break;
  601. case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK :
  602. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
  603. CheckMainStatus();
  604. break;
  605. case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING :
  606. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
  607. ModeRunCtrlWorking(false, false);
  608. break;
  609. case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING :
  610. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
  611. ModeReleaseCtrlWorking(false);
  612. break;
  613. case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE :
  614. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
  615. if (ElevatorUp != null && ElevatorDown != null) {
  616. boolean UpCalling = ElevatorUp.getElevatorCalling();
  617. boolean DownCalling = ElevatorDown.getElevatorCalling();
  618. Log.d( TAG , "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling );
  619. ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
  620. if (UpCalling && DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
  621. else if (UpCalling && !DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.UP;
  622. else if (!UpCalling && DownCalling) Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
  623. else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
  624. Log.d(TAG , " ElvCallState : " + ElvCallState );
  625. SendBRElevatorCallState(ElvCallState);
  626. // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  627. // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
  628. // sendIntent.putExtra("ELV", ElvCallState);
  629. // getApplicationContext().sendBroadcast(sendIntent);
  630. }
  631. break;
  632. case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
  633. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
  634. try {
  635. if (ScheServer != null) {
  636. ScheServer.SetLive();
  637. }
  638. } catch (RuntimeException re) {
  639. LogUtil.errorLogInfo("", TAG, re);
  640. }
  641. catch (Exception e) {
  642. //e.printStackTrace();
  643. LogUtil.errorLogInfo("", TAG, e);
  644. }
  645. break;
  646. case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
  647. Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
  648. stopIGW300RingGenerator();
  649. break;
  650. }
  651. }
  652. else if (strActionName.equals(define.NOTIFY_ACNAME)) {
  653. int kind = intent.getIntExtra("KIND",0);
  654. Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind+ "]");
  655. switch (kind) {
  656. case define.NOTIFY_SERVER_VERSION:
  657. try {
  658. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
  659. iMapSverReload tSock = new iMapSverReload();
  660. tSock.start();
  661. } catch (IOException e) {
  662. Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
  663. //e.printStackTrace();
  664. LogUtil.errorLogInfo("", TAG, e);
  665. }
  666. break;
  667. case define.NOTIFY_DEVICE_ELE_CALL_UP:
  668. // 제어기기 엘리베이터 상향 호출 요청
  669. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
  670. CallElevatorBtn(true);
  671. break;
  672. case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
  673. // 제어기기에서 엘리베이터 하향 호출 요청
  674. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
  675. CallElevatorBtn(false);
  676. break;
  677. case define.NOTIFY_SUBDEVCALLBUSY:
  678. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
  679. CallConnected = true;
  680. break;
  681. case define.NOTIFY_SUBDEVCALLEND:
  682. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
  683. CallConnected = false;
  684. break;
  685. case define.NOTIFY_STARTHEARTBEAT:
  686. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
  687. {
  688. Message msg = ScheDulerHandler.obtainMessage();
  689. msg.what = SCHEDULE_CHANGE_HEARTBEAT;
  690. ScheDulerHandler.sendMessage(msg);
  691. }
  692. break;
  693. case define.NOTIFY_STARTSTATUSBEAT:
  694. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
  695. {
  696. Message msg = ScheDulerHandler.obtainMessage();
  697. msg.what = SCHEDULE_START_STATUSBEAT;
  698. ScheDulerHandler.sendMessage(msg);
  699. }
  700. break;
  701. case define.NOTIFY_OUTGOINGSETTED:
  702. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
  703. OutGoingSensorWaiting = 0;
  704. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  705. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  706. sdata.closeDB();
  707. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  708. WallPadInterface wpifc = new WallPadInterface();
  709. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0 )
  710. OutGoingSensorWaiting |= SENSOR_MAG;
  711. int[] SensorInfoDB;
  712. int sensorIn = 0;
  713. int sensorOut = 0;
  714. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  715. if (SensorInfoDB[0] == 1) {
  716. // 내부동체가 사용함이면 상태 검사
  717. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  718. }
  719. if (SensorInfoDB[1] == 1) {
  720. // 외부동체가 사용함이면 상태 검사
  721. if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  722. }
  723. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
  724. // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
  725. if (OutGoingSensorWaiting > 0) {
  726. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  727. SensorThread.start();
  728. }
  729. break;
  730. case define.NOTIFY_DOOR_SET_DELAY:
  731. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
  732. DoorDelayTime = System.currentTimeMillis();
  733. imapsvrlog("Receive "+define.NOTIFY_DOOR_SET_DELAY+" Set : " +DoorDelayTime);
  734. break;
  735. case define.NOTIFY_DEVICE_INIT_COMPLETION :
  736. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
  737. Common.setDeviceServeiceLoadComplite();
  738. startRealtimemeterInfo(); // 실시간 검침기 확인
  739. startSmartIoTCamInfo(); // 스마트현관카메라 확인
  740. startDistributionPanel(); // 분전반 확인
  741. getRoomName();
  742. break;
  743. case define.NOTIFY_DLOCK_SET_OUTING:
  744. // 도어락 외출모드 / 대외향 RF 카드 외출모드
  745. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
  746. try {
  747. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  748. int AlarmStatus = DBMGR.GetAlarmStatus();
  749. DBMGR.closeDB();
  750. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  751. // 센서 체크하고
  752. // 현관폰으로 사운드 출력하고
  753. boolean bSensorOk = false;
  754. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  755. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  756. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  757. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  758. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  759. bSensorOk = mIGW300.checkSensorforOutmode();
  760. }
  761. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  762. bSensorOk = mIGW200.checkSensorforOutmode();
  763. }
  764. else {
  765. bSensorOk = checkSensorforOutmode();
  766. }
  767. if (bSensorOk) {
  768. playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  769. CallOutModeRunActivity();
  770. }
  771. else {
  772. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  773. }
  774. }
  775. } catch (RuntimeException re) {
  776. LogUtil.errorLogInfo("", TAG, re);
  777. }
  778. catch (Exception e) {
  779. //e.printStackTrace();
  780. LogUtil.errorLogInfo("", TAG, e);
  781. }
  782. break;
  783. case define.NOTIFY_DLOCK_FREE_OUTING:
  784. // 도어락 외출모드 해제
  785. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
  786. try {
  787. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  788. int AlarmStatus = DBMGR.GetAlarmStatus();
  789. DBMGR.closeDB();
  790. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  791. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK );
  792. Common.SendAppFinishReqBR(getApplicationContext());
  793. //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
  794. WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
  795. int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
  796. devDB.closeDB();
  797. if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
  798. mWallPadAPI.SetDoorLock_Open_ForRFCamera();
  799. }
  800. }
  801. } catch (RuntimeException re) {
  802. LogUtil.errorLogInfo("", TAG, re);
  803. }
  804. catch (Exception e) {
  805. //e.printStackTrace();
  806. LogUtil.errorLogInfo("", TAG, e);
  807. }
  808. break;
  809. case define.NOTIFY_SMARTSW_SET_OUTING:
  810. // 485 대외향 스마트스위치 외출모드
  811. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
  812. setUnoccupiedModeByNotHDCSmartSwitch();
  813. break;
  814. case define.NOTIFY_SMARTSW_FREE_OUTING:
  815. //대외향 485 스마트스위치 외출모드 해제
  816. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
  817. releaseUnoccupiedModeByNotHDCSmartSwitch();
  818. break;
  819. case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
  820. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
  821. String Type = intent.getStringExtra("TYPE");
  822. String Device = intent.getStringExtra("DEVICE");
  823. String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
  824. String CauseType = intent.getStringExtra("CAUSE_TYPE");
  825. String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
  826. iMAPSmartLightEvent imapSmartLightEvent;
  827. imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
  828. imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
  829. imapSmartLightEvent.SetRetCtr(new RetProci() {
  830. @Override
  831. public void ProcSuccess() {
  832. Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
  833. }
  834. @Override
  835. public void ProcError() {
  836. Log.e(TAG, "iMAPSmartLightEvent ProcError");
  837. }
  838. @Override
  839. public void ProcDoing() {
  840. Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
  841. }
  842. });
  843. break;
  844. case define.NOTIFY_KNX_DEVICE_EVENT:
  845. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
  846. String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
  847. String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
  848. String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
  849. String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
  850. String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
  851. iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
  852. iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
  853. iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
  854. iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
  855. @Override
  856. public void ProcSuccess() {
  857. Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
  858. }
  859. @Override
  860. public void ProcError() {
  861. Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
  862. }
  863. @Override
  864. public void ProcDoing() {
  865. Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
  866. }
  867. });
  868. break;
  869. case define.NOTIFY_SMART_DCAM_DETECT:
  870. // 스마트현관카메라 거동수상자 발생
  871. // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
  872. //jglee - 통화중일 경우
  873. if(Common.bWallPadCallingLive || bBlockFrontCall)
  874. {
  875. //현관문일 경우만 return 함
  876. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "] return - BR_RECORD_DELAY");
  877. Intent Newintent = new Intent();
  878. Newintent.setAction(Common.BR_RECORD_DELAY);
  879. getApplicationContext().sendBroadcast(Newintent);
  880. Log.w(TAG, "jglee - StrangeRecord Delay by Call");
  881. return;
  882. }
  883. if(Common.bRecordDelay)
  884. {
  885. Log.w(TAG, "jglee - [NOTIFY_SMART_DCAM_DETECT] bRecordDelay is return ");
  886. return;
  887. }
  888. Log.i(TAG, "jglee - [mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  889. //Call앱이 실행되어 있지 않으면서, 현관호출이 아닌경우
  890. if (!bWallPadCallLive && !bBlockFrontCall) {
  891. if (getStrangerRecordingManagerSetting()) {
  892. if (getStrangerRecordingUserSetting()) {
  893. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
  894. //거동 수상자 감지 또는 딜레인 경우 처리
  895. if(Common.bRecordStatus && !bWallPadCallLive)
  896. {
  897. Common.bRecordStatus = false;
  898. Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording Status Error is Status -> false");
  899. }
  900. if(Common.bRecordDelay || Common.bRecordStatus)
  901. {
  902. Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording is return ");
  903. return;
  904. }
  905. //거동 수상자 신호가 이중으로 빨리 오는 경우에 대한 처리가 필요
  906. Log.d(TAG, "Strange Recording Start - BR_RECORD_DELAY");
  907. Intent DelayIntent = new Intent();
  908. DelayIntent.setAction(Common.BR_RECORD_DELAY);
  909. getApplicationContext().sendBroadcast(DelayIntent);
  910. Log.w(TAG, "jglee - Strange Record Start so Delay Start");
  911. Intent Newintent = new Intent();
  912. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  913. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
  914. Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
  915. getApplicationContext().sendBroadcast(Newintent);
  916. Log.d(TAG, "Strange Recording Start");
  917. }
  918. else {
  919. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  920. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  921. Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  922. }
  923. }
  924. else {
  925. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  926. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  927. Log.w(TAG, "jglee - [mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  928. }
  929. }
  930. else {
  931. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  932. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  933. //MOIP 통화 중, 거동 수상자 신호가 들어오는 경우 중복 신호 방지
  934. //MOIP 통화 중, 거동 수상자 신호 입력에 대해서는 Call 내부에서 처리됨
  935. if(Common.bWallPadCallLive)
  936. {
  937. Log.w(TAG, "jglee - StrangeRecord Delay by Call - BR_RECORD_DELAY");
  938. Intent Newintent = new Intent();
  939. Newintent.setAction(Common.BR_RECORD_DELAY);
  940. getApplicationContext().sendBroadcast(Newintent);
  941. }
  942. Log.w(TAG, "jglee - [mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
  943. }
  944. break;
  945. case define.NOTIFY_SMART_DCAM_RELEASE:
  946. // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
  947. break;
  948. case define.NOTIFY_ACCEPT_RECORD_STRANGER:
  949. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
  950. if (getStrangerRecordingManagerSetting()) {
  951. if (getStrangerRecordingUserSetting()) {
  952. // 알람 상태 확인
  953. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  954. int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
  955. mWallpadStatusData.closeDB();
  956. Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
  957. if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  958. // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
  959. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  960. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  961. }
  962. else {
  963. Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
  964. Intent Newintent = new Intent();
  965. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  966. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
  967. Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
  968. getApplicationContext().sendBroadcast(Newintent);
  969. }
  970. }
  971. else {
  972. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
  973. }
  974. }
  975. else {
  976. Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
  977. }
  978. break;
  979. case define.NOTIFY_REJECT_RECORD_STRANGER:
  980. case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
  981. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
  982. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
  983. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  984. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  985. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  986. }
  987. break;
  988. case define.NOTIFY_ROOMNAME_CHANGED:
  989. getRoomName();
  990. break;
  991. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
  992. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
  993. break;
  994. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
  995. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
  996. break;
  997. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
  998. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
  999. break;
  1000. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
  1001. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
  1002. break;
  1003. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
  1004. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
  1005. break;
  1006. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
  1007. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
  1008. break;
  1009. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
  1010. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
  1011. break;
  1012. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
  1013. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
  1014. break;
  1015. case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
  1016. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
  1017. break;
  1018. case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
  1019. Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
  1020. break;
  1021. default:
  1022. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  1023. break;
  1024. }
  1025. }
  1026. } catch (RuntimeException re) {
  1027. LogUtil.errorLogInfo("", TAG, re);
  1028. }
  1029. catch (Exception e) {
  1030. Log.e(TAG, "[Exception] mWallPadNotifyBR");
  1031. //e.printStackTrace();
  1032. LogUtil.errorLogInfo("", TAG, e);
  1033. }
  1034. }
  1035. };
  1036. private void setUnoccupiedModeByNotHDCSmartSwitch() {
  1037. try {
  1038. Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
  1039. // 485 대외향 스마트스위치 외출모드
  1040. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1041. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1042. // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
  1043. boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
  1044. mWallpadStatusData.closeDB();
  1045. if (UseGuardSensorCheck == false) {
  1046. // 그냥 외출모드 처리 .. 기기 연동 처리만
  1047. if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
  1048. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1049. mWallpadStatusData.SetAlarmStatus (WallpadStatusData.OUT_MODE);
  1050. mWallpadStatusData.closeDB();
  1051. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  1052. //메인화면 업데이트
  1053. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1054. getApplicationContext().sendBroadcast(newIntent);
  1055. ModeRunCtrlWorking(false , false);
  1056. }
  1057. }
  1058. else {
  1059. // 실제 외출 방범 모드를 설정하도록 한다.
  1060. Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
  1061. if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
  1062. // 센서 체크하고
  1063. // 센서 체크하는 부분이 들어가야 함
  1064. Common.SendAppFinishReqBR(getApplicationContext());
  1065. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1066. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1067. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1068. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1069. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1070. if (mIGW300.checkSensorforOutmode()) {
  1071. CallOutModeWaitingActivity(AlarmStatus);
  1072. }
  1073. else {
  1074. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  1075. }
  1076. }
  1077. else {
  1078. if (checkSensorforOutmode()) {
  1079. //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
  1080. CallOutModeWaitingActivity(AlarmStatus);
  1081. }
  1082. else {
  1083. playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK );
  1084. }
  1085. }
  1086. }
  1087. }
  1088. } catch (RuntimeException re) {
  1089. LogUtil.errorLogInfo("", TAG, re);
  1090. }
  1091. catch (Exception e) {
  1092. Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
  1093. //e.printStackTrace();
  1094. LogUtil.errorLogInfo("", TAG, e);
  1095. }
  1096. }
  1097. private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
  1098. try {
  1099. Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
  1100. //대외향 485 스마트스위치 외출모드 해제
  1101. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1102. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  1103. boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
  1104. mWallpadStatusData.closeDB();
  1105. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease +"]");
  1106. if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1107. if (OutModePwRelease) {
  1108. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
  1109. // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
  1110. // 요청하여도 해제 되지 않으며
  1111. // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
  1112. Intent notiIntent = new Intent();
  1113. notiIntent.setAction(define.NOTIFY_ACNAME);
  1114. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1115. getApplicationContext().sendBroadcast(notiIntent);
  1116. }
  1117. else {
  1118. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
  1119. // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
  1120. // 처리하고.
  1121. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1122. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1123. mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  1124. mWallpadStatusData.closeDB();
  1125. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  1126. Common.SendAppFinishReqBR(getApplicationContext());
  1127. }
  1128. }
  1129. else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  1130. // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
  1131. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
  1132. ModeReleaseCtrlWorking(false);
  1133. bSmartSwitch485ComebackMode = true;
  1134. Intent notiIntent = new Intent();
  1135. notiIntent.setAction(define.NOTIFY_ACNAME);
  1136. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
  1137. getApplicationContext().sendBroadcast(notiIntent);
  1138. }
  1139. else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
  1140. Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
  1141. // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
  1142. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  1143. mWallpadStatusData.SetAlarmStatus (WallpadStatusData.ALARM_NONE);
  1144. mWallpadStatusData.closeDB();
  1145. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK );
  1146. //메인화면 업데이트
  1147. Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1148. getApplicationContext().sendBroadcast(newIntent);
  1149. ModeReleaseCtrlWorking(false);
  1150. }
  1151. } catch (RuntimeException re) {
  1152. LogUtil.errorLogInfo("", TAG, re);
  1153. }
  1154. catch (Exception e) {
  1155. Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
  1156. //e.printStackTrace();
  1157. LogUtil.errorLogInfo("", TAG, e);
  1158. }
  1159. }
  1160. /**
  1161. * 스마트현관카메라 녹화 여부 판별
  1162. * 사용자 화면에서 설정
  1163. */
  1164. private boolean getStrangerRecordingUserSetting() {
  1165. boolean bResult = false;
  1166. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1167. try {
  1168. bResult = DBMGR.GetStrangerRecordingOnOff();
  1169. DBMGR.closeDB();
  1170. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
  1171. } catch (RuntimeException re) {
  1172. LogUtil.errorLogInfo("", TAG, re);
  1173. DBMGR.closeDB();
  1174. bResult = false;
  1175. }
  1176. catch (Exception e) {
  1177. DBMGR.closeDB();
  1178. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1179. //e.printStackTrace();
  1180. LogUtil.errorLogInfo("", TAG, e);
  1181. bResult = false;
  1182. }
  1183. return bResult;
  1184. }
  1185. private boolean getStrangerTakePic() {
  1186. try {
  1187. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1188. boolean bResult = DBMGR.GetStrangerTakePicOnOff();
  1189. DBMGR.closeDB();
  1190. Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
  1191. return bResult;
  1192. } catch (RuntimeException re) {
  1193. LogUtil.errorLogInfo("", TAG, re);
  1194. return false;
  1195. }
  1196. catch (Exception e) {
  1197. Log.e(TAG, "[Exception] getStrangerTakePic()");
  1198. //e.printStackTrace();
  1199. LogUtil.errorLogInfo("", TAG, e);
  1200. return false;
  1201. }
  1202. }
  1203. // 관리자 설정 항목에 있음
  1204. private boolean getStrangerRecordUsage() {
  1205. try {
  1206. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  1207. boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
  1208. mWallpadDeviceSet .closeDB();
  1209. Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
  1210. return bResult;
  1211. } catch (RuntimeException re) {
  1212. LogUtil.errorLogInfo("", TAG, re);
  1213. return false;
  1214. }
  1215. catch (Exception e) {
  1216. Log.e(TAG, "[Exception] getStrangerRecordUsage()");
  1217. //e.printStackTrace();
  1218. LogUtil.errorLogInfo("", TAG, e);
  1219. return false;
  1220. }
  1221. }
  1222. private boolean checkSensorforOutmode() {
  1223. try {
  1224. WallPadInterface wallPadInterface = new WallPadInterface();
  1225. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1226. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1227. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1228. int[] SensorInfoDB;
  1229. int sensorIn = 0;
  1230. int sensorOut = 0;
  1231. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  1232. Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
  1233. if (SensorInfoDB[0] == 1) {
  1234. // 내부동체가 사용함이면 상태 검사
  1235. sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1236. Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
  1237. }
  1238. if (SensorInfoDB[1] == 1) {
  1239. // 외부동체가 사용함이면 상태 검사
  1240. sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1241. Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
  1242. }
  1243. // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  1244. // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  1245. // 동체 사용 설정 체크..
  1246. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1247. int sensor = devSet.Get_Sensor_Set();
  1248. Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
  1249. devSet.closeDB();
  1250. int OtherInSensor = 0;
  1251. // 내부동체 사용안함 이면
  1252. if ((sensor&WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
  1253. // 외부동체 사용안함 이면
  1254. if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
  1255. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
  1256. if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
  1257. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1258. return true;
  1259. }
  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. }
  1268. catch (Exception e) {
  1269. //e.printStackTrace();
  1270. LogUtil.errorLogInfo("", TAG, e);
  1271. return false;
  1272. }
  1273. }
  1274. private boolean checkSensorforInmode() {
  1275. try {
  1276. WallPadInterface wallPadInterface = new WallPadInterface();
  1277. Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
  1278. int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  1279. Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
  1280. Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
  1281. if (sensorMag == 0) {
  1282. Log.w(TAG, "[checkSensorforOutmode] Result -> true");
  1283. return true;
  1284. }
  1285. else {
  1286. Log.w(TAG, "[checkSensorforOutmode] Result -> false");
  1287. return false;
  1288. }
  1289. } catch (RuntimeException re) {
  1290. LogUtil.errorLogInfo("", TAG, re);
  1291. return false;
  1292. }
  1293. catch (Exception e) {
  1294. Log.e(TAG, e.toString());
  1295. //e.printStackTrace();
  1296. LogUtil.errorLogInfo("", TAG, e);
  1297. return false;
  1298. }
  1299. }
  1300. /////////////////////
  1301. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1302. //////////////
  1303. /////////////////////
  1304. // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
  1305. //////////////
  1306. public void playSoundthroughDoorphone(int SoundIdx) {
  1307. try
  1308. {
  1309. WallPadInterface Wiface = new WallPadInterface();
  1310. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  1311. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1312. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1313. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1314. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1315. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1316. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  1317. if (getUseSmartDoorCam()) {
  1318. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
  1319. }
  1320. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
  1321. /*
  1322. JEFF (2019.01.14)
  1323. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1324. 강신구입니다.
  1325. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1326. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1327. 내용 공유합니다.
  1328. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1329. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1330. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1331. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1332. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1333. 문제 없습니다.
  1334. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1335. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1336. 문의사항은 하기 연락바랍니다.
  1337. 감사합니다.
  1338. */
  1339. mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
  1340. }
  1341. else {
  1342. // 대외향 모델 처리
  1343. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1344. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
  1345. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  1346. }
  1347. try{Thread.sleep(100);}
  1348. catch (RuntimeException re) {
  1349. LogUtil.errorLogInfo("", TAG, re);
  1350. }
  1351. catch (Exception e){
  1352. LogUtil.errorLogInfo("", TAG, e);
  1353. }
  1354. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1355. amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  1356. try{Thread.sleep(1500);}
  1357. catch (RuntimeException re) {
  1358. LogUtil.errorLogInfo("", TAG, re);
  1359. }
  1360. catch (Exception e){
  1361. LogUtil.errorLogInfo("", TAG, e);
  1362. }
  1363. WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
  1364. int SLevel = Wdb.GetDoorSoundLevel();
  1365. Wdb.closeDB();
  1366. Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
  1367. if (SLevel != -1) {
  1368. /**
  1369. * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
  1370. * **/
  1371. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
  1372. }
  1373. else {
  1374. // 사용안함이면
  1375. Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
  1376. }
  1377. // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
  1378. int time = Sound().PlayMent(SoundIdx);
  1379. Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
  1380. if (0 > time) {
  1381. Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
  1382. time = 1000;
  1383. }
  1384. try{Thread.sleep(time + 1000);}
  1385. catch (RuntimeException re) {
  1386. LogUtil.errorLogInfo("", TAG, re);
  1387. }
  1388. catch (Exception e){
  1389. LogUtil.errorLogInfo("", TAG, e);
  1390. }
  1391. amanager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1392. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1393. try{Thread.sleep(100);}
  1394. catch (RuntimeException re) {
  1395. LogUtil.errorLogInfo("", TAG, re);
  1396. }
  1397. catch (Exception e){
  1398. LogUtil.errorLogInfo("", TAG, e);
  1399. }
  1400. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1401. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1402. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1403. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  1404. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1405. mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
  1406. if (getUseSmartDoorCam()) {
  1407. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  1408. }
  1409. Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
  1410. /*
  1411. JEFF (2019.01.14)
  1412. << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
  1413. 강신구입니다.
  1414. 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
  1415. 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
  1416. 내용 공유합니다.
  1417. 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
  1418. HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
  1419. IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
  1420. 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
  1421. 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
  1422. 문제 없습니다.
  1423. 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
  1424. 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
  1425. 문의사항은 하기 연락바랍니다.
  1426. 감사합니다.
  1427. */
  1428. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
  1429. }
  1430. else {
  1431. // 대외향 모델 처리
  1432. // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
  1433. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1434. Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
  1435. }
  1436. mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
  1437. } catch (RuntimeException re) {
  1438. LogUtil.errorLogInfo("", TAG, re);
  1439. }
  1440. catch (Exception e) {
  1441. //e.printStackTrace();
  1442. LogUtil.errorLogInfo("", TAG, e);
  1443. }
  1444. }
  1445. public void CallOutModeRunActivity() {
  1446. int base = 8000;
  1447. int [] Menu_Id_List = { base + 11 };
  1448. int Menu_StartId = base + 11;
  1449. int Menu_Option = -1;
  1450. Intent intent = new Intent(Intent.ACTION_MAIN);
  1451. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1452. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1453. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1454. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  1455. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1456. startActivity(intent);
  1457. }
  1458. public void CallOutModeWaitingActivity(int nAlarmStatus) {
  1459. Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
  1460. int base = 4000;
  1461. int [] Menu_Id_List = { base + 11 , base + 21};
  1462. int Menu_StartId = base + 11;
  1463. int Menu_Option = 1000;
  1464. Intent intent = new Intent(Intent.ACTION_MAIN);
  1465. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  1466. intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
  1467. intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
  1468. intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
  1469. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity","kr.co.icontrols.wallpadsecurity.MainActivity"));
  1470. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1471. startActivity(intent);
  1472. }
  1473. private boolean getGlobalScreenAppRunningStatus() {
  1474. boolean bRunning = false;
  1475. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1476. try {
  1477. bRunning = DBMGR.getGlobalScreenAPKRun();
  1478. DBMGR.closeDB();
  1479. Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
  1480. return bRunning;
  1481. } catch (RuntimeException re) {
  1482. LogUtil.errorLogInfo("", TAG, re);
  1483. DBMGR.closeDB();
  1484. }
  1485. catch (Exception e) {
  1486. Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
  1487. //e.printStackTrace();
  1488. LogUtil.errorLogInfo("", TAG, e);
  1489. DBMGR.closeDB();
  1490. }
  1491. return bRunning;
  1492. }
  1493. private void setGlobalScreenAppRunningStatus(boolean bRun) {
  1494. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
  1495. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1496. try {
  1497. boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
  1498. Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
  1499. DBMGR.closeDB();
  1500. } catch (RuntimeException re) {
  1501. LogUtil.errorLogInfo("", TAG, re);
  1502. DBMGR.closeDB();
  1503. }
  1504. catch (Exception e) {
  1505. Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
  1506. //e.printStackTrace();
  1507. LogUtil.errorLogInfo("", TAG, e);
  1508. DBMGR.closeDB();
  1509. }
  1510. }
  1511. String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
  1512. boolean bGlobalScreenRun = false;
  1513. public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1514. try {
  1515. Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel +"], hColor [" + hColor +"], hControl [" + hControl +"]");
  1516. wakeupLCD();
  1517. if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
  1518. setGlobalScreenAppRunningStatus(true);
  1519. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1520. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1521. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1522. mIntent.putExtra("ONOFF", hOnOff);
  1523. mIntent.putExtra("DIAL", hDial);
  1524. mIntent.putExtra("LEVEL", hLevel);
  1525. mIntent.putExtra("COLOR", hColor);
  1526. mIntent.putExtra("CONTROL", hControl);
  1527. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1528. mIntent.setComponent(mComponentName);
  1529. startActivity(mIntent);
  1530. }
  1531. else {
  1532. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1533. }
  1534. } catch (RuntimeException re) {
  1535. LogUtil.errorLogInfo("", TAG, re);
  1536. }
  1537. catch (Exception e) {
  1538. Log.e(TAG, "[Exception] runGlobalScreenAPK()");
  1539. //e.printStackTrace();
  1540. LogUtil.errorLogInfo("", TAG, e);
  1541. }
  1542. }
  1543. public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
  1544. try {
  1545. Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel +"], hColor [" + hColor +"], hControl [" + hControl +"]");
  1546. wakeupLCD();
  1547. if (!getGlobalScreenAppRunningStatus()) {
  1548. if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
  1549. Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
  1550. return;
  1551. }
  1552. setGlobalScreenAppRunningStatus(true);
  1553. sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
  1554. ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
  1555. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  1556. mIntent.putExtra("SCREENID", nScreenID);
  1557. mIntent.putExtra("ONOFF", hOnOff);
  1558. mIntent.putExtra("DIAL", hDial);
  1559. mIntent.putExtra("LEVEL", hLevel);
  1560. mIntent.putExtra("COLOR", hColor);
  1561. mIntent.putExtra("CONTROL", hControl);
  1562. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  1563. mIntent.setComponent(mComponentName);
  1564. startActivity(mIntent);
  1565. }
  1566. else {
  1567. Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
  1568. }
  1569. } catch (RuntimeException re) {
  1570. LogUtil.errorLogInfo("", TAG, re);
  1571. }
  1572. catch (Exception e) {
  1573. Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
  1574. //e.printStackTrace();
  1575. LogUtil.errorLogInfo("", TAG, e);
  1576. }
  1577. }
  1578. String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
  1579. public void sendBlackoutReleasedBR() {
  1580. try {
  1581. Intent notiIntent = new Intent();
  1582. notiIntent.setAction(strBLACKOUT_RELEASED);
  1583. getApplicationContext().sendBroadcast(notiIntent);
  1584. } catch (RuntimeException re) {
  1585. LogUtil.errorLogInfo("", TAG, re);
  1586. }
  1587. catch (Exception e) {
  1588. Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
  1589. //e.printStackTrace();
  1590. LogUtil.errorLogInfo("", TAG, e);
  1591. }
  1592. }
  1593. private int getCurrentScreen() {
  1594. int nScreenID = 0;
  1595. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1596. try {
  1597. nScreenID = DBMGR.GetCurrentScreenIDValue();
  1598. DBMGR.closeDB();
  1599. Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
  1600. return nScreenID;
  1601. } catch (RuntimeException re) {
  1602. LogUtil.errorLogInfo("", TAG, re);
  1603. DBMGR.closeDB();
  1604. }
  1605. catch (Exception e) {
  1606. Log.e(TAG, "[Exception] getCurrentScreen()");
  1607. //e.printStackTrace();
  1608. LogUtil.errorLogInfo("", TAG, e);
  1609. DBMGR.closeDB();
  1610. }
  1611. return nScreenID;
  1612. }
  1613. private void setCurrentScreen(int nScreenID) {
  1614. Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
  1615. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  1616. try {
  1617. DBMGR.SetCurrentScreenIDValue(nScreenID);
  1618. DBMGR.closeDB();
  1619. } catch (RuntimeException re) {
  1620. LogUtil.errorLogInfo("", TAG, re);
  1621. DBMGR.closeDB();
  1622. }
  1623. catch (Exception e) {
  1624. Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
  1625. //e.printStackTrace();
  1626. LogUtil.errorLogInfo("", TAG, e);
  1627. DBMGR.closeDB();
  1628. }
  1629. }
  1630. ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
  1631. private void procUploadMissedVisitorPic(Intent intent) {
  1632. try {
  1633. String strDong = intent.getStringExtra("DONG");
  1634. String strHo = intent.getStringExtra("HO");
  1635. Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
  1636. int nCnt = intent.getIntExtra("CNT", 0);
  1637. String[] strMissedPicURI = new String[nCnt];
  1638. strArrayMissedPicURI.clear();
  1639. for (int i = 0; i < nCnt; i++) {
  1640. strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
  1641. strArrayMissedPicURI.add(strMissedPicURI[i]);
  1642. Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
  1643. }
  1644. for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1645. Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
  1646. }
  1647. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1648. } catch (RuntimeException re) {
  1649. LogUtil.errorLogInfo("", TAG, re);
  1650. }
  1651. catch (Exception e) {
  1652. Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
  1653. //e.printStackTrace();
  1654. LogUtil.errorLogInfo("", TAG, e);
  1655. }
  1656. }
  1657. private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
  1658. try {
  1659. String strURI = "", strFileName = "", strTime = "", strType = "";
  1660. // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
  1661. // strURI = strArrayMissedPicURI.get(i).toString();
  1662. // strFileName = extractFileName(strURI);
  1663. // strTime = extractFileTime(strURI);
  1664. // strType = extractCallType(strFileName);
  1665. // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1666. // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1667. // }
  1668. if (strArrayMissedPicURI.size() > 0) {
  1669. strURI = strArrayMissedPicURI.get(0).toString();
  1670. strFileName = extractFileName(strURI);
  1671. strTime = extractFileTime(strFileName);
  1672. strType = extractCallType(strFileName);
  1673. Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
  1674. send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
  1675. }
  1676. else {
  1677. Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
  1678. }
  1679. } catch (RuntimeException re) {
  1680. LogUtil.errorLogInfo("", TAG, re);
  1681. }
  1682. catch (Exception e) {
  1683. Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
  1684. //e.printStackTrace();
  1685. LogUtil.errorLogInfo("", TAG, e);
  1686. }
  1687. }
  1688. public class uploadVisitorPicture extends Thread {
  1689. HDCFTPManager mFTPManager;
  1690. boolean bMainServer2dot0 = false;
  1691. int danjiserverType;
  1692. String strRemoteIP = "10.0.1.1";
  1693. String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
  1694. public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
  1695. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1696. try {
  1697. strDong = dong;
  1698. strHo = ho;
  1699. strType = type;
  1700. strTime = time;
  1701. strFileName = filename;
  1702. strUploadFile = uploadfile;
  1703. // bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
  1704. danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  1705. if(danjiserverType == define.DanjiServer1)
  1706. {
  1707. bMainServer2dot0 = false;
  1708. }
  1709. else if(danjiserverType == define.DanjiServer2)
  1710. {
  1711. bMainServer2dot0 = true;
  1712. }
  1713. else
  1714. {
  1715. bMainServer2dot0 = true;
  1716. }
  1717. Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
  1718. wallpadDeviceSet.closeDB();
  1719. Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile +"], strFileName [" + strFileName +"], strTime [" + strTime +"]");
  1720. } catch (RuntimeException re) {
  1721. LogUtil.errorLogInfo("", TAG, re);
  1722. }
  1723. catch (Exception e) {
  1724. Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
  1725. //e.printStackTrace();
  1726. LogUtil.errorLogInfo("", TAG, e);
  1727. }
  1728. }
  1729. public void run() {
  1730. try {
  1731. mFTPManager = new HDCFTPManager();
  1732. if (!mFTPManager.isFTPConnected()) {
  1733. boolean connect = false;
  1734. if(danjiserverType == define.DanjiServer1)
  1735. {
  1736. connect = mFTPManager.connectFTP(strRemoteIP);
  1737. }
  1738. else if(danjiserverType == define.DanjiServer2)
  1739. {
  1740. connect = mFTPManager.connectFTP(strRemoteIP);
  1741. }
  1742. else
  1743. {
  1744. connect = mFTPManager.connectFTP(define.NewDanjiServerIP);
  1745. }
  1746. if (!connect) {
  1747. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
  1748. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1749. return;
  1750. }
  1751. }
  1752. if (!mFTPManager.loginFTP(strUserID, strPW)) {
  1753. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
  1754. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1755. return;
  1756. }
  1757. if (!bMainServer2dot0) {
  1758. if (!mFTPManager.setPassiveMode()) {
  1759. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
  1760. disconnectFTP();
  1761. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1762. return;
  1763. }
  1764. }
  1765. if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
  1766. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
  1767. disconnectFTP();
  1768. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1769. return;
  1770. }
  1771. if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
  1772. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
  1773. disconnectFTP();
  1774. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1775. return;
  1776. }
  1777. if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
  1778. Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
  1779. disconnectFTP();
  1780. send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
  1781. return;
  1782. }
  1783. disconnectFTP();
  1784. Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
  1785. send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
  1786. sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1787. } catch (RuntimeException re) {
  1788. LogUtil.errorLogInfo("", TAG, re);
  1789. }
  1790. catch (Exception e) {
  1791. Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
  1792. //e.printStackTrace();
  1793. LogUtil.errorLogInfo("", TAG, e);
  1794. }
  1795. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1796. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1797. }
  1798. public boolean disconnectFTP() {
  1799. try {
  1800. if (mFTPManager.logoutFTP()) {
  1801. if (mFTPManager.disconnectFTP()) {
  1802. Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
  1803. return true;
  1804. }
  1805. }
  1806. Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
  1807. return false;
  1808. } catch (RuntimeException re) {
  1809. LogUtil.errorLogInfo("", TAG, re);
  1810. return false;
  1811. }
  1812. catch (Exception e) {
  1813. Log.e(TAG, "[Exception] disconnectFTP()");
  1814. //e.printStackTrace();
  1815. LogUtil.errorLogInfo("", TAG, e);
  1816. return false;
  1817. }
  1818. }
  1819. }
  1820. private String extractCallType(String strFileName) {
  1821. try {
  1822. Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
  1823. String[] strParse_01 = strFileName.split("_");
  1824. if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
  1825. else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
  1826. else return "none";
  1827. } catch (RuntimeException re) {
  1828. LogUtil.errorLogInfo("", TAG, re);
  1829. return null;
  1830. }
  1831. catch (Exception e) {
  1832. Log.e(TAG, "[Exception] extractCallType(String strFileName)");
  1833. //e.printStackTrace();
  1834. LogUtil.errorLogInfo("", TAG, e);
  1835. return null;
  1836. }
  1837. }
  1838. private String extractFileName(String strTargetFile) {
  1839. try {
  1840. Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
  1841. String[] strParse_01 = strTargetFile.split("/");
  1842. return strParse_01[strParse_01.length - 1];
  1843. } catch (RuntimeException re) {
  1844. LogUtil.errorLogInfo("", TAG, re);
  1845. return null;
  1846. }
  1847. catch (Exception e) {
  1848. Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
  1849. //e.printStackTrace();
  1850. LogUtil.errorLogInfo("", TAG, e);
  1851. return null;
  1852. }
  1853. }
  1854. private String extractFileTime(String strFileName) {
  1855. try {
  1856. Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
  1857. String[] strParse_01 = strFileName.split("\\.");
  1858. String[] strParse_02 = strParse_01[0].split("_");
  1859. // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
  1860. // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
  1861. // 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);
  1862. return strParse_02[5] + "_" + strParse_02[6];
  1863. } catch (RuntimeException re) {
  1864. LogUtil.errorLogInfo("", TAG, re);
  1865. return null;
  1866. }
  1867. catch (Exception e) {
  1868. Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
  1869. //e.printStackTrace();
  1870. LogUtil.errorLogInfo("", TAG, e);
  1871. return null;
  1872. }
  1873. }
  1874. String strRemoteURI, strUserID, strPW, strPath;
  1875. String strReply_User = "", strReply_PW = "", strReply_Path = "";
  1876. String strKey_Pass = "passwd";
  1877. 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) {
  1878. try {
  1879. Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
  1880. final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
  1881. if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1882. visitor_access_info.setResultCtrl(new RetProci() {
  1883. @Override
  1884. public void ProcSuccess() {
  1885. Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
  1886. visitor_access_info.SetItem("ftp_info");
  1887. strReply_User = visitor_access_info.GetAttributeVal(0, "user");
  1888. strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
  1889. strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
  1890. Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
  1891. strUserID = strReply_User;
  1892. strPW = strReply_PW;
  1893. strPath = strReply_Path;
  1894. strRemoteURI = strPath + "/" + strFileName;
  1895. // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1896. uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
  1897. mUploadVisitorPicture.start();
  1898. // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
  1899. // mUploadVisitorPicture.start();
  1900. }
  1901. @Override
  1902. public void ProcError() {
  1903. Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
  1904. if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
  1905. sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
  1906. prepareUploadPicturesOnFTPServer(strDong, strHo);
  1907. }
  1908. @Override
  1909. public void ProcDoing() {
  1910. Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
  1911. }
  1912. });
  1913. return true;
  1914. }
  1915. } catch (RuntimeException re) {
  1916. LogUtil.errorLogInfo("", TAG, re);
  1917. }
  1918. catch (Exception e) {
  1919. Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1920. //e.printStackTrace();
  1921. LogUtil.errorLogInfo("", TAG, e);
  1922. }
  1923. return false;
  1924. }
  1925. public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
  1926. try {
  1927. Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
  1928. final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
  1929. if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
  1930. visitor_upload_complete.setResultCtrl(new RetProci() {
  1931. @Override
  1932. public void ProcSuccess() {
  1933. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
  1934. }
  1935. @Override
  1936. public void ProcError() {
  1937. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
  1938. }
  1939. @Override
  1940. public void ProcDoing() {
  1941. Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
  1942. }
  1943. });
  1944. return true;
  1945. }
  1946. } catch (RuntimeException re) {
  1947. LogUtil.errorLogInfo("", TAG, re);
  1948. }
  1949. catch (Exception e) {
  1950. Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
  1951. //e.printStackTrace();
  1952. LogUtil.errorLogInfo("", TAG, e);
  1953. }
  1954. return false;
  1955. }
  1956. /**
  1957. * 이통사 연동 서비스를 위한 BR
  1958. * 방문자 사진이 발생 할때 BR 을 전송한다.
  1959. * @param kind (String) "lobby" or "home"
  1960. * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
  1961. */
  1962. public void sendVisitorEventBRtoMobileVendorSKT(String kind , String datetime) {
  1963. try {
  1964. Log.i(TAG, "[sendVisitorEventBRtoMobileVendorSKT] kind [" + kind + "], datetime [" + datetime + "]");
  1965. final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
  1966. final int BASE = define.BR_COM_MOBILE_SERVICE;
  1967. final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
  1968. Intent mIntent = new Intent();
  1969. mIntent.setAction(BR_VISITOR_EVENT);
  1970. mIntent.putExtra("KIND", kind);
  1971. mIntent.putExtra("TIME", datetime);
  1972. getApplicationContext().sendBroadcast(mIntent);
  1973. } catch (RuntimeException re) {
  1974. LogUtil.errorLogInfo("", TAG, re);
  1975. }
  1976. catch (Exception e) {
  1977. Log.e(TAG, "[Exception] sendVisitorEventBRtoMobileVendorSKT(String kind , String datetime)");
  1978. //e.printStackTrace();
  1979. LogUtil.errorLogInfo("", TAG, e);
  1980. }
  1981. }
  1982. BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
  1983. public void onReceive(Context context, Intent intent) {
  1984. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
  1985. Bundle bundle;
  1986. WallpadDeviceSet devset;
  1987. Intent newintent;
  1988. boolean CallAppRun = false;
  1989. boolean MgrAppRun = false;
  1990. final String packageName = "com.artncore.apps.ic_wallpad";
  1991. final String packageNameMgr = "com.artncore.managersetting";
  1992. //CallAppRun = getForegroundAPK().equals(packageName);
  1993. // CallAppRun = getCallAppRunning();
  1994. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  1995. int base = 7000;
  1996. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  1997. int Menu_Start_Option = 1;
  1998. if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
  1999. KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
  2000. int keyevt = ReceiveEvt.getKeyCode();
  2001. if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY -1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
  2002. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  2003. int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
  2004. sdata.closeDB();
  2005. if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  2006. return;
  2007. }
  2008. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2009. int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
  2010. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  2011. boolean updatestate = mWallpadStatusData.GetUpgradeState();
  2012. mWallpadStatusData.closeDB();
  2013. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  2014. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  2015. sdata.closeDB();
  2016. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
  2017. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
  2018. Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
  2019. int nModelType = Version.getModelType();
  2020. switch (ReceiveEvt.getKeyCode()) {
  2021. case 251: // 현산향 비상버튼 다운 업 처리
  2022. try {
  2023. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  2024. if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
  2025. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
  2026. }
  2027. else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
  2028. if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
  2029. }
  2030. }
  2031. } catch (RuntimeException re) {
  2032. LogUtil.errorLogInfo("", TAG, re);
  2033. }
  2034. catch (Exception e) {
  2035. //e.printStackTrace();
  2036. LogUtil.errorLogInfo("", TAG, e);
  2037. }
  2038. break;
  2039. case WallPadInterface.EVT_RING:
  2040. case WallPadInterface.BTN_PSTN_RING_IHN1010:
  2041. Log.w(TAG, "########## PSTN EVT_RING ##########");
  2042. // 전화 수신 링 수신
  2043. // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  2044. if (Version.getGatewayUsage()) {
  2045. // 국선 시작만 올라온다.
  2046. startIGW300RingGenerator();
  2047. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  2048. }
  2049. else {
  2050. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
  2051. }
  2052. break;
  2053. case WallPadInterface.EVT_END_RING:
  2054. // 전화 수신 링 종료
  2055. // Jeff added below codes for call app (2018.01.25)
  2056. // This event is managed by WallPadCall
  2057. Log.w(TAG, "########## This event is managed by WallPadCall ##########");
  2058. if (Version.getGatewayUsage()) {
  2059. stopIGW300RingGenerator();
  2060. }
  2061. break;
  2062. case WallPadInterface.BTN_EMR:
  2063. case WallPadInterface.BTN_EMR_IHN1010:
  2064. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2065. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2066. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2067. if (MgrAppRun) return;
  2068. if (Common.DIAGNOSTIC_MODE) return;
  2069. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  2070. //currentTime = System.currentTimeMillis();
  2071. //if (ALERTTIME > currentTime) break;
  2072. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2073. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2074. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2075. devset = new WallpadDeviceSet(getApplicationContext());
  2076. int StatusVal = devset.GetDeviceSetted("알람발생");
  2077. devset.closeDB();
  2078. Log.d("imap", "StatusVal : " + StatusVal);
  2079. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2080. // 보안 처리가 필요함..
  2081. // 지속적으로 이벤트가 들어올 경우 대비
  2082. Common.SendAppFinishReqBR(getApplicationContext());
  2083. newintent = new Intent(Intent.ACTION_MAIN);
  2084. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2085. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2086. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2087. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2088. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2089. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2090. iMAPstartActivity(newintent);
  2091. }
  2092. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2093. if (getIsSubWallpad()) {
  2094. Intent notiIntent = new Intent();
  2095. notiIntent.setAction(define.NOTIFY_ACNAME);
  2096. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2097. getApplicationContext().sendBroadcast(notiIntent);
  2098. }
  2099. break;
  2100. case WallPadInterface.BTN_CALL:
  2101. case WallPadInterface.BTN_CALL_IHN1010:
  2102. // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
  2103. if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
  2104. if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
  2105. // Jeff added below codes for call app (2018.01.25)
  2106. try {
  2107. Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
  2108. if (getIsSubWallpad()) {
  2109. // 서브월패드
  2110. runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2111. }
  2112. else {
  2113. // 메인월패드
  2114. runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
  2115. }
  2116. } catch (RuntimeException re) {
  2117. LogUtil.errorLogInfo("", TAG, re);
  2118. }
  2119. catch (Exception e) {
  2120. Log.e(TAG, "[Exception] onReceive().BTN_CALL");
  2121. //e.printStackTrace();
  2122. LogUtil.errorLogInfo("", TAG, e);
  2123. }
  2124. break;
  2125. case WallPadInterface.BTN_OPEN:
  2126. // 월패드 문여림 버튼 입력 상태 SA
  2127. break;
  2128. case WallPadInterface.BTN_DOOR:
  2129. case WallPadInterface.BTN_DOOR_IHN1010:
  2130. // 현관 도어폰 벨 눌림 입력 상태
  2131. // Jeff added below codes for call app (2018.01.25)
  2132. Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
  2133. if (!bWallPadCallLive && !bBlockFrontCall) {
  2134. try {
  2135. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2136. //여기서 확인
  2137. // if(MainActivity.CallBrList == null)
  2138. // MainActivity.CallBrList = new ArrayList<Intent>();
  2139. // Intent brListIntent = new Intent();
  2140. // brListIntent = intent;
  2141. //
  2142. // if(MainActivity.CallBrList.size() > 1)
  2143. // {
  2144. // if(MainActivity.CallBrList.get(0) != brListIntent)
  2145. // {
  2146. // MainActivity.CallBrList.add(brListIntent);
  2147. // Log.d(TAG, "jglee - Call 인텐트 추가 > size : " + MainActivity.CallBrList.size() + "현관 딩동");
  2148. // }
  2149. // }
  2150. // else {
  2151. // MainActivity.CallBrList.add(brListIntent);
  2152. // Log.d(TAG, "jglee - Call 인텐트 추가 > size : " + MainActivity.CallBrList.size() + "현관 딩동");
  2153. // }
  2154. //
  2155. // //여기서 BrList에 남아 있는 갯수를 확인
  2156. // if(MainActivity.CallBrList!=null && MainActivity.CallBrList.size() > 1)
  2157. // {
  2158. // return;
  2159. // }
  2160. Log.d(TAG, "jglee - Call Front");
  2161. bBlockFrontCall = true;
  2162. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2163. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2164. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2165. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2166. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2167. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2168. }
  2169. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2170. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2171. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2172. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2173. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2174. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2175. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2176. }
  2177. if (!Version.getGatewayUsage()) {
  2178. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2179. }
  2180. Log.w(TAG, "jglee - 띵동 수신 거동수상자 딜레이 - BR_RECORD_DELAY");
  2181. Intent Newintent = new Intent();
  2182. Newintent.setAction(Common.BR_RECORD_DELAY);
  2183. getApplicationContext().sendBroadcast(Newintent);
  2184. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2185. } catch (RuntimeException re) {
  2186. LogUtil.errorLogInfo("", TAG, re);
  2187. }
  2188. catch (Exception e) {
  2189. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2190. //e.printStackTrace();
  2191. LogUtil.errorLogInfo("", TAG, e);
  2192. }
  2193. }
  2194. else if(Common.bRecordStatus)
  2195. {
  2196. //여기서 거동 수상자 확인이 필요함
  2197. //녹화 여부 확인 후, 거동 수상자 녹화 중지 BR을 전송
  2198. // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
  2199. Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + Common.bRecordStatus + "]");
  2200. bBlockFrontCall = true;
  2201. handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
  2202. handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
  2203. mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
  2204. // yjyoon. 녹화 중지 브로드캐스트
  2205. Intent iIntent = new Intent();
  2206. iIntent.setAction(Common.BR_RECORD_STOP);
  2207. getApplicationContext().sendBroadcast(iIntent);
  2208. try {
  2209. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  2210. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
  2211. mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
  2212. }
  2213. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2214. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2215. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2216. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2217. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2218. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
  2219. mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
  2220. }
  2221. if (!Version.getGatewayUsage()) {
  2222. mDingDongHandler.sendEmptyMessage(0); // 띵똥
  2223. }
  2224. // yjyoon. 현재 Call 앱이 켜진 상태.
  2225. // WallPadCall > MainActivity > onCreate() 에서 generateCallEvent()를 통해 콜 이벤트를 생성.
  2226. if (false) {
  2227. // yjyoon. 기존 소스코드. 주석처리
  2228. Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
  2229. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
  2230. } else {
  2231. // yjyoon.
  2232. // 현관 콜 이벤트 생성 및 전송. runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus) 참조
  2233. sendLCDBacklightStatus(true);
  2234. Intent mIntent = new Intent();
  2235. mIntent.setAction(define.NOTIFY_ACNAME);
  2236. mIntent.putExtra(define.NOTIBR_KIND, 9999); // yjyoon. 임시로 9999로 설정.
  2237. mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
  2238. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, CALLEVENTTYPE.RECEIVE_CALL.toString());
  2239. mIntent.putExtra(CALLTRIGGER.CALLTYPE, CALLTYPE.FRONT.toString());
  2240. getApplicationContext().sendBroadcast(mIntent);
  2241. playFrontBell(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT);
  2242. }
  2243. } catch (RuntimeException re) {
  2244. LogUtil.errorLogInfo("", TAG, re);
  2245. }
  2246. catch (Exception e) {
  2247. Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
  2248. //e.printStackTrace();
  2249. LogUtil.errorLogInfo("", TAG, e);
  2250. }
  2251. }
  2252. else {
  2253. Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
  2254. }
  2255. break;
  2256. case WallPadInterface.EVT_SENSOR_EMRGENCY:
  2257. case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN101GL:
  2258. if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2259. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
  2260. && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN101GL)) {
  2261. Log.w(TAG, "########## EMERGENCY BUTTON ##########");
  2262. // 월패드 비상버튼 입력 SA 와 GLE 공통
  2263. Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
  2264. if (MgrAppRun) return;
  2265. if (Common.DIAGNOSTIC_MODE) return;
  2266. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED) return;
  2267. //currentTime = System.currentTimeMillis();
  2268. //if (ALERTTIME > currentTime) break;
  2269. //ALERTTIME = currentTime+EVENTTIMELIMITE;
  2270. Log.d(TAG, "AlarmStatus : " + AlarmStatus);
  2271. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2272. devset = new WallpadDeviceSet(getApplicationContext());
  2273. StatusVal = devset.GetDeviceSetted("알람발생");
  2274. devset.closeDB();
  2275. Log.d("imap", "StatusVal : " + StatusVal);
  2276. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2277. // 보안 처리가 필요함..
  2278. // 지속적으로 이벤트가 들어올 경우 대비
  2279. Common.SendAppFinishReqBR(getApplicationContext());
  2280. newintent = new Intent(Intent.ACTION_MAIN);
  2281. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2282. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2283. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2284. newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
  2285. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2286. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2287. iMAPstartActivity(newintent);
  2288. }
  2289. // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
  2290. if (getIsSubWallpad()) {
  2291. Intent notiIntent = new Intent();
  2292. notiIntent.setAction(define.NOTIFY_ACNAME);
  2293. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
  2294. getApplicationContext().sendBroadcast(notiIntent);
  2295. }
  2296. }
  2297. else {
  2298. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2299. if (!getEmergencyIOUsage()) {
  2300. Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
  2301. return;
  2302. }
  2303. if (MgrAppRun) {
  2304. Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
  2305. return;
  2306. }
  2307. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2308. devset = new WallpadDeviceSet(getApplicationContext());
  2309. StatusVal = devset.GetDeviceSetted("알람발생");
  2310. devset.closeDB();
  2311. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2312. Common.SendAppFinishReqBR(getApplicationContext());
  2313. newintent = new Intent(Intent.ACTION_MAIN);
  2314. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2315. newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
  2316. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2317. newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
  2318. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2319. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2320. iMAPstartActivity(newintent);
  2321. }
  2322. }
  2323. break;
  2324. case WallPadInterface.EVT_SENSOR_MAGNETIC0:
  2325. case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
  2326. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2327. if (MgrAppRun) return;
  2328. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  2329. || Version.getModelType() == MODEL_TYPE.IHN_1010_I_2443) {
  2330. WallPadInterface mWallPadInterface = new WallPadInterface();
  2331. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  2332. if (sensorMag == 0) return;
  2333. }
  2334. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2335. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT ) break;
  2336. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2337. Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
  2338. if (OutGoingSensorWaiting == 0) {
  2339. wakeupLCD();
  2340. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2341. SensorThread.start();
  2342. }
  2343. OutGoingSensorWaiting |= SENSOR_MAG;
  2344. }
  2345. else {
  2346. Common.SendAppFinishReqBR(getApplicationContext());
  2347. newintent = new Intent(Intent.ACTION_MAIN);
  2348. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2349. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2350. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2351. newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
  2352. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2353. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2354. iMAPstartActivity(newintent);
  2355. }
  2356. break;
  2357. case WallPadInterface.EVT_BLACKOUT_OCCURRED:
  2358. saveBlackoutStatus(true);
  2359. runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
  2360. break;
  2361. case WallPadInterface.EVT_BLACKOUT_RELEASED:
  2362. saveBlackoutStatus(false);
  2363. sendBlackoutReleasedBR();
  2364. break;
  2365. case WallPadInterface.EVT_SENSOR_REFUGELADDER:
  2366. case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
  2367. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2368. if (MgrAppRun) return;
  2369. if (AlarmStatus == WallpadStatusData.ALARM_ARISE ||AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2370. devset = new WallpadDeviceSet(getApplicationContext());
  2371. StatusVal = devset.GetDeviceSetted("피난사다리");
  2372. int LadderSend = devset.getEscapeLadderDownSend();
  2373. devset.closeDB();
  2374. Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
  2375. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  2376. Common.SendAppFinishReqBR(getApplicationContext());
  2377. newintent = new Intent(Intent.ACTION_MAIN);
  2378. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2379. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  2380. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2381. if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER) newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  2382. else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW) newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  2383. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2384. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2385. iMAPstartActivity(newintent);
  2386. }
  2387. break;
  2388. case WallPadInterface.EVT_SENSOR_MOTIONIN:
  2389. case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
  2390. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2391. {
  2392. // 내부동체가 상태가 변경된 경우
  2393. int[] SensorInfoDB;
  2394. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2395. if (SensorInfoDB[0] != 1) {
  2396. //내부동체가 사용함이면 상태 검사
  2397. return;
  2398. }
  2399. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  2400. || Version.getModelType() == MODEL_TYPE.IHN_1010_I_2443) {
  2401. WallPadInterface mWallPadInterface = new WallPadInterface();
  2402. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  2403. if (sensorMag == 0) return;
  2404. }
  2405. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2406. int sensor = devSet.Get_Sensor_Set();
  2407. devSet.closeDB();
  2408. if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
  2409. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
  2410. break;
  2411. if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2412. if (OutGoingSensorWaiting == 0) {
  2413. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2414. SensorThread.start();
  2415. }
  2416. OutGoingSensorWaiting |= SENSOR_IN;
  2417. }
  2418. break;
  2419. case WallPadInterface.EVT_SENSOR_MOTIONOUT:
  2420. case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
  2421. Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
  2422. {
  2423. // 외부동체가 상태가 변경된 경우
  2424. int[] SensorInfoDB;
  2425. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  2426. if (SensorInfoDB[1] != 1) {
  2427. // 외부동체가 사용함이면 상태 검사
  2428. return;
  2429. }
  2430. if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  2431. || Version.getModelType() == MODEL_TYPE.IHN_1010_I_2443) {
  2432. WallPadInterface mWallPadInterface = new WallPadInterface();
  2433. int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  2434. if (sensorMag == 0) return;
  2435. }
  2436. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  2437. int sensor = devSet.Get_Sensor_Set();
  2438. devSet.closeDB();
  2439. //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
  2440. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP) break;
  2441. if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT) break;
  2442. if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) break;
  2443. /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
  2444. {
  2445. // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
  2446. Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
  2447. break;
  2448. }*/
  2449. if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
  2450. if (OutGoingSensorWaiting == 0) {
  2451. OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
  2452. SensorThread.start();
  2453. }
  2454. OutGoingSensorWaiting |= SENSOR_OUT;
  2455. }
  2456. else {
  2457. Common.SendAppFinishReqBR(getApplicationContext());
  2458. newintent = new Intent(Intent.ACTION_MAIN);
  2459. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2460. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2461. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2462. if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) newintent.putExtra("MENU_DETAIL_INFO", "bugin");
  2463. else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  2464. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2465. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2466. iMAPstartActivity(newintent);
  2467. }
  2468. }
  2469. break;
  2470. }
  2471. }
  2472. else {
  2473. Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
  2474. }
  2475. }
  2476. };
  2477. protected void iMAPstartActivity(Intent intent) {
  2478. try {
  2479. startActivity(intent);
  2480. } catch (RuntimeException re) {
  2481. LogUtil.errorLogInfo("", TAG, re);
  2482. }
  2483. catch (Exception e) {
  2484. Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
  2485. //e.printStackTrace();
  2486. LogUtil.errorLogInfo("", TAG, e);
  2487. }
  2488. }
  2489. /**
  2490. * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
  2491. * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
  2492. * 1. 현관카메라 키이벤트 수신
  2493. * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
  2494. * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
  2495. * 4. 통화패스 설정 확인 및 띵똥 음원 재생
  2496. * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
  2497. * 6. 시스템 볼륨 원복
  2498. * 7. 통화 앱(WallPadCall) 으로 BR 전송
  2499. */
  2500. AudioManager mAudioManager;
  2501. int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
  2502. Handler mDingDongHandler = new Handler() {
  2503. public void handleMessage(Message msg) {
  2504. try {
  2505. Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
  2506. if (msg.what == 0) {
  2507. // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
  2508. int nVolume = 10;
  2509. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) nVolume = 12;
  2510. mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  2511. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
  2512. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
  2513. mDingDongHandler.sendEmptyMessage(1);
  2514. } else if (msg.what == 1) {
  2515. // 띵똥 패스 체크
  2516. check1++;
  2517. if (check1 > 200) {
  2518. Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
  2519. finishDingDongHandler();
  2520. check1 = 0;
  2521. return;
  2522. } else {
  2523. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
  2524. mDingDongHandler.sendEmptyMessageDelayed(2, 500);
  2525. else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
  2526. }
  2527. } else if (msg.what == 2) {
  2528. // 띵똥 음원 재생
  2529. Log.d(TAG, "띵동 1번 재생");
  2530. mIOInterface.ctrlSetTalkPathDoor();
  2531. sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
  2532. } else if (msg.what == 3) {
  2533. mIOInterface.ctrlSetTalkPathNormal();
  2534. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2535. mDingDongHandler.sendEmptyMessage(4);
  2536. } else if (msg.what == 4) {
  2537. // Normal 패스 체크
  2538. check2++;
  2539. if (check2 > 200) {
  2540. Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
  2541. finishDingDongHandler();
  2542. check2 = 0;
  2543. return;
  2544. } else {
  2545. if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
  2546. mDingDongHandler.sendEmptyMessageDelayed(5, 50);
  2547. else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
  2548. }
  2549. } else if (msg.what == 5) {
  2550. Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
  2551. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2552. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2553. wdb.closeDB();
  2554. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2555. Intent intent = new Intent(); // 통화 앱으로 BR 전송
  2556. intent.setAction(define.NOTIFY_ACNAME);
  2557. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
  2558. sendBroadcast(intent);
  2559. }
  2560. } catch (RuntimeException re) {
  2561. LogUtil.errorLogInfo("", TAG, re);
  2562. finishDingDongHandler();
  2563. }
  2564. catch (Exception e) {
  2565. Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
  2566. //e.printStackTrace();
  2567. LogUtil.errorLogInfo("", TAG, e);
  2568. finishDingDongHandler();
  2569. }
  2570. }
  2571. };
  2572. private void finishDingDongHandler() {
  2573. try {
  2574. Log.d(TAG, "[finishDingDongHandler]");
  2575. if (mDingDongHandler != null) {
  2576. mDingDongHandler.removeMessages(0);
  2577. mDingDongHandler.removeMessages(1);
  2578. mDingDongHandler.removeMessages(2);
  2579. mDingDongHandler.removeMessages(3);
  2580. mDingDongHandler.removeMessages(4);
  2581. mDingDongHandler.removeMessages(5);
  2582. }
  2583. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2584. int nSavedVolume = wdb.GetWallPadMasterVolume();
  2585. wdb.closeDB();
  2586. mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
  2587. mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  2588. mIOInterface.ctrlSetTalkPathNormal();
  2589. } catch (RuntimeException re) {
  2590. LogUtil.errorLogInfo("", TAG, re);
  2591. }
  2592. catch (Exception e) {
  2593. Log.e(TAG, "[Exception] finishDingDongHandler()");
  2594. //e.printStackTrace();
  2595. LogUtil.errorLogInfo("", TAG, e);
  2596. }
  2597. }
  2598. // 외출방범 대기 모드 중 사운드와 센서 체크
  2599. class OutgoingCheckSensor extends Thread {
  2600. public OutgoingCheckSensor() {
  2601. }
  2602. public void run() {
  2603. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2604. int timedata = mWallpadStatusData.GetComeBackWaitTime();
  2605. WallPadInterface wpifc = new WallPadInterface();
  2606. mWallpadStatusData.closeDB();
  2607. int checkcount = timedata / 5;
  2608. int i;
  2609. for (i = checkcount; i > 0; i--) {
  2610. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2611. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2612. mWallpadStatusData.closeDB();
  2613. if (alarmst != WallpadStatusData.GUARD_OUT) break;
  2614. Sound().PlayMent(WpadSound.SND.effect.WARNING005);
  2615. Log.d(TAG, "--------- OutgoingCheckSensor ");
  2616. try{Thread.sleep(5000);}
  2617. catch (RuntimeException re) {
  2618. LogUtil.errorLogInfo("", TAG, re);
  2619. }
  2620. catch (Exception e){
  2621. LogUtil.errorLogInfo("", TAG, e);
  2622. }
  2623. }
  2624. if (i==0) {
  2625. mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  2626. int alarmst = mWallpadStatusData.GetAlarmStatus();
  2627. mWallpadStatusData.closeDB();
  2628. if (alarmst == WallpadStatusData.GUARD_OUT) {
  2629. Common.SendAppFinishReqBR(getApplicationContext());
  2630. int base = 7000;
  2631. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  2632. int Menu_Start_Option = 1;
  2633. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  2634. mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2635. mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  2636. mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2637. String Cuase = (OutGoingSensorWaiting&SENSOR_OUT)>0?"bugout":"bugin";
  2638. if ((OutGoingSensorWaiting&SENSOR_OUT)>0) Cuase = "bugout";
  2639. else if ((OutGoingSensorWaiting&SENSOR_MAG)>0) Cuase = "magnetic";
  2640. else if ((OutGoingSensorWaiting&SENSOR_IN)>0) Cuase = "bugin";
  2641. mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
  2642. mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2643. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2644. iMAPstartActivity(mIntent);
  2645. }
  2646. }
  2647. Log.d(TAG, "--------- OutgoingCheckSensor End");
  2648. OutGoingSensorWaiting = 0;
  2649. }
  2650. }
  2651. @Override
  2652. public IBinder onBind(Intent arg0) {
  2653. return null;
  2654. }
  2655. public void imapsvrlog(String msg)
  2656. {
  2657. if (!log_sw) return;
  2658. Log.d(TAG, APIErrorCode.GetLogPrefix()+" IMAPSVR:"+msg);
  2659. }
  2660. public int onStartCommand(Intent intent, int flags, int startID) {
  2661. try {
  2662. try {
  2663. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  2664. } catch (RuntimeException re) {
  2665. LogUtil.errorLogInfo("", TAG, re);
  2666. }
  2667. catch (Exception e) {
  2668. //e.printStackTrace();
  2669. LogUtil.errorLogInfo("", TAG, e);
  2670. }
  2671. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2672. bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
  2673. mWallpadDeviceSet.closeDB();
  2674. SvrSock = new iMapSverSocket();
  2675. SvrSock.start();
  2676. } catch (IOException e) {
  2677. Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
  2678. //e.printStackTrace();
  2679. LogUtil.errorLogInfo("", TAG, e);
  2680. }
  2681. try {
  2682. mGleInterface = new jni();
  2683. } catch (RuntimeException re) {
  2684. LogUtil.errorLogInfo("", TAG, re);
  2685. }
  2686. catch (Exception e) {
  2687. Log.e(TAG,"[Exception] mGleInterface init...");
  2688. //e.printStackTrace();
  2689. LogUtil.errorLogInfo("", TAG, e);
  2690. }
  2691. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  2692. AddressSet addr = DBMGR.getAddressMGR();
  2693. DBMGR.closeDB();
  2694. String AddressStr = addr.Dong+"동 "+addr.Ho+"호";
  2695. AddrDong = addr.Dong;
  2696. AddrHo = addr.Ho;
  2697. XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  2698. "<imap ver=\"1.0\" address=\""+addr.IPAddress+"\" sender=\""+AddressStr+"\">\r\n";
  2699. Log.d(TAG, "*****************************************");
  2700. Log.d(TAG, "****************SchedulerThread**********");
  2701. Log.d(TAG, "*****************************************");
  2702. ScheServer = new SchedulerThread();
  2703. ScheServer.start();
  2704. // BR 등록 시작
  2705. Log.d(TAG, "[onStartCommand] BR register start!!!");
  2706. IntentFilter mIntentFilter = new IntentFilter();
  2707. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  2708. registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
  2709. mIntentFilter = new IntentFilter();
  2710. mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
  2711. // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
  2712. registerReceiver(mWallPadCTRDevBR, mIntentFilter);
  2713. mIntentFilter = new IntentFilter();
  2714. mIntentFilter.addAction(define.NOTIFY_ACNAME);
  2715. mIntentFilter.addAction(define.NOTIFY_DAIL);
  2716. mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
  2717. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2718. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  2719. Log.d(TAG, "[onStartCommand] BR register end!!!");
  2720. // BR 등록 완료
  2721. mWallPadAPI = new WallPadAPI(this.getApplicationContext());
  2722. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL) IGW200APICheckHandler.sendEmptyMessage(0);
  2723. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  2724. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  2725. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  2726. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  2727. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  2728. IGW300APICheckHandler.sendEmptyMessage(0);
  2729. }
  2730. mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
  2731. mIOInterface.setEmergencyType();
  2732. Intent notiIntent = new Intent();
  2733. notiIntent.setAction(define.NOTIFY_ACNAME);
  2734. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
  2735. getApplicationContext().sendBroadcast(notiIntent);
  2736. CheckMainStatus();
  2737. checkDoorCamConfig(); // 현관카메라 설정정보 확인
  2738. //여기서 감지시간을 3초로 초기화 jglee
  2739. try
  2740. {
  2741. if (getStrangerRecordingManagerSetting()) {
  2742. if (mSmartKeyRfDoorAPI != null) {
  2743. mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, (byte) 0x01);
  2744. }
  2745. }
  2746. }
  2747. catch (Exception e)
  2748. {
  2749. }
  2750. getAirQualityUsage();
  2751. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
  2752. SendLHGWCheck GwCheckThread = new SendLHGWCheck();
  2753. GwCheckThread.start();
  2754. }
  2755. return START_STICKY;
  2756. }
  2757. // 메인 서버 소켓 클래스
  2758. public class iMapSverSocket extends Thread
  2759. {
  2760. ServerSocket svr;
  2761. private SSLServerSocket sslsvr;
  2762. boolean receiveSocketRun = true;
  2763. public iMapSverSocket() throws IOException
  2764. {
  2765. /////////////////////////////////////////////////////////////////////
  2766. // 신형 단지서버 사용 유무를 가져온다.
  2767. /////////////////////////////////////////////////////////////////////
  2768. try {
  2769. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2770. // mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2771. danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  2772. wallpadDeviceSet.closeDB();
  2773. } catch (RuntimeException re) {
  2774. LogUtil.errorLogInfo("", TAG, re);
  2775. danjiserverType = 1;
  2776. }
  2777. catch (Exception e) {
  2778. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2779. //e.printStackTrace();
  2780. LogUtil.errorLogInfo("", TAG, e);
  2781. danjiserverType = 1;
  2782. }
  2783. //////////////////////////////////////////////////
  2784. /////////////////////////////////////////////////////////////////////
  2785. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2786. /////////////////////////////////////////////////////////////////////
  2787. if(danjiserverType == define.DanjiServer1)
  2788. {
  2789. svr = new ServerSocket(port);
  2790. }
  2791. else if(danjiserverType == define.DanjiServer2)
  2792. {
  2793. int svrport = port + 1000;
  2794. Log.i(TAG, "============================================");
  2795. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2796. Log.i(TAG, "============================================");
  2797. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2798. sslsvr = sslServerSocket.getServerSocket();
  2799. }
  2800. else
  2801. {
  2802. int svrport = port + 1000;
  2803. Log.i(TAG, "============================================");
  2804. Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
  2805. Log.i(TAG, "============================================");
  2806. SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
  2807. sslsvr = sslServerSocket.getServerSocket();
  2808. danji_mix =new iMapSverSocket_Mix();
  2809. danji_mix.start();
  2810. }
  2811. }
  2812. public void run()
  2813. {
  2814. while(receiveSocketRun)
  2815. {
  2816. try {
  2817. Socket sock = null;
  2818. /////////////////////////////////////////////////////////////////////
  2819. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2820. /////////////////////////////////////////////////////////////////////
  2821. if(danjiserverType == 1)
  2822. {
  2823. sock = svr.accept();
  2824. }
  2825. else
  2826. {
  2827. sock = sslsvr.accept();
  2828. }
  2829. iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
  2830. ProciMap.start();
  2831. } catch (IOException e) {
  2832. //e.printStackTrace();
  2833. LogUtil.errorLogInfo("", TAG, e);
  2834. }
  2835. }
  2836. }
  2837. public void destoryThread()
  2838. {
  2839. receiveSocketRun = false;
  2840. try
  2841. {
  2842. if( svr != null )
  2843. {
  2844. svr.close();
  2845. svr = null;
  2846. }
  2847. if( sslsvr != null )
  2848. {
  2849. sslsvr.close();
  2850. sslsvr = null;
  2851. }
  2852. }
  2853. catch (RuntimeException re) {
  2854. LogUtil.errorLogInfo("", TAG, re);
  2855. }
  2856. catch (Exception e)
  2857. {
  2858. //e.printStackTrace();
  2859. LogUtil.errorLogInfo("", TAG, e);
  2860. }
  2861. }
  2862. }
  2863. // 메인 서버 소켓 클래스
  2864. /**
  2865. * 무조건 Mix일 경우만 사용
  2866. */
  2867. public class iMapSverSocket_Mix extends Thread
  2868. {
  2869. ServerSocket svr;
  2870. boolean receiveSocketRun = true;
  2871. public iMapSverSocket_Mix() throws IOException
  2872. {
  2873. /////////////////////////////////////////////////////////////////////
  2874. // 신형 단지서버 사용 유무를 가져온다.
  2875. /////////////////////////////////////////////////////////////////////
  2876. try {
  2877. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2878. // mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2879. danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  2880. wallpadDeviceSet.closeDB();
  2881. } catch (RuntimeException re) {
  2882. LogUtil.errorLogInfo("", TAG, re);
  2883. }
  2884. catch (Exception e) {
  2885. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2886. //e.printStackTrace();
  2887. LogUtil.errorLogInfo("", TAG, e);
  2888. }
  2889. //////////////////////////////////////////////////
  2890. /////////////////////////////////////////////////////////////////////
  2891. // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
  2892. /////////////////////////////////////////////////////////////////////
  2893. if(danjiserverType == 0)
  2894. {
  2895. svr = new ServerSocket(port);
  2896. }
  2897. }
  2898. public void run()
  2899. {
  2900. while(receiveSocketRun)
  2901. {
  2902. try {
  2903. Socket sock = null;
  2904. /////////////////////////////////////////////////////////////////////
  2905. // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
  2906. /////////////////////////////////////////////////////////////////////
  2907. sock = svr.accept();
  2908. iMapSverSocketThread_Mix ProciMap = new iMapSverSocketThread_Mix(sock);
  2909. ProciMap.start();
  2910. } catch (IOException e) {
  2911. //e.printStackTrace();
  2912. LogUtil.errorLogInfo("", TAG, e);
  2913. }
  2914. }
  2915. }
  2916. public void destoryThread()
  2917. {
  2918. receiveSocketRun = false;
  2919. try
  2920. {
  2921. if( svr != null )
  2922. {
  2923. svr.close();
  2924. svr = null;
  2925. }
  2926. }
  2927. catch (RuntimeException re) {
  2928. LogUtil.errorLogInfo("", TAG, re);
  2929. }
  2930. catch (Exception e)
  2931. {
  2932. //e.printStackTrace();
  2933. LogUtil.errorLogInfo("", TAG, e);
  2934. }
  2935. }
  2936. }
  2937. private static String trimQuotation(String strValue) {
  2938. strValue = strValue.replaceAll("\"", "");
  2939. return strValue.trim();
  2940. }
  2941. // iMAP 서버 소켓 처리
  2942. public class iMapSverSocketThread extends Thread {
  2943. private final Socket iMAPSock;
  2944. String strRcvMSG;
  2945. WallPadiMAPUpgrade upgradeProc;
  2946. Document doc;
  2947. public iMapSverSocketThread(Socket sock) {
  2948. iMAPSock = sock;
  2949. }
  2950. public void run() {
  2951. try {
  2952. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  2953. InputStream InStm = iMAPSock.getInputStream();
  2954. iMAPSock.setSoLinger(true, 3000);
  2955. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  2956. strRcvMSG = "";
  2957. String InBuffer;
  2958. int i = 0;
  2959. boolean bRcvOK = false;
  2960. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  2961. /////////////////////////////////////////////////////////////////////
  2962. // 신형단지서버 미사용중일 경우 기존 코드로,
  2963. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  2964. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  2965. /////////////////////////////////////////////////////////////////////
  2966. if (danjiserverType == define.DanjiServer1) {
  2967. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  2968. try {
  2969. if (MsgReader.ready()) {
  2970. try {
  2971. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  2972. InBuffer = "";
  2973. while (MsgReader.ready()) {
  2974. long charCnt = MsgReader.read(ReadData);
  2975. InBuffer += new String(ReadData, 0, (int)charCnt);
  2976. }
  2977. if (InBuffer != null) strRcvMSG += InBuffer;
  2978. if (0 < InBuffer.indexOf("</imap>")) {
  2979. bRcvOK = true;
  2980. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  2981. break;
  2982. }
  2983. } catch (RuntimeException re) {
  2984. LogUtil.errorLogInfo("", TAG, re);
  2985. return;
  2986. }
  2987. catch (Exception e) {
  2988. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  2989. //e.printStackTrace();
  2990. LogUtil.errorLogInfo("", TAG, e);
  2991. return;
  2992. }
  2993. }
  2994. else {
  2995. Thread.sleep(100);
  2996. }
  2997. } catch (RuntimeException re) {
  2998. LogUtil.errorLogInfo("", TAG, re);
  2999. iMAPSock.close();
  3000. return;
  3001. }
  3002. catch (Exception e) {
  3003. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  3004. iMAPSock.close();
  3005. //e.printStackTrace();
  3006. LogUtil.errorLogInfo("", TAG, e);
  3007. return;
  3008. }
  3009. }
  3010. }
  3011. else {
  3012. // SSL 암호화 데이터 수신부
  3013. // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
  3014. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  3015. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  3016. try {
  3017. InBuffer = "";
  3018. long charCnt = MsgReader.read(ReadData);
  3019. if (charCnt > 0) {
  3020. InBuffer += new String(ReadData, 0, (int)charCnt);
  3021. strRcvMSG += InBuffer;
  3022. if (-1 < InBuffer.indexOf("</imap>")) {
  3023. bRcvOK = true;
  3024. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
  3025. break;
  3026. }
  3027. }
  3028. else {
  3029. Thread.sleep(100);
  3030. }
  3031. } catch (RuntimeException re) {
  3032. LogUtil.errorLogInfo("", TAG, re);
  3033. iMAPSock.close();
  3034. return;
  3035. }
  3036. catch (Exception e) {
  3037. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
  3038. iMAPSock.close();
  3039. //e.printStackTrace();
  3040. LogUtil.errorLogInfo("", TAG, e);
  3041. return;
  3042. }
  3043. }
  3044. }
  3045. if (!bRcvOK) {
  3046. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  3047. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  3048. Log.i(TAG, strRcvMSG);
  3049. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  3050. iMAPSock.close();
  3051. return;
  3052. }
  3053. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  3054. imapsvrlog( "Socket read end accept </imap>\n"+strRcvMSG);
  3055. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3056. DocumentBuilder builder = factory.newDocumentBuilder();
  3057. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  3058. doc = builder.parse(istream);
  3059. Element elelist = doc.getDocumentElement();
  3060. NodeList items = elelist.getElementsByTagName("service");
  3061. Node item = items.item(0);
  3062. NamedNodeMap attrs = item.getAttributes();
  3063. String retXML="";
  3064. for (int j=0; j< attrs.getLength(); j++) {
  3065. Node attr = attrs.item(j);
  3066. String cmd;
  3067. if (attr.getNodeName().equalsIgnoreCase("type")) {
  3068. cmd = attr.getNodeValue();
  3069. if (cmd.equalsIgnoreCase("notice")) {
  3070. iMAPSock.close();
  3071. }
  3072. }
  3073. else if (attr.getNodeName().equalsIgnoreCase("name")) {
  3074. cmd = attr.getNodeValue();
  3075. if (cmd.equalsIgnoreCase("event_notify")) {
  3076. retXML = ProcEventNotify(elelist);
  3077. }
  3078. else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  3079. ProcElevatorinfo(elelist);
  3080. retXML = null;
  3081. }
  3082. else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  3083. retXML = ProcCheckEpiceUpload(doc);
  3084. }
  3085. else if (cmd.equalsIgnoreCase("update_news")) {
  3086. retXML = ProcUpdateNews(doc);
  3087. }
  3088. else if (cmd.equalsIgnoreCase("update_weather")) {
  3089. retXML = ProcUpdateWeather(doc);
  3090. }
  3091. else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  3092. retXML = ProcSchduleInquiry(doc);
  3093. }
  3094. else if (cmd.equalsIgnoreCase("schedule_renew")) {
  3095. retXML = ProcSchduleRenew(doc);
  3096. }
  3097. else if (cmd.equalsIgnoreCase("schdule")) {
  3098. String SvcType="";
  3099. int k;
  3100. for (k = j + 1; k < attrs.getLength(); k++) {
  3101. Node attr1 = attrs.item(k);
  3102. SvcType = attr1.getNodeName();
  3103. if (SvcType.equalsIgnoreCase("shc_type")) {
  3104. SvcType = attr1.getNodeValue();
  3105. break;
  3106. }
  3107. }
  3108. retXML = ProcUpdateSchedule(elelist,SvcType);
  3109. }
  3110. else if (cmd.equalsIgnoreCase("device_reset")) {
  3111. retXML = ProcDeviceReset(elelist);
  3112. }
  3113. else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  3114. retXML = ProcNotifyparcel(doc);
  3115. }
  3116. else if (cmd.equalsIgnoreCase("notify_post_info")) {
  3117. // 스마트우편함 연동 여부
  3118. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  3119. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  3120. DevSet.closeDB();
  3121. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  3122. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  3123. }
  3124. else if (cmd.equalsIgnoreCase("get_security_mode")) {
  3125. String Dong = null;
  3126. String Ho = null;
  3127. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  3128. String result;
  3129. String modeStr = null;
  3130. int status = statusDB.GetAlarmStatus();
  3131. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  3132. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  3133. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  3134. else if (status == WallpadStatusData.GUARD_OUT) modeStr = "unoccupied";
  3135. else if (status == WallpadStatusData.GUARD_OUT_WAIT) modeStr = "waitunoccupied";
  3136. result = "ok";
  3137. }
  3138. else {
  3139. modeStr = "null";
  3140. result = "fail";
  3141. }
  3142. try {
  3143. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  3144. Node GSM_item = GSM_items.item(0);
  3145. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  3146. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  3147. Node GSM_attr = GSM_attrsParam.item(k);
  3148. if (GSM_attr.getNodeName().equalsIgnoreCase("dong")) Dong = trimquotation(GSM_attr.getNodeValue());
  3149. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho")) Ho = trimquotation(GSM_attr.getNodeValue());
  3150. }
  3151. WallpadStatusData DBMGR = null;
  3152. DBMGR = new WallpadStatusData(getApplicationContext());
  3153. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  3154. DBMGR.closeDB();
  3155. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  3156. result = "fail";
  3157. }
  3158. } catch (RuntimeException re) {
  3159. LogUtil.errorLogInfo("", TAG, re);
  3160. result = "fail";
  3161. }
  3162. catch (Exception e) {
  3163. result = "fail";
  3164. }
  3165. retXML = XMLHeader +
  3166. " <service type=\"reply\" name=\"get_security_mode\" result=\""+result+"\">\r\n"+
  3167. " <home_info dong=\""+AddrDong+"\" ho=\""+AddrHo+"\" mode=\""+modeStr+"\"/>\r\n"+
  3168. " </service>\r\n"+
  3169. "</imap>\r\n";
  3170. statusDB.closeDB();
  3171. }
  3172. else if (cmd.equalsIgnoreCase("call_redirect")) {
  3173. Log.d(TAG, "=== call_redirect ===");
  3174. NodeList mNodeList = elelist.getElementsByTagName("target_ip");
  3175. Element mElement = (Element) mNodeList.item(0);
  3176. String strRemoteIP = trimQuotation(mElement.getTextContent());
  3177. MainActivity.ReDirectCall(strRemoteIP);
  3178. }
  3179. else if (cmd.equalsIgnoreCase("set_setup_info")) {
  3180. retXML = ProcSetsetup(doc);
  3181. }
  3182. else if (cmd.equalsIgnoreCase("get_setup_info")) {
  3183. retXML = ProcGetsetup(doc);
  3184. }
  3185. else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  3186. retXML = CheckPassword(doc);
  3187. }
  3188. else if (cmd.equalsIgnoreCase("device_live_check")) {
  3189. retXML = ProcDeviceLiveCheck();
  3190. }
  3191. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  3192. retXML = ProcPairingHdevSyncAlarm(elelist);
  3193. }
  3194. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  3195. retXML = ProcPairingHdevSyncSecurity(elelist);
  3196. }
  3197. else if (cmd.equalsIgnoreCase("notify_car_event")) {
  3198. retXML = ProcParkInformation(elelist);
  3199. }
  3200. else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  3201. retXML = ProcSmartKeyEvent(elelist);
  3202. }
  3203. else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  3204. retXML = ProcParkInformation_cham_upis(elelist);
  3205. }
  3206. else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  3207. retXML = ProcauscultateReq(doc);
  3208. }
  3209. else if (cmd.equalsIgnoreCase("upgrade")) {
  3210. imapsvrlog( "Enter Upgrade");
  3211. procUpgrade();
  3212. retXML = null;
  3213. }
  3214. else if (cmd.equals("check_sip_activation")) {
  3215. String sip_result = "fail";
  3216. ActivityManager manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  3217. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  3218. // Jeff added below codes for call app (2018.01.25)
  3219. //String strSIPPackageName = "kr.co.icontrols.callengine.sip.CeresSIPService";
  3220. String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
  3221. for (int k = 0; k < rsi.size(); k++) {
  3222. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  3223. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  3224. //통화 테스트 필요함
  3225. //sip_result = "ok";
  3226. break;
  3227. }
  3228. }
  3229. 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";
  3230. }
  3231. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3232. retXML = iCMDProcDevList(doc);
  3233. }
  3234. else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3235. retXML = iCMDProcGASControl(elelist);
  3236. }
  3237. else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3238. retXML = iCMDProcSDPSmartLightControl(doc);
  3239. }
  3240. else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3241. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3242. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3243. retXML = iCMDProc_I_LightControl(doc);
  3244. }
  3245. else {
  3246. retXML = iCMDProcLivingLightControl(doc);
  3247. }
  3248. }
  3249. else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3250. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I
  3251. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
  3252. || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
  3253. retXML = iCMDProcSDPConcentControl(doc);
  3254. }
  3255. else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3256. || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3257. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3258. }
  3259. else {
  3260. retXML = iCMDProcMultiSWControl(doc);
  3261. }
  3262. }
  3263. else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3264. retXML = iCMDProcDoorlockControl(doc);
  3265. }
  3266. else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3267. retXML = iCMDProcTemperControl(doc);
  3268. }
  3269. else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3270. retXML = iCMDProcModeControl(doc);
  3271. }
  3272. else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3273. retXML = iCMDProcVentilControl(doc);
  3274. }
  3275. else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3276. retXML = iCMDProcCurtainControl(doc);
  3277. }
  3278. else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3279. if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
  3280. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  3281. retXML = iCMDProcEnergyMeterLightControl(doc);
  3282. }
  3283. else {
  3284. retXML = iCMDProcLightControl(doc);
  3285. }
  3286. }
  3287. else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3288. retXML = iCMDProcLightBatchControl(elelist);
  3289. }
  3290. //모바일 사용자 인증 관련 메시지
  3291. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3292. ProcMobileDevice_AuthNumber(elelist);
  3293. }
  3294. else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3295. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3296. }
  3297. else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3298. ProcMobileDevice_Delete(elelist);
  3299. }
  3300. else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3301. retXML = ProcGetSmartKeyInfo(elelist);
  3302. }
  3303. else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3304. retXML = ProcGetAppVersionInfo();
  3305. }
  3306. else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3307. retXML = ProcIgateInitInfo(elelist);
  3308. }
  3309. else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3310. retXML = ProcElecCarChargeEventInfo(elelist);
  3311. }
  3312. else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3313. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3314. }
  3315. else if (cmd.equalsIgnoreCase("check_call_option")) {
  3316. retXML = ProcCheckCallOption();
  3317. }
  3318. else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3319. retXML = ProcChatSequence(elelist);
  3320. }
  3321. else if (cmd.equalsIgnoreCase("chat_message")) {
  3322. retXML = ProcChatMessage(elelist);
  3323. }
  3324. else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3325. retXML = ProcEvacuationLadderOpen(elelist);
  3326. }
  3327. else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3328. retXML = SmartLightDetailInfo(elelist);
  3329. }
  3330. else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3331. retXML = KNXDeviceDetailInfo(elelist);
  3332. }
  3333. else if( cmd.equalsIgnoreCase("set_server_version")) {
  3334. retXML = ProcSetServerChange(elelist);
  3335. }
  3336. else if( cmd.equalsIgnoreCase("remote_access_onepass")) {
  3337. retXML = iCMDProcOnePass(elelist);
  3338. }
  3339. else if( cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3340. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3341. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3342. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3343. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3344. }
  3345. }
  3346. break;
  3347. }
  3348. }
  3349. if (retXML != null) {
  3350. imapsvrlog( "Socket write line\n"+retXML+"\r\n SO :"+iMAPSock.getSoLinger());
  3351. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3352. byte[] outBF = retXML.getBytes("euc-kr");
  3353. outstream.write(outBF);
  3354. outstream.flush();
  3355. try { Thread.sleep(3000);}
  3356. catch (RuntimeException re) {
  3357. LogUtil.errorLogInfo("", TAG, re);
  3358. }
  3359. catch (Exception e){
  3360. LogUtil.errorLogInfo("", TAG, e);
  3361. }
  3362. iMAPSock.close();
  3363. }
  3364. else {
  3365. try {iMAPSock.close();}
  3366. catch (RuntimeException re) {
  3367. LogUtil.errorLogInfo("", TAG, re);
  3368. }
  3369. catch (Exception e){
  3370. LogUtil.errorLogInfo("", TAG, e);
  3371. }
  3372. }
  3373. }
  3374. catch (RuntimeException re) {
  3375. LogUtil.errorLogInfo("", TAG, re);
  3376. }
  3377. catch (Exception e) {
  3378. try {iMAPSock.close();}
  3379. catch (RuntimeException re) {
  3380. LogUtil.errorLogInfo("", TAG, re);
  3381. }
  3382. catch (Exception E){
  3383. LogUtil.errorLogInfo("", TAG, E);
  3384. }
  3385. LogUtil.errorLogInfo("", TAG, e);
  3386. }
  3387. }
  3388. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3389. private void procUpgrade() {
  3390. imapsvrlog( "upgrade Start \n"+" "+WallPadiMAPUpgrade.active);
  3391. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3392. String[] getstate = sdb.GetSystemUpdateStatus();
  3393. sdb.closeDB();
  3394. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3395. for (int i = 0; i < getstate.length; i++) {
  3396. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3397. }
  3398. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3399. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3400. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3401. }
  3402. }
  3403. public class iMapSverSocketThread_Mix extends Thread {
  3404. private final Socket iMAPSock;
  3405. String strRcvMSG;
  3406. WallPadiMAPUpgrade upgradeProc;
  3407. Document doc;
  3408. public iMapSverSocketThread_Mix(Socket sock) {
  3409. iMAPSock = sock;
  3410. }
  3411. public void run() {
  3412. try {
  3413. Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
  3414. InputStream InStm = iMAPSock.getInputStream();
  3415. iMAPSock.setSoLinger(true, 3000);
  3416. BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
  3417. strRcvMSG = "";
  3418. String InBuffer;
  3419. int i = 0;
  3420. boolean bRcvOK = false;
  3421. lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
  3422. /////////////////////////////////////////////////////////////////////
  3423. // 신형단지서버 미사용중일 경우 기존 코드로,
  3424. // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
  3425. // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
  3426. /////////////////////////////////////////////////////////////////////
  3427. while (System.currentTimeMillis() < lSocketConnectionPeriod) {
  3428. try {
  3429. if (MsgReader.ready()) {
  3430. try {
  3431. char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
  3432. InBuffer = "";
  3433. while (MsgReader.ready()) {
  3434. long charCnt = MsgReader.read(ReadData);
  3435. InBuffer += new String(ReadData, 0, (int)charCnt);
  3436. }
  3437. if (InBuffer != null) strRcvMSG += InBuffer;
  3438. if (0 < InBuffer.indexOf("</imap>")) {
  3439. bRcvOK = true;
  3440. Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
  3441. break;
  3442. }
  3443. } catch (RuntimeException re) {
  3444. LogUtil.errorLogInfo("", TAG, re);
  3445. return;
  3446. }
  3447. catch (Exception e) {
  3448. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
  3449. //e.printStackTrace();
  3450. LogUtil.errorLogInfo("", TAG, e);
  3451. return;
  3452. }
  3453. }
  3454. else {
  3455. Thread.sleep(100);
  3456. }
  3457. } catch (RuntimeException re) {
  3458. LogUtil.errorLogInfo("", TAG, re);
  3459. iMAPSock.close();
  3460. return;
  3461. }
  3462. catch (Exception e) {
  3463. Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
  3464. iMAPSock.close();
  3465. //e.printStackTrace();
  3466. LogUtil.errorLogInfo("", TAG, e);
  3467. return;
  3468. }
  3469. }
  3470. if (!bRcvOK) {
  3471. Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
  3472. Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
  3473. Log.i(TAG, strRcvMSG);
  3474. Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
  3475. iMAPSock.close();
  3476. return;
  3477. }
  3478. strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
  3479. imapsvrlog( "Socket read end accept </imap>\n"+strRcvMSG);
  3480. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3481. DocumentBuilder builder = factory.newDocumentBuilder();
  3482. InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
  3483. doc = builder.parse(istream);
  3484. Element elelist = doc.getDocumentElement();
  3485. NodeList items = elelist.getElementsByTagName("service");
  3486. Node item = items.item(0);
  3487. NamedNodeMap attrs = item.getAttributes();
  3488. String retXML="";
  3489. for (int j=0; j< attrs.getLength(); j++) {
  3490. Node attr = attrs.item(j);
  3491. String cmd;
  3492. if (attr.getNodeName().equalsIgnoreCase("type")) {
  3493. cmd = attr.getNodeValue();
  3494. if (cmd.equalsIgnoreCase("notice")) {
  3495. iMAPSock.close();
  3496. }
  3497. }
  3498. else if (attr.getNodeName().equalsIgnoreCase("name")) {
  3499. cmd = attr.getNodeValue();
  3500. if (cmd.equalsIgnoreCase("event_notify")) {
  3501. retXML = ProcEventNotify(elelist);
  3502. }
  3503. else if (cmd.equalsIgnoreCase("elevator_move_info")) {
  3504. ProcElevatorinfo(elelist);
  3505. retXML = null;
  3506. }
  3507. else if (cmd.equalsIgnoreCase("check_epics_upload")) {
  3508. retXML = ProcCheckEpiceUpload(doc);
  3509. }
  3510. else if (cmd.equalsIgnoreCase("update_news")) {
  3511. retXML = ProcUpdateNews(doc);
  3512. }
  3513. else if (cmd.equalsIgnoreCase("update_weather")) {
  3514. retXML = ProcUpdateWeather(doc);
  3515. }
  3516. else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
  3517. retXML = ProcSchduleInquiry(doc);
  3518. }
  3519. else if (cmd.equalsIgnoreCase("schedule_renew")) {
  3520. retXML = ProcSchduleRenew(doc);
  3521. }
  3522. else if (cmd.equalsIgnoreCase("schdule")) {
  3523. String SvcType="";
  3524. int k;
  3525. for (k = j + 1; k < attrs.getLength(); k++) {
  3526. Node attr1 = attrs.item(k);
  3527. SvcType = attr1.getNodeName();
  3528. if (SvcType.equalsIgnoreCase("shc_type")) {
  3529. SvcType = attr1.getNodeValue();
  3530. break;
  3531. }
  3532. }
  3533. retXML = ProcUpdateSchedule(elelist,SvcType);
  3534. }
  3535. else if (cmd.equalsIgnoreCase("device_reset")) {
  3536. retXML = ProcDeviceReset(elelist);
  3537. }
  3538. else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
  3539. retXML = ProcNotifyparcel(doc);
  3540. }
  3541. else if (cmd.equalsIgnoreCase("notify_post_info")) {
  3542. // 스마트우편함 연동 여부
  3543. WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
  3544. boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
  3545. DevSet.closeDB();
  3546. Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
  3547. if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
  3548. }
  3549. else if (cmd.equalsIgnoreCase("get_security_mode")) {
  3550. String Dong = null;
  3551. String Ho = null;
  3552. WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
  3553. String result;
  3554. String modeStr = null;
  3555. int status = statusDB.GetAlarmStatus();
  3556. if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
  3557. if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
  3558. else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
  3559. else if (status == WallpadStatusData.GUARD_OUT) modeStr = "unoccupied";
  3560. else if (status == WallpadStatusData.GUARD_OUT_WAIT) modeStr = "waitunoccupied";
  3561. result = "ok";
  3562. }
  3563. else {
  3564. modeStr = "null";
  3565. result = "fail";
  3566. }
  3567. try {
  3568. NodeList GSM_items = elelist.getElementsByTagName("home_info");
  3569. Node GSM_item = GSM_items.item(0);
  3570. NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
  3571. for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
  3572. Node GSM_attr = GSM_attrsParam.item(k);
  3573. if (GSM_attr.getNodeName().equalsIgnoreCase("dong")) Dong = trimquotation(GSM_attr.getNodeValue());
  3574. else if (GSM_attr.getNodeName().equalsIgnoreCase("ho")) Ho = trimquotation(GSM_attr.getNodeValue());
  3575. }
  3576. WallpadStatusData DBMGR = null;
  3577. DBMGR = new WallpadStatusData(getApplicationContext());
  3578. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  3579. DBMGR.closeDB();
  3580. if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
  3581. result = "fail";
  3582. }
  3583. } catch (RuntimeException re) {
  3584. LogUtil.errorLogInfo("", TAG, re);
  3585. result = "fail";
  3586. }
  3587. catch (Exception e) {
  3588. result = "fail";
  3589. }
  3590. retXML = XMLHeader +
  3591. " <service type=\"reply\" name=\"get_security_mode\" result=\""+result+"\">\r\n"+
  3592. " <home_info dong=\""+AddrDong+"\" ho=\""+AddrHo+"\" mode=\""+modeStr+"\"/>\r\n"+
  3593. " </service>\r\n"+
  3594. "</imap>\r\n";
  3595. statusDB.closeDB();
  3596. }
  3597. else if (cmd.equalsIgnoreCase("set_setup_info")) {
  3598. retXML = ProcSetsetup(doc);
  3599. }
  3600. else if (cmd.equalsIgnoreCase("get_setup_info")) {
  3601. retXML = ProcGetsetup(doc);
  3602. }
  3603. else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
  3604. retXML = CheckPassword(doc);
  3605. }
  3606. else if (cmd.equalsIgnoreCase("device_live_check")) {
  3607. retXML = ProcDeviceLiveCheck();
  3608. }
  3609. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
  3610. retXML = ProcPairingHdevSyncAlarm(elelist);
  3611. }
  3612. else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
  3613. retXML = ProcPairingHdevSyncSecurity(elelist);
  3614. }
  3615. else if (cmd.equalsIgnoreCase("notify_car_event")) {
  3616. retXML = ProcParkInformation(elelist);
  3617. }
  3618. else if (cmd.equalsIgnoreCase("call_redirect")) {
  3619. Log.d(TAG, "=== call_redirect ===");
  3620. NodeList mNodeList = elelist.getElementsByTagName("target_ip");
  3621. Element mElement = (Element) mNodeList.item(0);
  3622. String strRemoteIP = trimQuotation(mElement.getTextContent());
  3623. MainActivity.ReDirectCall(strRemoteIP);
  3624. }
  3625. else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
  3626. retXML = ProcSmartKeyEvent(elelist);
  3627. }
  3628. else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
  3629. retXML = ProcParkInformation_cham_upis(elelist);
  3630. }
  3631. else if (cmd.equalsIgnoreCase("remote_auscultate")) {
  3632. retXML = ProcauscultateReq(doc);
  3633. }
  3634. else if (cmd.equalsIgnoreCase("upgrade")) {
  3635. imapsvrlog( "Enter Upgrade");
  3636. procUpgrade();
  3637. retXML = null;
  3638. }
  3639. else if (cmd.equals("check_sip_activation")) {
  3640. String sip_result = "fail";
  3641. ActivityManager manager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  3642. List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
  3643. // Jeff added below codes for call app (2018.01.25)
  3644. String strSIPPackageName = "kr.co.icontrols.callengine.sip.CeresSIPService";
  3645. for (int k = 0; k < rsi.size(); k++) {
  3646. ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
  3647. if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
  3648. sip_result = "ok";
  3649. break;
  3650. }
  3651. }
  3652. 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";
  3653. }
  3654. else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
  3655. retXML = iCMDProcDevList(doc);
  3656. }
  3657. else if (cmd.equalsIgnoreCase("remote_access_gas")) {
  3658. retXML = iCMDProcGASControl(elelist);
  3659. }
  3660. else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
  3661. retXML = iCMDProcSDPSmartLightControl(doc);
  3662. }
  3663. else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
  3664. if (ModelType == MODEL_TYPE.IHN_1020GL) {
  3665. retXML = iCMDProc_I_LightControl(doc);
  3666. }
  3667. else {
  3668. retXML = iCMDProcLivingLightControl(doc);
  3669. }
  3670. }
  3671. else if (cmd.equalsIgnoreCase("remote_access_electric")) {
  3672. if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I
  3673. || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I) {
  3674. retXML = iCMDProcSDPConcentControl(doc);
  3675. }
  3676. else if (ModelType == MODEL_TYPE.IHN_1020GL) {
  3677. retXML = iCMDProcEnergyMeterConcentControl(doc);
  3678. }
  3679. else {
  3680. retXML = iCMDProcMultiSWControl(doc);
  3681. }
  3682. }
  3683. else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
  3684. retXML = iCMDProcDoorlockControl(doc);
  3685. }
  3686. else if (cmd.equalsIgnoreCase("remote_access_temper")) {
  3687. retXML = iCMDProcTemperControl(doc);
  3688. }
  3689. else if (cmd.equalsIgnoreCase("remote_access_mode")) {
  3690. retXML = iCMDProcModeControl(doc);
  3691. }
  3692. else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
  3693. retXML = iCMDProcVentilControl(doc);
  3694. }
  3695. else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
  3696. retXML = iCMDProcCurtainControl(doc);
  3697. }
  3698. else if (cmd.equalsIgnoreCase("remote_access_light")) {
  3699. if (ModelType == Version.MODEL_TYPE.IHN_1020GL) {
  3700. retXML = iCMDProcEnergyMeterLightControl(doc);
  3701. }
  3702. else {
  3703. retXML = iCMDProcLightControl(doc);
  3704. }
  3705. }
  3706. else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
  3707. retXML = iCMDProcLightBatchControl(elelist);
  3708. }
  3709. //모바일 사용자 인증 관련 메시지
  3710. else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
  3711. ProcMobileDevice_AuthNumber(elelist);
  3712. }
  3713. else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
  3714. retXML = ProcMobileDevice_ADD_Finish(elelist);
  3715. }
  3716. else if (cmd.equalsIgnoreCase("remote_delete_device")) {
  3717. ProcMobileDevice_Delete(elelist);
  3718. }
  3719. else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
  3720. retXML = ProcGetSmartKeyInfo(elelist);
  3721. }
  3722. else if (cmd.equalsIgnoreCase("get_app_version_info")) {
  3723. retXML = ProcGetAppVersionInfo();
  3724. }
  3725. else if (cmd.equalsIgnoreCase("igate_init_info")) {
  3726. retXML = ProcIgateInitInfo(elelist);
  3727. }
  3728. else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
  3729. retXML = ProcElecCarChargeEventInfo(elelist);
  3730. }
  3731. else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
  3732. retXML = ProcEnergyTargetInfoAlarm(elelist);
  3733. }
  3734. else if (cmd.equalsIgnoreCase("check_call_option")) {
  3735. retXML = ProcCheckCallOption();
  3736. }
  3737. else if (cmd.equalsIgnoreCase("chat_sequence")) {
  3738. retXML = ProcChatSequence(elelist);
  3739. }
  3740. else if (cmd.equalsIgnoreCase("chat_message")) {
  3741. retXML = ProcChatMessage(elelist);
  3742. }
  3743. else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
  3744. retXML = ProcEvacuationLadderOpen(elelist);
  3745. }
  3746. else if (cmd.equalsIgnoreCase("smart_light_info")) {
  3747. retXML = SmartLightDetailInfo(elelist);
  3748. }
  3749. else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
  3750. retXML = KNXDeviceDetailInfo(elelist);
  3751. }
  3752. else if( cmd.equalsIgnoreCase("set_server_version")) {
  3753. retXML = ProcSetServerChange(elelist);
  3754. }
  3755. else if( cmd.equalsIgnoreCase("remote_access_onepass")) {
  3756. retXML = iCMDProcOnePass(elelist);
  3757. }
  3758. else if( cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
  3759. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3760. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  3761. retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
  3762. }
  3763. }
  3764. break;
  3765. }
  3766. }
  3767. if (retXML != null) {
  3768. imapsvrlog( "Socket write line\n"+retXML+"\r\n SO :"+iMAPSock.getSoLinger());
  3769. DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
  3770. byte[] outBF = retXML.getBytes("euc-kr");
  3771. outstream.write(outBF);
  3772. outstream.flush();
  3773. try { Thread.sleep(3000);}
  3774. catch (RuntimeException re) {
  3775. LogUtil.errorLogInfo("", TAG, re);
  3776. }
  3777. catch (Exception e){
  3778. LogUtil.errorLogInfo("", TAG, e);
  3779. }
  3780. iMAPSock.close();
  3781. }
  3782. else {
  3783. try {iMAPSock.close();}
  3784. catch (RuntimeException re) {
  3785. LogUtil.errorLogInfo("", TAG, re);
  3786. }
  3787. catch (Exception e){
  3788. LogUtil.errorLogInfo("", TAG, e);
  3789. }
  3790. }
  3791. }
  3792. catch (RuntimeException re) {
  3793. LogUtil.errorLogInfo("", TAG, re);
  3794. }
  3795. catch (Exception e) {
  3796. try {iMAPSock.close();}
  3797. catch (RuntimeException re) {
  3798. LogUtil.errorLogInfo("", TAG, re);
  3799. }
  3800. catch (Exception E){
  3801. LogUtil.errorLogInfo("", TAG, E);
  3802. }
  3803. LogUtil.errorLogInfo("", TAG, e);
  3804. }
  3805. }
  3806. // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
  3807. private void procUpgrade() {
  3808. imapsvrlog( "upgrade Start \n"+" "+WallPadiMAPUpgrade.active);
  3809. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3810. String[] getstate = sdb.GetSystemUpdateStatus();
  3811. sdb.closeDB();
  3812. Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
  3813. for (int i = 0; i < getstate.length; i++) {
  3814. Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
  3815. }
  3816. if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
  3817. upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
  3818. if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
  3819. }
  3820. }
  3821. // " 제거
  3822. private String trimquotation(String sen) {
  3823. sen = sen.replaceAll("\"", "");
  3824. return sen.trim();
  3825. }
  3826. //remote_auscultate 처리
  3827. public String ProcauscultateReq(Document Doc) {
  3828. String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
  3829. NodeList items = Doc.getElementsByTagName("group");
  3830. Node item;
  3831. String itemname=null;
  3832. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  3833. SettManager.DeleteSettingData();
  3834. SettManager.DropTable();
  3835. try
  3836. {
  3837. for( int i = 0; i<items.getLength();i++)
  3838. {
  3839. item = items.item(i);
  3840. itemname = GetAttributeVal(item, "type");
  3841. String GetCNT = GetAttributeVal(item, "count");
  3842. if (Integer.parseInt(GetCNT)<=0)
  3843. continue;
  3844. Element SettingItem = (Element) item;
  3845. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3846. for(int j=0;j<SettingList.getLength();j++)
  3847. {
  3848. Node subdevListitem = SettingList.item(j);
  3849. String devname = trimquotation(subdevListitem.getTextContent());
  3850. SettManager.InsertSettingData(itemname, devname, j);
  3851. }
  3852. }
  3853. }
  3854. catch (RuntimeException re) {
  3855. LogUtil.errorLogInfo("", TAG, re);
  3856. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3857. SettManager.closeDB();
  3858. return RetVal;
  3859. }
  3860. catch (Exception e)
  3861. {
  3862. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  3863. //e.printStackTrace();
  3864. LogUtil.errorLogInfo("", TAG, e);
  3865. SettManager.closeDB();
  3866. return RetVal;
  3867. }
  3868. SettManager.closeDB();
  3869. RetVal+="\"ok\" >\r\n </service>\r\n</imap>";
  3870. StatusBeatRequested = true;
  3871. Intent intent = new Intent();
  3872. intent.setAction(define.NOTIFY_ACNAME);
  3873. intent.putExtra(define.NOTIBR_KIND,define.NOTIFY_STARTSTATUSBEAT);
  3874. sendBroadcast(intent);
  3875. return RetVal;
  3876. }
  3877. public void DefaultProcauscultateReq(WallpadDevStatus SettManager)
  3878. {
  3879. String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  3880. "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n"+
  3881. "<service type=\"request\" name=\"remote_auscultate\">\r\n"+
  3882. " <guidemap devtype=\"homedev\" count=\"4\">\r\n"+
  3883. " <group type=\"ctrl_device\" count=\"5\">\r\n"+
  3884. " <unit>\"light\"</unit>\r\n"+
  3885. " <unit>\"thermostat\"</unit>\r\n"+
  3886. " <unit>\"gas\"</unit>\r\n"+
  3887. " <unit>\"doorlock\"</unit>\r\n"+
  3888. " <unit>\"ventil\"</unit>\r\n"+
  3889. " </group>\r\n"+
  3890. " <group type=\"talk_device\" count=\"4\">\r\n"+
  3891. " <unit>\"sub_homedev\"</unit>\r\n"+
  3892. " <unit>\"kitchen_tv\"</unit>\r\n"+
  3893. " <unit>\"bath_tv\"</unit>\r\n"+
  3894. " <unit>\"bath_phone\"</unit>\r\n"+
  3895. " </group>\r\n"+
  3896. " <group type=\"sensor\" count=\"6\">\r\n"+
  3897. " <unit>\"magnetic\"</unit>\r\n"+
  3898. " <unit>\"bugout\"</unit>\r\n"+
  3899. " <unit>\"bugin\"</unit>\r\n"+
  3900. " <unit>\"fire\"</unit>\r\n"+
  3901. " <unit>\"gas\"</unit>\r\n"+
  3902. " <unit>\"emergency\"</unit>\r\n"+
  3903. " </group>\r\n"+
  3904. " <group type=\"extended\" count=\"4\">\r\n"+
  3905. " <unit>\"gateway\"</unit>\r\n"+
  3906. " <unit>\"smartswitch\"</unit>\r\n"+
  3907. " <unit>\"handy\"</unit>\r\n"+
  3908. " <unit>\"energymeter\"</unit>\r\n"+
  3909. " </group>\r\n"+
  3910. " </guidemap>\r\n"+
  3911. "</service>\r\n"+
  3912. "</imap>\r\n";
  3913. try
  3914. {
  3915. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  3916. DocumentBuilder builder = factory.newDocumentBuilder();
  3917. InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
  3918. Document doc = builder.parse(istream);
  3919. NodeList items = doc.getElementsByTagName("group");
  3920. Node item;
  3921. String itemname=null;
  3922. SettManager.DeleteSettingData();
  3923. SettManager.DropTable();
  3924. for( int i = 0; i<items.getLength();i++)
  3925. {
  3926. item = items.item(i);
  3927. itemname = GetAttributeVal(item, "type");
  3928. String GetCNT = GetAttributeVal(item, "count");
  3929. if (Integer.parseInt(GetCNT)<=0)
  3930. continue;
  3931. Element SettingItem = (Element) item;
  3932. NodeList SettingList = SettingItem.getElementsByTagName("unit");
  3933. for(int j=0;j<SettingList.getLength();j++)
  3934. {
  3935. Node subdevListitem = SettingList.item(j);
  3936. String devname = trimquotation(subdevListitem.getTextContent());
  3937. SettManager.InsertSettingData(itemname, devname, j);
  3938. }
  3939. }
  3940. }
  3941. catch (RuntimeException re) {
  3942. LogUtil.errorLogInfo("", TAG, re);
  3943. }
  3944. catch (Exception e)
  3945. {
  3946. //e.printStackTrace();
  3947. LogUtil.errorLogInfo("", TAG, e);
  3948. }
  3949. }
  3950. String MakeFailMessage(String msg)
  3951. {
  3952. return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\""+msg+"\"</first_failed>\r\n</service>\r\n</imap>";
  3953. }
  3954. //SetInfo의 각 항목들의 무결성 확인
  3955. final String isUse = "사용함";
  3956. final String isNotUse = "사용안함";
  3957. boolean CheckSubdevData(String devName, String devData) {
  3958. String[] SplitedMSG;
  3959. try {
  3960. if (devName.equals("가스밸브")) {
  3961. SplitedMSG = devData.split("[(]");
  3962. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3963. String UseStr = SplitedMSG[2].split("[)]")[0];
  3964. if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
  3965. }
  3966. else if (devName.equals("디지털도어락")) {
  3967. SplitedMSG = devData.split("[(]");
  3968. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3969. String[] UseStr = SplitedMSG[2].split("[)]");
  3970. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3971. if (!UseStr[1].equals("종류")) return false;
  3972. UseStr = SplitedMSG[3].split("[)]");
  3973. if (!UseStr[0].equals("무선")&&!UseStr[0].equals("유선")) return false;
  3974. }
  3975. else if (devName.equals("온도조절기")) {
  3976. SplitedMSG = devData.split("[(]");
  3977. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3978. String[] UseStr = SplitedMSG[2].split("[)]");
  3979. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3980. }
  3981. else if (devName.equals("조명제어기")) {
  3982. SplitedMSG = devData.split("[(]");
  3983. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3984. String[] UseStr = SplitedMSG[2].split("[)]");
  3985. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3986. /*
  3987. if (!UseStr[1].equals("종류"))
  3988. return false;
  3989. UseStr = SplitedMSG[3].split("[)]");
  3990. if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
  3991. return false;
  3992. */
  3993. }
  3994. else if (devName.equals("환기시스템")) {
  3995. SplitedMSG = devData.split("[(]");
  3996. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  3997. String[] UseStr = SplitedMSG[2].split("[)]");
  3998. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  3999. /*
  4000. if (!UseStr[1].equals("종류"))
  4001. return false;
  4002. UseStr = SplitedMSG[3].split("[)]");
  4003. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
  4004. return false;
  4005. */
  4006. }
  4007. else if (devName.equals("시스템에어컨")) {
  4008. SplitedMSG = devData.split("[(]");
  4009. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4010. String[] UseStr = SplitedMSG[2].split("[)]");
  4011. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4012. }
  4013. else if (devName.equals("전동커튼")) {
  4014. SplitedMSG = devData.split("[(]");
  4015. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4016. String[] UseStr = SplitedMSG[2].split("[)]");
  4017. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4018. /*
  4019. if (!UseStr[1].equals("종류"))
  4020. return false;
  4021. UseStr = SplitedMSG[3].split("[)]");
  4022. if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
  4023. return false;
  4024. */
  4025. }
  4026. else if (devName.equals("실시간검침기")) {
  4027. SplitedMSG = devData.split("[(]");
  4028. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4029. String[] UseStr = SplitedMSG[2].split("[)]");
  4030. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4031. }
  4032. else if (devName.equals("스마트스위치&일괄소등")) {
  4033. SplitedMSG = devData.split("[(]");
  4034. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4035. String[] UseStr = SplitedMSG[2].split("[)]");
  4036. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4037. /*
  4038. if (!UseStr[1].equals("종류"))
  4039. return false;
  4040. UseStr = SplitedMSG[3].split("[)]");
  4041. if (!UseStr[0].equals("대외향스마트스위치")&&
  4042. !UseStr[0].equals("대외향일괄소등제어기")&&
  4043. !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
  4044. !UseStr[0].equals("현산향스마트스위치")&&
  4045. !UseStr[0].equals("현산향LCD스마트스위치"))
  4046. return false;
  4047. */
  4048. }
  4049. else if (devName.equals("무선리모컨")) {
  4050. SplitedMSG = devData.split("[(]");
  4051. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4052. String[] UseStr = SplitedMSG[2].split("[)]");
  4053. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4054. }
  4055. else if (devName.equals("현관카메라")) {
  4056. SplitedMSG = devData.split("[(]");
  4057. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4058. String[] UseStr = SplitedMSG[2].split("[)]");
  4059. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4060. /*
  4061. if (!UseStr[1].equals("종류"))
  4062. return false;
  4063. UseStr = SplitedMSG[3].split("[)]");
  4064. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
  4065. return false;
  4066. */
  4067. }
  4068. else if (devName.equals("공지사항")) {
  4069. SplitedMSG = devData.split("[(]");
  4070. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4071. String[] UseStr = SplitedMSG[2].split("[)]");
  4072. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4073. }
  4074. else if (devName.equals("날씨")) {
  4075. SplitedMSG = devData.split("[(]");
  4076. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4077. String[] UseStr = SplitedMSG[2].split("[)]");
  4078. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4079. }
  4080. else if (devName.equals("메모")) {
  4081. SplitedMSG = devData.split("[(]");
  4082. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4083. String[] UseStr = SplitedMSG[2].split("[)]");
  4084. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4085. }
  4086. else if (devName.equals("전자액자")) {
  4087. SplitedMSG = devData.split("[(]");
  4088. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4089. String[] UseStr = SplitedMSG[2].split("[)]");
  4090. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4091. }
  4092. else if (devName.equals("일정표")) {
  4093. SplitedMSG = devData.split("[(]");
  4094. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4095. String[] UseStr = SplitedMSG[2].split("[)]");
  4096. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4097. }
  4098. else if (devName.equals("주차확인")) {
  4099. SplitedMSG = devData.split("[(]");
  4100. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4101. String[] UseStr = SplitedMSG[2].split("[)]");
  4102. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4103. /*
  4104. UseStr = SplitedMSG[3].split("[)]");
  4105. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
  4106. return false;
  4107. */
  4108. }
  4109. else if (devName.equals("시간설정")) {
  4110. SplitedMSG = devData.split("[(]");
  4111. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4112. String[] UseStr = SplitedMSG[2].split("[)]");
  4113. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4114. }
  4115. else if (devName.equals("원격검침")) {
  4116. SplitedMSG = devData.split("[(]");
  4117. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4118. String[] UseStr = SplitedMSG[2].split("[)]");
  4119. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4120. }
  4121. else if (devName.equals("뮤직")) {
  4122. SplitedMSG = devData.split("[(]");
  4123. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4124. String[] UseStr = SplitedMSG[2].split("[)]");
  4125. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4126. }
  4127. else if (devName.equals("영상재생")) {
  4128. SplitedMSG = devData.split("[(]");
  4129. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4130. String[] UseStr = SplitedMSG[2].split("[)]");
  4131. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4132. }
  4133. else if (devName.equals("CCTV")) {
  4134. SplitedMSG = devData.split("[(]");
  4135. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4136. String[] UseStr = SplitedMSG[2].split("[)]");
  4137. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4138. /*
  4139. UseStr = SplitedMSG[3].split("[)]");
  4140. if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
  4141. return false;
  4142. */
  4143. }
  4144. else if (devName.equals("명칭설정")) {
  4145. SplitedMSG = devData.split("[(]");
  4146. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4147. String[] UseStr = SplitedMSG[2].split("[)]");
  4148. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4149. }
  4150. else if (devName.equals("출동경비")) {
  4151. SplitedMSG = devData.split("[(]");
  4152. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4153. String[] UseStr = SplitedMSG[2].split("[)]");
  4154. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4155. }
  4156. else if (devName.equals("경비실영상통화")) {
  4157. SplitedMSG = devData.split("[(]");
  4158. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4159. String[] UseStr = SplitedMSG[2].split("[)]");
  4160. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4161. }
  4162. else if (devName.equals("엘리베이터")) {
  4163. SplitedMSG = devData.split("[(]");
  4164. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4165. String[] UseStr = SplitedMSG[2].split("[)]");
  4166. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4167. /*
  4168. UseStr = SplitedMSG[3].split("[)]");
  4169. if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
  4170. return false;
  4171. */
  4172. }
  4173. else if (devName.equals("현장특화기능")) {
  4174. SplitedMSG = devData.split("[(]");
  4175. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4176. String[] UseStr = SplitedMSG[2].split("[)]");
  4177. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4178. /*
  4179. UseStr = SplitedMSG[3].split("[)]");
  4180. if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
  4181. return false;
  4182. */
  4183. }
  4184. else if (devName.equals("월패드카메라")) {
  4185. SplitedMSG = devData.split("[(]");
  4186. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4187. String[] UseStr = SplitedMSG[2].split("[)]");
  4188. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4189. }
  4190. else if (devName.equals("무드등")) {
  4191. SplitedMSG = devData.split("[(]");
  4192. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4193. String[] UseStr = SplitedMSG[2].split("[)]");
  4194. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4195. /*
  4196. UseStr = SplitedMSG[3].split("[)]");
  4197. if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
  4198. return false;
  4199. */
  4200. }
  4201. else if (devName.equals("피난사다리")) {
  4202. SplitedMSG = devData.split("[(]");
  4203. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4204. String[] UseStr = SplitedMSG[2].split("[)]");
  4205. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4206. }
  4207. else if (devName.equals("동체설정")) {
  4208. return true;
  4209. /*
  4210. SplitedMSG = devData.split("[(]");
  4211. if (!SplitedMSG[1].split(":")[1].equals(devName))
  4212. return false;
  4213. String[] UseStr = SplitedMSG[2].split("[)]");
  4214. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  4215. return false;
  4216. if (UseStr[0].equals(isNotUse)) return true;
  4217. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  4218. return false;
  4219. for (int i=3; i < SplitedMSG.length; i++)
  4220. {
  4221. UseStr = SplitedMSG[i].split("[)]");
  4222. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
  4223. return false;
  4224. if (i != SplitedMSG.length-1)
  4225. {
  4226. if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
  4227. return false;
  4228. }
  4229. }
  4230. */
  4231. }
  4232. else if (devName.equals("알람발생")) {
  4233. SplitedMSG = devData.split("[(]");
  4234. if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
  4235. String[] UseStr = SplitedMSG[2].split("[)]");
  4236. if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
  4237. }
  4238. else {
  4239. Log.w("iMAP", "No Such Name, Set Setup devName ="+ devName + ", devData ="+devData);
  4240. Log.w("iMAP", "Return true");
  4241. return true;
  4242. }
  4243. }
  4244. catch (RuntimeException re) {
  4245. LogUtil.errorLogInfo("", TAG, re);
  4246. return false;
  4247. }
  4248. catch (Exception e)
  4249. {
  4250. //e.printStackTrace();
  4251. LogUtil.errorLogInfo("", TAG, e);
  4252. return false;
  4253. }
  4254. return true;
  4255. }
  4256. public String ProcSetsetup(Document ele) {
  4257. Common.DebugLog("ProcSetsetup------------------------->");
  4258. String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
  4259. NodeList items = ele.getElementsByTagName("setting");
  4260. Node item;
  4261. String itemname=null;
  4262. String dateData=null;
  4263. String heartbeatP=null;
  4264. String Versions = null;
  4265. String SdbAccInit_Str = null;
  4266. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4267. Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
  4268. if (!SettManager.StartTransaction()) {
  4269. ResetFlag = false;
  4270. RetVal+="\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
  4271. SettManager.EndTransaction(false);
  4272. SettManager.closeDB();
  4273. return RetVal;
  4274. }
  4275. try {
  4276. for (int i = 0; i < items.getLength(); i++) {
  4277. item = items.item(i);
  4278. itemname = GetAttributeVal(item, "name");
  4279. if(itemname!=null)
  4280. {
  4281. if (itemname.equals("beat_time")) {
  4282. heartbeatP = GetAttributeVal(item, "value");
  4283. }
  4284. else if (itemname.equals("ver_setting")) {
  4285. Versions = GetAttributeVal(item, "value");
  4286. }
  4287. else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
  4288. Element guardlist = (Element) item;
  4289. NodeList GuardCTList = guardlist.getElementsByTagName("list");
  4290. if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
  4291. else continue;
  4292. for (int j = 0; j < GuardCTList.getLength(); j++) {
  4293. Node GuardListitem = GuardCTList.item(j);
  4294. String guardname = GetAttributeVal(GuardListitem, "name");
  4295. String guardvalue = GetAttributeVal(GuardListitem, "value");
  4296. SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
  4297. }
  4298. }
  4299. else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
  4300. Log.i(TAG, "[ProcSetsetup] danjiserverType: " + danjiserverType);
  4301. if (true) {
  4302. Element subdevList = (Element) item;
  4303. NodeList SubDevList = subdevList.getElementsByTagName("list");
  4304. for (int j = 0; j < SubDevList.getLength(); j++) {
  4305. Node subdevListitem = SubDevList.item(j);
  4306. String devname = GetAttributeVal(subdevListitem, "name");
  4307. String devval = GetAttributeVal(subdevListitem, "value");
  4308. if(devname!=null && devval!=null)
  4309. {
  4310. devname = devname.replaceAll("\\p{Z}", "");
  4311. devval = devval.replaceAll("\\p{Z}", "");
  4312. if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
  4313. devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  4314. devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
  4315. }
  4316. if (CheckSubdevData(devname, devval)==false) {
  4317. ResetFlag = false;
  4318. Log.w("iMAP", "Set Setup Fail name : "+devname+ " Value : "+devval );
  4319. //서브기기 이상하게 설정된 데이터 (<list name = "가스밸브" value = "1(1:주방)"/>)이런데이터의 처리가 필요하기 때문에 해당 데이터로 인해 파싱이 되지
  4320. //않으면, 그냥 다음 서브기기 데이터 파싱에서 사용
  4321. //해당 내용 테스트 확인 필요
  4322. //xml Test이용하여 확인함
  4323. continue;
  4324. // SettManager.EndTransaction(false);
  4325. // SettManager.closeDB();
  4326. // return MakeFailMessage(devname);
  4327. }
  4328. String[] SettingDBValue = SettManager.GetSettingData(devname);
  4329. if (SettingDBValue != null) {
  4330. String devInfo = SettingDBValue[1];
  4331. if (devInfo.equals(devval) == false) {
  4332. Log.w("iMAP", "Set Setup(imap) Name : "+devname+ " Value : "+devval );
  4333. Log.w("iMAP", "DB Setup Value : "+devInfo);
  4334. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  4335. ResetFlag = true;
  4336. }
  4337. }
  4338. else {
  4339. Log.w("iMAP", "DB No Setup Name and Value");
  4340. Log.w("iMAP", "Set Setup(imap) Name : "+devname+ " Value : "+devval );
  4341. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  4342. ResetFlag = true;
  4343. }
  4344. //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
  4345. if (devname.equals("로고설정")) {
  4346. String devInfo = devval;
  4347. devInfo = devInfo.replace('(', '_');
  4348. devInfo = devInfo.replace(':', '_');
  4349. devInfo = devInfo.replace(')', '_');
  4350. String[] DetailInfo = devInfo.split("_");
  4351. int LogoType = 0;
  4352. if (DetailInfo[5].equals("표시안함") == true) {
  4353. LogoType = 0;
  4354. }
  4355. else if (DetailInfo[5].equals("SKT스마트홈") == true) {
  4356. LogoType = 1;
  4357. }
  4358. else if (DetailInfo[5].equals("양우내안애") == true) {
  4359. LogoType = 2;
  4360. }
  4361. else if (DetailInfo[5].equals("GSITM") == true) {
  4362. LogoType = 3;
  4363. }
  4364. else if (DetailInfo[5].equals("제로에너지하우스") == true) {
  4365. LogoType = 4;
  4366. }
  4367. else if (DetailInfo[5].equals("거실조명표시") == true) {
  4368. LogoType = 5;
  4369. }
  4370. else if (DetailInfo[5].equals("거실조명삭제") == true) {
  4371. LogoType = 6;
  4372. }
  4373. else if (DetailInfo[5].equals("기타1") == true) {
  4374. LogoType = 7;
  4375. }
  4376. else if (DetailInfo[5].equals("기타2") == true) {
  4377. LogoType = 8;
  4378. }
  4379. if ((LogoType >= 0) && (LogoType <= 8)) {
  4380. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
  4381. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  4382. }
  4383. }
  4384. else if (devname.equals("엘리베이터위젯복구")) {
  4385. String devInfo = devval;
  4386. devInfo = devInfo.replace('(', '_');
  4387. devInfo = devInfo.replace(':', '_');
  4388. devInfo = devInfo.replace(')', '_');
  4389. String[] DetailInfo = devInfo.split("_");
  4390. if (DetailInfo[3].equals("사용함") == true) {
  4391. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
  4392. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  4393. }
  4394. }
  4395. else if (devname.equals("분전반알람설정")) {
  4396. try {
  4397. String devInfo = devval;
  4398. devInfo = devInfo.replace('(', '_');
  4399. devInfo = devInfo.replace(':', '_');
  4400. devInfo = devInfo.replace(')', '_');
  4401. SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
  4402. //[0] - 기기번호
  4403. //[1] - 회로수
  4404. //[2] - 기기이름
  4405. //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
  4406. //[4] - 명칭
  4407. //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
  4408. String[] DetailInfo = devInfo.split("_");
  4409. for (int a = 0; a < DetailInfo.length; a++) {
  4410. if (DetailInfo[a].equals("누적전력초기화")) {
  4411. // 분전반 알람 설정 안에 '초기화'가 있는 경우
  4412. if ((a+1) <= DetailInfo.length) {
  4413. // 설정정보가 존재해야 인식하도록 함
  4414. if (DetailInfo[a+1].equals("1")) {
  4415. // 1(사용함) 일때
  4416. if (sdbAPI != null) {
  4417. if (sdbAPI.Set_AccPwReset() >= 0) {
  4418. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
  4419. }
  4420. else {
  4421. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
  4422. }
  4423. }
  4424. AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
  4425. AfterTransactionTodoList.offer(afterTransactionTodoListData);
  4426. }
  4427. devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
  4428. SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
  4429. Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
  4430. }
  4431. }
  4432. }
  4433. } catch (RuntimeException re) {
  4434. LogUtil.errorLogInfo("", TAG, re);
  4435. }
  4436. catch (Exception e) {
  4437. Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
  4438. //e.printStackTrace();
  4439. LogUtil.errorLogInfo("", TAG, e);
  4440. }
  4441. }
  4442. else if (devname.equals("욕실폰통화음량값")) {
  4443. Intent Iintent = new Intent();
  4444. Iintent.setAction(define.NOTIFY_ACNAME);
  4445. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
  4446. sendBroadcast(Iintent);
  4447. }
  4448. else if (devname.equals("주방TV통화음량값")) {
  4449. Intent Iintent = new Intent();
  4450. Iintent.setAction(define.NOTIFY_ACNAME);
  4451. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
  4452. sendBroadcast(Iintent);
  4453. }
  4454. else if (devname.equals("현관카메라")) {
  4455. if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  4456. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  4457. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  4458. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  4459. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF)
  4460. {
  4461. String devInfo = devval;
  4462. if(devInfo!=null)
  4463. {
  4464. devInfo = devInfo.replace('(', '_');
  4465. devInfo = devInfo.replace(':', '_');
  4466. devInfo = devInfo.replace(')', '_');
  4467. String[] DetailInfo = devInfo.split("_");
  4468. if (DetailInfo!=null && devname.equalsIgnoreCase(DetailInfo[2])) {
  4469. if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
  4470. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  4471. if(mIOInterface!=null) mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  4472. } else {
  4473. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
  4474. if(mIOInterface!=null) mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
  4475. }
  4476. }
  4477. }
  4478. }
  4479. }
  4480. else if (devname.equals("거동수상자녹화")) {
  4481. String devInfo = devval;
  4482. devInfo = devInfo.replace('(', '_');
  4483. devInfo = devInfo.replace(':', '_');
  4484. devInfo = devInfo.replace(')', '_');
  4485. String[] DetailInfo = devInfo.split("_");
  4486. // for (int k = 0; k < DetailInfo.length; k++) {
  4487. // Log.e(TAG, "[ProcSetsetup] DetailInfo[" + k + "] -> " + DetailInfo[k]);
  4488. // }
  4489. if (devname.equalsIgnoreCase(DetailInfo[2])) {
  4490. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  4491. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  4492. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  4493. }
  4494. else {
  4495. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  4496. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  4497. }
  4498. }
  4499. }
  4500. else if (devname.equals("스마트현관카메라좌우반전")) {
  4501. String devInfo = devval;
  4502. if(devInfo!=null)
  4503. {
  4504. devInfo = devInfo.replace('(', '_');
  4505. devInfo = devInfo.replace(':', '_');
  4506. devInfo = devInfo.replace(')', '_');
  4507. }
  4508. String[] DetailInfo = devInfo.split("_");
  4509. if (DetailInfo!=null && devname.equalsIgnoreCase(DetailInfo[2])) {
  4510. if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
  4511. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
  4512. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
  4513. } else {
  4514. Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
  4515. mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
  4516. }
  4517. }
  4518. }
  4519. else {
  4520. Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
  4521. }
  4522. }
  4523. }
  4524. }
  4525. }
  4526. else if (itemname.equals("datetime")) {
  4527. dateData = GetAttributeVal(item, "value");
  4528. }
  4529. else {
  4530. String GetVal = GetAttributeVal(item, "value");
  4531. if(GetVal!=null)
  4532. {
  4533. if (!GetVal.equals("list")) {
  4534. if (itemname.equals("site_code")) {
  4535. String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
  4536. if (Existing_SiteCode_Array == null) {
  4537. ResetFlag = true;
  4538. }
  4539. else {
  4540. String Existing_SiteCode = Existing_SiteCode_Array[1];
  4541. if (GetVal!=null && GetVal.equals(Existing_SiteCode) == false) {
  4542. ResetFlag = true;
  4543. }
  4544. }
  4545. }
  4546. SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
  4547. }
  4548. else {
  4549. String GetCNT = GetAttributeVal(item, "count");
  4550. if (Integer.parseInt(GetCNT)<=0) continue;
  4551. Element SettingItem = (Element) item;
  4552. NodeList SettingList = SettingItem.getElementsByTagName("list");
  4553. for (int j = 0; j < SettingList.getLength(); j++) {
  4554. Node subdevListitem = SettingList.item(j);
  4555. String devname = GetAttributeVal(subdevListitem, "name");
  4556. String devval = GetAttributeVal(subdevListitem, "value");
  4557. SettManager.UpdateSettingData(itemname, devname, j, devval);
  4558. }
  4559. }
  4560. }
  4561. }
  4562. }
  4563. }
  4564. } catch (RuntimeException re) {
  4565. LogUtil.errorLogInfo("", TAG, re);
  4566. ResetFlag = false;
  4567. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  4568. SettManager.EndTransaction(false);
  4569. SettManager.closeDB();
  4570. return RetVal;
  4571. }
  4572. catch (Exception e) {
  4573. ResetFlag = false;
  4574. RetVal+="\"fail\" >\r\n <first_failed>\""+itemname+"\"</first_failed>\r\n</service>\r\n</imap>";
  4575. //e.printStackTrace();
  4576. LogUtil.errorLogInfo("", TAG, e);
  4577. SettManager.EndTransaction(false);
  4578. SettManager.closeDB();
  4579. return RetVal;
  4580. }
  4581. SettManager.EndTransaction(true);
  4582. SettManager.closeDB();
  4583. //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
  4584. if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
  4585. Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
  4586. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  4587. }
  4588. if (AfterTransactionTodoList != null) {
  4589. if (AfterTransactionTodoList.size() > 0) {
  4590. for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
  4591. AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
  4592. if (afterTransactionTodoListData != null) {
  4593. if (afterTransactionTodoListData.Title.equals("로고설정")) {
  4594. WallpadSalesSampleData mWallpadSalesSampleData;
  4595. mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
  4596. mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
  4597. mWallpadSalesSampleData.closeDB();
  4598. }
  4599. else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
  4600. //ifdb에 있는지
  4601. ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
  4602. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  4603. int result = devSet.Get_Elevator_Info();
  4604. devSet.closeDB();
  4605. if (result != WallpadDeviceSet.ELEVATOR_NONE) {
  4606. // 엘리베이터가 사용함이면
  4607. if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
  4608. boolean result_get_restoreUseOrNot;
  4609. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  4610. if (wdb != null) {
  4611. result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
  4612. if (result_get_restoreUseOrNot == false) {
  4613. wdb.SetElevator_Widget_Restore(true);
  4614. //위젯 DB 초기화
  4615. WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
  4616. devSet2.DropTable(wallpaddbmgr.WidgetTBL);
  4617. devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
  4618. devSet2.initWidgetData();
  4619. devSet2.closeDB();
  4620. }
  4621. }
  4622. wdb.closeDB();
  4623. }
  4624. }
  4625. }
  4626. }
  4627. }
  4628. }
  4629. }
  4630. if (dateData!=null) {
  4631. try {
  4632. int year = Integer.parseInt(dateData.substring(0,4));
  4633. int month = Integer.parseInt(dateData.substring(4,6));
  4634. int day = Integer.parseInt(dateData.substring(6,8));
  4635. int hour = Integer.parseInt(dateData.substring(8,10));
  4636. int min = Integer.parseInt(dateData.substring(10,12));
  4637. int sec = Integer.parseInt(dateData.substring(12,14));
  4638. Calendar nowdate = new GregorianCalendar();
  4639. long settedtime = nowdate.getTimeInMillis();
  4640. nowdate.set(Calendar.YEAR, year);
  4641. nowdate.set(Calendar.MONTH, month);
  4642. nowdate.set(Calendar.DAY_OF_MONTH, day);
  4643. nowdate.set(Calendar.HOUR_OF_DAY, hour);
  4644. nowdate.set(Calendar.MINUTE, min);
  4645. nowdate.set(Calendar.SECOND, sec);
  4646. long bootupmil = nowdate.getTimeInMillis();
  4647. if (Math.abs(bootupmil-settedtime) > 5000) {
  4648. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4649. DBMGR.setSystemTime(year, month, day, hour, min, sec);
  4650. DBMGR.closeDB();
  4651. Intent Iintent = new Intent();
  4652. Iintent.setAction(define.NOTIFY_ACNAME);
  4653. Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
  4654. sendBroadcast(Iintent);
  4655. }
  4656. } catch (RuntimeException re) {
  4657. LogUtil.errorLogInfo("", TAG, re);
  4658. }
  4659. catch (Exception e) {
  4660. //e.printStackTrace();
  4661. LogUtil.errorLogInfo("", TAG, e);
  4662. }
  4663. }
  4664. if (heartbeatP != null) {
  4665. try {
  4666. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4667. DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
  4668. DBMGR.closeDB();
  4669. } catch (RuntimeException re) {
  4670. LogUtil.errorLogInfo("", TAG, re);
  4671. RetVal +="\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  4672. SettManager.closeDB();
  4673. return RetVal;
  4674. }
  4675. catch (Exception e) {
  4676. //e.printStackTrace();
  4677. LogUtil.errorLogInfo("", TAG, e);
  4678. RetVal +="\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
  4679. SettManager.closeDB();
  4680. return RetVal;
  4681. }
  4682. }
  4683. if (Versions != null) {
  4684. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4685. Log.d(TAG, "-----------Version Save ---------->" + Versions);
  4686. DBMGR.SetSettingVer(Versions);
  4687. DBMGR.closeDB();
  4688. }
  4689. Intent intent = new Intent();
  4690. intent.setAction(define.NOTIFY_ACNAME);
  4691. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  4692. getApplicationContext().sendBroadcast(intent);
  4693. RetVal+="\"ok\" >\r\n </service>\r\n</imap>";
  4694. return RetVal;
  4695. }
  4696. public String ProcNotifyparcel(Document doc) {
  4697. NodeList param = doc.getElementsByTagName("move_info");
  4698. Node item = param.item(0);
  4699. String aa = item.getTextContent();
  4700. aa = trimquotation(aa);
  4701. param = doc.getElementsByTagName("params");
  4702. item = param.item(0);
  4703. if (item != null) {
  4704. String devname = GetAttributeVal(item, "message");
  4705. if (devname != null) {
  4706. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4707. if (msgList[0].equalsIgnoreCase("remains")) {
  4708. int itemCount = Integer.parseInt(msgList[1]);
  4709. if (itemCount > 0) {
  4710. wakeupLCD();
  4711. Intent intent = new Intent();
  4712. intent.setAction(define.NOTIFY_ACNAME);
  4713. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  4714. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4715. intent.putExtra("ITEM",itemCount);
  4716. getApplicationContext().sendBroadcast(intent);
  4717. }
  4718. }
  4719. }
  4720. }
  4721. String retVal = XMLHeader +
  4722. "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n"+
  4723. "</imap>\r\n";
  4724. return retVal;
  4725. }
  4726. public String ProcNotiPostInfo(Document doc) {
  4727. NodeList param = doc.getElementsByTagName("move_info");
  4728. Node item = param.item(0);
  4729. String aa = item.getTextContent();
  4730. aa = trimquotation(aa);
  4731. if (item != null) {
  4732. String info = item.getTextContent();
  4733. if (info != null) {
  4734. Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
  4735. if (info.contains("post_in")) { // 우편물 보관
  4736. wakeupLCD();
  4737. int itemCount = -1;
  4738. param = doc.getElementsByTagName("params");
  4739. item = param.item(0);
  4740. if (item != null) {
  4741. String devname = GetAttributeVal(item, "message");
  4742. if (devname != null) {
  4743. if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
  4744. String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
  4745. if (msgList[0].equalsIgnoreCase("remains")) {
  4746. itemCount = Integer.parseInt(msgList[1]);
  4747. }
  4748. }
  4749. }
  4750. }
  4751. if (itemCount > 0) {
  4752. Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
  4753. Intent intent = new Intent();
  4754. intent.setAction(define.NOTIFY_ACNAME);
  4755. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
  4756. intent.putExtra(define.NOTIBR_CONTENT, aa);
  4757. intent.putExtra("ITEM", itemCount);
  4758. getApplicationContext().sendBroadcast(intent);
  4759. }
  4760. }
  4761. }
  4762. }
  4763. String retVal = XMLHeader +
  4764. "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n"+
  4765. "</imap>\r\n";
  4766. return retVal;
  4767. }
  4768. /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
  4769. public String ProcNotifypark(Document doc)
  4770. {
  4771. String MoveInfo = "none";
  4772. NodeList param = doc.getElementsByTagName("destination");
  4773. Node item = param.item(0);
  4774. if (item != null)
  4775. {
  4776. String dong = GetAttributeVal(item, "id_high").trim();
  4777. String ho = GetAttributeVal(item, "id_low").trim();
  4778. if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
  4779. return (XMLHeader +
  4780. "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
  4781. "</imap>\r\n");
  4782. }
  4783. param = doc.getElementsByTagName("move_info");
  4784. item = param.item(0);
  4785. if (item != null) MoveInfo = trimquotation(item.getNodeValue());
  4786. param = doc.getElementsByTagName("params");
  4787. item = param.item(0);
  4788. if (item != null)
  4789. {
  4790. String carnum = GetAttributeVal(item, "car_num");
  4791. String locinfo = GetAttributeVal(item, "loc_info");
  4792. String msg = GetAttributeVal(item, "message");
  4793. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  4794. parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
  4795. parkdb.closeDB();Intent intent = new Intent();
  4796. intent.setAction(define.NOTIFY_ACNAME);
  4797. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  4798. getApplicationContext().sendBroadcast(intent);
  4799. }
  4800. String retVal = XMLHeader +
  4801. "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
  4802. "</imap>\r\n";
  4803. return retVal;
  4804. }
  4805. */
  4806. public String ProcGetsetup(Document doc) {
  4807. WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
  4808. NodeList items = doc.getElementsByTagName("variable");
  4809. String RetVal = XMLHeader+"<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n"+
  4810. " <guidemap devtype=\"homedev\" count=\""+items.getLength()+"\">\r\n";
  4811. Node item;
  4812. try {
  4813. for (int i = 0; i < items.getLength(); i++) {
  4814. item = items.item(i);
  4815. //String mRealTimeMeterData = item.getNodeValue();
  4816. String data = trimquotation(item.getTextContent());
  4817. List<String[]> gData = SettManager.GetSettingGroupData(data);
  4818. if (gData.size() == 1) {
  4819. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+gData.get(0)[1]+"\" />\r\n";
  4820. }
  4821. else if (gData.size() > 1) {
  4822. RetVal+=" <setting name=\""+data+"\" count=\""+gData.size()+"\" value=\"list\" >\r\n";
  4823. RetVal+=" <list name=\"DeviceInfo\" value=\""+ Build.MODEL + "/" + getAOSVerCode() +"\" />\r\n";
  4824. for (int k = 0 ; k <gData.size();k++) {
  4825. // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
  4826. if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
  4827. //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4828. gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4829. gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
  4830. }
  4831. RetVal+=" <list name=\""+gData.get(k)[0]+"\" value=\""+gData.get(k)[1]+"\" />\r\n";
  4832. }
  4833. if (bAirQualityEnable) {
  4834. RetVal+=" <list name=\"공기질센서버전\" value=\""+ getAirQualityInfo() +"\" />\r\n";
  4835. }
  4836. RetVal+=" </setting>\r\n";
  4837. }
  4838. else {
  4839. if (data.equals("beat_time")) {
  4840. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4841. int heartbeatP = DBMGR.GetHeartbeatPeriod();
  4842. DBMGR.closeDB();
  4843. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+heartbeatP+"\" />\r\n";
  4844. }
  4845. else if (data.equals("ver_setting")) {
  4846. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4847. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+DBMGR.GetSettingVer()+"\" />\r\n";
  4848. DBMGR.closeDB();
  4849. }
  4850. else if (data.equals("datetime")) {
  4851. Calendar cal = new GregorianCalendar();
  4852. 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";
  4853. }
  4854. else if (data.equals("security_state")) {
  4855. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  4856. int alarmST = DBMGR.GetAlarmStatus();
  4857. String SEC_ST;
  4858. if (alarmST == WallpadStatusData.GUARD_OUT ) SEC_ST = "out";
  4859. else if (alarmST == WallpadStatusData.GUARD_IN ) SEC_ST = "in";
  4860. else SEC_ST = "normal";
  4861. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\""+SEC_ST+"\" />\r\n";
  4862. DBMGR.closeDB();
  4863. }
  4864. else if (data.equals("sensor_state")) {
  4865. int senIDX = 0;
  4866. String resultStr = "";
  4867. WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
  4868. int BugSensor = DBMGR.Get_Sensor_Set();
  4869. WallPadInterface wpifc = new WallPadInterface();
  4870. if (BugSensor > 0) {
  4871. if ((BugSensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
  4872. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4873. String Senret;
  4874. if (outSen>0) Senret = "detect";
  4875. else Senret = "undetect";
  4876. resultStr+=" <list name=\"in_move\" count=\"0\" value=\""+Senret+"\" />\r\n";
  4877. senIDX++;
  4878. }
  4879. else {
  4880. if ((BugSensor&WallpadDeviceSet.SET_IN_MOTION) > 0) {
  4881. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  4882. String Senret;
  4883. if (outSen>0) Senret = "detect";
  4884. else Senret = "undetect";
  4885. resultStr+=" <list name=\"in_move\" value=\""+Senret+"\" />\r\n";
  4886. senIDX++;
  4887. }
  4888. if ((BugSensor&WallpadDeviceSet.SET_OUT_MOTION) > 0) {
  4889. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  4890. String Senret;
  4891. if (outSen>0) Senret = "detect";
  4892. else Senret = "undetect";
  4893. resultStr+=" <list name=\"out_move\" value=\""+Senret+"\" />\r\n";
  4894. senIDX++;
  4895. }
  4896. }
  4897. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  4898. String Senret;
  4899. if (outSen>0) Senret = "detect";
  4900. else Senret = "undetect";
  4901. resultStr+=" <list name=\"magnetic\" value=\""+Senret+"\" />\r\n";
  4902. senIDX++;
  4903. int StatusVal = DBMGR.GetDeviceSetted("알람발생");
  4904. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  4905. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  4906. if (outSen>0) Senret = "detect";
  4907. else Senret = "undetect";
  4908. resultStr+=" <list name=\"emergency\" value=\""+Senret+"\" />\r\n";
  4909. senIDX++;
  4910. }
  4911. DBMGR.closeDB();
  4912. }
  4913. if (senIDX > 0) {
  4914. RetVal += " <setting name = \"sensor_state\" count = \""+senIDX+"\" value = \"list\" >\r\n";
  4915. RetVal += resultStr;
  4916. RetVal += " </setting>\r\n";
  4917. }
  4918. }
  4919. else if (data.equals("statusbeat_time")) {
  4920. }
  4921. else {
  4922. RetVal+=" <setting name=\""+data+"\" count=\"0\" value=\"\" />\r\n";
  4923. }
  4924. }
  4925. }
  4926. } catch (RuntimeException re) {
  4927. LogUtil.errorLogInfo("", TAG, re);
  4928. }
  4929. catch (Exception e) {
  4930. Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
  4931. //e.printStackTrace();
  4932. LogUtil.errorLogInfo("", TAG, e);
  4933. }
  4934. SettManager.closeDB();
  4935. RetVal+=" </guidemap>\r\n </service>\r\n</imap>";
  4936. return RetVal;
  4937. }
  4938. public void ProcElevatorinfo(Element ele) {
  4939. try {
  4940. String floor;
  4941. String move_dir;
  4942. /*
  4943. NodeList evinfo = ele.getElementsByTagName("ev_count");
  4944. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
  4945. Node info = evinfo.item(0);
  4946. imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
  4947. if (info != null)
  4948. {
  4949. elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
  4950. }
  4951. */
  4952. NodeList ievinfo = ele.getElementsByTagName("ev_info");
  4953. Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength() );
  4954. Node iinfo = ievinfo.item(0);
  4955. if (iinfo == null) {
  4956. Log.d("iMapServer" , "func ProcElevatorinfo info == null");
  4957. return;
  4958. }
  4959. floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
  4960. // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
  4961. move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
  4962. int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4963. if(move_dir!=null)
  4964. {
  4965. if (move_dir.equalsIgnoreCase("up")) {
  4966. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
  4967. }
  4968. else if (move_dir.equalsIgnoreCase("down")) {
  4969. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
  4970. }
  4971. else if (move_dir.equalsIgnoreCase("stop")) {
  4972. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
  4973. }
  4974. else if (move_dir.equalsIgnoreCase("wrong")) {
  4975. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4976. }
  4977. else if (move_dir.equalsIgnoreCase("finish")) {
  4978. MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
  4979. }
  4980. Log.d("iMapServer" , "MoveDirForIntent: "+MoveDirForIntent);
  4981. }
  4982. byte updown = 0x00;
  4983. if (ievinfo != null) {
  4984. boolean downCall = false;
  4985. boolean upCall = false;
  4986. for (int i = 0; i < ievinfo.getLength(); i++ ) {
  4987. Node valItem = ievinfo.item(i);
  4988. if (valItem != null) {
  4989. if (downCall == false)
  4990. {
  4991. String val =GetAttributeVal(valItem, "ev_call_dir");
  4992. if(val!=null)
  4993. downCall = val.equalsIgnoreCase("down");
  4994. }
  4995. if (upCall == false) {
  4996. String val = GetAttributeVal(valItem, "ev_call_dir");
  4997. if(val!=null)
  4998. {
  4999. upCall = val.equalsIgnoreCase("up");
  5000. }
  5001. }
  5002. }
  5003. }
  5004. Log.d("iMapServer" , "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall );
  5005. if (downCall == true && upCall == true) updown = 0x02;
  5006. else if (downCall == false && upCall == true) updown = 0x01;
  5007. }
  5008. Log.d(TAG , "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
  5009. Intent intent = new Intent();
  5010. intent.setAction(define.NOTIFY_ACNAME);
  5011. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
  5012. intent.putExtra(define.NOTIBR_FLOOR, floor);
  5013. intent.putExtra(define.NOTIBR_UPDOWN, updown);
  5014. intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
  5015. getApplicationContext().sendBroadcast(intent);
  5016. } catch (RuntimeException re) {
  5017. LogUtil.errorLogInfo("", TAG, re);
  5018. }
  5019. catch (Exception e) {
  5020. Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
  5021. //e.printStackTrace();
  5022. LogUtil.errorLogInfo("", TAG, e);
  5023. }
  5024. }
  5025. private String MakeTargetStr(WallpadiCMDParser data) {
  5026. return " <target name=\""+data.target+"\" id = \""+data.tid+"\" msg_no=\""+data.msgno+"\"/>\r\n";
  5027. }
  5028. public String iCMDProcVentilControl(Document doc) {
  5029. try {
  5030. String unit_status = "null", mode = "null", unit_mode = "null";
  5031. String retStr = CheckiCMDProc("remote_access_ventil");
  5032. if (retStr != null) return retStr;
  5033. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
  5034. String target= "null", tid= "null", msgno= "null";
  5035. NodeList items = doc.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")) msgno = attr.getNodeValue();
  5044. }
  5045. }
  5046. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5047. if (NewServerUse()) {
  5048. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  5049. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5050. }
  5051. boolean procSucc = true;
  5052. WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
  5053. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  5054. if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
  5055. if (VentilCTR!=null && VentilCTR.Refresh(false) == 0) {
  5056. if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
  5057. boolean OnOff = false;
  5058. if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
  5059. if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
  5060. else procSucc = false;
  5061. }
  5062. else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
  5063. byte strength = 0;
  5064. if (ventilParser.ctraction.equalsIgnoreCase("low")) strength = VentiAPI.WIND.LOW;
  5065. else if (ventilParser.ctraction.equalsIgnoreCase("mid")) strength = VentiAPI.WIND.MID;
  5066. else strength = VentiAPI.WIND.HI;
  5067. if (VentilCTR.data.OnOff) {
  5068. // 환기가 On인 경우
  5069. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  5070. else procSucc = false;
  5071. }
  5072. else {
  5073. // 환기가 Off인 경우
  5074. if (VentilCTR.SetOnOff(true) >= 0) {
  5075. if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
  5076. else procSucc = false;
  5077. }
  5078. else {
  5079. procSucc = false;
  5080. }
  5081. }
  5082. }
  5083. if (VentilCTR.Refresh(true) == 0) {
  5084. if (VentilCTR.data.OnOff == false) unit_status = "off";
  5085. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  5086. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  5087. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  5088. else unit_status = "unknown";
  5089. if (VentilCTR.data.Support.AutoDriving) {
  5090. mode = "normal/auto";
  5091. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  5092. else unit_mode = "normal";
  5093. }
  5094. else {
  5095. mode = "normal";
  5096. unit_mode = "normal";
  5097. }
  5098. }
  5099. else {
  5100. procSucc = false;
  5101. }
  5102. }
  5103. else {
  5104. procSucc = false;
  5105. }
  5106. }
  5107. else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
  5108. if (VentilCTR!=null && VentilCTR.Refresh(false) == 0) {
  5109. if (VentilCTR.data.OnOff == false) unit_status = "off";
  5110. else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
  5111. else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
  5112. else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
  5113. else unit_status = "unknown";
  5114. if (VentilCTR.data.Support.AutoDriving) {
  5115. mode = "normal/auto";
  5116. if (VentilCTR.data.AutoDriving) unit_mode = "auto";
  5117. else unit_mode = "normal";
  5118. }
  5119. else {
  5120. mode = "normal";
  5121. unit_mode = "normal";
  5122. }
  5123. }
  5124. else {
  5125. procSucc = false;
  5126. }
  5127. }
  5128. else {
  5129. procSucc = false;
  5130. }
  5131. if (procSucc == false) {
  5132. retStr+=(" result=\"fail\" >\r\n");
  5133. unit_status = "unknown";
  5134. }
  5135. else {
  5136. retStr+=(" result=\"ok\" >\r\n");
  5137. }
  5138. retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
  5139. retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
  5140. retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
  5141. retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
  5142. return retStr;
  5143. } catch (RuntimeException re) {
  5144. LogUtil.errorLogInfo("", TAG, re);
  5145. return null;
  5146. }
  5147. catch (Exception e) {
  5148. Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
  5149. //e.printStackTrace();
  5150. LogUtil.errorLogInfo("", TAG, e);
  5151. return null;
  5152. }
  5153. }
  5154. public String iCMDProcTemperControl(Document doc) {
  5155. try {
  5156. String retStr = CheckiCMDProc("remote_access_temper");
  5157. if (retStr != null) return retStr;
  5158. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
  5159. String target= "null", tid= "null", msgno= "null";
  5160. NodeList items = doc.getElementsByTagName("target");
  5161. Node item = items.item(0);
  5162. if (item != null) {
  5163. NamedNodeMap attrs = item.getAttributes();
  5164. for (int j = 0; j< attrs.getLength(); j++) {
  5165. Node attr = attrs.item(j);
  5166. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5167. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5168. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5169. }
  5170. }
  5171. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5172. if (NewServerUse()) {
  5173. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  5174. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5175. }
  5176. WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
  5177. String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
  5178. tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
  5179. // 난방 종류를 얻어온다.
  5180. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5181. HeatingV1API heatingV1API = null;
  5182. HeatingV2API heatingV2API = null;
  5183. // 종류별 API를 로딩한다.
  5184. if(HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5185. else if(HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5186. Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
  5187. if (tempercmd.actionTXT.equals("control")) {
  5188. String[] CtrList;
  5189. byte ctrl = 0;
  5190. byte roomNum = (byte)0xFF;
  5191. double temp = 0;
  5192. if (tempercmd.unitnum.equals("all")) {
  5193. if (tempercmd.ctraction.equals("on")) {
  5194. ctrl = 1;
  5195. }
  5196. else if (tempercmd.ctraction.equals("off")) {
  5197. ctrl = 0;
  5198. }
  5199. else {
  5200. retStr+="\"fail\">\r\n <target name=\""+tempercmd.target+"\" id=\""+tempercmd.tid+"\" msg_no=\""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap> ";
  5201. return retStr;
  5202. }
  5203. }
  5204. else {
  5205. CtrList = tempercmd.ctraction.split("/");
  5206. if (CtrList[0].equals("on")) ctrl = 1;
  5207. else ctrl = 0;
  5208. roomNum = (byte)0xFF;
  5209. temp = Double.parseDouble(CtrList[1]);
  5210. }
  5211. if (HeatingKind == 1) {
  5212. boolean OnOff = false;
  5213. if (ctrl == 1) OnOff = true;
  5214. if (tempercmd.unitnum.equals("all") && heatingV1API!=null) {
  5215. int ret = heatingV1API.SetAllRoomStatus(OnOff);
  5216. if (ret != APIErrorCode.C_SUCCESS) {
  5217. retStr+="\"fail\">\r\n <target name=\""+tempercmd.target+"\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
  5218. return retStr;
  5219. }
  5220. heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  5221. }
  5222. else {
  5223. for (byte i = 0; i < RoomList.length; i++) {
  5224. if (tempercmd.unitnum.equals(RoomList[i])) {
  5225. roomNum = i;
  5226. break;
  5227. }
  5228. }
  5229. if (roomNum == (byte) 0xFF) {
  5230. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\""+tempercmd.msgno+"\"/>\r\n </service>\r\n</imap>";
  5231. return retStr;
  5232. }
  5233. if(heatingV1API!=null)
  5234. {
  5235. int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff)?(byte)1:(byte)2, temp);
  5236. if (ret != APIErrorCode.C_SUCCESS) {
  5237. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5238. return retStr;
  5239. }
  5240. heatingV1API.Refresh(roomNum, false);
  5241. }
  5242. }
  5243. }
  5244. else if (HeatingKind == 2) {
  5245. byte Mode = HeatingV2.MODE.HeatingOFF;
  5246. if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
  5247. if (tempercmd.unitnum.equals("all")) {
  5248. if(heatingV2API!=null)
  5249. {
  5250. int ret = heatingV2API.SetAllRoomStatus(Mode);
  5251. if (ret != APIErrorCode.C_SUCCESS) {
  5252. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5253. return retStr;
  5254. }
  5255. heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
  5256. }
  5257. }
  5258. else {
  5259. for (byte i = 0; i < RoomList.length; i++) {
  5260. if (tempercmd.unitnum.equals(RoomList[i])) {
  5261. roomNum = i;
  5262. break;
  5263. }
  5264. }
  5265. if (roomNum == (byte) 0xFF) {
  5266. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5267. return retStr;
  5268. }
  5269. if(heatingV2API!=null)
  5270. {
  5271. int ret = heatingV2API.SetEachRoomStatus(roomNum, Mode, temp);
  5272. if (ret != APIErrorCode.C_SUCCESS) {
  5273. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5274. return retStr;
  5275. }
  5276. heatingV2API.Refresh(roomNum, false);
  5277. }
  5278. }
  5279. }
  5280. else {
  5281. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5282. return retStr;
  5283. }
  5284. }
  5285. String resultStr=" <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
  5286. if (HeatingKind == 1) {
  5287. try {
  5288. if(heatingV1API == null)
  5289. {
  5290. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5291. return retStr;
  5292. }
  5293. byte RoomCount = heatingV1API.data.Device.RoomCount;
  5294. resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
  5295. resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount +"\"/>\r\n";
  5296. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  5297. String drvmode = "off";
  5298. for (byte i = 0; i < RoomCount ; i++) {
  5299. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
  5300. if (roomData.bOnOff) drvmode = "on";
  5301. else drvmode = "off";
  5302. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  5303. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  5304. }
  5305. resultStr += " </service>\r\n</imap>\r\n";
  5306. retStr+=("\"ok\">\r\n"+resultStr);
  5307. return retStr;
  5308. }
  5309. else {
  5310. String drvmode = "off";
  5311. byte roomNum = (byte) 0xFF;
  5312. for (byte i = 0; i < RoomList.length; i++) {
  5313. if (tempercmd.unitnum.equals(RoomList[i])) {
  5314. roomNum = i;
  5315. break;
  5316. }
  5317. }
  5318. if (roomNum == (byte) 0xFF) {
  5319. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5320. return retStr;
  5321. }
  5322. HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
  5323. if (roomData.bOnOff) drvmode = "on";
  5324. else drvmode = "off";
  5325. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  5326. resultStr += " <status_info unit_num=\""+RoomList[roomNum]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  5327. resultStr += " </service>\r\n</imap>\r\n";
  5328. retStr+=("\"ok\">\r\n"+resultStr);
  5329. return retStr;
  5330. }
  5331. } catch (RuntimeException re) {
  5332. LogUtil.errorLogInfo("", TAG, re);
  5333. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5334. return retStr;
  5335. }
  5336. catch (Exception e) {
  5337. //e.printStackTrace();
  5338. LogUtil.errorLogInfo("", TAG, e);
  5339. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5340. return retStr;
  5341. }
  5342. }
  5343. else if (HeatingKind == 2) {
  5344. try {
  5345. if(heatingV2API == null)
  5346. {
  5347. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5348. return retStr;
  5349. }
  5350. byte RoomCount = heatingV2API.data.Device.info.RoomCount;
  5351. resultStr += " <action> \""+tempercmd.actionTXT+"\"</action>\r\n";
  5352. resultStr += " <status_map dev_num=\"1\" unit_cnt = \""+RoomCount+"\" />\r\n";
  5353. if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
  5354. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount );
  5355. String drvmode = "off";
  5356. for (byte i = 0; i < RoomCount; i++) {
  5357. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
  5358. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  5359. else drvmode = "off";
  5360. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  5361. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  5362. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\" room_name=\"" + mDefaultRoomNameList_Heating[i] + "\"/>\r\n";
  5363. }
  5364. else {
  5365. resultStr += " <status_info unit_num=\""+RoomList[i]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  5366. }
  5367. }
  5368. resultStr += " </service>\r\n</imap>\r\n";
  5369. retStr+=("\"ok\">\r\n"+resultStr);
  5370. return retStr;
  5371. }
  5372. else {
  5373. String drvmode = "off";
  5374. byte roomNum = (byte) 0xFF;
  5375. for (byte i = 0; i < RoomList.length; i++) {
  5376. if (tempercmd.unitnum.equals(RoomList[i])) {
  5377. roomNum = i;
  5378. break;
  5379. }
  5380. }
  5381. if (roomNum == (byte) 0xFF) {
  5382. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5383. return retStr;
  5384. }
  5385. HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[roomNum];
  5386. if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
  5387. else drvmode = "off";
  5388. drvmode += "/"+roomData.SetTemp+"/"+roomData.NowTemp;
  5389. resultStr += " <status_info unit_num=\""+RoomList[roomNum]+"\" unit_status=\""+drvmode+"\"/>\r\n";
  5390. resultStr += " </service>\r\n</imap>\r\n";
  5391. retStr+=("\"ok\">\r\n"+resultStr);
  5392. return retStr;
  5393. }
  5394. } catch (RuntimeException re) {
  5395. LogUtil.errorLogInfo("", TAG, re);
  5396. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5397. return retStr;
  5398. }
  5399. catch (Exception e) {
  5400. //e.printStackTrace();
  5401. LogUtil.errorLogInfo("", TAG, e);
  5402. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5403. return retStr;
  5404. }
  5405. }
  5406. else {
  5407. Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^" );
  5408. retStr+="\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
  5409. return retStr;
  5410. }
  5411. // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
  5412. // return retStr;
  5413. } catch (RuntimeException re) {
  5414. LogUtil.errorLogInfo("", TAG, re);
  5415. return null;
  5416. }
  5417. catch (Exception e) {
  5418. Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
  5419. //e.printStackTrace();
  5420. LogUtil.errorLogInfo("", TAG, e);
  5421. return null;
  5422. }
  5423. }
  5424. public String iCMDProcDoorlockControl(Document doc) {
  5425. try {
  5426. String DLStatus = "none";
  5427. String strResult = CheckiCMDProc("remote_access_doorlock");
  5428. if (strResult != null) return strResult;
  5429. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
  5430. String target= "null", tid= "null", msgno= "null";
  5431. NodeList items = doc.getElementsByTagName("target");
  5432. Node item = items.item(0);
  5433. if (item != null) {
  5434. NamedNodeMap attrs = item.getAttributes();
  5435. for (int j = 0; j< attrs.getLength(); j++) {
  5436. Node attr = attrs.item(j);
  5437. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5438. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5439. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5440. }
  5441. }
  5442. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5443. if (NewServerUse()) {
  5444. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
  5445. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5446. }
  5447. WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
  5448. try {
  5449. DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
  5450. if(doorStatus!=null)
  5451. {
  5452. if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
  5453. DLStatus = "unknown";
  5454. }
  5455. else {
  5456. if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce) DLStatus = "close";
  5457. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open|| doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce) DLStatus = "open";
  5458. else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation) DLStatus = "ing";
  5459. else DLStatus="unknown";
  5460. }
  5461. }
  5462. }
  5463. catch (RuntimeException re) {
  5464. LogUtil.errorLogInfo("", TAG, re);
  5465. DLStatus="unknown";
  5466. }
  5467. catch (Exception e) {
  5468. //e.printStackTrace();
  5469. LogUtil.errorLogInfo("", TAG, e);
  5470. DLStatus="unknown";
  5471. }
  5472. String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n"+
  5473. " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n"+
  5474. " <action>\"status\"</action>\r\n"+
  5475. " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n"+
  5476. " <status_info unit_num=\"doorlock1\" unit_status=\""+DLStatus+"\"/>\r\n </service>\r\n</imap>";
  5477. return retXML;
  5478. } catch (RuntimeException re) {
  5479. LogUtil.errorLogInfo("", TAG, re);
  5480. return null;
  5481. }
  5482. catch (Exception e) {
  5483. Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
  5484. //e.printStackTrace();
  5485. LogUtil.errorLogInfo("", TAG, e);
  5486. return null;
  5487. }
  5488. }
  5489. /*
  5490. protected String iCMDProcsavelog(Document doc)
  5491. {
  5492. String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
  5493. String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
  5494. NodeList items = doc.getElementsByTagName("guidemap");
  5495. Node item = items.item(0);
  5496. NamedNodeMap attrsParam = item.getAttributes();
  5497. for(int j=0; j< attrsParam.getLength();j++)
  5498. {
  5499. Node attr = attrsParam.item(j);
  5500. if (attr.getNodeName().equalsIgnoreCase("enable"))
  5501. {
  5502. String enable = attr.getNodeValue();
  5503. if (enable == null) return FailretStr;
  5504. if (enable.equals("false"))
  5505. {
  5506. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  5507. logSet.SetLogDoing(0);
  5508. logSet.closeDB();
  5509. return SucretStr;
  5510. }
  5511. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  5512. logSet.SetLogDoing(1);
  5513. logSet.closeDB();
  5514. }
  5515. }
  5516. items = doc.getElementsByTagName("setting");
  5517. item = items.item(0);
  5518. attrsParam = item.getAttributes();
  5519. String SaveType = "";
  5520. String FtpLoc = "";
  5521. String Ftpuser = "";
  5522. String FtpPW= "";
  5523. String period = "";
  5524. String FileSize = "";
  5525. for(int j=0; j< attrsParam.getLength();j++)
  5526. {
  5527. Node attr = attrsParam.item(j);
  5528. if (attr.getNodeName().equalsIgnoreCase("save_type"))
  5529. SaveType = attr.getNodeValue();
  5530. else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
  5531. FtpLoc = attr.getNodeValue();
  5532. else if (attr.getNodeName().equalsIgnoreCase("user"))
  5533. Ftpuser = attr.getNodeValue();
  5534. else if (attr.getNodeName().equalsIgnoreCase("passwd"))
  5535. FtpPW = attr.getNodeValue();
  5536. else if (attr.getNodeName().equalsIgnoreCase("period"))
  5537. period = attr.getNodeValue();
  5538. else if (attr.getNodeName().equalsIgnoreCase("filesize"))
  5539. FileSize = attr.getNodeValue();
  5540. }
  5541. if (SaveType.equalsIgnoreCase("now"))
  5542. {
  5543. LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
  5544. LogUpThread.start();
  5545. return SucretStr;
  5546. }
  5547. else if (SaveType.equalsIgnoreCase("periodic"))
  5548. {
  5549. try
  5550. {
  5551. WallpadLogData logSet = new WallpadLogData(getApplicationContext());
  5552. period = period.trim();
  5553. String[] logperiod = period.split("[-]");
  5554. String StartDate = logperiod[0].replace(".", "_");
  5555. String EndDate = logperiod[1].replace(".", "_");
  5556. logSet.SetLogDoing(1);
  5557. logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
  5558. if (FileSize.equalsIgnoreCase("null"))
  5559. logSet.SetLogLogFileSize(0);
  5560. else
  5561. logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
  5562. logSet.SetLogStartDate(StartDate);
  5563. logSet.SetLogEndDate(EndDate);
  5564. logSet.closeDB();
  5565. return SucretStr;
  5566. }
  5567. catch (RuntimeException re) {
  5568. LogUtil.errorLogInfo("", TAG, re);
  5569. }
  5570. catch (Exception e)
  5571. {
  5572. e.printStackTrace();
  5573. return FailretStr;
  5574. }
  5575. }
  5576. else
  5577. {
  5578. return FailretStr;
  5579. }
  5580. }
  5581. */
  5582. protected void SendLogSaved(String ftploc, String fname, String size)
  5583. {
  5584. String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n"+
  5585. " <device_info devtype=\"homedev\" id_high=\""+AddrDong+"\" id_low=\""+AddrHo+"\"/>\r\n"+
  5586. " <file_info path=\""+ftploc+"\" name=\""+fname+"\" size=\""+size+"\"/>\r\n</service>\r\n</imap>";
  5587. SendToServer(SendMsg);
  5588. }
  5589. public final static int FTPLOGTRSUCC = 1110;
  5590. public final static int FTPLOGTRFAIL = 1120;
  5591. Handler FileTrHandler = new Handler(){
  5592. public void handleMessage(Message msg)
  5593. {
  5594. switch (msg.what)
  5595. {
  5596. case FTPLOGTRSUCC:
  5597. String[] getMSG = ((String)(msg.obj)).split(define.DEVCTR_CMD_SPLITER);
  5598. File fileinfo = new File(define.LOG_FILE_LOCATION+"/"+getMSG[1]);
  5599. int size = (int)(fileinfo.length()/1024);
  5600. SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
  5601. imapsvrlog("FTPLOGTRSUCC");
  5602. break;
  5603. case FTPLOGTRFAIL:
  5604. imapsvrlog("FTPLOGTRFAIL");
  5605. break;
  5606. }
  5607. }
  5608. };
  5609. class LogUploader extends Thread
  5610. {
  5611. int fileidx = 0;
  5612. boolean TRing = false;
  5613. String FtpLoc;
  5614. String FtpID;
  5615. String FtpPasswd;
  5616. class ftpuploader extends WallPadFTPUploader
  5617. {
  5618. String filename;
  5619. public ftpuploader(Context ctx, String ftpPath, String User,String Passwd, String LocalFile)
  5620. {
  5621. super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION+"/"+LocalFile);
  5622. filename = LocalFile;
  5623. }
  5624. protected void ProcUploadFail()
  5625. {
  5626. Message TrResult = FileTrHandler.obtainMessage();
  5627. TrResult.obj = ftpPATH+define.DEVCTR_CMD_SPLITER+filename+define.DEVCTR_CMD_SPLITER+id+define.DEVCTR_CMD_SPLITER+passwd;
  5628. TrResult.what = FTPLOGTRFAIL;
  5629. TRing = false;
  5630. imapsvrlog("Send Log Fail Message");
  5631. FileTrHandler.sendMessage(TrResult);
  5632. }
  5633. protected void ProcUploadSuccess()
  5634. {
  5635. Message TrResult = FileTrHandler.obtainMessage();
  5636. TrResult.obj = ftpPATH+define.DEVCTR_CMD_SPLITER+filename+define.DEVCTR_CMD_SPLITER+id+define.DEVCTR_CMD_SPLITER+passwd;
  5637. TrResult.what = FTPLOGTRSUCC;
  5638. TRing = false;
  5639. imapsvrlog("Send Log success Message");
  5640. FileTrHandler.sendMessage(TrResult);
  5641. }
  5642. }
  5643. public LogUploader(String loc, String user, String pw)
  5644. {
  5645. FtpLoc = loc;
  5646. FtpID = user;
  5647. FtpPasswd = pw;
  5648. }
  5649. public void run()
  5650. {
  5651. File LogLoc = new File(define.LOG_FILE_LOCATION);
  5652. String[] LogFileList = LogLoc.list();
  5653. while(true)
  5654. {
  5655. if (TRing == false)
  5656. {
  5657. if (LogFileList!=null && fileidx < LogFileList.length)
  5658. {
  5659. ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx] );
  5660. fileidx++;
  5661. TRing = true;
  5662. uploader.start();
  5663. }
  5664. else
  5665. return;
  5666. }
  5667. try {Thread.sleep(500); }
  5668. catch (RuntimeException re) {
  5669. LogUtil.errorLogInfo("", TAG, re);
  5670. }
  5671. catch (Exception e) {
  5672. LogUtil.errorLogInfo("", TAG, e);
  5673. }
  5674. }
  5675. }
  5676. }
  5677. public String iCMDProcDevList(Document ele) {
  5678. try {
  5679. String strResult = CheckiCMDProc("remote_get_home_devices");
  5680. if (strResult != null) return strResult;
  5681. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" result=";
  5682. String target= "null", tid= "null", msgno= "null";
  5683. NodeList items = ele.getElementsByTagName("target");
  5684. Node item = items.item(0);
  5685. if (item != null) {
  5686. NamedNodeMap attrs = item.getAttributes();
  5687. for (int j = 0; j< attrs.getLength(); j++) {
  5688. Node attr = attrs.item(j);
  5689. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  5690. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  5691. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  5692. }
  5693. }
  5694. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  5695. if (NewServerUse()) {
  5696. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  5697. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  5698. }
  5699. GasAPI mGasAPI = null;
  5700. CooktopAPI mCooktopAPI = null;
  5701. if (mWallPadAPI.GetGasKind() == 1) {
  5702. mGasAPI = mWallPadAPI.Get_GasController();
  5703. }
  5704. else if (mWallPadAPI.GetGasKind() == 2) {
  5705. mCooktopAPI = mWallPadAPI.Get_CookTopController();
  5706. }
  5707. WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
  5708. // String[] devlist = {"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop"};
  5709. String[] devlist = {"gas", "livinglight", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop"};
  5710. strResult += "\"ok\">\r\n";
  5711. strResult +=" <target name=\""+DevListCMD.target+"\" id=\""+DevListCMD.tid+"\" msg_no=\""+DevListCMD.msgno+"\"/>\r\n";
  5712. strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
  5713. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  5714. for (int i = 0; i < devlist.length; i++) {
  5715. if (devlist[i].equals("cooktop")) {
  5716. if (mWallPadAPI.GetGasKind() == 1) {
  5717. // 가스밸브
  5718. int Gasinfo = devSet.Get_GAS_Info();
  5719. if (Gasinfo == 1) {
  5720. // 사용함
  5721. if (bGasAsCooktopOutlet) {
  5722. strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  5723. strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
  5724. }
  5725. else {
  5726. strResult +=" <devinfo name=\"gas\" value=\"1\"/>\r\n";
  5727. strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  5728. }
  5729. }
  5730. else {
  5731. // 사용안함
  5732. strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  5733. strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  5734. }
  5735. }
  5736. else if (mWallPadAPI.GetGasKind() == 2) {
  5737. // 하이브리드 쿡탑
  5738. if (mCooktopAPI != null) {
  5739. int nGas = 0; int nOutlet = 0;
  5740. for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
  5741. for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
  5742. if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
  5743. else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
  5744. }
  5745. }
  5746. strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\"/>\r\n";
  5747. strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\"/>\r\n";
  5748. }
  5749. }
  5750. else {
  5751. strResult +=" <devinfo name=\"gas\" value=\"0\"/>\r\n";
  5752. strResult +=" <devinfo name=\"cooktop\" value=\"0\"/>\r\n";
  5753. }
  5754. }
  5755. else if (devlist[i].equals("doorlock")) {
  5756. try {
  5757. int[] DoorLockInfo = devSet.Get_DoorLock_Info();
  5758. if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
  5759. strResult +=" <devinfo name=\"doorlock\" value=\"1\"/>\r\n";
  5760. }
  5761. else {
  5762. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  5763. }
  5764. } catch (RuntimeException re) {
  5765. LogUtil.errorLogInfo("", TAG, re);
  5766. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  5767. }
  5768. catch (Exception e) {
  5769. //e.printStackTrace();
  5770. LogUtil.errorLogInfo("", TAG, e);
  5771. strResult +=" <devinfo name=\"doorlock\" value=\"0\"/>\r\n";
  5772. }
  5773. }
  5774. else if (devlist[i].equals("light")) {
  5775. try {
  5776. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5777. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5778. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5779. if (bSmartLightAsNormalLight) {
  5780. if (mSdbAPI != null) {
  5781. strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\"/>\r\n";
  5782. }
  5783. else {
  5784. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  5785. }
  5786. }
  5787. else {
  5788. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5789. }
  5790. }
  5791. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5792. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5793. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5794. strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\"/>\r\n";
  5795. }
  5796. else {
  5797. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  5798. }
  5799. }
  5800. else {
  5801. int[] lightinfo = devSet.Get_Light_info();
  5802. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5803. strResult += " <devinfo name=\"light\" value=\"0\"/>\r\n";
  5804. }
  5805. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
  5806. strResult += " <devinfo name=\"light\" value=\"1\"/>\r\n";
  5807. }
  5808. else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_NORMAL)) {
  5809. strResult += " <devinfo name=\"light\" value=\"1\"/>\r\n";
  5810. }
  5811. else {
  5812. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5813. int ret = multisw.Refresh((byte)0xFF, false);
  5814. if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  5815. else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\"/>\r\n";
  5816. }
  5817. }
  5818. } catch (RuntimeException re) {
  5819. LogUtil.errorLogInfo("", TAG, re);
  5820. strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  5821. }
  5822. catch (Exception e) {
  5823. //e.printStackTrace();
  5824. LogUtil.errorLogInfo("", TAG, e);
  5825. strResult +=" <devinfo name=\"light\" value=\"0\"/>\r\n";
  5826. }
  5827. }
  5828. else if (devlist[i].equals("livinglight")) {
  5829. try {
  5830. int[] lightinfo = devSet.Get_Light_info();
  5831. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5832. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5833. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5834. if (bSmartLightAsNormalLight) {
  5835. if (mSdb_LivingRoomLightAPI != null) {
  5836. strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\"/>\r\n";
  5837. }
  5838. else {
  5839. strResult += " <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5840. }
  5841. }
  5842. else {
  5843. Log.w(TAG, "[iCMDProcDevList] Not supported!!");
  5844. }
  5845. }
  5846. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 ) {
  5847. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\"/>\r\n";
  5848. }
  5849. else {
  5850. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  5851. strResult += " <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5852. }
  5853. else {
  5854. strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\"/>\r\n";
  5855. }
  5856. }
  5857. } catch (RuntimeException re) {
  5858. LogUtil.errorLogInfo("", TAG, re);
  5859. strResult +=" <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5860. }
  5861. catch (Exception e) {
  5862. //e.printStackTrace();
  5863. LogUtil.errorLogInfo("", TAG, e);
  5864. strResult +=" <devinfo name=\"livinglight\" value=\"0\"/>\r\n";
  5865. }
  5866. }
  5867. else if (devlist[i].equals("ventil")) {
  5868. try {
  5869. int[] Ventilinfo = devSet.Get_Ventil_Info();
  5870. if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  5871. else strResult +=" <devinfo name=\"ventil\" value=\"1\"/>\r\n";
  5872. } catch (RuntimeException re) {
  5873. LogUtil.errorLogInfo("", TAG, re);
  5874. strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  5875. }
  5876. catch (Exception e) {
  5877. //e.printStackTrace();
  5878. LogUtil.errorLogInfo("", TAG, e);
  5879. strResult +=" <devinfo name=\"ventil\" value=\"0\"/>\r\n";
  5880. }
  5881. }
  5882. else if (devlist[i].equals("thermostat")) {
  5883. try {
  5884. int Temperinfo = devSet.Get_Temper_Info();
  5885. int HeatingKind = mWallPadAPI.GetHeatingKind();
  5886. HeatingV1API heatingV1API = null;
  5887. HeatingV2API heatingV2API = null;
  5888. byte RoomCount = 0;
  5889. // 종류별 API를 로딩한다.
  5890. if (HeatingKind == 1) {
  5891. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  5892. if (heatingV1API != null) {
  5893. RoomCount = heatingV1API.data.Device.RoomCount;
  5894. }
  5895. }
  5896. else if (HeatingKind == 2) {
  5897. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  5898. if (heatingV2API != null) {
  5899. RoomCount = heatingV2API.data.Device.info.RoomCount;
  5900. }
  5901. }
  5902. if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  5903. else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\"/>\r\n";
  5904. } catch (RuntimeException re) {
  5905. LogUtil.errorLogInfo("", TAG, re);
  5906. strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  5907. }
  5908. catch (Exception e) {
  5909. //e.printStackTrace();
  5910. LogUtil.errorLogInfo("", TAG, e);
  5911. strResult += " <devinfo name=\"thermostat\" value=\"0\"/>\r\n";
  5912. }
  5913. }
  5914. else if (devlist[i].equals("curtain")) {
  5915. try {
  5916. int[] Curtaininfo = devSet.Get_CURTAIN_Info();
  5917. if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  5918. else strResult += " <devinfo name=\"curtain\" value=\"1\"/>\r\n";
  5919. } catch (RuntimeException re) {
  5920. LogUtil.errorLogInfo("", TAG, re);
  5921. strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  5922. }
  5923. catch (Exception e) {
  5924. //e.printStackTrace();
  5925. LogUtil.errorLogInfo("", TAG, e);
  5926. strResult += " <devinfo name=\"curtain\" value=\"0\"/>\r\n";
  5927. }
  5928. }
  5929. else if (devlist[i].equals("electric")) {
  5930. try {
  5931. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  5932. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  5933. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  5934. int nOutlet = 0;
  5935. if (mSdb_LivingRoomLightAPI != null) {
  5936. if (mSdbAPI != null) {
  5937. nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
  5938. }
  5939. else {
  5940. nOutlet = 1;
  5941. }
  5942. }
  5943. else {
  5944. if (mSdbAPI != null) {
  5945. nOutlet = mSdbAPI.data.BadRoom_Em_Count;
  5946. }
  5947. else {
  5948. nOutlet = 0;
  5949. }
  5950. }
  5951. strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\"/>\r\n";
  5952. }
  5953. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  5954. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  5955. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
  5956. strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\"/>\r\n";
  5957. }
  5958. else {
  5959. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5960. }
  5961. }
  5962. else {
  5963. int[] lightinfo = devSet.Get_Light_info();
  5964. if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
  5965. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5966. }
  5967. else {
  5968. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  5969. int ret = multisw.Refresh((byte)0xFF, false);
  5970. if (ret< 0 || multisw.data.DeviceCnt < 1) {
  5971. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5972. }
  5973. else {
  5974. int DeviceCount = 0;
  5975. for (int j = 0; j < multisw.data.DeviceCnt; j++) {
  5976. if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
  5977. DeviceCount++;
  5978. }
  5979. }
  5980. strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\"/>\r\n";
  5981. }
  5982. }
  5983. }
  5984. } catch (RuntimeException re) {
  5985. LogUtil.errorLogInfo("", TAG, re);
  5986. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5987. }
  5988. catch (Exception e) {
  5989. //e.printStackTrace();
  5990. LogUtil.errorLogInfo("", TAG, e);
  5991. strResult += " <devinfo name=\"electric\" value=\"0\"/>\r\n";
  5992. }
  5993. }
  5994. else if (devlist[i].equals("smartlight")) {
  5995. if (!bSmartLightAsNormalLight) {
  5996. int nSmartLight = 0;
  5997. if (mSdb_LivingRoomLightAPI != null) {
  5998. if (mSdbAPI != null) {
  5999. nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
  6000. }
  6001. else {
  6002. nSmartLight = 1;
  6003. }
  6004. }
  6005. else {
  6006. if (mSdbAPI != null) {
  6007. nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
  6008. }
  6009. else {
  6010. nSmartLight = 0;
  6011. }
  6012. }
  6013. strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\"/>\r\n";
  6014. }
  6015. }
  6016. }
  6017. strResult += " </service>\r\n</imap>\r\n";
  6018. devSet.closeDB();
  6019. return strResult;
  6020. } catch (RuntimeException re) {
  6021. LogUtil.errorLogInfo("", TAG, re);
  6022. return null;
  6023. }
  6024. catch (Exception e) {
  6025. Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
  6026. //e.printStackTrace();
  6027. LogUtil.errorLogInfo("", TAG, e);
  6028. return null;
  6029. }
  6030. }
  6031. public String iCMDProcMultiSWControl(Document ele) {
  6032. try {
  6033. String retStr = CheckiCMDProc(MULTISW_CTR);
  6034. if (retStr != null) return retStr;
  6035. else retStr = XMLHeader + " <service type=\"reply\" name=\""+MULTISW_CTR+"\"";
  6036. WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
  6037. MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
  6038. if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
  6039. int devNum = Integer.parseInt(multiswcmd.devnum);
  6040. if(multisw!=null)
  6041. {
  6042. int ret = multisw.Refresh((byte)0xFF, false);
  6043. String result;
  6044. if (ret==APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
  6045. else result = "fail";
  6046. retStr+=(" result=\""+result+"\" >\r\n");
  6047. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  6048. retStr += MakeTargetStr(multiswcmd);
  6049. retStr += " <action>\"status\"</action>\r\n";
  6050. retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum-1].device.hOutletCnt + "\"/>\r\n";
  6051. if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6052. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6053. 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";
  6054. }
  6055. else {
  6056. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.hOutletCnt +"\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
  6057. }
  6058. }
  6059. else {
  6060. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+ multisw.data.Device[devNum-1].device.hOutletCnt +"\"/>\r\n";
  6061. }
  6062. String unitStr;
  6063. for (int i = 0;i < multisw.data.Device[devNum-1].device.hOutletCnt;i++) {
  6064. Log.e(TAG, multisw.data.Device[devNum-1].device.ToDebugString((byte) i));
  6065. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  6066. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  6067. unitStr = (multisw.data.Device[devNum-1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
  6068. unitStr += (multisw.data.Device[devNum-1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
  6069. retStr += " <status_info unit_num=\"switch"+(i+1)+"\" unit_status=\""+unitStr+"\" />\r\n";
  6070. }
  6071. }
  6072. retStr+=" </service>\r\n</imap>\r\n";
  6073. }
  6074. }
  6075. else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
  6076. int devNum = Integer.parseInt(multiswcmd.devnum);
  6077. int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
  6078. {
  6079. if(multisw!=null)
  6080. {
  6081. multisw.Refresh((byte)0xFF, false);
  6082. String result;
  6083. int ret = -1;
  6084. if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
  6085. ret = multisw.SetConcentMode((byte)(devNum-1), (byte)(swNum-1), true);
  6086. }
  6087. else if(multiswcmd.ctraction.equalsIgnoreCase("unset")) {
  6088. ret = multisw.SetConcentMode((byte)(devNum-1), (byte)(swNum-1), false);
  6089. }
  6090. else if(multiswcmd.ctraction.equalsIgnoreCase("on")) {
  6091. ret = multisw.SetConcentOnOff((byte)(devNum-1), (byte)(swNum-1), true);
  6092. }
  6093. else if(multiswcmd.ctraction.equalsIgnoreCase("off")) {
  6094. ret = multisw.SetConcentOnOff((byte)(devNum-1), (byte)(swNum-1), false);
  6095. }
  6096. if (ret==APIErrorCode.C_SUCCESS) result = "ok";
  6097. else result = "fail";
  6098. if (ret == APIErrorCode.C_SUCCESS) {
  6099. ret = multisw.Refresh((byte)0xFF, false);
  6100. if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
  6101. retStr+=(" result=\""+result+"\" > \r\n");
  6102. retStr += MakeTargetStr(multiswcmd);
  6103. retStr += " <action>\"control\"</action>\r\n";
  6104. retStr += " <status_map dev_num=\""+multiswcmd.devnum+"\" unit_cnt=\""+multisw.data.Device[devNum-1].device.hOutletCnt+"\"/>\r\n";
  6105. String unitStr;
  6106. for (int i = 0; i < multisw.data.Device[devNum-1].device.hOutletCnt; i++) {
  6107. //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
  6108. //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
  6109. unitStr = (multisw.data.Device[devNum-1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto)?"set/":"unset/";
  6110. unitStr += (multisw.data.Device[devNum-1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off)?"off":"on";
  6111. retStr += " <status_info unit_num=\"switch"+(i + 1)+"\" unit_status=\"" + unitStr + "\" />\r\n";
  6112. }
  6113. }
  6114. else {
  6115. retStr+=(" result=\"fail\"> \r\n");
  6116. }
  6117. }
  6118. else {
  6119. retStr+=(" result=\"fail\"> \r\n");
  6120. }
  6121. retStr+=" </service>\r\n</imap>\r\n";
  6122. }
  6123. }
  6124. }
  6125. return retStr;
  6126. } catch (RuntimeException re) {
  6127. LogUtil.errorLogInfo("", TAG, re);
  6128. return null;
  6129. }
  6130. catch (Exception e) {
  6131. Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
  6132. //e.printStackTrace();
  6133. LogUtil.errorLogInfo("", TAG, e);
  6134. return null;
  6135. }
  6136. }
  6137. public String iCMDProcSDPConcentControl(Document ele) {
  6138. try {
  6139. WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
  6140. String retStr = CheckiCMDProc("remote_access_electric");
  6141. if (retStr != null) return retStr;
  6142. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
  6143. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6144. if (NewServerUse()) {
  6145. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
  6146. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6147. }
  6148. if (mSdbAPI == null) {
  6149. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6150. Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
  6151. return retStr;
  6152. }
  6153. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6154. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6155. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6156. return retStr;
  6157. }
  6158. int nTotalLightCnt = 0;
  6159. if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
  6160. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  6161. }
  6162. else {
  6163. nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
  6164. }
  6165. Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  6166. int nDevNo = 0;
  6167. try {
  6168. nDevNo = Integer.parseInt(concentcmd.devnum);
  6169. } catch (RuntimeException re) {
  6170. LogUtil.errorLogInfo("", TAG, re);
  6171. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6172. return retStr;
  6173. }
  6174. catch (Exception e) {
  6175. Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
  6176. //e.printStackTrace();
  6177. LogUtil.errorLogInfo("", TAG, e);
  6178. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6179. return retStr;
  6180. }
  6181. if (nDevNo < 1 && 12 < nDevNo) {
  6182. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6183. Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
  6184. return retStr;
  6185. }
  6186. String strAction = trimquotation(concentcmd.actionTXT);
  6187. String unit_status = "null", status_mode = "unset", status_onoff = "off";
  6188. String dev_num = "null",unit_num = "null", ctrl_action = "null";
  6189. int nRet_Mode = -99, nRet_OnOff = -99;
  6190. boolean Set = false, OnOff = false; // 제어요청 상태
  6191. boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
  6192. if (strAction.equalsIgnoreCase("status")) {
  6193. retStr += " result=\"ok\">\r\n";
  6194. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6195. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6196. if (nDevNo == 1) {
  6197. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6198. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount +"\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
  6199. }
  6200. else {
  6201. retStr += " <status_map dev_num=\""+concentcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount +"\"/>\r\n";
  6202. }
  6203. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6204. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  6205. else status_mode = "set";
  6206. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  6207. else status_onoff = "off";
  6208. unit_status = status_mode + "/" + status_onoff;
  6209. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6210. }
  6211. // retStr += " </status_map>\r\n";
  6212. retStr += " </service>\r\n</imap>\r\n";
  6213. }
  6214. else if (nDevNo > 1) {
  6215. if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6216. 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";
  6217. }
  6218. else {
  6219. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6220. }
  6221. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6222. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  6223. else status_mode = "set";
  6224. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) 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. }
  6232. }
  6233. else if (strAction.equalsIgnoreCase("control")) {
  6234. NodeList items = ele.getElementsByTagName("params");
  6235. Node item = items.item(0);
  6236. if (item != null) {
  6237. NamedNodeMap attrs = item.getAttributes();
  6238. for (int i = 0; i< attrs.getLength(); i++) {
  6239. Node attr = attrs.item(i);
  6240. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  6241. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  6242. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) ctrl_action = attr.getNodeValue();
  6243. }
  6244. }
  6245. else {
  6246. Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
  6247. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6248. return retStr;
  6249. }
  6250. try {
  6251. nDevNo = Integer.parseInt(dev_num);
  6252. } catch (RuntimeException re) {
  6253. LogUtil.errorLogInfo("", TAG, re);
  6254. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6255. return retStr;
  6256. }
  6257. catch (Exception e) {
  6258. Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
  6259. //e.printStackTrace();
  6260. LogUtil.errorLogInfo("", TAG, e);
  6261. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6262. return retStr;
  6263. }
  6264. if (nDevNo < 1 && 12 < nDevNo) {
  6265. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6266. return retStr;
  6267. }
  6268. int nUnitNo = 0;
  6269. if (!unit_num.equalsIgnoreCase("all")) {
  6270. try {
  6271. nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
  6272. } catch (RuntimeException re) {
  6273. LogUtil.errorLogInfo("", TAG, re);
  6274. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6275. return retStr;
  6276. }
  6277. catch (Exception e) {
  6278. Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
  6279. //e.printStackTrace();
  6280. LogUtil.errorLogInfo("", TAG, e);
  6281. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6282. return retStr;
  6283. }
  6284. }
  6285. if (ctrl_action.contains("/")) {
  6286. String[] strParsed = ctrl_action.split("/");
  6287. if (strParsed[0].equals("set")) {
  6288. Set = true;
  6289. bCtrl_Set = true;
  6290. }
  6291. else if (strParsed[0].equals("unset")) {
  6292. Set = false;
  6293. bCtrl_Set = true;
  6294. }
  6295. if (strParsed[1].equals("on")) {
  6296. OnOff = true;
  6297. bCtrl_OnOff = true;
  6298. }
  6299. else if (strParsed[1].equals("off")) {
  6300. OnOff = false;
  6301. bCtrl_OnOff = true;
  6302. }
  6303. }
  6304. else {
  6305. if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
  6306. if (ctrl_action.equalsIgnoreCase("set")) {
  6307. Set = true;
  6308. bCtrl_Set = true;
  6309. }
  6310. else if (ctrl_action.equalsIgnoreCase("unset")) {
  6311. Set = false;
  6312. bCtrl_Set = true;
  6313. }
  6314. }
  6315. if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
  6316. if (ctrl_action.equalsIgnoreCase("on")) {
  6317. OnOff = true;
  6318. bCtrl_OnOff = true;
  6319. }
  6320. else if (ctrl_action.equalsIgnoreCase("off")) {
  6321. OnOff = false;
  6322. bCtrl_OnOff = true;
  6323. }
  6324. }
  6325. }
  6326. Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
  6327. if (nDevNo == 1) {
  6328. if (unit_num.equalsIgnoreCase("all")) {
  6329. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6330. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
  6331. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
  6332. Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6333. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6334. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6335. return retStr;
  6336. }
  6337. }
  6338. }
  6339. else {
  6340. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
  6341. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
  6342. Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6343. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6344. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6345. return retStr;
  6346. }
  6347. }
  6348. }
  6349. else {
  6350. if (unit_num.equalsIgnoreCase("all")) {
  6351. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6352. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
  6353. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
  6354. Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6355. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6356. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6357. return retStr;
  6358. }
  6359. }
  6360. }
  6361. else {
  6362. if (bCtrl_Set) nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
  6363. if (bCtrl_OnOff) nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
  6364. Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) +"], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
  6365. if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
  6366. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6367. return retStr;
  6368. }
  6369. }
  6370. }
  6371. if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
  6372. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  6373. Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
  6374. return retStr;
  6375. }
  6376. retStr += " result=\"ok\">\r\n";
  6377. retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
  6378. retStr += " <action>\"" + strAction + "\"</action>\r\n";
  6379. if (nDevNo == 1) {
  6380. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
  6381. for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
  6382. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  6383. else status_mode = "set";
  6384. if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  6385. else status_onoff = "off";
  6386. unit_status = status_mode + "/" + status_onoff;
  6387. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6388. }
  6389. // retStr += " </status_map>\r\n";
  6390. retStr += " </service>\r\n</imap>\r\n";
  6391. }
  6392. else if (nDevNo > 1) {
  6393. retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
  6394. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
  6395. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always) status_mode = "unset";
  6396. else status_mode = "set";
  6397. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On) status_onoff = "on";
  6398. else status_onoff = "off";
  6399. unit_status = status_mode + "/" + status_onoff;
  6400. retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
  6401. }
  6402. // retStr += " </status_map>\r\n";
  6403. retStr += " </service>\r\n</imap>\r\n";
  6404. }
  6405. }
  6406. else {
  6407. Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
  6408. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  6409. }
  6410. return retStr;
  6411. } catch (RuntimeException re) {
  6412. LogUtil.errorLogInfo("", TAG, re);
  6413. return null;
  6414. }
  6415. catch (Exception e) {
  6416. Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
  6417. //e.printStackTrace();
  6418. LogUtil.errorLogInfo("", TAG, e);
  6419. return null;
  6420. }
  6421. }
  6422. public String iCMDProcEnergyMeterConcentControl(Document ele) {
  6423. try {
  6424. String retStr = CheckiCMDProc(MULTISW_CTR);
  6425. if (retStr != null) return retStr;
  6426. else retStr = XMLHeader + " <service type=\"reply\" name=\""+MULTISW_CTR+"\" ";
  6427. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6428. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6429. if(energymetercmd == null) return null;
  6430. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6431. if(energymeter == null )return null;
  6432. int devNum = Integer.parseInt(energymetercmd.devnum)-1;
  6433. int ret = energymeter.Refresh((byte)0xFF, false);
  6434. String result;
  6435. if (ret==APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
  6436. else result = "fail";
  6437. retStr+=(" result=\""+result+"\" >\r\n");
  6438. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6439. retStr += MakeTargetStr(energymetercmd);
  6440. retStr += " <action>\"status\"</action>\r\n";
  6441. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6442. String unitStr;
  6443. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6444. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6445. if (i == 2) {
  6446. unitStr += "on";
  6447. }
  6448. else {
  6449. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6450. }
  6451. retStr += " <status_info unit_num=\"switch"+(i + 1)+"\" unit_status=\"" + unitStr + "\"/>\r\n";
  6452. }
  6453. }
  6454. retStr+=" </service>\r\n</imap>\r\n";
  6455. }
  6456. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6457. int devNum = Integer.parseInt(energymetercmd.devnum)-1;
  6458. int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) -1;
  6459. byte cmd = 0;
  6460. int ret = 0;
  6461. String result;
  6462. if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
  6463. else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
  6464. else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
  6465. else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
  6466. if (cmd>0) {
  6467. if(energymeter!=null)
  6468. {
  6469. energymeter.Refresh((byte)0xFF, false);
  6470. if (cmd == 1) {
  6471. ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
  6472. }
  6473. else if (cmd == 2) {
  6474. ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
  6475. }
  6476. else if (cmd == 3) {
  6477. ret = energymeter.SetConcentOnOff((byte) devNum, (byte)swNum, true);
  6478. }
  6479. else if (cmd == 4) {
  6480. ret = energymeter.SetConcentOnOff((byte) devNum, (byte)swNum, false);
  6481. }
  6482. if (ret==APIErrorCode.C_SUCCESS) result = "ok";
  6483. else result = "fail";
  6484. retStr+=(" result=\""+result+"\" >\r\n");
  6485. if (ret == APIErrorCode.C_SUCCESS) {
  6486. ret = energymeter.Refresh((byte)0xFF, false);
  6487. if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
  6488. retStr += MakeTargetStr(energymetercmd);
  6489. retStr += " <action>\"control\"</action>\r\n";
  6490. retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
  6491. String unitStr;
  6492. for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
  6493. unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
  6494. if (i == 2) {
  6495. unitStr += "on";
  6496. }
  6497. else {
  6498. unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
  6499. }
  6500. retStr += " <status_info unit_num=\"switch"+(i+1)+"\" unit_status=\""+unitStr+"\"/>\r\n";
  6501. }
  6502. }
  6503. else {
  6504. retStr+=(" result=\"fail\"> \r\n");
  6505. }
  6506. }
  6507. else {
  6508. retStr+=(" result=\"fail\"> \r\n");
  6509. }
  6510. retStr+=" </service>\r\n</imap>\r\n";
  6511. }
  6512. }
  6513. }
  6514. return retStr;
  6515. } catch (RuntimeException re) {
  6516. LogUtil.errorLogInfo("", TAG, re);
  6517. return null;
  6518. }
  6519. catch (Exception e) {
  6520. Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
  6521. //e.printStackTrace();
  6522. LogUtil.errorLogInfo("", TAG, e);
  6523. return null;
  6524. }
  6525. }
  6526. public String iCMDProcModeControl(Document doc) {
  6527. try {
  6528. String status = "unknown";
  6529. boolean SendBR = false;
  6530. String retStr = CheckiCMDProc("remote_access_mode");
  6531. if (retStr != null) return retStr;
  6532. else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
  6533. String target= "null", tid= "null", msgno= "null";
  6534. NodeList items = doc.getElementsByTagName("target");
  6535. Node item = items.item(0);
  6536. if (item != null) {
  6537. NamedNodeMap attrs = item.getAttributes();
  6538. for (int j = 0; j< attrs.getLength(); j++) {
  6539. Node attr = attrs.item(j);
  6540. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6541. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6542. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6543. }
  6544. }
  6545. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6546. if (NewServerUse()) {
  6547. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
  6548. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6549. }
  6550. WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
  6551. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  6552. int curState = SetData.GetAlarmStatus();
  6553. Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
  6554. if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
  6555. if (accmode.ctraction.equalsIgnoreCase("normal")) {
  6556. switch (curState) {
  6557. case WallpadStatusData.GUARD_IN:
  6558. SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
  6559. Intent intent = new Intent();
  6560. intent.setAction(define.NOTIFY_ACNAME);
  6561. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6562. intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
  6563. getApplicationContext().sendBroadcast(intent);
  6564. Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
  6565. SendBR = true;
  6566. break;
  6567. case WallpadStatusData.GUARD_OUT:
  6568. break;
  6569. }
  6570. }
  6571. else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
  6572. switch (curState) {
  6573. case WallpadStatusData.ALARM_NONE:
  6574. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6575. if (mIGW200.checkSensorforInmode()) {
  6576. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6577. Intent intent = new Intent();
  6578. intent.setAction(define.NOTIFY_ACNAME);
  6579. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6580. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6581. getApplicationContext().sendBroadcast(intent);
  6582. SendBR = true;
  6583. }
  6584. else {
  6585. SendBR = false;
  6586. }
  6587. }
  6588. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  6589. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6590. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6591. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6592. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6593. if (mIGW300.checkSensorforInmode()) {
  6594. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6595. Intent intent = new Intent();
  6596. intent.setAction(define.NOTIFY_ACNAME);
  6597. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6598. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6599. getApplicationContext().sendBroadcast(intent);
  6600. SendBR = true;
  6601. }
  6602. else {
  6603. SendBR = false;
  6604. }
  6605. }
  6606. else {
  6607. if (checkSensorforInmode()) {
  6608. SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
  6609. Intent intent = new Intent();
  6610. intent.setAction(define.NOTIFY_ACNAME);
  6611. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6612. intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
  6613. getApplicationContext().sendBroadcast(intent);
  6614. Sound().PlayMent(SND.mode.INMODE_SETTING);
  6615. SendBR = true;
  6616. }
  6617. else {
  6618. SendBR = false;
  6619. }
  6620. }
  6621. break;
  6622. default:
  6623. break;
  6624. }
  6625. }
  6626. else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
  6627. if (GetUseIlgalControlForAdmin() == false) {
  6628. // 관리자용 일괄소등 원격제어 사용안할 시
  6629. switch (curState) {
  6630. case WallpadStatusData.ALARM_NONE:
  6631. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
  6632. if (mIGW200.checkSensorforOutmode()) {
  6633. Common.SendAppFinishReqBR(getApplicationContext());
  6634. Intent intent = new Intent();
  6635. intent.setAction(define.NOTIFY_ACNAME);
  6636. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6637. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6638. getApplicationContext().sendBroadcast(intent);
  6639. SendBR = true;
  6640. }
  6641. else {
  6642. SendBR = false;
  6643. }
  6644. }
  6645. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  6646. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  6647. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  6648. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  6649. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  6650. if (mIGW300.checkSensorforOutmode()) {
  6651. Common.SendAppFinishReqBR(getApplicationContext());
  6652. Intent intent = new Intent();
  6653. intent.setAction(define.NOTIFY_ACNAME);
  6654. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6655. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6656. getApplicationContext().sendBroadcast(intent);
  6657. SendBR = true;
  6658. }
  6659. else {
  6660. SendBR = false;
  6661. }
  6662. }
  6663. else {
  6664. if (checkSensorforOutmode()) {
  6665. Common.SendAppFinishReqBR(getApplicationContext());
  6666. Intent intent = new Intent();
  6667. intent.setAction(define.NOTIFY_ACNAME);
  6668. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
  6669. intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
  6670. getApplicationContext().sendBroadcast(intent);
  6671. Sound().PlayMent(SND.mode.OUTMODE_SETTING);
  6672. SendBR = true;
  6673. }
  6674. else {
  6675. SendBR = false;
  6676. }
  6677. }
  6678. break;
  6679. default:
  6680. break;
  6681. }
  6682. }
  6683. else {
  6684. // 관리자용 일괄소등 원격제어 사용 시
  6685. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  6686. SendBR = true;
  6687. }
  6688. }
  6689. }
  6690. else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
  6691. int getStatus = SetData.GetAlarmStatus();
  6692. switch (getStatus) {
  6693. case WallpadStatusData.GUARD_IN:
  6694. status = "occupied";
  6695. break;
  6696. case WallpadStatusData.GUARD_OUT:
  6697. status = "unoccupied";
  6698. break;
  6699. case WallpadStatusData.ALARM_NONE:
  6700. status = "normal";
  6701. break;
  6702. case WallpadStatusData.ALARM_ARISE:
  6703. status = "emergency";
  6704. break;
  6705. default:
  6706. break;
  6707. }
  6708. retStr+=("\"ok\">\r\n ");
  6709. retStr+=" <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
  6710. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6711. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
  6712. retStr += " <status_info unit_num=\"null\" unit_status=\""+status+"\" />\r\n </service>\r\n</imap>\r\n";
  6713. return retStr;
  6714. }
  6715. if (!SendBR) {
  6716. retStr += "\"fail\">\r\n </service>\r\n</imap>";
  6717. SetData.closeDB();
  6718. return retStr;
  6719. }
  6720. else {
  6721. try { Thread.sleep(1000); }
  6722. catch (RuntimeException re) {
  6723. LogUtil.errorLogInfo("", TAG, re);
  6724. }
  6725. catch (Exception e){
  6726. LogUtil.errorLogInfo("", TAG, e);
  6727. }
  6728. int getStatus = SetData.GetAlarmStatus();
  6729. switch (getStatus) {
  6730. case WallpadStatusData.GUARD_IN:
  6731. status = "occupied";
  6732. break;
  6733. case WallpadStatusData.GUARD_OUT:
  6734. status = "unoccupied";
  6735. break;
  6736. case WallpadStatusData.ALARM_NONE:
  6737. status = "normal";
  6738. break;
  6739. case WallpadStatusData.ALARM_ARISE:
  6740. status = "emergency";
  6741. break;
  6742. }
  6743. }
  6744. retStr+="\"ok\">\r\n";
  6745. retStr+=" <target name=\"" + accmode.target+"\" id=\""+accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
  6746. retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
  6747. retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
  6748. retStr += " <status_info unit_num=\"null\" unit_status=\""+status+"\" />\r\n </service>\r\n</imap>\r\n";
  6749. SetData.closeDB();
  6750. return retStr;
  6751. } catch (RuntimeException re) {
  6752. LogUtil.errorLogInfo("", TAG, re);
  6753. return null;
  6754. }
  6755. catch (Exception e) {
  6756. Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
  6757. //e.printStackTrace();
  6758. LogUtil.errorLogInfo("", TAG, e);
  6759. return null;
  6760. }
  6761. }
  6762. public String iCMDProcCurtainControl(Document ele) {
  6763. return " ";
  6764. }
  6765. public String iCMDProcSDPLightControl(Document ele) {
  6766. try {
  6767. String retStr = CheckiCMDProc("remote_access_light");
  6768. if (retStr != null) return retStr;
  6769. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6770. String target= "null", tid= "null", msgno= "null";
  6771. NodeList items = ele.getElementsByTagName("target");
  6772. Node item = items.item(0);
  6773. if (item != null) {
  6774. NamedNodeMap attrs = item.getAttributes();
  6775. for (int j = 0; j< attrs.getLength(); j++) {
  6776. Node attr = attrs.item(j);
  6777. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6778. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6779. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6780. }
  6781. }
  6782. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6783. if (NewServerUse()) {
  6784. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6785. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6786. }
  6787. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6788. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6789. if(energymetercmd==null) return null;
  6790. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6791. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6792. if(energymeter == null) return null;
  6793. if (energymeter!=null && (energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6794. retStr += "result=\"ok\">\r\n" +
  6795. " <action>\"status\"</action>\r\n" +
  6796. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6797. for (int i=0 ; i< energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6798. 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");
  6799. }
  6800. retStr+="\r\n</service>\r\n</imap>";
  6801. }
  6802. else {
  6803. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6804. }
  6805. }
  6806. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6807. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6808. num--;
  6809. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6810. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6811. if(energymeter == null) return null;
  6812. if (energymeter!=null && energymeter.SetLightOnOff( (byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6813. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6814. retStr += "result=\"ok\">\r\n" +
  6815. " <action>\"control\"</action>\r\n" +
  6816. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6817. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6818. 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");
  6819. }
  6820. retStr+="\r\n</service>\r\n</imap>";
  6821. }
  6822. else {
  6823. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6824. }
  6825. }
  6826. else {
  6827. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6828. }
  6829. }
  6830. else {
  6831. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6832. }
  6833. energymetercmd = null;
  6834. return retStr;
  6835. } catch (RuntimeException re) {
  6836. LogUtil.errorLogInfo("", TAG, re);
  6837. return null;
  6838. }
  6839. catch (Exception e) {
  6840. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6841. //e.printStackTrace();
  6842. LogUtil.errorLogInfo("", TAG, e);
  6843. return null;
  6844. }
  6845. }
  6846. public String iCMDProcEnergyMeterLightControl(Document ele) {
  6847. try {
  6848. String retStr = CheckiCMDProc("remote_access_light");
  6849. if (retStr != null) return retStr;
  6850. else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
  6851. String target= "null", tid= "null", msgno= "null";
  6852. NodeList items = ele.getElementsByTagName("target");
  6853. Node item = items.item(0);
  6854. if (item != null) {
  6855. NamedNodeMap attrs = item.getAttributes();
  6856. for (int j = 0; j< attrs.getLength(); j++) {
  6857. Node attr = attrs.item(j);
  6858. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6859. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6860. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6861. }
  6862. }
  6863. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6864. if (NewServerUse()) {
  6865. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6866. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6867. }
  6868. WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
  6869. EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
  6870. if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
  6871. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6872. if (energymeter!=null&& (energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6873. retStr += "result=\"ok\">\r\n" +
  6874. " <action>\"status\"</action>\r\n" +
  6875. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6876. for (int i=0 ; i< energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6877. 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");
  6878. }
  6879. retStr+="\r\n</service>\r\n</imap>";
  6880. }
  6881. else {
  6882. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6883. }
  6884. }
  6885. else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
  6886. int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
  6887. num--;
  6888. int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
  6889. if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
  6890. if (energymeter!=null && energymeter.SetLightOnOff( (byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
  6891. if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
  6892. retStr += "result=\"ok\">\r\n" +
  6893. " <action>\"control\"</action>\r\n" +
  6894. " <status_map dev_num=\""+energymetercmd.devnum+"\" unit_cnt=\""+energymeter.data.Em.eachRoom[deviceNum].LightCnt+"\"/>\r\n";
  6895. for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
  6896. 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");
  6897. }
  6898. retStr+="\r\n</service>\r\n</imap>";
  6899. }
  6900. else {
  6901. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6902. }
  6903. }
  6904. else {
  6905. retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
  6906. }
  6907. }
  6908. else {
  6909. retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
  6910. }
  6911. energymetercmd = null;
  6912. return retStr;
  6913. } catch (RuntimeException re) {
  6914. LogUtil.errorLogInfo("", TAG, re);
  6915. return null;
  6916. }
  6917. catch (Exception e) {
  6918. Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
  6919. //e.printStackTrace();
  6920. LogUtil.errorLogInfo("", TAG, e);
  6921. return null;
  6922. }
  6923. }
  6924. public String iCMDProcLightControl(Document ele) {
  6925. try {
  6926. String retStr = CheckiCMDProc("remote_access_light");
  6927. if (retStr != null) return retStr;
  6928. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
  6929. String target= "null", tid= "null", msgno= "null";
  6930. NodeList items = ele.getElementsByTagName("target");
  6931. Node item = items.item(0);
  6932. if (item != null) {
  6933. NamedNodeMap attrs = item.getAttributes();
  6934. for (int j = 0; j< attrs.getLength(); j++) {
  6935. Node attr = attrs.item(j);
  6936. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  6937. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  6938. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  6939. }
  6940. }
  6941. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  6942. if (NewServerUse()) {
  6943. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  6944. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  6945. }
  6946. WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
  6947. MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
  6948. if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
  6949. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  6950. if (bSmartLightAsNormalLight) {
  6951. if (mSdbAPI != null) {
  6952. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  6953. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  6954. if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
  6955. retStr += "result=\"ok\">\r\n" +
  6956. " <action>\"status\"</action>\r\n";
  6957. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6958. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount +"\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
  6959. }
  6960. else {
  6961. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount +"\"/>\r\n";
  6962. }
  6963. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  6964. 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");
  6965. }
  6966. retStr+=" </service>\r\n</imap>";
  6967. }
  6968. else {
  6969. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6970. }
  6971. }
  6972. else {
  6973. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  6974. }
  6975. }
  6976. else {
  6977. if (mMultiSwitchAPI != null) {
  6978. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  6979. if (nResult == 0) {
  6980. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  6981. retStr += "result=\"ok\">\r\n" +
  6982. " <action>\"status\"</action>\r\n";
  6983. if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  6984. if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
  6985. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt +"\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
  6986. }
  6987. else {
  6988. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt +"\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
  6989. }
  6990. }
  6991. else {
  6992. retStr += " <status_map dev_num=\""+MSlightcmd.devnum+"\" unit_cnt=\""+ mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt +"\"/>\r\n";
  6993. }
  6994. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  6995. 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");
  6996. }
  6997. retStr+=" </service>\r\n</imap>";
  6998. }
  6999. else {
  7000. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  7001. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7002. }
  7003. }
  7004. else {
  7005. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7006. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7007. }
  7008. }
  7009. else {
  7010. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
  7011. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7012. }
  7013. }
  7014. }
  7015. else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
  7016. int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
  7017. boolean OnOff = false;
  7018. if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  7019. if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
  7020. if (bSmartLightAsNormalLight) {
  7021. if (mSdbAPI != null) {
  7022. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  7023. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
  7024. if (ret >= 0) {
  7025. retStr += "result=\"ok\">\r\n" +
  7026. " <action>\"status\"</action>\r\n" +
  7027. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  7028. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  7029. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  7030. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  7031. 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");
  7032. }
  7033. retStr += " </service>\r\n</imap>";
  7034. }
  7035. else {
  7036. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7037. }
  7038. }
  7039. else {
  7040. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  7041. int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
  7042. if (ret >= 0) {
  7043. retStr += "result=\"ok\">\r\n" +
  7044. " <action>\"status\"</action>\r\n" +
  7045. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
  7046. int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
  7047. Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
  7048. for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
  7049. Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
  7050. 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");
  7051. }
  7052. retStr += " </service>\r\n</imap>";
  7053. }
  7054. else {
  7055. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7056. }
  7057. }
  7058. }
  7059. else {
  7060. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7061. }
  7062. }
  7063. else {
  7064. if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
  7065. if(mMultiSwitchAPI!=null)
  7066. {
  7067. int nResultRefresh = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  7068. if (nResultRefresh == 0) {
  7069. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  7070. if (nCtrlResult == 0) {
  7071. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  7072. if (nResult == 0) {
  7073. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  7074. retStr += "result=\"ok\">\r\n" +
  7075. " <action>\"status\"</action>\r\n" +
  7076. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  7077. for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
  7078. 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");
  7079. }
  7080. retStr += " </service>\r\n</imap>";
  7081. }
  7082. else {
  7083. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  7084. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7085. }
  7086. }
  7087. else {
  7088. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7089. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7090. }
  7091. }
  7092. else {
  7093. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  7094. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7095. }
  7096. }
  7097. else {
  7098. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7099. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7100. }
  7101. }
  7102. }
  7103. else {
  7104. int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
  7105. if(mMultiSwitchAPI!=null)
  7106. {
  7107. int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
  7108. if (nCtrlResult == 0) {
  7109. int nResult = mMultiSwitchAPI.Refresh((byte)0xFF, false);
  7110. if (nResult == 0) {
  7111. if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
  7112. retStr += "result=\"ok\">\r\n" +
  7113. " <action>\"status\"</action>\r\n" +
  7114. " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
  7115. for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
  7116. 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");
  7117. }
  7118. retStr += " </service>\r\n</imap>";
  7119. }
  7120. else {
  7121. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
  7122. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7123. }
  7124. }
  7125. else {
  7126. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
  7127. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7128. }
  7129. }
  7130. else {
  7131. Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
  7132. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7133. }
  7134. }
  7135. }
  7136. }
  7137. }
  7138. else {
  7139. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  7140. }
  7141. }
  7142. else {
  7143. retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
  7144. }
  7145. MSlightcmd = null;
  7146. return retStr;
  7147. } catch (RuntimeException re) {
  7148. LogUtil.errorLogInfo("", TAG, re);
  7149. return null;
  7150. }
  7151. catch (Exception e) {
  7152. Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
  7153. //e.printStackTrace();
  7154. LogUtil.errorLogInfo("", TAG, e);
  7155. return null;
  7156. }
  7157. }
  7158. public String iCMDProcSDPSmartLightControl(Document ele) {
  7159. try {
  7160. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7161. String retStr = CheckiCMDProc("remote_access_smartlight");
  7162. if (retStr != null) return retStr;
  7163. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
  7164. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7165. if (NewServerUse()) {
  7166. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
  7167. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7168. }
  7169. if (mSdb_LivingRoomLightAPI == null) {
  7170. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7171. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
  7172. return retStr;
  7173. }
  7174. if (mSdbAPI == null) {
  7175. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7176. Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
  7177. return retStr;
  7178. }
  7179. if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
  7180. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7181. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
  7182. return retStr;
  7183. }
  7184. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  7185. if (mSdbAPI.Refresh((byte)0x00, (byte)i) != 0) {
  7186. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7187. Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
  7188. return retStr;
  7189. }
  7190. }
  7191. int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
  7192. Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  7193. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7194. if (lightcmd.devnum.equalsIgnoreCase("all")) {
  7195. retStr += " result=\"ok\">\r\n";
  7196. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7197. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7198. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7199. for (int i = 0; i < nTotalLightCnt; i++) {
  7200. if (i == 0) {
  7201. 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";
  7202. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7203. String status_power = "off", status_dim = "null", status_color = "null";
  7204. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7205. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7206. }
  7207. else {
  7208. status_power = "null";
  7209. }
  7210. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7211. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7212. }
  7213. else {
  7214. status_dim = "null";
  7215. }
  7216. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7217. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7218. }
  7219. else {
  7220. status_color = "null";
  7221. }
  7222. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7223. }
  7224. retStr += " </status_map>\r\n";
  7225. }
  7226. else {
  7227. 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";
  7228. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7229. String status_power = "off", status_dim = "null", status_color = "null";
  7230. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7231. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7232. }
  7233. else {
  7234. status_power = "null";
  7235. }
  7236. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7237. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7238. }
  7239. else {
  7240. status_dim = "null";
  7241. }
  7242. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7243. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7244. }
  7245. else {
  7246. status_color = "null";
  7247. }
  7248. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7249. }
  7250. retStr += " </status_map>\r\n";
  7251. }
  7252. }
  7253. retStr += " </service>\r\n</imap>\r\n";
  7254. }
  7255. else {
  7256. int nDevNo = 0;
  7257. try {
  7258. nDevNo = Integer.parseInt(lightcmd.devnum);
  7259. } catch (RuntimeException re) {
  7260. LogUtil.errorLogInfo("", TAG, re);
  7261. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7262. return retStr;
  7263. }
  7264. catch (Exception e) {
  7265. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
  7266. //e.printStackTrace();
  7267. LogUtil.errorLogInfo("", TAG, e);
  7268. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7269. return retStr;
  7270. }
  7271. if ((nDevNo - 1) > nTotalLightCnt) {
  7272. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  7273. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7274. return retStr;
  7275. }
  7276. retStr += " result=\"ok\">\r\n";
  7277. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7278. retStr += " <action>\"status\"</action>\r\n";
  7279. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7280. if (nDevNo == 1) {
  7281. 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";
  7282. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7283. String status_power = "off", status_dim = "null", status_color = "null";
  7284. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7285. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7286. }
  7287. else {
  7288. status_power = "null";
  7289. }
  7290. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7291. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7292. }
  7293. else {
  7294. status_dim = "null";
  7295. }
  7296. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7297. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7298. }
  7299. else {
  7300. status_color = "null";
  7301. }
  7302. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7303. }
  7304. retStr += " </status_map>\r\n";
  7305. }
  7306. else {
  7307. 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";
  7308. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7309. String status_power = "off", status_dim = "null", status_color = "null";
  7310. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7311. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7312. }
  7313. else {
  7314. status_power = "null";
  7315. }
  7316. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7317. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7318. }
  7319. else {
  7320. status_dim = "null";
  7321. }
  7322. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7323. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7324. }
  7325. else {
  7326. status_color = "null";
  7327. }
  7328. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7329. }
  7330. retStr += " </status_map>\r\n";
  7331. }
  7332. retStr += " </service>\r\n</imap>\r\n";
  7333. }
  7334. }
  7335. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7336. int nResult = 0;
  7337. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7338. NodeList items = ele.getElementsByTagName("params");
  7339. Node item = items.item(0);
  7340. if (item != null) {
  7341. NamedNodeMap attrs = item.getAttributes();
  7342. for (int j = 0; j< attrs.getLength(); j++) {
  7343. Node attr = attrs.item(j);
  7344. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7345. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7346. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7347. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7348. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7349. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7350. }
  7351. }
  7352. if (dev_num.equalsIgnoreCase("all")) {
  7353. retStr += " result=\"ok\">\r\n";
  7354. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7355. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7356. retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
  7357. for (int i = 0; i < nTotalLightCnt; i++) {
  7358. if (i == 0) {
  7359. mSdb_LivingRoomLightAPI.SetLight2((byte) 0xFF, convertSmartLightPowerValue(unit_status),
  7360. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7361. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7362. }
  7363. else {
  7364. mSdbAPI.SetLight2((byte) (i - 1), (byte) 0xFF, convertSmartLightPowerValue(unit_status),
  7365. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7366. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7367. }
  7368. }
  7369. mSdb_LivingRoomLightAPI.Refresh();
  7370. mSdbAPI.Refresh((byte) 0xFF, (byte) 0xFF);
  7371. for (int i = 0; i < nTotalLightCnt; i++) {
  7372. if (i == 0) {
  7373. 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";
  7374. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7375. String status_power = "off", status_dim = "null", status_color = "null";
  7376. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7377. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7378. }
  7379. else {
  7380. status_power = "null";
  7381. }
  7382. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7383. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7384. }
  7385. else {
  7386. status_dim = "null";
  7387. }
  7388. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7389. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7390. }
  7391. else {
  7392. status_color = "null";
  7393. }
  7394. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7395. }
  7396. retStr += " </status_map>\r\n";
  7397. }
  7398. else {
  7399. 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";
  7400. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
  7401. String status_power = "off", status_dim = "null", status_color = "null";
  7402. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
  7403. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7404. }
  7405. else {
  7406. status_power = "null";
  7407. }
  7408. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
  7409. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
  7410. }
  7411. else {
  7412. status_dim = "null";
  7413. }
  7414. if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
  7415. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
  7416. }
  7417. else {
  7418. status_color = "null";
  7419. }
  7420. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7421. }
  7422. retStr += " </status_map>\r\n";
  7423. }
  7424. }
  7425. retStr += " </service>\r\n</imap>\r\n";
  7426. }
  7427. else {
  7428. int nDevNo = 0;
  7429. int nUnitNo = 0;
  7430. try {
  7431. nDevNo = Integer.parseInt(dev_num);
  7432. } catch (RuntimeException re) {
  7433. LogUtil.errorLogInfo("", TAG, re);
  7434. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7435. return retStr;
  7436. }
  7437. catch (Exception e) {
  7438. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7439. //e.printStackTrace();
  7440. LogUtil.errorLogInfo("", TAG, e);
  7441. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7442. return retStr;
  7443. }
  7444. if ((nDevNo - 1) > nTotalLightCnt) {
  7445. Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt +"]");
  7446. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7447. return retStr;
  7448. }
  7449. retStr += " result=\"ok\">\r\n";
  7450. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7451. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7452. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7453. if (unit_num.equalsIgnoreCase("all")) {
  7454. if (nDevNo == 1) {
  7455. mSdb_LivingRoomLightAPI.SetLight2((byte) 0xFF, convertSmartLightPowerValue(unit_status),
  7456. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7457. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7458. }
  7459. else {
  7460. mSdbAPI.SetLight2((byte) (nDevNo -2), (byte) 0xFF, convertSmartLightPowerValue(unit_status),
  7461. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7462. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7463. }
  7464. }
  7465. else {
  7466. try {
  7467. nUnitNo = Integer.parseInt(unit_num);
  7468. } catch (RuntimeException re) {
  7469. LogUtil.errorLogInfo("", TAG, re);
  7470. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7471. return retStr;
  7472. }
  7473. catch (Exception e) {
  7474. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7475. //e.printStackTrace();
  7476. LogUtil.errorLogInfo("", TAG, e);
  7477. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7478. return retStr;
  7479. }
  7480. if (nDevNo == 1) {
  7481. mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7482. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7483. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7484. }
  7485. else {
  7486. mSdbAPI.SetLight2((byte) (nDevNo -2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
  7487. unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
  7488. unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
  7489. }
  7490. }
  7491. if (nDevNo == 1) {
  7492. mSdb_LivingRoomLightAPI.Refresh();
  7493. 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";
  7494. for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
  7495. String status_power = "off", status_dim = "null", status_color = "null";
  7496. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
  7497. status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7498. }
  7499. else {
  7500. status_power = "null";
  7501. }
  7502. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
  7503. status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
  7504. }
  7505. else {
  7506. status_dim = "null";
  7507. }
  7508. if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
  7509. status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
  7510. }
  7511. else {
  7512. status_color = "null";
  7513. }
  7514. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7515. }
  7516. retStr += " </status_map>\r\n";
  7517. }
  7518. else {
  7519. mSdbAPI.Refresh((byte) 0xFF, (byte) 0xFF);
  7520. 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";
  7521. for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
  7522. String status_power = "off", status_dim = "null", status_color = "null";
  7523. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
  7524. status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
  7525. }
  7526. else {
  7527. status_power = "null";
  7528. }
  7529. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
  7530. status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
  7531. }
  7532. else {
  7533. status_dim = "null";
  7534. }
  7535. if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
  7536. status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
  7537. }
  7538. else {
  7539. status_color = "null";
  7540. }
  7541. retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
  7542. }
  7543. retStr += " </status_map>\r\n";
  7544. }
  7545. retStr += " </service>\r\n</imap>\r\n";
  7546. }
  7547. }
  7548. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
  7549. int nResult = 0;
  7550. String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
  7551. NodeList items = ele.getElementsByTagName("params");
  7552. Node item = items.item(0);
  7553. if (item != null) {
  7554. NamedNodeMap attrs = item.getAttributes();
  7555. for (int j = 0; j< attrs.getLength(); j++) {
  7556. Node attr = attrs.item(j);
  7557. if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
  7558. else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
  7559. else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
  7560. else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
  7561. else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
  7562. else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
  7563. }
  7564. }
  7565. if (dev_num.equalsIgnoreCase("all")) {
  7566. retStr += " result=\"ok\">\r\n";
  7567. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7568. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7569. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7570. if (!dev_mode.equals("null")) mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7571. 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";
  7572. // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
  7573. retStr += " </service>\r\n</imap>\r\n";
  7574. }
  7575. else {
  7576. int nDevNo = 0;
  7577. try {
  7578. nDevNo = Integer.parseInt(dev_num);
  7579. } catch (RuntimeException re) {
  7580. LogUtil.errorLogInfo("", TAG, re);
  7581. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7582. return retStr;
  7583. }
  7584. catch (Exception e) {
  7585. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
  7586. //e.printStackTrace();
  7587. LogUtil.errorLogInfo("", TAG, e);
  7588. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7589. return retStr;
  7590. }
  7591. if (nDevNo != 1) {
  7592. Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
  7593. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7594. return retStr;
  7595. }
  7596. retStr += " result=\"ok\">\r\n";
  7597. retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
  7598. retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
  7599. retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
  7600. if (!dev_mode.equals("null")) mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
  7601. 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";
  7602. retStr += " </service>\r\n</imap>\r\n";
  7603. }
  7604. }
  7605. else {
  7606. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7607. }
  7608. lightcmd = null;
  7609. return retStr;
  7610. } catch (RuntimeException re) {
  7611. LogUtil.errorLogInfo("", TAG, re);
  7612. return null;
  7613. }
  7614. catch (Exception e) {
  7615. Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
  7616. //e.printStackTrace();
  7617. LogUtil.errorLogInfo("", TAG, e);
  7618. return null;
  7619. }
  7620. }
  7621. public String iCMDProcLivingLightControl(Document ele) {
  7622. try {
  7623. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7624. String retStr = CheckiCMDProc("remote_access_livinglight");
  7625. if (retStr != null) return retStr;
  7626. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
  7627. String target= "null", tid= "null", msgno= "null";
  7628. NodeList items = ele.getElementsByTagName("target");
  7629. Node item = items.item(0);
  7630. if (item != null) {
  7631. NamedNodeMap attrs = item.getAttributes();
  7632. for (int j = 0; j< attrs.getLength(); j++) {
  7633. Node attr = attrs.item(j);
  7634. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7635. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7636. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7637. }
  7638. }
  7639. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7640. if (NewServerUse()) {
  7641. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7642. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7643. }
  7644. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7645. if (bSmartLightAsNormalLight) {
  7646. if (mSdb_LivingRoomLightAPI != null) {
  7647. mSdb_LivingRoomLightAPI.Refresh();
  7648. 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";
  7649. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7650. 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");
  7651. }
  7652. retStr+=" </service>\r\n</imap>\r\n";
  7653. }
  7654. else {
  7655. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7656. }
  7657. }
  7658. else {
  7659. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  7660. if (lightCTR!=null)
  7661. {
  7662. if (lightCTR.Refresh(false)==0) {
  7663. retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+ lightcmd.devnum +"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7664. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7665. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7666. }
  7667. retStr+=" </service>\r\n</imap>\r\n";
  7668. }
  7669. else {
  7670. retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
  7671. }
  7672. }
  7673. }
  7674. }
  7675. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7676. if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
  7677. boolean OnOff = false;
  7678. if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
  7679. if (bSmartLightAsNormalLight) {
  7680. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  7681. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
  7682. if (ret >= 0) {
  7683. ret = mSdb_LivingRoomLightAPI.Refresh();
  7684. if (ret >= 0) {
  7685. 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";
  7686. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7687. 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");
  7688. }
  7689. retStr += " </service>\r\n</imap>\r\n";
  7690. } else {
  7691. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7692. }
  7693. }
  7694. else {
  7695. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7696. }
  7697. }
  7698. else {
  7699. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  7700. int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
  7701. if (ret >= 0) {
  7702. ret = mSdb_LivingRoomLightAPI.Refresh();
  7703. if (ret >= 0) {
  7704. 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";
  7705. for (int i = 0 ; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
  7706. 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");
  7707. }
  7708. retStr += " </service>\r\n</imap>\r\n";
  7709. } else {
  7710. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7711. }
  7712. }
  7713. else {
  7714. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7715. }
  7716. }
  7717. }
  7718. else {
  7719. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  7720. if(lightCTR!=null)
  7721. {
  7722. if (lightcmd.unitnum.equalsIgnoreCase("all")) {
  7723. int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
  7724. if (ret >= 0) {
  7725. ret = lightCTR.Refresh(false);
  7726. if (ret >= 0) {
  7727. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  7728. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  7729. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7730. }
  7731. retStr += " </service>\r\n</imap>\r\n";
  7732. }
  7733. else {
  7734. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7735. }
  7736. }
  7737. else {
  7738. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7739. }
  7740. }
  7741. else {
  7742. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  7743. int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
  7744. if (ret >= 0) {
  7745. ret = lightCTR.Refresh(false);
  7746. if (ret >= 0) {
  7747. retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
  7748. for (int i = 0; i < lightCTR.data.LightCount; i++) {
  7749. retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
  7750. }
  7751. retStr += " </service>\r\n</imap>\r\n";
  7752. }
  7753. else {
  7754. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7755. }
  7756. }
  7757. else {
  7758. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7759. }
  7760. }
  7761. }
  7762. }
  7763. }
  7764. else {
  7765. retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
  7766. }
  7767. }
  7768. else {
  7769. retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
  7770. }
  7771. lightcmd = null;
  7772. return retStr;
  7773. } catch (RuntimeException re) {
  7774. LogUtil.errorLogInfo("", TAG, re);
  7775. return null;
  7776. }
  7777. catch (Exception e) {
  7778. Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
  7779. //e.printStackTrace();
  7780. LogUtil.errorLogInfo("", TAG, e);
  7781. return null;
  7782. }
  7783. }
  7784. public String iCMDProc_I_LightControl(Document ele) {
  7785. try {
  7786. WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
  7787. String retStr = CheckiCMDProc("remote_access_livinglight");
  7788. if (retStr != null) return retStr;
  7789. else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
  7790. String target= "null", tid= "null", msgno= "null";
  7791. NodeList items = ele.getElementsByTagName("target");
  7792. Node item = items.item(0);
  7793. if (item != null) {
  7794. NamedNodeMap attrs = item.getAttributes();
  7795. for (int j = 0; j< attrs.getLength(); j++) {
  7796. Node attr = attrs.item(j);
  7797. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7798. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7799. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7800. }
  7801. }
  7802. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7803. if (NewServerUse()) {
  7804. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  7805. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7806. }
  7807. IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
  7808. if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
  7809. if (lightCTR!=null && lightCTR.Refresh(false)==0) {
  7810. retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7811. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7812. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7813. }
  7814. retStr+=" </service>\r\n</imap>\r\n";
  7815. }
  7816. else {
  7817. retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
  7818. }
  7819. }
  7820. else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
  7821. if((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
  7822. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
  7823. int result = -999;
  7824. if(lightCTR!=null)
  7825. {
  7826. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  7827. result = lightCTR.LightProgramControl((byte)num, (byte)1);
  7828. }
  7829. else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  7830. result = lightCTR.LightProgramControl((byte)num, (byte)0);
  7831. }
  7832. if (result >= 0) {
  7833. // 제어 성공
  7834. try { Thread.sleep(1000);}
  7835. catch (RuntimeException re) {
  7836. LogUtil.errorLogInfo("", TAG, re);
  7837. }
  7838. catch (Exception e) {
  7839. LogUtil.errorLogInfo("", TAG, e);
  7840. }
  7841. lightCTR.Refresh(false);
  7842. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7843. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7844. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7845. }
  7846. retStr+=" </service>\r\n</imap>";
  7847. }
  7848. else {
  7849. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7850. }
  7851. }
  7852. else {
  7853. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7854. }
  7855. }
  7856. else if(lightcmd.unitnum.toLowerCase().equals("all") == true)
  7857. {
  7858. int result = -999;
  7859. if(lightCTR!=null)
  7860. {
  7861. if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
  7862. result = lightCTR.LightControl((byte)0xFF, true);
  7863. }
  7864. else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
  7865. result = lightCTR.LightControl((byte)0xFF, false);
  7866. }
  7867. if (result >= 0) {
  7868. // 제어 성공
  7869. try { Thread.sleep(1000);}
  7870. catch (RuntimeException re) {
  7871. LogUtil.errorLogInfo("", TAG, re);
  7872. }
  7873. catch (Exception e) {
  7874. LogUtil.errorLogInfo("", TAG, e);
  7875. }
  7876. lightCTR.Refresh(false);
  7877. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7878. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7879. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7880. }
  7881. retStr+=" </service>\r\n</imap>";
  7882. }
  7883. else {
  7884. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7885. }
  7886. }
  7887. }
  7888. else {
  7889. int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
  7890. if (!lightcmd.ctraction.equalsIgnoreCase("null"))
  7891. if (lightCTR!=null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on")?true:false)==0) {
  7892. try { Thread.sleep(1000);}
  7893. catch (RuntimeException re) {
  7894. LogUtil.errorLogInfo("", TAG, re);
  7895. }
  7896. catch (Exception e) {
  7897. LogUtil.errorLogInfo("", TAG, e);
  7898. }
  7899. lightCTR.Refresh(false);
  7900. retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\""+lightcmd.devnum+"\" unit_cnt=\""+lightCTR.data.LightCount+"\"/>\r\n";
  7901. for(int i=0 ; i< lightCTR.data.LightCount; i++) {
  7902. retStr+= " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i+1, lightCTR.data.LightStatus[i]==true?"on":"off");
  7903. }
  7904. retStr+=" </service>\r\n</imap>\r\n";
  7905. }
  7906. else {
  7907. retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
  7908. }
  7909. }
  7910. }
  7911. else {
  7912. retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
  7913. }
  7914. lightcmd = null;
  7915. return retStr;
  7916. } catch (RuntimeException re) {
  7917. LogUtil.errorLogInfo("", TAG, re);
  7918. return null;
  7919. }
  7920. catch (Exception e) {
  7921. Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
  7922. //e.printStackTrace();
  7923. LogUtil.errorLogInfo("", TAG, e);
  7924. return null;
  7925. }
  7926. }
  7927. public String iCMDProcGASControl(Element ele) {
  7928. try {
  7929. String target= "null", tid= "null", msgno= "null", devnum = "null", ctraction = "null", valvestatus = "null";
  7930. String strResult = CheckiCMDProc("remote_access_gas");
  7931. if (strResult != null) return strResult;
  7932. else strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
  7933. NodeList items = ele.getElementsByTagName("target");
  7934. Node item = items.item(0);
  7935. if (item != null) {
  7936. NamedNodeMap attrs = item.getAttributes();
  7937. for (int j = 0; j< attrs.getLength(); j++) {
  7938. Node attr = attrs.item(j);
  7939. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  7940. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  7941. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  7942. }
  7943. }
  7944. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  7945. if (NewServerUse()) {
  7946. String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
  7947. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  7948. }
  7949. NodeList itemsParam = ele.getElementsByTagName("params");
  7950. Node itemParam = itemsParam.item(0);
  7951. if (itemParam != null) {
  7952. NamedNodeMap attrsParam = itemParam.getAttributes();
  7953. for (int j = 0; j < attrsParam.getLength(); j++) {
  7954. Node attr = attrsParam.item(j);
  7955. if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
  7956. // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
  7957. //unitnum = attr.getNodeValue();
  7958. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) ctraction = attr.getNodeValue();
  7959. }
  7960. }
  7961. NodeList itemsaction = ele.getElementsByTagName("action");
  7962. Node itemaction = itemsaction.item(0);
  7963. Node text = itemaction.getFirstChild();
  7964. String actionTXT = text.getNodeValue();
  7965. //수정
  7966. strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
  7967. actionTXT = trimquotation(actionTXT);
  7968. GasAPI GasValveCTR = null;
  7969. CooktopAPI HybridCookTopCTR = null;
  7970. if(mWallPadAPI.GetGasKind() == 2)
  7971. {
  7972. //하이브리드
  7973. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  7974. }
  7975. else
  7976. {
  7977. GasValveCTR = mWallPadAPI.Get_GasController();
  7978. }
  7979. if (actionTXT.equalsIgnoreCase("status")) {
  7980. // 가스밸브 상태 조회
  7981. if(mWallPadAPI.GetGasKind() == 2)
  7982. {
  7983. //하이브리드
  7984. if(HybridCookTopCTR!=null)
  7985. {
  7986. //전체 정보가져오기
  7987. int ret = HybridCookTopCTR.Refresh((byte)0xFF, false);
  7988. if (ret < 0) {
  7989. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  7990. return strResult;
  7991. }
  7992. int OnOpenCount = 0;
  7993. int OperationCount = 0;
  7994. for(int RoomIndex=0 ; RoomIndex<HybridCookTopCTR.data.Device[0].circuit.length ; RoomIndex++)
  7995. {
  7996. // 콘센트 ON/OFF 업데이트
  7997. if( HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  7998. if(HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN)
  7999. {
  8000. OnOpenCount++;
  8001. }
  8002. else if(HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING)
  8003. {
  8004. OperationCount++;
  8005. }
  8006. }
  8007. }
  8008. if(OperationCount > 0)
  8009. {
  8010. valvestatus = "ing";
  8011. }
  8012. else if(OnOpenCount > 0)
  8013. {
  8014. valvestatus = "open";
  8015. }
  8016. else
  8017. {
  8018. valvestatus = "close";
  8019. }
  8020. }
  8021. }
  8022. else
  8023. {
  8024. if(GasValveCTR!=null)
  8025. {
  8026. int ret = GasValveCTR.Refresh((byte)0, false);
  8027. if (ret < 0) {
  8028. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8029. return strResult;
  8030. }
  8031. if (GasValveCTR.data.DeviceCnt == 2) {
  8032. GasValveCTR.Refresh((byte)1, false);
  8033. }
  8034. byte GasStatus = GasAPI.GASSTATUS.Close;
  8035. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8036. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8037. GasStatus = GasAPI.GASSTATUS.Operation;
  8038. break;
  8039. }
  8040. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8041. GasStatus = GasAPI.GASSTATUS.Open;
  8042. break;
  8043. }
  8044. }
  8045. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8046. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8047. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8048. else valvestatus = "unknown";
  8049. }
  8050. }
  8051. }
  8052. else if (actionTXT.equalsIgnoreCase("control")) {
  8053. // 가스밸브 콘트롤
  8054. if(mWallPadAPI.GetGasKind() == 2)
  8055. {
  8056. //하이브리드
  8057. if(HybridCookTopCTR!=null)
  8058. {
  8059. int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
  8060. if (ret < 0) {
  8061. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8062. return strResult;
  8063. }
  8064. ret = HybridCookTopCTR.Refresh((byte)0xFF, false);
  8065. if (ret < 0) {
  8066. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8067. return strResult;
  8068. }
  8069. int OnOpenCount = 0;
  8070. int OperationCount = 0;
  8071. for(int RoomIndex=0 ; RoomIndex<HybridCookTopCTR.data.Device[0].circuit.length ; RoomIndex++)
  8072. {
  8073. // 콘센트 ON/OFF 업데이트
  8074. if( HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
  8075. if(HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN)
  8076. {
  8077. OnOpenCount++;
  8078. }
  8079. else if(HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING)
  8080. {
  8081. OperationCount++;
  8082. }
  8083. }
  8084. }
  8085. if(OperationCount > 0)
  8086. {
  8087. valvestatus = "ing";
  8088. }
  8089. else if(OnOpenCount > 0)
  8090. {
  8091. valvestatus = "open";
  8092. }
  8093. else
  8094. {
  8095. valvestatus = "close";
  8096. }
  8097. }
  8098. }
  8099. else
  8100. {
  8101. if(GasValveCTR!=null)
  8102. {
  8103. int ret = GasValveCTR.SetClose((byte)0xFF);
  8104. if (ret < 0) {
  8105. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8106. return strResult;
  8107. }
  8108. ret = GasValveCTR.Refresh((byte)0, false);
  8109. if (ret < 0) {
  8110. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8111. return strResult;
  8112. }
  8113. if (GasValveCTR.data.DeviceCnt == 2) {
  8114. GasValveCTR.Refresh((byte)1, false);
  8115. }
  8116. byte GasStatus = GasAPI.GASSTATUS.Close;
  8117. for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
  8118. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
  8119. GasStatus = GasAPI.GASSTATUS.Operation;
  8120. break;
  8121. }
  8122. if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
  8123. GasStatus = GasAPI.GASSTATUS.Open;
  8124. break;
  8125. }
  8126. }
  8127. if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
  8128. else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
  8129. else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
  8130. else valvestatus = "unknown";
  8131. }
  8132. }
  8133. }
  8134. else {
  8135. strResult += "\"fail\">\r\n </service>\r\n</imap>";
  8136. return strResult;
  8137. }
  8138. strResult += "\"ok\" >\r\n";
  8139. strResult += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  8140. strResult += " <action>\""+actionTXT+"\"</action>\r\n";
  8141. strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
  8142. strResult += " <status_info unit_num=\"gas1\" unit_status=\""+valvestatus+"\"/>\r\n";
  8143. strResult += " </service>\r\n";
  8144. strResult += "</imap> ";
  8145. return strResult;
  8146. } catch (RuntimeException re) {
  8147. LogUtil.errorLogInfo("", TAG, re);
  8148. return null;
  8149. }
  8150. catch (Exception e) {
  8151. Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
  8152. //e.printStackTrace();
  8153. LogUtil.errorLogInfo("", TAG, e);
  8154. return null;
  8155. }
  8156. }
  8157. private String iCMDProcLightBatchControl(Element ele) {
  8158. try {
  8159. String target= "null", tid= "null", msgno= "null", ctraction = "null", ilgalstatus = "null";
  8160. String retStr = CheckiCMDProc("remote_access_light_batch_control");
  8161. if (retStr != null) return retStr;
  8162. NodeList items = ele.getElementsByTagName("target");
  8163. Node item = items.item(0);
  8164. if (item != null) {
  8165. NamedNodeMap attrs = item.getAttributes();
  8166. for (int j = 0; j < attrs.getLength(); j++) {
  8167. Node attr = attrs.item(j);
  8168. if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
  8169. else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
  8170. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
  8171. }
  8172. }
  8173. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  8174. if (NewServerUse()) {
  8175. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
  8176. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
  8177. }
  8178. NodeList itemsParam = ele.getElementsByTagName("params");
  8179. Node itemParam = itemsParam.item(0);
  8180. if (itemParam != null) {
  8181. NamedNodeMap attrsParam = itemParam.getAttributes();
  8182. for (int j = 0; j < attrsParam.getLength(); j++) {
  8183. Node attr = attrsParam.item(j);
  8184. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
  8185. ctraction = attr.getNodeValue();
  8186. }
  8187. }
  8188. }
  8189. NodeList itemsaction = ele.getElementsByTagName("action");
  8190. Node itemaction = itemsaction.item(0);
  8191. Node text = itemaction.getFirstChild();
  8192. String actionTXT = text.getNodeValue();
  8193. retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
  8194. actionTXT = trimquotation(actionTXT);
  8195. Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
  8196. if (actionTXT.equalsIgnoreCase("status")) {
  8197. // 일괄소등 상태 조회
  8198. int ret = mWallPadAPI.GetBatchSwitchStatus();
  8199. if (ret > 1) {
  8200. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8201. return retStr;
  8202. }
  8203. if (ret == 0) {
  8204. ilgalstatus = "on";
  8205. }
  8206. else if (ret == 1) {
  8207. ilgalstatus = "off";
  8208. }
  8209. else {
  8210. ilgalstatus = "error";
  8211. }
  8212. }
  8213. else if (actionTXT.equalsIgnoreCase("control")) {
  8214. // 일괄소등 제어
  8215. int ret = -1;
  8216. int status = -1;
  8217. if(ctraction.equals("on") == true) {
  8218. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  8219. status = 0;
  8220. }
  8221. else if(ctraction.equals("off") == true) {
  8222. ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  8223. status = 1;
  8224. }
  8225. if (ret < 0) {
  8226. retStr += " \"fail\" >\r\n </service>\r\n</imap>";
  8227. return retStr;
  8228. }
  8229. if (status == 0) {
  8230. ilgalstatus = "on";
  8231. }
  8232. else if (status == 1) {
  8233. ilgalstatus = "off";
  8234. }
  8235. else {
  8236. ilgalstatus = "error";
  8237. }
  8238. }
  8239. else {
  8240. retStr += "\"fail\" />\r\n </service>\r\n</imap>";
  8241. return retStr;
  8242. }
  8243. retStr += "\"ok\" >\r\n";
  8244. retStr += " <target name=\"" + target +"\" id=\"" + tid + "\" msg_no=\"" + msgno +"\"/>\r\n";
  8245. retStr += " <action>\""+actionTXT+"\"</action>\r\n";
  8246. retStr += " <status_info unit_status=\""+ilgalstatus+"\"/>\r\n </service>\r\n</imap> ";
  8247. return retStr;
  8248. } catch (RuntimeException re) {
  8249. LogUtil.errorLogInfo("", TAG, re);
  8250. return null;
  8251. }
  8252. catch (Exception e) {
  8253. Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
  8254. //e.printStackTrace();
  8255. LogUtil.errorLogInfo("", TAG, e);
  8256. return null;
  8257. }
  8258. }
  8259. private String iCMDProcEntireLightControl(Document ele) {
  8260. try {
  8261. String retStr = CheckiCMDProc("remote_entire_access_light_control");
  8262. if (retStr != null) return retStr;
  8263. else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
  8264. String sDong = null;
  8265. String sHo = null;
  8266. String sDevice_Num = null;
  8267. String sSelCtrl_Action = null;
  8268. String sUnselCtrl_Action = null;
  8269. NodeList items = ele.getElementsByTagName("home_info");
  8270. Node item = items.item(0);
  8271. NamedNodeMap attrsParam = item.getAttributes();
  8272. for (int i = 0; i < attrsParam.getLength(); i++) {
  8273. Node attr = attrsParam.item(i);
  8274. if (attr.getNodeName().equalsIgnoreCase("dong"))
  8275. sDong = trimquotation(attr.getNodeValue());
  8276. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  8277. sHo = trimquotation(attr.getNodeValue());
  8278. }
  8279. WallpadStatusData DBMGR = null;
  8280. DBMGR = new WallpadStatusData(getApplicationContext());
  8281. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  8282. DBMGR.closeDB();
  8283. if (mSdb_LivingRoomLightAPI == null) {
  8284. Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
  8285. retStr += " result=\"fail\" >\r\n";
  8286. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8287. retStr += " </service>\r\n</imap>";
  8288. return retStr;
  8289. }
  8290. if (mSdbAPI == null) {
  8291. Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
  8292. retStr += " result=\"fail\" >\r\n";
  8293. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8294. retStr += " </service>\r\n</imap>";
  8295. return retStr;
  8296. }
  8297. if ((sDong!=null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo!=null && sHo.equalsIgnoreCase(addc.Ho))) {
  8298. items = ele.getElementsByTagName("sel_ctrlinfo");
  8299. item = items.item(0);
  8300. attrsParam = item.getAttributes();
  8301. for (int i = 0; i < attrsParam.getLength(); i++) {
  8302. Node attr = attrsParam.item(i);
  8303. if (attr.getNodeName().equalsIgnoreCase("dev_num"))
  8304. sDevice_Num = trimquotation(attr.getNodeValue());
  8305. else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8306. sSelCtrl_Action = trimquotation(attr.getNodeValue());
  8307. }
  8308. Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
  8309. int result = -1; // 조명 제어 결과
  8310. boolean bLivingLightSel = false; // 거실조명 선택 여부
  8311. // ============================== 선택된 조명 ==============================
  8312. String[] sel_devNum = null;
  8313. if (sDevice_Num!=null && sDevice_Num.contains("light")) {
  8314. if (sDevice_Num.contains("/")) sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
  8315. else {
  8316. sel_devNum = new String[1];
  8317. sel_devNum[0] = sDevice_Num.replaceAll("light", "");
  8318. }
  8319. }
  8320. if (sel_devNum == null) sel_devNum = new String[0];
  8321. for (int i = 0; i < sel_devNum.length; i++) {
  8322. if (sel_devNum[i].equals("1")) {
  8323. bLivingLightSel = true;
  8324. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
  8325. if(sSelCtrl_Action!=null)
  8326. {
  8327. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8328. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8329. } else {
  8330. int nColor = 0;
  8331. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8332. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8333. if (nColor > 0) {
  8334. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8335. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8336. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8337. }
  8338. }
  8339. // 거실조명 제어 결과
  8340. if (result < 0) {
  8341. Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
  8342. retStr += " result=\"fail\" >\r\n";
  8343. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8344. retStr += " </service>\r\n</imap>";
  8345. return retStr;
  8346. }
  8347. }
  8348. } else {
  8349. Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
  8350. if(sSelCtrl_Action!=null)
  8351. {
  8352. if (sSelCtrl_Action.equalsIgnoreCase("off")) {
  8353. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
  8354. } else {
  8355. int nColor = 0;
  8356. if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8357. else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8358. if (nColor > 0) {
  8359. result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
  8360. result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
  8361. result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
  8362. }
  8363. }
  8364. }
  8365. // 그 외 방 조명 제어 결과
  8366. if (result < 0) {
  8367. Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
  8368. retStr += " result=\"fail\" >\r\n";
  8369. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8370. retStr += " </service>\r\n</imap>";
  8371. return retStr;
  8372. }
  8373. }
  8374. }
  8375. // ============================== 선택안된 조명 ==============================
  8376. items = ele.getElementsByTagName("unsel_ctrlinfo");
  8377. item = items.item(0);
  8378. attrsParam = item.getAttributes();
  8379. for (int i = 0; i < attrsParam.getLength(); i++) {
  8380. Node attr = attrsParam.item(i);
  8381. if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
  8382. sUnselCtrl_Action = trimquotation(attr.getNodeValue());
  8383. Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
  8384. }
  8385. if (!bLivingLightSel) {
  8386. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
  8387. if(sUnselCtrl_Action!=null)
  8388. {
  8389. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8390. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
  8391. } else {
  8392. int nColor = 0;
  8393. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8394. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8395. if (nColor > 0) {
  8396. result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
  8397. result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
  8398. result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
  8399. }
  8400. }
  8401. }
  8402. if (result < 0) {
  8403. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
  8404. retStr += " result=\"fail\" >\r\n";
  8405. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8406. retStr += " </service>\r\n</imap>";
  8407. return retStr;
  8408. }
  8409. }
  8410. ArrayList<Integer> unsel_devNum = new ArrayList<>();
  8411. // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
  8412. for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
  8413. unsel_devNum.add(i + 1);
  8414. }
  8415. for (int i = 0; i < unsel_devNum.size(); i++) {
  8416. for (int j = 0; j < sel_devNum.length; j++) {
  8417. if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1) unsel_devNum.remove(i);
  8418. }
  8419. }
  8420. for (int i = 0; i < unsel_devNum.size(); i++) {
  8421. Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) -1) + "]");
  8422. if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
  8423. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
  8424. } else {
  8425. int nColor = 0;
  8426. if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
  8427. else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
  8428. if (nColor > 0) {
  8429. result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
  8430. result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
  8431. result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
  8432. }
  8433. }
  8434. if (result < 0) {
  8435. Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
  8436. retStr += " result=\"fail\" >\r\n";
  8437. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8438. retStr += " </service>\r\n</imap>";
  8439. return retStr;
  8440. }
  8441. }
  8442. Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
  8443. retStr += " result=\"ok\">\r\n";
  8444. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8445. retStr += " </service>\r\n</imap>";
  8446. return retStr;
  8447. } else {
  8448. Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
  8449. retStr += " result=\"fail\" >\r\n";
  8450. retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
  8451. retStr += " </service>\r\n</imap>";
  8452. return retStr;
  8453. }
  8454. } catch (RuntimeException re) {
  8455. LogUtil.errorLogInfo("", TAG, re);
  8456. return null;
  8457. }
  8458. catch (Exception e) {
  8459. Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
  8460. //e.printStackTrace();
  8461. LogUtil.errorLogInfo("", TAG, e);
  8462. return null;
  8463. }
  8464. }
  8465. // 월패드에 원격제어 사용 여부를 확인하다.
  8466. private String CheckiCMDProc(String CMDStr) {
  8467. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  8468. try {
  8469. boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
  8470. mWallpadStatusData.closeDB();
  8471. if (!bRemoteCtrlEnabled) {
  8472. String retXML = XMLHeader +"<service type=\"reply\" name=\""+CMDStr+"\" result=\"deny\">\r\n"+
  8473. " </service>\r\n</imap>";
  8474. return retXML;
  8475. }
  8476. return null;
  8477. } catch (RuntimeException re) {
  8478. LogUtil.errorLogInfo("", TAG, re);
  8479. mWallpadStatusData.closeDB();
  8480. return null;
  8481. }
  8482. catch (Exception e) {
  8483. mWallpadStatusData.closeDB();
  8484. Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
  8485. //e.printStackTrace();
  8486. LogUtil.errorLogInfo("", TAG, e);
  8487. return null;
  8488. }
  8489. }
  8490. //메인으로 공지 해야 할 노티 사항을 처리
  8491. public String ProcEventNotify(Element ele) {
  8492. try {
  8493. NodeList items = ele.getElementsByTagName("event");
  8494. Node item = items.item(0);
  8495. Node text = item.getFirstChild();
  8496. String eventTXT = trimquotation(text.getNodeValue());
  8497. if (eventTXT.equalsIgnoreCase("news_arrival")) {
  8498. // 새로운 공지사항 존재
  8499. wakeupLCD();
  8500. Intent intent = new Intent();
  8501. intent.setAction(define.NOTIFY_ACNAME);
  8502. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  8503. getApplicationContext().sendBroadcast(intent);
  8504. }
  8505. else if (eventTXT.equalsIgnoreCase("box_arrival")) {
  8506. // 택배 도착
  8507. wakeupLCD();
  8508. Intent intent = new Intent();
  8509. intent.setAction(define.NOTIFY_ACNAME);
  8510. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  8511. intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
  8512. intent.putExtra("ITEM",1);
  8513. getApplicationContext().sendBroadcast(intent);
  8514. }
  8515. else if (eventTXT.equalsIgnoreCase("box_delivered")) {
  8516. // 택배 반출
  8517. wakeupLCD();
  8518. Intent intent = new Intent();
  8519. intent.setAction(define.NOTIFY_ACNAME);
  8520. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
  8521. intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
  8522. intent.putExtra("ITEM",0);
  8523. getApplicationContext().sendBroadcast(intent);
  8524. }
  8525. else if (eventTXT.equalsIgnoreCase("car_arrival")) {
  8526. // 등록된 차량 도착
  8527. wakeupLCD();
  8528. // 팝업을 띄우도록 하자
  8529. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  8530. Common.CarInOoutEventBR(getApplicationContext(),"car_in", "");
  8531. }
  8532. else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
  8533. // 내려가는 방향의 엘리베이터가 도착함
  8534. if (ElevatorDown != null) {
  8535. ElevatorDown.TimeOutCancel();
  8536. ElevatorDown.ClearElevator();
  8537. }
  8538. Intent intent = new Intent();
  8539. intent.setAction(define.NOTIFY_ACNAME);
  8540. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
  8541. getApplicationContext().sendBroadcast(intent);
  8542. }
  8543. else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
  8544. // 올라가는 방향의 엘리베이터가 도착함
  8545. if (ElevatorUp != null) {
  8546. ElevatorUp.TimeOutCancel();
  8547. ElevatorUp.ClearElevator();
  8548. }
  8549. Intent intent = new Intent();
  8550. intent.setAction(define.NOTIFY_ACNAME);
  8551. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
  8552. getApplicationContext().sendBroadcast(intent);
  8553. }
  8554. else {
  8555. }
  8556. String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
  8557. "<event> \""+eventTXT+"\" </event>\r\n" + " </service>\r\n </imap> ";
  8558. return returnStr;
  8559. } catch (RuntimeException re) {
  8560. LogUtil.errorLogInfo("", TAG, re);
  8561. return null;
  8562. }
  8563. catch (Exception e) {
  8564. Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
  8565. //e.printStackTrace();
  8566. LogUtil.errorLogInfo("", TAG, e);
  8567. return null;
  8568. }
  8569. }
  8570. public String GetAttributeVal(Node node, String attname) {
  8571. NamedNodeMap attrs = node.getAttributes();
  8572. for (int j = 0; j < attrs.getLength(); j++) {
  8573. Node attr = attrs.item(j);
  8574. if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
  8575. }
  8576. return null;
  8577. }
  8578. public class imageFileFilter implements FilenameFilter {
  8579. public boolean accept(File dir, String name ) {
  8580. if (name.endsWith(".jpg") || name.endsWith(".JPG") || name.endsWith(".jpeg") || name.endsWith(".JPEG")||name.endsWith(".png")||name.endsWith(".PNG")||name.endsWith(".gif")||name.endsWith(".GIF")) return true;
  8581. else return false;
  8582. }
  8583. }
  8584. public String ProcCheckEpiceUpload(Document ele) {
  8585. try {
  8586. String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
  8587. NodeList items = ele.getElementsByTagName("filename");
  8588. Node item = items.item(0);
  8589. Node text = item.getFirstChild();
  8590. String filename = trimquotation(text.getNodeValue());
  8591. Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
  8592. String duplicate = null;
  8593. Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
  8594. File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
  8595. if (!dirInternal.exists()) dirInternal.mkdir();
  8596. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  8597. AddressSet addr = SetData.getAddressMGR();
  8598. if (!dirInternal.exists()) {
  8599. returnStr+=" <homeaddr dong=\""+addr.Dong+"\" ho=\""+addr.Ho+"\"/>\r\n"+
  8600. " <pics space=\""+define.MAX_ALBUM_PICTURE+"\" total=\""+define.MAX_ALBUM_PICTURE+"\" available=\"0\" duplicate=\"new\"/>\r\n"+
  8601. " </service>\r\n</imap>";
  8602. return returnStr;
  8603. }
  8604. imageFileFilter jpegfilter = new imageFileFilter();
  8605. String[] subfile = dirInternal.list(jpegfilter);
  8606. Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
  8607. File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
  8608. if (checkFile.exists()) duplicate = "exist";
  8609. else duplicate = "new";
  8610. if(subfile!=null)
  8611. {
  8612. returnStr+=" <homeaddr dong=\""+addr.Dong+"\" ho=\""+addr.Ho+"\"/>\r\n"+
  8613. " <pics space=\""+define.MAX_ALBUM_PICTURE+"\" total=\""+subfile.length+"\" available=\""+(define.MAX_ALBUM_PICTURE-subfile.length)+"\" duplicate=\""+duplicate+"\"/>\r\n"+
  8614. " </service>\r\n</imap>";
  8615. }
  8616. SetData.closeDB();
  8617. return returnStr;
  8618. } catch (RuntimeException re) {
  8619. LogUtil.errorLogInfo("", TAG, re);
  8620. return null;
  8621. }
  8622. catch (Exception e) {
  8623. Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
  8624. //e.printStackTrace();
  8625. LogUtil.errorLogInfo("", TAG, e);
  8626. return null;
  8627. }
  8628. }
  8629. private void playNotifySound(int nSoundID) {
  8630. try {
  8631. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  8632. Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  8633. if (getCompareBSPVersion()) {
  8634. if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
  8635. }
  8636. else {
  8637. if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  8638. }
  8639. boolean NeedPlay = false;
  8640. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  8641. if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
  8642. NeedPlay = SetData.GetCarSoundOfEventAlarm();
  8643. }
  8644. else {
  8645. NeedPlay = SetData.GetSoundOutputOfEventAlarm();
  8646. }
  8647. SetData.closeDB();
  8648. if (NeedPlay) Sound().PlayMent(nSoundID);
  8649. } catch (RuntimeException re) {
  8650. LogUtil.errorLogInfo("", TAG, re);
  8651. }
  8652. catch (Exception e) {
  8653. Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
  8654. //e.printStackTrace();
  8655. LogUtil.errorLogInfo("", TAG, e);
  8656. }
  8657. }
  8658. private void wakeupLCD() {
  8659. try {
  8660. // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  8661. // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
  8662. // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
  8663. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  8664. int AlarmStatus = WsDB.GetAlarmStatus();
  8665. WsDB.closeDB();
  8666. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  8667. Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
  8668. return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
  8669. } else {
  8670. Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
  8671. mIOInterface.ctrlLcdWakeUp();
  8672. }
  8673. } catch (RuntimeException re) {
  8674. LogUtil.errorLogInfo("", TAG, re);
  8675. }
  8676. catch (Exception e) {
  8677. Log.e(TAG, "[Exception] wakeupLCD()");
  8678. //e.printStackTrace();
  8679. LogUtil.errorLogInfo("", TAG, e);
  8680. }
  8681. }
  8682. /**
  8683. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  8684. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  8685. * Jeff, 2020.09.07
  8686. * @return true: LCD backlight On, false: LCD backlight Off
  8687. */
  8688. public boolean checkLCDOnByCMD() {
  8689. try {
  8690. Runtime mRuntime = Runtime.getRuntime();
  8691. Process mProcess;
  8692. String cmd = "getprop persist.sys.lcdcon";
  8693. mProcess = mRuntime.exec(cmd);
  8694. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  8695. String line;
  8696. String strResult = null;
  8697. while ((line = br.readLine()) != null) {
  8698. strResult = line;
  8699. }
  8700. if(strResult!=null)
  8701. {
  8702. if (strResult.equals("0")) {
  8703. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  8704. return true;
  8705. }
  8706. else if (strResult.equals("1")) {
  8707. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  8708. return false;
  8709. }
  8710. else {
  8711. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  8712. return false;
  8713. }
  8714. }
  8715. else
  8716. return false;
  8717. } catch (RuntimeException re) {
  8718. LogUtil.errorLogInfo("", TAG, re);
  8719. return false;
  8720. }
  8721. catch (Exception e) {
  8722. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  8723. //e.printStackTrace();
  8724. LogUtil.errorLogInfo("", TAG, e);
  8725. return false;
  8726. }
  8727. }
  8728. /**
  8729. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  8730. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  8731. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  8732. */
  8733. public boolean getCompareBSPVersion() {
  8734. try {
  8735. StringBuilder strBSPVersion = new StringBuilder();
  8736. StringBuffer sysInfoBuffer = new StringBuffer();
  8737. sysInfoBuffer.append(Build.DISPLAY);
  8738. strBSPVersion.append(sysInfoBuffer.toString());
  8739. String result = strBSPVersion.toString();
  8740. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  8741. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  8742. Date date = simpleDateFormat.parse(result);
  8743. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  8744. if (date.compareTo(standardDate) >= 0) {
  8745. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  8746. return true;
  8747. }
  8748. } catch (RuntimeException re) {
  8749. LogUtil.errorLogInfo("", TAG, re);
  8750. }
  8751. catch (Exception e) {
  8752. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  8753. //e.printStackTrace();
  8754. LogUtil.errorLogInfo("", TAG, e);
  8755. }
  8756. return false;
  8757. }
  8758. public String ProcUpdateWeather(Document ele) {
  8759. String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
  8760. String nowloc ="";
  8761. String nowlcode="";
  8762. String nowdate="";
  8763. String nowtext="";
  8764. String nowcode="";
  8765. String nowtemp="";
  8766. String nowlo = "", nowhigh = "";
  8767. NodeList items = ele.getElementsByTagName("now");
  8768. Node item = items.item(0);
  8769. if (item == null)
  8770. return resultstr += "\"fail\"/> \r\n </imap>";
  8771. NamedNodeMap attrsParam = item.getAttributes();
  8772. for (int j = 0; j < attrsParam.getLength(); j++) {
  8773. Node attr = attrsParam.item(j);
  8774. if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
  8775. else if (attr.getNodeName().equalsIgnoreCase("loc_code")) nowlcode = attr.getNodeValue();
  8776. else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
  8777. else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
  8778. else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
  8779. else if (attr.getNodeName().equalsIgnoreCase("temperature")) nowtemp = attr.getNodeValue();
  8780. }
  8781. items = ele.getElementsByTagName("week");
  8782. String weekdate="", weektext="", weekcode="", weeklow="", weekhigh="", weekam="", weekpm = "";
  8783. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8784. WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
  8785. Weathertbl.InitWeatherTable();
  8786. for (int i = 0; i < items.getLength(); i++) {
  8787. item = items.item(i);
  8788. attrsParam = item.getAttributes();
  8789. for (int j = 0; j < attrsParam.getLength(); j++) {
  8790. Node attr = attrsParam.item(j);
  8791. if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
  8792. else if (attr.getNodeName().equalsIgnoreCase("text")) weektext = attr.getNodeValue();
  8793. else if (attr.getNodeName().equalsIgnoreCase("code")) weekcode = attr.getNodeValue();
  8794. else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
  8795. else if (attr.getNodeName().equalsIgnoreCase("high")) weekhigh = attr.getNodeValue();
  8796. else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
  8797. else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
  8798. }
  8799. if ( i == 0) {
  8800. nowlo = weeklow;
  8801. nowhigh = weekhigh;
  8802. }
  8803. Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
  8804. }
  8805. //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
  8806. Intent intent = new Intent();
  8807. intent.setAction(define.NOTIFY_ACNAME);
  8808. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
  8809. intent.putExtra(define.NOTIBR_CONTENT, nowcode+define.DEVCTR_DATA_SPLITER+nowlo+define.DEVCTR_DATA_SPLITER+nowhigh);
  8810. getApplicationContext().sendBroadcast(intent);
  8811. String WeatherVer = nowdate.substring(0,4)+"."+nowdate.substring(4,6)+"."+nowdate.substring(6,8)+"."+nowdate.substring(8,10);
  8812. 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);
  8813. DBMGR.closeDB();
  8814. return resultstr += "\"ok\"/> \r\n </imap>";
  8815. }
  8816. //iMAP update_news 처리
  8817. public String ProcUpdateNews(Document ele) {
  8818. NodeList items = ele.getElementsByTagName("ver_news");
  8819. Node item = items.item(0);
  8820. String strNewsVer = item.getTextContent();
  8821. strNewsVer = trimquotation(strNewsVer);
  8822. String retXML = XMLHeader+"<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n"+
  8823. " <ver_news>\""+strNewsVer+"\"</ver_news>\r\n<service/>\r\n</imap>";
  8824. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8825. String NotiVer = DBMGR.GetNoticeVer();
  8826. int noticeCNT = DBMGR.GetNoticeCNT();
  8827. if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
  8828. String[] spdt = strNewsVer.split("[.]");
  8829. noticeCNT+=Integer.parseInt(spdt[spdt.length-1]);
  8830. }
  8831. else {
  8832. String[] spdt = strNewsVer.split("[.]");
  8833. int newcnt = Integer.parseInt(spdt[spdt.length-1]);
  8834. spdt = NotiVer.split("[.]");
  8835. newcnt-=Integer.parseInt(spdt[spdt.length-1]);
  8836. noticeCNT+=newcnt;
  8837. }
  8838. Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer +"], News Version [" + strNewsVer + "]");
  8839. DBMGR.SetNoticeVer(strNewsVer);
  8840. DBMGR.SetNoticeCNT(noticeCNT);
  8841. DBMGR.closeDB();
  8842. if (NotiVer.compareTo(strNewsVer) != 0) {
  8843. Intent intent = new Intent();
  8844. intent.setAction(define.NOTIFY_ACNAME);
  8845. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
  8846. intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
  8847. getApplicationContext().sendBroadcast(intent);
  8848. }
  8849. return retXML;
  8850. }
  8851. //iMAP check_lobby_passwd 처리
  8852. public String CheckPassword(Document doc)
  8853. {
  8854. NodeList items = doc.getElementsByTagName("inpasswd");
  8855. Node item = items.item(0);
  8856. Node text = item.getFirstChild();
  8857. String passwd = trimquotation(text.getNodeValue());
  8858. if(passwd!=null && passwd.length() < 4)
  8859. {
  8860. int temp_length = 4 - passwd.length();
  8861. for(int i = 0 ; i < temp_length; i++)
  8862. passwd = "0"+passwd;
  8863. }
  8864. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  8865. String settedpasswd = DBMGR.GetUserPW();
  8866. DBMGR.closeDB();
  8867. String retString = XMLHeader;
  8868. Common.DebugLog("================ CheckPassword ================ ");
  8869. Common.DebugLog("Saved Password :"+ settedpasswd);
  8870. Common.DebugLog("Input Password :"+ passwd);
  8871. Common.DebugLog("================ CheckPassword ================ ");
  8872. if (settedpasswd.equals(passwd))
  8873. {
  8874. retString+="<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
  8875. }
  8876. else
  8877. {
  8878. retString+="<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>"+passwd+"</wrongpasswd>\r\n</service>";
  8879. }
  8880. retString+="</imap>";
  8881. return retString;
  8882. }
  8883. //schedule_renew 처리
  8884. protected String ProcSchduleRenew(Document doc)
  8885. {
  8886. String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n "+
  8887. "<homeaddr dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" /> \r\n </service> \r\n </imap>";
  8888. WallpadScheduleData schedulDB=null;
  8889. try {
  8890. NodeList items = doc.getElementsByTagName("renew_info");
  8891. schedulDB = new WallpadScheduleData(getApplicationContext());
  8892. for(int i= 0 ;i < items.getLength();i++)
  8893. {
  8894. Node item = items.item(i);
  8895. WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
  8896. NamedNodeMap attrsParam = item.getAttributes();
  8897. String Type="none";
  8898. for(int j=0; j< attrsParam.getLength();j++)
  8899. {
  8900. Node attr = attrsParam.item(j);
  8901. String name = attr.getNodeName();
  8902. String Val = attr.getNodeValue();
  8903. if (attr.getNodeName().equalsIgnoreCase("rn_num"))
  8904. SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
  8905. else if (name.equalsIgnoreCase("rn_type"))
  8906. Type = Val;
  8907. else if (name.equalsIgnoreCase("rn_t_type"))
  8908. SCdata.inqttype = Val;
  8909. else if (name.equalsIgnoreCase("rn_c_type"))
  8910. SCdata.inqctype = Val;
  8911. else if (name.equalsIgnoreCase("rn_a_type"))
  8912. SCdata.inqatype = Val;
  8913. else if (name.equalsIgnoreCase("rn_i_type"))
  8914. SCdata.inqitype = Val;
  8915. else if (name.equalsIgnoreCase("rn_year"))
  8916. SCdata.inqyear = Integer.parseInt(Val);
  8917. else if (name.equalsIgnoreCase("rn_month"))
  8918. SCdata.inqmonth = Integer.parseInt(Val);
  8919. else if (name.equalsIgnoreCase("rn_day"))
  8920. SCdata.inqday = Integer.parseInt(Val);
  8921. else if (name.equalsIgnoreCase("rn_hour"))
  8922. SCdata.inqhour = Integer.parseInt(Val);
  8923. else if (name.equalsIgnoreCase("rn_message"))
  8924. SCdata.inqmsg = Val;
  8925. }
  8926. if (Type.equals("delete"))
  8927. {
  8928. schedulDB.DeleteSchedule(SCdata);
  8929. }
  8930. else if (Type.equals("add"))
  8931. {
  8932. schedulDB.AddSchedule(SCdata);
  8933. }
  8934. else if (Type.equals("change"))
  8935. {
  8936. schedulDB.UpdateSchedule(SCdata);
  8937. }
  8938. }
  8939. schedulDB.closeDB();
  8940. // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
  8941. // Intent intent = new Intent();
  8942. // intent.setAction(define.NOTIFY_ACNAME);
  8943. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  8944. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
  8945. // getApplicationContext().sendBroadcast(intent);
  8946. }
  8947. catch (RuntimeException re) {
  8948. LogUtil.errorLogInfo("", TAG, re);
  8949. if (schedulDB != null) schedulDB.closeDB();
  8950. }
  8951. catch (Exception e)
  8952. {
  8953. //e.printStackTrace();
  8954. LogUtil.errorLogInfo("", TAG, e);
  8955. if (schedulDB != null) schedulDB.closeDB();
  8956. }
  8957. return retXML;
  8958. }
  8959. //schedule_inquiry 처리
  8960. @SuppressWarnings("unused")
  8961. public String ProcSchduleInquiry(Document doc)
  8962. {
  8963. WallpadScheduleData schedulDB=null;
  8964. String retXML;
  8965. int QYear = 0;
  8966. int QMonth = 0;
  8967. try {
  8968. NodeList items = doc.getElementsByTagName("inquiry_time");
  8969. schedulDB = new WallpadScheduleData(getApplicationContext());
  8970. Node item = items.item(0);
  8971. NamedNodeMap attrsParam = item.getAttributes();
  8972. for(int j=0; j< attrsParam.getLength();j++)
  8973. {
  8974. Node attr = attrsParam.item(j);
  8975. if (attr.getNodeName().equalsIgnoreCase("year"))
  8976. QYear = Integer.parseInt(attr.getNodeValue());
  8977. else if (attr.getNodeName().equalsIgnoreCase("month"))
  8978. QMonth = Integer.parseInt(attr.getNodeValue());
  8979. }
  8980. List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
  8981. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  8982. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  8983. " <inquiry_time year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  8984. " <inquiry_count>"+SCData.size()+"</inquiry_count>\r\n";
  8985. if(SCData != null)
  8986. {
  8987. if (SCData.size()>0)
  8988. {
  8989. for(int i = 0; i<SCData.size(); i++)
  8990. {
  8991. WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
  8992. 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=\""+
  8993. SCINQDATA.inqyear+"\" inq_month=\""+SCINQDATA.inqmonth+"\" inq_day=\""+SCINQDATA.inqday+"\" inq_hour=\""+SCINQDATA.inqhour+"\" inq_message=\""+SCINQDATA.inqmsg+"\"/>\r\n";
  8994. }
  8995. }
  8996. retXML+="</service>\r\n</imap>";
  8997. }
  8998. else
  8999. {
  9000. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  9001. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  9002. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  9003. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9004. }
  9005. }
  9006. catch (RuntimeException re) {
  9007. LogUtil.errorLogInfo("", TAG, re);
  9008. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  9009. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  9010. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  9011. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9012. }
  9013. catch (Exception e)
  9014. {
  9015. //e.printStackTrace();
  9016. LogUtil.errorLogInfo("", TAG, e);
  9017. retXML = XMLHeader +"<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n"+
  9018. " <homeaddr dong = \""+AddrDong+"\" ho=\""+AddrHo+"\"/>\r\n"+
  9019. " <inquery_type year = \""+QYear+"\" month=\""+QMonth+"\"/>\r\n"+
  9020. " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
  9021. }
  9022. schedulDB.closeDB();
  9023. return retXML;
  9024. }
  9025. public String ProcUpdateSchedule(Element ele, String type)
  9026. {
  9027. String retXML = "";
  9028. return retXML;
  9029. }
  9030. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
  9031. public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
  9032. private void setDefaultLauncher() {
  9033. try
  9034. {
  9035. PackageManager pm = getPackageManager();
  9036. IntentFilter filter = new IntentFilter();
  9037. filter.addAction(Intent.ACTION_MAIN);
  9038. filter.addCategory(Intent.CATEGORY_HOME);
  9039. filter.addCategory(Intent.CATEGORY_DEFAULT);
  9040. Context context = getApplicationContext();
  9041. ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
  9042. ComponentName[] components = new ComponentName[] {new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
  9043. pm.clearPackagePreferredActivities("com.android.launcher");
  9044. pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
  9045. Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
  9046. try{Thread.sleep(300);}
  9047. catch (RuntimeException re) {
  9048. LogUtil.errorLogInfo("", TAG, re);
  9049. }
  9050. catch (Exception e){
  9051. LogUtil.errorLogInfo("", TAG, e);
  9052. }
  9053. // 리셋코드 추가
  9054. //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
  9055. try {
  9056. PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
  9057. powerMg.reboot(null);
  9058. Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
  9059. } catch (RuntimeException re) {
  9060. LogUtil.errorLogInfo("", TAG, re);
  9061. }
  9062. catch (Exception e) {
  9063. //e.printStackTrace();
  9064. LogUtil.errorLogInfo("", TAG, e);
  9065. }
  9066. Log.d(TAG, "$$$$$$$$$ Reset !!!!");
  9067. } catch (RuntimeException re) {
  9068. LogUtil.errorLogInfo("", TAG, re);
  9069. }
  9070. catch (Exception e) {
  9071. //e.printStackTrace();
  9072. LogUtil.errorLogInfo("", TAG, e);
  9073. }
  9074. }
  9075. public String ProcDeviceReset(Element ele)
  9076. {
  9077. String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
  9078. "</imap>\r\n";
  9079. NodeList resettype = ele.getElementsByTagName("guidemap");
  9080. Node resettypeItem = resettype.item(0);
  9081. String type = GetAttributeVal(resettypeItem, "type");
  9082. if(type!=null)
  9083. {
  9084. if (type.equals("now"))
  9085. {
  9086. setDefaultLauncher();
  9087. Intent intent = new Intent();
  9088. intent.setAction(define.NOTIFY_ACNAME);
  9089. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  9090. getApplicationContext().sendBroadcast(intent);
  9091. }
  9092. else if (type.equals("disable"))
  9093. {
  9094. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9095. SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE,0,0 );
  9096. SetReset.closeDB();
  9097. }
  9098. else if (type.equals("week") || type.equals("month"))
  9099. {
  9100. int Resettype = type.equals("week")?WallpadStatusData.RESET_WEEK:WallpadStatusData.RESET_MONTH;
  9101. NodeList periodList = ele.getElementsByTagName("period");
  9102. Node perioditem = periodList.item(0);
  9103. int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
  9104. int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
  9105. WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
  9106. SetReset.SetResetSchedule(Resettype,cycle,time );
  9107. SetReset.closeDB();
  9108. }
  9109. }
  9110. // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
  9111. // Intent intent = new Intent();
  9112. // intent.setAction(define.NOTIFY_ACNAME);
  9113. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
  9114. // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
  9115. // getApplicationContext().sendBroadcast(intent);
  9116. return retXML;
  9117. }
  9118. public String ProcDeviceLiveCheck()
  9119. {
  9120. String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
  9121. return retXML;
  9122. }
  9123. public String ProcPairingHdevSyncAlarm(Element ele) {
  9124. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
  9125. return retXML;
  9126. }
  9127. public String ProcPairingHdevSyncSecurity(Element ele) {
  9128. String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
  9129. return retXML;
  9130. }
  9131. public String ProcParkInformation(Element ele) {
  9132. try {
  9133. Log.d(TAG, "[ProcParkInformation] ========== START ==========");
  9134. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
  9135. String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
  9136. NodeList items = ele.getElementsByTagName("destination");
  9137. Node item = items.item(0);
  9138. Node text;
  9139. NamedNodeMap attrsParam = item.getAttributes();
  9140. for (int j = 0; j < attrsParam.getLength(); j++) {
  9141. Node attr = attrsParam.item(j);
  9142. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  9143. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  9144. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  9145. }
  9146. items = ele.getElementsByTagName("move_info");
  9147. item = items.item(0);
  9148. text = item.getFirstChild();
  9149. strCarMove = trimquotation(text.getNodeValue());
  9150. items = ele.getElementsByTagName("params");
  9151. item = items.item(0);
  9152. attrsParam = item.getAttributes();
  9153. for (int j = 0; j < attrsParam.getLength(); j++) {
  9154. Node attr = attrsParam.item(j);
  9155. if (attr.getNodeName().equalsIgnoreCase("car_num")) strCarNo = trimquotation(attr.getNodeValue());
  9156. else if (attr.getNodeName().equalsIgnoreCase("loc_info")) strCarLocation = trimquotation(attr.getNodeValue());
  9157. else if (attr.getNodeName().equalsIgnoreCase("message")) strMsg = trimquotation(attr.getNodeValue());
  9158. }
  9159. if(strName!=null && strDong!=null && strHo!=null && strCarMove!=null && strCarNo!=null && strCarLocation!=null && strMsg!=null)
  9160. Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
  9161. try {
  9162. int iTempDong = Integer.parseInt(AddrDong);
  9163. String sTempDong = Integer.toString(iTempDong);
  9164. int iTempHo = Integer.parseInt(AddrHo);
  9165. String sTempHo = Integer.toString(iTempHo);
  9166. if ((strName!=null && strName.equalsIgnoreCase("homedev") == true) && (strDong!=null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo!=null && strHo.equalsIgnoreCase(sTempHo) == true)) {
  9167. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9168. }
  9169. else {
  9170. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9171. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9172. return retXML;
  9173. }
  9174. } catch (RuntimeException re) {
  9175. LogUtil.errorLogInfo("", TAG, re);
  9176. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9177. return retXML;
  9178. }
  9179. catch (Exception e) {
  9180. //e.printStackTrace();
  9181. LogUtil.errorLogInfo("", TAG, e);
  9182. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
  9183. return retXML;
  9184. }
  9185. //DB정보 업데이트!
  9186. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9187. CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
  9188. CarDB.closeDB();
  9189. //DB정보 업데이트!
  9190. if (strCarMove.equalsIgnoreCase("in")) {
  9191. // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9192. // 팝업을 띄우도록 하자
  9193. wakeupLCD();
  9194. if (strMsg!=null && strMsg.equalsIgnoreCase("guest")) {
  9195. Intent iIntent = new Intent();
  9196. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9197. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9198. iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
  9199. getApplicationContext().sendBroadcast(iIntent);
  9200. }
  9201. else {
  9202. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9203. }
  9204. Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
  9205. Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
  9206. }
  9207. if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
  9208. if (strCarMove.equalsIgnoreCase("park")) {
  9209. //주차정보 얻어오도록 intent 알림
  9210. SendGetParkingInfoIntent();
  9211. }
  9212. }
  9213. else {
  9214. //주차정보 얻어오도록 intent 알림
  9215. SendGetParkingInfoIntent();
  9216. //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
  9217. SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
  9218. }
  9219. return retXML;
  9220. } catch (RuntimeException re) {
  9221. LogUtil.errorLogInfo("", TAG, re);
  9222. return null;
  9223. }
  9224. catch (Exception e) {
  9225. Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
  9226. //e.printStackTrace();
  9227. LogUtil.errorLogInfo("", TAG, e);
  9228. return null;
  9229. }
  9230. }
  9231. /**
  9232. * 스마트키 이벤트 수신시 처리
  9233. * **/
  9234. public String ProcSmartKeyEvent(Element ele) {
  9235. Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
  9236. String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
  9237. String strName = null, strDong = null, strHo = null, strCnt = null;
  9238. String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
  9239. String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
  9240. NodeList items = ele.getElementsByTagName("destination");
  9241. Node item = items.item(0);
  9242. NamedNodeMap attrsParam = item.getAttributes();
  9243. for (int j = 0; j < attrsParam.getLength(); j++) {
  9244. Node attr = attrsParam.item(j);
  9245. if (attr.getNodeName().equalsIgnoreCase("name")) strName = trimquotation(attr.getNodeValue());
  9246. else if (attr.getNodeName().equalsIgnoreCase("id_high")) strDong = trimquotation(attr.getNodeValue());
  9247. else if (attr.getNodeName().equalsIgnoreCase("id_low")) strHo = trimquotation(attr.getNodeValue());
  9248. }
  9249. items = ele.getElementsByTagName("event_info");
  9250. item = items.item(0);
  9251. attrsParam = item.getAttributes();
  9252. for (int j = 0; j < attrsParam.getLength(); j++) {
  9253. Node attr = attrsParam.item(j);
  9254. if (attr.getNodeName().equalsIgnoreCase("info_cnt")) strCnt = trimquotation(attr.getNodeValue());
  9255. }
  9256. items = ele.getElementsByTagName("event");
  9257. item = items.item(0);
  9258. attrsParam = item.getAttributes();
  9259. for (int j = 0; j < attrsParam.getLength(); j++) {
  9260. Node attr = attrsParam.item(j);
  9261. if (attr.getNodeName().equalsIgnoreCase("event_type")) strEventType = trimquotation(attr.getNodeValue());
  9262. else if (attr.getNodeName().equalsIgnoreCase("trigger_type")) strEventTriggerType = trimquotation(attr.getNodeValue());
  9263. else if (attr.getNodeName().equalsIgnoreCase("uid")) strEventUID = trimquotation(attr.getNodeValue());
  9264. else if (attr.getNodeName().equalsIgnoreCase("sn")) strEventSN = trimquotation(attr.getNodeValue());
  9265. else if (attr.getNodeName().equalsIgnoreCase("sitecode")) strEventSitecode = trimquotation(attr.getNodeValue());
  9266. else if (attr.getNodeName().equalsIgnoreCase("dong")) strEventDong = trimquotation(attr.getNodeValue());
  9267. else if (attr.getNodeName().equalsIgnoreCase("ho")) strEventHo = trimquotation(attr.getNodeValue());
  9268. else if (attr.getNodeName().equalsIgnoreCase("card_num")) strEventCardNo = trimquotation(attr.getNodeValue());
  9269. else if (attr.getNodeName().equalsIgnoreCase("issue_cnt")) strEventIssueCnt = trimquotation(attr.getNodeValue());
  9270. else if (attr.getNodeName().equalsIgnoreCase("card_type")) strEventCardType = trimquotation(attr.getNodeValue());
  9271. else if (attr.getNodeName().equalsIgnoreCase("location")) strEventLocation = trimquotation(attr.getNodeValue());
  9272. }
  9273. if(strName!=null && strDong!=null && strHo!=null && strCnt!=null)
  9274. Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
  9275. Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
  9276. Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
  9277. if ((strName!=null && strName.equalsIgnoreCase("homedev")) && (strDong!=null && strDong.equalsIgnoreCase(AddrDong)) && (strHo!=null && strHo.equalsIgnoreCase(AddrHo))) {
  9278. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
  9279. }
  9280. else {
  9281. Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
  9282. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9283. return retXML;
  9284. }
  9285. //데이터가 null인지 확인
  9286. if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
  9287. return retXML;
  9288. }
  9289. if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
  9290. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9291. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9292. wakeupLCD();
  9293. // 팝업을 띄우도록 하자
  9294. String CardNum = "";
  9295. try {
  9296. int iEvent_Dong = Integer.parseInt(strEventDong);
  9297. CardNum += String.format("%04d", iEvent_Dong);
  9298. int iEvent_Ho = Integer.parseInt(strEventHo);
  9299. CardNum += String.format("%04d", iEvent_Ho);
  9300. int iEvent_CardNum = Integer.parseInt(strEventCardNo);
  9301. CardNum += String.format("%03d", iEvent_CardNum);
  9302. } catch (RuntimeException re) {
  9303. LogUtil.errorLogInfo("", TAG, re);
  9304. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9305. return retXML;
  9306. }
  9307. catch (Exception e) {
  9308. //e.printStackTrace();
  9309. LogUtil.errorLogInfo("", TAG, e);
  9310. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9311. return retXML;
  9312. }
  9313. Intent iIntent = new Intent();
  9314. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9315. iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
  9316. iIntent.putExtra("LOCATION", strEventLocation);
  9317. iIntent.putExtra("CARD_NO", CardNum);
  9318. getApplicationContext().sendBroadcast(iIntent);
  9319. }
  9320. }
  9321. }
  9322. else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
  9323. if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
  9324. if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
  9325. int nCardNum;
  9326. try {
  9327. nCardNum = Integer.parseInt(strEventCardNo);
  9328. Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
  9329. } catch (RuntimeException re) {
  9330. LogUtil.errorLogInfo("", TAG, re);
  9331. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9332. return retXML;
  9333. }
  9334. catch (Exception e) {
  9335. //e.printStackTrace();
  9336. LogUtil.errorLogInfo("", TAG, e);
  9337. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
  9338. return retXML;
  9339. }
  9340. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  9341. boolean bBandUse = deviceSet.getBandLocationUsage();
  9342. deviceSet.closeDB();
  9343. if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
  9344. wakeupLCD();
  9345. Intent iIntent = new Intent();
  9346. iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  9347. iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
  9348. iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
  9349. getApplicationContext().sendBroadcast(iIntent);
  9350. }
  9351. }
  9352. }
  9353. }
  9354. return retXML;
  9355. }
  9356. public String ProcParkInformation_cham_upis(Element ele)
  9357. {
  9358. Log.d(TAG, "ProcParkInformation_cham_upis START");
  9359. String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
  9360. String infoName = null;
  9361. String infoDong = null;
  9362. String infoHo = null;
  9363. String infoCarMove = null;
  9364. String infoCarnum = null;
  9365. String infoCarLocation = null;
  9366. String infoMessage = null;
  9367. NodeList items = ele.getElementsByTagName("home_info");
  9368. Node item = items.item(0);
  9369. Node text;
  9370. NamedNodeMap attrsParam = item.getAttributes();
  9371. for(int j=0; j< attrsParam.getLength();j++)
  9372. {
  9373. Node attr = attrsParam.item(j);
  9374. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9375. infoDong = trimquotation(attr.getNodeValue());
  9376. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9377. infoHo = trimquotation(attr.getNodeValue());
  9378. }
  9379. items = ele.getElementsByTagName("park_info");
  9380. item = items.item(0);
  9381. attrsParam = item.getAttributes();
  9382. for(int j=0; j< attrsParam.getLength();j++)
  9383. {
  9384. Node attr = attrsParam.item(j);
  9385. if (attr.getNodeName().equalsIgnoreCase("car_info"))
  9386. infoCarnum = trimquotation(attr.getNodeValue());
  9387. else if (attr.getNodeName().equalsIgnoreCase("location_2"))
  9388. infoCarLocation = trimquotation(attr.getNodeValue());
  9389. else if (attr.getNodeName().equalsIgnoreCase("message"))
  9390. infoMessage = trimquotation(attr.getNodeValue());
  9391. }
  9392. Log.d(TAG, "ProcParkInformation infoName :"+infoName);
  9393. if(infoDong!=null)
  9394. Log.d(TAG, "ProcParkInformation infoDong :"+infoDong);
  9395. Log.d(TAG, "ProcParkInformation infoHo :"+infoHo);
  9396. Log.d(TAG, "ProcParkInformation infoCarMove :"+infoCarMove);
  9397. Log.d(TAG, "ProcParkInformation infoCarnum :"+infoCarnum);
  9398. Log.d(TAG, "ProcParkInformation infoCarLocation :"+infoCarLocation);
  9399. Log.d(TAG, "ProcParkInformation infoMessage :"+infoMessage);
  9400. if((infoDong!=null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
  9401. (infoHo!=null && infoHo.equalsIgnoreCase(AddrHo) == true))
  9402. {
  9403. Log.d(TAG, "ProcParkInformation Input EMData is Correct");
  9404. }
  9405. else
  9406. {
  9407. Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
  9408. retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
  9409. return retXML;
  9410. }
  9411. infoCarMove = "park";
  9412. //DB정보 업데이트!
  9413. WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
  9414. CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
  9415. CarDB.closeDB();
  9416. //DB정보 업데이트!
  9417. Intent iIntent = new Intent();
  9418. iIntent.setAction(define.NOTIFY_ACNAME);
  9419. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  9420. this.sendBroadcast(iIntent);
  9421. /*
  9422. if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
  9423. {
  9424. playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
  9425. // 팝업을 띄우도록 하자
  9426. Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
  9427. }
  9428. */
  9429. return retXML;
  9430. }
  9431. public String ProcGetSmartKeyInfo(Element ele)
  9432. {
  9433. List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
  9434. List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
  9435. String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
  9436. NodeList items = ele.getElementsByTagName("info_type");
  9437. Node item = items.item(0);
  9438. Node text = item.getFirstChild();
  9439. String sInfo_type = trimquotation(text.getNodeValue());
  9440. String sCard_info = null;
  9441. String sMessage = null;
  9442. if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
  9443. {
  9444. items = ele.getElementsByTagName("uid_info");
  9445. item = items.item(0);
  9446. text = item.getFirstChild();
  9447. sCard_info = trimquotation(text.getNodeValue());
  9448. //==============================================//
  9449. items = ele.getElementsByTagName("message");
  9450. item = items.item(0);
  9451. text = item.getFirstChild();
  9452. sMessage = trimquotation(text.getNodeValue());
  9453. //==============================================//
  9454. //쿼리문 작성
  9455. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9456. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9457. for(int i=0; i<SyncData.size(); i++)
  9458. {
  9459. if(SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true)
  9460. {
  9461. NewData.add(SyncData.get(i));
  9462. }
  9463. }
  9464. wallpadSmartKeyRegData.closeDB();
  9465. }
  9466. else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
  9467. {
  9468. items = ele.getElementsByTagName("sn_info");
  9469. item = items.item(0);
  9470. text = item.getFirstChild();
  9471. sCard_info = trimquotation(text.getNodeValue());
  9472. //==============================================//
  9473. items = ele.getElementsByTagName("message");
  9474. item = items.item(0);
  9475. text = item.getFirstChild();
  9476. sMessage = trimquotation(text.getNodeValue());
  9477. //==============================================//
  9478. //쿼리문 작성
  9479. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9480. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9481. for(int i=0; i<SyncData.size(); i++)
  9482. {
  9483. if(SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true)
  9484. {
  9485. NewData.add(SyncData.get(i));
  9486. }
  9487. }
  9488. wallpadSmartKeyRegData.closeDB();
  9489. }
  9490. else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
  9491. {
  9492. items = ele.getElementsByTagName("uid_info");
  9493. item = items.item(0);
  9494. text = item.getFirstChild();
  9495. sCard_info = trimquotation(text.getNodeValue());
  9496. //==============================================//
  9497. items = ele.getElementsByTagName("message");
  9498. item = items.item(0);
  9499. text = item.getFirstChild();
  9500. sMessage = trimquotation(text.getNodeValue());
  9501. //==============================================//
  9502. //쿼리문 작성
  9503. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9504. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9505. for(int i=0; i<SyncData.size(); i++)
  9506. {
  9507. if(SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true)
  9508. {
  9509. NewData.add(SyncData.get(i));
  9510. }
  9511. }
  9512. if(NewData.size() > 0)
  9513. {
  9514. NewData = SyncData;
  9515. }
  9516. wallpadSmartKeyRegData.closeDB();
  9517. }
  9518. else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
  9519. {
  9520. items = ele.getElementsByTagName("sn_info");
  9521. item = items.item(0);
  9522. text = item.getFirstChild();
  9523. sCard_info = trimquotation(text.getNodeValue());
  9524. //==============================================//
  9525. items = ele.getElementsByTagName("message");
  9526. item = items.item(0);
  9527. text = item.getFirstChild();
  9528. sMessage = trimquotation(text.getNodeValue());
  9529. //==============================================//
  9530. //쿼리문 작성
  9531. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9532. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9533. for(int i=0; i<SyncData.size(); i++)
  9534. {
  9535. if(SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true)
  9536. {
  9537. NewData.add(SyncData.get(i));
  9538. }
  9539. }
  9540. if(NewData.size() > 0)
  9541. {
  9542. NewData = SyncData;
  9543. }
  9544. wallpadSmartKeyRegData.closeDB();
  9545. }
  9546. else if (sInfo_type.equalsIgnoreCase("hkey"))
  9547. {
  9548. String dong = "";
  9549. String ho = "";
  9550. String Num = "all";
  9551. //==============================================//
  9552. items = ele.getElementsByTagName("message");
  9553. item = items.item(0);
  9554. text = item.getFirstChild();
  9555. sMessage = trimquotation(text.getNodeValue());
  9556. //==============================================//
  9557. items = ele.getElementsByTagName("hkey_info");
  9558. item = items.item(0);
  9559. if (item == null)
  9560. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9561. NamedNodeMap attrsParam = item.getAttributes();
  9562. for(int j=0; j< attrsParam.getLength();j++)
  9563. {
  9564. Node attr = attrsParam.item(j);
  9565. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9566. dong = attr.getNodeValue();
  9567. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9568. ho = attr.getNodeValue();
  9569. else if (attr.getNodeName().equalsIgnoreCase("num"))
  9570. Num = attr.getNodeValue();
  9571. }
  9572. if(!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo))))
  9573. {
  9574. Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :"+ dong+ "-" + ho);
  9575. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9576. }
  9577. //쿼리문 작성
  9578. int intNum = 0;
  9579. WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
  9580. SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
  9581. for(int i=0; i<SyncData.size(); i++)
  9582. {
  9583. if(Num.equalsIgnoreCase("all") == true)
  9584. {
  9585. NewData.add(SyncData.get(i));
  9586. }
  9587. else
  9588. {
  9589. try
  9590. {
  9591. intNum = Integer.parseInt(Num);
  9592. }
  9593. catch (RuntimeException re) {
  9594. LogUtil.errorLogInfo("", TAG, re);
  9595. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9596. }
  9597. catch (Exception e)
  9598. {
  9599. //e.printStackTrace();
  9600. LogUtil.errorLogInfo("", TAG, e);
  9601. return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
  9602. }
  9603. if(SyncData.get(i).id == intNum)
  9604. {
  9605. NewData.add(SyncData.get(i));
  9606. }
  9607. }
  9608. }
  9609. wallpadSmartKeyRegData.closeDB();
  9610. }
  9611. else if (sInfo_type.equalsIgnoreCase("dkey"))
  9612. {
  9613. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  9614. }
  9615. else if (sInfo_type.equalsIgnoreCase("mkey"))
  9616. {
  9617. return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
  9618. }
  9619. if(NewData.size() == 0)
  9620. {
  9621. retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
  9622. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  9623. retXML += " <hkey_info dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" count = \""+NewData.size()+"\" />\r\n";
  9624. retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
  9625. retXML += " </service>\r\n</imap>";
  9626. return retXML;
  9627. }
  9628. retXML += " <key_type>\"hkey\"</key_type>\r\n";
  9629. retXML += " <hkey_info dong = \""+AddrDong+"\" ho = \""+AddrHo+"\" count = \""+NewData.size()+"\" />\r\n";
  9630. for(int i = 0; i<NewData.size(); i++)
  9631. {
  9632. Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
  9633. SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
  9634. String strFormat = sFormat.format(date);
  9635. retXML += " <key_info index = \""+NewData.get(i).id+"\" "
  9636. + "sn = \""+NewData.get(i).SerialNumber+"\" "
  9637. + "uid = \""+NewData.get(i).Uid+"\" "
  9638. + "key_num = \""+NewData.get(i).id+"\" "
  9639. + "issue_cnt = \""+1+"\" "
  9640. + "issued_date = \""+strFormat+"\" "
  9641. + "message = \""+"null"+"\" "
  9642. + "/>\r\n";
  9643. }
  9644. retXML += " </service>\r\n</imap>";
  9645. return retXML;
  9646. }
  9647. public void ProcMobileDevice_AuthNumber(Element ele) {
  9648. String sDong = null;
  9649. String sHo = null;
  9650. String sIP = null;
  9651. String sType = null;
  9652. String sDevice_Name = null;
  9653. String sTwinID = null;
  9654. String sAuthNumber = null;
  9655. try {
  9656. NodeList items = ele.getElementsByTagName("home_info");
  9657. Node item = items.item(0);
  9658. NamedNodeMap attrsParam = item.getAttributes();
  9659. for (int i=0; i< attrsParam.getLength(); i++) {
  9660. Node attr = attrsParam.item(i);
  9661. if (attr.getNodeName().equalsIgnoreCase("dong")) sDong = trimquotation(attr.getNodeValue());
  9662. else if (attr.getNodeName().equalsIgnoreCase("ho")) sHo = trimquotation(attr.getNodeValue());
  9663. else if (attr.getNodeName().equalsIgnoreCase("ip")) sIP = trimquotation(attr.getNodeValue());
  9664. else if (attr.getNodeName().equalsIgnoreCase("type")) sType = trimquotation(attr.getNodeValue());
  9665. }
  9666. WallpadStatusData DBMGR = null;
  9667. DBMGR = new WallpadStatusData(getApplicationContext());
  9668. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9669. DBMGR.closeDB();
  9670. if((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo!=null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP!=null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
  9671. items = ele.getElementsByTagName("device_info");
  9672. item = items.item(0);
  9673. attrsParam = item.getAttributes();
  9674. for (int i = 0; i < attrsParam.getLength(); i++) {
  9675. Node attr = attrsParam.item(i);
  9676. if (attr.getNodeName().equalsIgnoreCase("alias")) sDevice_Name = trimquotation(attr.getNodeValue());
  9677. else if (attr.getNodeName().equalsIgnoreCase("twinid")) sTwinID = trimquotation(attr.getNodeValue());
  9678. else if (attr.getNodeName().equalsIgnoreCase("auth_number")) sAuthNumber = trimquotation(attr.getNodeValue());
  9679. }
  9680. /**데이터 전달**/
  9681. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9682. Log.d(TAG, "sTwinID :" + sTwinID);
  9683. Log.d(TAG, "sAuthNumber :" + sAuthNumber);
  9684. Intent intent = new Intent();
  9685. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  9686. intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
  9687. intent.putExtra("AuthNumber", sAuthNumber);
  9688. if (NewServerUse()) {
  9689. getApplicationContext().sendBroadcast(intent);
  9690. }
  9691. }
  9692. else {
  9693. }
  9694. } catch (RuntimeException re) {
  9695. LogUtil.errorLogInfo("", TAG, re);
  9696. }
  9697. catch (Exception e) {
  9698. //e.printStackTrace();
  9699. LogUtil.errorLogInfo("", TAG, e);
  9700. }
  9701. }
  9702. public String ProcMobileDevice_ADD_Finish(Element ele) {
  9703. String retXML = "";
  9704. String sDong = null;
  9705. String sHo = null;
  9706. String sIP = null;
  9707. String sType = null;
  9708. String sDevice_Name = null;
  9709. String sTwinID = null;
  9710. try
  9711. {
  9712. NodeList items = ele.getElementsByTagName("home_info");
  9713. Node item = items.item(0);
  9714. NamedNodeMap attrsParam = item.getAttributes();
  9715. for(int i=0; i< attrsParam.getLength(); i++)
  9716. {
  9717. Node attr = attrsParam.item(i);
  9718. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9719. sDong = trimquotation(attr.getNodeValue());
  9720. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9721. sHo = trimquotation(attr.getNodeValue());
  9722. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  9723. sIP = trimquotation(attr.getNodeValue());
  9724. else if (attr.getNodeName().equalsIgnoreCase("type"))
  9725. sType = trimquotation(attr.getNodeValue());
  9726. }
  9727. WallpadStatusData DBMGR = null;
  9728. DBMGR = new WallpadStatusData(getApplicationContext());
  9729. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9730. DBMGR.closeDB();
  9731. if((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  9732. (sHo!=null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  9733. (sIP!=null && sIP.equalsIgnoreCase(addc.IPAddress) == true))
  9734. {
  9735. items = ele.getElementsByTagName("device_info");
  9736. item = items.item(0);
  9737. attrsParam = item.getAttributes();
  9738. for(int i=0; i< attrsParam.getLength(); i++)
  9739. {
  9740. Node attr = attrsParam.item(i);
  9741. if (attr.getNodeName().equalsIgnoreCase("alias"))
  9742. sDevice_Name = trimquotation(attr.getNodeValue());
  9743. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  9744. sTwinID = trimquotation(attr.getNodeValue());
  9745. }
  9746. /**데이터 전달**/
  9747. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9748. Log.d(TAG, "sTwinID :" + sTwinID);
  9749. Intent intent = new Intent();
  9750. intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
  9751. intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
  9752. if(NewServerUse())
  9753. {
  9754. getApplicationContext().sendBroadcast(intent);
  9755. }
  9756. else
  9757. {
  9758. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9759. retXML += " </service>\r\n</imap>";
  9760. return retXML;
  9761. }
  9762. String tempType = "main";
  9763. //DB에 저장 필요
  9764. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  9765. if(wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
  9766. {
  9767. wallpadMobileDeviceData.closeDB();
  9768. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9769. retXML += " </service>\r\n</imap>";
  9770. return retXML;
  9771. }
  9772. wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
  9773. wallpadMobileDeviceData.closeDB();
  9774. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
  9775. retXML += " <home_info dong=\""+addc.Dong+"\" ho=\""+ addc.Ho+"\" ip=\""+ addc.IPAddress+"\" type=\""+ tempType +"\"/>\r\n";
  9776. retXML += " <device_info alias=\""+sDevice_Name+"\" twinid=\""+sTwinID+"\" />\r\n";
  9777. retXML += " </service>\r\n</imap>";
  9778. return retXML;
  9779. }
  9780. else
  9781. {
  9782. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9783. retXML += " </service>\r\n</imap>";
  9784. return retXML;
  9785. }
  9786. }
  9787. catch (RuntimeException re) {
  9788. LogUtil.errorLogInfo("", TAG, re);
  9789. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9790. retXML += " </service>\r\n</imap>";
  9791. return retXML;
  9792. }
  9793. catch (Exception e)
  9794. {
  9795. //e.printStackTrace();
  9796. LogUtil.errorLogInfo("", TAG, e);
  9797. retXML= XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
  9798. retXML += " </service>\r\n</imap>";
  9799. return retXML;
  9800. }
  9801. }
  9802. public void ProcMobileDevice_Delete(Element ele)
  9803. {
  9804. String sDong = null;
  9805. String sHo = null;
  9806. String sIP = null;
  9807. String sType = null;
  9808. String sDevice_Name = null;
  9809. String sTwinID = null;
  9810. Log.d(TAG, "ProcMobileDevice_Delete");
  9811. try
  9812. {
  9813. NodeList items = ele.getElementsByTagName("home_info");
  9814. Node item = items.item(0);
  9815. NamedNodeMap attrsParam = item.getAttributes();
  9816. for(int i=0; i< attrsParam.getLength(); i++)
  9817. {
  9818. Node attr = attrsParam.item(i);
  9819. if (attr.getNodeName().equalsIgnoreCase("dong"))
  9820. sDong = trimquotation(attr.getNodeValue());
  9821. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  9822. sHo = trimquotation(attr.getNodeValue());
  9823. else if (attr.getNodeName().equalsIgnoreCase("ip"))
  9824. sIP = trimquotation(attr.getNodeValue());
  9825. else if (attr.getNodeName().equalsIgnoreCase("type"))
  9826. sType = trimquotation(attr.getNodeValue());
  9827. }
  9828. WallpadStatusData DBMGR = null;
  9829. DBMGR = new WallpadStatusData(getApplicationContext());
  9830. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  9831. DBMGR.closeDB();
  9832. if((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
  9833. (sHo!=null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
  9834. (sIP!=null && sIP.equalsIgnoreCase(addc.IPAddress) == true))
  9835. {
  9836. if(NewServerUse())
  9837. {
  9838. WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  9839. items = ele.getElementsByTagName("device_info");
  9840. for(int i = 0; i< items.getLength(); i++)
  9841. {
  9842. item = items.item(i);
  9843. attrsParam = item.getAttributes();
  9844. for(int j=0; j < attrsParam.getLength(); j++)
  9845. {
  9846. Node attr = attrsParam.item(j);
  9847. if (attr.getNodeName().equalsIgnoreCase("alias"))
  9848. sDevice_Name = trimquotation(attr.getNodeValue());
  9849. else if (attr.getNodeName().equalsIgnoreCase("twinid"))
  9850. sTwinID = trimquotation(attr.getNodeValue());
  9851. }
  9852. Log.d(TAG, "sDevice_Name :" + sDevice_Name);
  9853. Log.d(TAG, "sTwinID :" + sTwinID);
  9854. wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
  9855. }
  9856. wallpadMobileDeviceData.closeDB();
  9857. Intent intent = new Intent();
  9858. intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
  9859. getApplicationContext().sendBroadcast(intent);
  9860. }
  9861. }
  9862. else
  9863. {
  9864. }
  9865. }
  9866. catch (RuntimeException re) {
  9867. LogUtil.errorLogInfo("", TAG, re);
  9868. }
  9869. catch (Exception e)
  9870. {
  9871. //e.printStackTrace();
  9872. LogUtil.errorLogInfo("", TAG, e);
  9873. }
  9874. }
  9875. public String ProcGetAppVersionInfo()
  9876. {
  9877. String retXML = "";
  9878. MainDatabaseManager mDBM = new MainDatabaseManager( getApplicationContext() , null, null);
  9879. int AppCount;
  9880. AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
  9881. retXML= XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
  9882. retXML += " <home_info dong = \""+AddrDong+"\" ho=\""+AddrHo+"\" platform=\"Android\" count=\""+AppCount+"\" />\r\n";
  9883. for(int i =0; i<AppCount; i++)
  9884. {
  9885. String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE+i);
  9886. if(getString != null)
  9887. {
  9888. retXML += " <app_list name=\""+getString[0]+"\" version=\""+getString[1]+"\" />\r\n";
  9889. }
  9890. }
  9891. retXML += " </service>\r\n</imap>";
  9892. return retXML;
  9893. }
  9894. public String ProcIgateInitInfo(Element ele)
  9895. {
  9896. String retXML = "";
  9897. String ctrl_baudrate = "";
  9898. String ctrl_open = "";
  9899. String ctrl_framecheck = "";
  9900. String ctrl_message = "";
  9901. String eth_mode = "";
  9902. String eth_ip = "";
  9903. String eth_mac = "";
  9904. String eth_gw = "";
  9905. String eth_sm = "";
  9906. String noti_send = "";
  9907. String noti_level = "";
  9908. String noti_ip = "";
  9909. String noti_port= "";
  9910. try
  9911. {
  9912. NodeList items = ele.getElementsByTagName("ctrl_param");
  9913. Node item = items.item(0);
  9914. NamedNodeMap attrsParam = item.getAttributes();
  9915. for(int i=0; i< attrsParam.getLength(); i++)
  9916. {
  9917. Node attr = attrsParam.item(i);
  9918. if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
  9919. ctrl_baudrate = trimquotation(attr.getNodeValue());
  9920. else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
  9921. ctrl_open = trimquotation(attr.getNodeValue());
  9922. else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
  9923. ctrl_framecheck = trimquotation(attr.getNodeValue());
  9924. else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
  9925. ctrl_message = trimquotation(attr.getNodeValue());
  9926. }
  9927. items = ele.getElementsByTagName("eth_param");
  9928. item = items.item(0);
  9929. attrsParam = item.getAttributes();
  9930. for(int i=0; i< attrsParam.getLength(); i++)
  9931. {
  9932. Node attr = attrsParam.item(i);
  9933. if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
  9934. eth_mode = trimquotation(attr.getNodeValue());
  9935. else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
  9936. eth_ip = trimquotation(attr.getNodeValue());
  9937. else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
  9938. eth_mac = trimquotation(attr.getNodeValue());
  9939. else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
  9940. eth_gw = trimquotation(attr.getNodeValue());
  9941. else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
  9942. eth_sm = trimquotation(attr.getNodeValue());
  9943. }
  9944. items = ele.getElementsByTagName("noti_param");
  9945. item = items.item(0);
  9946. attrsParam = item.getAttributes();
  9947. for(int i=0; i< attrsParam.getLength(); i++)
  9948. {
  9949. Node attr = attrsParam.item(i);
  9950. if (attr.getNodeName().equalsIgnoreCase("noti_send"))
  9951. noti_send = trimquotation(attr.getNodeValue());
  9952. else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
  9953. noti_level = trimquotation(attr.getNodeValue());
  9954. else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
  9955. noti_ip = trimquotation(attr.getNodeValue());
  9956. else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
  9957. noti_port = trimquotation(attr.getNodeValue());
  9958. }
  9959. wallpaddbmgr WallpadDBMGR = null;
  9960. WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  9961. int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
  9962. if(RowCount_GatewayData > 100)
  9963. {
  9964. WallpadDBMGR.DeleteLH_GatewayData("50");
  9965. }
  9966. 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);
  9967. WallpadDBMGR.closeDB();
  9968. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
  9969. retXML += " </service>\r\n</imap>";
  9970. return retXML;
  9971. }
  9972. catch (RuntimeException re) {
  9973. LogUtil.errorLogInfo("", TAG, re);
  9974. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  9975. retXML += " </service>\r\n</imap>";
  9976. return retXML;
  9977. }
  9978. catch (Exception e)
  9979. {
  9980. //e.printStackTrace();
  9981. LogUtil.errorLogInfo("", TAG, e);
  9982. retXML= XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
  9983. retXML += " </service>\r\n</imap>";
  9984. return retXML;
  9985. }
  9986. }
  9987. public String ProcElecCarChargeEventInfo(Element ele) {
  9988. Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
  9989. String retXML = "";
  9990. String sName = "", sId_High = "", sId_Low = "", sCard_Num ="", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
  9991. String sStart_Time = "", sRemain_Time = "", sMessage = "";
  9992. try {
  9993. NodeList items = ele.getElementsByTagName("destination");
  9994. Node item = items.item(0);
  9995. NamedNodeMap attrsParam = item.getAttributes();
  9996. for (int i = 0; i < attrsParam.getLength(); i++) {
  9997. Node attr = attrsParam.item(i);
  9998. if (attr.getNodeName().equalsIgnoreCase("name")) sName = trimquotation(attr.getNodeValue());
  9999. else if (attr.getNodeName().equalsIgnoreCase("id_high")) sId_High = trimquotation(attr.getNodeValue());
  10000. else if (attr.getNodeName().equalsIgnoreCase("id_low")) sId_Low = trimquotation(attr.getNodeValue());
  10001. }
  10002. WallpadStatusData DBMGR = null;
  10003. DBMGR = new WallpadStatusData(getApplicationContext());
  10004. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10005. DBMGR.closeDB();
  10006. if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
  10007. items = ele.getElementsByTagName("charging_info");
  10008. item = items.item(0);
  10009. attrsParam = item.getAttributes();
  10010. for (int i = 0; i < attrsParam.getLength(); i++) {
  10011. Node attr = attrsParam.item(i);
  10012. if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
  10013. (attr.getNodeName().equalsIgnoreCase("car_num")) ||
  10014. (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
  10015. (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
  10016. (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
  10017. (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
  10018. (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
  10019. (attr.getNodeName().equalsIgnoreCase("start_time")) ||
  10020. (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
  10021. (attr.getNodeName().equalsIgnoreCase("c_msg"))
  10022. ))
  10023. {
  10024. Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10025. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10026. retXML += " </service>\r\n</imap>";
  10027. return retXML;
  10028. }
  10029. if (attr.getNodeName().equalsIgnoreCase("card_num")) sCard_Num = trimquotation(attr.getNodeValue());
  10030. else if (attr.getNodeName().equalsIgnoreCase("car_num")) sCar_Num = trimquotation(attr.getNodeValue());
  10031. else if (attr.getNodeName().equalsIgnoreCase("charger_num")) sCharger_Num = trimquotation(attr.getNodeValue());
  10032. else if (attr.getNodeName().equalsIgnoreCase("charger_loc")) sCharger_Loc = trimquotation(attr.getNodeValue());
  10033. else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
  10034. sCharging_Status = trimquotation(attr.getNodeValue());
  10035. if (!((sCharging_Status.equalsIgnoreCase("start")) ||
  10036. (sCharging_Status.equalsIgnoreCase("charging")) ||
  10037. (sCharging_Status.equalsIgnoreCase("full")) ||
  10038. (sCharging_Status.equalsIgnoreCase("charged")) ||
  10039. (sCharging_Status.equalsIgnoreCase("stop")) ||
  10040. (sCharging_Status.equalsIgnoreCase("service_out")) ||
  10041. (sCharging_Status.equalsIgnoreCase("check")) ||
  10042. (sCharging_Status.equalsIgnoreCase("commerror"))
  10043. ))
  10044. {
  10045. Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
  10046. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10047. retXML += " </service>\r\n</imap>";
  10048. return retXML;
  10049. }
  10050. }
  10051. else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
  10052. sCharger_sort = trimquotation(attr.getNodeValue());
  10053. if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
  10054. (sCharger_sort.equalsIgnoreCase("fast")) ||
  10055. (sCharger_sort.equalsIgnoreCase("no_info"))
  10056. ))
  10057. {
  10058. Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
  10059. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10060. retXML += " </service>\r\n</imap>";
  10061. return retXML;
  10062. }
  10063. }
  10064. else if (attr.getNodeName().equalsIgnoreCase("charging_ratio")) sCharging_Ratio = trimquotation(attr.getNodeValue());
  10065. else if (attr.getNodeName().equalsIgnoreCase("start_time")) sStart_Time = trimquotation(attr.getNodeValue());
  10066. else if (attr.getNodeName().equalsIgnoreCase("remain_time")) sRemain_Time = trimquotation(attr.getNodeValue());
  10067. }
  10068. items = ele.getElementsByTagName("message");
  10069. item = items.item(0);
  10070. Node text = item.getFirstChild();
  10071. sMessage = trimquotation(text.getNodeValue());
  10072. /**데이터 전달**/
  10073. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
  10074. Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
  10075. Intent intent = new Intent();
  10076. intent.setAction(define.NOTIFY_ACNAME);
  10077. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  10078. intent.putExtra("sCard_Num", sCard_Num);
  10079. intent.putExtra("sCar_Num", sCar_Num);
  10080. intent.putExtra("sCharger_Num", sCharger_Num);
  10081. intent.putExtra("sCharger_Loc", sCharger_Loc);
  10082. intent.putExtra("sCharging_Status", sCharging_Status);
  10083. intent.putExtra("sCharger_sort", sCharger_sort);
  10084. intent.putExtra("sCharging_Ratio", sCharging_Ratio);
  10085. intent.putExtra("sStart_Time", sStart_Time);
  10086. intent.putExtra("sRemain_Time", sRemain_Time);
  10087. intent.putExtra("sMessage", sMessage);
  10088. WallpadDeviceSet devDB = null;
  10089. devDB = new WallpadDeviceSet(getApplicationContext());
  10090. int retInt = -1;
  10091. retInt = devDB.GetDeviceSetted("전기차충전");
  10092. devDB.closeDB();
  10093. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10094. getApplicationContext().sendBroadcast(intent);
  10095. }
  10096. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
  10097. retXML += " <source name=\"homedev\" id_high=\""+sId_High+"\" id_low=\""+ sId_Low+"\" />\r\n";
  10098. retXML += " </service>\r\n</imap>";
  10099. return retXML;
  10100. }
  10101. else {
  10102. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10103. retXML += " </service>\r\n</imap>";
  10104. return retXML;
  10105. }
  10106. } catch (RuntimeException re) {
  10107. LogUtil.errorLogInfo("", TAG, re);
  10108. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10109. retXML += " </service>\r\n</imap>";
  10110. return retXML;
  10111. }
  10112. catch (Exception e) {
  10113. //e.printStackTrace();
  10114. LogUtil.errorLogInfo("", TAG, e);
  10115. retXML= XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
  10116. retXML += " </service>\r\n</imap>";
  10117. return retXML;
  10118. }
  10119. }
  10120. public String ProcEnergyTargetInfoAlarm(Element ele) {
  10121. String retXML = "";
  10122. String sName = "";
  10123. String sId_High = "";
  10124. String sId_Low = "";
  10125. String vName[];
  10126. String vTarget[];
  10127. String vTarget_Cost[];
  10128. String vUsed[];
  10129. String vUsed_Cost[];
  10130. String vPredict[];
  10131. String vPredict_Cost[];
  10132. String vAlarm_info[];
  10133. String vRead_Date[];
  10134. String vRead_Day[];
  10135. String vV_Msg[];
  10136. String sMessage = "";
  10137. try
  10138. {
  10139. NodeList items = ele.getElementsByTagName("source");
  10140. Node item = items.item(0);
  10141. NamedNodeMap attrsParam = item.getAttributes();
  10142. for(int i=0; i< attrsParam.getLength(); i++)
  10143. {
  10144. Node attr = attrsParam.item(i);
  10145. if (attr.getNodeName().equalsIgnoreCase("name"))
  10146. sName = trimquotation(attr.getNodeValue());
  10147. else if (attr.getNodeName().equalsIgnoreCase("id_high"))
  10148. sId_High = trimquotation(attr.getNodeValue());
  10149. else if (attr.getNodeName().equalsIgnoreCase("id_low"))
  10150. sId_Low = trimquotation(attr.getNodeValue());
  10151. }
  10152. WallpadStatusData DBMGR = null;
  10153. DBMGR = new WallpadStatusData(getApplicationContext());
  10154. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10155. DBMGR.closeDB();
  10156. if((sName.equalsIgnoreCase("home") == true) &&
  10157. (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
  10158. (sId_Low.equalsIgnoreCase(addc.Ho) == true))
  10159. {
  10160. items = ele.getElementsByTagName("valuelist");
  10161. Log.d(TAG, "items.getLength() :" + items.getLength());
  10162. vName = new String[items.getLength()];
  10163. vTarget = new String[items.getLength()];
  10164. vTarget_Cost = new String[items.getLength()];
  10165. vUsed = new String[items.getLength()];
  10166. vUsed_Cost = new String[items.getLength()];
  10167. vPredict = new String[items.getLength()];
  10168. vPredict_Cost = new String[items.getLength()];
  10169. vAlarm_info = new String[items.getLength()];
  10170. vRead_Date = new String[items.getLength()];
  10171. vRead_Day = new String[items.getLength()];
  10172. vV_Msg = new String[items.getLength()];
  10173. for (int j = 0; j < items.getLength(); j++)
  10174. {
  10175. Log.d(TAG, "j :" + j);
  10176. item = items.item(j);
  10177. attrsParam = item.getAttributes();
  10178. Log.d(TAG, "attrsParam :" + attrsParam);
  10179. for(int i=0; i< attrsParam.getLength(); i++)
  10180. {
  10181. Node attr = attrsParam.item(i);
  10182. if(!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
  10183. (attr.getNodeName().equalsIgnoreCase("target") == true) ||
  10184. (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
  10185. (attr.getNodeName().equalsIgnoreCase("used") == true) ||
  10186. (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
  10187. (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
  10188. (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
  10189. (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
  10190. (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
  10191. (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
  10192. (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
  10193. ))
  10194. {
  10195. Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
  10196. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10197. retXML += " </service>\r\n</imap>";
  10198. return retXML;
  10199. }
  10200. if (attr.getNodeName().equalsIgnoreCase("name"))
  10201. {
  10202. vName[j] = trimquotation(attr.getNodeValue());
  10203. if(!((vName[j].equalsIgnoreCase("elect") == true) ||
  10204. (vName[j].equalsIgnoreCase("water") == true) ||
  10205. (vName[j].equalsIgnoreCase("gas") == true) ||
  10206. (vName[j].equalsIgnoreCase("heating") == true) ||
  10207. (vName[j].equalsIgnoreCase("hotwater") == true)
  10208. ))
  10209. {
  10210. Log.d(TAG, "vName[j] is wrong :" + vName[j]);
  10211. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10212. retXML += " </service>\r\n</imap>";
  10213. return retXML;
  10214. }
  10215. }
  10216. else if (attr.getNodeName().equalsIgnoreCase("target"))
  10217. vTarget[j] = trimquotation(attr.getNodeValue());
  10218. else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
  10219. vTarget_Cost[j] = trimquotation(attr.getNodeValue());
  10220. else if (attr.getNodeName().equalsIgnoreCase("used"))
  10221. vUsed[j] = trimquotation(attr.getNodeValue());
  10222. else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
  10223. vUsed_Cost[j] = trimquotation(attr.getNodeValue());
  10224. else if (attr.getNodeName().equalsIgnoreCase("predict"))
  10225. vPredict[j] = trimquotation(attr.getNodeValue());
  10226. else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
  10227. vPredict_Cost[j] = trimquotation(attr.getNodeValue());
  10228. else if (attr.getNodeName().equalsIgnoreCase("alarm_info"))
  10229. {
  10230. vAlarm_info[j] = trimquotation(attr.getNodeValue());
  10231. if(!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
  10232. (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
  10233. (vAlarm_info[j].equalsIgnoreCase("over") == true)
  10234. ))
  10235. {
  10236. Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
  10237. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10238. retXML += " </service>\r\n</imap>";
  10239. return retXML;
  10240. }
  10241. }
  10242. else if (attr.getNodeName().equalsIgnoreCase("read_date"))
  10243. {
  10244. vRead_Date[j] = trimquotation(attr.getNodeValue());
  10245. if(!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
  10246. (vRead_Date[j].equalsIgnoreCase("last_day") == true)
  10247. ))
  10248. {
  10249. Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
  10250. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10251. retXML += " </service>\r\n</imap>";
  10252. return retXML;
  10253. }
  10254. }
  10255. else if (attr.getNodeName().equalsIgnoreCase("read_day"))
  10256. vRead_Day[j] = trimquotation(attr.getNodeValue());
  10257. else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
  10258. vV_Msg[j] = trimquotation(attr.getNodeValue());
  10259. }
  10260. }
  10261. items = ele.getElementsByTagName("message");
  10262. item = items.item(0);
  10263. Node text = item.getFirstChild();
  10264. sMessage = trimquotation(text.getNodeValue());
  10265. /**데이터 전달**/
  10266. for(int i = 0; i<vName.length; i++)
  10267. {
  10268. Log.d(TAG, "vName["+i+"]: " + vName[i]);
  10269. Log.d(TAG, "vTarget"+i+"]: " + vTarget[i]);
  10270. Log.d(TAG, "vTarget_Cost["+i+"]: " + vTarget_Cost[i]);
  10271. Log.d(TAG, "vUsed["+i+"]: " + vUsed[i]);
  10272. Log.d(TAG, "vUsed_Cost["+i+"]: " + vUsed_Cost[i]);
  10273. Log.d(TAG, "vPredict["+i+"]: " + vPredict[i]);
  10274. Log.d(TAG, "vPredict_Cost["+i+"]: " + vPredict_Cost[i]);
  10275. Log.d(TAG, "vAlarm_info["+i+"]: " + vAlarm_info[i]);
  10276. Log.d(TAG, "vRead_Date["+i+"]: " + vRead_Date[i]);
  10277. Log.d(TAG, "vRead_Day["+i+"]: " + vRead_Day[i]);
  10278. Log.d(TAG, "vV_Msg["+i+"]: " + vV_Msg[i]);
  10279. }
  10280. Intent intent = new Intent();
  10281. intent.setAction(define.NOTIFY_ACNAME);
  10282. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  10283. for(int i = 0; i<vName.length; i++)
  10284. {
  10285. if(vName[i].equals("elect"))
  10286. {
  10287. intent.putExtra("elect_target", vTarget[i]);
  10288. intent.putExtra("elect_used", vUsed[i]);
  10289. intent.putExtra("elect_info", vAlarm_info[i]);
  10290. }
  10291. else if(vName[i].equals("water"))
  10292. {
  10293. intent.putExtra("water_target", vTarget[i]);
  10294. intent.putExtra("water_used", vUsed[i]);
  10295. intent.putExtra("water_info", vAlarm_info[i]);
  10296. }
  10297. else if(vName[i].equals("gas"))
  10298. {
  10299. intent.putExtra("gas_target", vTarget[i]);
  10300. intent.putExtra("gas_used", vUsed[i]);
  10301. intent.putExtra("gas_info", vAlarm_info[i]);
  10302. }
  10303. else if(vName[i].equals("heating"))
  10304. {
  10305. intent.putExtra("heating_target", vTarget[i]);
  10306. intent.putExtra("heating_used", vUsed[i]);
  10307. intent.putExtra("heating_info", vAlarm_info[i]);
  10308. }
  10309. else if(vName[i].equals("hotwater"))
  10310. {
  10311. intent.putExtra("hotwater_target", vTarget[i]);
  10312. intent.putExtra("hotwater_used", vUsed[i]);
  10313. intent.putExtra("hotwater_info", vAlarm_info[i]);
  10314. }
  10315. }
  10316. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
  10317. retXML += " <source name=\"home\" id_high=\""+sId_High+"\" id_low=\""+ sId_Low+"\" count=\""+vName.length+"\""+" s_msg=\"null\" />\r\n";
  10318. for(int i = 0; i<vName.length; i++)
  10319. {
  10320. retXML += " <valuelist name=\""+vName[i]+"\" alarm_info=\""+vAlarm_info[i]+"\" v_msg=\"null\" />\r\n";
  10321. }
  10322. retXML += " <message>\"null\"</message>\r\n";
  10323. retXML += " </service>\r\n</imap>";
  10324. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10325. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  10326. devSet.closeDB();
  10327. if (MetringDB != null)
  10328. {
  10329. try
  10330. {
  10331. String devInfo = MetringDB[1];
  10332. devInfo = devInfo.replace('(', '_');
  10333. devInfo = devInfo.replace(':', '_');
  10334. devInfo = devInfo.replace(')', '_');
  10335. String[] MetringInfo = devInfo.split("_");
  10336. // MetringInfo[1] -> 회로수
  10337. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  10338. // MetringInfo[4] -> IP
  10339. // MetringInfo[5] -> IP정보
  10340. // MetringInfo[6] -> 검침일사용자설정
  10341. // MetringInfo[7] -> 사용함 또는 사용안함
  10342. if(MetringInfo[3].equals("사용함") == true)
  10343. {
  10344. getApplicationContext().sendBroadcast(intent);
  10345. }
  10346. }
  10347. catch (RuntimeException re) {
  10348. LogUtil.errorLogInfo("", TAG, re);
  10349. }
  10350. catch (Exception e)
  10351. {
  10352. //e.printStackTrace();
  10353. LogUtil.errorLogInfo("", TAG, e);
  10354. }
  10355. }
  10356. else
  10357. {
  10358. }
  10359. return retXML;
  10360. }
  10361. else
  10362. {
  10363. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10364. retXML += " </service>\r\n</imap>";
  10365. return retXML;
  10366. }
  10367. }
  10368. catch (RuntimeException re) {
  10369. LogUtil.errorLogInfo("", TAG, re);
  10370. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10371. retXML += " </service>\r\n</imap>";
  10372. return retXML;
  10373. }
  10374. catch (Exception e)
  10375. {
  10376. //e.printStackTrace();
  10377. LogUtil.errorLogInfo("", TAG, e);
  10378. retXML= XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
  10379. retXML += " </service>\r\n</imap>";
  10380. return retXML;
  10381. }
  10382. }
  10383. public String ProcCheckCallOption()
  10384. {
  10385. int[] resultDB = {0, 0};
  10386. String retXML = "";
  10387. String sOption = "sip";
  10388. String sMessage = "null";
  10389. try
  10390. {
  10391. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  10392. resultDB = devSet.Get_Handicapped_Mode();
  10393. devSet.closeDB();
  10394. if(resultDB[0] == 0)
  10395. {
  10396. //장애인모드 사용 안함
  10397. }
  10398. else if (resultDB[0] == 1)
  10399. {
  10400. //장애인모드 사용함
  10401. }
  10402. switch(resultDB[1])
  10403. {
  10404. case 0: //일반모드
  10405. sOption = "sip";
  10406. break;
  10407. case 1: //청각장애인
  10408. sOption = "deaf";
  10409. break;
  10410. case 2: //시각장애인
  10411. sOption = "blind";
  10412. break;
  10413. default:
  10414. break;
  10415. }
  10416. if(resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
  10417. {
  10418. //본 구문에 들어올수 없음
  10419. sOption = "none";
  10420. }
  10421. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
  10422. retXML += " <option>\""+sOption+"\"</option>\r\n";
  10423. retXML += " <message>\""+sMessage+"\"</message>\r\n";
  10424. retXML += " </service>\r\n</imap>";
  10425. return retXML;
  10426. }
  10427. catch (RuntimeException re) {
  10428. LogUtil.errorLogInfo("", TAG, re);
  10429. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10430. retXML += " </service>\r\n</imap>";
  10431. return retXML;
  10432. }
  10433. catch (Exception e)
  10434. {
  10435. //e.printStackTrace();
  10436. LogUtil.errorLogInfo("", TAG, e);
  10437. retXML= XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
  10438. retXML += " </service>\r\n</imap>";
  10439. return retXML;
  10440. }
  10441. }
  10442. public String ProcChatSequence(Element ele)
  10443. {
  10444. String retXML = "";
  10445. String sFrom = "error";
  10446. String sTo = "error";
  10447. String sContact = "error";
  10448. String sSequence = "error";
  10449. String sStatus = "error";
  10450. String sMessage = "error";
  10451. String reply_Sequence = "error";
  10452. String reply_Status = "error";
  10453. String reply_Message = "null";
  10454. try
  10455. {
  10456. NodeList items = ele.getElementsByTagName("sequence");
  10457. Node item = items.item(0);
  10458. NamedNodeMap attrsParam = item.getAttributes();
  10459. sSequence = trimquotation(item.getTextContent());
  10460. ///////////////////////////////////////////////
  10461. items = ele.getElementsByTagName("status");
  10462. item = items.item(0);
  10463. attrsParam = item.getAttributes();
  10464. sStatus = trimquotation(item.getTextContent());
  10465. ///////////////////////////////////////////////
  10466. items = ele.getElementsByTagName("message");
  10467. item = items.item(0);
  10468. attrsParam = item.getAttributes();
  10469. sMessage = trimquotation(item.getTextContent());
  10470. ///////////////////////////////////////////////
  10471. items = ele.getElementsByTagName("from");
  10472. item = items.item(0);
  10473. attrsParam = item.getAttributes();
  10474. sFrom = trimquotation(item.getTextContent());
  10475. ///////////////////////////////////////////////
  10476. items = ele.getElementsByTagName("to");
  10477. item = items.item(0);
  10478. attrsParam = item.getAttributes();
  10479. sTo = trimquotation(item.getTextContent());
  10480. ///////////////////////////////////////////////
  10481. items = ele.getElementsByTagName("contact");
  10482. item = items.item(0);
  10483. attrsParam = item.getAttributes();
  10484. sContact = trimquotation(item.getTextContent());
  10485. ///////////////////////////////////////////////
  10486. if(!((sSequence.equalsIgnoreCase("try") == true) ||
  10487. (sSequence.equalsIgnoreCase("start") == true) ||
  10488. (sSequence.equalsIgnoreCase("quit") == true) ||
  10489. (sSequence.equalsIgnoreCase("cancel") == true) ||
  10490. (sSequence.equalsIgnoreCase("ok") == true) ||
  10491. (sSequence.equalsIgnoreCase("busy") == true) ||
  10492. (sSequence.equalsIgnoreCase("busy_sip") == true) ||
  10493. (sSequence.equalsIgnoreCase("reject") == true)
  10494. ))
  10495. {
  10496. Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
  10497. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10498. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  10499. retXML += " </service>\r\n</imap>";
  10500. return retXML;
  10501. }
  10502. if(!((sStatus.equalsIgnoreCase("idle") == true) ||
  10503. (sStatus.equalsIgnoreCase("ringing") == true) ||
  10504. (sStatus.equalsIgnoreCase("talking") == true)
  10505. ))
  10506. {
  10507. Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
  10508. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10509. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  10510. retXML += " </service>\r\n</imap>";
  10511. return retXML;
  10512. }
  10513. //입력값 처리 필요!!
  10514. //김용성 과장님 작업필요
  10515. //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
  10516. //확인 하시고 위 정보 확인해주세요.
  10517. Log.d(TAG, "sFrom:" + sFrom);
  10518. Log.d(TAG, "sTo:" + sTo);
  10519. Log.d(TAG, "Contact:" + sContact);
  10520. Log.d(TAG, "sSequence:" + sSequence);
  10521. Log.d(TAG, "sStatus:" + sStatus);
  10522. if(sSequence.equalsIgnoreCase("try") == true)
  10523. {
  10524. //채팅 요청
  10525. }
  10526. else if(sSequence.equalsIgnoreCase("start") == true)
  10527. {
  10528. //채팅 시작
  10529. }
  10530. else if(sSequence.equalsIgnoreCase("quit") == true)
  10531. {
  10532. //채팅 종료
  10533. }
  10534. else if(sSequence.equalsIgnoreCase("cancel") == true)
  10535. {
  10536. //취소
  10537. }
  10538. else if(sSequence.equalsIgnoreCase("ok") == true)
  10539. {
  10540. //요청확인
  10541. }
  10542. else if(sSequence.equalsIgnoreCase("busy") == true)
  10543. {
  10544. //통화중
  10545. }
  10546. else if(sSequence.equalsIgnoreCase("busy_sip") == true)
  10547. {
  10548. //SIP 통화중
  10549. }
  10550. else if(sSequence.equalsIgnoreCase("reject") == true)
  10551. {
  10552. //거절
  10553. }
  10554. if(sStatus.equalsIgnoreCase("idle") == true)
  10555. {
  10556. //대기
  10557. }
  10558. else if(sStatus.equalsIgnoreCase("ringing") == true)
  10559. {
  10560. //연결중
  10561. }
  10562. else if(sStatus.equalsIgnoreCase("talking") == true)
  10563. {
  10564. //통화중
  10565. }
  10566. //응답값 입력 필요!!
  10567. //김용성 과장님 작업필요
  10568. reply_Message = "null";
  10569. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
  10570. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  10571. retXML += " </service>\r\n</imap>";
  10572. return retXML;
  10573. }
  10574. catch (RuntimeException re) {
  10575. LogUtil.errorLogInfo("", TAG, re);
  10576. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10577. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  10578. retXML += " </service>\r\n</imap>";
  10579. return retXML;
  10580. }
  10581. catch (Exception e)
  10582. {
  10583. //e.printStackTrace();
  10584. LogUtil.errorLogInfo("", TAG, e);
  10585. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
  10586. retXML += " <message>\""+reply_Message+"\"</message>\r\n";
  10587. retXML += " </service>\r\n</imap>";
  10588. return retXML;
  10589. }
  10590. }
  10591. public String ProcChatMessage(Element ele)
  10592. {
  10593. String retXML = "";
  10594. String sChatMessage = "error";
  10595. String sMessage = "error";
  10596. try
  10597. {
  10598. NodeList items = ele.getElementsByTagName("chat");
  10599. Node item = items.item(0);
  10600. NamedNodeMap attrsParam = item.getAttributes();
  10601. sChatMessage = trimquotation(item.getTextContent());
  10602. ///////////////////////////////////////////////
  10603. items = ele.getElementsByTagName("message");
  10604. item = items.item(0);
  10605. attrsParam = item.getAttributes();
  10606. sMessage = trimquotation(item.getTextContent());
  10607. ///////////////////////////////////////////////
  10608. //test
  10609. Log.d(TAG, "sChatMessage is " + sChatMessage);
  10610. Log.d(TAG, "sMessage is " + sMessage);
  10611. //test
  10612. Intent intent = new Intent();
  10613. intent.setAction(define.NOTIFY_ACNAME);
  10614. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
  10615. intent.putExtra("CHAT_MESSAGE", sChatMessage);
  10616. intent.putExtra("ADD_MESSAGE", sMessage);
  10617. getApplicationContext().sendBroadcast(intent);
  10618. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
  10619. retXML += " <message>\""+"null"+"\"</message>\r\n";
  10620. retXML += " </service>\r\n</imap>";
  10621. return retXML;
  10622. }
  10623. catch (RuntimeException re) {
  10624. LogUtil.errorLogInfo("", TAG, re);
  10625. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10626. retXML += " </service>\r\n</imap>";
  10627. return retXML;
  10628. }
  10629. catch (Exception e)
  10630. {
  10631. //e.printStackTrace();
  10632. LogUtil.errorLogInfo("", TAG, e);
  10633. retXML= XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
  10634. retXML += " </service>\r\n</imap>";
  10635. return retXML;
  10636. }
  10637. }
  10638. public String ProcEvacuationLadderOpen(Element ele)
  10639. {
  10640. String retXML = "";
  10641. try
  10642. {
  10643. String sDong = null;
  10644. String sHo = null;
  10645. NodeList items = ele.getElementsByTagName("home_info");
  10646. Node item = items.item(0);
  10647. NamedNodeMap attrsParam = item.getAttributes();
  10648. for(int i=0; i< attrsParam.getLength(); i++)
  10649. {
  10650. Node attr = attrsParam.item(i);
  10651. if (attr.getNodeName().equalsIgnoreCase("dong"))
  10652. sDong = trimquotation(attr.getNodeValue());
  10653. else if (attr.getNodeName().equalsIgnoreCase("ho"))
  10654. sHo = trimquotation(attr.getNodeValue());
  10655. }
  10656. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  10657. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  10658. deviceSet.closeDB();
  10659. Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
  10660. WallpadStatusData DBMGR = null;
  10661. DBMGR = new WallpadStatusData(getApplicationContext());
  10662. AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
  10663. DBMGR.closeDB();
  10664. String myIP =addc.IPAddress;
  10665. String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
  10666. String[] SplitedString = myIP.split("\\.");
  10667. if(SplitedString != null)
  10668. {
  10669. if(SplitedString.length == 4)
  10670. {
  10671. int temp = Integer.parseInt(SplitedString[2]);
  10672. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER) temp = temp - 1;
  10673. else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW) temp = temp + 1;
  10674. String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
  10675. Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
  10676. temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
  10677. DestStair = String.valueOf(temp);
  10678. }
  10679. }
  10680. if ((sDong!=null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo!=null && sHo.equalsIgnoreCase(DestStair) == true))
  10681. {
  10682. /**
  10683. * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
  10684. * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
  10685. * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
  10686. * **/
  10687. WallpadDeviceSet devset;
  10688. devset = new WallpadDeviceSet(getApplicationContext());
  10689. int StatusVal = devset.GetDeviceSetted("피난사다리");
  10690. devset.closeDB();
  10691. if ( StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  10692. {
  10693. /**
  10694. * 피난사다리 알림!!!
  10695. * **/
  10696. ReceiveNetworkLadderBr(ladderDownSend);
  10697. }
  10698. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
  10699. retXML += " </service>\r\n</imap>";
  10700. return retXML;
  10701. }
  10702. else
  10703. {
  10704. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  10705. retXML += " </service>\r\n</imap>";
  10706. return retXML;
  10707. }
  10708. }
  10709. catch (RuntimeException re) {
  10710. LogUtil.errorLogInfo("", TAG, re);
  10711. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  10712. retXML += " </service>\r\n</imap>";
  10713. return retXML;
  10714. }
  10715. catch (Exception e)
  10716. {
  10717. //e.printStackTrace();
  10718. LogUtil.errorLogInfo("", TAG, e);
  10719. retXML= XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
  10720. retXML += " </service>\r\n</imap>";
  10721. return retXML;
  10722. }
  10723. }
  10724. private void ReceiveNetworkLadderBr(int val)
  10725. {
  10726. int base = 7000;
  10727. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  10728. int Menu_Start_Option = 1;
  10729. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  10730. int AlarmStatus = wdb.GetAlarmStatus();
  10731. wdb.closeDB();
  10732. boolean MgrAppRun = false;
  10733. final String packageNameMgr = "com.artncore.managersetting";
  10734. MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
  10735. if( MgrAppRun )
  10736. return;
  10737. if (AlarmStatus == WallpadStatusData.ALARM_ARISE ||AlarmStatus == WallpadStatusData.ALARM_STOP) return;
  10738. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10739. int StatusVal = devset.GetDeviceSetted("피난사다리");
  10740. devset.closeDB();
  10741. if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
  10742. Common.SendAppFinishReqBR(getApplicationContext());
  10743. Intent newintent = new Intent(Intent.ACTION_MAIN);
  10744. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  10745. newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  10746. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  10747. if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER) newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  10748. else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW) newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
  10749. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  10750. newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  10751. getApplicationContext().startActivity(newintent);
  10752. }
  10753. }
  10754. /**
  10755. * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
  10756. * @param ele Element Xml 데이터
  10757. * @return String 타입의 응답 메시지 생성
  10758. * **/
  10759. public String SmartLightDetailInfo(Element ele)
  10760. {
  10761. iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
  10762. return imapSmartLightInfo.SmartLightDetailInfo(ele);
  10763. }
  10764. /**
  10765. * KNX 시스템 상태 응답(서버 요청에 대한 응답)
  10766. * @param ele Element Xml 데이터
  10767. * @return String 타입의 응답 메시지 생성
  10768. * **/
  10769. public String KNXDeviceDetailInfo(Element ele) {
  10770. iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
  10771. return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
  10772. }
  10773. public String ProcSetServerChange(Element ele) {
  10774. String retXML = "";
  10775. String versionTXT = null;
  10776. try {
  10777. boolean bRet = false;
  10778. NodeList items = ele.getElementsByTagName("ver_server");
  10779. Node item = items.item(0);
  10780. Node text = item.getFirstChild();
  10781. versionTXT = trimquotation(text.getNodeValue());
  10782. if (versionTXT.equalsIgnoreCase("1.0")) {
  10783. bRet = true;
  10784. }
  10785. else if ( versionTXT.indexOf("2.") >= 0) {
  10786. bRet = true;
  10787. }
  10788. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10789. if (SetData != null && bRet == true) {
  10790. SetData.SetServerVer(versionTXT);
  10791. SetData.closeDB();
  10792. }
  10793. if (bRet == true) {
  10794. try {
  10795. iMapSverReload tSock = new iMapSverReload();
  10796. tSock.start();
  10797. } catch (IOException e) {
  10798. Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
  10799. //e.printStackTrace();
  10800. LogUtil.errorLogInfo("", TAG, e);
  10801. }
  10802. }
  10803. // 버전 체크해서
  10804. // 응답하고 나서
  10805. // 수신부 쓰레드 재 로딩..
  10806. if (versionTXT != null && bRet == true) {
  10807. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
  10808. retXML += " </service>\r\n</imap>";
  10809. return retXML;
  10810. }
  10811. else {
  10812. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10813. retXML += " </service>\r\n</imap>";
  10814. return retXML;
  10815. }
  10816. } catch (RuntimeException re) {
  10817. LogUtil.errorLogInfo("", TAG, re);
  10818. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10819. retXML += " </service>\r\n</imap>";
  10820. return retXML;
  10821. }
  10822. catch (Exception e) {
  10823. //e.printStackTrace();
  10824. LogUtil.errorLogInfo("", TAG, e);
  10825. retXML= XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
  10826. retXML += " </service>\r\n</imap>";
  10827. return retXML;
  10828. }
  10829. }
  10830. // 메인 서버 소켓 클래스
  10831. public class iMapSverReload extends Thread {
  10832. ServerSocket svr;
  10833. public iMapSverReload() throws IOException {
  10834. /////////////////////////////////////////////////////////////////////
  10835. // 신형 단지서버 사용 유무를 가져온다.
  10836. /////////////////////////////////////////////////////////////////////
  10837. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  10838. if (SetData != null) {
  10839. String serverVesionInfo = SetData.GetServerVer();
  10840. SetData.closeDB();
  10841. if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
  10842. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10843. boolean retValue = devset.SetSubDevListItem( false , define.DEVICE_ID_NEW_DANJI_SERVER);
  10844. devset.closeDB();
  10845. }
  10846. else {
  10847. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  10848. boolean retValue = false;
  10849. if(devset.GetNewDanjiServer() == define.DanjiServerBlended)
  10850. {
  10851. Log.d(TAG, "ReSetting DB Version Blended");
  10852. devset.UpdateSettingData("subdev_list"
  10853. , define.DEVICE_ID_NEW_DANJI_SERVER
  10854. , 0
  10855. , "1(1:신형단지서버(사용함)종류(Blended))"
  10856. );
  10857. //devset.setSettingDataSubDev(MainDatabaseManager.SETTING_ITEM_SUB_DEVICE_NEWSERVER, 0, value)
  10858. //retValue = devset.SetSubDevListItem( true , define.DEVICE_ID_NEW_DANJI_SERVER);
  10859. }
  10860. else
  10861. {
  10862. Log.d(TAG, "ReSetting DB Version 2.0");
  10863. retValue = devset.SetSubDevListItem( true , define.DEVICE_ID_NEW_DANJI_SERVER);
  10864. }
  10865. devset.closeDB();
  10866. }
  10867. }
  10868. try {
  10869. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  10870. // mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  10871. danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  10872. wallpadDeviceSet.closeDB();
  10873. } catch (RuntimeException re) {
  10874. LogUtil.errorLogInfo("", TAG, re);
  10875. danjiserverType = define.DanjiServer1;
  10876. }
  10877. catch (Exception e) {
  10878. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  10879. //e.printStackTrace();
  10880. LogUtil.errorLogInfo("", TAG, e);
  10881. danjiserverType = define.DanjiServer1;
  10882. }
  10883. Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + danjiserverType );
  10884. // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
  10885. // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
  10886. // 관리 PC IP도 변경하도록 한다.
  10887. if (danjiserverType != 0) {
  10888. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  10889. wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
  10890. wallpadStatusData.closeDB();
  10891. }
  10892. else {
  10893. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  10894. wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
  10895. wallpadStatusData.closeDB();
  10896. }
  10897. Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + danjiserverType);
  10898. }
  10899. public void run() {
  10900. try {
  10901. try{ Thread.sleep(400); }
  10902. catch (RuntimeException re) {
  10903. LogUtil.errorLogInfo("", TAG, re);
  10904. }
  10905. catch (Exception e){
  10906. LogUtil.errorLogInfo("", TAG, e);
  10907. }
  10908. if(danji_mix!=null)
  10909. {
  10910. danji_mix.destoryThread();
  10911. }
  10912. SvrSock.destoryThread();
  10913. for( int i = 0 ; i < 20 ; i++ )
  10914. {
  10915. if( SvrSock.isAlive() == false )
  10916. {
  10917. Log.d(TAG, " Receive Socket Reload i = : " + i );
  10918. break;
  10919. }
  10920. else
  10921. {
  10922. Log.d(TAG, " is Live Socket Reload i = : " + i );
  10923. }
  10924. if(danji_mix!=null)
  10925. {
  10926. if( danji_mix.isAlive() == false )
  10927. {
  10928. Log.d(TAG, " Mix Receive Socket Reload i = : " + i );
  10929. break;
  10930. }
  10931. }
  10932. try{ Thread.sleep(100); }
  10933. catch (RuntimeException re) {
  10934. LogUtil.errorLogInfo("", TAG, re);
  10935. }
  10936. catch (Exception e){
  10937. LogUtil.errorLogInfo("", TAG, e);
  10938. }
  10939. }
  10940. SvrSock = new iMapSverSocket();
  10941. SvrSock.start();
  10942. // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
  10943. try{ Thread.sleep(3000); }
  10944. catch (RuntimeException re) {
  10945. LogUtil.errorLogInfo("", TAG, re);
  10946. }
  10947. catch (Exception e){
  10948. LogUtil.errorLogInfo("", TAG, e);
  10949. }
  10950. try
  10951. {
  10952. Intent intent = new Intent();
  10953. intent.setAction(define.NOTIFY_ACNAME);
  10954. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
  10955. getApplicationContext().sendBroadcast(intent);
  10956. }
  10957. catch (RuntimeException re) {
  10958. LogUtil.errorLogInfo("", TAG, re);
  10959. }
  10960. catch (Exception e)
  10961. {
  10962. //e.printStackTrace();
  10963. LogUtil.errorLogInfo("", TAG, e);
  10964. }
  10965. } catch (IOException e) {
  10966. //e.printStackTrace();
  10967. LogUtil.errorLogInfo("", TAG, e);
  10968. }
  10969. }
  10970. }
  10971. public static final int SCHEDULE_START_HEARTBEAT = 30000;
  10972. public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
  10973. public static final int SCHEDULE_START_STATUSBEAT = 30002;
  10974. public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
  10975. public static final int SCHEDULE_START_CALLAPP = 30004;
  10976. public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
  10977. public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
  10978. public class SchedulerThread extends Thread
  10979. {
  10980. boolean doRun;
  10981. AddressSet addr;
  10982. String AddressStr;
  10983. String IPaddr;
  10984. String VerBSP = "";
  10985. String VerAPP;
  10986. String VerSetting;
  10987. String VerNews;
  10988. String VerWeather;
  10989. int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
  10990. List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
  10991. private jni mGleInterface = null;
  10992. private final int LIVE_SIGNAL_TIME = 20;
  10993. private int m_LiveSignalCount = 0;
  10994. private int m_MainAppLiveCount = 0;
  10995. Handler ScheDuleHandler = new Handler(){
  10996. public void handleMessage(Message msg) {
  10997. switch (msg.what) {
  10998. case SCHEDULE_START_HEARTBEAT:
  10999. {
  11000. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
  11001. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11002. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11003. DBMGR.closeDB();
  11004. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11005. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11006. }
  11007. break;
  11008. case SCHEDULE_CHANGE_HEARTBEAT:
  11009. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
  11010. synchronized (ScheduleList) {
  11011. ScheduleData CheckData;
  11012. for (int i = 0; i < ScheduleList.size(); i++) {
  11013. CheckData = ScheduleList.get(i);
  11014. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
  11015. Calendar cal = new GregorianCalendar();
  11016. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11017. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11018. DBMGR.closeDB();
  11019. cal.add(Calendar.MINUTE,heartbeatP);
  11020. CheckData.TData = cal;
  11021. ScheduleList.set(i, CheckData);
  11022. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11023. return;
  11024. }
  11025. }
  11026. }
  11027. reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
  11028. doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11029. break;
  11030. case SCHEDULE_START_STATUSBEAT:
  11031. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
  11032. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11033. break;
  11034. case SCHEDULE_CHANGE_STATUSBEAT:
  11035. Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
  11036. synchronized(ScheduleList) {
  11037. ScheduleData CheckData;
  11038. for (int i = 0; i < ScheduleList.size(); i++) {
  11039. CheckData = ScheduleList.get(i);
  11040. if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
  11041. Calendar cal = new GregorianCalendar();
  11042. cal.add(Calendar.MINUTE,heartbeatP);
  11043. CheckData.TData = cal;
  11044. ScheduleList.set(i, CheckData);
  11045. doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11046. return;
  11047. }
  11048. }
  11049. }
  11050. break;
  11051. case SCHEDULE_START_CALLAPP:
  11052. // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
  11053. // Bundle bundle = new Bundle();
  11054. // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
  11055. // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
  11056. // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
  11057. // .putExtra(ITEM_CALL_DATA, bundle);
  11058. // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  11059. // iMAPstartActivity(intent);
  11060. break;
  11061. }
  11062. }
  11063. };
  11064. Handler GetHandler(){
  11065. return ScheDuleHandler;
  11066. }
  11067. public class ScheduleData
  11068. {
  11069. Calendar TData;
  11070. String ActionSTR;
  11071. public ScheduleData(Calendar tdata, String ActionStr)
  11072. {
  11073. TData = tdata;
  11074. ActionSTR = ActionStr;
  11075. }
  11076. }
  11077. public SchedulerThread()
  11078. {
  11079. doRun = true;
  11080. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11081. addr = DBMGR.getAddressMGR();
  11082. VerAPP = DBMGR.GetAPPVer();
  11083. VerSetting = DBMGR.GetSettingVer();
  11084. VerNews = DBMGR.GetNoticeVer();
  11085. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11086. DBMGR.closeDB();
  11087. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  11088. {
  11089. try { mGleInterface = new jni(); }
  11090. catch (RuntimeException re) {
  11091. LogUtil.errorLogInfo("", TAG, re);
  11092. }
  11093. catch (Exception e) {
  11094. Log.e( "iMapServer" ,"[ExceptionError] - onCreate->mGleInterface Create : " + e);
  11095. }
  11096. }
  11097. if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT))
  11098. {
  11099. VerAPP = GetAppVersion();
  11100. }
  11101. AddressStr = addr.Dong+"동"+addr.Ho+"호";
  11102. IPaddr = addr.IPAddress;
  11103. ScheDulerHandler = ScheDuleHandler;
  11104. }
  11105. public void reg_schedule(int min, String Action)
  11106. {
  11107. for (int i = 0; i <ScheduleList.size();i++)
  11108. {
  11109. ScheduleData scdata = ScheduleList.get(i);
  11110. if (scdata.ActionSTR.equals(Action))
  11111. {
  11112. ScheduleList.remove(i);
  11113. break;
  11114. }
  11115. }
  11116. Calendar cal = new GregorianCalendar();
  11117. cal.add(Calendar.MINUTE,min);
  11118. ScheduleData regData = new ScheduleData(cal,Action );
  11119. synchronized(ScheduleList)
  11120. {
  11121. ScheduleList.add(regData);
  11122. }
  11123. }
  11124. private void doSchedule(String doing)
  11125. {
  11126. String[] doingData = doing.split(";");
  11127. if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT))
  11128. {
  11129. try{
  11130. String SendingStr = MakeHeartbeat();
  11131. SendToServer(SendingStr);
  11132. Calendar cal = new GregorianCalendar();
  11133. 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));
  11134. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11135. DBMGR.SetLastHeartbeat(timedata);
  11136. heartbeatP = DBMGR.GetHeartbeatPeriod();
  11137. DBMGR.closeDB();
  11138. }
  11139. catch (RuntimeException re) {
  11140. LogUtil.errorLogInfo("", TAG, re);
  11141. }
  11142. catch (Exception e)
  11143. {
  11144. //e.printStackTrace();
  11145. LogUtil.errorLogInfo("", TAG, e);
  11146. }
  11147. }
  11148. else if (doingData[0].equals("UPDATETIME"))
  11149. {
  11150. }
  11151. else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT))
  11152. {
  11153. // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
  11154. if (!Common.getDeviceServeiceLoadComplite()) return;
  11155. String SendingStr = MakeStatusReport();
  11156. if (SendingStr == null) return;
  11157. SendToServer(SendingStr);
  11158. Calendar cal = new GregorianCalendar();
  11159. 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));
  11160. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11161. DBMGR.SetLastStatusbeat(timedata);
  11162. DBMGR.closeDB();
  11163. int StatusP = 720;
  11164. try {
  11165. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11166. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11167. devset.closeDB();
  11168. if (StatusVal == null) StatusP = 720;
  11169. else StatusP = Integer.parseInt(StatusVal[1]);
  11170. }
  11171. catch (RuntimeException re) {
  11172. LogUtil.errorLogInfo("", TAG, re);
  11173. }
  11174. catch (Exception e)
  11175. {
  11176. //e.printStackTrace();
  11177. LogUtil.errorLogInfo("", TAG, e);
  11178. }
  11179. reg_schedule(StatusP,SCHEDULE_ACTION_STATUSBEAT);
  11180. }
  11181. }
  11182. private String MakeHeartbeat() {
  11183. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11184. VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
  11185. VerNews = DBMGR.GetNoticeVer();
  11186. VerSetting = DBMGR.GetSettingVer();
  11187. String VerServer = DBMGR.GetServerVer();
  11188. DBMGR.closeDB();
  11189. if (VerServer == null) {
  11190. Log.d(TAG, "VerServer null");
  11191. VerServer = "1.0";
  11192. }
  11193. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11194. int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
  11195. wallpadDeviceSet.closeDB();
  11196. if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
  11197. // 스마트 분전반
  11198. WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
  11199. WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
  11200. String retStr = XMLHeader+
  11201. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  11202. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  11203. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  11204. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  11205. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  11206. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  11207. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  11208. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  11209. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  11210. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  11211. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11212. "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n"+
  11213. "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n"+
  11214. "</service>\r\n</imap>";
  11215. return retStr;
  11216. }
  11217. else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
  11218. // TODO KNX 분전반
  11219. // String retStr = XMLHeader+
  11220. // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
  11221. // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
  11222. // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
  11223. // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
  11224. // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
  11225. // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
  11226. // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
  11227. // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
  11228. // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
  11229. // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
  11230. // "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11231. // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
  11232. // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
  11233. // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
  11234. // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
  11235. // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
  11236. // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
  11237. // "</service>\r\n</imap>";
  11238. String retStr = XMLHeader+
  11239. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  11240. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  11241. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  11242. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  11243. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  11244. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  11245. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  11246. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  11247. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  11248. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  11249. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11250. "</service>\r\n</imap>";
  11251. return retStr;
  11252. }
  11253. else {
  11254. String retStr = XMLHeader+
  11255. "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n"+
  11256. "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n"+
  11257. "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n"+
  11258. "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n"+
  11259. "<ver_news>\"" + VerNews + "\"</ver_news>\r\n"+
  11260. "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n"+
  11261. "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n"+
  11262. "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n"+
  11263. "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n"+
  11264. "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n"+
  11265. "<ver_server>" + VerServer + "</ver_server>\r\n"+
  11266. "</service>\r\n</imap>";
  11267. return retStr;
  11268. }
  11269. }
  11270. public String GetAppVersion() {
  11271. PackageInfo pi = null;
  11272. try {
  11273. pi = getPackageManager().getPackageInfo(getPackageName(), 0);
  11274. }
  11275. catch (RuntimeException re) {
  11276. LogUtil.errorLogInfo("", TAG, re);
  11277. }
  11278. catch (Exception e) {
  11279. LogUtil.errorLogInfo("", TAG, e);
  11280. }
  11281. return pi.versionName;
  11282. }
  11283. boolean isAlawaysrun = true;
  11284. public void run()
  11285. {
  11286. while(/*doRun*/ isAlawaysrun)
  11287. {
  11288. //Common.DebugLog("SchedulerThread ------ 10Sec");
  11289. CheckHeartBeat();
  11290. CheckStatusBeat();
  11291. CheckWallPadLiveSignal();
  11292. LiveCheckRebooting();
  11293. try { Thread.sleep(10000);}
  11294. catch (RuntimeException re) {
  11295. LogUtil.errorLogInfo("", TAG, re);
  11296. }
  11297. catch (Exception e) {
  11298. LogUtil.errorLogInfo("", TAG, e);
  11299. }
  11300. }
  11301. }
  11302. public void SetLive() {
  11303. m_MainAppLiveCount++;
  11304. }
  11305. private int CheckTime30Sec = 0 ;
  11306. private void LiveCheckRebooting() {
  11307. try {
  11308. CheckTime30Sec++;
  11309. if (CheckTime30Sec%20 == 0) {
  11310. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  11311. // // 10초마다 수행되는 함수이니....
  11312. // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
  11313. // if (m_MainAppLiveCount == 0) {
  11314. // //리셋
  11315. // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
  11316. // {
  11317. // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
  11318. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  11319. // pm.userActivity(8, true);
  11320. // }
  11321. // else
  11322. // {
  11323. // Log.d(TAG, "Main App Down Reset IHN_750");
  11324. // WallPadInterface wpdifc = new WallPadInterface();
  11325. // wpdifc.WachdogSystemReset();
  11326. // }
  11327. // }
  11328. // }
  11329. CheckTime30Sec = 0;
  11330. }
  11331. if( CheckTime30Sec >= 30000)
  11332. {
  11333. CheckTime30Sec = 0;
  11334. }
  11335. }
  11336. catch (RuntimeException re) {
  11337. LogUtil.errorLogInfo("", TAG, re);
  11338. }
  11339. catch (Exception e )
  11340. {
  11341. //e.printStackTrace();
  11342. LogUtil.errorLogInfo("", TAG, e);
  11343. }
  11344. }
  11345. private void CheckWallPadLiveSignal()
  11346. {
  11347. try
  11348. {
  11349. int nTime = LIVE_SIGNAL_TIME / 10;
  11350. m_LiveSignalCount++;
  11351. if( m_LiveSignalCount >= nTime )
  11352. {
  11353. m_LiveSignalCount = 0;
  11354. Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
  11355. }
  11356. }
  11357. catch (RuntimeException re) {
  11358. LogUtil.errorLogInfo("", TAG, re);
  11359. }
  11360. catch (Exception e )
  11361. {
  11362. Log.e("imapServer" , "CheckWallPadLiveSignal Exeption :" + e);
  11363. }
  11364. }
  11365. protected void CheckStatusBeat()
  11366. {
  11367. try {
  11368. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11369. String statusbeatdata = WPD.GetLastStatusbeat();
  11370. WPD.closeDB();
  11371. int StatusP = 720;
  11372. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  11373. String[] StatusVal = devset.GetSettingData("statusbeat_time");
  11374. if (StatusVal == null) StatusP = 720;
  11375. else
  11376. StatusP = Integer.parseInt(StatusVal[1]);
  11377. devset.closeDB();
  11378. if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
  11379. }
  11380. catch (RuntimeException re) {
  11381. LogUtil.errorLogInfo("", TAG, re);
  11382. }
  11383. catch (Exception e)
  11384. {
  11385. //e.printStackTrace();
  11386. LogUtil.errorLogInfo("", TAG, e);
  11387. }
  11388. }
  11389. protected void CheckHeartBeat()
  11390. {
  11391. try {
  11392. WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
  11393. String heartbeatdata = WPD.GetLastHeartbeat();
  11394. int heartbeatPer = WPD.GetHeartbeatPeriod();
  11395. WPD.closeDB();
  11396. if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
  11397. }
  11398. catch (RuntimeException re) {
  11399. LogUtil.errorLogInfo("", TAG, re);
  11400. }
  11401. catch (Exception e)
  11402. {
  11403. //e.printStackTrace();
  11404. LogUtil.errorLogInfo("", TAG, e);
  11405. }
  11406. }
  11407. protected boolean CheckTime(String CheckT, int period)
  11408. {
  11409. Calendar last = new GregorianCalendar();
  11410. String[] timedata = CheckT.split("[.]");
  11411. last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
  11412. last.set(Calendar.MONTH, Integer.parseInt(timedata[1])-1);
  11413. last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
  11414. last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
  11415. last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
  11416. last.add(Calendar.MINUTE, period);
  11417. Calendar checkCal = new GregorianCalendar();
  11418. //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
  11419. if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
  11420. return true;
  11421. return false;
  11422. }
  11423. }
  11424. class SendMSGToSVR extends Thread
  11425. {
  11426. String sendmsg;
  11427. public SendMSGToSVR(String msg)
  11428. {
  11429. sendmsg = msg;
  11430. }
  11431. public void run()
  11432. {
  11433. Socket sock = null;
  11434. DataOutputStream outstream = null;
  11435. try {
  11436. // 신형 단지서버 사용 유무를 가져온다.
  11437. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  11438. // boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  11439. boolean bNewDanjiServer = false;
  11440. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  11441. if(danjiserverType == 1)
  11442. {
  11443. bNewDanjiServer = false;
  11444. }
  11445. else if(danjiserverType == 2)
  11446. {
  11447. bNewDanjiServer = true;
  11448. }
  11449. else
  11450. {
  11451. bNewDanjiServer = true;
  11452. }
  11453. wallpadDeviceSet.closeDB();
  11454. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  11455. SVRIP = DBMGR.GetServerIP();
  11456. port = DBMGR.GetServerPort();
  11457. DBMGR.closeDB();
  11458. /////////////////////////////////////////////////////////////////////
  11459. // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
  11460. // 사용중일 경우 암호화 소켓을 생성한다.
  11461. /////////////////////////////////////////////////////////////////////
  11462. if(!bNewDanjiServer)
  11463. {
  11464. sock = new Socket(SVRIP,port);
  11465. }
  11466. else
  11467. {
  11468. int setport = port + 1000;
  11469. Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
  11470. SSLClient sslClientSocket = null;
  11471. if(define.DanjiServerBlended == danjiserverType)
  11472. {
  11473. sslClientSocket = new SSLClient(define.NewDanjiServerIP, setport);
  11474. }
  11475. else
  11476. {
  11477. sslClientSocket = new SSLClient(SVRIP, setport);
  11478. }
  11479. sock = sslClientSocket.getSocket();
  11480. }
  11481. /////////////////////////////////////////////////////////////////////
  11482. if(sock!=null)
  11483. {
  11484. sock.setSoLinger(true, 1000);
  11485. outstream = new DataOutputStream(sock.getOutputStream());
  11486. byte[] outBF = sendmsg.getBytes("euc-kr");
  11487. outstream.write(outBF);
  11488. outstream.flush();
  11489. }
  11490. }
  11491. catch (RuntimeException re) {
  11492. LogUtil.errorLogInfo("", TAG, re);
  11493. }
  11494. catch (Exception e) {
  11495. //e.printStackTrace();
  11496. LogUtil.errorLogInfo("", TAG, e);
  11497. }
  11498. finally {
  11499. if(outstream!=null) {
  11500. try {
  11501. outstream.close();
  11502. } catch (IOException e) {
  11503. LogUtil.errorLogInfo("", TAG, e);
  11504. }
  11505. }
  11506. outstream = null;
  11507. if(sock!=null) {
  11508. try {
  11509. sock.close();
  11510. } catch (IOException e) {
  11511. LogUtil.errorLogInfo("", TAG, e);
  11512. }
  11513. }
  11514. sock = null;
  11515. }
  11516. }
  11517. }
  11518. private void SendToServer(String msg)
  11519. {
  11520. SendMSGToSVR msan = new SendMSGToSVR(msg);
  11521. msan.start();
  11522. }
  11523. boolean StatusBeatRequested = false;
  11524. private String MakeStatusReport()
  11525. {
  11526. try
  11527. {
  11528. String ServiceType = StatusBeatRequested?"requested":"notice";
  11529. StatusBeatRequested = false;
  11530. String RetData = XMLHeader+"<service type=\""+ServiceType+"\" name=\"statusbeat\"> \r\n";
  11531. WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
  11532. String[] typeList = SettManager.GetTypeList();
  11533. if (typeList == null || typeList.length == 0) {
  11534. DefaultProcauscultateReq(SettManager);
  11535. typeList = SettManager.GetTypeList();
  11536. }
  11537. SettManager.closeDB();
  11538. String[] ControlList;
  11539. String Vender = "null";
  11540. String devid = "null";
  11541. String Model = "null";
  11542. String subunitcnt = "null";
  11543. String statusRate = "null";
  11544. String statusType = "null";
  11545. String message = "null";
  11546. int itemCNT = 0;
  11547. int totalGroup = 0;
  11548. int totalItem = 0;
  11549. String ControlDEVList;
  11550. String ContentList = " ";
  11551. if(typeList!=null)
  11552. {
  11553. for (int i = 0; i < typeList.length; i++)
  11554. {
  11555. if (typeList[i].equals("ctrl_device"))
  11556. {
  11557. SettManager = new WallpadDevStatus(getApplicationContext());
  11558. ControlList = SettManager.GetSettingGroupData("ctrl_device");
  11559. SettManager.closeDB();
  11560. ControlDEVList = "";
  11561. if(ControlList!=null)
  11562. {
  11563. for (int k = 0; k < ControlList.length; k++)
  11564. {
  11565. if (ControlList[k].equals("light"))
  11566. {
  11567. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11568. int[] lightinfo = devSet.Get_Light_info();
  11569. devSet.closeDB();
  11570. if (lightinfo[0]==1)
  11571. {
  11572. if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)
  11573. {
  11574. subunitcnt = String.valueOf(lightinfo[2]);
  11575. LightAPI lightCTR = mWallPadAPI.Get_LightController();
  11576. devid = "0x11";
  11577. Vender = "null";
  11578. Model = "null";
  11579. if(lightCTR!=null)
  11580. {
  11581. lightCTR.TRInfo.GetTransactionList(0);
  11582. statusRate = String.format("%d/%d",lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess+lightCTR.TRInfo.RecentFail));
  11583. double surate = lightCTR.TRInfo.GetSuccessRate(false);
  11584. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11585. message = "null";
  11586. ControlDEVList+=" <unit type=\"light\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11587. itemCNT++;
  11588. }
  11589. }
  11590. else
  11591. {
  11592. subunitcnt = String.valueOf(lightinfo[2]);
  11593. MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
  11594. if(MultiSW!=null)
  11595. {
  11596. MultiSW.Refresh((byte)0xFF, false);
  11597. byte Bdevid = 0x51;
  11598. for(int j = 0; j <MultiSW.data.DeviceCnt;j++ )
  11599. {
  11600. devid = String.format("0x%02X",Bdevid+j);
  11601. Vender = "null";
  11602. Model = "null";
  11603. MultiSW.TRInfo.GetTransactionList(j);
  11604. statusRate = String.format("%d/%d",MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess+MultiSW.TRInfo.RecentFail));
  11605. double surate = MultiSW.TRInfo.GetSuccessRate(false);
  11606. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11607. ControlDEVList+=" <unit type=\"light\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11608. itemCNT++;
  11609. }
  11610. }
  11611. }
  11612. }
  11613. else
  11614. {
  11615. Vender = "null";
  11616. devid = "null";
  11617. Model = "null";
  11618. subunitcnt = "null";
  11619. statusRate = "null";
  11620. message = "null";
  11621. }
  11622. }
  11623. else if (ControlList[k].equals("thermostat"))
  11624. {
  11625. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11626. int ret = devSet.Get_Temper_Info();
  11627. devSet.closeDB();
  11628. if (ret == 1)
  11629. {
  11630. // 난방 종류를 얻어온다.
  11631. int HeatingKind = mWallPadAPI.GetHeatingKind();
  11632. HeatingV1API heatingV1API = null;
  11633. HeatingV2API heatingV2API = null;
  11634. // 종류별 API를 로딩한다.
  11635. if(HeatingKind == 1)
  11636. {
  11637. heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
  11638. if(heatingV1API!=null)
  11639. {
  11640. subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
  11641. devid = "0x21";
  11642. Vender = "null";
  11643. Model = "null";
  11644. heatingV1API.TRInfo.GetTransactionList(0);
  11645. statusRate = String.format("%d/%d",heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess+heatingV1API.TRInfo.RecentFail));
  11646. double surate = heatingV1API.TRInfo.GetSuccessRate(false);
  11647. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11648. message = "null";
  11649. }
  11650. }
  11651. else if(HeatingKind == 2)
  11652. {
  11653. heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
  11654. if(heatingV2API!=null)
  11655. {
  11656. subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
  11657. devid = "0x28";
  11658. Vender = "null";
  11659. Model = "null";
  11660. heatingV2API.TRInfo.GetTransactionList(0);
  11661. statusRate = String.format("%d/%d",heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess+heatingV2API.TRInfo.RecentFail));
  11662. double surate = heatingV2API.TRInfo.GetSuccessRate(false);
  11663. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11664. message = "null";
  11665. }
  11666. }
  11667. else
  11668. {
  11669. subunitcnt = "null";
  11670. devid = "null";
  11671. Vender = "null";
  11672. Model = "null";
  11673. statusRate = "0/0";
  11674. statusType = "bad";
  11675. message = "null";
  11676. }
  11677. ControlDEVList+=" <unit type=\"thermostat\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11678. itemCNT++;
  11679. }
  11680. else
  11681. {
  11682. }
  11683. }
  11684. else if (ControlList[k].equals("gas"))
  11685. {
  11686. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11687. if (devSet.Get_GAS_Info() == 1)
  11688. {
  11689. //여기서 신우전자확인이 더 필요함
  11690. GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
  11691. CooktopAPI HybridCookTopCTR = null;
  11692. subunitcnt = "1";
  11693. devid = "0x31";
  11694. Vender = "null";
  11695. Model = "null";
  11696. if(mWallPadAPI.GetGasKind() == 2)
  11697. {
  11698. HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
  11699. if(HybridCookTopCTR!=null)
  11700. {
  11701. HybridCookTopCTR.TRInfo.GetTransactionList(0);
  11702. statusRate = String.format("%d/%d",HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess+HybridCookTopCTR.TRInfo.RecentFail));
  11703. double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
  11704. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11705. message = "null";
  11706. ControlDEVList+=" <unit type=\"gas\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11707. itemCNT++;
  11708. }
  11709. }
  11710. else
  11711. {
  11712. GasCTR = mWallPadAPI.Get_GasController();
  11713. if(GasCTR!=null)
  11714. {
  11715. GasCTR.TRInfo.GetTransactionList(0);
  11716. statusRate = String.format("%d/%d",GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess+GasCTR.TRInfo.RecentFail));
  11717. double surate = GasCTR.TRInfo.GetSuccessRate(false);
  11718. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11719. message = "null";
  11720. ControlDEVList+=" <unit type=\"gas\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11721. itemCNT++;
  11722. }
  11723. }
  11724. }
  11725. else
  11726. {
  11727. }
  11728. devSet.closeDB();
  11729. }
  11730. else if (ControlList[k].equals("doorlock"))
  11731. {
  11732. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11733. int[] doorlockInfo = devSet.Get_DoorLock_Info();
  11734. if (doorlockInfo[0] == 1)
  11735. {
  11736. DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
  11737. subunitcnt = "1";
  11738. devid = "0x41";
  11739. Vender = "null";
  11740. Model = "null";
  11741. if(DoorCTR!=null)
  11742. {
  11743. DoorCTR.TRInfo.GetTransactionList(0);
  11744. statusRate = String.format("%d/%d",DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess+DoorCTR.TRInfo.RecentFail));
  11745. double surate = DoorCTR.TRInfo.GetSuccessRate(false);
  11746. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11747. message = "null";
  11748. ControlDEVList+=" <unit type=\"doorlock\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11749. itemCNT++;
  11750. }
  11751. }
  11752. else
  11753. {
  11754. }
  11755. devSet.closeDB();
  11756. }
  11757. else if (ControlList[k].equals("ventil"))
  11758. {
  11759. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11760. int[] ventilInfo = devSet.Get_Ventil_Info();
  11761. if (ventilInfo[0] == 1)
  11762. {
  11763. VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
  11764. subunitcnt = "1";
  11765. devid = "0x61";
  11766. Vender = "null";
  11767. Model = "null";
  11768. if(VentilCTR!=null)
  11769. {
  11770. VentilCTR.TRInfo.GetTransactionList(0);
  11771. statusRate = String.format("%d/%d",VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess+VentilCTR.TRInfo.RecentFail));
  11772. double surate = VentilCTR.TRInfo.GetSuccessRate(false);
  11773. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11774. message = "null";
  11775. ControlDEVList+=" <unit type=\"ventil\" id=\""+devid+"\" vendor=\""+Vender+"\" model=\""+Model+"\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11776. itemCNT++;
  11777. }
  11778. }
  11779. else
  11780. {
  11781. }
  11782. devSet.closeDB();
  11783. }
  11784. else if (ControlList[k].equals("aircon"))
  11785. {
  11786. }
  11787. else if (ControlList[k].equals("curtain"))
  11788. {
  11789. }
  11790. }
  11791. if (itemCNT > 0)
  11792. {
  11793. ContentList+="<group type=\"ctrl_device\" count=\""+itemCNT+"\">\r\n";
  11794. ContentList+=ControlDEVList;
  11795. ContentList+="</group>\r\n";
  11796. totalGroup++;
  11797. totalItem+=itemCNT;
  11798. }
  11799. }
  11800. }
  11801. else if (typeList[i].equals("talk_device"))
  11802. {
  11803. SettManager = new WallpadDevStatus(getApplicationContext());
  11804. ControlList = SettManager.GetSettingGroupData("talk_device");
  11805. SettManager.closeDB();
  11806. itemCNT = 0;
  11807. ControlDEVList = "";
  11808. PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
  11809. if(testAPI!=null)
  11810. testAPI.GetVersion();
  11811. if(ControlList!=null)
  11812. {
  11813. for (int k = 0; k < ControlList.length; k++)
  11814. {
  11815. if (ControlList[k].equals("kitchen_tv") && testAPI!=null)
  11816. {
  11817. 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";
  11818. itemCNT++;
  11819. //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
  11820. //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
  11821. }
  11822. else if (ControlList[k].equals("bath_phone") && testAPI!=null)
  11823. {
  11824. 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";
  11825. itemCNT++;
  11826. }
  11827. else if (ControlList[k].equals("subhome_dev"))
  11828. {
  11829. }
  11830. }
  11831. if (itemCNT > 0)
  11832. {
  11833. ContentList+="<group type=\"talk_device\" count=\""+itemCNT+"\">\r\n";
  11834. ContentList+=ControlDEVList;
  11835. ContentList+="</group>\r\n";
  11836. totalGroup++;
  11837. totalItem+=itemCNT;
  11838. }
  11839. }
  11840. }
  11841. else if (typeList[i].equals("sensor"))
  11842. {
  11843. SettManager = new WallpadDevStatus(getApplicationContext());
  11844. ControlList = SettManager.GetSettingGroupData("sensor");
  11845. SettManager.closeDB();
  11846. itemCNT = 0;
  11847. ControlDEVList = "";
  11848. if(ControlList!=null)
  11849. {
  11850. for (int k = 0; k < ControlList.length; k++)
  11851. {
  11852. if (ControlList[k].equals("magnetic"))
  11853. {
  11854. WallPadInterface wpifc = new WallPadInterface();
  11855. int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
  11856. String SenStateCom;
  11857. String SenStateType;
  11858. if (MagSen==1)
  11859. {
  11860. SenStateCom = "1/1";
  11861. SenStateType = "";
  11862. }
  11863. else
  11864. {
  11865. SenStateCom = "0/1";
  11866. SenStateType = "perfect";
  11867. }
  11868. ControlDEVList+= " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  11869. itemCNT++;
  11870. }
  11871. else if (ControlList[k].equals("bugout"))
  11872. {
  11873. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11874. int sensor = devSet.Get_Sensor_Set();
  11875. devSet.closeDB();
  11876. if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0)
  11877. {
  11878. WallPadInterface wpifc = new WallPadInterface();
  11879. int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  11880. String SenStateCom;
  11881. String SenStateType;
  11882. if (outSen==1)
  11883. {
  11884. SenStateCom = "1/1";
  11885. SenStateType = "bad";
  11886. }
  11887. else
  11888. {
  11889. SenStateCom = "0/1";
  11890. SenStateType = "perfect";
  11891. }
  11892. ControlDEVList+= " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  11893. itemCNT++;
  11894. }
  11895. }
  11896. else if (ControlList[k].equals("bugin"))
  11897. {
  11898. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11899. int sensor = devSet.Get_Sensor_Set();
  11900. devSet.closeDB();
  11901. if ((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0)
  11902. {
  11903. WallPadInterface wpifc = new WallPadInterface();
  11904. int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  11905. String SenStateCom;
  11906. String SenStateType;
  11907. if (InSen==1)
  11908. {
  11909. SenStateCom = "1/1";
  11910. SenStateType = "bad";
  11911. }
  11912. else
  11913. {
  11914. SenStateCom = "0/1";
  11915. SenStateType = "perfect";
  11916. }
  11917. ControlDEVList+= " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\""+SenStateCom+"\" status_type=\""+SenStateType+"\" message=\"null\"/>\r\n";
  11918. itemCNT++;
  11919. }
  11920. }
  11921. else if (ControlList[k].equals("fire"))
  11922. {
  11923. //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  11924. }
  11925. else if (ControlList[k].equals("gas"))
  11926. {
  11927. //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
  11928. }
  11929. }
  11930. if (itemCNT > 0)
  11931. {
  11932. ContentList+="<group type=\"sensor\" count=\""+itemCNT+"\">\r\n";
  11933. ContentList+=ControlDEVList;
  11934. ContentList+="</group>\r\n";
  11935. totalGroup++;
  11936. totalItem+=itemCNT;
  11937. }
  11938. }
  11939. }
  11940. else if (typeList[i].equals("extended"))
  11941. {
  11942. SettManager = new WallpadDevStatus(getApplicationContext());
  11943. ControlList = SettManager.GetSettingGroupData("extended");
  11944. SettManager.closeDB();
  11945. itemCNT=0;
  11946. ControlDEVList = "";
  11947. if(ControlList!=null)
  11948. {
  11949. for (int k = 0; k < ControlList.length; k++)
  11950. {
  11951. if (ControlList[k].equals("gateway"))
  11952. {
  11953. }
  11954. else if (ControlList[k].equals("handy"))
  11955. {
  11956. }
  11957. else if (ControlList[k].equals("smartswitch"))
  11958. {
  11959. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  11960. int[] BatchInfo = devSet.Get_BatchSW_Info();
  11961. devSet.closeDB();
  11962. if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART )
  11963. {
  11964. SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
  11965. SmartSWCTR.TRInfo.GetTransactionList(0);
  11966. subunitcnt = "1";
  11967. statusRate = String.format("%d/%d",SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess+SmartSWCTR.TRInfo.RecentFail));
  11968. double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
  11969. statusType = surate>70?"good":surate>30?"notgood":"bad";
  11970. message = "null";
  11971. ControlDEVList+=" <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\""+subunitcnt+"\" status_com=\""+statusRate+"\" status_type=\""+statusType+"\" message=\""+message+"\"/>\r\n";
  11972. itemCNT++;
  11973. }
  11974. else
  11975. {
  11976. }
  11977. }
  11978. else if (ControlList[k].equals("energymeter"))
  11979. {
  11980. }
  11981. }
  11982. if (itemCNT > 0)
  11983. {
  11984. ContentList+="<group type=\"extended\" count=\""+itemCNT+"\">\r\n";
  11985. ContentList+=ControlDEVList;
  11986. ContentList+="</group>\r\n";
  11987. totalGroup++;
  11988. totalItem+=itemCNT;
  11989. }
  11990. }
  11991. }
  11992. }
  11993. SettManager.closeDB();
  11994. ContentList+="</guidemap> \r\n";
  11995. RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\""+totalGroup+"\" device_cnt=\""+totalItem+"\">\r\n";
  11996. RetData += ContentList;
  11997. String LogSet;
  11998. LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
  11999. RetData+=LogSet;
  12000. try {
  12001. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  12002. String[] ResetData = WsDB.GetResetSchedule();
  12003. WsDB.closeDB();
  12004. if (!ResetData[0].equals("NONE"))
  12005. {
  12006. int type = Integer.parseInt(ResetData[0]);
  12007. if (type == WallpadStatusData.RESET_MONTH)
  12008. LogSet="<reset_info enable=\"true\" type=\"month\" cycle=\""+ResetData[1]+"\" time=\""+ResetData[2]+"\"/>\r\n";
  12009. else if (type == WallpadStatusData.RESET_WEEK)
  12010. LogSet="<reset_info enable=\"true\" type=\"week\" cycle=\""+ResetData[1]+"\" time=\""+ResetData[2]+"\"/>\r\n";
  12011. else
  12012. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12013. }
  12014. else
  12015. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12016. }
  12017. catch (RuntimeException re) {
  12018. LogUtil.errorLogInfo("", TAG, re);
  12019. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12020. } catch (Exception e)
  12021. {
  12022. //e.printStackTrace();
  12023. LogUtil.errorLogInfo("", TAG, e);
  12024. LogSet="<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
  12025. }
  12026. RetData+=LogSet;
  12027. RetData+="</service>\r\n</imap>\r\n";
  12028. }
  12029. return RetData;
  12030. }
  12031. catch (RuntimeException re) {
  12032. LogUtil.errorLogInfo("", TAG, re);
  12033. return null;
  12034. }
  12035. catch (Exception e )
  12036. {
  12037. //e.printStackTrace();
  12038. LogUtil.errorLogInfo("", TAG, e);
  12039. return null;
  12040. }
  12041. }
  12042. private String getKNXDeviceStatus(int device) {
  12043. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12044. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12045. String status = knxHeartbeat.getStatus();
  12046. Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
  12047. return status;
  12048. }
  12049. private String getKNXDeviceCause(int device) {
  12050. WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
  12051. WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
  12052. String cause = knxHeartbeat.getCause();
  12053. Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
  12054. return cause;
  12055. }
  12056. //mWallPadAPI
  12057. // private String TAG = "*yskim*";
  12058. //private IGW200dAPI iGW200dAPI = null;
  12059. /**
  12060. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12061. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12062. * 본 딜레이 코드를 임시로 적용한다.
  12063. */
  12064. @SuppressLint("HandlerLeak")
  12065. protected Handler IGW200APICheckHandler = new Handler() {
  12066. @SuppressLint("HandlerLeak")
  12067. @Override
  12068. public void handleMessage(Message msg) {
  12069. if (msg.what == 0) {
  12070. if (mWallPadAPI != null) {
  12071. Common.DebugLog("handleMessage what 0 ");
  12072. if (mWallPadAPI.Check_Connect()) IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12073. else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12074. }
  12075. }
  12076. else if(msg.what == 1) {
  12077. Common.DebugLog("handleMessage what 1 ");
  12078. setIGE200Interface();
  12079. }
  12080. }
  12081. };
  12082. public void setIGE200Interface() {
  12083. try {
  12084. Common.DebugLog("setIGE200Interface");
  12085. mIGW200 = new IGW200(this, mWallPadAPI);
  12086. } catch (RuntimeException re) {
  12087. LogUtil.errorLogInfo("", TAG, re);
  12088. }
  12089. catch (Exception e) {
  12090. Log.e(TAG, "[Exception] setIGE200Interface()");
  12091. //e.printStackTrace();
  12092. LogUtil.errorLogInfo("", TAG, e);
  12093. }
  12094. }
  12095. /**
  12096. * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
  12097. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  12098. * 본 딜레이 코드를 임시로 적용한다.
  12099. */
  12100. @SuppressLint("HandlerLeak")
  12101. protected Handler IGW300APICheckHandler = new Handler() {
  12102. @SuppressLint("HandlerLeak")
  12103. @Override
  12104. public void handleMessage(Message msg) {
  12105. if (msg.what == 0) {
  12106. if (mWallPadAPI != null) {
  12107. Common.DebugLog("handleMessage what 0 ");
  12108. if (mWallPadAPI.Check_Connect()) IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
  12109. else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
  12110. }
  12111. }
  12112. else if(msg.what == 1) {
  12113. Common.DebugLog("handleMessage what 1 ");
  12114. setIGE300Interface();
  12115. }
  12116. }
  12117. };
  12118. public void setIGE300Interface() {
  12119. try {
  12120. Common.DebugLog("setIGE300Interface");
  12121. mIGW300 = new IGW300(this, mWallPadAPI);
  12122. } catch (RuntimeException re) {
  12123. LogUtil.errorLogInfo("", TAG, re);
  12124. }
  12125. catch (Exception e) {
  12126. Log.e(TAG, "[Exception] setIGE300Interface()");
  12127. //e.printStackTrace();
  12128. LogUtil.errorLogInfo("", TAG, e);
  12129. }
  12130. }
  12131. // 외출모드 연동
  12132. private void ModeRunCtrlWorking( boolean WallpadUI , boolean BedMode )
  12133. {
  12134. try
  12135. {
  12136. bSmartSwitch485ComebackMode = false;
  12137. String [] mOutModeTextContents = { "엘리베이터호출" , "일괄소등" , "가스닫기", "난방외출모드" , "환기끄기", "쿡탑콘센트차단"};
  12138. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12139. String outLinkCtrl = wd.GetOutModeLinkDevice();
  12140. if( BedMode == true )
  12141. outLinkCtrl = wd.GetInBedLinkDevice();
  12142. wd.closeDB();
  12143. // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
  12144. if( WallpadUI == false )
  12145. {
  12146. if( outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0 ) // 엘리베이터 호출
  12147. {
  12148. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0] );
  12149. CallElevatorBtn(false);
  12150. }
  12151. }
  12152. if( outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0 ) // 일괄소등 처리
  12153. {
  12154. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1] );
  12155. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
  12156. }
  12157. if( (outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
  12158. {
  12159. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2] );
  12160. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
  12161. }
  12162. if( outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
  12163. {
  12164. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3] );
  12165. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
  12166. }
  12167. if( outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0 ) // 환기끄기
  12168. {
  12169. Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4] );
  12170. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
  12171. }
  12172. }
  12173. catch (RuntimeException re) {
  12174. LogUtil.errorLogInfo("", TAG, re);
  12175. }
  12176. catch (Exception e )
  12177. {
  12178. Log.e("YSKIM", e.toString());
  12179. }
  12180. }
  12181. // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
  12182. // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
  12183. private boolean bSmartSwitch485ComebackMode = false ;
  12184. private void ModeReleaseCtrlWorking(boolean bBedMode) {
  12185. try {
  12186. if (bSmartSwitch485ComebackMode == true) return;
  12187. String [] mCombackHomeTextContents = { "일괄소등해제" , "환기동작" , "난방외출모드해제", "웰컴조명" };
  12188. WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
  12189. String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
  12190. if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
  12191. wd.closeDB();
  12192. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
  12193. // 일괄소등 해제
  12194. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0] );
  12195. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
  12196. }
  12197. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0 ) {
  12198. // 환기동작
  12199. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1] );
  12200. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  12201. }
  12202. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
  12203. // 난방 외출모드 해제
  12204. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2] );
  12205. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
  12206. }
  12207. if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
  12208. // 웰컴조명 켜기
  12209. Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3] );
  12210. // 웰컴조명 Handler 실행
  12211. WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
  12212. }
  12213. } catch (RuntimeException re) {
  12214. LogUtil.errorLogInfo("", TAG, re);
  12215. }
  12216. catch (Exception e) {
  12217. Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
  12218. //e.printStackTrace();
  12219. LogUtil.errorLogInfo("", TAG, e);
  12220. }
  12221. }
  12222. private Handler WelcomeLightHandler = new Handler()
  12223. {
  12224. int LightOnCount = 0;
  12225. @Override
  12226. public void handleMessage(Message msg)
  12227. {
  12228. if(msg.what == 0)
  12229. {
  12230. try
  12231. {
  12232. if(LightOnCount == 0)
  12233. {
  12234. Log.d("TAG", "[WelcomeLightHandler] - START !!!");
  12235. }
  12236. // 일괄소등 해제이면
  12237. if(mWallPadAPI.GetBatchSwitchStatus() == 1)
  12238. {
  12239. Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
  12240. WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
  12241. }
  12242. else
  12243. {
  12244. WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
  12245. LightOnCount++;
  12246. Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
  12247. if(LightOnCount > 10)
  12248. {
  12249. Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
  12250. LightOnCount = 0;
  12251. WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
  12252. }
  12253. }
  12254. }
  12255. catch (RuntimeException re) {
  12256. LogUtil.errorLogInfo("", TAG, re);
  12257. }
  12258. catch (Exception e1)
  12259. {
  12260. Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
  12261. //e1.printStackTrace();
  12262. LogUtil.errorLogInfo("", TAG, e1);
  12263. }
  12264. }
  12265. else if(msg.what == 1)
  12266. {
  12267. try
  12268. {
  12269. Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
  12270. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
  12271. LightOnCount = 0;
  12272. }
  12273. catch (RuntimeException re) {
  12274. LogUtil.errorLogInfo("", TAG, re);
  12275. }
  12276. catch (Exception e1)
  12277. {
  12278. Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
  12279. //e1.printStackTrace();
  12280. LogUtil.errorLogInfo("", TAG, e1);
  12281. }
  12282. }
  12283. else if(msg.what == 2)
  12284. {
  12285. // Do Nothing
  12286. Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
  12287. WelcomeLightHandler.removeMessages(0);
  12288. }
  12289. }
  12290. };
  12291. //방범 및 알람 상태 확인 Resume 시 처리
  12292. private void CheckMainStatus() {
  12293. //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  12294. try {
  12295. final String packageName = "com.artncore.apps.ic_wallpad";
  12296. final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
  12297. //CallAppRun = getForegroundAPK().equals(packageName);
  12298. boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
  12299. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  12300. int alarmstate = SetData.GetAlarmStatus();
  12301. SetData.closeDB();
  12302. Log.d("iMap", "CheckMainStatus Check status : " + alarmstate );
  12303. if (alarmstate == WallpadStatusData.ALARM_NONE) {
  12304. Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE" );
  12305. return;
  12306. }
  12307. else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
  12308. if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
  12309. int base = 7000;
  12310. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  12311. int Menu_Start_Id = 0;
  12312. SetData = new WallpadStatusData(getApplicationContext());
  12313. int alarmtype = SetData.GetAlarmType();
  12314. SetData.closeDB();
  12315. switch (alarmtype) {
  12316. case WallpadStatusData.ALARM_ALERT:
  12317. Menu_Start_Id = Menu_Id_List[1];
  12318. break;
  12319. case WallpadStatusData.ALARM_EMM:
  12320. Menu_Start_Id = Menu_Id_List[0];
  12321. break;
  12322. case WallpadStatusData.ALARM_EVAC:
  12323. Menu_Start_Id = Menu_Id_List[3];
  12324. break;
  12325. case WallpadStatusData.ALARM_INVADE:
  12326. Menu_Start_Id =Menu_Id_List[2];
  12327. break;
  12328. case WallpadStatusData.ALARM_HEATING_LEAK:
  12329. Menu_Start_Id =Menu_Id_List[4];
  12330. break;
  12331. default:
  12332. Menu_Start_Id = Menu_Id_List[1];
  12333. break;
  12334. }
  12335. if (Menu_Start_Id > 0) {
  12336. /*
  12337. * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
  12338. * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
  12339. * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
  12340. * "RESUME"을 전달한다.
  12341. */
  12342. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12343. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12344. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12345. newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
  12346. newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
  12347. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12348. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12349. startActivity(newintent);
  12350. return;
  12351. }
  12352. }
  12353. else if (alarmstate == WallpadStatusData.GUARD_OUT) {
  12354. if (OutModeRunAppRun == true) {
  12355. Log.d(TAG, "already outmoderun app running !!!!");
  12356. return;
  12357. }
  12358. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12359. int sensor = devset.Get_Sensor_Set();
  12360. devset.closeDB();
  12361. int base = 7000;
  12362. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12363. int Menu_Start_Id = 0;
  12364. int Menu_Start_Option = 1;
  12365. if (sensor > 0) {
  12366. WallPadInterface wpifc = new WallPadInterface();
  12367. int[] SensorInfoDB;
  12368. int inSen = 0;
  12369. int outSen = 0;
  12370. SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12371. if (SensorInfoDB[0] == 1) {
  12372. // 내부동체가 사용함이면 상태 검사
  12373. inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12374. }
  12375. if (SensorInfoDB[1] == 1) {
  12376. // 외부동체가 사용함이면 상태 검사
  12377. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12378. }
  12379. // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
  12380. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12381. if (((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0 &&( outSen > 0 || inSen > 0)) ||
  12382. ((sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
  12383. ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12384. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12385. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12386. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12387. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12388. newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0)?"bugout":"bugin");
  12389. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12390. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12391. startActivity(newintent);
  12392. return;
  12393. }
  12394. }
  12395. base = 8000;
  12396. Menu_Id_List = new int[]{ base+11};
  12397. Menu_Start_Id = base+11;
  12398. Menu_Start_Option = -1;
  12399. Intent intent = new Intent(Intent.ACTION_MAIN);
  12400. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12401. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12402. intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12403. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  12404. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12405. startActivity(intent);
  12406. }
  12407. else if (alarmstate == WallpadStatusData.GUARD_IN) {
  12408. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12409. int sensor = devset.Get_Sensor_Set();
  12410. devset.closeDB();
  12411. int base = 7000;
  12412. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12413. int Menu_Start_Option = 1;
  12414. if (sensor > 0) {
  12415. WallPadInterface wpifc = new WallPadInterface();
  12416. int[] SensorInfoDB;
  12417. int outSen = 0;SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
  12418. if (SensorInfoDB[1] == 1) {
  12419. // 외부동체가 사용함이면 상태 검사
  12420. outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12421. }
  12422. // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
  12423. if (((sensor&WallpadDeviceSet.SET_IN_MOTION) > 0 &&( outSen > 0 )) ||
  12424. ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
  12425. Intent newintent = new Intent(Intent.ACTION_MAIN);
  12426. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12427. newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
  12428. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12429. newintent.putExtra("MENU_DETAIL_INFO", "bugout");
  12430. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12431. newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12432. startActivity(newintent);
  12433. return;
  12434. }
  12435. }
  12436. }
  12437. else if (alarmstate == WallpadStatusData.ALARM_STOP) {
  12438. WallPadInterface wpifc = new WallPadInterface();
  12439. wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
  12440. return;
  12441. }
  12442. else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
  12443. int base = 4000;
  12444. int Menu_Start_Id = 0;
  12445. int[] Menu_Id_List = new int[]{ base+11, base+21};
  12446. Menu_Start_Id = base+11;
  12447. Intent intent = new Intent(Intent.ACTION_MAIN);
  12448. intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12449. intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  12450. intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
  12451. intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity","kr.co.icontrols.wallpadsecurity.MainActivity"));
  12452. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12453. startActivity(intent);
  12454. return;
  12455. }
  12456. } catch (RuntimeException re) {
  12457. LogUtil.errorLogInfo("", TAG, re);
  12458. }
  12459. catch (Exception e) {
  12460. Log.e(TAG, "[Exception] CheckMainStatus()");
  12461. //e.printStackTrace();
  12462. LogUtil.errorLogInfo("", TAG, e);
  12463. }
  12464. // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  12465. // int StatusVal = devset.GetDeviceSetted("피난사다리");
  12466. // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12467. // {
  12468. // WallPadInterface wpifc = new WallPadInterface();
  12469. // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
  12470. //
  12471. // if (fleeSensor > 0)
  12472. // {
  12473. // int base = 7000;
  12474. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12475. // int Menu_Start_Option = 1;
  12476. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12477. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12478. // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
  12479. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12480. // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
  12481. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12482. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12483. // startActivity(newintent);
  12484. // devset.closeDB();
  12485. // return;
  12486. // }
  12487. // }
  12488. //
  12489. // StatusVal = devset.GetDeviceSetted("알람발생");
  12490. // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
  12491. // {
  12492. // WallPadInterface wpifc = new WallPadInterface();
  12493. // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
  12494. //
  12495. // if (AlarmSensor > 0)
  12496. // {
  12497. // int base = 7000;
  12498. // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
  12499. // int Menu_Start_Option = 1;
  12500. // Intent newintent = new Intent(Intent.ACTION_MAIN);
  12501. // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  12502. // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
  12503. // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  12504. // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
  12505. // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  12506. // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  12507. // startActivity(newintent);
  12508. // devset.closeDB();
  12509. // return;
  12510. // }
  12511. //
  12512. // }
  12513. // devset.closeDB();
  12514. }
  12515. /**
  12516. * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
  12517. *
  12518. * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
  12519. */
  12520. public boolean GetUseIlgalControlForAdmin()
  12521. {
  12522. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  12523. String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
  12524. devSet.closeDB();
  12525. boolean result = false;
  12526. if (MetringDB != null)
  12527. {
  12528. try
  12529. {
  12530. String devInfo = MetringDB[1];
  12531. devInfo = devInfo.replace('(', '_');
  12532. devInfo = devInfo.replace(':', '_');
  12533. devInfo = devInfo.replace(')', '_');
  12534. String[] MetringInfo = devInfo.split("_");
  12535. if (MetringInfo[3].equals("사용함") == true)
  12536. {
  12537. result = true;
  12538. }
  12539. }
  12540. catch (RuntimeException re) {
  12541. LogUtil.errorLogInfo("", TAG, re);
  12542. }
  12543. catch (Exception e)
  12544. {
  12545. //e.printStackTrace();
  12546. LogUtil.errorLogInfo("", TAG, e);
  12547. }
  12548. }
  12549. return result;
  12550. }
  12551. class SendLHGWCheck extends Thread
  12552. {
  12553. private iMAP_hn_config_read m_HnGWConfigRead = null;
  12554. private iMAPEmptyMessage m_HnGWEmptyMsg = null;
  12555. private boolean retSucces = false;
  12556. private int retryCount = 0;
  12557. public SendLHGWCheck()
  12558. {
  12559. m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
  12560. m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
  12561. retryCount = 0;
  12562. }
  12563. public void run()
  12564. {
  12565. try {
  12566. try{Thread.sleep(2000);}
  12567. catch (RuntimeException re) {
  12568. LogUtil.errorLogInfo("", TAG, re);
  12569. }
  12570. catch (Exception e){
  12571. LogUtil.errorLogInfo("", TAG, e);
  12572. }
  12573. for( int i = 0 ; i < 10 ; i++ )
  12574. {
  12575. m_HnGWConfigRead.DoWork();
  12576. m_HnGWConfigRead.SetRetCtr(new RetProci()
  12577. {
  12578. @Override
  12579. public void ProcSuccess()
  12580. {
  12581. retSucces = true;
  12582. Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount );
  12583. }
  12584. @Override
  12585. public void ProcError()
  12586. {
  12587. }
  12588. @Override
  12589. public void ProcDoing()
  12590. {
  12591. // TODO Auto-generated method stub
  12592. }
  12593. });
  12594. if( retSucces == true )
  12595. break;
  12596. retryCount++;
  12597. try{Thread.sleep(3000);}
  12598. catch (RuntimeException re) {
  12599. LogUtil.errorLogInfo("", TAG, re);
  12600. }
  12601. catch (Exception e){
  12602. LogUtil.errorLogInfo("", TAG, e);
  12603. }
  12604. }
  12605. m_HnGWEmptyMsg.DoWork();
  12606. m_HnGWEmptyMsg.SetRetCtr(new RetProci()
  12607. {
  12608. @Override
  12609. public void ProcSuccess()
  12610. {
  12611. Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess " );
  12612. }
  12613. @Override
  12614. public void ProcError()
  12615. {
  12616. Log.d(TAG, "HN GW EmptyMsg Send ProcError " );
  12617. }
  12618. @Override
  12619. public void ProcDoing()
  12620. {
  12621. // TODO Auto-generated method stub
  12622. Log.d(TAG, "HN GW EmptyMsg Send ProcDoing " );
  12623. }
  12624. });
  12625. } catch (RuntimeException re) {
  12626. LogUtil.errorLogInfo("", TAG, re);
  12627. }
  12628. catch (Exception e) {
  12629. //e.printStackTrace();
  12630. LogUtil.errorLogInfo("", TAG, e);
  12631. }
  12632. }
  12633. }
  12634. //Reset Handler
  12635. private Handler mResetHandler = new Handler() {
  12636. @Override
  12637. public void handleMessage(Message msg) {
  12638. if (msg.what == 0) {
  12639. Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
  12640. Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
  12641. if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
  12642. Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
  12643. if (NowMainStatus == false) {
  12644. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12645. ResetCount = 1;
  12646. }
  12647. ResetCount++;
  12648. NowMainStatus = true;
  12649. if (ResetCount == 30) {
  12650. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12651. }
  12652. else {
  12653. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12654. }
  12655. }
  12656. else {
  12657. if (NowMainStatus == true) {
  12658. Log.d(TAG, "[mResetHandler] ResetCount will be 1");
  12659. ResetCount = 1;
  12660. }
  12661. ResetCount++;
  12662. NowMainStatus = false;
  12663. if (ResetCount == 180) {
  12664. // 3분
  12665. mResetHandler.sendEmptyMessageDelayed(1, 10);
  12666. }
  12667. else {
  12668. mResetHandler.sendEmptyMessageDelayed(0, 1000);
  12669. }
  12670. }
  12671. }
  12672. else if (msg.what == 1) {
  12673. Log.d(TAG, "[mResetHandler] Do Reset!!!");
  12674. setDefaultLauncher();
  12675. Intent intent = new Intent();
  12676. intent.setAction(define.NOTIFY_ACNAME);
  12677. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  12678. getApplicationContext().sendBroadcast(intent);
  12679. }
  12680. }
  12681. };
  12682. // 통화주체를 다루는 enum
  12683. public enum CALLOWNER {
  12684. NONE,
  12685. WALLPAD,
  12686. SUB_WALLPAD,
  12687. KITCHEN_TV,
  12688. BATH_PHONE,
  12689. BATH_TV,
  12690. UNIVERSAL_DEVICE,
  12691. ERROR;
  12692. }
  12693. public enum CALLEVENTTYPE {
  12694. RECEIVE_CALL, // 호출 수신 (호출 수신)
  12695. TRYING_CALL, // 호출 시도중 (호출 발신)
  12696. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  12697. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  12698. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  12699. REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
  12700. CONNECT_CALL, // 통화 시작
  12701. TERMINATE_CALL, // 통화 종료
  12702. CANCEL_CALL, // 호출 취소
  12703. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  12704. REJECT_CALL, // 호출수신 거절
  12705. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  12706. FORWARD_CALL, // 착신전환 설정
  12707. CALLERID, // Caller ID
  12708. TIMEOUT_1STCALL, // 1st Call Timeout
  12709. TIMEOUT_2NDCALL, // 2nd Call Timeout
  12710. TIMEOUT_3RDCALL, // 3rd Call Timeout
  12711. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  12712. DOOR_OPEN, // 문열림 설정
  12713. PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
  12714. PSTN_DTMF, // PSTN DTMF 수신
  12715. DETECT_STRANGER, // 거동수상자 발생
  12716. NONE;
  12717. public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
  12718. try {
  12719. if (value.equals(RECEIVE_CALL.toString())) {
  12720. return RECEIVE_CALL;
  12721. } else if (value.equals(TRYING_CALL.toString())) {
  12722. return TRYING_CALL;
  12723. } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
  12724. return RECEIVE_CALL_2ND;
  12725. } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
  12726. return RECEIVE_CALL_ACK;
  12727. } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
  12728. return REQUEST_FRONT_MONITORING;
  12729. } else if (value.equals(CONNECT_CALL.toString())) {
  12730. return CONNECT_CALL;
  12731. } else if (value.equals(TERMINATE_CALL.toString())) {
  12732. return TERMINATE_CALL;
  12733. } else if (value.equals(CANCEL_CALL.toString())) {
  12734. return CANCEL_CALL;
  12735. } else if (value.equals(REJECT_CALL.toString())) {
  12736. return REJECT_CALL;
  12737. } else if (value.equals(REJECT_BUSY_CALL.toString())) {
  12738. return REJECT_BUSY_CALL;
  12739. } else if (value.equals(FORWARD_CALL.toString())) {
  12740. return FORWARD_CALL;
  12741. } else if (value.equals(CALLERID.toString())) {
  12742. return CALLERID;
  12743. } else if (value.equals(TIMEOUT_1STCALL.toString())) {
  12744. return TIMEOUT_1STCALL;
  12745. } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
  12746. return TIMEOUT_2NDCALL;
  12747. } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
  12748. return TIMEOUT_3RDCALL;
  12749. } else if (value.equals(MOIP_VIDEO_SET.toString())) {
  12750. return MOIP_VIDEO_SET;
  12751. } else if (value.equals(DOOR_OPEN.toString())) {
  12752. return DOOR_OPEN;
  12753. } else if (value.equals(PSTN_RING.toString())) {
  12754. return PSTN_RING;
  12755. } else if (value.equals(PSTN_DTMF.toString())) {
  12756. return PSTN_DTMF;
  12757. } else if (value.equals(DETECT_STRANGER.toString())) {
  12758. return DETECT_STRANGER;
  12759. } else if (value.equals(NONE.toString())) {
  12760. return NONE;
  12761. } else {
  12762. return null;
  12763. }
  12764. } catch (RuntimeException re) {
  12765. LogUtil.errorLogInfo("", "", re);
  12766. return null;
  12767. }
  12768. catch (Exception e) {
  12769. Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
  12770. //e.printStackTrace();
  12771. LogUtil.errorLogInfo("", "", e);
  12772. return null;
  12773. }
  12774. }
  12775. }
  12776. public enum CALLTYPE {
  12777. NONE,
  12778. FRONT,
  12779. RESIDENCE,
  12780. LOBBY,
  12781. GUARD,
  12782. PSTN,
  12783. IHUB,
  12784. ERROR,
  12785. }
  12786. public static class CALLTRIGGER {
  12787. public static String CALLOWNER = "CALLOWNER";
  12788. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  12789. public static String CALLTYPE = "CALLTYPE";
  12790. public enum SOURCE {
  12791. USER,
  12792. CALL_RECEIVE,
  12793. SUBPHONE
  12794. }
  12795. public enum TYPE {
  12796. MENU,
  12797. FRONT,
  12798. LOBBY,
  12799. GUARD,
  12800. RESIDENCE,
  12801. PSTN
  12802. }
  12803. }
  12804. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  12805. int TAB_TALKFRONT = 130011;
  12806. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
  12807. try {
  12808. Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType +"], nAlramStatus [" + nAlramStatus +"]");
  12809. if (!bWallPadCallLive) {
  12810. sendLCDBacklightStatus(true);
  12811. // 통화어플을 실행시킨다.
  12812. if (nAlramStatus != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  12813. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  12814. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  12815. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  12816. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  12817. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  12818. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  12819. mIntent.setComponent(mComponentName);
  12820. startActivity(mIntent);
  12821. playFrontBell(eCallOwner, eEventType, eCallType);
  12822. }
  12823. else {
  12824. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  12825. }
  12826. } catch (RuntimeException re) {
  12827. LogUtil.errorLogInfo("", TAG, re);
  12828. }
  12829. catch (Exception e) {
  12830. Log.e(TAG, "[Exception] runCallMainActivity()");
  12831. //e.printStackTrace();
  12832. LogUtil.errorLogInfo("", TAG, e);
  12833. }
  12834. }
  12835. private String getTopActivity() {
  12836. try {
  12837. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  12838. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  12839. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  12840. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  12841. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  12842. return mComponentName.getPackageName();
  12843. } catch (RuntimeException re) {
  12844. LogUtil.errorLogInfo("", TAG, re);
  12845. return null;
  12846. }
  12847. catch (Exception e) {
  12848. Log.e(TAG, "[Exception] getTopActivity()");
  12849. //e.printStackTrace();
  12850. LogUtil.errorLogInfo("", TAG, e);
  12851. return null;
  12852. }
  12853. }
  12854. private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  12855. try {
  12856. if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
  12857. WallPadInterface Wiface = new WallPadInterface();
  12858. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
  12859. Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
  12860. }
  12861. } catch (RuntimeException re) {
  12862. LogUtil.errorLogInfo("", TAG, re);
  12863. }
  12864. catch (Exception e) {
  12865. Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
  12866. //e.printStackTrace();
  12867. LogUtil.errorLogInfo("", TAG, e);
  12868. }
  12869. }
  12870. private class AfterTransactionTodoListData
  12871. {
  12872. String Title;
  12873. int Valueint;
  12874. String ValueString;
  12875. private AfterTransactionTodoListData(String title, int valueint, String valueString)
  12876. {
  12877. Title = title;
  12878. Valueint = valueint;
  12879. ValueString = valueString;
  12880. }
  12881. }
  12882. /**
  12883. * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
  12884. * **/
  12885. public void SendGetParkingInfoIntent()
  12886. {
  12887. Intent iIntent = new Intent();
  12888. iIntent.setAction(define.NOTIFY_ACNAME);
  12889. iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
  12890. this.sendBroadcast(iIntent);
  12891. }
  12892. /**
  12893. * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
  12894. * **/
  12895. public Handler SendParkingInfoIntentAfter20min = new Handler()
  12896. {
  12897. @SuppressLint("HandlerLeak")
  12898. @Override
  12899. public void handleMessage(Message msg)
  12900. {
  12901. if (msg.what == 0)
  12902. {
  12903. SendGetParkingInfoIntent();
  12904. }
  12905. }
  12906. };
  12907. /**
  12908. * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
  12909. * **/
  12910. public Handler mWallPadOutmodeSleepHandler = new Handler()
  12911. {
  12912. @SuppressLint("HandlerLeak")
  12913. @Override
  12914. public void handleMessage(Message msg)
  12915. {
  12916. if(msg.what == 0)
  12917. {
  12918. mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
  12919. }
  12920. }
  12921. };
  12922. // Handler
  12923. public final class HANDLERMSG {
  12924. public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
  12925. public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
  12926. public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
  12927. public final static int CALLAPP_FINISHING_END = 300;
  12928. public final static int FRONTCAM_PLAY_DINGDONG = 400;
  12929. }
  12930. public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
  12931. public void handleMessage(Message msg) {
  12932. Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 +"]");
  12933. switch (msg.what) {
  12934. case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
  12935. bGlobalScreenRun = true;
  12936. break;
  12937. case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
  12938. bGlobalScreenRun = false;
  12939. break;
  12940. case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
  12941. break;
  12942. case HANDLERMSG.CALLAPP_FINISHING_END:
  12943. // bBlockCallEvent = false;
  12944. break;
  12945. case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
  12946. int time = Sound().PlayMent(SND.call.DINGDONG);
  12947. Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
  12948. if (time < 0) time = 2088;
  12949. mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
  12950. break;
  12951. default:
  12952. Log.v(TAG, "iMAPServerHandler : "+ msg.what);
  12953. break;
  12954. }
  12955. }
  12956. };
  12957. public void sendHandlerMsg(int what, int arg1, int arg2) {
  12958. try {
  12959. Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 +"]");
  12960. Message HandleMsg = iMAPServerHandler.obtainMessage();
  12961. HandleMsg.what = what;
  12962. HandleMsg.arg1 = arg1;
  12963. HandleMsg.arg2 = arg2;
  12964. iMAPServerHandler.sendMessage(HandleMsg);
  12965. } catch (RuntimeException re) {
  12966. LogUtil.errorLogInfo("", TAG, re);
  12967. }
  12968. catch (Exception e) {
  12969. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  12970. //e.printStackTrace();
  12971. LogUtil.errorLogInfo("", TAG, e);
  12972. }
  12973. }
  12974. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
  12975. try {
  12976. Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 +"], delay [" + delay +"]");
  12977. Message HandleMsg = iMAPServerHandler.obtainMessage();
  12978. HandleMsg.what = what;
  12979. HandleMsg.arg1 = arg1;
  12980. HandleMsg.arg2 = arg2;
  12981. iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
  12982. } catch (RuntimeException re) {
  12983. LogUtil.errorLogInfo("", TAG, re);
  12984. }
  12985. catch (Exception e) {
  12986. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  12987. //e.printStackTrace();
  12988. LogUtil.errorLogInfo("", TAG, e);
  12989. }
  12990. }
  12991. int mSensitivity = 0, mDuration = 0;
  12992. int MIN_SENSOR_SENSITIVITY = 1;
  12993. int MAX_SENSOR_SENSITIVITY = 5;
  12994. int MIN_SENSOR_DURATION = 30;
  12995. int MAX_SENSOR_DURATION = 250;
  12996. int DEFAULT_SENSOR_SENSITIVITY = 3;
  12997. int DEFAULT_SENSOR_DURATION = 60;
  12998. private final int COMPONENT_USE = 1;
  12999. /**
  13000. * 스마트현관카메라 사용여부 판별
  13001. */
  13002. private boolean getUseSmartDoorCam() {
  13003. try {
  13004. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13005. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13006. mWallpadDeviceSet.closeDB();
  13007. if (nFrontCam[0] == COMPONENT_USE) {
  13008. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  13009. Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
  13010. return true;
  13011. }
  13012. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
  13013. Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
  13014. return true;
  13015. }
  13016. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13017. Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
  13018. return true;
  13019. }
  13020. else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
  13021. Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
  13022. return true;
  13023. }
  13024. else {
  13025. Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
  13026. return false;
  13027. }
  13028. }
  13029. else {
  13030. Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
  13031. return false;
  13032. }
  13033. } catch (RuntimeException re) {
  13034. LogUtil.errorLogInfo("", TAG, re);
  13035. return false;
  13036. }
  13037. catch (Exception e) {
  13038. Log.e(TAG, "[Exception] getUseSmartDoorCam()");
  13039. //e.printStackTrace();
  13040. LogUtil.errorLogInfo("", TAG, e);
  13041. return false;
  13042. }
  13043. }
  13044. private int getSmartDoorCamType() {
  13045. try {
  13046. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13047. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  13048. mWallpadDeviceSet.closeDB();
  13049. if (nFrontCam[0] == COMPONENT_USE) {
  13050. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  13051. return nFrontCam[1];
  13052. }
  13053. }
  13054. } catch (RuntimeException re) {
  13055. LogUtil.errorLogInfo("", TAG, re);
  13056. }
  13057. catch (Exception e) {
  13058. Log.e(TAG, "[Exception] getSmartDoorCamType()");
  13059. //e.printStackTrace();
  13060. LogUtil.errorLogInfo("", TAG, e);
  13061. }
  13062. return -1;
  13063. }
  13064. /**
  13065. * 방문객원격통화 솔루션 사용여부 판별
  13066. */
  13067. private boolean getRemoteCallUseInfo() {
  13068. try {
  13069. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  13070. if (mWallpadDeviceSet != null) {
  13071. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  13072. if (astrRemoteCall != null) {
  13073. if (astrRemoteCall[1].contains("사용함")) return true;
  13074. } else {
  13075. Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
  13076. }
  13077. }
  13078. mWallpadDeviceSet.closeDB();
  13079. } catch (RuntimeException re) {
  13080. LogUtil.errorLogInfo("", TAG, re);
  13081. }
  13082. catch (Exception e) {
  13083. Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
  13084. //e.printStackTrace();
  13085. LogUtil.errorLogInfo("", TAG, e);
  13086. }
  13087. return false;
  13088. }
  13089. /*
  13090. 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
  13091. */
  13092. private RealTimeMeterAPI mRealTimeMeterAPI;
  13093. private DataClasses.RealTimeMeter mRealTimeMeterData = null;
  13094. private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  13095. public Thread saveRealmeterDataThread = null;
  13096. private void startRealtimemeterInfo() {
  13097. try {
  13098. // 영업샘플 모드 판단
  13099. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13100. Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
  13101. }
  13102. else {
  13103. Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
  13104. // 실시간 검침기 사용유무 판단
  13105. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13106. int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13107. mWallpadDeviceSet.closeDB();
  13108. boolean bRealtimemeterUsage = false;
  13109. int nRealtimemeterCntDB = -99;
  13110. if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
  13111. // 실시간 검침 사용함
  13112. bRealtimemeterUsage = true;
  13113. nRealtimemeterCntDB = naRealtimemtInfo[1];
  13114. initRealtimemeterFunctionHandler.sendEmptyMessage(0);
  13115. }
  13116. else {
  13117. // 실시간 검침 사용하지 않음
  13118. bRealtimemeterUsage = false;
  13119. }
  13120. Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB +"]");
  13121. }
  13122. } catch (RuntimeException re) {
  13123. LogUtil.errorLogInfo("", TAG, re);
  13124. }
  13125. catch (Exception e) {
  13126. Log.e(TAG, "[Exception] startRealtimemeterInfo()");
  13127. //e.printStackTrace();
  13128. LogUtil.errorLogInfo("", TAG, e);
  13129. }
  13130. }
  13131. private void startSmartIoTCamInfo() {
  13132. try {
  13133. // 영업샘플 모드 판단
  13134. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13135. Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
  13136. }
  13137. else {
  13138. Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
  13139. if (getUseSmartDoorCam()) {
  13140. initSmartIoTFunctionHandler.sendEmptyMessage(0);
  13141. }
  13142. else {
  13143. Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
  13144. }
  13145. }
  13146. } catch (RuntimeException re) {
  13147. LogUtil.errorLogInfo("", TAG, re);
  13148. }
  13149. catch (Exception e) {
  13150. Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
  13151. //e.printStackTrace();
  13152. LogUtil.errorLogInfo("", TAG, e);
  13153. }
  13154. }
  13155. private void startDistributionPanel() {
  13156. try {
  13157. // 영업샘플 모드 판단
  13158. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  13159. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  13160. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  13161. Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
  13162. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13163. int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  13164. mWallpadDeviceSet.closeDB();
  13165. if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST) initSmartDistributionPanelHandler.sendEmptyMessage(0);
  13166. if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) initKNXDistributionPanelHandler.sendEmptyMessage(0);
  13167. else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
  13168. }
  13169. else {
  13170. Log.w(TAG, "[startDistributionPanel] Not supported!!!");
  13171. }
  13172. } catch (RuntimeException re) {
  13173. LogUtil.errorLogInfo("", TAG, re);
  13174. }
  13175. catch (Exception e) {
  13176. Log.e(TAG, "[Exception] startDistributionPanel()");
  13177. //e.printStackTrace();
  13178. LogUtil.errorLogInfo("", TAG, e);
  13179. }
  13180. }
  13181. // =================================================================================================
  13182. // [[ Device ]] region
  13183. // =================================================================================================
  13184. /**
  13185. * 디바이스 API 를 Load 한다.
  13186. *
  13187. * @param wpapi - 생성시 전달받은 WallPadAPI
  13188. * @return (int) - >=0 : 성공, <0 : 실패
  13189. */
  13190. private int loadRealtimemeterAPI(WallPadAPI wpapi) {
  13191. // 1. Mode Check
  13192. if (Common.GetDeviceSampleMode(getApplicationContext())) {
  13193. Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
  13194. return -1;
  13195. }
  13196. Log.i(TAG, "[loadRealtimemeterAPI] - Start");
  13197. // 2. wpapi Check
  13198. if (wpapi == null) {
  13199. Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
  13200. return -2;
  13201. }
  13202. // 3. Load API
  13203. Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
  13204. try {
  13205. mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  13206. } catch (RuntimeException re) {
  13207. LogUtil.errorLogInfo("", TAG, re);
  13208. return -100;
  13209. }
  13210. catch (Exception e) {
  13211. Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
  13212. //e.printStackTrace();
  13213. LogUtil.errorLogInfo("", TAG, e);
  13214. return -100;
  13215. }
  13216. if (mRealTimeMeterAPI == null) {
  13217. Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
  13218. return -4;
  13219. }
  13220. Log.i(TAG, "[loadRealtimemeterAPI] - OK");
  13221. return 0;
  13222. }
  13223. /**
  13224. * 제어기 상태를 가져온다.
  13225. *
  13226. * @param real - (boolean) true : 실시간 , false : 가장최근
  13227. * @return (int) - >=0 : 성공, <0 : 실패
  13228. */
  13229. @SuppressWarnings("unused")
  13230. private int updateRealtimemeterData(boolean real) {
  13231. try {
  13232. // 1. Api Load Check
  13233. if (mRealTimeMeterAPI == null) {
  13234. Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
  13235. return -1;
  13236. }
  13237. // 2. reflash
  13238. try {
  13239. int ret = mRealTimeMeterAPI.Refresh(real);
  13240. if (ret < 0) {
  13241. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
  13242. return -2;
  13243. }
  13244. } catch (RuntimeException re) {
  13245. LogUtil.errorLogInfo("", TAG, re);
  13246. return -100;
  13247. }
  13248. catch (Exception e) {
  13249. Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  13250. //e.printStackTrace();
  13251. LogUtil.errorLogInfo("", TAG, e);
  13252. return -100;
  13253. }
  13254. // 3. Range Check
  13255. if (mRealTimeMeterAPI.data == null) {
  13256. Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
  13257. return -9;
  13258. }
  13259. if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
  13260. Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
  13261. return -10;
  13262. }
  13263. if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
  13264. Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
  13265. return -11;
  13266. }
  13267. if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
  13268. Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
  13269. return -12;
  13270. }
  13271. if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
  13272. Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
  13273. return -13;
  13274. }
  13275. if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
  13276. Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
  13277. return -14;
  13278. }
  13279. // 4. Data Copy
  13280. mRealTimeMeterData = mRealTimeMeterAPI.data;
  13281. // 5. Debug msg
  13282. if (DEBUG_REALMETER_DATA_LOG_ON) {
  13283. Log.i(TAG, mRealTimeMeterData.ToDebugString());
  13284. Log.i(TAG, "[updateRealtimemeterData] - OK");
  13285. }
  13286. return 0;
  13287. } catch (RuntimeException re) {
  13288. LogUtil.errorLogInfo("", TAG, re);
  13289. return -99;
  13290. }
  13291. catch (Exception e) {
  13292. Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
  13293. //e.printStackTrace();
  13294. LogUtil.errorLogInfo("", TAG, e);
  13295. return -99;
  13296. }
  13297. }
  13298. /**
  13299. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  13300. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  13301. * 본 딜레이 코드를 임시로 적용한다.
  13302. */
  13303. @SuppressLint("HandlerLeak")
  13304. protected Handler initRealtimemeterFunctionHandler = new Handler() {
  13305. @SuppressLint("HandlerLeak")
  13306. @Override
  13307. public void handleMessage(Message msg) {
  13308. Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
  13309. if (msg.what == 0) {
  13310. if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
  13311. if (updateRealtimemeterData(false) == 0) {
  13312. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13313. }
  13314. else {
  13315. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13316. }
  13317. }
  13318. else {
  13319. Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
  13320. initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
  13321. }
  13322. }
  13323. else if (msg.what == 1) {
  13324. Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
  13325. if (mRealTimeMeterAPI != null) {
  13326. // Device_BrRegistration(true);
  13327. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  13328. int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
  13329. mWallpadDeviceSet.closeDB();
  13330. if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
  13331. saveRealmeterDataThread = new saveRealmeterData();
  13332. saveRealmeterDataThread.start();
  13333. }
  13334. // RemoveUsedData();
  13335. // ShowUsedDataGraph();
  13336. }
  13337. }
  13338. }
  13339. };
  13340. protected Handler initSmartDistributionPanelHandler = new Handler() {
  13341. @SuppressLint("HandlerLeak")
  13342. @Override
  13343. public void handleMessage(Message msg) {
  13344. Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
  13345. if (msg.what == 0) {
  13346. if (mWallPadAPI.Check_Connect()) initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13347. else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13348. } else if (msg.what == 1) {
  13349. Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
  13350. mSdbAPI = mWallPadAPI.Get_SdbController();
  13351. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  13352. mSdb_LivingRoomLightAPI.Refresh();
  13353. }
  13354. }
  13355. };
  13356. protected Handler initKNXDistributionPanelHandler = new Handler() {
  13357. @SuppressLint("HandlerLeak")
  13358. @Override
  13359. public void handleMessage(Message msg) {
  13360. Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
  13361. if (msg.what == 0) {
  13362. if (mWallPadAPI.Check_Connect()) initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
  13363. else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
  13364. } else if (msg.what == 1) {
  13365. Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
  13366. mKnxAPI = mWallPadAPI.Get_KnxController();
  13367. mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
  13368. mKnx_LivingRoomLightAPI.Refresh();
  13369. }
  13370. }
  13371. };
  13372. protected Handler initSmartIoTFunctionHandler = new Handler() {
  13373. @SuppressLint("HandlerLeak")
  13374. @Override
  13375. public void handleMessage(Message msg) {
  13376. Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
  13377. if (msg.what == 0) {
  13378. if (mWallPadAPI.Check_Connect()) initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
  13379. else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
  13380. } else if (msg.what == 1) {
  13381. Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
  13382. mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  13383. // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (상태 Off, LED Off)
  13384. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
  13385. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
  13386. if (getStrangerRecordingManagerSetting()) {
  13387. if (mSmartKeyRfDoorAPI != null) {
  13388. mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, (byte) 0x01);
  13389. }
  13390. }
  13391. if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
  13392. // 설정값을 확인하여 스마트 IoT 현관카메라의 상태를 전송한다. (거동수상자 녹화를 위한 자동 On 기능 활성화)
  13393. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  13394. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  13395. }
  13396. else {
  13397. // 설정값을 확인하여 스마트 IoT 현관카메라의 상태를 전송한다. (거동수상자 녹화를 위한 자동 On 기능 비활성화)
  13398. ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  13399. ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  13400. }
  13401. }
  13402. }
  13403. };
  13404. // 스마트현관카메라 MODE 제어
  13405. private void ctrlSmartIOTCamStatusMode(byte mode) {
  13406. try {
  13407. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
  13408. if (mSmartKeyRfDoorAPI != null) {
  13409. int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
  13410. Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
  13411. }
  13412. else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
  13413. } catch (RuntimeException re) {
  13414. LogUtil.errorLogInfo("", TAG, re);
  13415. }
  13416. catch (Exception e) {
  13417. Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
  13418. //e.printStackTrace();
  13419. LogUtil.errorLogInfo("", TAG, e);
  13420. }
  13421. }
  13422. // 스마트현관카메라 LED 상태 제어
  13423. private void ctrlSmartIOTCamLEDMode(byte mode) {
  13424. try {
  13425. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
  13426. if (mSmartKeyRfDoorAPI != null) {
  13427. int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
  13428. Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
  13429. }
  13430. else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
  13431. } catch (RuntimeException re) {
  13432. LogUtil.errorLogInfo("", TAG, re);
  13433. }
  13434. catch (Exception e) {
  13435. Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
  13436. //e.printStackTrace();
  13437. LogUtil.errorLogInfo("", TAG, e);
  13438. }
  13439. }
  13440. // =================================================================================================
  13441. // [[ Thread ]] region
  13442. // =================================================================================================
  13443. /**
  13444. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  13445. * 10분에 한번씩 저장
  13446. */
  13447. @SuppressLint("UseValueOf")
  13448. class saveRealmeterData extends Thread {
  13449. @Override
  13450. public void run() {
  13451. super.run();
  13452. Log.i(TAG, "[saveRealmeterData] ========== START ==========");
  13453. int ret;
  13454. wallpaddbmgr WallpadDBMGRforThread = null;
  13455. while(true) {
  13456. try {
  13457. Thread.sleep(1000 * 60 * 3); //3분마다
  13458. if (mRealTimeMeterAPI != null) {
  13459. ret = mRealTimeMeterAPI.Refresh(false);
  13460. if (ret == 0) {
  13461. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
  13462. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :"+ mRealTimeMeterAPI.data.Elec.Acc);
  13463. WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
  13464. WallpadDBMGRforThread.InsertRealTimeMeterData(
  13465. new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
  13466. new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
  13467. new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
  13468. new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
  13469. new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
  13470. new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
  13471. new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
  13472. new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
  13473. new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
  13474. new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
  13475. );
  13476. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  13477. Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :"+ tempInt);
  13478. if (tempInt > 6000) {
  13479. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  13480. }
  13481. WallpadDBMGRforThread.closeDB();
  13482. }
  13483. else {
  13484. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
  13485. }
  13486. }
  13487. else {
  13488. Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
  13489. }
  13490. } catch (InterruptedException e1) {
  13491. // TODO Auto-generated catch block
  13492. if (WallpadDBMGRforThread != null) {
  13493. WallpadDBMGRforThread.closeDB();
  13494. }
  13495. Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
  13496. //e1.printStackTrace();
  13497. LogUtil.errorLogInfo("", TAG, e1);
  13498. }
  13499. }
  13500. }
  13501. }
  13502. /**
  13503. * 단지서버 2.0 사용여부
  13504. * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
  13505. * **/
  13506. public boolean NewServerUse() {
  13507. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  13508. if (SetData != null) {
  13509. String serverVesionInfo = SetData.GetServerVer();
  13510. SetData.closeDB();
  13511. if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
  13512. return true;
  13513. }
  13514. }
  13515. return false;
  13516. }
  13517. /**
  13518. * 단지서버2.0 적용시에만 사용한다.
  13519. * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
  13520. * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
  13521. * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
  13522. **/
  13523. String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
  13524. String REMOTETYPE_SVR2WEB = "danji_web_control";
  13525. String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
  13526. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
  13527. try {
  13528. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13529. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13530. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13531. NodeList mNodeList = doc.getElementsByTagName("device_info");
  13532. Node mNode = mNodeList.item(0);
  13533. if (mNode != null) {
  13534. String alias = "null", twinid = "null";
  13535. NamedNodeMap attrsParam = mNode.getAttributes();
  13536. for (int j=0; j< attrsParam.getLength(); j++) {
  13537. Node attr = attrsParam.item(j);
  13538. if (attr.getNodeName().equalsIgnoreCase("alias")) alias = attr.getNodeValue();
  13539. else if (attr.getNodeName().equalsIgnoreCase("twinid")) twinid = attr.getNodeValue();
  13540. }
  13541. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13542. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13543. Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
  13544. return MOBILE_USER_AUTH_PASSED;
  13545. }
  13546. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13547. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13548. mWallpadMobileDeviceData.closeDB();
  13549. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13550. else {
  13551. Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
  13552. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13553. return strReplyMsg;
  13554. }
  13555. }
  13556. else {
  13557. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13558. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13559. return strReplyMsg;
  13560. }
  13561. }
  13562. else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13563. NodeList mNodeList = doc.getElementsByTagName("password_info");
  13564. Node mNode = mNodeList.item(0);
  13565. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13566. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13567. mWallpadStatusData.closeDB();
  13568. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
  13569. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13570. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13571. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13572. return strReplyMsg;
  13573. }
  13574. if (mNode != null) {
  13575. String strReceivedPW = "000000";
  13576. NamedNodeMap attrsParam = mNode.getAttributes();
  13577. for (int j=0; j< attrsParam.getLength(); j++) {
  13578. Node attr = attrsParam.item(j);
  13579. if (attr.getNodeName().equalsIgnoreCase("password")) strReceivedPW = attr.getNodeValue();
  13580. }
  13581. if (!checkPWValidation(strReceivedPW)) {
  13582. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13583. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13584. return strReplyMsg;
  13585. }
  13586. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13587. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13588. return WEB_USER_AUTH_PASSED;
  13589. }
  13590. else {
  13591. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13592. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13593. return strReplyMsg;
  13594. }
  13595. }
  13596. else {
  13597. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13598. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13599. return strReplyMsg;
  13600. }
  13601. }
  13602. else {
  13603. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13604. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13605. return strReplyMsg;
  13606. }
  13607. } catch (RuntimeException re) {
  13608. LogUtil.errorLogInfo("", TAG, re);
  13609. return null;
  13610. }
  13611. catch (Exception e) {
  13612. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
  13613. //e.printStackTrace();
  13614. LogUtil.errorLogInfo("", TAG, e);
  13615. return null;
  13616. }
  13617. }
  13618. public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
  13619. try {
  13620. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
  13621. // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
  13622. if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
  13623. NodeList mNodeList = ele.getElementsByTagName("device_info");
  13624. Node mNode = mNodeList.item(0);
  13625. if (mNode != null) {
  13626. String alias = "null", twinid = "null";
  13627. NamedNodeMap attrsParam = mNode.getAttributes();
  13628. for (int j=0; j< attrsParam.getLength(); j++) {
  13629. Node attr = attrsParam.item(j);
  13630. if (attr.getNodeName().equalsIgnoreCase("alias")) alias = attr.getNodeValue();
  13631. else if (attr.getNodeName().equalsIgnoreCase("twinid")) twinid = attr.getNodeValue();
  13632. }
  13633. //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
  13634. if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
  13635. Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
  13636. return MOBILE_USER_AUTH_PASSED;
  13637. }
  13638. WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
  13639. int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
  13640. mWallpadMobileDeviceData.closeDB();
  13641. if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
  13642. else {
  13643. Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
  13644. strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
  13645. return strReplyMsg;
  13646. }
  13647. }
  13648. else {
  13649. Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
  13650. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13651. return strReplyMsg;
  13652. }
  13653. }
  13654. else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
  13655. NodeList mNodeList = ele.getElementsByTagName("password_info");
  13656. Node mNode = mNodeList.item(0);
  13657. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  13658. String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
  13659. mWallpadStatusData.closeDB();
  13660. if (!checkPWValidation(strSavedWebCtrlPW)) {
  13661. Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
  13662. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13663. return strReplyMsg;
  13664. }
  13665. if (mNode != null) {
  13666. String strReceivedPW = "000000";
  13667. NamedNodeMap attrsParam = mNode.getAttributes();
  13668. for (int j=0; j< attrsParam.getLength(); j++) {
  13669. Node attr = attrsParam.item(j);
  13670. if (attr.getNodeName().equalsIgnoreCase("password")) strReceivedPW = attr.getNodeValue();
  13671. }
  13672. if (!checkPWValidation(strReceivedPW)) {
  13673. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
  13674. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13675. return strReplyMsg;
  13676. }
  13677. if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
  13678. Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
  13679. return WEB_USER_AUTH_PASSED;
  13680. }
  13681. else {
  13682. Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
  13683. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13684. return strReplyMsg;
  13685. }
  13686. }
  13687. else {
  13688. Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
  13689. strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
  13690. return strReplyMsg;
  13691. }
  13692. }
  13693. else {
  13694. Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
  13695. strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
  13696. return strReplyMsg;
  13697. }
  13698. } catch (RuntimeException re) {
  13699. LogUtil.errorLogInfo("", TAG, re);
  13700. return null;
  13701. }
  13702. catch (Exception e) {
  13703. Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
  13704. //e.printStackTrace();
  13705. LogUtil.errorLogInfo("", TAG, e);
  13706. return null;
  13707. }
  13708. }
  13709. String[] astrPreventedPWs = { "000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852" };
  13710. private boolean checkPWValidation(String strPW) {
  13711. try {
  13712. // null 확인
  13713. if (strPW == null) {
  13714. Log.w(TAG, "[checkPWValidation] strPW is null!!");
  13715. return false;
  13716. }
  13717. // 입력된 비밀번호 길이 확인
  13718. if (strPW.length() != 6) {
  13719. Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
  13720. return false;
  13721. }
  13722. // 사전 금지된 비밀번호 확인
  13723. for (int i = 0; i < astrPreventedPWs.length; i++) {
  13724. if (strPW.contains(astrPreventedPWs[i])) {
  13725. Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
  13726. return false;
  13727. }
  13728. }
  13729. /*// 연속된 비밀번호 확인
  13730. int nSerialNoCnt = 0;
  13731. int nCompareNo = 0;
  13732. int[] naPW = new int[strPW.length()];
  13733. for (int i = 0; i < naPW.length; i++)
  13734. {
  13735. naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
  13736. Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
  13737. if (i ==0) {
  13738. nCompareNo = naPW[i];
  13739. nCompareNo++;
  13740. }
  13741. else if (0 < i && i < 6) {
  13742. if (nCompareNo == naPW[i]) nSerialNoCnt++;
  13743. nCompareNo++;
  13744. }
  13745. else {
  13746. Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
  13747. }
  13748. }
  13749. if (nSerialNoCnt > 3) {
  13750. Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
  13751. return false;
  13752. }*/
  13753. // 동일한 번호 5회이상 입력 확인
  13754. int nSameNoCnt = 0;
  13755. for (int i = 0; i < strPW.length() - 1; i++) {
  13756. if (strPW.charAt(i) == strPW.charAt(i + 1)) {
  13757. nSameNoCnt++;
  13758. }
  13759. }
  13760. if (nSameNoCnt > 4) {
  13761. Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
  13762. return false;
  13763. }
  13764. // 동, 호정보 확인
  13765. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  13766. wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
  13767. DBMGR.closeDB();
  13768. String strDong = addr.Dong;
  13769. String strHo = addr.Ho;
  13770. Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
  13771. if (strPW.substring(0,4).contains(strDong)) {
  13772. Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
  13773. return false;
  13774. }
  13775. if (strPW.substring(0,4).contains(strHo)) {
  13776. Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
  13777. return false;
  13778. }
  13779. return true;
  13780. } catch (RuntimeException re) {
  13781. LogUtil.errorLogInfo("", TAG, re);
  13782. return false;
  13783. }
  13784. catch (Exception e) {
  13785. Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
  13786. //e.printStackTrace();
  13787. LogUtil.errorLogInfo("", TAG, e);
  13788. return false;
  13789. }
  13790. }
  13791. public String iCMDProcOnePass(Element ele) {
  13792. String[] strTarget = { "null", "null", "null" }; // name, id, msg_no
  13793. String[] strDeviceInfo = { "null", "null" }; // alias, twinid
  13794. String strAction = "null", strTargetLobbyIP = "null";
  13795. try {
  13796. // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
  13797. String retStr = CheckiCMDProc("remote_access_onepass");
  13798. if (retStr != null) return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13799. // 단지서버 2.0 사용여부 확인
  13800. if (!NewServerUse()) {
  13801. return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13802. }
  13803. // 메시지 송신지 구분
  13804. NodeList items = ele.getElementsByTagName("target");
  13805. Node item = items.item(0);
  13806. if (item != null) {
  13807. NamedNodeMap attrs = item.getAttributes();
  13808. for (int j = 0; j< attrs.getLength(); j++) {
  13809. Node attr = attrs.item(j);
  13810. if (attr.getNodeName().equalsIgnoreCase("name")) strTarget[0] = attr.getNodeValue();
  13811. else if (attr.getNodeName().equalsIgnoreCase("id")) strTarget[1] = attr.getNodeValue();
  13812. else if (attr.getNodeName().equalsIgnoreCase("msg_no")) strTarget[2] = attr.getNodeValue();
  13813. }
  13814. }
  13815. // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
  13816. if (NewServerUse()) {
  13817. String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
  13818. if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
  13819. if (ServerCheckResult.contains("fail")) return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13820. else if (ServerCheckResult.contains("deny")) return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
  13821. else if (ServerCheckResult.contains("none")) return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
  13822. else return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13823. }
  13824. }
  13825. NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
  13826. Node itemDeviceParam = itemsDeviceParam.item(0);
  13827. if (itemDeviceParam != null) {
  13828. NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
  13829. for (int j=0; j< attrsParam.getLength(); j++) {
  13830. Node attr = attrsParam.item(j);
  13831. if (attr.getNodeName().equalsIgnoreCase("alias")) strDeviceInfo[0] = attr.getNodeValue();
  13832. else if (attr.getNodeName().equalsIgnoreCase("twinid")) strDeviceInfo[1] = attr.getNodeValue();
  13833. }
  13834. }
  13835. else {
  13836. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13837. }
  13838. // 명령어 구분
  13839. NodeList itemsaction = ele.getElementsByTagName("action");
  13840. Node itemaction = itemsaction.item(0);
  13841. Node text = itemaction.getFirstChild();
  13842. strAction = text.getNodeValue();
  13843. strAction = trimquotation(strAction);
  13844. // 문열림 타겟 로비폰 IP
  13845. NodeList itemsParam = ele.getElementsByTagName("params");
  13846. Node itemParam = itemsParam.item(0);
  13847. if (itemParam != null) {
  13848. NamedNodeMap attrsParam = itemParam.getAttributes();
  13849. for (int j = 0; j < attrsParam.getLength(); j++) {
  13850. Node attr = attrsParam.item(j);
  13851. if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) strTargetLobbyIP = attr.getNodeValue();
  13852. }
  13853. }
  13854. Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
  13855. if (strAction.equalsIgnoreCase("authorize_request")) {
  13856. sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
  13857. return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
  13858. }
  13859. else {
  13860. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13861. }
  13862. } catch (RuntimeException re) {
  13863. LogUtil.errorLogInfo("", TAG, re);
  13864. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13865. }
  13866. catch (Exception e) {
  13867. Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
  13868. //e.printStackTrace();
  13869. LogUtil.errorLogInfo("", TAG, e);
  13870. return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
  13871. }
  13872. }
  13873. public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
  13874. try {
  13875. String strReplyXml = XMLHeader;
  13876. strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
  13877. strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
  13878. strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
  13879. strReplyXml += " <action>\"" + strAction + "\"</action>\n";
  13880. strReplyXml += " </service>\n";
  13881. strReplyXml += "</imap>";
  13882. return strReplyXml;
  13883. } catch (RuntimeException re) {
  13884. LogUtil.errorLogInfo("", TAG, re);
  13885. return "ERROR";
  13886. }
  13887. catch (Exception e) {
  13888. Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
  13889. //e.printStackTrace();
  13890. LogUtil.errorLogInfo("", TAG, e);
  13891. return "ERROR";
  13892. }
  13893. }
  13894. public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
  13895. try {
  13896. Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName +"]");
  13897. iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
  13898. miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
  13899. miMAPLobbyOnePass.SetRetCtr(new RetProci(){
  13900. @Override
  13901. public void ProcSuccess() {
  13902. Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
  13903. }
  13904. @Override
  13905. public void ProcError() {
  13906. Log.i(TAG, "[sendLobbyOnePass.ProcError]");
  13907. }
  13908. @Override
  13909. public void ProcDoing() {
  13910. Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
  13911. }
  13912. });
  13913. } catch (RuntimeException re) {
  13914. LogUtil.errorLogInfo("", TAG, re);
  13915. }
  13916. catch (Exception e) {
  13917. Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
  13918. //e.printStackTrace();
  13919. LogUtil.errorLogInfo("", TAG, e);
  13920. }
  13921. }
  13922. private void saveBlackoutStatus(boolean bOccurred) {
  13923. try {
  13924. Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
  13925. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  13926. SharedPreferences.Editor mEditor = mSharedPreferences.edit();
  13927. mEditor.putBoolean("status", bOccurred);
  13928. mEditor.commit();
  13929. } catch (RuntimeException re) {
  13930. LogUtil.errorLogInfo("", TAG, re);
  13931. }
  13932. catch (Exception e) {
  13933. Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
  13934. //e.printStackTrace();
  13935. LogUtil.errorLogInfo("", TAG, e);
  13936. }
  13937. }
  13938. private boolean getBlackoutStatus() {
  13939. try {
  13940. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  13941. return mSharedPreferences.getBoolean("status", false);
  13942. } catch (RuntimeException re) {
  13943. LogUtil.errorLogInfo("", TAG, re);
  13944. return false;
  13945. }
  13946. catch (Exception e) {
  13947. Log.e(TAG, "[Exception] getBlackoutStatus()");
  13948. //e.printStackTrace();
  13949. LogUtil.errorLogInfo("", TAG, e);
  13950. return false;
  13951. }
  13952. }
  13953. /**
  13954. * JEFF, 2019.12.25
  13955. * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
  13956. * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
  13957. * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
  13958. * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
  13959. */
  13960. int MAX_WALLPADCALL_LIVE_CNT = 2;
  13961. int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
  13962. public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
  13963. public static boolean bWallPadRecoder = false; // WallPadCall의 Live 상태를 나타낸다.
  13964. int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
  13965. Handler handlerCheckWallPadCallLive = new Handler() {
  13966. public void handleMessage(Message msg) {
  13967. super.handleMessage(msg);
  13968. sendWallPadCallLiveBR_Request();
  13969. handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
  13970. }
  13971. };
  13972. private void sendWallPadCallLiveBR_Request() {
  13973. try {
  13974. // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
  13975. Intent mIntent = new Intent();
  13976. mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
  13977. getApplicationContext().sendBroadcast(mIntent);
  13978. if (nWallPadCallACKCnt >= 0) {
  13979. nWallPadCallACKCnt--;
  13980. }
  13981. else {
  13982. bWallPadCallLive = false;
  13983. bWallPadRecoder = false;
  13984. Common.bWallPadCallLive = bWallPadCallLive;
  13985. //jglee - 변수 초기화
  13986. Common.bWallPadCallingLive = false;
  13987. }
  13988. if (bWallPadCallLive != getCallAppRunning()) {
  13989. setCallAppRunning(bWallPadCallLive);
  13990. }
  13991. Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
  13992. } catch (RuntimeException re) {
  13993. LogUtil.errorLogInfo("", TAG, re);
  13994. }
  13995. catch (Exception e) {
  13996. Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
  13997. //e.printStackTrace();
  13998. LogUtil.errorLogInfo("", TAG, e);
  13999. }
  14000. }
  14001. BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
  14002. @Override
  14003. public void onReceive(Context context, Intent intent) {
  14004. try {
  14005. String strActionName = intent.getAction();
  14006. // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
  14007. if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  14008. bWallPadCallLive = true;
  14009. Common.bWallPadCallLive = bWallPadCallLive;
  14010. //여기서 삭제
  14011. // if(MainActivity.CallBrList.size()>0) {
  14012. // Log.d(TAG, "jglee - CallBR Remove");
  14013. // MainActivity.CallBrList.remove(0);
  14014. // if(MainActivity.CallBrList.size() > 0) {
  14015. // //Log.d(TAG, "jglee - Call Next 호출 > Action : " + MainActivity.CallBrList.get(0).getAction() + ", Extra : " + MainActivity.CallBrList.get(0).getIntExtra(Common.BR_MAIN_NOTI.KIND,0) );
  14016. // //jglee - 내부 이슈가 수정이 되지 않으면, 아래 핸들러를 이용하여 사용 필요
  14017. // if(false)
  14018. // {
  14019. // if(MainActivity.CallIntentHandler!=null)
  14020. // MainActivity.CallIntentHandler.sendMessageDelayed(MainActivity.CallIntentHandler.obtainMessage(), 1500);
  14021. // }
  14022. // else
  14023. // {
  14024. // getApplicationContext().sendBroadcast(MainActivity.CallBrList.get(0));
  14025. // Log.d(TAG, "jglee - Call 직접 Next 호출");
  14026. // }
  14027. //
  14028. // }
  14029. // }
  14030. nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
  14031. Log.w(TAG,"[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "]");
  14032. //jglee 여기서 Extra변수값을 적용
  14033. boolean isCalling = false;
  14034. isCalling = intent.getBooleanExtra("isCalling", false);
  14035. if(Common.bWallPadCallingLive != isCalling)
  14036. {
  14037. if(isCalling)
  14038. {
  14039. //현관문사용일 경우
  14040. Intent Newintent = new Intent();
  14041. Newintent.setAction(Common.BR_RECORD_NOT_USE);
  14042. getApplicationContext().sendBroadcast(Newintent);
  14043. }
  14044. else
  14045. {
  14046. //현관문 사용안하는 경우
  14047. Intent Newintent = new Intent();
  14048. Newintent.setAction(Common.BR_RECORD_DELAY);
  14049. getApplicationContext().sendBroadcast(Newintent);
  14050. Log.w(TAG, "[WallPadCallLiveBRCheck] BR_RECORD_DELAY");
  14051. }
  14052. }
  14053. Common.bWallPadCallingLive = isCalling;
  14054. }
  14055. else {
  14056. Log.w(TAG,"[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
  14057. }
  14058. } catch (RuntimeException re) {
  14059. LogUtil.errorLogInfo("", TAG, re);
  14060. }
  14061. catch (Exception e) {
  14062. Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
  14063. //e.printStackTrace();
  14064. LogUtil.errorLogInfo("", TAG, e);
  14065. }
  14066. }
  14067. };
  14068. static class CALLCTRLHANDLERMSG {
  14069. static final int RELEASE_BLOCK_FRONTCALL = 100;
  14070. }
  14071. boolean bBlockFrontCall = false;
  14072. Handler handlerCallCtrl = new Handler() {
  14073. public void handleMessage(Message msg) {
  14074. super.handleMessage(msg);
  14075. int nMSG = msg.what;
  14076. switch (nMSG) {
  14077. case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
  14078. bBlockFrontCall = false;
  14079. break;
  14080. }
  14081. }
  14082. };
  14083. /**
  14084. * JEFF, 2019.12.31
  14085. * WallPadCall 실행여부를 DB에 저장한다.
  14086. * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
  14087. * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
  14088. */
  14089. public void setCallAppRunning(boolean bRunning) {
  14090. try {
  14091. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  14092. mWallpadStatusData.SetCallAPKStatus(bRunning);
  14093. mWallpadStatusData.closeDB();
  14094. } catch (RuntimeException re) {
  14095. LogUtil.errorLogInfo("", TAG, re);
  14096. }
  14097. catch (Exception e) {
  14098. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  14099. //e.printStackTrace();
  14100. LogUtil.errorLogInfo("", TAG, e);
  14101. }
  14102. }
  14103. private boolean getCallAppRunning() {
  14104. boolean bRunning = false;
  14105. try {
  14106. WallpadStatusData WallpadStatusData = new WallpadStatusData(getApplicationContext());
  14107. bRunning = WallpadStatusData.GetCallAPKStatusRunning();
  14108. WallpadStatusData.closeDB();
  14109. // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
  14110. return bRunning;
  14111. } catch (RuntimeException re) {
  14112. LogUtil.errorLogInfo("", TAG, re);
  14113. return false;
  14114. }
  14115. catch (Exception e) {
  14116. Log.d(TAG, "[Exception] getCallAppRunning()");
  14117. //e.printStackTrace();
  14118. LogUtil.errorLogInfo("", TAG, e);
  14119. return false;
  14120. }
  14121. }
  14122. /**
  14123. * 통화앱 종료코드
  14124. */
  14125. public void killWallPadCall() {
  14126. try {
  14127. Log.i(TAG, "[killWallPadCall] ===== START =====");
  14128. // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  14129. // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14130. Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
  14131. // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
  14132. // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14133. // android.os.Process.killProcess(nWallPadCallPID);
  14134. // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
  14135. // if(list != null){
  14136. // for(int i=0;i<list.size();++i){
  14137. // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
  14138. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14139. // android.os.Process.killProcess(pid);
  14140. // }
  14141. // }
  14142. // }
  14143. // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
  14144. // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
  14145. // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
  14146. // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
  14147. // android.os.Process.killProcess(pid);
  14148. } catch (RuntimeException re) {
  14149. LogUtil.errorLogInfo("", TAG, re);
  14150. }
  14151. catch (Exception e) {
  14152. Log.e(TAG, "[Exception] killWallPadCall()");
  14153. //e.printStackTrace();
  14154. LogUtil.errorLogInfo("", TAG, e);
  14155. }
  14156. }
  14157. private void checkForegroundActivity() {
  14158. try {
  14159. // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
  14160. ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  14161. List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
  14162. ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
  14163. Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
  14164. } catch (RuntimeException re) {
  14165. LogUtil.errorLogInfo("", TAG, re);
  14166. }
  14167. catch (Exception e) {
  14168. Log.e(TAG, "[Exception] checkForegroundActivity()");
  14169. //e.printStackTrace();
  14170. LogUtil.errorLogInfo("", TAG, e);
  14171. }
  14172. }
  14173. /**
  14174. * JEFF, 2020.01.04
  14175. * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
  14176. * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
  14177. * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
  14178. * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
  14179. */
  14180. static long lConnectionPeriod = 0;
  14181. static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
  14182. boolean bRingGeneratorRun = false;
  14183. private void startIGW300RingGenerator() {
  14184. try {
  14185. Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14186. if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
  14187. bRingGeneratorRun = true;
  14188. mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
  14189. mIGW300RingGeneratorThread.start();
  14190. }
  14191. else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
  14192. } catch (RuntimeException re) {
  14193. LogUtil.errorLogInfo("", TAG, re);
  14194. }
  14195. catch (Exception e) {
  14196. Log.e(TAG, "[Exception] startIGW300RingGenerator()");
  14197. //e.printStackTrace();
  14198. LogUtil.errorLogInfo("", TAG, e);
  14199. }
  14200. }
  14201. private void stopIGW300RingGenerator() {
  14202. try {
  14203. Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14204. if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
  14205. lConnectionPeriod = -999;
  14206. bRingGeneratorRun = false;
  14207. mIGW300RingGeneratorThread = null;
  14208. }
  14209. else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
  14210. } catch (RuntimeException re) {
  14211. LogUtil.errorLogInfo("", TAG, re);
  14212. }
  14213. catch (Exception e) {
  14214. Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
  14215. //e.printStackTrace();
  14216. LogUtil.errorLogInfo("", TAG, e);
  14217. }
  14218. }
  14219. private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
  14220. private class IGW300RingGeneratorThread extends Thread {
  14221. public IGW300RingGeneratorThread() {
  14222. Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
  14223. }
  14224. public void run() {
  14225. try {
  14226. Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
  14227. if (bRingGeneratorRun) Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
  14228. lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
  14229. while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
  14230. if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
  14231. Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
  14232. try {
  14233. if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
  14234. } catch (InterruptedException e) {
  14235. Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
  14236. //e.printStackTrace();
  14237. LogUtil.errorLogInfo("", TAG, e);
  14238. }
  14239. }
  14240. bRingGeneratorRun = false;
  14241. Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
  14242. } catch (RuntimeException re) {
  14243. LogUtil.errorLogInfo("", TAG, re);
  14244. }
  14245. catch (Exception e) {
  14246. Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
  14247. //e.printStackTrace();
  14248. LogUtil.errorLogInfo("", TAG, e);
  14249. }
  14250. }
  14251. }
  14252. private void sendPSTNRingEvent(int nKeyCode) {
  14253. try {
  14254. Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
  14255. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  14256. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  14257. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  14258. intent.putExtra("keycode",nKeyCode);
  14259. getApplicationContext().sendBroadcast(intent);
  14260. } catch (RuntimeException re) {
  14261. LogUtil.errorLogInfo("", TAG, re);
  14262. }
  14263. catch (Exception e) {
  14264. Log.e(TAG, "[Exception] sendPSTNRingEvent()");
  14265. //e.printStackTrace();
  14266. LogUtil.errorLogInfo("", TAG, e);
  14267. }
  14268. }
  14269. /**
  14270. * 월패드 타입 판별
  14271. * @return bResult
  14272. * false: 메인월패드
  14273. * true: 서브월패드
  14274. */
  14275. public boolean getIsSubWallpad() {
  14276. boolean bResult = false;
  14277. try {
  14278. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14279. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  14280. mWallpadDeviceSet.closeDB();
  14281. if(DBinfo != null) {
  14282. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  14283. else bResult = false;
  14284. }
  14285. } catch (RuntimeException re) {
  14286. LogUtil.errorLogInfo("", TAG, re);
  14287. }
  14288. catch (Exception e) {
  14289. Log.e(TAG, "[Exception] getIsSubWallpad()");
  14290. //e.printStackTrace();
  14291. LogUtil.errorLogInfo("", TAG, e);
  14292. }
  14293. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  14294. return bResult;
  14295. }
  14296. /**
  14297. * JEFF, 2020.02.05
  14298. * 월패드 비상접점 신호 사용 여부 확인
  14299. */
  14300. public boolean getEmergencyIOUsage() {
  14301. boolean bResult = false;
  14302. try {
  14303. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  14304. bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
  14305. mWallpadDeviceSet.closeDB();
  14306. } catch (RuntimeException re) {
  14307. LogUtil.errorLogInfo("", TAG, re);
  14308. }
  14309. catch (Exception e) {
  14310. Log.e(TAG, "[Exception] getEmergencyIOUsage()");
  14311. //e.printStackTrace();
  14312. LogUtil.errorLogInfo("", TAG, e);
  14313. }
  14314. Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
  14315. return bResult;
  14316. }
  14317. /**
  14318. * JEFF, 2020.02.05
  14319. * 거동수상자 녹화기능 활성화 확인
  14320. * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
  14321. * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
  14322. * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
  14323. */
  14324. public boolean getStrangerRecordingManagerSetting() {
  14325. boolean bResult = false;
  14326. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14327. try {
  14328. int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14329. boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
  14330. mWallpadDeviceSet.closeDB();
  14331. if (nFrontCam[0] == COMPONENT_USE) {
  14332. if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
  14333. if (bRecord) bResult = true;
  14334. else bResult = false;
  14335. }
  14336. else bResult = false;
  14337. }
  14338. else bResult = false;
  14339. } catch (RuntimeException re) {
  14340. LogUtil.errorLogInfo("", TAG, re);
  14341. mWallpadDeviceSet.closeDB();
  14342. }
  14343. catch (Exception e) {
  14344. mWallpadDeviceSet.closeDB();
  14345. Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
  14346. //e.printStackTrace();
  14347. LogUtil.errorLogInfo("", TAG, e);
  14348. }
  14349. Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
  14350. return bResult;
  14351. }
  14352. /**
  14353. * Edited by jeff (2020.06.22)
  14354. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  14355. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  14356. * @param bOn
  14357. */
  14358. private void sendLCDBacklightStatus(boolean bOn) {
  14359. try {
  14360. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  14361. Intent mIntent = new Intent();
  14362. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  14363. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  14364. getApplicationContext().sendBroadcast(mIntent);
  14365. } catch (RuntimeException re) {
  14366. LogUtil.errorLogInfo("", TAG, re);
  14367. }
  14368. catch (Exception e) {
  14369. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  14370. //e.printStackTrace();
  14371. LogUtil.errorLogInfo("", TAG, e);
  14372. }
  14373. }
  14374. // 명칭 관련
  14375. boolean bRoomNameLog = true;
  14376. public static final int HEATING = 1;
  14377. public static final int LIGHT = 2;
  14378. private String[] mRoomNameList_Light = null; //조명 방 명칭
  14379. private String[] mRoomNameList_Heating = null; //난방 방 명칭
  14380. private String[] mDefaultRoomNameList = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14381. private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
  14382. private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14383. private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14384. private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
  14385. /**
  14386. * DB 에서 룸이름 정보를 가져온다.
  14387. *
  14388. * @return (String []) null - 실패, not null
  14389. */
  14390. private String[] getDBRoomName() {
  14391. try {
  14392. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14393. String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
  14394. wallpadStatusData.closeDB();
  14395. if (strRoomNameList == null) {
  14396. Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
  14397. return null;
  14398. }
  14399. if (bRoomNameLog) {
  14400. for (int i = 0; i < strRoomNameList.length; i++)
  14401. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14402. }
  14403. return strRoomNameList;
  14404. } catch (RuntimeException re) {
  14405. LogUtil.errorLogInfo("", TAG, re);
  14406. }
  14407. catch (Exception e) {
  14408. Log.e(TAG, "[Exception] getDBRoomName()");
  14409. //e.printStackTrace();
  14410. LogUtil.errorLogInfo("", TAG, e);
  14411. }
  14412. return null;
  14413. }
  14414. /**
  14415. * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
  14416. *
  14417. * @param nDeviceType - int
  14418. * @return (String []) null - 실패, not null
  14419. */
  14420. private String[] getDBRoomName(int nDeviceType) {
  14421. try {
  14422. String[] strRoomNameList = null;
  14423. WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
  14424. if (nDeviceType == HEATING) {
  14425. strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
  14426. }
  14427. else {
  14428. strRoomNameList = wallpadStatusData.GetDevRoomName("light");
  14429. }
  14430. wallpadStatusData.closeDB();
  14431. if (strRoomNameList == null) {
  14432. Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
  14433. return null;
  14434. }
  14435. if (bRoomNameLog) {
  14436. for (int i = 0; i < strRoomNameList.length; i++)
  14437. Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
  14438. }
  14439. return strRoomNameList;
  14440. } catch (RuntimeException re) {
  14441. LogUtil.errorLogInfo("", TAG, re);
  14442. }
  14443. catch (Exception e) {
  14444. Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
  14445. //e.printStackTrace();
  14446. LogUtil.errorLogInfo("", TAG, e);
  14447. }
  14448. return null;
  14449. }
  14450. /**
  14451. * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
  14452. **/
  14453. private void getRoomName() {
  14454. try {
  14455. Log.i(TAG, "[getRoomName] ====================");
  14456. // WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14457. // boolean bRoomNameEach = wallpadDeviceSet.GetEachRoomNameInfo();
  14458. // wallpadDeviceSet.closeDB();
  14459. // Log.i(TAG, "[getRoomName] bRoomNameEach [" + bRoomNameEach + "]");
  14460. //
  14461. // if (bRoomNameEach) {
  14462. // // 명칭 난방, 조명 분리 사용
  14463. // mRoomNameList_Light = getDBRoomName(LIGHT);
  14464. // if (mRoomNameList_Light == null) {
  14465. // mRoomNameList_Light = mDefaultRoomNameList_Light;
  14466. // }
  14467. //
  14468. // if (getEasyModeUXUsage()) {
  14469. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  14470. // }
  14471. // else {
  14472. // mRoomNameList_Heating = getDBRoomName(HEATING);
  14473. // if (mRoomNameList_Heating == null) {
  14474. // mRoomNameList_Heating = mDefaultRoomNameList_Heating;
  14475. // }
  14476. // }
  14477. // }
  14478. // else {
  14479. // // 명칭 통합사용
  14480. // mRoomNameList_Light = getDBRoomName();
  14481. // if (mRoomNameList_Light == null) {
  14482. // mRoomNameList_Light = mDefaultRoomNameList;
  14483. // }
  14484. //
  14485. // if (getEasyModeUXUsage()) {
  14486. // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
  14487. // }
  14488. // else {
  14489. // mRoomNameList_Heating = getDBRoomName();
  14490. // if (mRoomNameList_Heating == null) {
  14491. // mRoomNameList_Heating = mDefaultRoomNameList;
  14492. // }
  14493. // }
  14494. // }
  14495. //
  14496. // if (bRoomNameLog) {
  14497. // for (int i = 0; i < mRoomNameList_Light.length; i++) {
  14498. // Log.i(TAG, "[getRoomName] mRoomNameList_Light[" + i + "] " + mRoomNameList_Light[i]);
  14499. // }
  14500. //
  14501. // for (int i = 0; i < mRoomNameList_Heating.length; i++) {
  14502. // Log.i(TAG, "[getRoomName] mRoomNameList_Heating[" + i + "] " + mRoomNameList_Heating[i]);
  14503. // }
  14504. // }
  14505. } catch (RuntimeException re) {
  14506. LogUtil.errorLogInfo("", TAG, re);
  14507. }
  14508. catch (Exception e) {
  14509. Log.e(TAG, "[Exception] getRoomName()");
  14510. //e.printStackTrace();
  14511. LogUtil.errorLogInfo("", TAG, e);
  14512. }
  14513. }
  14514. public boolean getEasyModeUXUsage() {
  14515. try {
  14516. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
  14517. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  14518. deviceSet.closeDB();
  14519. WallpadStatusData data = new WallpadStatusData(getApplicationContext());
  14520. boolean bUse = data.GetEasyModeUxUse();
  14521. data.closeDB();
  14522. Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
  14523. return bSupport & bUse;
  14524. } catch (RuntimeException re) {
  14525. LogUtil.errorLogInfo("", TAG, re);
  14526. }
  14527. catch (Exception e) {
  14528. Log.e(TAG, "[Exception] getEasyModeUXUsage()");
  14529. //e.printStackTrace();
  14530. LogUtil.errorLogInfo("", TAG, e);
  14531. }
  14532. return false;
  14533. }
  14534. /**
  14535. * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
  14536. * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
  14537. * 재설정 5초 후 월패드 재부팅을 실행한다.
  14538. * 2020.11.18 SEULKI
  14539. */
  14540. public void checkDoorCamConfig() {
  14541. try {
  14542. if (Build.VERSION.SDK_INT > 23) {
  14543. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  14544. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  14545. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  14546. || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
  14547. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  14548. if (!checkAvailableBSPDoorCamConfig()) {
  14549. Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
  14550. return;
  14551. }
  14552. if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
  14553. Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
  14554. if(mIOInterface!=null) mIOInterface.setCameraConfigure(getDBDoorCamConfig());
  14555. // 재부팅
  14556. setDefaultLauncher();
  14557. Intent intent = new Intent();
  14558. if(intent!=null)
  14559. {
  14560. intent.setAction(define.NOTIFY_ACNAME);
  14561. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
  14562. getApplicationContext().sendBroadcast(intent);
  14563. }
  14564. }
  14565. }
  14566. }
  14567. }
  14568. catch (RuntimeException re)
  14569. {
  14570. LogUtil.errorLogInfo("", "", re);
  14571. }
  14572. catch (Exception e) {
  14573. Log.e(TAG, "[Exception] checkDoorCamConfig(");
  14574. LogUtil.errorLogInfo("", "", e);
  14575. }
  14576. }
  14577. /**
  14578. * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
  14579. * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
  14580. * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
  14581. * @return true: 지원, false: 미지원
  14582. */
  14583. int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
  14584. private boolean checkAvailableBSPDoorCamConfig() {
  14585. try {
  14586. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  14587. Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
  14588. if (nCurrentVer >= nCriterionVer) {
  14589. return true;
  14590. }
  14591. else return false;
  14592. } catch (RuntimeException re) {
  14593. LogUtil.errorLogInfo("", TAG, re);
  14594. return false;
  14595. }
  14596. catch (Exception e) {
  14597. Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
  14598. //e.printStackTrace();
  14599. LogUtil.errorLogInfo("", TAG, e);
  14600. return false;
  14601. }
  14602. }
  14603. /**
  14604. * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14605. * @return 1 - 스마트현관카메라
  14606. * 0 - 일반현관카메라
  14607. * @return 0 - 스마트현관카메라
  14608. * 2 - 스마트현관카메라 좌우반전
  14609. * 1 - 일반현관카메라
  14610. * 2020.11.18 SEULKI
  14611. */
  14612. public int getBSPDoorCamConfig() {
  14613. InputStreamReader is = null;
  14614. try {
  14615. Runtime mRuntime = Runtime.getRuntime();
  14616. String cmd = "getprop camera.setting.value";
  14617. if(mRuntime!=null)
  14618. {
  14619. Process mProcess = mRuntime.exec(cmd);
  14620. is = new InputStreamReader(mProcess.getInputStream());
  14621. BufferedReader br = new BufferedReader(is);
  14622. String line;
  14623. String strResult = null;
  14624. if(br!=null)
  14625. {
  14626. while ((line = br.readLine()) != null) {
  14627. strResult = line;
  14628. }
  14629. if(strResult!=null)
  14630. {
  14631. Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
  14632. if (strResult.equals("0")) {
  14633. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
  14634. return 0;
  14635. } else if (strResult.equals("1")) {
  14636. Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
  14637. return 1;
  14638. } else if (strResult.equals("2")) {
  14639. Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
  14640. return 2;
  14641. } else {
  14642. Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
  14643. return -1;
  14644. }
  14645. }
  14646. }
  14647. }
  14648. return -1;
  14649. } catch (Exception e) {
  14650. Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
  14651. e.printStackTrace();
  14652. return -1;
  14653. }
  14654. finally {
  14655. if(is!=null)
  14656. {
  14657. try {
  14658. is.close();
  14659. } catch (IOException e) {
  14660. LogUtil.errorLogInfo("", TAG, e);
  14661. }
  14662. is =null;
  14663. }
  14664. }
  14665. }
  14666. /**
  14667. * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
  14668. * @return 0 - 스마트현관카메라
  14669. * 2 - 스마트현관카메라 좌우반전
  14670. * 1 - 일반현관카메라
  14671. * 2020.11.18 SEULKI
  14672. */
  14673. public int getDBDoorCamConfig() {
  14674. try {
  14675. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14676. if(mWallpadDeviceSet!=null)
  14677. {
  14678. int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
  14679. boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
  14680. mWallpadDeviceSet.closeDB();
  14681. if(nType!=null)
  14682. {
  14683. Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
  14684. if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
  14685. Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA");
  14686. if (bFlip) {
  14687. Log.d(TAG, "[getDBDoorCamConfig] BSP - SMART IOT FLIP CAMERA");
  14688. return 2;
  14689. } else {
  14690. Log.d(TAG, "[getDBDoorCamConfig] BSP - SMART IOT CAMERA");
  14691. return 0;
  14692. }
  14693. } else {
  14694. Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
  14695. return 1;
  14696. }
  14697. }
  14698. }
  14699. return -1;
  14700. } catch (Exception e) {
  14701. Log.e(TAG, "[Exception] getDBDoorCamConfig()");
  14702. e.printStackTrace();
  14703. return -1;
  14704. }
  14705. }
  14706. /**
  14707. * 공기질 센서 사용여부 확인
  14708. * @return true - 사용함, false: 사용안함
  14709. */
  14710. boolean bAirQualityEnable = false;
  14711. private boolean getAirQualityUsage() {
  14712. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  14713. try {
  14714. int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
  14715. mWallpadDeviceSet.closeDB();
  14716. if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  14717. bAirQualityEnable = true;
  14718. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable +"]");
  14719. }
  14720. else {
  14721. bAirQualityEnable = false;
  14722. Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable +"]");
  14723. }
  14724. return bAirQualityEnable;
  14725. } catch (RuntimeException re) {
  14726. LogUtil.errorLogInfo("", TAG, re);
  14727. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14728. return false;
  14729. }
  14730. catch (Exception e) {
  14731. Log.e(TAG, "[Exception] getAirQualityUsage()");
  14732. //e.printStackTrace();
  14733. LogUtil.errorLogInfo("", TAG, e);
  14734. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  14735. return false;
  14736. }
  14737. }
  14738. String strAirQualityFWVer = "";
  14739. String strAirQualityProtocolVer = "";
  14740. String strAirQualityInfo = "";
  14741. private String getAirQualityInfo() {
  14742. try {
  14743. AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
  14744. if (mAirQualitySensorAPI != null) {
  14745. int nRet = mAirQualitySensorAPI.Refresh(false);
  14746. if (nRet >= 0) {
  14747. Log.i(TAG, "[getAirQualityInfo] ");
  14748. DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
  14749. strAirQualityFWVer = "FW" + (int)(mAirQualityInfo.FWVer_Year +2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
  14750. strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
  14751. strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
  14752. return strAirQualityInfo;
  14753. }
  14754. else return "FAIL";
  14755. }
  14756. else return "NULL";
  14757. } catch (RuntimeException re) {
  14758. LogUtil.errorLogInfo("", TAG, re);
  14759. return "ERROR";
  14760. }
  14761. catch (Exception e) {
  14762. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14763. //e.printStackTrace();
  14764. LogUtil.errorLogInfo("", TAG, e);
  14765. return "ERROR";
  14766. }
  14767. }
  14768. private String getAOSVerCode() {
  14769. try {
  14770. int nOSVer = Build.VERSION.SDK_INT;
  14771. switch (nOSVer) {
  14772. case Build.VERSION_CODES.BASE:
  14773. return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
  14774. case Build.VERSION_CODES.BASE_1_1:
  14775. return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
  14776. case Build.VERSION_CODES.CUPCAKE:
  14777. return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
  14778. case Build.VERSION_CODES.DONUT:
  14779. return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
  14780. case Build.VERSION_CODES.ECLAIR:
  14781. return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
  14782. case Build.VERSION_CODES.ECLAIR_0_1:
  14783. return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
  14784. case Build.VERSION_CODES.ECLAIR_MR1:
  14785. return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
  14786. case Build.VERSION_CODES.FROYO:
  14787. return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
  14788. case Build.VERSION_CODES.GINGERBREAD:
  14789. return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
  14790. case Build.VERSION_CODES.GINGERBREAD_MR1:
  14791. return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
  14792. case Build.VERSION_CODES.HONEYCOMB:
  14793. return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
  14794. case Build.VERSION_CODES.HONEYCOMB_MR1:
  14795. return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
  14796. case Build.VERSION_CODES.HONEYCOMB_MR2:
  14797. return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
  14798. case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
  14799. return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
  14800. case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
  14801. return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
  14802. case Build.VERSION_CODES.JELLY_BEAN:
  14803. return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
  14804. case Build.VERSION_CODES.JELLY_BEAN_MR1:
  14805. return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
  14806. case Build.VERSION_CODES.JELLY_BEAN_MR2:
  14807. return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
  14808. case Build.VERSION_CODES.KITKAT:
  14809. return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
  14810. case Build.VERSION_CODES.KITKAT_WATCH:
  14811. return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
  14812. case Build.VERSION_CODES.LOLLIPOP:
  14813. return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
  14814. case Build.VERSION_CODES.LOLLIPOP_MR1:
  14815. return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
  14816. case Build.VERSION_CODES.M:
  14817. return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
  14818. case Build.VERSION_CODES.N:
  14819. return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
  14820. case Build.VERSION_CODES.N_MR1:
  14821. return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
  14822. case Build.VERSION_CODES.O:
  14823. return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
  14824. case Build.VERSION_CODES.O_MR1:
  14825. return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
  14826. case Build.VERSION_CODES.P:
  14827. return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
  14828. case Build.VERSION_CODES.CUR_DEVELOPMENT:
  14829. return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
  14830. default:
  14831. return "SDK(" + nOSVer + ")/UNKNOWN";
  14832. }
  14833. } catch (RuntimeException re) {
  14834. LogUtil.errorLogInfo("", TAG, re);
  14835. return "ERROR";
  14836. }
  14837. catch (Exception e) {
  14838. Log.e(TAG, "[Exception] getAirQualityInfo()");
  14839. //e.printStackTrace();
  14840. LogUtil.errorLogInfo("", TAG, e);
  14841. return "ERROR";
  14842. }
  14843. }
  14844. /** 조명 ON/OFF 상태 */
  14845. public static class LIGHT_ONOFF {
  14846. /** ON */
  14847. public static byte ON = (byte) 0x01;
  14848. /** OFF */
  14849. public static byte OFF = (byte) 0x02;
  14850. /** OFF */
  14851. public static byte DONTCARE = (byte) 0xFF;
  14852. }
  14853. private byte convertSmartLightPowerValue(String cmd) {
  14854. try {
  14855. if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
  14856. else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
  14857. else return LIGHT_ONOFF.DONTCARE;
  14858. } catch (RuntimeException re) {
  14859. LogUtil.errorLogInfo("", TAG, re);
  14860. return -1;
  14861. }
  14862. catch (Exception e) {
  14863. Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
  14864. //e.printStackTrace();
  14865. LogUtil.errorLogInfo("", TAG, e);
  14866. return -1;
  14867. }
  14868. }
  14869. // private void demoPushMsg()
  14870. // {
  14871. // String urlStr1 = "";
  14872. //
  14873. // if(android.os.Build.VERSION.SDK_INT > 9 )
  14874. // {
  14875. // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  14876. // StrictMode.setThreadPolicy(policy);
  14877. // }
  14878. //
  14879. // String Msg ="";
  14880. // try {
  14881. // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
  14882. // } catch (UnsupportedEncodingException e1) {
  14883. // // TODO Auto-generated catch block
  14884. // e1.printStackTrace();
  14885. // }
  14886. //
  14887. // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
  14888. // Log.d(TAG , "################ : " + urlStr1);
  14889. // try
  14890. // {
  14891. // //URLEncoder.encode(s)
  14892. // HttpClient client = new DefaultHttpClient();
  14893. //
  14894. // HttpGet get = new HttpGet();
  14895. // //get.setURI(new URI("http://www.google.com/"));
  14896. // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
  14897. // HttpResponse resp = client.execute(get);
  14898. // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
  14899. // String str = null;
  14900. // StringBuilder sb = new StringBuilder();
  14901. // while((str = br.readLine()) != null)
  14902. // {
  14903. // sb.append(str).append("\n");
  14904. // }
  14905. // br.close();
  14906. // //TextView txt = (TextView) findViewById(R.id.txt_get);
  14907. // //txt.setText(sb.toString());
  14908. // }catch(Exception e)
  14909. // {
  14910. //
  14911. // e.printStackTrace();
  14912. //
  14913. // }
  14914. //
  14915. //
  14916. // }
  14917. //
  14918. //
  14919. // public static boolean checkForExternal(String str) {
  14920. // int length = str.length();
  14921. // for (int i = 0; i < length; i++) {
  14922. // if (str.charAt(i) > 0x7F) {
  14923. // return true;
  14924. // }
  14925. // }
  14926. // return false;
  14927. // }
  14928. //
  14929. // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
  14930. // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
  14931. // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
  14932. // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
  14933. // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
  14934. //
  14935. // public static String encodeUrl(String url) {
  14936. // if (checkForExternal(url)) {
  14937. // try {
  14938. // String value = URLEncoder.encode(url, "UTF-8");
  14939. // value = COLON.matcher(value).replaceAll(":");
  14940. // value = SLASH.matcher(value).replaceAll("/");
  14941. // value = QUEST_MARK.matcher(value).replaceAll("?");
  14942. // value = EQUAL.matcher(value).replaceAll("=");
  14943. // return AMP.matcher(value).replaceAll("&");
  14944. // } catch (UnsupportedEncodingException e) {
  14945. // //throw LOGGER.getIllegalStateException(e);
  14946. // return null;
  14947. // }
  14948. // } else {
  14949. // return url;
  14950. // }
  14951. // }
  14952. }