123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716 |
- package kr.co.icontrols.wallpadmain.util;
- import android.annotation.SuppressLint;
- import android.app.ActivityManager;
- import android.app.ActivityManager.RunningTaskInfo;
- import android.app.Service;
- import android.content.BroadcastReceiver;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.SharedPreferences;
- import android.content.pm.PackageInfo;
- import android.content.pm.PackageManager;
- import android.media.AudioManager;
- import android.os.Build;
- import android.os.Bundle;
- import android.os.CountDownTimer;
- import android.os.Handler;
- import android.os.IBinder;
- import android.os.Looper;
- import android.os.Message;
- import android.os.Messenger;
- import android.os.PowerManager;
- import android.os.RemoteException;
- import android.provider.Settings;
- import android.util.Log;
- import android.view.KeyEvent;
- import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
- import com.artncore.WallPadDataMgr.WallpadDevStatus;
- import com.artncore.WallPadDataMgr.WallpadDeviceSet;
- import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
- import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
- import com.artncore.WallPadDataMgr.WallpadScheduleData;
- import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
- import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
- import com.artncore.WallPadDataMgr.wallpaddbmgr;
- import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
- import com.artncore.WallPadKNXSystem.WallPadKNX;
- import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
- import com.artncore.commons.APIErrorCode;
- import com.artncore.commons.API_Menu;
- import com.artncore.commons.DataClasses;
- import com.artncore.commons.DataClasses.HeatingV1;
- import com.artncore.commons.DataClasses.HeatingV2;
- import com.artncore.commons.DataClasses.MultiSwitch;
- import com.artncore.commons.KNX_DataClasses;
- import com.artncore.commons.define;
- import com.artncore.deviceinterface.WallPadInterface;
- import com.artncore.wallpadapi.AirQualitySensorAPI;
- import com.artncore.wallpadapi.CooktopAPI;
- import com.artncore.wallpadapi.DLockAPI;
- import com.artncore.wallpadapi.EnergyMeterAPI;
- import com.artncore.wallpadapi.GasAPI;
- import com.artncore.wallpadapi.HeatingV1API;
- import com.artncore.wallpadapi.HeatingV2API;
- import com.artncore.wallpadapi.IGW200dAPI;
- import com.artncore.wallpadapi.IGW300API;
- import com.artncore.wallpadapi.IntLightAPI;
- import com.artncore.wallpadapi.KnxAPI;
- import com.artncore.wallpadapi.KnxSystemAirconAPI;
- import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
- import com.artncore.wallpadapi.LightAPI;
- import com.artncore.wallpadapi.MultiSwitchAPI;
- import com.artncore.wallpadapi.PhonNRemocon;
- import com.artncore.wallpadapi.RealTimeMeterAPI;
- import com.artncore.wallpadapi.SdbAPI;
- import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
- import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
- import com.artncore.wallpadapi.SmartSwitchPolAPI;
- import com.artncore.wallpadapi.VentiAPI;
- import com.artncore.wallpadapi.WallPadAPI;
- import com.artncore.wallpadimap.RetProci;
- import com.artncore.wallpadimap.WallPadFTPUploader;
- import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
- import com.artncore.wallpadimap.WallpadiCMDParser;
- import com.util.LogUtil;
- import org.apache.commons.net.ftp.FTP;
- import org.w3c.dom.Document;
- import org.w3c.dom.Element;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import java.io.BufferedReader;
- import java.io.ByteArrayInputStream;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.FilenameFilter;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import java.util.LinkedList;
- import java.util.List;
- import java.util.Queue;
- import javax.net.ssl.SSLServerSocket;
- import javax.xml.parsers.DocumentBuilder;
- import javax.xml.parsers.DocumentBuilderFactory;
- import kr.co.icontrols.gledeviceinterface.jni;
- import kr.co.icontrols.hdcftp.HDCFTPManager;
- import kr.co.icontrols.sslapi.SSLClient;
- import kr.co.icontrols.sslapi.SSLServer;
- import kr.co.icontrols.wallpadmain.IOInterface;
- import kr.co.icontrols.wallpadmain.MainActivity;
- import kr.co.icontrols.wallpadmain.R;
- import kr.co.icontrols.wallpadmain.declare.Common;
- import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
- import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
- import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
- import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
- import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
- import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
- import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
- import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
- import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
- import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
- import kr.co.icontrols.wallpadsupport.Version;
- import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
- import kr.co.icontrols.wallpadsupport.WpadSound;
- import kr.co.icontrols.wallpadsupport.WpadSound.SND;
- import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
- import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
- public class iMapServer extends Service {
- private String TAG = "iMapServer";
- static final int EVENTTIMELIMITE = 2000;
- iMapSverSocket SvrSock;
- int port = 10000;
- String StrAddr = "";
- String IPaddr;
- String AddrDong;
- String AddrHo;
- int ho;
- boolean log_sw = true;
- String SVRIP = "";
- static WallPadAPI mWallPadAPI;
- private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
- private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
- private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
- private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
- private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
- private IGW200 mIGW200;
- private IGW300 mIGW300;
- PhonNRemocon PnRCtr;
- boolean CallConnected = false;
- long ALERTTIME = 0;
- long CALLTIME = 0;
- long OPENDOORTIME = 0;
- long currentTime = 0;
- long DoorDelayTime = 0;
- static Handler ScheDulerHandler;
- static final boolean iMAPDOORCTR = true;
- private jni mGleInterface = null;
- IOInterface mIOInterface = null;
- private boolean ResetFlag = false;
- final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
- private int ResetCount = 0;
- private boolean NowMainStatus = false;
- public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
- public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
- public iMapServer() {
- Log.i(TAG, "[iMapServer] ========== START ==========");
- }
- public static final int SENSOR_MAG = 0x01;
- public static final int SENSOR_IN = 0x02;
- public static final int SENSOR_OUT = 0x04;
- static int PORT_NUM_iMAP = 10000;
- static int SOCKET_WAIT_TIME = 40;
- static long lSocketConnectionPeriod = 0;
- static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
- static int SOCKET_BUFFER_SIZE_READ = 50;
- public static final String ITEM_MENU_TYPE = "call_menu";
- static final int DOOR_DELAY_TIME = 3000;
- static final String MULTISW_CTR = "remote_access_electric";
- String XMLHeader;
- SchedulerThread ScheServer;
- int OutGoingSensorWaiting = 0;
- private int ModelType = Version.getModelType();
- private WpadSound mSound;
- private WpadSound Sound() {
- if (mSound == null) mSound = new WpadSound(getApplicationContext());
- return mSound;
- }
- /**
- * 신형 단지서버 사용 유무
- */
- private boolean mNewDanjiServer = false;
- /**
- * 방범 앱 재실행 여부
- */
- private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
- /**
- * JEFF, 2019.12.31
- * 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
- * WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
- * 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
- * 통화앱 종료 BR을 삭제하면 안됨
- */
- // 통화어플이 종료중인 경우에는 호출 무시
- // private boolean bBlockCallEvent = false;
- ////////////////////////////////////////////////////////////////////////////////
- // 엘리베이터관련
- ////////////////////////////////////////////////////////////////////////////////
- /**
- * 엘리베이터 호출관련 class
- * <p>
- * shkang
- */
- private class ElevatorClass {
- /**
- * 엘리베이터 호출 타임아웃 (단위:초)
- */
- private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
- /**
- * 상향/하향 플레그 true:상향UP, false:하향DN
- */
- private boolean mUpDn = false;
- /**
- * 엘리베이터 호출중
- */
- private boolean mCallElevator = false;
- /**
- * 엘리베이터 호출 API
- */
- private WallPadiMAPNotifyAPI mElevatorAPI;
- /**
- * 엘리베이터 호출 타이머
- */
- private CountDownTimer mElevatorTimer;
- /**
- * 엘리베이터 호출중 상태 가져오기
- */
- public boolean getElevatorCalling() {
- return mCallElevator;
- }
- /**
- * 엘리베이터 호출 상태 클리어
- */
- public void ClearElevator() {
- mCallElevator = false;
- }
- /**
- * 생성자
- *
- * @param Up - (boolean) true:상향, false:하향
- */
- private ElevatorClass(boolean Up) {
- try {
- Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
- // 1. Input Param
- mUpDn = Up;
- mCallElevator = false;
- // 2. Create API
- mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
- mElevatorAPI.SetElevatorRetCtr(new RetProci() {
- @Override
- public void ProcDoing() {
- Log.i(TAG, "[ElevatorClass] ProcDoing()");
- }
- @Override
- public void ProcError() {
- Log.i(TAG, "[ElevatorClass] ProcError()");
- mCallElevator = false;
- // 엘리베이터 호출 에러 알림
- SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
- }
- @Override
- public void ProcSuccess() {
- Log.i(TAG, "[ElevatorClass] ProcSuccess()");
- mCallElevator = true;
- // 엘리베이터 호출 성공 알림
- SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
- // "엘리베이터를 호출하였습니다" 멘트출력
- Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
- Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
- if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
- Sound().PlayMent(WpadSound.SND.elevator.CALL);
- bOutModeRestart = false;
- // 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
- // 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
- // 타임아웃 시작
- TimeOutStart();
- }
- });
- // 3. Create Timer
- mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
- @Override
- public void onFinish() {
- Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
- mCallElevator = false;
- // 호출 타임아웃 알림
- SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
- }
- @Override
- public void onTick(long arg0) {
- int RemainingTime = (int) (arg0 / 1000);
- if (RemainingTime <= 10) {
- Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
- }
- }
- };
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 엘리베이터 호출을 한다.
- */
- public void CallElevator() {
- try {
- if (mElevatorAPI == null) return;
- mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
- mCallElevator = true;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] CallElevator()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 엘리베이터 상향호출 타임아웃을 취소한다.
- */
- public void TimeOutCancel() {
- try {
- if (mElevatorTimer == null) return;
- mElevatorTimer.cancel();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] TimeOutCancel()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 엘리베이터 상향호출 타임아웃을 시작한다.
- */
- private void TimeOutStart() {
- try {
- if (mElevatorTimer == null) return;
- mElevatorTimer.cancel();
- mElevatorTimer.start();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] TimeOutStart()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
- *
- * @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
- */
- private void SendNotifyKindBR(int kind) {
- try {
- Intent notiIntent = new Intent();
- notiIntent.setAction(define.NOTIFY_ACNAME);
- notiIntent.putExtra(define.NOTIBR_KIND, kind);
- getApplicationContext().sendBroadcast(notiIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- /**
- * 엘리베이터 상향호출 Class
- */
- private ElevatorClass ElevatorUp;
- /**
- * 엘리베이터 하향호출 Class
- */
- private ElevatorClass ElevatorDown;
- /**
- * 엘리베이터 호출한다.
- *
- * @param Up (boolean) true : 상향, false : 하향
- */
- private void CallElevatorBtn(boolean Up) {
- try {
- Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
- if (Up) {
- // 상향호출
- if (ElevatorUp == null) {
- Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
- return;
- }
- ElevatorUp.CallElevator();
- } else {
- // 하향호출
- if (ElevatorDown == null) {
- Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
- return;
- }
- ElevatorDown.CallElevator();
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- @Override
- public void onCreate() {
- try {
- super.onCreate();
- Log.i(TAG, "[onCreate] ========== START ==========");
- setGlobalScreenAppRunningStatus(false);
- ModelType = Version.getModelType();
- mSound = new WpadSound(getApplicationContext());
- ElevatorUp = new ElevatorClass(true);
- ElevatorDown = new ElevatorClass(false);
- } catch (RuntimeException re) {
- Log.e(TAG, "[Exception] onCreate()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] onCreate()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
- try {
- Intent notiIntent = new Intent();
- notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
- notiIntent.putExtra("ElevatorFloor", eStatus.toString());
- getApplicationContext().sendBroadcast(notiIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- protected String GetForegroundAPP() {
- try {
- ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
- List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
- ComponentName topActivity = taskInfo.get(0).topActivity;
- String str = topActivity.getPackageName();
- return str;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return " ";
- } catch (Exception e) {
- Log.e(TAG, "[Exception] GetForegroundAPP()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return " ";
- }
- }
- long lSavedTimestamp = 0;
- BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- try {
- String strActionName = intent.getAction();
- Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
- if (strActionName.equals(define.NOTIFY_DAIL)) {
- long lTimestamp = System.currentTimeMillis();
- long lInterval = lTimestamp - lSavedTimestamp;
- if (lInterval < 1000) return;
- else
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
- lSavedTimestamp = lTimestamp;
- if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
- if (mSdb_LivingRoomLightAPI == null) {
- Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
- return;
- }
- byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
- byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
- byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
- byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
- byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
- if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
- Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
- // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
- if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
- mSdb_LivingRoomLightAPI.SetControlMode(false);
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
- }
- return;
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
- // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
- Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
- return;
- }
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
- if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
- runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
- } else {
- setGlobalScreenAppRunningStatus(false);
- }
- } else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
- if (mKnx_LivingRoomLightAPI == null) {
- Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
- return;
- }
- byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
- byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
- byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
- byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
- byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
- if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
- Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
- // 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
- if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
- mKnx_LivingRoomLightAPI.SetControlMode(false);
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
- }
- return;
- }
- if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
- // 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
- Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
- return;
- }
- for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
- 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 + "]");
- }
- if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
- runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
- } else {
- setGlobalScreenAppRunningStatus(false);
- }
- } else {
- Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
- }
- } else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
- runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
- } else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
- int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
- Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
- switch (kind) {
- case define.NOTIFY_SCREEN_TOUCHED:
- setTimeStamp_ScreenTouched();
- break;
- case define.NOTIFY_DOOR_OPENED:
- setTimeStamp_Magnetic();
- break;
- }
- } else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
- int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
- Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
- switch (kind) {
- case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
- procUploadMissedVisitorPic(intent);
- break;
- case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
- // bBlockCallEvent = true;
- // sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
- break;
- case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
- Sound().Play(SND.mode.OUTMODE_SETTING);
- break;
- case Common.BR_MAIN_NOTI.SOUND_INMODE:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
- Sound().Play(SND.mode.INMODE_SETTING);
- break;
- case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
- Sound().Play(SND.mode.NORMALMODE_COMEBACK);
- break;
- case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
- playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
- break;
- case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
- playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
- break;
- case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
- CallElevatorBtn(false);
- break;
- case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
- CallElevatorBtn(true);
- break;
- case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
- // 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
- int CalledWallPadUI = intent.getIntExtra("Called", 0);
- if (CalledWallPadUI == 1) {
- ModeRunCtrlWorking(true, false);
- } else {
- ModeRunCtrlWorking(false, false);
- }
- break;
- case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
- ModeReleaseCtrlWorking(false);
- break;
- case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
- CheckMainStatus();
- break;
- case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
- ModeRunCtrlWorking(false, false);
- break;
- case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
- ModeReleaseCtrlWorking(false);
- break;
- case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
- if (ElevatorUp != null && ElevatorDown != null) {
- boolean UpCalling = ElevatorUp.getElevatorCalling();
- boolean DownCalling = ElevatorDown.getElevatorCalling();
- Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
- ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
- if (UpCalling && DownCalling)
- Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
- else if (UpCalling && !DownCalling)
- Common.eElevCallStatus = Common.ELEV_STATUS.UP;
- else if (!UpCalling && DownCalling)
- Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
- else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
- Log.d(TAG, " ElvCallState : " + ElvCallState);
- SendBRElevatorCallState(ElvCallState);
- // Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
- // sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
- // sendIntent.putExtra("ELV", ElvCallState);
- // getApplicationContext().sendBroadcast(sendIntent);
- }
- break;
- case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
- try {
- if (ScheServer != null) {
- ScheServer.SetLive();
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- break;
- case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
- Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
- stopIGW300RingGenerator();
- break;
- }
- } else if (strActionName.equals(define.NOTIFY_ACNAME)) {
- int kind = intent.getIntExtra("KIND", 0);
- Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
- switch (kind) {
- case define.NOTIFY_SERVER_VERSION:
- try {
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
- iMapSverReload tSock = new iMapSverReload();
- tSock.start();
- } catch (IOException e) {
- Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- break;
- case define.NOTIFY_DEVICE_ELE_CALL_UP:
- // 제어기기 엘리베이터 상향 호출 요청
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
- CallElevatorBtn(true);
- break;
- case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
- // 제어기기에서 엘리베이터 하향 호출 요청
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
- CallElevatorBtn(false);
- break;
- case define.NOTIFY_SUBDEVCALLBUSY:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
- CallConnected = true;
- break;
- case define.NOTIFY_SUBDEVCALLEND:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
- CallConnected = false;
- break;
- case define.NOTIFY_STARTHEARTBEAT:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
- {
- Message msg = ScheDulerHandler.obtainMessage();
- msg.what = SCHEDULE_CHANGE_HEARTBEAT;
- ScheDulerHandler.sendMessage(msg);
- }
- break;
- case define.NOTIFY_STARTSTATUSBEAT:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
- {
- Message msg = ScheDulerHandler.obtainMessage();
- msg.what = SCHEDULE_START_STATUSBEAT;
- ScheDulerHandler.sendMessage(msg);
- }
- break;
- case define.NOTIFY_OUTGOINGSETTED:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
- OutGoingSensorWaiting = 0;
- WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
- int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
- sdata.closeDB();
- if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
- return;
- WallPadInterface wpifc = new WallPadInterface();
- if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
- OutGoingSensorWaiting |= SENSOR_MAG;
- int[] SensorInfoDB;
- int sensorIn = 0;
- int sensorOut = 0;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
- if (SensorInfoDB[0] == 1) {
- // 내부동체가 사용함이면 상태 검사
- if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
- OutGoingSensorWaiting |= SENSOR_IN;
- }
- if (SensorInfoDB[1] == 1) {
- // 외부동체가 사용함이면 상태 검사
- if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
- OutGoingSensorWaiting |= SENSOR_OUT;
- }
- // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
- // if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
- if (OutGoingSensorWaiting > 0) {
- OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
- SensorThread.start();
- }
- break;
- case define.NOTIFY_DOOR_SET_DELAY:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
- DoorDelayTime = System.currentTimeMillis();
- imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
- break;
- case define.NOTIFY_DEVICE_INIT_COMPLETION:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
- Common.setDeviceServeiceLoadComplite();
- startRealtimemeterInfo(); // 실시간 검침기 확인
- startSmartIoTCamInfo(); // 스마트현관카메라 확인
- startDistributionPanel(); // 분전반 확인
- getRoomName();
- break;
- case define.NOTIFY_DLOCK_SET_OUTING:
- // 도어락 외출모드 / 대외향 RF 카드 외출모드
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
- try {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- int AlarmStatus = DBMGR.GetAlarmStatus();
- DBMGR.closeDB();
- if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
- // 센서 체크하고
- // 현관폰으로 사운드 출력하고
- boolean bSensorOk = false;
- if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- bSensorOk = mIGW300.checkSensorforOutmode();
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- bSensorOk = mIGW200.checkSensorforOutmode();
- } else {
- bSensorOk = checkSensorforOutmode();
- }
- if (bSensorOk) {
- playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
- CallOutModeRunActivity();
- } else {
- playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- break;
- case define.NOTIFY_DLOCK_FREE_OUTING:
- // 도어락 외출모드 해제
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
- try {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- int AlarmStatus = DBMGR.GetAlarmStatus();
- DBMGR.closeDB();
- if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
- Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
- Common.SendAppFinishReqBR(getApplicationContext());
- //RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
- WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
- int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
- devDB.closeDB();
- if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
- mWallPadAPI.SetDoorLock_Open_ForRFCamera();
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- break;
- case define.NOTIFY_SMARTSW_SET_OUTING:
- // 485 대외향 스마트스위치 외출모드
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
- setUnoccupiedModeByNotHDCSmartSwitch();
- break;
- case define.NOTIFY_SMARTSW_FREE_OUTING:
- //대외향 485 스마트스위치 외출모드 해제
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
- releaseUnoccupiedModeByNotHDCSmartSwitch();
- break;
- case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
- String Type = intent.getStringExtra("TYPE");
- String Device = intent.getStringExtra("DEVICE");
- String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
- String CauseType = intent.getStringExtra("CAUSE_TYPE");
- String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
- iMAPSmartLightEvent imapSmartLightEvent;
- imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
- imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
- imapSmartLightEvent.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
- }
- @Override
- public void ProcError() {
- Log.e(TAG, "iMAPSmartLightEvent ProcError");
- }
- @Override
- public void ProcDoing() {
- Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
- }
- });
- break;
- case define.NOTIFY_KNX_DEVICE_EVENT:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
- String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
- String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
- String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
- String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
- String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
- iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
- iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
- iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
- iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
- }
- @Override
- public void ProcError() {
- Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
- }
- @Override
- public void ProcDoing() {
- Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
- }
- });
- break;
- case define.NOTIFY_SMART_DCAM_DETECT:
- // 스마트현관카메라 거동수상자 발생
- // Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
- if (!bWallPadCallLive && !bBlockFrontCall) {
- if (getStrangerRecordingManagerSetting()) {
- if (getStrangerRecordingUserSetting()) {
- Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
- Intent Newintent = new Intent();
- Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
- Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
- getApplicationContext().sendBroadcast(Newintent);
- } else {
- ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
- Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
- }
- } else {
- ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
- Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
- }
- } else {
- ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
- Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
- }
- break;
- case define.NOTIFY_SMART_DCAM_RELEASE:
- // Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
- break;
- case define.NOTIFY_ACCEPT_RECORD_STRANGER:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
- if (getStrangerRecordingManagerSetting()) {
- if (getStrangerRecordingUserSetting()) {
- // 알람 상태 확인
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
- if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
- // 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
- ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
- } else {
- Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
- Intent Newintent = new Intent();
- Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
- Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
- getApplicationContext().sendBroadcast(Newintent);
- }
- } else {
- Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
- }
- } else {
- Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
- }
- break;
- case define.NOTIFY_REJECT_RECORD_STRANGER:
- case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
- if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
- ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
- }
- break;
- case define.NOTIFY_ROOMNAME_CHANGED:
- getRoomName();
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
- break;
- case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
- break;
- case define.NOTIFY_FINISH_RECORD_STRANGER:
- // 녹화 종료 알림
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
- if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
- break;
- case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
- // 사용자 설정화면에서 원격제어시 조명제어 타입 변경
- getDeviceCtrlOption();
- break;
- default:
- Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
- break;
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] mWallPadNotifyBR");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- };
- private void setUnoccupiedModeByNotHDCSmartSwitch() {
- try {
- Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
- // 485 대외향 스마트스위치 외출모드
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
- // 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
- boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
- mWallpadStatusData.closeDB();
- if (UseGuardSensorCheck == false) {
- // 그냥 외출모드 처리 .. 기기 연동 처리만
- if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
- mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
- mWallpadStatusData.closeDB();
- Sound().PlayMent(SND.mode.OUTMODE_SETTING);
- //메인화면 업데이트
- Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
- getApplicationContext().sendBroadcast(newIntent);
- ModeRunCtrlWorking(false, false);
- }
- } else {
- // 실제 외출 방범 모드를 설정하도록 한다.
- Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
- if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
- // 센서 체크하고
- // 센서 체크하는 부분이 들어가야 함
- Common.SendAppFinishReqBR(getApplicationContext());
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (mIGW300.checkSensorforOutmode()) {
- CallOutModeWaitingActivity(AlarmStatus);
- } else {
- playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
- }
- } else {
- if (checkSensorforOutmode()) {
- //playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
- CallOutModeWaitingActivity(AlarmStatus);
- } else {
- playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
- }
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
- try {
- Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
- //대외향 485 스마트스위치 외출모드 해제
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
- boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
- mWallpadStatusData.closeDB();
- Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
- if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
- if (OutModePwRelease) {
- Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
- // 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
- // 요청하여도 해제 되지 않으며
- // 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
- Intent notiIntent = new Intent();
- notiIntent.setAction(define.NOTIFY_ACNAME);
- notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
- getApplicationContext().sendBroadcast(notiIntent);
- } else {
- Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
- // 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
- // 처리하고.
- // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
- mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
- mWallpadStatusData.closeDB();
- Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
- Common.SendAppFinishReqBR(getApplicationContext());
- }
- } else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
- // 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
- Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
- ModeReleaseCtrlWorking(false);
- bSmartSwitch485ComebackMode = true;
- Intent notiIntent = new Intent();
- notiIntent.setAction(define.NOTIFY_ACNAME);
- notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
- getApplicationContext().sendBroadcast(notiIntent);
- } else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
- Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
- // 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
- mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
- mWallpadStatusData.closeDB();
- Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
- //메인화면 업데이트
- Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
- getApplicationContext().sendBroadcast(newIntent);
- ModeReleaseCtrlWorking(false);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 스마트현관카메라 녹화 여부 판별
- * 사용자 화면에서 설정
- */
- private boolean getStrangerRecordingUserSetting() {
- boolean bResult = false;
- WallpadStatusData DBMGR = new WallpadStatusData(this);
- try {
- bResult = DBMGR.GetStrangerRecordingOnOff();
- DBMGR.closeDB();
- Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- DBMGR.closeDB();
- bResult = false;
- } catch (Exception e) {
- DBMGR.closeDB();
- Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- bResult = false;
- }
- return bResult;
- }
- private boolean getStrangerTakePic() {
- try {
- WallpadStatusData DBMGR = new WallpadStatusData(this);
- boolean bResult = DBMGR.GetStrangerTakePicOnOff();
- DBMGR.closeDB();
- Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
- return bResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getStrangerTakePic()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- // 관리자 설정 항목에 있음
- private boolean getStrangerRecordUsage() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
- boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
- mWallpadDeviceSet.closeDB();
- Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
- return bResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getStrangerRecordUsage()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- private boolean checkSensorforOutmode() {
- try {
- WallPadInterface wallPadInterface = new WallPadInterface();
- Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
- int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
- Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
- int[] SensorInfoDB;
- int sensorIn = 0;
- int sensorOut = 0;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
- Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
- if (SensorInfoDB[0] == 1) {
- // 내부동체가 사용함이면 상태 검사
- sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
- }
- if (SensorInfoDB[1] == 1) {
- // 외부동체가 사용함이면 상태 검사
- sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
- }
- // int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- // int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- // 동체 사용 설정 체크..
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int sensor = devSet.Get_Sensor_Set();
- Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
- devSet.closeDB();
- int OtherInSensor = 0;
- // 내부동체 사용안함 이면
- if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
- // 외부동체 사용안함 이면
- if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
- Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
- if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
- Log.w(TAG, "[checkSensorforOutmode] Result -> true");
- return true;
- } else {
- Log.w(TAG, "[checkSensorforOutmode] Result -> false");
- return false;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- private boolean checkSensorforInmode() {
- try {
- WallPadInterface wallPadInterface = new WallPadInterface();
- Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
- int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
- Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
- Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
- if (sensorMag == 0) {
- Log.w(TAG, "[checkSensorforOutmode] Result -> true");
- return true;
- } else {
- Log.w(TAG, "[checkSensorforOutmode] Result -> false");
- return false;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- /////////////////////
- // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
- //////////////
- /////////////////////
- // 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
- //////////////
- public void playSoundthroughDoorphone(int SoundIdx) {
- try {
- WallPadInterface Wiface = new WallPadInterface();
- mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
- if (getUseSmartDoorCam()) {
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
- }
- Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
- /*
- JEFF (2019.01.14)
- << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
- 강신구입니다.
- 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
- 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
- 내용 공유합니다.
- 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
- HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
- IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
- 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
- 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
- 문제 없습니다.
- 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
- 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
- 문의사항은 하기 연락바랍니다.
- 감사합니다.
- */
- mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
- } else {
- // 대외향 모델 처리
- // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
- if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
- Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
- Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
- }
- try {
- Thread.sleep(100);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
- amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
- try {
- Thread.sleep(1500);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
- int SLevel = Wdb.GetDoorSoundLevel();
- Wdb.closeDB();
- Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
- if (SLevel != -1) {
- /**
- * A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
- * **/
- Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
- } else {
- // 사용안함이면
- Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
- }
- // try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
- int time = Sound().PlayMent(SoundIdx);
- Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
- if (0 > time) {
- Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
- time = 1000;
- }
- try {
- Thread.sleep(time + 1000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
- amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
- try {
- Thread.sleep(100);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
- if (getUseSmartDoorCam()) {
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
- }
- Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
- /*
- JEFF (2019.01.14)
- << IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
- 강신구입니다.
- 동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
- 증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
- 내용 공유합니다.
- 1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
- HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
- IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
- 이로 인해 GND가 OPEN되어 발생하는 문제입니다.
- 2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
- 문제 없습니다.
- 3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
- 월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
- 문의사항은 하기 연락바랍니다.
- 감사합니다.
- */
- mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
- } else {
- // 대외향 모델 처리
- // IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
- if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
- Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
- Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
- }
- mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void CallOutModeRunActivity() {
- int base = 8000;
- int[] Menu_Id_List = {base + 11};
- int Menu_StartId = base + 11;
- int Menu_Option = -1;
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
- intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
- intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }
- public void CallOutModeWaitingActivity(int nAlarmStatus) {
- Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
- int base = 4000;
- int[] Menu_Id_List = {base + 11, base + 21};
- int Menu_StartId = base + 11;
- int Menu_Option = 1000;
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
- intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
- intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
- intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }
- private boolean getGlobalScreenAppRunningStatus() {
- boolean bRunning = false;
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- try {
- bRunning = DBMGR.getGlobalScreenAPKRun();
- DBMGR.closeDB();
- Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
- return bRunning;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- DBMGR.closeDB();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- DBMGR.closeDB();
- }
- return bRunning;
- }
- private void setGlobalScreenAppRunningStatus(boolean bRun) {
- Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- try {
- boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
- Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
- DBMGR.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- DBMGR.closeDB();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- DBMGR.closeDB();
- }
- }
- String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
- boolean bGlobalScreenRun = false;
- public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
- try {
- Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
- wakeupLCD();
- if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
- setGlobalScreenAppRunningStatus(true);
- sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
- ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
- Intent mIntent = new Intent(Intent.ACTION_MAIN);
- mIntent.putExtra("ONOFF", hOnOff);
- mIntent.putExtra("DIAL", hDial);
- mIntent.putExtra("LEVEL", hLevel);
- mIntent.putExtra("COLOR", hColor);
- mIntent.putExtra("CONTROL", hControl);
- mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mIntent.setComponent(mComponentName);
- startActivity(mIntent);
- } else {
- Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] runGlobalScreenAPK()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
- try {
- Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
- wakeupLCD();
- if (!getGlobalScreenAppRunningStatus()) {
- if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
- Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
- return;
- }
- setGlobalScreenAppRunningStatus(true);
- sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
- ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
- Intent mIntent = new Intent(Intent.ACTION_MAIN);
- mIntent.putExtra("SCREENID", nScreenID);
- mIntent.putExtra("ONOFF", hOnOff);
- mIntent.putExtra("DIAL", hDial);
- mIntent.putExtra("LEVEL", hLevel);
- mIntent.putExtra("COLOR", hColor);
- mIntent.putExtra("CONTROL", hControl);
- mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mIntent.setComponent(mComponentName);
- startActivity(mIntent);
- } else {
- Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
- public void sendBlackoutReleasedBR() {
- try {
- Intent notiIntent = new Intent();
- notiIntent.setAction(strBLACKOUT_RELEASED);
- getApplicationContext().sendBroadcast(notiIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private int getCurrentScreen() {
- int nScreenID = 0;
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- try {
- nScreenID = DBMGR.GetCurrentScreenIDValue();
- DBMGR.closeDB();
- Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
- return nScreenID;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- DBMGR.closeDB();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getCurrentScreen()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- DBMGR.closeDB();
- }
- return nScreenID;
- }
- private void setCurrentScreen(int nScreenID) {
- Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- try {
- DBMGR.SetCurrentScreenIDValue(nScreenID);
- DBMGR.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- DBMGR.closeDB();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- DBMGR.closeDB();
- }
- }
- ArrayList<String> strArrayMissedPicURI = new ArrayList<String>();
- private void procUploadMissedVisitorPic(Intent intent) {
- try {
- String strDong = intent.getStringExtra("DONG");
- String strHo = intent.getStringExtra("HO");
- Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
- int nCnt = intent.getIntExtra("CNT", 0);
- String[] strMissedPicURI = new String[nCnt];
- strArrayMissedPicURI.clear();
- for (int i = 0; i < nCnt; i++) {
- strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
- strArrayMissedPicURI.add(strMissedPicURI[i]);
- Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
- }
- for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
- Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
- }
- prepareUploadPicturesOnFTPServer(strDong, strHo);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
- try {
- String strURI = "", strFileName = "", strTime = "", strType = "";
- // for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
- // strURI = strArrayMissedPicURI.get(i).toString();
- // strFileName = extractFileName(strURI);
- // strTime = extractFileTime(strURI);
- // strType = extractCallType(strFileName);
- // Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
- // sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
- // }
- if (strArrayMissedPicURI.size() > 0) {
- strURI = strArrayMissedPicURI.get(0).toString();
- strFileName = extractFileName(strURI);
- strTime = extractFileTime(strFileName);
- strType = extractCallType(strFileName);
- Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
- send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
- } else {
- Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public class uploadVisitorPicture extends Thread {
- HDCFTPManager mFTPManager;
- boolean bMainServer2dot0 = false;
- String strRemoteIP = "10.0.1.1";
- String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
- public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- try {
- strDong = dong;
- strHo = ho;
- strType = type;
- strTime = time;
- strFileName = filename;
- strUploadFile = uploadfile;
- bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
- Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
- wallpadDeviceSet.closeDB();
- Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void run() {
- try {
- mFTPManager = new HDCFTPManager();
- if (!mFTPManager.isFTPConnected()) {
- if (!mFTPManager.connectFTP(strRemoteIP)) {
- Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
- send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
- return;
- }
- }
- if (!mFTPManager.loginFTP(strUserID, strPW)) {
- Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
- send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
- return;
- }
- if (!bMainServer2dot0) {
- if (!mFTPManager.setPassiveMode()) {
- Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
- disconnectFTP();
- send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
- return;
- }
- }
- if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
- Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
- disconnectFTP();
- send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
- return;
- }
- if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
- Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
- disconnectFTP();
- send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
- return;
- }
- if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
- Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
- disconnectFTP();
- send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
- return;
- }
- disconnectFTP();
- Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
- send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
- sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
- prepareUploadPicturesOnFTPServer(strDong, strHo);
- }
- public boolean disconnectFTP() {
- try {
- if (mFTPManager.logoutFTP()) {
- if (mFTPManager.disconnectFTP()) {
- Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
- return true;
- }
- }
- Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] disconnectFTP()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- }
- private String extractCallType(String strFileName) {
- try {
- Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
- String[] strParse_01 = strFileName.split("_");
- if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
- else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
- else return "none";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] extractCallType(String strFileName)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private String extractFileName(String strTargetFile) {
- try {
- Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
- String[] strParse_01 = strTargetFile.split("/");
- return strParse_01[strParse_01.length - 1];
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private String extractFileTime(String strFileName) {
- try {
- Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
- String[] strParse_01 = strFileName.split("\\.");
- String[] strParse_02 = strParse_01[0].split("_");
- // 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
- // 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
- // 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);
- return strParse_02[5] + "_" + strParse_02[6];
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- String strRemoteURI, strUserID, strPW, strPath;
- String strReply_User = "", strReply_PW = "", strReply_Path = "";
- String strKey_Pass = "passwd";
- 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) {
- try {
- Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
- final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
- if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
- visitor_access_info.setResultCtrl(new RetProci() {
- @Override
- public void ProcSuccess() {
- Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
- visitor_access_info.SetItem("ftp_info");
- strReply_User = visitor_access_info.GetAttributeVal(0, "user");
- strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
- strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
- Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
- strUserID = strReply_User;
- strPW = strReply_PW;
- strPath = strReply_Path;
- strRemoteURI = strPath + "/" + strFileName;
- // uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
- uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
- mUploadVisitorPicture.start();
- // uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
- // mUploadVisitorPicture.start();
- }
- @Override
- public void ProcError() {
- Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
- if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
- sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
- prepareUploadPicturesOnFTPServer(strDong, strHo);
- }
- @Override
- public void ProcDoing() {
- Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
- }
- });
- return true;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
- try {
- Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
- final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
- if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
- visitor_upload_complete.setResultCtrl(new RetProci() {
- @Override
- public void ProcSuccess() {
- Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
- }
- @Override
- public void ProcError() {
- Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
- }
- @Override
- public void ProcDoing() {
- Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
- }
- });
- return true;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- /**
- * 이통사 연동 서비스를 위한 BR
- * 방문자 사진이 발생 할때 BR 을 전송한다.
- *
- * @param kind (String) "lobby" or "home"
- * @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
- */
- public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
- try {
- Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
- final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
- final int BASE = define.BR_COM_MOBILE_SERVICE;
- final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
- Intent mIntent = new Intent();
- mIntent.setAction(BR_VISITOR_EVENT);
- mIntent.putExtra("KIND", kind);
- mIntent.putExtra("TIME", datetime);
- mIntent.putExtra("FILENAME", filename);
- getApplicationContext().sendBroadcast(mIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
- Bundle bundle;
- WallpadDeviceSet devset;
- Intent newintent;
- boolean CallAppRun = false;
- boolean MgrAppRun = false;
- final String packageName = "com.artncore.apps.ic_wallpad";
- final String packageNameMgr = "com.artncore.managersetting";
- //CallAppRun = getForegroundAPK().equals(packageName);
- // CallAppRun = getCallAppRunning();
- MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
- int base = 7000;
- int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
- int Menu_Start_Option = 1;
- if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
- KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
- int keyevt = ReceiveEvt.getKeyCode();
- if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
- WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
- int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
- sdata.closeDB();
- if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
- return;
- }
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
- int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
- boolean updatestate = mWallpadStatusData.GetUpgradeState();
- mWallpadStatusData.closeDB();
- WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
- int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
- sdata.closeDB();
- Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
- Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
- Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
- int nModelType = Version.getModelType();
- switch (ReceiveEvt.getKeyCode()) {
- case 251: // 현산향 비상버튼 다운 업 처리
- try {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
- if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
- } else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
- if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- break;
- case WallPadInterface.EVT_RING:
- case WallPadInterface.BTN_PSTN_RING_IHN1010:
- Log.w(TAG, "########## PSTN EVT_RING ##########");
- // 전화 수신 링 수신
- // runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
- if (Version.getGatewayUsage()) {
- // 국선 시작만 올라온다.
- startIGW300RingGenerator();
- runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
- } else {
- runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
- }
- break;
- case WallPadInterface.EVT_END_RING:
- // 전화 수신 링 종료
- // Jeff added below codes for call app (2018.01.25)
- // This event is managed by WallPadCall
- Log.w(TAG, "########## This event is managed by WallPadCall ##########");
- if (Version.getGatewayUsage()) {
- stopIGW300RingGenerator();
- }
- break;
- case WallPadInterface.BTN_EMR:
- case WallPadInterface.BTN_EMR_IHN1010:
- Log.w(TAG, "########## EMERGENCY BUTTON ##########");
- // 월패드 비상버튼 입력 SA 와 GLE 공통
- Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
- if (MgrAppRun) return;
- if (Common.DIAGNOSTIC_MODE) return;
- if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
- return;
- //currentTime = System.currentTimeMillis();
- //if (ALERTTIME > currentTime) break;
- //ALERTTIME = currentTime+EVENTTIMELIMITE;
- Log.d(TAG, "AlarmStatus : " + AlarmStatus);
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- devset = new WallpadDeviceSet(getApplicationContext());
- int StatusVal = devset.GetDeviceSetted("알람발생");
- devset.closeDB();
- Log.d("imap", "StatusVal : " + StatusVal);
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- // 보안 처리가 필요함..
- // 지속적으로 이벤트가 들어올 경우 대비
- Common.SendAppFinishReqBR(getApplicationContext());
- newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(newintent);
- }
- // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
- if (getIsSubWallpad()) {
- Intent notiIntent = new Intent();
- notiIntent.setAction(define.NOTIFY_ACNAME);
- notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
- getApplicationContext().sendBroadcast(notiIntent);
- }
- break;
- case WallPadInterface.BTN_CALL:
- case WallPadInterface.BTN_CALL_IHN1010:
- // 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
- if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
- // Jeff added below codes for call app (2018.01.25)
- try {
- Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
- if (getIsSubWallpad()) {
- // 서브월패드
- runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
- } else {
- // 메인월패드
- if (MainActivity.bRecordStatus) {
- // 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
- Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
- Intent iIntent = new Intent();
- iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
- getApplicationContext().sendBroadcast(iIntent);
- }
- runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] onReceive().BTN_CALL");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- break;
- case WallPadInterface.BTN_OPEN:
- // 월패드 문여림 버튼 입력 상태 SA
- break;
- case WallPadInterface.BTN_DOOR:
- case WallPadInterface.BTN_DOOR_IHN1010:
- // 현관 도어폰 벨 눌림 입력 상태
- // Jeff added below codes for call app (2018.01.25)
- Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
- if (!bWallPadCallLive && !bBlockFrontCall) {
- if (MainActivity.bRecordStatus) {
- // 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
- Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
- Intent iIntent = new Intent();
- iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
- getApplicationContext().sendBroadcast(iIntent);
- }
- bBlockFrontCall = true;
- handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
- handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
- mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
- try {
- if (ModelType == MODEL_TYPE.IHN_1020GL) {
- mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
- mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
- mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
- }
- if (!Version.getGatewayUsage()) {
- mDingDongHandler.sendEmptyMessage(0); // 띵똥
- }
- Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
- runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- } else {
- Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
- }
- break;
- case WallPadInterface.BTN_CAMERA_SET:
- Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
- Intent iIntent = new Intent();
- iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
- getApplicationContext().sendBroadcast(iIntent);
- break;
- case WallPadInterface.EVT_SENSOR_EMRGENCY:
- case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
- if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
- && (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
- Log.w(TAG, "########## EMERGENCY BUTTON ##########");
- // 월패드 비상버튼 입력 SA 와 GLE 공통
- Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
- if (MgrAppRun) return;
- if (Common.DIAGNOSTIC_MODE) return;
- if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
- return;
- //currentTime = System.currentTimeMillis();
- //if (ALERTTIME > currentTime) break;
- //ALERTTIME = currentTime+EVENTTIMELIMITE;
- Log.d(TAG, "AlarmStatus : " + AlarmStatus);
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- devset = new WallpadDeviceSet(getApplicationContext());
- StatusVal = devset.GetDeviceSetted("알람발생");
- devset.closeDB();
- Log.d("imap", "StatusVal : " + StatusVal);
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- // 보안 처리가 필요함..
- // 지속적으로 이벤트가 들어올 경우 대비
- Common.SendAppFinishReqBR(getApplicationContext());
- newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(newintent);
- }
- // 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
- if (getIsSubWallpad()) {
- Intent notiIntent = new Intent();
- notiIntent.setAction(define.NOTIFY_ACNAME);
- notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
- getApplicationContext().sendBroadcast(notiIntent);
- }
- } else {
- Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
- if (!getEmergencyIOUsage()) {
- Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
- return;
- }
- if (MgrAppRun) {
- Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
- return;
- }
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- devset = new WallpadDeviceSet(getApplicationContext());
- StatusVal = devset.GetDeviceSetted("알람발생");
- devset.closeDB();
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- Common.SendAppFinishReqBR(getApplicationContext());
- newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(newintent);
- }
- }
- break;
- case WallPadInterface.EVT_SENSOR_MAGNETIC0:
- case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
- Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
- // 대외향의 경우 여기에서 마그네틱이 감지된다.
- if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
- if (MgrAppRun) return;
- if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
- WallPadInterface mWallPadInterface = new WallPadInterface();
- int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
- if (sensorMag == 0) return;
- }
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
- break;
- if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
- Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
- if (OutGoingSensorWaiting == 0) {
- // wakeupLCD();
- mIOInterface.ctrlLcdWakeUp();
- OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
- SensorThread.start();
- }
- OutGoingSensorWaiting |= SENSOR_MAG;
- } else {
- Common.SendAppFinishReqBR(getApplicationContext());
- newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(newintent);
- }
- break;
- case WallPadInterface.EVT_BLACKOUT_OCCURRED:
- saveBlackoutStatus(true);
- runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
- break;
- case WallPadInterface.EVT_BLACKOUT_RELEASED:
- saveBlackoutStatus(false);
- sendBlackoutReleasedBR();
- break;
- case WallPadInterface.EVT_SENSOR_REFUGELADDER:
- case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
- Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
- if (MgrAppRun) return;
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- devset = new WallpadDeviceSet(getApplicationContext());
- StatusVal = devset.GetDeviceSetted("피난사다리");
- int LadderSend = devset.getEscapeLadderDownSend();
- String pentHouseHo = devset.getPentHouseHoEscapeLadder();
- devset.closeDB();
- Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
- Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- Common.SendAppFinishReqBR(getApplicationContext());
- newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- if (!pentHouseHo.equals("")) {
- // 윗집이 펜트하우스인 경우
- newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
- } else {
- if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
- newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
- else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
- newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
- }
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(newintent);
- }
- break;
- case WallPadInterface.EVT_SENSOR_MOTIONIN:
- case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
- Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
- {
- // 내부동체가 상태가 변경된 경우
- int[] SensorInfoDB;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
- if (SensorInfoDB[0] != 1) {
- //내부동체가 사용함이면 상태 검사
- return;
- }
- if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
- WallPadInterface mWallPadInterface = new WallPadInterface();
- int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- if (sensorMag == 0) return;
- }
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int sensor = devSet.Get_Sensor_Set();
- devSet.closeDB();
- if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
- if (OutGoingSensorWaiting == 0) {
- OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
- SensorThread.start();
- }
- OutGoingSensorWaiting |= SENSOR_IN;
- }
- break;
- case WallPadInterface.EVT_SENSOR_MOTIONOUT:
- case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
- Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
- {
- // 외부동체가 상태가 변경된 경우
- int[] SensorInfoDB;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
- if (SensorInfoDB[1] != 1) {
- // 외부동체가 사용함이면 상태 검사
- return;
- }
- if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I) {
- WallPadInterface mWallPadInterface = new WallPadInterface();
- int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- if (sensorMag == 0) return;
- }
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int sensor = devSet.Get_Sensor_Set();
- devSet.closeDB();
- //if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- break;
- if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
- break;
- if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
- break;
- /*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
- {
- // IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
- Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
- break;
- }*/
- if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
- if (OutGoingSensorWaiting == 0) {
- OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
- SensorThread.start();
- }
- OutGoingSensorWaiting |= SENSOR_OUT;
- } else {
- Common.SendAppFinishReqBR(getApplicationContext());
- newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
- newintent.putExtra("MENU_DETAIL_INFO", "bugin");
- else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(newintent);
- }
- }
- break;
- }
- } else {
- Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
- }
- }
- };
- protected void iMAPstartActivity(Intent intent) {
- try {
- startActivity(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
- * 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
- * 1. 현관카메라 키이벤트 수신
- * 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
- * 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
- * 4. 통화패스 설정 확인 및 띵똥 음원 재생
- * 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
- * 6. 시스템 볼륨 원복
- * 7. 통화 앱(WallPadCall) 으로 BR 전송
- */
- AudioManager mAudioManager;
- int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
- Handler mDingDongHandler = new Handler() {
- public void handleMessage(Message msg) {
- try {
- Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
- if (msg.what == 0) {
- // 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
- int nVolume = 10;
- if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
- nVolume = 12;
- mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
- mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
- mDingDongHandler.sendEmptyMessage(1);
- } else if (msg.what == 1) {
- // 띵똥 패스 체크
- check1++;
- if (check1 > 200) {
- Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
- finishDingDongHandler();
- check1 = 0;
- return;
- } else {
- if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
- mDingDongHandler.sendEmptyMessageDelayed(2, 500);
- else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
- }
- } else if (msg.what == 2) {
- // 띵똥 음원 재생
- mIOInterface.ctrlSetTalkPathDoor();
- sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
- } else if (msg.what == 3) {
- mIOInterface.ctrlSetTalkPathNormal();
- mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
- mDingDongHandler.sendEmptyMessage(4);
- } else if (msg.what == 4) {
- // Normal 패스 체크
- check2++;
- if (check2 > 200) {
- Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
- finishDingDongHandler();
- check2 = 0;
- return;
- } else {
- if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
- mDingDongHandler.sendEmptyMessageDelayed(5, 50);
- else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
- }
- } else if (msg.what == 5) {
- Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
- WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
- int nSavedVolume = wdb.GetWallPadMasterVolume();
- wdb.closeDB();
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
- Intent intent = new Intent(); // 통화 앱으로 BR 전송
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
- sendBroadcast(intent);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- finishDingDongHandler();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- finishDingDongHandler();
- }
- }
- };
- private void finishDingDongHandler() {
- try {
- Log.d(TAG, "[finishDingDongHandler]");
- if (mDingDongHandler != null) {
- mDingDongHandler.removeMessages(0);
- mDingDongHandler.removeMessages(1);
- mDingDongHandler.removeMessages(2);
- mDingDongHandler.removeMessages(3);
- mDingDongHandler.removeMessages(4);
- mDingDongHandler.removeMessages(5);
- }
- WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
- int nSavedVolume = wdb.GetWallPadMasterVolume();
- wdb.closeDB();
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
- mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
- mIOInterface.ctrlSetTalkPathNormal();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] finishDingDongHandler()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 외출방범 대기 모드 중 사운드와 센서 체크
- class OutgoingCheckSensor extends Thread {
- public OutgoingCheckSensor() {
- }
- public void run() {
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int timedata = mWallpadStatusData.GetComeBackWaitTime();
- WallPadInterface wpifc = new WallPadInterface();
- mWallpadStatusData.closeDB();
- int checkcount = timedata / 5;
- int i;
- for (i = checkcount; i > 0; i--) {
- mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int alarmst = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- if (alarmst != WallpadStatusData.GUARD_OUT) break;
- Sound().PlayMent(WpadSound.SND.effect.WARNING005);
- Log.d(TAG, "--------- OutgoingCheckSensor ");
- try {
- Thread.sleep(5000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- if (i == 0) {
- mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int alarmst = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- if (alarmst == WallpadStatusData.GUARD_OUT) {
- Common.SendAppFinishReqBR(getApplicationContext());
- int base = 7000;
- int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
- int Menu_Start_Option = 1;
- Intent mIntent = new Intent(Intent.ACTION_MAIN);
- mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
- mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
- if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
- else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
- else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
- mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
- mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- iMAPstartActivity(mIntent);
- }
- }
- Log.d(TAG, "--------- OutgoingCheckSensor End");
- OutGoingSensorWaiting = 0;
- }
- }
- @Override
- public IBinder onBind(Intent arg0) {
- return mMessenger.getBinder();
- //return null;
- }
- public void imapsvrlog(String msg) {
- if (!log_sw) return;
- Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
- }
- public int onStartCommand(Intent intent, int flags, int startID) {
- try {
- try {
- handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- getDeviceCtrlOption();
- SvrSock = new iMapSverSocket();
- SvrSock.start();
- } catch (IOException e) {
- Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- try {
- mGleInterface = new jni();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] mGleInterface init...");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addr = DBMGR.getAddressMGR();
- DBMGR.closeDB();
- String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
- AddrDong = addr.Dong;
- AddrHo = addr.Ho;
- ho = Integer.valueOf(AddrHo.substring(0, 1));
- XMLHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
- "<imap ver=\"1.0\" address=\"" + addr.IPAddress + "\" sender=\"" + AddressStr + "\">\r\n";
- Log.d(TAG, "*****************************************");
- Log.d(TAG, "****************SchedulerThread**********");
- Log.d(TAG, "*****************************************");
- ScheServer = new SchedulerThread();
- ScheServer.start();
- // BR 등록 시작
- Log.d(TAG, "[onStartCommand] BR register start!!!");
- IntentFilter mIntentFilter = new IntentFilter();
- mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
- registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
- mIntentFilter = new IntentFilter();
- mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
- // mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
- registerReceiver(mWallPadCTRDevBR, mIntentFilter);
- mIntentFilter = new IntentFilter();
- mIntentFilter.addAction(define.NOTIFY_ACNAME);
- mIntentFilter.addAction(define.NOTIFY_DAIL);
- mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
- mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
- registerReceiver(mWallPadNotifyBR, mIntentFilter);
- Log.d(TAG, "[onStartCommand] BR register end!!!");
- // BR 등록 완료
- mWallPadAPI = new WallPadAPI(this.getApplicationContext());
- if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
- IGW200APICheckHandler.sendEmptyMessage(0);
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- IGW300APICheckHandler.sendEmptyMessage(0);
- }
- mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
- mIOInterface.setEmergencyType();
- Intent notiIntent = new Intent();
- notiIntent.setAction(define.NOTIFY_ACNAME);
- notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
- getApplicationContext().sendBroadcast(notiIntent);
- CheckMainStatus();
- checkDoorCamConfig(); // 현관카메라 설정정보 확인
- getAirQualityUsage();
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
- SendLHGWCheck GwCheckThread = new SendLHGWCheck();
- GwCheckThread.start();
- }
- getResidentSafetyCheckSetting();
- return START_STICKY;
- }
- //멀티기기 정보 전송을 위한 추가
- public static final int MSG_REGISTER_CLIENT = 1;
- //public static final int MSG_UNREGISTER_CLIENT = 2;
- public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
- public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
- public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
- public static final int MSG_SEND_TO_ACTIVITY = 4;
- private Messenger mClient = null; // Activity 에서 가져온 Messenger
- String remote_get_home_devices1;
- String remote_get_home_devices2;
- String remote_get_home_devices3;
- /**
- * activity로부터 binding 된 Messenger
- */
- private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
- @Override
- public boolean handleMessage(Message msg) {
- Log.w("test", "ControlService - message what : " + msg.what + " , msg.obj " + msg.obj);
- switch (msg.what) {
- case MSG_REGISTER_CLIENT:
- mClient = msg.replyTo; // activity로부터 가져온
- break;
- case MSG_SEND_TO_SERVICE_DEVICES1:
- remote_get_home_devices1 = (String) msg.obj; // activity로부터 가져온
- break;
- case MSG_SEND_TO_SERVICE_DEVICES2:
- remote_get_home_devices2 = (String) msg.obj; // activity로부터 가져온
- break;
- case MSG_SEND_TO_SERVICE_DEVICES3:
- remote_get_home_devices3 = (String) msg.obj; // activity로부터 가져온
- break;
- default:
- sendMsgToActivity(1234);
- break;
- }
- return false;
- }
- }));
- private void sendMsgToActivity(int sendValue) {
- try {
- Bundle bundle = new Bundle();
- bundle.putInt("fromService", sendValue);
- bundle.putString("test", "abcdefg");
- Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
- msg.setData(bundle);
- mClient.send(msg); // msg 보내기
- } catch (RemoteException e) {
- }
- }
- // 메인 서버 소켓 클래스
- public class iMapSverSocket extends Thread {
- ServerSocket svr;
- private SSLServerSocket sslsvr;
- boolean receiveSocketRun = true;
- public iMapSverSocket() throws IOException {
- /////////////////////////////////////////////////////////////////////
- // 신형 단지서버 사용 유무를 가져온다.
- /////////////////////////////////////////////////////////////////////
- try {
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
- wallpadDeviceSet.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- mNewDanjiServer = false;
- } catch (Exception e) {
- Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mNewDanjiServer = false;
- }
- //////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- // 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
- /////////////////////////////////////////////////////////////////////
- if (!mNewDanjiServer) {
- svr = new ServerSocket(port);
- } else {
- int svrport = port + 1000;
- Log.i(TAG, "============================================");
- Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
- Log.i(TAG, "============================================");
- SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
- sslsvr = sslServerSocket.getServerSocket();
- }
- }
- public void run() {
- while (receiveSocketRun) {
- try {
- Socket sock = null;
- /////////////////////////////////////////////////////////////////////
- // 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
- /////////////////////////////////////////////////////////////////////
- if (!mNewDanjiServer) {
- sock = svr.accept();
- } else {
- sock = sslsvr.accept();
- }
- //madeinlab accept 대기중에 모바일에서 요청오면 아래 쓰레드 돌려서 처리.
- //아래 쓰레드가 돌기전에 다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
- sendMsgToActivity(1234);
- iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
- ProciMap.start();
- } catch (IOException e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void destoryThread() {
- receiveSocketRun = false;
- try {
- if (svr != null) {
- svr.close();
- svr = null;
- }
- if (sslsvr != null) {
- sslsvr.close();
- sslsvr = null;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public String getRemoteIPAddress(Socket Sock) {
- try {
- // Log.i(TAG, "[getRemoteIPAddress] == START ==");
- if (Sock == null) return "10.0.1.1";
- String strRemoteIP = Sock.getRemoteSocketAddress().toString();
- String[] strSplited_01 = strRemoteIP.split(":");
- String[] strSplited_02 = strSplited_01[0].split("/");
- strRemoteIP = strSplited_02[1];
- return strRemoteIP;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getRemoteIPAddress(Sock)");
- e.printStackTrace();
- return "10.0.1.1";
- }
- }
- // iMAP 서버 소켓 처리
- public class iMapSverSocketThread extends Thread {
- private final Socket iMAPSock;
- String strRcvMSG;
- WallPadiMAPUpgrade upgradeProc;
- Document doc;
- public iMapSverSocketThread(Socket sock) {
- iMAPSock = sock;
- }
- public void run() {
- try {
- Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
- InputStream InStm = iMAPSock.getInputStream();
- iMAPSock.setSoLinger(true, 3000);
- BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
- strRcvMSG = "";
- String InBuffer;
- int i = 0;
- boolean bRcvOK = false;
- lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
- /////////////////////////////////////////////////////////////////////
- // 신형단지서버 미사용중일 경우 기존 코드로,
- // 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
- // (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
- /////////////////////////////////////////////////////////////////////
- if (!mNewDanjiServer) {
- while (System.currentTimeMillis() < lSocketConnectionPeriod) {
- try {
- if (MsgReader.ready()) {
- try {
- char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
- InBuffer = "";
- while (MsgReader.ready()) {
- long charCnt = MsgReader.read(ReadData);
- InBuffer += new String(ReadData, 0, (int) charCnt);
- }
- if (InBuffer != null) strRcvMSG += InBuffer;
- if (0 < InBuffer.indexOf("</imap>")) {
- bRcvOK = true;
- Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
- break;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return;
- }
- } else {
- Thread.sleep(100);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- iMAPSock.close();
- return;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
- iMAPSock.close();
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return;
- }
- }
- } else {
- // SSL 암호화 데이터 수신부
- // * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
- char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
- while (System.currentTimeMillis() < lSocketConnectionPeriod) {
- try {
- InBuffer = "";
- long charCnt = MsgReader.read(ReadData);
- if (charCnt > 0) {
- InBuffer += new String(ReadData, 0, (int) charCnt);
- strRcvMSG += InBuffer;
- if (-1 < InBuffer.indexOf("</imap>")) {
- bRcvOK = true;
- Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
- break;
- }
- } else {
- Thread.sleep(100);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- iMAPSock.close();
- return;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
- iMAPSock.close();
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return;
- }
- }
- }
- if (!bRcvOK) {
- Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
- Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
- Log.i(TAG, strRcvMSG);
- Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
- iMAPSock.close();
- return;
- }
- strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
- imapsvrlog("Socket read end accept </imap>\n" + strRcvMSG);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
- doc = builder.parse(istream);
- Element elelist = doc.getDocumentElement();
- NodeList items = elelist.getElementsByTagName("service");
- Node item = items.item(0);
- NamedNodeMap attrs = item.getAttributes();
- String retXML = "";
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- String cmd;
- if (attr.getNodeName().equalsIgnoreCase("type")) {
- cmd = attr.getNodeValue();
- if (cmd.equalsIgnoreCase("notice")) {
- iMAPSock.close();
- }
- } else if (attr.getNodeName().equalsIgnoreCase("name")) {
- cmd = attr.getNodeValue();
- if (cmd.equalsIgnoreCase("event_notify")) {
- retXML = ProcEventNotify(elelist);
- } else if (cmd.equalsIgnoreCase("elevator_move_info")) {
- ProcElevatorinfo(elelist);
- retXML = null;
- } else if (cmd.equalsIgnoreCase("check_epics_upload")) {
- retXML = ProcCheckEpiceUpload(doc);
- } else if (cmd.equalsIgnoreCase("update_news")) {
- retXML = ProcUpdateNews(doc);
- } else if (cmd.equalsIgnoreCase("update_weather")) {
- retXML = ProcUpdateWeather(doc);
- } else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
- retXML = ProcSchduleInquiry(doc);
- } else if (cmd.equalsIgnoreCase("schedule_renew")) {
- retXML = ProcSchduleRenew(doc);
- } else if (cmd.equalsIgnoreCase("schdule")) {
- String SvcType = "";
- int k;
- for (k = j + 1; k < attrs.getLength(); k++) {
- Node attr1 = attrs.item(k);
- SvcType = attr1.getNodeName();
- if (SvcType.equalsIgnoreCase("shc_type")) {
- SvcType = attr1.getNodeValue();
- break;
- }
- }
- retXML = ProcUpdateSchedule(elelist, SvcType);
- } else if (cmd.equalsIgnoreCase("device_reset")) {
- retXML = ProcDeviceReset(elelist);
- } else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
- retXML = ProcNotifyparcel(doc);
- } else if (cmd.equalsIgnoreCase("notify_post_info")) {
- // 스마트우편함 연동 여부
- WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
- boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
- DevSet.closeDB();
- Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
- if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
- } else if (cmd.equalsIgnoreCase("get_security_mode")) {
- String Dong = null;
- String Ho = null;
- WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
- String result;
- String modeStr = null;
- int status = statusDB.GetAlarmStatus();
- if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
- if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
- else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
- else if (status == WallpadStatusData.GUARD_OUT)
- modeStr = "unoccupied";
- else if (status == WallpadStatusData.GUARD_OUT_WAIT)
- modeStr = "waitunoccupied";
- result = "ok";
- } else {
- modeStr = "null";
- result = "fail";
- }
- try {
- NodeList GSM_items = elelist.getElementsByTagName("home_info");
- Node GSM_item = GSM_items.item(0);
- NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
- for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
- Node GSM_attr = GSM_attrsParam.item(k);
- if (GSM_attr.getNodeName().equalsIgnoreCase("dong"))
- Dong = trimquotation(GSM_attr.getNodeValue());
- else if (GSM_attr.getNodeName().equalsIgnoreCase("ho"))
- Ho = trimquotation(GSM_attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
- result = "fail";
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- result = "fail";
- } catch (Exception e) {
- result = "fail";
- }
- retXML = XMLHeader +
- " <service type=\"reply\" name=\"get_security_mode\" result=\"" + result + "\">\r\n" +
- " <home_info dong=\"" + AddrDong + "\" ho=\"" + AddrHo + "\" mode=\"" + modeStr + "\"/>\r\n" +
- " </service>\r\n" +
- "</imap>\r\n";
- statusDB.closeDB();
- } else if (cmd.equalsIgnoreCase("set_setup_info")) {
- retXML = ProcSetsetup(doc);
- } else if (cmd.equalsIgnoreCase("get_setup_info")) {
- retXML = ProcGetsetup(doc);
- } else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
- retXML = CheckPassword(doc);
- } else if (cmd.equalsIgnoreCase("device_live_check")) {
- retXML = ProcDeviceLiveCheck();
- } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
- retXML = ProcPairingHdevSyncAlarm(elelist);
- } else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
- retXML = ProcPairingHdevSyncSecurity(elelist);
- } else if (cmd.equalsIgnoreCase("notify_car_event")) {
- retXML = ProcParkInformation(elelist);
- } else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
- retXML = ProcSmartKeyEvent(elelist);
- } else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
- retXML = ProcParkInformation_cham_upis(elelist);
- } else if (cmd.equalsIgnoreCase("remote_auscultate")) {
- retXML = ProcauscultateReq(doc);
- } else if (cmd.equalsIgnoreCase("upgrade")) {
- imapsvrlog("Enter Upgrade");
- procUpgrade();
- retXML = null;
- } else if (cmd.equals("check_sip_activation")) {
- String sip_result = "fail";
- ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
- List<ActivityManager.RunningServiceInfo> rsi = manager.getRunningServices(50);
- //add KSJ 2021.11.02 socket addr 가져오기 위해 추가
- String strIP = getRemoteIPAddress(iMAPSock);
- //~add KSJ
- // Jeff added below codes for call app (2018.01.25)
- String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
- for (int k = 0; k < rsi.size(); k++) {
- ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
- if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
- sip_result = "ok";
- break;
- }
- }
- if(bWallPadCallLive && m_bWallpadCallScreen == false)
- {
- sip_result = "fail";
- }
- 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";
- //add KSJ 2021.11.02 check_sip_activation msg recv 이후 wallpadcall app start
- String[] IP_Parse = strIP.split("\\.");
- Log.d(TAG, "1" + strIP);
- //Log.d(TAG, "2" + strSplit[1]);
- //Log.d(TAG, "3" + strSplit[2]);
- //Log.d(TAG, "4" + strSplit[3]);
- CALLTYPE eCallType = CALLTYPE.LOBBY;
- if (IP_Parse[2].equals("0")) {
- eCallType = CALLTYPE.LOBBY;
- if (IP_Parse[3].equals("11"))
- eCallType = CALLTYPE.FRONT;
- } else if (IP_Parse[2].equals("129")) {
- eCallType = CALLTYPE.FRONT;
- } else {
- eCallType = CALLTYPE.RESIDENCE;
- }
- if ((eCallType == CALLTYPE.LOBBY) || (eCallType == CALLTYPE.FRONT))
- runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
- }
- //add KSJ 2021.11.02 stop_talking msg 추가 (wallpadcall 종료)
- else if (cmd.equals("stop_talking")) {
- Common.SendAppFinishReqBR(getApplicationContext());
- }
- //~add KSJ
- else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
- retXML = iCMDProcDevList(doc);
- } else if (cmd.equalsIgnoreCase("remote_access_gas")) {
- retXML = iCMDProcGASControl(elelist);
- } else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
- // 현대건설 더펜트하우스 와 구분하여 처리
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
- mWallpadDeviceSet.closeDB();
- if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
- retXML = iCMDProcChumDamSmartLightControl(doc);
- }
- else {
- retXML = iCMDProcSDPSmartLightControl(doc);
- }
- } else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
- if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
- || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
- retXML = iCMDProc_I_LightControl(doc);
- } else {
- retXML = iCMDProcLivingLightControl(doc);
- }
- } else if (cmd.equalsIgnoreCase("remote_access_electric")) {
- if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I
- || ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
- || ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
- retXML = iCMDProcSDPConcentControl(doc);
- } else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
- || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
- retXML = iCMDProcEnergyMeterConcentControl(doc);
- } else {
- retXML = iCMDProcMultiSWControl(doc);
- }
- } else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
- retXML = iCMDProcDoorlockControl(doc);
- } else if (cmd.equalsIgnoreCase("remote_access_temper")) {
- retXML = iCMDProcTemperControl(doc);
- } else if (cmd.equalsIgnoreCase("remote_access_mode")) {
- retXML = iCMDProcModeControl(doc);
- } else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
- retXML = iCMDProcVentilControl(doc);
- } else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
- retXML = iCMDProcCurtainControl(doc);
- } else if (cmd.equalsIgnoreCase("remote_access_light")) {
- if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
- retXML = iCMDProcEnergyMeterLightControl(doc);
- } else {
- retXML = iCMDProcLightControl(doc);
- }
- } else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
- retXML = iCMDProcLightBatchControl(elelist);
- }
- //모바일 사용자 인증 관련 메시지
- else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
- ProcMobileDevice_AuthNumber(elelist);
- } else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
- retXML = ProcMobileDevice_ADD_Finish(elelist);
- } else if (cmd.equalsIgnoreCase("remote_delete_device")) {
- ProcMobileDevice_Delete(elelist);
- } else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
- retXML = ProcGetSmartKeyInfo(elelist);
- } else if (cmd.equalsIgnoreCase("get_app_version_info")) {
- retXML = ProcGetAppVersionInfo();
- } else if (cmd.equalsIgnoreCase("igate_init_info")) {
- retXML = ProcIgateInitInfo(elelist);
- } else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
- retXML = ProcElecCarChargeEventInfo(elelist);
- } else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
- retXML = ProcEnergyTargetInfoAlarm(elelist);
- } else if (cmd.equalsIgnoreCase("check_call_option")) {
- retXML = ProcCheckCallOption();
- } else if (cmd.equalsIgnoreCase("chat_sequence")) {
- retXML = ProcChatSequence(elelist);
- } else if (cmd.equalsIgnoreCase("chat_message")) {
- retXML = ProcChatMessage(elelist);
- } else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
- retXML = ProcEvacuationLadderOpen(elelist);
- } else if (cmd.equalsIgnoreCase("smart_light_info")) {
- retXML = SmartLightDetailInfo(elelist);
- } else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
- retXML = KNXDeviceDetailInfo(elelist);
- } else if (cmd.equalsIgnoreCase("set_server_version")) {
- retXML = ProcSetServerChange(elelist);
- } else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
- retXML = iCMDProcOnePass(elelist);
- } else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
- }
- } else if (cmd.equalsIgnoreCase("check_resident_safety")) {
- retXML = iCMDProcResidentSafety(elelist);
- }
- break;
- }
- }
- if (retXML != null) {
- imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
- DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
- byte[] outBF = retXML.getBytes("euc-kr");
- outstream.write(outBF);
- outstream.flush();
- try {
- Thread.sleep(3000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- iMAPSock.close();
- } else {
- try {
- iMAPSock.close();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- try {
- iMAPSock.close();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception E) {
- LogUtil.errorLogInfo("", TAG, E);
- }
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
- private void procUpgrade() {
- imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
- WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
- String[] getstate = sdb.GetSystemUpdateStatus();
- sdb.closeDB();
- Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
- for (int i = 0; i < getstate.length; i++) {
- Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
- }
- if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
- upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
- if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
- }
- }
- // " 제거
- private String trimquotation(String sen) {
- sen = sen.replaceAll("\"", "");
- return sen.trim();
- }
- //remote_auscultate 처리
- public String ProcauscultateReq(Document Doc) {
- String RetVal = XMLHeader + "<service type=\"reply\" name=\"remote_auscultate\" result=";
- NodeList items = Doc.getElementsByTagName("group");
- Node item;
- String itemname = null;
- WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
- SettManager.DeleteSettingData();
- SettManager.DropTable();
- try {
- for (int i = 0; i < items.getLength(); i++) {
- item = items.item(i);
- itemname = GetAttributeVal(item, "type");
- String GetCNT = GetAttributeVal(item, "count");
- if (Integer.parseInt(GetCNT) <= 0)
- continue;
- Element SettingItem = (Element) item;
- NodeList SettingList = SettingItem.getElementsByTagName("unit");
- for (int j = 0; j < SettingList.getLength(); j++) {
- Node subdevListitem = SettingList.item(j);
- String devname = trimquotation(subdevListitem.getTextContent());
- SettManager.InsertSettingData(itemname, devname, j);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
- SettManager.closeDB();
- return RetVal;
- } catch (Exception e) {
- RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- SettManager.closeDB();
- return RetVal;
- }
- SettManager.closeDB();
- RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
- StatusBeatRequested = true;
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
- sendBroadcast(intent);
- return RetVal;
- }
- public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
- String defaultAUSSet = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
- "<imap ver=\"1.0\" address=\"10.0.1.1\" sender=\"단지서버\">\r\n" +
- "<service type=\"request\" name=\"remote_auscultate\">\r\n" +
- " <guidemap devtype=\"homedev\" count=\"4\">\r\n" +
- " <group type=\"ctrl_device\" count=\"5\">\r\n" +
- " <unit>\"light\"</unit>\r\n" +
- " <unit>\"thermostat\"</unit>\r\n" +
- " <unit>\"gas\"</unit>\r\n" +
- " <unit>\"doorlock\"</unit>\r\n" +
- " <unit>\"ventil\"</unit>\r\n" +
- " </group>\r\n" +
- " <group type=\"talk_device\" count=\"4\">\r\n" +
- " <unit>\"sub_homedev\"</unit>\r\n" +
- " <unit>\"kitchen_tv\"</unit>\r\n" +
- " <unit>\"bath_tv\"</unit>\r\n" +
- " <unit>\"bath_phone\"</unit>\r\n" +
- " </group>\r\n" +
- " <group type=\"sensor\" count=\"6\">\r\n" +
- " <unit>\"magnetic\"</unit>\r\n" +
- " <unit>\"bugout\"</unit>\r\n" +
- " <unit>\"bugin\"</unit>\r\n" +
- " <unit>\"fire\"</unit>\r\n" +
- " <unit>\"gas\"</unit>\r\n" +
- " <unit>\"emergency\"</unit>\r\n" +
- " </group>\r\n" +
- " <group type=\"extended\" count=\"4\">\r\n" +
- " <unit>\"gateway\"</unit>\r\n" +
- " <unit>\"smartswitch\"</unit>\r\n" +
- " <unit>\"handy\"</unit>\r\n" +
- " <unit>\"energymeter\"</unit>\r\n" +
- " </group>\r\n" +
- " </guidemap>\r\n" +
- "</service>\r\n" +
- "</imap>\r\n";
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
- Document doc = builder.parse(istream);
- NodeList items = doc.getElementsByTagName("group");
- Node item;
- String itemname = null;
- SettManager.DeleteSettingData();
- SettManager.DropTable();
- for (int i = 0; i < items.getLength(); i++) {
- item = items.item(i);
- itemname = GetAttributeVal(item, "type");
- String GetCNT = GetAttributeVal(item, "count");
- if (Integer.parseInt(GetCNT) <= 0)
- continue;
- Element SettingItem = (Element) item;
- NodeList SettingList = SettingItem.getElementsByTagName("unit");
- for (int j = 0; j < SettingList.getLength(); j++) {
- Node subdevListitem = SettingList.item(j);
- String devname = trimquotation(subdevListitem.getTextContent());
- SettManager.InsertSettingData(itemname, devname, j);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- String MakeFailMessage(String msg) {
- return XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=\"fail\" >\r\n <first_failed>\"" + msg + "\"</first_failed>\r\n</service>\r\n</imap>";
- }
- //SetInfo의 각 항목들의 무결성 확인
- final String isUse = "사용함";
- final String isNotUse = "사용안함";
- boolean CheckSubdevData(String devName, String devData) {
- String[] SplitedMSG;
- try {
- if (devName.equals("가스밸브")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String UseStr = SplitedMSG[2].split("[)]")[0];
- if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
- } else if (devName.equals("디지털도어락")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- if (!UseStr[1].equals("종류")) return false;
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
- } else if (devName.equals("온도조절기")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("조명제어기")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- if (!UseStr[1].equals("종류"))
- return false;
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
- return false;
- */
- } else if (devName.equals("환기시스템")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- if (!UseStr[1].equals("종류"))
- return false;
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
- return false;
- */
- } else if (devName.equals("시스템에어컨")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("전동커튼")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- if (!UseStr[1].equals("종류"))
- return false;
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
- return false;
- */
- } else if (devName.equals("실시간검침기")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("스마트스위치&일괄소등")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- if (!UseStr[1].equals("종류"))
- return false;
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("대외향스마트스위치")&&
- !UseStr[0].equals("대외향일괄소등제어기")&&
- !UseStr[0].equals("현산향3로제어일괄소등제어기")&&
- !UseStr[0].equals("현산향스마트스위치")&&
- !UseStr[0].equals("현산향LCD스마트스위치"))
- return false;
- */
- } else if (devName.equals("무선리모컨")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("현관카메라")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- if (!UseStr[1].equals("종류"))
- return false;
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
- return false;
- */
- } else if (devName.equals("공지사항")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("날씨")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("메모")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("전자액자")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("일정표")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("주차확인")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
- return false;
- */
- } else if (devName.equals("시간설정")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("원격검침")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("뮤직")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("영상재생")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("CCTV")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
- return false;
- */
- } else if (devName.equals("명칭설정")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("출동경비")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("경비실영상통화")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("엘리베이터")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
- return false;
- */
- } else if (devName.equals("현장특화기능")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
- return false;
- */
- } else if (devName.equals("월패드카메라")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("무드등")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- /*
- UseStr = SplitedMSG[3].split("[)]");
- if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
- return false;
- */
- } else if (devName.equals("피난사다리")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("동체설정")) {
- return true;
- /*
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName))
- return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
- return false;
- if (UseStr[0].equals(isNotUse)) return true;
- if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
- return false;
- for (int i=3; i < SplitedMSG.length; i++)
- {
- UseStr = SplitedMSG[i].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
- return false;
- if (i != SplitedMSG.length-1)
- {
- if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
- return false;
- }
- }
- */
- } else if (devName.equals("알람발생")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else if (devName.equals("UI순서")) {
- SplitedMSG = devData.split("[(]");
- if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
- String[] UseStr = SplitedMSG[2].split("[)]");
- if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
- } else {
- Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
- Log.w("iMAP", "Return true");
- return true;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- return true;
- }
- public String ProcSetsetup(Document ele) {
- Common.DebugLog("ProcSetsetup------------------------->");
- String RetVal = XMLHeader + "<service type=\"reply\" name=\"set_setup_info\" result=";
- NodeList items = ele.getElementsByTagName("setting");
- Node item;
- String itemname = null;
- String dateData = null;
- String heartbeatP = null;
- String Versions = null;
- String SdbAccInit_Str = null;
- WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
- Queue<AfterTransactionTodoListData> AfterTransactionTodoList = new LinkedList<AfterTransactionTodoListData>();
- if (!SettManager.StartTransaction()) {
- ResetFlag = false;
- RetVal += "\"fail\" >\r\n <first_failed>\"service\"</first_failed>\r\n</service>\r\n</imap>";
- SettManager.EndTransaction(false);
- SettManager.closeDB();
- return RetVal;
- }
- try {
- for (int i = 0; i < items.getLength(); i++) {
- item = items.item(i);
- itemname = GetAttributeVal(item, "name");
- if (itemname != null) {
- if (itemname.equals("beat_time")) {
- heartbeatP = GetAttributeVal(item, "value");
- } else if (itemname.equals("ver_setting")) {
- Versions = GetAttributeVal(item, "value");
- } else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
- Element guardlist = (Element) item;
- NodeList GuardCTList = guardlist.getElementsByTagName("list");
- if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
- else continue;
- for (int j = 0; j < GuardCTList.getLength(); j++) {
- Node GuardListitem = GuardCTList.item(j);
- String guardname = GetAttributeVal(GuardListitem, "name");
- String guardvalue = GetAttributeVal(GuardListitem, "value");
- SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
- }
- } else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
- Element subdevList = (Element) item;
- NodeList SubDevList = subdevList.getElementsByTagName("list");
- for (int j = 0; j < SubDevList.getLength(); j++) {
- Node subdevListitem = SubDevList.item(j);
- String devname = GetAttributeVal(subdevListitem, "name");
- String devval = GetAttributeVal(subdevListitem, "value");
- if (devname != null && devval != null) {
- devname = devname.replaceAll("\\p{Z}", "");
- devval = devval.replaceAll("\\p{Z}", "");
- if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
- devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
- devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
- }
- if (CheckSubdevData(devname, devval) == false) {
- ResetFlag = false;
- Log.w("iMAP", "Set Setup Fail name : " + devname + " Value : " + devval);
- SettManager.EndTransaction(false);
- SettManager.closeDB();
- return MakeFailMessage(devname);
- }
- String[] SettingDBValue = SettManager.GetSettingData(devname);
- if (SettingDBValue != null) {
- String devInfo = SettingDBValue[1];
- if (devInfo.equals(devval) == false) {
- Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
- Log.w("iMAP", "DB Setup Value : " + devInfo);
- SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
- ResetFlag = true;
- }
- } else {
- Log.w("iMAP", "DB No Setup Name and Value");
- Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
- SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
- ResetFlag = true;
- }
- //iMAP 설정값 수신 시 즉시 적용해야할 사항들.
- if (devname.equals("로고설정")) {
- String devInfo = devval;
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] DetailInfo = devInfo.split("_");
- int LogoType = 0;
- if (DetailInfo[5].equals("표시안함") == true) {
- LogoType = 0;
- } else if (DetailInfo[5].equals("SKT스마트홈") == true) {
- LogoType = 1;
- } else if (DetailInfo[5].equals("양우내안애") == true) {
- LogoType = 2;
- } else if (DetailInfo[5].equals("GSITM") == true) {
- LogoType = 3;
- } else if (DetailInfo[5].equals("제로에너지하우스") == true) {
- LogoType = 4;
- } else if (DetailInfo[5].equals("거실조명표시") == true) {
- LogoType = 5;
- } else if (DetailInfo[5].equals("거실조명삭제") == true) {
- LogoType = 6;
- } else if (DetailInfo[5].equals("기타1") == true) {
- LogoType = 7;
- } else if (DetailInfo[5].equals("기타2") == true) {
- LogoType = 8;
- }
- if ((LogoType >= 0) && (LogoType <= 8)) {
- AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
- AfterTransactionTodoList.offer(afterTransactionTodoListData);
- }
- } else if (devname.equals("엘리베이터위젯복구")) {
- String devInfo = devval;
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] DetailInfo = devInfo.split("_");
- if (DetailInfo[3].equals("사용함") == true) {
- AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
- AfterTransactionTodoList.offer(afterTransactionTodoListData);
- }
- } else if (devname.equals("분전반알람설정")) {
- try {
- String devInfo = devval;
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
- //[0] - 기기번호
- //[1] - 회로수
- //[2] - 기기이름
- //[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
- //[4] - 명칭
- //[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
- String[] DetailInfo = devInfo.split("_");
- for (int a = 0; a < DetailInfo.length; a++) {
- if (DetailInfo[a].equals("누적전력초기화")) {
- // 분전반 알람 설정 안에 '초기화'가 있는 경우
- if ((a + 1) <= DetailInfo.length) {
- // 설정정보가 존재해야 인식하도록 함
- if (DetailInfo[a + 1].equals("1")) {
- // 1(사용함) 일때
- if (sdbAPI != null) {
- if (sdbAPI.Set_AccPwReset() >= 0) {
- Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
- } else {
- Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
- }
- }
- AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
- AfterTransactionTodoList.offer(afterTransactionTodoListData);
- }
- devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
- SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
- Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- } else if (devname.equals("욕실폰통화음량값")) {
- Intent Iintent = new Intent();
- Iintent.setAction(define.NOTIFY_ACNAME);
- Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
- sendBroadcast(Iintent);
- } else if (devname.equals("주방TV통화음량값")) {
- Intent Iintent = new Intent();
- Iintent.setAction(define.NOTIFY_ACNAME);
- Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
- sendBroadcast(Iintent);
- } else if (devname.equals("현관카메라")) {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- String devInfo = devval;
- if (devInfo != null) {
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] DetailInfo = devInfo.split("_");
- if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
- if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
- Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
- if (mIOInterface != null)
- mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
- } else {
- Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
- if (mIOInterface != null)
- mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
- }
- }
- }
- }
- } else if (devname.equals("거동수상자녹화")) {
- String devInfo = devval;
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] DetailInfo = devInfo.split("_");
- } else if (devname.equals("스마트현관카메라좌우반전")) {
- String devInfo = devval;
- if (devInfo != null) {
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- }
- String[] DetailInfo = devInfo.split("_");
- if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
- if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
- Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
- mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
- } else {
- Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
- mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
- }
- }
- } else {
- Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
- }
- }
- }
- } else if (itemname.equals("datetime")) {
- dateData = GetAttributeVal(item, "value");
- } else {
- String GetVal = GetAttributeVal(item, "value");
- if (GetVal != null) {
- if (!GetVal.equals("list")) {
- if (itemname.equals("site_code")) {
- String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
- if (Existing_SiteCode_Array == null) {
- ResetFlag = true;
- } else {
- String Existing_SiteCode = Existing_SiteCode_Array[1];
- if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
- ResetFlag = true;
- }
- }
- }
- SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
- } else {
- String GetCNT = GetAttributeVal(item, "count");
- if (Integer.parseInt(GetCNT) <= 0) continue;
- Element SettingItem = (Element) item;
- NodeList SettingList = SettingItem.getElementsByTagName("list");
- for (int j = 0; j < SettingList.getLength(); j++) {
- Node subdevListitem = SettingList.item(j);
- String devname = GetAttributeVal(subdevListitem, "name");
- String devval = GetAttributeVal(subdevListitem, "value");
- SettManager.UpdateSettingData(itemname, devname, j, devval);
- }
- }
- }
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- ResetFlag = false;
- RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
- SettManager.EndTransaction(false);
- SettManager.closeDB();
- return RetVal;
- } catch (Exception e) {
- ResetFlag = false;
- RetVal += "\"fail\" >\r\n <first_failed>\"" + itemname + "\"</first_failed>\r\n</service>\r\n</imap>";
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- SettManager.EndTransaction(false);
- SettManager.closeDB();
- return RetVal;
- }
- SettManager.EndTransaction(true);
- SettManager.closeDB();
- //** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
- if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
- Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
- mResetHandler.sendEmptyMessageDelayed(0, 1000);
- }
- if (AfterTransactionTodoList != null) {
- if (AfterTransactionTodoList.size() > 0) {
- for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
- AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
- if (afterTransactionTodoListData != null) {
- if (afterTransactionTodoListData.Title.equals("로고설정")) {
- WallpadSalesSampleData mWallpadSalesSampleData;
- mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
- mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
- mWallpadSalesSampleData.closeDB();
- } else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
- //ifdb에 있는지
- ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int result = devSet.Get_Elevator_Info();
- devSet.closeDB();
- if (result != WallpadDeviceSet.ELEVATOR_NONE) {
- // 엘리베이터가 사용함이면
- if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
- boolean result_get_restoreUseOrNot;
- WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
- if (wdb != null) {
- result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
- if (result_get_restoreUseOrNot == false) {
- wdb.SetElevator_Widget_Restore(true);
- //위젯 DB 초기화
- WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
- devSet2.DropTable(wallpaddbmgr.WidgetTBL);
- devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
- devSet2.initWidgetData();
- devSet2.closeDB();
- }
- }
- wdb.closeDB();
- }
- }
- }
- }
- }
- }
- }
- if (dateData != null) {
- try {
- int year = Integer.parseInt(dateData.substring(0, 4));
- int month = Integer.parseInt(dateData.substring(4, 6));
- int day = Integer.parseInt(dateData.substring(6, 8));
- int hour = Integer.parseInt(dateData.substring(8, 10));
- int min = Integer.parseInt(dateData.substring(10, 12));
- int sec = Integer.parseInt(dateData.substring(12, 14));
- Calendar nowdate = new GregorianCalendar();
- long settedtime = nowdate.getTimeInMillis();
- nowdate.set(Calendar.YEAR, year);
- nowdate.set(Calendar.MONTH, month);
- nowdate.set(Calendar.DAY_OF_MONTH, day);
- nowdate.set(Calendar.HOUR_OF_DAY, hour);
- nowdate.set(Calendar.MINUTE, min);
- nowdate.set(Calendar.SECOND, sec);
- long bootupmil = nowdate.getTimeInMillis();
- if (Math.abs(bootupmil - settedtime) > 5000) {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- DBMGR.setSystemTime(year, month, day, hour, min, sec);
- DBMGR.closeDB();
- Intent Iintent = new Intent();
- Iintent.setAction(define.NOTIFY_ACNAME);
- Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
- sendBroadcast(Iintent);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- if (heartbeatP != null) {
- try {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
- DBMGR.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
- SettManager.closeDB();
- return RetVal;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- RetVal += "\"fail\" >\r\n <first_failed>\"beat_time\"</first_failed>\r\n</service>\r\n</imap>";
- SettManager.closeDB();
- return RetVal;
- }
- }
- if (Versions != null) {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- Log.d(TAG, "-----------Version Save ---------->" + Versions);
- DBMGR.SetSettingVer(Versions);
- DBMGR.closeDB();
- }
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
- getApplicationContext().sendBroadcast(intent);
- RetVal += "\"ok\" >\r\n </service>\r\n</imap>";
- return RetVal;
- }
- public String ProcNotifyparcel(Document doc) {
- String moveInfo = "null";
- String boxNo = "null";
- String serviceInfo = "null";
- String receiverInfo = "null";
- String message = "null";
- int remainCnt = 0;
- try {
- NodeList param = doc.getElementsByTagName("move_info");
- Node item = param.item(0);
- moveInfo = trimquotation(item.getTextContent());
- param = doc.getElementsByTagName("params");
- item = param.item(0);
- if (item != null) {
- boxNo = GetAttributeVal(item, "box_num");
- serviceInfo = GetAttributeVal(item, "service_info");
- receiverInfo = GetAttributeVal(item, "receiver_info");
- message = GetAttributeVal(item, "message");
- if (message != null) {
- String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
- if (msgList[0].equalsIgnoreCase("remains")) {
- remainCnt = Integer.parseInt(msgList[1]);
- if (remainCnt > 0) {
- wakeupLCD();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
- intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
- intent.putExtra("BOX_NO", boxNo);
- intent.putExtra("SERVICE_INFO", serviceInfo);
- intent.putExtra("RECEIVER_INFO", receiverInfo);
- intent.putExtra("REMAIN_CNT", remainCnt);
- getApplicationContext().sendBroadcast(intent);
- }
- }
- }
- }
- String retVal = XMLHeader +
- "<service type = \"reply\" name= \"notify_parcel_event\" result = \"ok\" />\r\n" +
- "</imap>\r\n";
- return retVal;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- String retVal = XMLHeader +
- "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
- "</imap>\r\n";
- return retVal;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- String retVal = XMLHeader +
- "<service type = \"reply\" name= \"notify_parcel_event\" result = \"fail\" />\r\n" +
- "</imap>\r\n";
- return retVal;
- }
- }
- public String ProcNotiPostInfo(Document doc) {
- NodeList param = doc.getElementsByTagName("move_info");
- Node item = param.item(0);
- String aa = item.getTextContent();
- aa = trimquotation(aa);
- if (item != null) {
- String info = item.getTextContent();
- if (info != null) {
- Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
- if (info.contains("post_in")) { // 우편물 보관
- wakeupLCD();
- int itemCount = -1;
- param = doc.getElementsByTagName("params");
- item = param.item(0);
- if (item != null) {
- String devname = GetAttributeVal(item, "message");
- if (devname != null) {
- if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
- String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
- if (msgList[0].equalsIgnoreCase("remains")) {
- itemCount = Integer.parseInt(msgList[1]);
- }
- }
- }
- }
- if (itemCount > 0) {
- Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
- intent.putExtra(define.NOTIBR_CONTENT, aa);
- intent.putExtra("ITEM", itemCount);
- getApplicationContext().sendBroadcast(intent);
- }
- }
- }
- }
- String retVal = XMLHeader +
- "<service type = \"reply\" name= \"notify_post_info\" result = \"ok\" />\r\n" +
- "</imap>\r\n";
- return retVal;
- }
- /* 15.04.02 강현수 주석처리(기존 ANC 작업분)
- public String ProcNotifypark(Document doc)
- {
- String MoveInfo = "none";
- NodeList param = doc.getElementsByTagName("destination");
- Node item = param.item(0);
- if (item != null)
- {
- String dong = GetAttributeVal(item, "id_high").trim();
- String ho = GetAttributeVal(item, "id_low").trim();
- if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
- return (XMLHeader +
- "<service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n"+
- "</imap>\r\n");
- }
- param = doc.getElementsByTagName("move_info");
- item = param.item(0);
- if (item != null) MoveInfo = trimquotation(item.getNodeValue());
- param = doc.getElementsByTagName("params");
- item = param.item(0);
- if (item != null)
- {
- String carnum = GetAttributeVal(item, "car_num");
- String locinfo = GetAttributeVal(item, "loc_info");
- String msg = GetAttributeVal(item, "message");
- WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
- parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
- parkdb.closeDB();Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
- getApplicationContext().sendBroadcast(intent);
- }
- String retVal = XMLHeader +
- "<service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n"+
- "</imap>\r\n";
- return retVal;
- }
- */
- public String ProcGetsetup(Document doc) {
- WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
- NodeList items = doc.getElementsByTagName("variable");
- String RetVal = XMLHeader + "<service type=\"reply\" name=\"get_setup_info\" result=\"ok\">\r\n" +
- " <guidemap devtype=\"homedev\" count=\"" + items.getLength() + "\">\r\n";
- Node item;
- try {
- for (int i = 0; i < items.getLength(); i++) {
- item = items.item(i);
- //String mRealTimeMeterData = item.getNodeValue();
- String data = trimquotation(item.getTextContent());
- List<String[]> gData = SettManager.GetSettingGroupData(data);
- if (gData.size() == 1) {
- RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + gData.get(0)[1] + "\" />\r\n";
- } else if (gData.size() > 1) {
- RetVal += " <setting name=\"" + data + "\" count=\"" + gData.size() + "\" value=\"list\" >\r\n";
- RetVal += " <list name=\"DeviceInfo\" value=\"" + Build.MODEL + "/" + getAOSVerCode() + "\" />\r\n";
- for (int k = 0; k < gData.size(); k++) {
- // String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
- if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
- //String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
- gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
- gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
- }
- RetVal += " <list name=\"" + gData.get(k)[0] + "\" value=\"" + gData.get(k)[1] + "\" />\r\n";
- }
- if (bAirQualityEnable) {
- RetVal += " <list name=\"공기질센서버전\" value=\"" + getAirQualityInfo() + "\" />\r\n";
- }
- RetVal += " </setting>\r\n";
- } else {
- if (data.equals("beat_time")) {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- int heartbeatP = DBMGR.GetHeartbeatPeriod();
- DBMGR.closeDB();
- RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + heartbeatP + "\" />\r\n";
- } else if (data.equals("ver_setting")) {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + DBMGR.GetSettingVer() + "\" />\r\n";
- DBMGR.closeDB();
- } else if (data.equals("datetime")) {
- Calendar cal = new GregorianCalendar();
- 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";
- } else if (data.equals("security_state")) {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- int alarmST = DBMGR.GetAlarmStatus();
- String SEC_ST;
- if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
- else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
- else SEC_ST = "normal";
- RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"" + SEC_ST + "\" />\r\n";
- DBMGR.closeDB();
- } else if (data.equals("sensor_state")) {
- int senIDX = 0;
- String resultStr = "";
- WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
- int BugSensor = DBMGR.Get_Sensor_Set();
- WallPadInterface wpifc = new WallPadInterface();
- if (BugSensor > 0) {
- if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
- int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- String Senret;
- if (outSen > 0) Senret = "detect";
- else Senret = "undetect";
- resultStr += " <list name=\"in_move\" count=\"0\" value=\"" + Senret + "\" />\r\n";
- senIDX++;
- } else {
- if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
- int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- String Senret;
- if (outSen > 0) Senret = "detect";
- else Senret = "undetect";
- resultStr += " <list name=\"in_move\" value=\"" + Senret + "\" />\r\n";
- senIDX++;
- }
- if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
- int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- String Senret;
- if (outSen > 0) Senret = "detect";
- else Senret = "undetect";
- resultStr += " <list name=\"out_move\" value=\"" + Senret + "\" />\r\n";
- senIDX++;
- }
- }
- int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
- String Senret;
- if (outSen > 0) Senret = "detect";
- else Senret = "undetect";
- resultStr += " <list name=\"magnetic\" value=\"" + Senret + "\" />\r\n";
- senIDX++;
- int StatusVal = DBMGR.GetDeviceSetted("알람발생");
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
- if (outSen > 0) Senret = "detect";
- else Senret = "undetect";
- resultStr += " <list name=\"emergency\" value=\"" + Senret + "\" />\r\n";
- senIDX++;
- }
- DBMGR.closeDB();
- }
- if (senIDX > 0) {
- RetVal += " <setting name = \"sensor_state\" count = \"" + senIDX + "\" value = \"list\" >\r\n";
- RetVal += resultStr;
- RetVal += " </setting>\r\n";
- }
- } else if (data.equals("statusbeat_time")) {
- } else {
- RetVal += " <setting name=\"" + data + "\" count=\"0\" value=\"\" />\r\n";
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- SettManager.closeDB();
- RetVal += " </guidemap>\r\n </service>\r\n</imap>";
- return RetVal;
- }
- public void ProcElevatorinfo(Element ele) {
- try {
- String floor;
- String move_dir;
- /*
- NodeList evinfo = ele.getElementsByTagName("ev_count");
- imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
- Node info = evinfo.item(0);
- imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
- if (info != null)
- {
- elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
- }
- */
- NodeList ievinfo = ele.getElementsByTagName("ev_info");
- Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
- Node iinfo = ievinfo.item(0);
- if (iinfo == null) {
- Log.d("iMapServer", "func ProcElevatorinfo info == null");
- return;
- }
- floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
- // byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
- move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
- int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
- if (move_dir != null) {
- if (move_dir.equalsIgnoreCase("up")) {
- MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
- } else if (move_dir.equalsIgnoreCase("down")) {
- MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
- } else if (move_dir.equalsIgnoreCase("stop")) {
- MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
- } else if (move_dir.equalsIgnoreCase("wrong")) {
- MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
- } else if (move_dir.equalsIgnoreCase("finish")) {
- MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
- }
- Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
- }
- byte updown = 0x00;
- if (ievinfo != null) {
- boolean downCall = false;
- boolean upCall = false;
- for (int i = 0; i < ievinfo.getLength(); i++) {
- Node valItem = ievinfo.item(i);
- if (valItem != null) {
- if (downCall == false) {
- String val = GetAttributeVal(valItem, "ev_call_dir");
- if (val != null)
- downCall = val.equalsIgnoreCase("down");
- }
- if (upCall == false) {
- String val = GetAttributeVal(valItem, "ev_call_dir");
- if (val != null) {
- upCall = val.equalsIgnoreCase("up");
- }
- }
- }
- }
- Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
- if (downCall == true && upCall == true) updown = 0x02;
- else if (downCall == false && upCall == true) updown = 0x01;
- }
- Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
- intent.putExtra(define.NOTIBR_FLOOR, floor);
- intent.putExtra(define.NOTIBR_UPDOWN, updown);
- intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
- getApplicationContext().sendBroadcast(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private String MakeTargetStr(WallpadiCMDParser data) {
- return " <target name=\"" + data.target + "\" id = \"" + data.tid + "\" msg_no=\"" + data.msgno + "\"/>\r\n";
- }
- public String iCMDProcVentilControl(Document doc) {
- try {
- String unit_status = "null", mode = "null", unit_mode = "null";
- String retStr = CheckiCMDProc("remote_access_ventil");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_ventil\"";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = doc.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- boolean procSucc = true;
- WallpadiCMDParser ventilParser = new WallpadiCMDParser(doc);
- VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
- if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("control")) {
- if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
- if (ventilParser.ctraction.equalsIgnoreCase("on") || ventilParser.ctraction.equalsIgnoreCase("off")) {
- boolean OnOff = false;
- if (ventilParser.ctraction.equalsIgnoreCase("on")) OnOff = true;
- if (VentilCTR.SetOnOff(OnOff) == 0) procSucc = true;
- else procSucc = false;
- } else if (ventilParser.ctraction.equalsIgnoreCase("low") || ventilParser.ctraction.equalsIgnoreCase("mid") || ventilParser.ctraction.equalsIgnoreCase("high")) {
- byte strength = 0;
- if (ventilParser.ctraction.equalsIgnoreCase("low"))
- strength = VentiAPI.WIND.LOW;
- else if (ventilParser.ctraction.equalsIgnoreCase("mid"))
- strength = VentiAPI.WIND.MID;
- else strength = VentiAPI.WIND.HI;
- if (VentilCTR.data.OnOff) {
- // 환기가 On인 경우
- if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
- else procSucc = false;
- } else {
- // 환기가 Off인 경우
- if (VentilCTR.SetOnOff(true) >= 0) {
- if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
- else procSucc = false;
- } else {
- procSucc = false;
- }
- }
- }
- if (VentilCTR.Refresh(true) == 0) {
- if (VentilCTR.data.OnOff == false) unit_status = "off";
- else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
- else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
- else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
- else unit_status = "unknown";
- if (VentilCTR.data.Support.AutoDriving) {
- mode = "normal/auto";
- if (VentilCTR.data.AutoDriving) unit_mode = "auto";
- else unit_mode = "normal";
- } else {
- mode = "normal";
- unit_mode = "normal";
- }
- } else {
- procSucc = false;
- }
- } else {
- procSucc = false;
- }
- } else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
- if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
- if (VentilCTR.data.OnOff == false) unit_status = "off";
- else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
- else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
- else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
- else unit_status = "unknown";
- if (VentilCTR.data.Support.AutoDriving) {
- mode = "normal/auto";
- if (VentilCTR.data.AutoDriving) unit_mode = "auto";
- else unit_mode = "normal";
- } else {
- mode = "normal";
- unit_mode = "normal";
- }
- } else {
- procSucc = false;
- }
- } else {
- procSucc = false;
- }
- if (procSucc == false) {
- retStr += (" result=\"fail\" >\r\n");
- unit_status = "unknown";
- } else {
- retStr += (" result=\"ok\" >\r\n");
- }
- retStr += " <target name=\"" + ventilParser.target + "\" id=\"" + ventilParser.tid + "\" msg_no=\"" + ventilParser.msgno + "\"/>\r\n";
- retStr += " <action>\"" + trimquotation(ventilParser.actionTXT) + "\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + ventilParser.devnum + "\" unit_cnt=\"1\"/>\r\n";
- // retStr += " <status_info unit_num=\"ventil\" mode=\"" + mode + "\" unit_mode=\"" + unit_mode + "\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
- retStr += " <status_info unit_num=\"ventil\" unit_status=\"" + unit_status + "\" />\r\n </service>\r\n</imap>\r\n";
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcTemperControl(Document doc) {
- try {
- String retStr = CheckiCMDProc("remote_access_temper");
- if (retStr != null) return retStr;
- else
- retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = doc.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- WallpadiCMDParser tempercmd = new WallpadiCMDParser(doc);
- String[] RoomList = {"room1", "room2", "room3", "room4", "room5", "room6", "room7", "room8"};
- tempercmd.actionTXT = trimquotation(tempercmd.actionTXT);
- // 난방 종류를 얻어온다.
- int HeatingKind = mWallPadAPI.GetHeatingKind();
- HeatingV1API heatingV1API = null;
- HeatingV2API heatingV2API = null;
- // 종류별 API를 로딩한다.
- if (HeatingKind == 1) heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
- else if (HeatingKind == 2) heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
- Log.d(TAG, "&&&&&&&&&&& HeatingKind : " + HeatingKind + " , tempercmd.unitnum :" + tempercmd.unitnum);
- if (tempercmd.actionTXT.equals("control")) {
- String[] CtrList;
- byte ctrl = 0;
- byte roomNum = (byte) 0xFF;
- double temp = 0;
- if (tempercmd.unitnum.equals("all")) {
- if (tempercmd.ctraction.equals("on")) {
- ctrl = 1;
- } else if (tempercmd.ctraction.equals("off")) {
- ctrl = 0;
- } else {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\" />\r\n </service>\r\n</imap> ";
- return retStr;
- }
- } else {
- CtrList = tempercmd.ctraction.split("/");
- if (CtrList[0].equals("on")) ctrl = 1;
- else ctrl = 0;
- roomNum = (byte) 0xFF;
- temp = Double.parseDouble(CtrList[1]);
- }
- if (HeatingKind == 1) {
- boolean OnOff = false;
- if (ctrl == 1) OnOff = true;
- if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
- int ret = heatingV1API.SetAllRoomStatus(OnOff);
- if (ret != APIErrorCode.C_SUCCESS) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap> ";
- return retStr;
- }
- heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
- } else {
- for (byte i = 0; i < RoomList.length; i++) {
- if (tempercmd.unitnum.equals(RoomList[i])) {
- roomNum = i;
- break;
- }
- }
- if (roomNum == (byte) 0xFF) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (heatingV1API != null) {
- int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
- if (ret != APIErrorCode.C_SUCCESS) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- heatingV1API.Refresh(roomNum, false);
- }
- }
- } else if (HeatingKind == 2) {
- byte Mode = HeatingV2.MODE.HeatingOFF;
- if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
- if (tempercmd.unitnum.equals("all")) {
- if (heatingV2API != null) {
- int ret = heatingV2API.SetAllRoomStatus(Mode);
- if (ret != APIErrorCode.C_SUCCESS) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
- }
- } else {
- for (byte i = 0; i < RoomList.length; i++) {
- if (tempercmd.unitnum.equals(RoomList[i])) {
- roomNum = i;
- break;
- }
- }
- if (roomNum == (byte) 0xFF) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (heatingV2API != null) {
- int ret = heatingV2API.SetEachRoomStatus(roomNum, Mode, temp);
- if (ret != APIErrorCode.C_SUCCESS) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- heatingV2API.Refresh(roomNum, false);
- }
- }
- } else {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- }
- String resultStr = " <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n";
- if (HeatingKind == 1) {
- try {
- if (heatingV1API == null) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- byte RoomCount = heatingV1API.data.Device.RoomCount;
- resultStr += " <action>\"" + tempercmd.actionTXT + "\"</action>\r\n";
- resultStr += " <status_map dev_num=\"1\" unit_cnt=\"" + RoomCount + "\"/>\r\n";
- if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
- String drvmode = "off";
- for (byte i = 0; i < RoomCount; i++) {
- HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
- if (roomData.bOnOff) drvmode = "on";
- else drvmode = "off";
- drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
- resultStr += " <status_info unit_num=\"" + RoomList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
- }
- resultStr += " </service>\r\n</imap>\r\n";
- retStr += ("\"ok\">\r\n" + resultStr);
- return retStr;
- } else {
- String drvmode = "off";
- byte roomNum = (byte) 0xFF;
- for (byte i = 0; i < RoomList.length; i++) {
- if (tempercmd.unitnum.equals(RoomList[i])) {
- roomNum = i;
- break;
- }
- }
- if (roomNum == (byte) 0xFF) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
- if (roomData.bOnOff) drvmode = "on";
- else drvmode = "off";
- drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
- resultStr += " <status_info unit_num=\"" + RoomList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
- resultStr += " </service>\r\n</imap>\r\n";
- retStr += ("\"ok\">\r\n" + resultStr);
- return retStr;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- } else if (HeatingKind == 2) {
- try {
- if (heatingV2API == null) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- byte RoomCount = heatingV2API.data.Device.info.RoomCount;
- resultStr += " <action> \"" + tempercmd.actionTXT + "\"</action>\r\n";
- resultStr += " <status_map dev_num=\"1\" unit_cnt = \"" + RoomCount + "\" />\r\n";
- if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
- Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
- String drvmode = "off";
- for (byte i = 0; i < RoomCount; i++) {
- HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
- if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
- else drvmode = "off";
- drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
- if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- resultStr += " <status_info unit_num=\"" + RoomList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + mDefaultRoomNameList_Heating[i] + "\"/>\r\n";
- } else {
- resultStr += " <status_info unit_num=\"" + RoomList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
- }
- }
- resultStr += " </service>\r\n</imap>\r\n";
- retStr += ("\"ok\">\r\n" + resultStr);
- return retStr;
- } else {
- String drvmode = "off";
- byte roomNum = (byte) 0xFF;
- for (byte i = 0; i < RoomList.length; i++) {
- if (tempercmd.unitnum.equals(RoomList[i])) {
- roomNum = i;
- break;
- }
- }
- if (roomNum == (byte) 0xFF) {
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[roomNum];
- if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
- else drvmode = "off";
- drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
- resultStr += " <status_info unit_num=\"" + RoomList[roomNum] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
- resultStr += " </service>\r\n</imap>\r\n";
- retStr += ("\"ok\">\r\n" + resultStr);
- return retStr;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- } else {
- Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
- retStr += "\"fail\">\r\n <target name=\"" + tempercmd.target + "\" id=\"" + tempercmd.tid + "\" msg_no=\"" + tempercmd.msgno + "\"/>\r\n </service>\r\n</imap>";
- return retStr;
- }
- // retStr+="\"fail\">\r\n <target name = \""+tempercmd.target+"\" id = \""+tempercmd.tid+"\" msg_no = \""+tempercmd.msgno+"\" />\r\n </service>\r\n</imap>";
- // return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcDoorlockControl(Document doc) {
- try {
- String DLStatus = "none";
- String strResult = CheckiCMDProc("remote_access_doorlock");
- if (strResult != null) return strResult;
- else
- strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result =";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = doc.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, doc);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- WallpadiCMDParser doorlockcmd = new WallpadiCMDParser(doc);
- try {
- DLockAPI doorStatus = mWallPadAPI.Get_DLockController();
- if (doorStatus != null) {
- if (doorStatus.Refresh(false) != APIErrorCode.C_SUCCESS) {
- DLStatus = "unknown";
- } else {
- if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Close_LockingForce)
- DLStatus = "close";
- else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open || doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Open_LockingForce)
- DLStatus = "open";
- else if (doorStatus.data.DoorStatus == DLockAPI.DOORSTATUS.Operation)
- DLStatus = "ing";
- else DLStatus = "unknown";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- DLStatus = "unknown";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- DLStatus = "unknown";
- }
- String retXML = XMLHeader + " <service type=\"reply\" name=\"remote_access_doorlock\" result=\"ok\">\r\n" +
- " <target name=\"" + doorlockcmd.target + "\" id=\"" + doorlockcmd.tid + "\" msg_no=\"" + doorlockcmd.msgno + "\"/>\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"1\" unit_cnt=\"1\"/>\r\n" +
- " <status_info unit_num=\"doorlock1\" unit_status=\"" + DLStatus + "\"/>\r\n </service>\r\n</imap>";
- return retXML;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- /*
- protected String iCMDProcsavelog(Document doc)
- {
- String SucretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"ok\"/>\r\n</imap>";
- String FailretStr = XMLHeader+"<service type = \"reply\" name= \"remote_save_logfile\" result = \"false\"/>\r\n</imap>";
- NodeList items = doc.getElementsByTagName("guidemap");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for(int j=0; j< attrsParam.getLength();j++)
- {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("enable"))
- {
- String enable = attr.getNodeValue();
- if (enable == null) return FailretStr;
- if (enable.equals("false"))
- {
- WallpadLogData logSet = new WallpadLogData(getApplicationContext());
- logSet.SetLogDoing(0);
- logSet.closeDB();
- return SucretStr;
- }
- WallpadLogData logSet = new WallpadLogData(getApplicationContext());
- logSet.SetLogDoing(1);
- logSet.closeDB();
- }
- }
- items = doc.getElementsByTagName("setting");
- item = items.item(0);
- attrsParam = item.getAttributes();
- String SaveType = "";
- String FtpLoc = "";
- String Ftpuser = "";
- String FtpPW= "";
- String period = "";
- String FileSize = "";
- for(int j=0; j< attrsParam.getLength();j++)
- {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("save_type"))
- SaveType = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
- FtpLoc = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("user"))
- Ftpuser = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("passwd"))
- FtpPW = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("period"))
- period = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("filesize"))
- FileSize = attr.getNodeValue();
- }
- if (SaveType.equalsIgnoreCase("now"))
- {
- LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
- LogUpThread.start();
- return SucretStr;
- }
- else if (SaveType.equalsIgnoreCase("periodic"))
- {
- try
- {
- WallpadLogData logSet = new WallpadLogData(getApplicationContext());
- period = period.trim();
- String[] logperiod = period.split("[-]");
- String StartDate = logperiod[0].replace(".", "_");
- String EndDate = logperiod[1].replace(".", "_");
- logSet.SetLogDoing(1);
- logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
- if (FileSize.equalsIgnoreCase("null"))
- logSet.SetLogLogFileSize(0);
- else
- logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
- logSet.SetLogStartDate(StartDate);
- logSet.SetLogEndDate(EndDate);
- logSet.closeDB();
- return SucretStr;
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return FailretStr;
- }
- }
- else
- {
- return FailretStr;
- }
- }
- */
- protected void SendLogSaved(String ftploc, String fname, String size) {
- String SendMsg = XMLHeader + "<service type = \"notice\" name= \"saved_logfile\">\r\n" +
- " <device_info devtype=\"homedev\" id_high=\"" + AddrDong + "\" id_low=\"" + AddrHo + "\"/>\r\n" +
- " <file_info path=\"" + ftploc + "\" name=\"" + fname + "\" size=\"" + size + "\"/>\r\n</service>\r\n</imap>";
- SendToServer(SendMsg);
- }
- public final static int FTPLOGTRSUCC = 1110;
- public final static int FTPLOGTRFAIL = 1120;
- Handler FileTrHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case FTPLOGTRSUCC:
- String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
- File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
- int size = (int) (fileinfo.length() / 1024);
- SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
- imapsvrlog("FTPLOGTRSUCC");
- break;
- case FTPLOGTRFAIL:
- imapsvrlog("FTPLOGTRFAIL");
- break;
- }
- }
- };
- class LogUploader extends Thread {
- int fileidx = 0;
- boolean TRing = false;
- String FtpLoc;
- String FtpID;
- String FtpPasswd;
- class ftpuploader extends WallPadFTPUploader {
- String filename;
- public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
- super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
- filename = LocalFile;
- }
- protected void ProcUploadFail() {
- Message TrResult = FileTrHandler.obtainMessage();
- TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
- TrResult.what = FTPLOGTRFAIL;
- TRing = false;
- imapsvrlog("Send Log Fail Message");
- FileTrHandler.sendMessage(TrResult);
- }
- protected void ProcUploadSuccess() {
- Message TrResult = FileTrHandler.obtainMessage();
- TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
- TrResult.what = FTPLOGTRSUCC;
- TRing = false;
- imapsvrlog("Send Log success Message");
- FileTrHandler.sendMessage(TrResult);
- }
- }
- public LogUploader(String loc, String user, String pw) {
- FtpLoc = loc;
- FtpID = user;
- FtpPasswd = pw;
- }
- public void run() {
- File LogLoc = new File(define.LOG_FILE_LOCATION);
- String[] LogFileList = LogLoc.list();
- while (true) {
- if (TRing == false) {
- if (LogFileList != null && fileidx < LogFileList.length) {
- ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
- fileidx++;
- TRing = true;
- uploader.start();
- } else
- return;
- }
- try {
- Thread.sleep(500);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- }
- public String iCMDProcDevList(Document ele) {
- try {
- String strResult = CheckiCMDProc("remote_get_home_devices");
- if (strResult != null) return strResult;
- else
- strResult = XMLHeader + " <service type=\"reply\" name=\"remote_get_home_devices\" result=";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- GasAPI mGasAPI = null;
- CooktopAPI mCooktopAPI = null;
- if (mWallPadAPI.GetGasKind() == 1) {
- mGasAPI = mWallPadAPI.Get_GasController();
- } else if (mWallPadAPI.GetGasKind() == 2) {
- mCooktopAPI = mWallPadAPI.Get_CookTopController();
- }
- Log.i(TAG, "[iCMDProcDevList] bLightCMDUseAsSmartLight: " + bLightCMDUseAsSmartLight);
- WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
- String[] devlist = {"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
- strResult += "\"ok\">\r\n";
- strResult += " <target name=\"" + DevListCMD.target + "\" id=\"" + DevListCMD.tid + "\" msg_no=\"" + DevListCMD.msgno + "\"/>\r\n";
- strResult += " <devlist total_count=\"" + (devlist.length * 3 + 6) + "\"/>\r\n";
- //strResult += " <devlist total_count=\""+devlist.length+"\"/>\r\n";
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
- String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
- mWallpadDeviceSet.closeDB();
- String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
- String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
- String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
- strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
- strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
- strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
- for (int i = 0; i < devlist.length; i++) {
- if (devlist[i].equals("cooktop")) {
- if (mWallPadAPI.GetGasKind() == 1) {
- // 가스밸브
- int Gasinfo = devSet.Get_GAS_Info();
- if (Gasinfo == 1) {
- // 사용함
- if (bGasAsCooktopOutlet) {
- strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"cooktop\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"gas\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- // 사용안함
- strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } else if (mWallPadAPI.GetGasKind() == 2) {
- // 하이브리드 쿡탑
- if (mCooktopAPI != null) {
- int nGas = 0;
- int nOutlet = 0;
- for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
- for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
- if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
- nGas++;
- else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
- nOutlet++;
- }
- }
- strResult += " <devinfo name=\"gas\" value=\"" + nGas + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("doorlock")) {
- try {
- int[] DoorLockInfo = devSet.Get_DoorLock_Info();
- if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
- strResult += " <devinfo name=\"doorlock\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"doorlock\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("light")) {
- try {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdbAPI != null) {
- strResult += " <devinfo name=\"light\" value=\"" + mSdbAPI.data.BadRoom_Em_Count + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- Log.w(TAG, "[iCMDProcDevList] Not supported!!");
- }
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
- strResult += " <devinfo name=\"light\" value=\"" + energymeter.data.RoomCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- int[] lightinfo = devSet.Get_Light_info();
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
- strResult += " <devinfo name=\"light\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- int ret = multisw.Refresh((byte) 0xFF, false);
- if (ret < 0 || multisw.data.DeviceCnt < 1)
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- else
- strResult += " <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"light\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("livinglight")) {
- try {
- int[] lightinfo = devSet.Get_Light_info();
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdb_LivingRoomLightAPI != null) {
- strResult += " <devinfo name=\"livinglight\" value=\"" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- Log.w(TAG, "[iCMDProcDevList] Not supported!!");
- }
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"livinglight\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("ventil")) {
- try {
- int[] Ventilinfo = devSet.Get_Ventil_Info();
- if (Ventilinfo[0] == 0)
- strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- else
- strResult += " <devinfo name=\"ventil\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"ventil\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("thermostat")) {
- try {
- int Temperinfo = devSet.Get_Temper_Info();
- int HeatingKind = mWallPadAPI.GetHeatingKind();
- HeatingV1API heatingV1API = null;
- HeatingV2API heatingV2API = null;
- byte RoomCount = 0;
- // 종류별 API를 로딩한다.
- if (HeatingKind == 1) {
- heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
- if (heatingV1API != null) {
- RoomCount = heatingV1API.data.Device.RoomCount;
- }
- } else if (HeatingKind == 2) {
- heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
- if (heatingV2API != null) {
- RoomCount = heatingV2API.data.Device.info.RoomCount;
- }
- }
- if (Temperinfo == 0)
- strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
- else
- strResult += " <devinfo name=\"thermostat\" value=\"" + RoomCount + "\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"thermostat\" value=\"0\" order=\"" + strHeating + "\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("curtain")) {
- try {
- int[] Curtaininfo = devSet.Get_CURTAIN_Info();
- if (Curtaininfo[0] == 0)
- strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- else
- strResult += " <devinfo name=\"curtain\" value=\"1\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"curtain\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("electric")) {
- try {
- if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
- // 청담 콘센트 처리
- KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
- int BadConcentCount = 0;
- if (KnxApi != null) {
- int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
- if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
- BadConcentCount = 1;
- }
- int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
- for (int k = 0; k < BadConCount; k++) {
- if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
- BadConcentCount++;
- }
- Log.e(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
- strResult += " <devinfo name=\"electric\" value=\"" + BadConcentCount + "\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- int nOutlet = 0;
- if (mSdb_LivingRoomLightAPI != null) {
- if (mSdbAPI != null) {
- nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
- } else {
- nOutlet = 1;
- }
- } else {
- if (mSdbAPI != null) {
- nOutlet = mSdbAPI.data.BadRoom_Em_Count;
- } else {
- nOutlet = 0;
- }
- }
- strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"" + ho + "\"/>\r\n";
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
- strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- int[] lightinfo = devSet.Get_Light_info();
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
- } else {
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- int ret = multisw.Refresh((byte) 0xFF, false);
- if (ret < 0 || multisw.data.DeviceCnt < 1) {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
- } else {
- int DeviceCount = 0;
- for (int j = 0; j < multisw.data.DeviceCnt; j++) {
- if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
- DeviceCount++;
- }
- }
- strResult += " <devinfo name=\"electric\" value=\"" + DeviceCount + "\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- else if (devlist[i].equals("smartlight")) {
- if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
- // KNX 조명 처리
- try {
- KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
- if (KnxApi != null) {
- int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
- if (KnxApi.data == null)
- Log.e(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
- if (KnxApi.data.MasterController == null)
- Log.e(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
- if (ret >= 0) {
- int LivingLightCount = 0;
- if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
- Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
- } else {
- if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
- LivingLightCount = 1;
- }
- int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
- strResult += " <devinfo name=\"smartlight\" value=\"" + AllEMcount + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- } catch (Exception ek) {
- strResult += " <devinfo name=\"smartlight\" value=\"" + 0 + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- if (!bLightCMDUseAsSmartLight) {
- int nSmartLight = 0;
- if (mSdb_LivingRoomLightAPI != null) {
- if (mSdbAPI != null) {
- nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
- } else {
- nSmartLight = 1;
- }
- } else {
- if (mSdbAPI != null) {
- nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
- } else {
- nSmartLight = 0;
- }
- }
- strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" order=\"" + strLight + "\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- }
- else if (devlist[i].equals("sysaircon")) {
- // 에어컨 처리
- if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
- KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
- if (airconAPI != null) {
- int nCount = airconAPI.data.Device.info.InsideAirconCount;
- Log.e(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
- // 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
- strResult += " <devinfo name=\"sysaircon\" value=\"" + nCount + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
- } else {
- strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
- }
- } else {
- strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + ho + "\"/>\r\n";
- }
- }
- }
- //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
- strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + ho + "\"/>\r\n";
- if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
- strResult += remote_get_home_devices1;
- }
- if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
- strResult += remote_get_home_devices2;
- }
- if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
- strResult += remote_get_home_devices3;
- }
- /*
- for (int i = 0; i < devlist.length; i++) {
- if (devlist[i].equals("cooktop")) {
- if (mWallPadAPI.GetGasKind() == 1) {
- // 가스밸브
- int Gasinfo = devSet.Get_GAS_Info();
- if (Gasinfo == 1) {
- // 사용함
- if (bGasAsCooktopOutlet) {
- strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"1\" floor=\"2\"/>\r\n";
- }
- else {
- strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"2\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else {
- // 사용안함
- strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (mWallPadAPI.GetGasKind() == 2) {
- // 하이브리드 쿡탑
- if (mCooktopAPI != null) {
- int nGas = 0; int nOutlet = 0;
- for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
- for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
- if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
- else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
- }
- }
- strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"2\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
- }
- }
- else {
- strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"2\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("doorlock")) {
- try {
- int[] DoorLockInfo = devSet.Get_DoorLock_Info();
- if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
- strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"2\"/>\r\n";
- }
- else {
- strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("light")) {
- try {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdbAPI != null) {
- strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"2\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- Log.w(TAG, "[iCMDProcDevList] Not supported!!");
- }
- }
- else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
- strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"2\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else {
- int[] lightinfo = devSet.Get_Light_info();
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- }
- else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
- strResult += " <devinfo name=\"light\" value=\"1\" floor=\"2\"/>\r\n";
- }
- else {
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- int ret = multisw.Refresh((byte)0xFF, false);
- if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"2\"/>\r\n";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("livinglight")) {
- try {
- int[] lightinfo = devSet.Get_Light_info();
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdb_LivingRoomLightAPI != null) {
- strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"2\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
- Log.w(TAG, "[iCMDProcDevList] Not supported!!");
- }
- }
- else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
- }
- else {
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"2\"/>\r\n";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("ventil")) {
- try {
- int[] Ventilinfo = devSet.Get_Ventil_Info();
- if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
- else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"2\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("thermostat")) {
- try {
- int Temperinfo = devSet.Get_Temper_Info();
- int HeatingKind = mWallPadAPI.GetHeatingKind();
- HeatingV1API heatingV1API = null;
- HeatingV2API heatingV2API = null;
- byte RoomCount = 0;
- // 종류별 API를 로딩한다.
- if (HeatingKind == 1) {
- heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
- if (heatingV1API != null) {
- RoomCount = heatingV1API.data.Device.RoomCount;
- }
- }
- else if (HeatingKind == 2) {
- heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
- if (heatingV2API != null) {
- RoomCount = heatingV2API.data.Device.info.RoomCount;
- }
- }
- if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
- else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"2\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("curtain")) {
- try {
- int[] Curtaininfo = devSet.Get_CURTAIN_Info();
- if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
- else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"2\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("electric")) {
- try {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- int nOutlet = 0;
- if (mSdb_LivingRoomLightAPI != null) {
- if (mSdbAPI != null) {
- nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
- }
- else {
- nOutlet = 1;
- }
- }
- else {
- if (mSdbAPI != null) {
- nOutlet = mSdbAPI.data.BadRoom_Em_Count;
- }
- else {
- nOutlet = 0;
- }
- }
- strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"2\"/>\r\n";
- }
- else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
- strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"2\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else {
- int[] lightinfo = devSet.Get_Light_info();
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
- }
- else {
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- int ret = multisw.Refresh((byte)0xFF, false);
- if (ret< 0 || multisw.data.DeviceCnt < 1) {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
- }
- else {
- int DeviceCount = 0;
- for (int j = 0; j < multisw.data.DeviceCnt; j++) {
- if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
- DeviceCount++;
- }
- }
- strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"2\"/>\r\n";
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"2\"/>\r\n";
- }
- }
- else if (devlist[i].equals("smartlight")) {
- if (!bLightCMDUseAsSmartLight) {
- int nSmartLight = 0;
- if (mSdb_LivingRoomLightAPI != null) {
- if (mSdbAPI != null) {
- nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
- }
- else {
- nSmartLight = 1;
- }
- }
- else {
- if (mSdbAPI != null) {
- nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
- }
- else {
- nSmartLight = 0;
- }
- }
- strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"2\"/>\r\n";
- }
- }
- }
- for (int i = 0; i < devlist.length; i++) {
- if (devlist[i].equals("cooktop")) {
- if (mWallPadAPI.GetGasKind() == 1) {
- // 가스밸브
- int Gasinfo = devSet.Get_GAS_Info();
- if (Gasinfo == 1) {
- // 사용함
- if (bGasAsCooktopOutlet) {
- strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"1\"/>\r\n";
- }
- else {
- strResult +=" <devinfo name=\"gas\" value=\"1\" floor=\"3\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else {
- // 사용안함
- strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (mWallPadAPI.GetGasKind() == 2) {
- // 하이브리드 쿡탑
- if (mCooktopAPI != null) {
- int nGas = 0; int nOutlet = 0;
- for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
- for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
- if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
- else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
- }
- }
- strResult +=" <devinfo name=\"gas\" value=\"" + nGas + "\" floor=\"3\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
- }
- }
- else {
- strResult +=" <devinfo name=\"gas\" value=\"0\" floor=\"3\"/>\r\n";
- strResult +=" <devinfo name=\"cooktop\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("doorlock")) {
- try {
- int[] DoorLockInfo = devSet.Get_DoorLock_Info();
- if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
- strResult +=" <devinfo name=\"doorlock\" value=\"1\" floor=\"3\"/>\r\n";
- }
- else {
- strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"doorlock\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("light")) {
- try {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdbAPI != null) {
- strResult +=" <devinfo name=\"light\" value=\""+ mSdbAPI.data.BadRoom_Em_Count +"\" floor=\"3\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- Log.w(TAG, "[iCMDProcDevList] Not supported!!");
- }
- }
- else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
- strResult +=" <devinfo name=\"light\" value=\""+energymeter.data.RoomCnt+"\" floor=\"3\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else {
- int[] lightinfo = devSet.Get_Light_info();
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
- strResult += " <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- }
- else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
- strResult += " <devinfo name=\"light\" value=\"1\" floor=\"3\"/>\r\n";
- }
- else {
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- int ret = multisw.Refresh((byte)0xFF, false);
- if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- else strResult +=" <devinfo name=\"light\" value=\"" + multisw.data.DeviceCnt + "\" floor=\"3\"/>\r\n";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"light\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("livinglight")) {
- try {
- int[] lightinfo = devSet.Get_Light_info();
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdb_LivingRoomLightAPI != null) {
- strResult +=" <devinfo name=\"livinglight\" value=\""+ mSdb_LivingRoomLightAPI.data.Info.LightCount +"\" floor=\"3\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
- Log.w(TAG, "[iCMDProcDevList] Not supported!!");
- }
- }
- else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
- }
- else {
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
- strResult += " <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"livinglight\" value=\"" + lightinfo[2] + "\" floor=\"3\"/>\r\n";
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"livinglight\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("ventil")) {
- try {
- int[] Ventilinfo = devSet.Get_Ventil_Info();
- if (Ventilinfo[0] == 0) strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
- else strResult +=" <devinfo name=\"ventil\" value=\"1\" floor=\"3\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult +=" <devinfo name=\"ventil\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("thermostat")) {
- try {
- int Temperinfo = devSet.Get_Temper_Info();
- int HeatingKind = mWallPadAPI.GetHeatingKind();
- HeatingV1API heatingV1API = null;
- HeatingV2API heatingV2API = null;
- byte RoomCount = 0;
- // 종류별 API를 로딩한다.
- if (HeatingKind == 1) {
- heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
- if (heatingV1API != null) {
- RoomCount = heatingV1API.data.Device.RoomCount;
- }
- }
- else if (HeatingKind == 2) {
- heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
- if (heatingV2API != null) {
- RoomCount = heatingV2API.data.Device.info.RoomCount;
- }
- }
- if (Temperinfo == 0) strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
- else strResult +=" <devinfo name=\"thermostat\" value=\""+RoomCount+"\" floor=\"3\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"thermostat\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("curtain")) {
- try {
- int[] Curtaininfo = devSet.Get_CURTAIN_Info();
- if (Curtaininfo[0] == 0) strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
- else strResult += " <devinfo name=\"curtain\" value=\"1\" floor=\"3\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"curtain\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("electric")) {
- try {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- int nOutlet = 0;
- if (mSdb_LivingRoomLightAPI != null) {
- if (mSdbAPI != null) {
- nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
- }
- else {
- nOutlet = 1;
- }
- }
- else {
- if (mSdbAPI != null) {
- nOutlet = mSdbAPI.data.BadRoom_Em_Count;
- }
- else {
- nOutlet = 0;
- }
- }
- strResult += " <devinfo name=\"electric\" value=\"" + nOutlet + "\" floor=\"3\"/>\r\n";
- }
- else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
- strResult += " <devinfo name=\"electric\" value=\"" + energymeter.data.RoomCnt + "\" floor=\"3\"/>\r\n";
- }
- else {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else {
- int[] lightinfo = devSet.Get_Light_info();
- if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
- }
- else {
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- int ret = multisw.Refresh((byte)0xFF, false);
- if (ret< 0 || multisw.data.DeviceCnt < 1) {
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
- }
- else {
- int DeviceCount = 0;
- for (int j = 0; j < multisw.data.DeviceCnt; j++) {
- if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
- DeviceCount++;
- }
- }
- strResult += " <devinfo name=\"electric\" value=\""+DeviceCount+"\" floor=\"3\"/>\r\n";
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult += " <devinfo name=\"electric\" value=\"0\" floor=\"3\"/>\r\n";
- }
- }
- else if (devlist[i].equals("smartlight")) {
- if (!bLightCMDUseAsSmartLight) {
- int nSmartLight = 0;
- if (mSdb_LivingRoomLightAPI != null) {
- if (mSdbAPI != null) {
- nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
- }
- else {
- nSmartLight = 1;
- }
- }
- else {
- if (mSdbAPI != null) {
- nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
- }
- else {
- nSmartLight = 0;
- }
- }
- strResult += " <devinfo name=\"smartlight\" value=\"" + nSmartLight + "\" floor=\"3\"/>\r\n";
- }
- }
- }
- */
- strResult += " </service>\r\n</imap>\r\n";
- devSet.closeDB();
- return strResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcMultiSWControl(Document ele) {
- try {
- String retStr = CheckiCMDProc(MULTISW_CTR);
- if (retStr != null) return retStr;
- else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\"";
- WallpadiCMDParser multiswcmd = new WallpadiCMDParser(ele);
- MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
- if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("status")) {
- int devNum = Integer.parseInt(multiswcmd.devnum);
- if (multisw != null) {
- int ret = multisw.Refresh((byte) 0xFF, false);
- String result;
- if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) result = "ok";
- else result = "fail";
- retStr += (" result=\"" + result + "\" >\r\n");
- if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
- retStr += MakeTargetStr(multiswcmd);
- retStr += " <action>\"status\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
- if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
- 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";
- } else {
- retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[devNum - 1] + "\"/>\r\n";
- }
- } else {
- retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
- }
- String unitStr;
- for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
- Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
- //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
- //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
- unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
- unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
- }
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- } else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
- int devNum = Integer.parseInt(multiswcmd.devnum);
- int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
- {
- if (multisw != null) {
- multisw.Refresh((byte) 0xFF, false);
- String result;
- int ret = -1;
- if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
- ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
- } else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
- ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
- } else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
- ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
- } else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
- ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
- }
- if (ret == APIErrorCode.C_SUCCESS) result = "ok";
- else result = "fail";
- if (ret == APIErrorCode.C_SUCCESS) {
- ret = multisw.Refresh((byte) 0xFF, false);
- if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
- retStr += (" result=\"" + result + "\" > \r\n");
- retStr += MakeTargetStr(multiswcmd);
- retStr += " <action>\"control\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + multiswcmd.devnum + "\" unit_cnt=\"" + multisw.data.Device[devNum - 1].device.hOutletCnt + "\"/>\r\n";
- String unitStr;
- for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
- //unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
- //unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
- unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
- unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\" />\r\n";
- }
- } else {
- retStr += (" result=\"fail\"> \r\n");
- }
- } else {
- retStr += (" result=\"fail\"> \r\n");
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- }
- }
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcSDPConcentControl(Document ele) {
- try {
- WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
- String retStr = CheckiCMDProc("remote_access_electric");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_electric\"";
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, concentcmd.target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- if (mSdbAPI == null) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
- return retStr;
- }
- if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- int nTotalLightCnt = 0;
- if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
- nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
- } else {
- nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
- }
- Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
- int nDevNo = 0;
- try {
- nDevNo = Integer.parseInt(concentcmd.devnum);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (nDevNo < 1 && 12 < nDevNo) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
- return retStr;
- }
- String strAction = trimquotation(concentcmd.actionTXT);
- String unit_status = "null", status_mode = "unset", status_onoff = "off";
- String dev_num = "null", unit_num = "null", ctrl_action = "null";
- int nRet_Mode = -99, nRet_OnOff = -99;
- boolean Set = false, OnOff = false; // 제어요청 상태
- boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
- if (strAction.equalsIgnoreCase("status")) {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + strAction + "\"</action>\r\n";
- if (nDevNo == 1) {
- if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\" room_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\"/>\r\n";
- } else {
- retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
- }
- for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
- if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
- status_mode = "unset";
- else status_mode = "set";
- if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
- status_onoff = "on";
- else status_onoff = "off";
- unit_status = status_mode + "/" + status_onoff;
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
- }
- // retStr += " </status_map>\r\n";
- retStr += " </service>\r\n</imap>\r\n";
- } else if (nDevNo > 1) {
- if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- 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";
- } else {
- retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
- }
- for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
- status_mode = "unset";
- else status_mode = "set";
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
- status_onoff = "on";
- else status_onoff = "off";
- unit_status = status_mode + "/" + status_onoff;
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
- }
- // retStr += " </status_map>\r\n";
- retStr += " </service>\r\n</imap>\r\n";
- }
- } else if (strAction.equalsIgnoreCase("control")) {
- NodeList items = ele.getElementsByTagName("params");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attr = attrs.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dev_num"))
- dev_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
- unit_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
- ctrl_action = attr.getNodeValue();
- }
- } else {
- Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- try {
- nDevNo = Integer.parseInt(dev_num);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (nDevNo < 1 && 12 < nDevNo) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- int nUnitNo = 0;
- if (!unit_num.equalsIgnoreCase("all")) {
- try {
- nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- }
- if (ctrl_action.contains("/")) {
- String[] strParsed = ctrl_action.split("/");
- if (strParsed[0].equals("set")) {
- Set = true;
- bCtrl_Set = true;
- } else if (strParsed[0].equals("unset")) {
- Set = false;
- bCtrl_Set = true;
- }
- if (strParsed[1].equals("on")) {
- OnOff = true;
- bCtrl_OnOff = true;
- } else if (strParsed[1].equals("off")) {
- OnOff = false;
- bCtrl_OnOff = true;
- }
- } else {
- if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
- if (ctrl_action.equalsIgnoreCase("set")) {
- Set = true;
- bCtrl_Set = true;
- } else if (ctrl_action.equalsIgnoreCase("unset")) {
- Set = false;
- bCtrl_Set = true;
- }
- }
- if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
- if (ctrl_action.equalsIgnoreCase("on")) {
- OnOff = true;
- bCtrl_OnOff = true;
- } else if (ctrl_action.equalsIgnoreCase("off")) {
- OnOff = false;
- bCtrl_OnOff = true;
- }
- }
- }
- Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
- if (nDevNo == 1) {
- if (unit_num.equalsIgnoreCase("all")) {
- for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
- if (bCtrl_Set)
- nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
- if (bCtrl_OnOff)
- nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
- Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
- if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- }
- } else {
- if (bCtrl_Set)
- nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
- if (bCtrl_OnOff)
- nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
- Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
- if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- }
- } else {
- if (unit_num.equalsIgnoreCase("all")) {
- for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
- if (bCtrl_Set)
- nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
- if (bCtrl_OnOff)
- nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
- Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
- if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- }
- } else {
- if (bCtrl_Set)
- nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
- if (bCtrl_OnOff)
- nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
- Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
- if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- }
- }
- if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + concentcmd.target + "\" id=\"" + concentcmd.tid + "\" msg_no=\"" + concentcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + strAction + "\"</action>\r\n";
- if (nDevNo == 1) {
- retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "\"/>\r\n";
- for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
- if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
- status_mode = "unset";
- else status_mode = "set";
- if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
- status_onoff = "on";
- else status_onoff = "off";
- unit_status = status_mode + "/" + status_onoff;
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
- }
- // retStr += " </status_map>\r\n";
- retStr += " </service>\r\n</imap>\r\n";
- } else if (nDevNo > 1) {
- retStr += " <status_map dev_num=\"" + concentcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount + "\"/>\r\n";
- for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
- status_mode = "unset";
- else status_mode = "set";
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
- status_onoff = "on";
- else status_onoff = "off";
- unit_status = status_mode + "/" + status_onoff;
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unit_status + "\"/>\r\n";
- }
- // retStr += " </status_map>\r\n";
- retStr += " </service>\r\n</imap>\r\n";
- }
- } else {
- Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
- retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
- }
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcEnergyMeterConcentControl(Document ele) {
- try {
- String retStr = CheckiCMDProc(MULTISW_CTR);
- if (retStr != null) return retStr;
- else retStr = XMLHeader + " <service type=\"reply\" name=\"" + MULTISW_CTR + "\" ";
- WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if (energymetercmd == null) return null;
- if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
- if (energymeter == null) return null;
- int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
- int ret = energymeter.Refresh((byte) 0xFF, false);
- String result;
- if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) result = "ok";
- else result = "fail";
- retStr += (" result=\"" + result + "\" >\r\n");
- if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
- retStr += MakeTargetStr(energymetercmd);
- retStr += " <action>\"status\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
- String unitStr;
- for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
- unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
- if (i == 2) {
- unitStr += "on";
- } else {
- unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
- }
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
- }
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
- int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
- int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
- byte cmd = 0;
- int ret = 0;
- String result;
- if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
- else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
- else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
- else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
- if (cmd > 0) {
- if (energymeter != null) {
- energymeter.Refresh((byte) 0xFF, false);
- if (cmd == 1) {
- ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
- } else if (cmd == 2) {
- ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
- } else if (cmd == 3) {
- ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
- } else if (cmd == 4) {
- ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
- }
- if (ret == APIErrorCode.C_SUCCESS) result = "ok";
- else result = "fail";
- retStr += (" result=\"" + result + "\" >\r\n");
- if (ret == APIErrorCode.C_SUCCESS) {
- ret = energymeter.Refresh((byte) 0xFF, false);
- if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
- retStr += MakeTargetStr(energymetercmd);
- retStr += " <action>\"control\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[devNum].ConCnt + "\"/>\r\n";
- String unitStr;
- for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
- unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
- if (i == 2) {
- unitStr += "on";
- } else {
- unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
- }
- retStr += " <status_info unit_num=\"switch" + (i + 1) + "\" unit_status=\"" + unitStr + "\"/>\r\n";
- }
- } else {
- retStr += (" result=\"fail\"> \r\n");
- }
- } else {
- retStr += (" result=\"fail\"> \r\n");
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- }
- }
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcModeControl(Document doc) {
- try {
- String status = "unknown";
- boolean SendBR = false;
- String retStr = CheckiCMDProc("remote_access_mode");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + "<service type=\"reply\" name=\"remote_access_mode\" result=";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = doc.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, doc);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- WallpadiCMDParser accmode = new WallpadiCMDParser(doc);
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- int curState = SetData.GetAlarmStatus();
- Log.i(TAG, "[iCMDProcModeControl] curState = " + curState);
- if (trimquotation(accmode.actionTXT).equalsIgnoreCase("control")) {
- if (accmode.ctraction.equalsIgnoreCase("normal")) {
- switch (curState) {
- case WallpadStatusData.GUARD_IN:
- SetData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.ALARM_NONE);
- getApplicationContext().sendBroadcast(intent);
- Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
- SendBR = true;
- break;
- case WallpadStatusData.GUARD_OUT:
- break;
- }
- } else if (accmode.ctraction.equalsIgnoreCase("occupied")) {
- switch (curState) {
- case WallpadStatusData.ALARM_NONE:
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- if (mIGW200.checkSensorforInmode()) {
- SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
- getApplicationContext().sendBroadcast(intent);
- SendBR = true;
- } else {
- SendBR = false;
- }
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (mIGW300.checkSensorforInmode()) {
- SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
- getApplicationContext().sendBroadcast(intent);
- SendBR = true;
- } else {
- SendBR = false;
- }
- } else {
- if (checkSensorforInmode()) {
- SetData.SetAlarmStatus(WallpadStatusData.GUARD_IN);
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.GUARD_IN);
- getApplicationContext().sendBroadcast(intent);
- Sound().PlayMent(SND.mode.INMODE_SETTING);
- SendBR = true;
- } else {
- SendBR = false;
- }
- }
- break;
- default:
- break;
- }
- } else if (accmode.ctraction.equalsIgnoreCase("unoccupied")) {
- if (GetUseIlgalControlForAdmin() == false) {
- // 관리자용 일괄소등 원격제어 사용안할 시
- switch (curState) {
- case WallpadStatusData.ALARM_NONE:
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- if (mIGW200.checkSensorforOutmode()) {
- Common.SendAppFinishReqBR(getApplicationContext());
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
- getApplicationContext().sendBroadcast(intent);
- SendBR = true;
- } else {
- SendBR = false;
- }
- } else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (mIGW300.checkSensorforOutmode()) {
- Common.SendAppFinishReqBR(getApplicationContext());
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
- getApplicationContext().sendBroadcast(intent);
- SendBR = true;
- } else {
- SendBR = false;
- }
- } else {
- if (checkSensorforOutmode()) {
- Common.SendAppFinishReqBR(getApplicationContext());
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARMSTAUSCHANGED);
- intent.putExtra("ITEM", WallpadStatusData.GUARD_OUT);
- getApplicationContext().sendBroadcast(intent);
- Sound().PlayMent(SND.mode.OUTMODE_SETTING);
- SendBR = true;
- } else {
- SendBR = false;
- }
- }
- break;
- default:
- break;
- }
- } else {
- // 관리자용 일괄소등 원격제어 사용 시
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
- SendBR = true;
- }
- }
- } else if (trimquotation(accmode.actionTXT).equalsIgnoreCase("status")) {
- int getStatus = SetData.GetAlarmStatus();
- switch (getStatus) {
- case WallpadStatusData.GUARD_IN:
- status = "occupied";
- break;
- case WallpadStatusData.GUARD_OUT:
- status = "unoccupied";
- break;
- case WallpadStatusData.ALARM_NONE:
- status = "normal";
- break;
- case WallpadStatusData.ALARM_ARISE:
- status = "emergency";
- break;
- default:
- break;
- }
- retStr += ("\"ok\">\r\n ");
- retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no=\"" + accmode.msgno + "\"/>\r\n";
- retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt=\"1\"/>\r\n";
- retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
- return retStr;
- }
- if (!SendBR) {
- retStr += "\"fail\">\r\n </service>\r\n</imap>";
- SetData.closeDB();
- return retStr;
- } else {
- try {
- Thread.sleep(1000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- int getStatus = SetData.GetAlarmStatus();
- switch (getStatus) {
- case WallpadStatusData.GUARD_IN:
- status = "occupied";
- break;
- case WallpadStatusData.GUARD_OUT:
- status = "unoccupied";
- break;
- case WallpadStatusData.ALARM_NONE:
- status = "normal";
- break;
- case WallpadStatusData.ALARM_ARISE:
- status = "emergency";
- break;
- }
- }
- retStr += "\"ok\">\r\n";
- retStr += " <target name=\"" + accmode.target + "\" id=\"" + accmode.tid + "\" msg_no = \"" + accmode.msgno + "\" />\r\n";
- retStr += " <action>\"" + trimquotation(accmode.actionTXT) + "\"</action>\r\n";
- retStr += " <status_map dev_num=\"" + 1 + "\" unit_cnt = \"1\"/>\r\n";
- retStr += " <status_info unit_num=\"null\" unit_status=\"" + status + "\" />\r\n </service>\r\n</imap>\r\n";
- SetData.closeDB();
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcCurtainControl(Document ele) {
- return " ";
- }
- public String iCMDProcSDPLightControl(Document ele) {
- try {
- String retStr = CheckiCMDProc("remote_access_light");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if (energymetercmd == null) return null;
- if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
- int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
- if (energymeter == null) return null;
- if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
- for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
- 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");
- }
- retStr += "\r\n</service>\r\n</imap>";
- } else {
- retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
- }
- } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
- int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
- num--;
- int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
- if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
- if (energymeter == null) return null;
- if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
- if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"control\"</action>\r\n" +
- " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
- for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
- 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");
- }
- retStr += "\r\n</service>\r\n</imap>";
- } else {
- retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
- }
- } else {
- retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
- }
- } else {
- retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
- }
- energymetercmd = null;
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcEnergyMeterLightControl(Document ele) {
- try {
- String retStr = CheckiCMDProc("remote_access_light");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + "<service type = \"reply\" name= \"remote_access_light\" ";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- WallpadiCMDParser energymetercmd = new WallpadiCMDParser(ele);
- EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
- if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("status")) {
- int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
- if (energymeter != null && (energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
- for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
- 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");
- }
- retStr += "\r\n</service>\r\n</imap>";
- } else {
- retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
- }
- } else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
- int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
- num--;
- int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
- if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
- if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
- if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"control\"</action>\r\n" +
- " <status_map dev_num=\"" + energymetercmd.devnum + "\" unit_cnt=\"" + energymeter.data.Em.eachRoom[deviceNum].LightCnt + "\"/>\r\n";
- for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
- 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");
- }
- retStr += "\r\n</service>\r\n</imap>";
- } else {
- retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
- }
- } else {
- retStr += "result=\"fail\">\r\n</service>\r\n</imap> ";
- }
- } else {
- retStr += "result = \"fail\">\r\n</service>\r\n</imap>";
- }
- energymetercmd = null;
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcLightControl(Document ele) {
- try {
- String retStr = CheckiCMDProc("remote_access_light");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_light\" ";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- WallpadiCMDParser MSlightcmd = new WallpadiCMDParser(ele);
- MultiSwitchAPI mMultiSwitchAPI = mWallPadAPI.Get_MultiSwitchController();
- if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("status")) {
- int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
- if (bLightCMDUseAsSmartLight) {
- if (mSdbAPI != null) {
- int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
- Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
- if (mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount > 0) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n";
- if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum + 1] + "\"/>\r\n";
- } else {
- retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
- }
- for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- if (mMultiSwitchAPI != null) {
- int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
- if (nResult == 0) {
- if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n";
- if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
- retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light_HS[deviceNum] + "\"/>\r\n";
- } else {
- retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\" room_name=\"" + mDefaultRoomNameList_Light[deviceNum] + "\"/>\r\n";
- }
- } else {
- retStr += " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
- }
- for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- }
- } else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
- int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
- boolean OnOff = false;
- if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
- if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdbAPI != null) {
- if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
- int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
- if (ret >= 0) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
- int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
- Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
- for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
- int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
- if (ret >= 0) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount + "\"/>\r\n";
- int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
- Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
- for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
- Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
- 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");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- }
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
- if (mMultiSwitchAPI != null) {
- int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
- if (nResultRefresh == 0) {
- int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
- if (nCtrlResult == 0) {
- int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
- if (nResult == 0) {
- if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
- for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
- 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");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- }
- } else {
- int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
- if (mMultiSwitchAPI != null) {
- int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
- if (nCtrlResult == 0) {
- int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
- if (nResult == 0) {
- if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
- retStr += "result=\"ok\">\r\n" +
- " <action>\"status\"</action>\r\n" +
- " <status_map dev_num=\"" + MSlightcmd.devnum + "\" unit_cnt=\"" + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt + "\"/>\r\n";
- for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- }
- }
- }
- } else {
- retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- retStr += "result = \"fail\">\r\n </service>\r\n</imap> ";
- }
- MSlightcmd = null;
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcSDPSmartLightControl(Document ele) {
- try {
- WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
- String retStr = CheckiCMDProc("remote_access_smartlight");
- if (retStr != null) return retStr;
- else
- retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- if (mSdb_LivingRoomLightAPI == null) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
- return retStr;
- }
- if (mSdbAPI == null) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
- return retStr;
- }
- if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
- return retStr;
- }
- for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
- if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- }
- int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
- if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
- if (lightcmd.devnum.equalsIgnoreCase("all")) {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
- for (int i = 0; i < nTotalLightCnt; i++) {
- if (i == 0) {
- 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";
- for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- } else {
- 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";
- for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- int nDevNo = 0;
- try {
- nDevNo = Integer.parseInt(lightcmd.devnum);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if ((nDevNo - 1) > nTotalLightCnt) {
- Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"status\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- if (nDevNo == 1) {
- 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";
- for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- } else {
- 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";
- for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
- int nResult = -99;
- String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
- NodeList items = ele.getElementsByTagName("params");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dev_num"))
- dev_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
- dev_mode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
- unit_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
- unit_status = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
- unit_dimming = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
- unit_color = attr.getNodeValue();
- }
- }
- if (dev_num.equalsIgnoreCase("all")) {
- nResult = 0;
- for (int i = 0; i < nTotalLightCnt; i++) {
- if (i == 0) {
- nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
- unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
- unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
- } else {
- nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
- unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
- unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
- }
- }
- if (nResult != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
- return retStr;
- } else {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"" + nTotalLightCnt + "\"</dev_cnt>\r\n";
- }
- if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
- return retStr;
- }
- if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- for (int i = 0; i < nTotalLightCnt; i++) {
- if (i == 0) {
- 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";
- for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- } else {
- 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";
- for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- int nDevNo = 0;
- int nUnitNo = 0;
- try {
- nDevNo = Integer.parseInt(dev_num);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if ((nDevNo - 1) > nTotalLightCnt) {
- Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- nResult = -99;
- if (unit_num.equalsIgnoreCase("all")) {
- if (nDevNo == 1) {
- nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
- unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
- unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
- } else {
- nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
- unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
- unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
- }
- if (nResult != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
- return retStr;
- }
- } else {
- try {
- nUnitNo = Integer.parseInt(unit_num);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- nResult = -99;
- if (nDevNo == 1) {
- nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
- unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
- unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
- } else {
- nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
- unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
- unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
- }
- if (nResult != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
- return retStr;
- }
- }
- if (nDevNo == 1) {
- if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
- return retStr;
- } else {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- }
- 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";
- for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- } else {
- int nRealDevNo = (byte) (nDevNo - 2);
- if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- } else {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- }
- retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\"null\" dev_name=\"" + mDefaultRoomNameList_Light[nDevNo - 1] + "\" unit_cnt=\"" + mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount + "\">\r\n";
- for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
- int nResult = 0;
- String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
- NodeList items = ele.getElementsByTagName("params");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dev_num"))
- dev_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
- dev_mode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
- unit_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
- unit_status = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
- unit_dimming = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
- unit_color = attr.getNodeValue();
- }
- }
- if (dev_num.equalsIgnoreCase("all")) {
- if (!dev_mode.equals("null")) {
- nResult = -99;
- nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
- if (nResult != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
- return retStr;
- } else {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- }
- 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";
- // 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
- retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
- } else {
- int nDevNo = 0;
- try {
- nDevNo = Integer.parseInt(dev_num);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (nDevNo != 1) {
- Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (!dev_mode.equals("null")) {
- nResult = -99;
- nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
- if (nResult != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
- return retStr;
- } else {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- }
- 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";
- for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
- status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
- } else {
- status_power = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
- status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
- } else {
- status_dim = "null";
- }
- if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
- status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
- } else {
- status_color = "null";
- }
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n </service>\r\n</imap>\r\n";
- }
- } else {
- retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
- }
- lightcmd = null;
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
- byte type = 0;
- //각 스위치 개수는 4개임
- switch (lightIndex) {
- case 0:
- type = benEm.Info.LightType_1;
- break;
- case 1:
- type = benEm.Info.LightType_2;
- break;
- case 2:
- type = benEm.Info.LightType_3;
- break;
- case 3:
- type = benEm.Info.LightType_4;
- break;
- default:
- break;
- }
- return type;
- }
- public String iCMDProcChumDamSmartLightControl(Document ele) {
- try {
- WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
- String retStr = CheckiCMDProc("remote_access_smartlight");
- if (retStr != null) return retStr;
- else retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_smartlight\"";
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, lightcmd.target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
- }
- KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
- if (KnxApi == null) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
- return retStr;
- }
- if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- int LivingLightCount = 0;
- if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
- Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
- } else {
- if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
- LivingLightCount = 1;
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- //기준층 명칭
- String[] mDefaultRoomNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
- "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
- String[] mEtypeRoomNameList = new String[]{"거실", "침실1", "침실2", "침실3", "식당", "주방", "드레스룸1",
- "서재", "다용도실", "메이드룸","욕실1","파우더룸","간이주방","테라스계단","오픈라운지","스위치1","스위치2","스위치3","스위치4","스위치5","스위치6","스위치7","스위치8"};
- String [] knxRoomNameList = null;
- // 기준층 A, B, C 타입과 D타입 2003호 , E타입 2001호 구분하여 처리
- if(Integer.parseInt(addc.Ho) == 2001 || Integer.parseInt(addc.Ho) == 2003)
- {
- knxRoomNameList = mEtypeRoomNameList;
- Log.e(TAG, "yskim[iCMDProcChumDamSmartLightControl] mEtypeRoomNameList");
- }
- else
- {
- knxRoomNameList = mDefaultRoomNameList;
- Log.e(TAG, "yskim[iCMDProcChumDamSmartLightControl] mDefaultRoomNameList");
- }
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- String[] strValue = devSet.GetSettingData("KNX명칭");
- devSet.closeDB();
- // 현대건설 더 펜트하우스 서버에서 설정된 명칭이 있다면 그 명칭을 사용하도록 한다.
- if( strValue != null ) {
- String strLight = strValue[1].substring( (strValue[1].indexOf("조명(") + 3) , (strValue[1].indexOf(")난방(")));
- String strHeating = strValue[1].substring( (strValue[1].indexOf("난방(") + 3) , (strValue[1].indexOf(")에어컨(")));
- String strAircon = strValue[1].substring( (strValue[1].indexOf("에어컨(") + 4) , (strValue[1].indexOf("))")));
- // DebugLogOutput("[Create] - room name strlight " + strLight);
- // DebugLogOutput("[Create] - room name strHeating " + strHeating);
- // DebugLogOutput("[Create] - room name strAircon " + strAircon);
- if( strLight != null)knxRoomNameList = strLight.split("_");
- }
- int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
- int totalLightCount = LivingLightCount + BadLightCount;
- //mData.MasterController.Info.Light_SwitchCount
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
- if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
- {
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
- if (lightcmd.devnum.equalsIgnoreCase("all")) {
- for (int i = 0; i < totalLightCount; i++) {
- if (i == 0) {
- retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
- status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
- status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- } else {
- retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff);
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming);
- status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
- if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
- status_dim ="null";
- // zzz
- //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- }
- }
- else
- {
- int nResult = 0;
- String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
- NodeList items = ele.getElementsByTagName("params");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j< attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
- }
- }
- int nDevNo = Integer.parseInt(dev_num);
- if (nDevNo == 1) {
- retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"" + "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
- status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
- status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- } else {
- retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff : " + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Info.Support.OnOff);
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming : " + KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Info.Support.Dimming);
- status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
- // zzz
- //Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) );
- if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
- status_dim ="null";
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
- int nResult = 0;
- String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
- NodeList items = ele.getElementsByTagName("params");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j< attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
- }
- }
- if (dev_num.equalsIgnoreCase("ALL")) {
- // 일괄소등 실행/해제
- if (!unit_status.equalsIgnoreCase("null")) {
- KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
- }
- if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"" + totalLightCount + "\"</dev_cnt>\r\n";
- for (int i = 0; i < totalLightCount; i++) {
- if (i == 0) {
- retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\""+ "null" + "\" dev_name=\""+ knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
- status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
- status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- else {
- retStr += " <status_map dev_num=\""+ (i + 1) + "\" dev_mode=\"null\" dev_name=\""+ knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.OnOff);
- Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming : " + KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Info.Support.Dimming);
- status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
- if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
- status_dim ="null";
- retStr += " <status_info unit_num=\"" + (j + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + status_color + "\"/>\r\n";
- }
- retStr += " </status_map>\r\n";
- }
- }
- retStr += " </service>\r\n</imap>\r\n";
- }
- else {
- int nDevNo = 0;
- int nUnitNo = 0;
- try {
- nDevNo = Integer.parseInt(dev_num);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
- e.printStackTrace();
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if ((nDevNo - 1) > totalLightCount) {
- Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- // retStr += " result=\"ok\">\r\n";
- // retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- // retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- // retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- if (unit_num.equalsIgnoreCase("all")) {
- if (nDevNo == 1) {
- // 거실 조명 일괄제어일 경우
- if (!unit_status.equalsIgnoreCase("null")) {
- int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
- //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
- }
- if (!unit_dimming.equalsIgnoreCase("null")) {
- KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
- }
- if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
- for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
- String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
- String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
- retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
- }
- }
- else {
- // 각각 EM 조명 일괄제어일 경우
- if (!unit_status.equalsIgnoreCase("null")) {
- KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
- //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
- }
- if (!unit_dimming.equalsIgnoreCase("null")) {
- Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : ");
- if( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_2 == 0x0F
- || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_3 == 0x0F || KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_4 == 0x0F)
- {
- Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] ==> Fan : " + nDevNo );
- for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
- // 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
- int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
- Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
- }
- }
- else {
- int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
- Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
- }
- //KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
- }
- if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.e(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
- nDevNo = Integer.parseInt(dev_num);
- for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
- //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
- String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
- String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
- if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
- status_dim ="null";
- retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
- }
- }
- // retStr += " </status_map>\r\n";
- // retStr += " </service>\r\n</imap>\r\n";
- }
- else {
- // 회로별 제어일경우
- try {
- nUnitNo = Integer.parseInt(unit_num);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
- e.printStackTrace();
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (nDevNo == 1) {
- if (!unit_status.equalsIgnoreCase("null")) {
- int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
- //mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
- }
- if (!unit_dimming.equalsIgnoreCase("null")) {
- KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
- //mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
- }
- if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[0] + "\" unit_cnt=\"" + KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount + "\">\r\n";
- nDevNo = Integer.parseInt(dev_num);
- for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
- String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
- String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
- retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
- }
- }
- else {
- if (!unit_status.equalsIgnoreCase("null")) {
- KnxApi.SetLightOnOff((byte) (nDevNo -2), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
- //mSdbAPI.SetLightOnOff((byte) (nDevNo -2), (byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
- //회로별 제어는 On/Off 만 가능함
- }
- if (!unit_dimming.equalsIgnoreCase("null")) {
- KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)(nUnitNo-1),(byte) Integer.parseInt(unit_dimming));
- //일괄제어라 회로별 제어기능은 없음
- // 시험 2021.05.12
- }
- if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
- return retStr;
- }
- retStr += " result=\"ok\">\r\n";
- retStr += " <target name=\"" + lightcmd.target + "\" id=\"" + lightcmd.tid + "\" msg_no=\"" + lightcmd.msgno + "\"/>\r\n";
- retStr += " <action>\"" + lightcmd.actionTXT + "\"</action>\r\n";
- retStr += " <dev_cnt>\"1\"</dev_cnt>\r\n";
- retStr += " <status_map dev_num=\"" + nDevNo + "\" dev_mode=\""+ "null" + "\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount + "\">\r\n";
- nDevNo = Integer.parseInt(dev_num);
- for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
- String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
- String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
- if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
- status_dim ="null";
- retStr += " <status_info unit_num=\"" + (i + 1) + "\" unit_status=\"" + status_power + "\" unit_dimming=\"" + status_dim + "\" unit_color=\"" + "null" + "\"/>\r\n";
- }
- }
- }
- retStr += " </status_map>\r\n";
- retStr += " </service>\r\n</imap>\r\n";
- }
- }
- else {
- retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
- }
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
- e.printStackTrace();
- return null;
- }
- }
- public String iCMDProcLivingLightControl(Document ele) {
- try {
- WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
- String retStr = CheckiCMDProc("remote_access_livinglight");
- if (retStr != null) return retStr;
- else
- retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_livinglight\"";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
- if (bLightCMDUseAsSmartLight) {
- if (mSdb_LivingRoomLightAPI != null) {
- mSdb_LivingRoomLightAPI.Refresh();
- 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";
- for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else {
- LightAPI lightCTR = mWallPadAPI.Get_LightController();
- if (lightCTR != null) {
- if (lightCTR.Refresh(false) == 0) {
- retStr += " result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
- for (int i = 0; i < lightCTR.data.LightCount; i++) {
- retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- }
- }
- } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
- if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
- boolean OnOff = false;
- if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
- if (bLightCMDUseAsSmartLight) {
- if (lightcmd.unitnum.equalsIgnoreCase("all")) {
- int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
- if (ret >= 0) {
- ret = mSdb_LivingRoomLightAPI.Refresh();
- if (ret >= 0) {
- 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";
- for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
- int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
- if (ret >= 0) {
- ret = mSdb_LivingRoomLightAPI.Refresh();
- if (ret >= 0) {
- 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";
- for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
- 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");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- }
- } else {
- LightAPI lightCTR = mWallPadAPI.Get_LightController();
- if (lightCTR != null) {
- if (lightcmd.unitnum.equalsIgnoreCase("all")) {
- int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
- if (ret >= 0) {
- ret = lightCTR.Refresh(false);
- if (ret >= 0) {
- retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
- for (int i = 0; i < lightCTR.data.LightCount; i++) {
- retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
- int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
- if (ret >= 0) {
- ret = lightCTR.Refresh(false);
- if (ret >= 0) {
- retStr += " result=\"ok\">\r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
- for (int i = 0; i < lightCTR.data.LightCount; i++) {
- retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- }
- }
- }
- } else {
- retStr += " result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- retStr += " result = \"fail\">\r\n </service>\r\n</imap>";
- }
- lightcmd = null;
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProc_I_LightControl(Document ele) {
- try {
- WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
- String retStr = CheckiCMDProc("remote_access_livinglight");
- if (retStr != null) return retStr;
- else
- retStr = XMLHeader + " <service type = \"reply\" name= \"remote_access_livinglight\" ";
- String target = "null", tid = "null", msgno = "null";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- IntLightAPI lightCTR = mWallPadAPI.Get_IntLightController();
- if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
- if (lightCTR != null && lightCTR.Refresh(false) == 0) {
- retStr += "result=\"ok\">\r\n <action>\"status\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
- for (int i = 0; i < lightCTR.data.LightCount; i++) {
- retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap> ";
- }
- } else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
- if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
- int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
- int result = -999;
- if (lightCTR != null) {
- if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
- result = lightCTR.LightProgramControl((byte) num, (byte) 1);
- } else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
- result = lightCTR.LightProgramControl((byte) num, (byte) 0);
- }
- if (result >= 0) {
- // 제어 성공
- try {
- Thread.sleep(1000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- lightCTR.Refresh(false);
- retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
- for (int i = 0; i < lightCTR.data.LightCount; i++) {
- retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
- }
- retStr += " </service>\r\n</imap>";
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
- }
- } else {
- int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
- if (!lightcmd.ctraction.equalsIgnoreCase("null"))
- if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
- try {
- Thread.sleep(1000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- lightCTR.Refresh(false);
- retStr += "result=\"ok\"> \r\n <action>\"control\"</action>\r\n <status_map dev_num=\"" + lightcmd.devnum + "\" unit_cnt=\"" + lightCTR.data.LightCount + "\"/>\r\n";
- for (int i = 0; i < lightCTR.data.LightCount; i++) {
- retStr += " <status_info unit_num=\"" + String.format("switch%d\" unit_status=\"%s\" />\r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
- }
- retStr += " </service>\r\n</imap>\r\n";
- } else {
- retStr += "result=\"fail\">\r\n </service>\r\n</imap>";
- }
- }
- } else {
- retStr += "result = \"fail\">\r\n </service>\r\n</imap>";
- }
- lightcmd = null;
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String iCMDProcGASControl(Element ele) {
- try {
- String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
- String strResult = CheckiCMDProc("remote_access_gas");
- if (strResult != null) return strResult;
- else
- strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result =";
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(strResult, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- NodeList itemsParam = ele.getElementsByTagName("params");
- Node itemParam = itemsParam.item(0);
- if (itemParam != null) {
- NamedNodeMap attrsParam = itemParam.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dev_num"))
- devnum = attr.getNodeValue();
- // else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
- //unitnum = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
- ctraction = attr.getNodeValue();
- }
- }
- NodeList itemsaction = ele.getElementsByTagName("action");
- Node itemaction = itemsaction.item(0);
- Node text = itemaction.getFirstChild();
- String actionTXT = text.getNodeValue();
- //수정
- strResult = XMLHeader + " <service type=\"reply\" name=\"remote_access_gas\" result=";
- actionTXT = trimquotation(actionTXT);
- GasAPI GasValveCTR = null;
- CooktopAPI HybridCookTopCTR = null;
- if (mWallPadAPI.GetGasKind() == 2) {
- //하이브리드
- HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
- } else {
- GasValveCTR = mWallPadAPI.Get_GasController();
- }
- if (actionTXT.equalsIgnoreCase("status")) {
- // 가스밸브 상태 조회
- if (mWallPadAPI.GetGasKind() == 2) {
- //하이브리드
- if (HybridCookTopCTR != null) {
- //전체 정보가져오기
- int ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
- if (ret < 0) {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- int OnOpenCount = 0;
- int OperationCount = 0;
- for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
- // 콘센트 ON/OFF 업데이트
- if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
- if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
- OnOpenCount++;
- } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
- OperationCount++;
- }
- }
- }
- if (OperationCount > 0) {
- valvestatus = "ing";
- } else if (OnOpenCount > 0) {
- valvestatus = "open";
- } else {
- valvestatus = "close";
- }
- }
- } else {
- if (GasValveCTR != null) {
- int ret = GasValveCTR.Refresh((byte) 0, false);
- if (ret < 0) {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- if (GasValveCTR.data.DeviceCnt == 2) {
- GasValveCTR.Refresh((byte) 1, false);
- }
- byte GasStatus = GasAPI.GASSTATUS.Close;
- for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
- if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
- GasStatus = GasAPI.GASSTATUS.Operation;
- break;
- }
- if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
- GasStatus = GasAPI.GASSTATUS.Open;
- break;
- }
- }
- if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
- else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
- else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
- else valvestatus = "unknown";
- }
- }
- } else if (actionTXT.equalsIgnoreCase("control")) {
- // 가스밸브 콘트롤
- if (mWallPadAPI.GetGasKind() == 2) {
- //하이브리드
- if (HybridCookTopCTR != null) {
- int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
- if (ret < 0) {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
- if (ret < 0) {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- int OnOpenCount = 0;
- int OperationCount = 0;
- for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
- // 콘센트 ON/OFF 업데이트
- if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
- if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
- OnOpenCount++;
- } else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
- OperationCount++;
- }
- }
- }
- if (OperationCount > 0) {
- valvestatus = "ing";
- } else if (OnOpenCount > 0) {
- valvestatus = "open";
- } else {
- valvestatus = "close";
- }
- }
- } else {
- if (GasValveCTR != null) {
- int ret = GasValveCTR.SetClose((byte) 0xFF);
- if (ret < 0) {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- ret = GasValveCTR.Refresh((byte) 0, false);
- if (ret < 0) {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- if (GasValveCTR.data.DeviceCnt == 2) {
- GasValveCTR.Refresh((byte) 1, false);
- }
- byte GasStatus = GasAPI.GASSTATUS.Close;
- for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
- if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
- GasStatus = GasAPI.GASSTATUS.Operation;
- break;
- }
- if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
- GasStatus = GasAPI.GASSTATUS.Open;
- break;
- }
- }
- if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
- else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
- else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
- else valvestatus = "unknown";
- }
- }
- } else {
- strResult += "\"fail\">\r\n </service>\r\n</imap>";
- return strResult;
- }
- strResult += "\"ok\" >\r\n";
- strResult += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
- strResult += " <action>\"" + actionTXT + "\"</action>\r\n";
- strResult += " <status_map dev_num=\"" + devnum + "\" unit_cnt=\"1\"/>\r\n";
- strResult += " <status_info unit_num=\"gas1\" unit_status=\"" + valvestatus + "\"/>\r\n";
- strResult += " </service>\r\n";
- strResult += "</imap> ";
- return strResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private String iCMDProcLightBatchControl(Element ele) {
- try {
- String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
- String retStr = CheckiCMDProc("remote_access_light_batch_control");
- if (retStr != null) return retStr;
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- msgno = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
- return ServerCheckResult;
- }
- NodeList itemsParam = ele.getElementsByTagName("params");
- Node itemParam = itemsParam.item(0);
- if (itemParam != null) {
- NamedNodeMap attrsParam = itemParam.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
- ctraction = attr.getNodeValue();
- }
- }
- }
- NodeList itemsaction = ele.getElementsByTagName("action");
- Node itemaction = itemsaction.item(0);
- Node text = itemaction.getFirstChild();
- String actionTXT = text.getNodeValue();
- retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_light_batch_control\" result=";
- actionTXT = trimquotation(actionTXT);
- Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
- if (actionTXT.equalsIgnoreCase("status")) {
- // 일괄소등 상태 조회
- int ret = mWallPadAPI.GetBatchSwitchStatus();
- if (ret > 1) {
- retStr += " \"fail\" >\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (ret == 0) {
- ilgalstatus = "on";
- } else if (ret == 1) {
- ilgalstatus = "off";
- } else {
- ilgalstatus = "error";
- }
- } else if (actionTXT.equalsIgnoreCase("control")) {
- // 일괄소등 제어
- int ret = -1;
- int status = -1;
- if (ctraction.equals("on") == true) {
- ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
- status = 0;
- } else if (ctraction.equals("off") == true) {
- ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
- status = 1;
- }
- if (ret < 0) {
- retStr += " \"fail\" >\r\n </service>\r\n</imap>";
- return retStr;
- }
- if (status == 0) {
- ilgalstatus = "on";
- } else if (status == 1) {
- ilgalstatus = "off";
- } else {
- ilgalstatus = "error";
- }
- } else {
- retStr += "\"fail\" />\r\n </service>\r\n</imap>";
- return retStr;
- }
- retStr += "\"ok\" >\r\n";
- retStr += " <target name=\"" + target + "\" id=\"" + tid + "\" msg_no=\"" + msgno + "\"/>\r\n";
- retStr += " <action>\"" + actionTXT + "\"</action>\r\n";
- retStr += " <status_info unit_status=\"" + ilgalstatus + "\"/>\r\n </service>\r\n</imap> ";
- return retStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private String iCMDProcEntireLightControl(Document ele) {
- try {
- String retStr = CheckiCMDProc("remote_entire_access_light_control");
- if (retStr != null) return retStr;
- else
- retStr = XMLHeader + " <service type=\"reply\" name=\"remote_entire_access_light_control\"";
- String sDong = null;
- String sHo = null;
- String sDevice_Num = null;
- String sSelCtrl_Action = null;
- String sUnselCtrl_Action = null;
- NodeList items = ele.getElementsByTagName("home_info");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- sDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- sHo = trimquotation(attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if (mSdb_LivingRoomLightAPI == null) {
- Log.w(TAG, "[iCMDProcEntireLightControl] mSdb_LivingRoomLightAPI is null!!!");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- if (mSdbAPI == null) {
- Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
- items = ele.getElementsByTagName("sel_ctrlinfo");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dev_num"))
- sDevice_Num = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
- sSelCtrl_Action = trimquotation(attr.getNodeValue());
- }
- Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
- int result = -1; // 조명 제어 결과
- boolean bLivingLightSel = false; // 거실조명 선택 여부
- // ============================== 선택된 조명 ==============================
- String[] sel_devNum = null;
- if (sDevice_Num != null && sDevice_Num.contains("light")) {
- if (sDevice_Num.contains("/"))
- sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
- else {
- sel_devNum = new String[1];
- sel_devNum[0] = sDevice_Num.replaceAll("light", "");
- }
- }
- if (sel_devNum == null) sel_devNum = new String[0];
- for (int i = 0; i < sel_devNum.length; i++) {
- if (sel_devNum[i].equals("1")) {
- bLivingLightSel = true;
- Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
- if (sSelCtrl_Action != null) {
- if (sSelCtrl_Action.equalsIgnoreCase("off")) {
- result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
- } else {
- int nColor = 0;
- if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
- else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
- if (nColor > 0) {
- result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
- result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
- result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
- }
- }
- // 거실조명 제어 결과
- if (result < 0) {
- Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- }
- } else {
- Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
- if (sSelCtrl_Action != null) {
- if (sSelCtrl_Action.equalsIgnoreCase("off")) {
- result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
- } else {
- int nColor = 0;
- if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
- else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
- if (nColor > 0) {
- result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
- result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
- result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
- }
- }
- }
- // 그 외 방 조명 제어 결과
- if (result < 0) {
- Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- }
- }
- // ============================== 선택안된 조명 ==============================
- items = ele.getElementsByTagName("unsel_ctrlinfo");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
- sUnselCtrl_Action = trimquotation(attr.getNodeValue());
- Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
- }
- if (!bLivingLightSel) {
- Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
- if (sUnselCtrl_Action != null) {
- if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
- result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
- } else {
- int nColor = 0;
- if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
- else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
- if (nColor > 0) {
- result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
- result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
- result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
- }
- }
- }
- if (result < 0) {
- Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- }
- ArrayList<Integer> unsel_devNum = new ArrayList<>();
- // Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
- for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
- unsel_devNum.add(i + 1);
- }
- for (int i = 0; i < unsel_devNum.size(); i++) {
- for (int j = 0; j < sel_devNum.length; j++) {
- if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
- unsel_devNum.remove(i);
- }
- }
- for (int i = 0; i < unsel_devNum.size(); i++) {
- Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
- if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
- result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
- } else {
- int nColor = 0;
- if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
- else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
- if (nColor > 0) {
- result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
- result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
- result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
- }
- }
- if (result < 0) {
- Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- }
- Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
- retStr += " result=\"ok\">\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- } else {
- Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
- retStr += " result=\"fail\" >\r\n";
- retStr += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" />\r\n";
- retStr += " </service>\r\n</imap>";
- return retStr;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- // 월패드에 원격제어 사용 여부를 확인하다.
- private String CheckiCMDProc(String CMDStr) {
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- try {
- boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
- mWallpadStatusData.closeDB();
- if (!bRemoteCtrlEnabled) {
- String retXML = XMLHeader + "<service type=\"reply\" name=\"" + CMDStr + "\" result=\"deny\">\r\n" +
- " </service>\r\n</imap>";
- return retXML;
- }
- return null;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- mWallpadStatusData.closeDB();
- return null;
- } catch (Exception e) {
- mWallpadStatusData.closeDB();
- Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- //메인으로 공지 해야 할 노티 사항을 처리
- public String ProcEventNotify(Element ele) {
- try {
- NodeList items = ele.getElementsByTagName("event");
- Node item = items.item(0);
- Node text = item.getFirstChild();
- String eventTXT = trimquotation(text.getNodeValue());
- if (eventTXT.equalsIgnoreCase("news_arrival")) {
- // 새로운 공지사항 존재
- wakeupLCD();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
- getApplicationContext().sendBroadcast(intent);
- } else if (eventTXT.equalsIgnoreCase("box_arrival")) {
- // 택배 도착
- wakeupLCD();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
- intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
- intent.putExtra("REMAIN_CNT", 1);
- getApplicationContext().sendBroadcast(intent);
- } else if (eventTXT.equalsIgnoreCase("box_delivered")) {
- // 택배 반출
- wakeupLCD();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
- intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
- intent.putExtra("REMAIN_CNT", 0);
- getApplicationContext().sendBroadcast(intent);
- } else if (eventTXT.equalsIgnoreCase("car_arrival")) {
- // 등록된 차량 도착
- wakeupLCD();
- // 팝업을 띄우도록 하자
- Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
- Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
- } else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
- // 내려가는 방향의 엘리베이터가 도착함
- if (ElevatorDown != null) {
- ElevatorDown.TimeOutCancel();
- ElevatorDown.ClearElevator();
- }
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
- getApplicationContext().sendBroadcast(intent);
- } else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
- // 올라가는 방향의 엘리베이터가 도착함
- if (ElevatorUp != null) {
- ElevatorUp.TimeOutCancel();
- ElevatorUp.ClearElevator();
- }
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
- getApplicationContext().sendBroadcast(intent);
- } else {
- }
- String returnStr = XMLHeader + "<service type = \"reply\" name= \"event_notify\" result = \"ok\">\r\n" +
- "<event> \"" + eventTXT + "\" </event>\r\n" + " </service>\r\n </imap> ";
- return returnStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String GetAttributeVal(Node node, String attname) {
- NamedNodeMap attrs = node.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
- }
- return null;
- }
- public class imageFileFilter implements FilenameFilter {
- public boolean accept(File dir, String name) {
- 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;
- else return false;
- }
- }
- public String ProcCheckEpiceUpload(Document ele) {
- try {
- String returnStr = XMLHeader + "<service type = \"reply\" name= \"check_epics_upload\" result =\"ok\">\r\n";
- NodeList items = ele.getElementsByTagName("filename");
- Node item = items.item(0);
- Node text = item.getFirstChild();
- String filename = trimquotation(text.getNodeValue());
- Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
- String duplicate = null;
- Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
- File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
- if (!dirInternal.exists()) dirInternal.mkdir();
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- AddressSet addr = SetData.getAddressMGR();
- if (!dirInternal.exists()) {
- returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
- " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + define.MAX_ALBUM_PICTURE + "\" available=\"0\" duplicate=\"new\"/>\r\n" +
- " </service>\r\n</imap>";
- return returnStr;
- }
- imageFileFilter jpegfilter = new imageFileFilter();
- String[] subfile = dirInternal.list(jpegfilter);
- Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
- File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
- if (checkFile.exists()) duplicate = "exist";
- else duplicate = "new";
- if (subfile != null) {
- returnStr += " <homeaddr dong=\"" + addr.Dong + "\" ho=\"" + addr.Ho + "\"/>\r\n" +
- " <pics space=\"" + define.MAX_ALBUM_PICTURE + "\" total=\"" + subfile.length + "\" available=\"" + (define.MAX_ALBUM_PICTURE - subfile.length) + "\" duplicate=\"" + duplicate + "\"/>\r\n" +
- " </service>\r\n</imap>";
- }
- SetData.closeDB();
- return returnStr;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private void playNotifySound(int nSoundID) {
- try {
- PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
- Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
- if (getCompareBSPVersion()) {
- if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
- } else {
- if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
- }
- boolean NeedPlay = false;
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
- NeedPlay = SetData.GetCarSoundOfEventAlarm();
- } else {
- NeedPlay = SetData.GetSoundOutputOfEventAlarm();
- }
- SetData.closeDB();
- if (NeedPlay) Sound().PlayMent(nSoundID);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void wakeupLCD() {
- try {
- // PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
- // Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
- // if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
- WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
- int AlarmStatus = WsDB.GetAlarmStatus();
- WsDB.closeDB();
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
- Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
- return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
- } else {
- Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
- mIOInterface.ctrlLcdWakeUp();
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] wakeupLCD()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
- * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
- * Jeff, 2020.09.07
- *
- * @return true: LCD backlight On, false: LCD backlight Off
- */
- public boolean checkLCDOnByCMD() {
- try {
- Runtime mRuntime = Runtime.getRuntime();
- Process mProcess;
- String cmd = "getprop persist.sys.lcdcon";
- mProcess = mRuntime.exec(cmd);
- BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
- String line;
- String strResult = null;
- while ((line = br.readLine()) != null) {
- strResult = line;
- }
- if (strResult != null) {
- if (strResult.equals("0")) {
- Log.e(TAG, "[checkLCDOnByCMD] LCD On");
- return true;
- } else if (strResult.equals("1")) {
- Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
- return false;
- } else {
- Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
- return false;
- }
- } else
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkLCDOnByCMD()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- /**
- * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
- * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
- *
- * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
- */
- public boolean getCompareBSPVersion() {
- try {
- StringBuilder strBSPVersion = new StringBuilder();
- StringBuffer sysInfoBuffer = new StringBuffer();
- sysInfoBuffer.append(Build.DISPLAY);
- strBSPVersion.append(sysInfoBuffer.toString());
- String result = strBSPVersion.toString();
- Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
- Date date = simpleDateFormat.parse(result);
- Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
- if (date.compareTo(standardDate) >= 0) {
- Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
- return true;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getCompareBSPVersion()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- public String ProcUpdateWeather(Document ele) {
- String resultstr = XMLHeader + "<service type = \"reply\" name= \"update_weather\" result=";
- String nowloc = "";
- String nowlcode = "";
- String nowdate = "";
- String nowtext = "";
- String nowcode = "";
- String nowtemp = "";
- String nowlo = "", nowhigh = "";
- NodeList items = ele.getElementsByTagName("now");
- Node item = items.item(0);
- if (item == null)
- return resultstr += "\"fail\"/> \r\n </imap>";
- NamedNodeMap attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
- nowlcode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("temperature"))
- nowtemp = attr.getNodeValue();
- }
- items = ele.getElementsByTagName("week");
- String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
- Weathertbl.InitWeatherTable();
- for (int i = 0; i < items.getLength(); i++) {
- item = items.item(i);
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("text"))
- weektext = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("code"))
- weekcode = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("high"))
- weekhigh = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
- }
- if (i == 0) {
- nowlo = weeklow;
- nowhigh = weekhigh;
- }
- Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
- }
- //WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
- intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
- getApplicationContext().sendBroadcast(intent);
- String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
- 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);
- //air
- items = ele.getElementsByTagName("air");
- String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
- item = items.item(0);
- if (item != null) {
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("pm25"))
- airpm25 = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("co2"))
- airco2 = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("ozone"))
- airozone = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("air_index"))
- air_index = attr.getNodeValue();
- }
- Intent intentAir = new Intent();
- intentAir.setAction(define.NOTIFY_ACNAME);
- intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
- getApplicationContext().sendBroadcast(intentAir);
- DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
- }
- DBMGR.closeDB();
- return resultstr += "\"ok\"/> \r\n </imap>";
- }
- //iMAP update_news 처리
- public String ProcUpdateNews(Document ele) {
- NodeList items = ele.getElementsByTagName("ver_news");
- Node item = items.item(0);
- String strNewsVer = item.getTextContent();
- strNewsVer = trimquotation(strNewsVer);
- String retXML = XMLHeader + "<service type = \"reply\" name= \"update_news\" result = \"ok\" >\r\n" +
- " <ver_news>\"" + strNewsVer + "\"</ver_news>\r\n<service/>\r\n</imap>";
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- String NotiVer = DBMGR.GetNoticeVer();
- int noticeCNT = DBMGR.GetNoticeCNT();
- if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
- String[] spdt = strNewsVer.split("[.]");
- noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
- } else {
- String[] spdt = strNewsVer.split("[.]");
- int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
- spdt = NotiVer.split("[.]");
- newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
- noticeCNT += newcnt;
- }
- Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
- DBMGR.SetNoticeVer(strNewsVer);
- DBMGR.SetNoticeCNT(noticeCNT);
- DBMGR.closeDB();
- if (NotiVer.compareTo(strNewsVer) != 0) {
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
- intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
- getApplicationContext().sendBroadcast(intent);
- }
- return retXML;
- }
- //iMAP check_lobby_passwd 처리
- public String CheckPassword(Document doc) {
- NodeList items = doc.getElementsByTagName("inpasswd");
- Node item = items.item(0);
- Node text = item.getFirstChild();
- String passwd = trimquotation(text.getNodeValue());
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- String settedpasswd = DBMGR.GetUserPW();
- DBMGR.closeDB();
- String retString = XMLHeader;
- Common.DebugLog("================ CheckPassword ================ ");
- Common.DebugLog("Saved Password :" + settedpasswd);
- Common.DebugLog("Input Password :" + passwd);
- Common.DebugLog("================ CheckPassword ================ ");
- if (settedpasswd.equals(passwd)) {
- retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"ok\"/>\r\n";
- } else {
- retString += "<service type=\"reply\" name=\"check_lobby_passwd\" result = \"fail\">\r\n<wrongpasswd>" + passwd + "</wrongpasswd>\r\n</service>";
- }
- retString += "</imap>";
- return retString;
- }
- //schedule_renew 처리
- protected String ProcSchduleRenew(Document doc) {
- String retXML = XMLHeader + " <service type = \"reply\" name= \"schedule_renew\" result = \"ok\" > \r\n " +
- "<homeaddr dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" /> \r\n </service> \r\n </imap>";
- WallpadScheduleData schedulDB = null;
- try {
- NodeList items = doc.getElementsByTagName("renew_info");
- schedulDB = new WallpadScheduleData(getApplicationContext());
- for (int i = 0; i < items.getLength(); i++) {
- Node item = items.item(i);
- WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
- NamedNodeMap attrsParam = item.getAttributes();
- String Type = "none";
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- String name = attr.getNodeName();
- String Val = attr.getNodeValue();
- if (attr.getNodeName().equalsIgnoreCase("rn_num"))
- SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
- else if (name.equalsIgnoreCase("rn_type"))
- Type = Val;
- else if (name.equalsIgnoreCase("rn_t_type"))
- SCdata.inqttype = Val;
- else if (name.equalsIgnoreCase("rn_c_type"))
- SCdata.inqctype = Val;
- else if (name.equalsIgnoreCase("rn_a_type"))
- SCdata.inqatype = Val;
- else if (name.equalsIgnoreCase("rn_i_type"))
- SCdata.inqitype = Val;
- else if (name.equalsIgnoreCase("rn_year"))
- SCdata.inqyear = Integer.parseInt(Val);
- else if (name.equalsIgnoreCase("rn_month"))
- SCdata.inqmonth = Integer.parseInt(Val);
- else if (name.equalsIgnoreCase("rn_day"))
- SCdata.inqday = Integer.parseInt(Val);
- else if (name.equalsIgnoreCase("rn_hour"))
- SCdata.inqhour = Integer.parseInt(Val);
- else if (name.equalsIgnoreCase("rn_message"))
- SCdata.inqmsg = Val;
- }
- if (Type.equals("delete")) {
- schedulDB.DeleteSchedule(SCdata);
- } else if (Type.equals("add")) {
- schedulDB.AddSchedule(SCdata);
- } else if (Type.equals("change")) {
- schedulDB.UpdateSchedule(SCdata);
- }
- }
- schedulDB.closeDB();
- // yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
- // Intent intent = new Intent();
- // intent.setAction(define.NOTIFY_ACNAME);
- // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
- // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
- // getApplicationContext().sendBroadcast(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- if (schedulDB != null) schedulDB.closeDB();
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- if (schedulDB != null) schedulDB.closeDB();
- }
- return retXML;
- }
- //schedule_inquiry 처리
- @SuppressWarnings("unused")
- public String ProcSchduleInquiry(Document doc) {
- WallpadScheduleData schedulDB = null;
- String retXML;
- int QYear = 0;
- int QMonth = 0;
- try {
- NodeList items = doc.getElementsByTagName("inquiry_time");
- schedulDB = new WallpadScheduleData(getApplicationContext());
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("year"))
- QYear = Integer.parseInt(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("month"))
- QMonth = Integer.parseInt(attr.getNodeValue());
- }
- List<WallpadScheduleData.ScheduleData> SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
- retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
- " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
- " <inquiry_time year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
- " <inquiry_count>" + SCData.size() + "</inquiry_count>\r\n";
- if (SCData != null) {
- if (SCData.size() > 0) {
- for (int i = 0; i < SCData.size(); i++) {
- WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
- 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=\"" +
- SCINQDATA.inqyear + "\" inq_month=\"" + SCINQDATA.inqmonth + "\" inq_day=\"" + SCINQDATA.inqday + "\" inq_hour=\"" + SCINQDATA.inqhour + "\" inq_message=\"" + SCINQDATA.inqmsg + "\"/>\r\n";
- }
- }
- retXML += "</service>\r\n</imap>";
- } else {
- retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
- " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
- " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
- " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
- " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
- " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
- " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + "<service type=\"reply\" name=\"schedule_inquiry\" result = \"ok\">\r\n" +
- " <homeaddr dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\"/>\r\n" +
- " <inquery_type year = \"" + QYear + "\" month=\"" + QMonth + "\"/>\r\n" +
- " <inquery_count> 0 </inquery_count>\r\n</service>\r\n</imap>";
- }
- schedulDB.closeDB();
- return retXML;
- }
- public String ProcUpdateSchedule(Element ele, String type) {
- String retXML = "";
- return retXML;
- }
- public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
- public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
- private void setDefaultLauncher() {
- try {
- PackageManager pm = getPackageManager();
- IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_MAIN);
- filter.addCategory(Intent.CATEGORY_HOME);
- filter.addCategory(Intent.CATEGORY_DEFAULT);
- Context context = getApplicationContext();
- ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
- ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
- pm.clearPackagePreferredActivities("com.android.launcher");
- pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
- Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
- try {
- Thread.sleep(300);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- // 리셋코드 추가
- //try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
- try {
- PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
- powerMg.reboot(null);
- Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- Log.d(TAG, "$$$$$$$$$ Reset !!!!");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public String ProcDeviceReset(Element ele) {
- String retXML = XMLHeader + "<service type = \"reply\" name= \"device_reset\" result = \"ok\"/>\r\n" +
- "</imap>\r\n";
- NodeList resettype = ele.getElementsByTagName("guidemap");
- Node resettypeItem = resettype.item(0);
- String type = GetAttributeVal(resettypeItem, "type");
- if (type != null) {
- if (type.equals("now")) {
- setDefaultLauncher();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
- getApplicationContext().sendBroadcast(intent);
- } else if (type.equals("disable")) {
- WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
- SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
- SetReset.closeDB();
- } else if (type.equals("week") || type.equals("month")) {
- int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
- NodeList periodList = ele.getElementsByTagName("period");
- Node perioditem = periodList.item(0);
- int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
- int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
- WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
- SetReset.SetResetSchedule(Resettype, cycle, time);
- SetReset.closeDB();
- }
- }
- // yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
- // Intent intent = new Intent();
- // intent.setAction(define.NOTIFY_ACNAME);
- // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
- // intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
- // getApplicationContext().sendBroadcast(intent);
- return retXML;
- }
- public String ProcDeviceLiveCheck() {
- String retXML = XMLHeader + "<service type=\"reply\" name = \"device_live_check\" result = \"ok\"/>\r\n</imap>";
- return retXML;
- }
- public String ProcPairingHdevSyncAlarm(Element ele) {
- String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_alarm\" result = \"ok\" />\r\n</imap>";
- return retXML;
- }
- public String ProcPairingHdevSyncSecurity(Element ele) {
- String retXML = XMLHeader + "<service type = \"reply\" name= \"pairing_hdev_sync_security\" result = \"ok\" />\r\n</imap>";
- return retXML;
- }
- public String ProcParkInformation(Element ele) {
- try {
- Log.d(TAG, "[ProcParkInformation] ========== START ==========");
- String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"ok\" />\r\n</imap>";
- String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
- NodeList items = ele.getElementsByTagName("destination");
- Node item = items.item(0);
- Node text;
- NamedNodeMap attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name"))
- strName = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_high"))
- strDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_low"))
- strHo = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("move_info");
- item = items.item(0);
- text = item.getFirstChild();
- strCarMove = trimquotation(text.getNodeValue());
- items = ele.getElementsByTagName("params");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("car_num"))
- strCarNo = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
- strCarLocation = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("message"))
- strMsg = trimquotation(attr.getNodeValue());
- }
- if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
- Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
- try {
- int iTempDong = Integer.parseInt(AddrDong);
- String sTempDong = Integer.toString(iTempDong);
- int iTempHo = Integer.parseInt(AddrHo);
- String sTempHo = Integer.toString(iTempHo);
- if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
- Log.d(TAG, "ProcParkInformation Input EMData is Correct");
- } else {
- Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_car_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- }
- //DB정보 업데이트!
- WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
- CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
- CarDB.closeDB();
- //DB정보 업데이트!
- if (strCarMove.equalsIgnoreCase("in")) {
- // playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
- // 팝업을 띄우도록 하자
- wakeupLCD();
- if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
- Intent iIntent = new Intent();
- iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
- iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
- getApplicationContext().sendBroadcast(iIntent);
- } else {
- Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
- }
- Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
- Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
- }
- if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
- if (strCarMove.equalsIgnoreCase("park")) {
- //주차정보 얻어오도록 intent 알림
- SendGetParkingInfoIntent();
- }
- } else {
- //주차정보 얻어오도록 intent 알림
- SendGetParkingInfoIntent();
- //20분 후에 한번 더 주차정보 얻어오도록 intent 전송
- SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
- }
- return retXML;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- /**
- * 스마트키 이벤트 수신시 처리
- **/
- public String ProcSmartKeyEvent(Element ele) {
- Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
- String retXML = XMLHeader + " <service type=\"reply\" name=\"notify_smartkey_event\" result=\"ok\"/>\r\n</imap>";
- String strName = null, strDong = null, strHo = null, strCnt = null;
- String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
- String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
- NodeList items = ele.getElementsByTagName("destination");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name"))
- strName = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_high"))
- strDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_low"))
- strHo = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("event_info");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
- strCnt = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("event");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("event_type"))
- strEventType = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
- strEventTriggerType = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("uid"))
- strEventUID = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("sn"))
- strEventSN = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
- strEventSitecode = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("dong"))
- strEventDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- strEventHo = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("card_num"))
- strEventCardNo = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
- strEventIssueCnt = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("card_type"))
- strEventCardType = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("location"))
- strEventLocation = trimquotation(attr.getNodeValue());
- }
- if (strName != null && strDong != null && strHo != null && strCnt != null)
- Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
- Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
- Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
- if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
- Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
- } else {
- Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- }
- //데이터가 null인지 확인
- if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
- return retXML;
- }
- if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
- if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
- if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
- wakeupLCD();
- // 팝업을 띄우도록 하자
- String CardNum = "";
- try {
- int iEvent_Dong = Integer.parseInt(strEventDong);
- CardNum += String.format("%04d", iEvent_Dong);
- int iEvent_Ho = Integer.parseInt(strEventHo);
- CardNum += String.format("%04d", iEvent_Ho);
- int iEvent_CardNum = Integer.parseInt(strEventCardNo);
- CardNum += String.format("%03d", iEvent_CardNum);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- }
- Intent iIntent = new Intent();
- iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
- iIntent.putExtra("LOCATION", strEventLocation);
- iIntent.putExtra("CARD_NO", CardNum);
- getApplicationContext().sendBroadcast(iIntent);
- }
- }
- } else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
- if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
- if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
- int nCardNum;
- try {
- nCardNum = Integer.parseInt(strEventCardNo);
- Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_smartkey_event\" result = \"fail\" />\r\n</imap>";
- return retXML;
- }
- WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
- boolean bBandUse = deviceSet.getBandLocationUsage();
- deviceSet.closeDB();
- if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
- wakeupLCD();
- Intent iIntent = new Intent();
- iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
- iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
- iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
- getApplicationContext().sendBroadcast(iIntent);
- }
- }
- }
- }
- return retXML;
- }
- public String ProcParkInformation_cham_upis(Element ele) {
- Log.d(TAG, "ProcParkInformation_cham_upis START");
- String retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"ok\" />\r\n</imap>";
- String infoName = null;
- String infoDong = null;
- String infoHo = null;
- String infoCarMove = null;
- String infoCarnum = null;
- String infoCarLocation = null;
- String infoMessage = null;
- NodeList items = ele.getElementsByTagName("home_info");
- Node item = items.item(0);
- Node text;
- NamedNodeMap attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- infoDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- infoHo = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("park_info");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("car_info"))
- infoCarnum = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("location_2"))
- infoCarLocation = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("message"))
- infoMessage = trimquotation(attr.getNodeValue());
- }
- Log.d(TAG, "ProcParkInformation infoName :" + infoName);
- if (infoDong != null)
- Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
- Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
- Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
- Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
- Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
- Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
- if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
- (infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
- Log.d(TAG, "ProcParkInformation Input EMData is Correct");
- } else {
- Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
- retXML = XMLHeader + " <service type = \"reply\" name= \"notify_parkinfo_cham_upis\" result = \"fail\" />\r\n</imap>";
- return retXML;
- }
- infoCarMove = "park";
- //DB정보 업데이트!
- WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
- CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
- CarDB.closeDB();
- //DB정보 업데이트!
- Intent iIntent = new Intent();
- iIntent.setAction(define.NOTIFY_ACNAME);
- iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
- this.sendBroadcast(iIntent);
- /*
- if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
- {
- playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
- // 팝업을 띄우도록 하자
- Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
- }
- */
- return retXML;
- }
- public String ProcGetSmartKeyInfo(Element ele) {
- List<SmartKeyDataClass> SyncData = new ArrayList<SmartKeyDataClass>();
- List<SmartKeyDataClass> NewData = new ArrayList<SmartKeyDataClass>();
- String retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"ok\">\r\n";
- NodeList items = ele.getElementsByTagName("info_type");
- Node item = items.item(0);
- Node text = item.getFirstChild();
- String sInfo_type = trimquotation(text.getNodeValue());
- String sCard_info = null;
- String sMessage = null;
- if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
- {
- items = ele.getElementsByTagName("uid_info");
- item = items.item(0);
- text = item.getFirstChild();
- sCard_info = trimquotation(text.getNodeValue());
- //==============================================//
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- //==============================================//
- //쿼리문 작성
- WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
- SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
- for (int i = 0; i < SyncData.size(); i++) {
- if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
- NewData.add(SyncData.get(i));
- }
- }
- wallpadSmartKeyRegData.closeDB();
- } else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
- {
- items = ele.getElementsByTagName("sn_info");
- item = items.item(0);
- text = item.getFirstChild();
- sCard_info = trimquotation(text.getNodeValue());
- //==============================================//
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- //==============================================//
- //쿼리문 작성
- WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
- SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
- for (int i = 0; i < SyncData.size(); i++) {
- if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
- NewData.add(SyncData.get(i));
- }
- }
- wallpadSmartKeyRegData.closeDB();
- } else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
- {
- items = ele.getElementsByTagName("uid_info");
- item = items.item(0);
- text = item.getFirstChild();
- sCard_info = trimquotation(text.getNodeValue());
- //==============================================//
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- //==============================================//
- //쿼리문 작성
- WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
- SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
- for (int i = 0; i < SyncData.size(); i++) {
- if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
- NewData.add(SyncData.get(i));
- }
- }
- if (NewData.size() > 0) {
- NewData = SyncData;
- }
- wallpadSmartKeyRegData.closeDB();
- } else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
- {
- items = ele.getElementsByTagName("sn_info");
- item = items.item(0);
- text = item.getFirstChild();
- sCard_info = trimquotation(text.getNodeValue());
- //==============================================//
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- //==============================================//
- //쿼리문 작성
- WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
- SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
- for (int i = 0; i < SyncData.size(); i++) {
- if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
- NewData.add(SyncData.get(i));
- }
- }
- if (NewData.size() > 0) {
- NewData = SyncData;
- }
- wallpadSmartKeyRegData.closeDB();
- } else if (sInfo_type.equalsIgnoreCase("hkey")) {
- String dong = "";
- String ho = "";
- String Num = "all";
- //==============================================//
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- //==============================================//
- items = ele.getElementsByTagName("hkey_info");
- item = items.item(0);
- if (item == null)
- return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
- NamedNodeMap attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- dong = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- ho = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("num"))
- Num = attr.getNodeValue();
- }
- if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
- Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
- return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
- }
- //쿼리문 작성
- int intNum = 0;
- WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
- SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
- for (int i = 0; i < SyncData.size(); i++) {
- if (Num.equalsIgnoreCase("all") == true) {
- NewData.add(SyncData.get(i));
- } else {
- try {
- intNum = Integer.parseInt(Num);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return retXML = XMLHeader + " <service type = \"reply\" name = \"get_accesskey_info\" result = \"fail\"/>\r\n</imap>";
- }
- if (SyncData.get(i).id == intNum) {
- NewData.add(SyncData.get(i));
- }
- }
- }
- wallpadSmartKeyRegData.closeDB();
- } else if (sInfo_type.equalsIgnoreCase("dkey")) {
- return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
- } else if (sInfo_type.equalsIgnoreCase("mkey")) {
- return retXML = XMLHeader + "<service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\"/>\r\n </imap>";
- }
- if (NewData.size() == 0) {
- retXML = XMLHeader + " <service type = \"reply\" name= \"get_accesskey_info\" result = \"fail\">\r\n";
- retXML += " <key_type>\"hkey\"</key_type>\r\n";
- retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
- retXML += " <key_info index=\"null\" sn=\"null\" uid=\"null\" key_num=\"null\" issue_cnt=\"null\" issued_date=\"null\" message=\"null\"/>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- retXML += " <key_type>\"hkey\"</key_type>\r\n";
- retXML += " <hkey_info dong = \"" + AddrDong + "\" ho = \"" + AddrHo + "\" count = \"" + NewData.size() + "\" />\r\n";
- for (int i = 0; i < NewData.size(); i++) {
- Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
- SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
- String strFormat = sFormat.format(date);
- retXML += " <key_info index = \"" + NewData.get(i).id + "\" "
- + "sn = \"" + NewData.get(i).SerialNumber + "\" "
- + "uid = \"" + NewData.get(i).Uid + "\" "
- + "key_num = \"" + NewData.get(i).id + "\" "
- + "issue_cnt = \"" + 1 + "\" "
- + "issued_date = \"" + strFormat + "\" "
- + "message = \"" + "null" + "\" "
- + "/>\r\n";
- }
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- public void ProcMobileDevice_AuthNumber(Element ele) {
- String sDong = null;
- String sHo = null;
- String sIP = null;
- String sType = null;
- String sDevice_Name = null;
- String sTwinID = null;
- String sAuthNumber = null;
- try {
- NodeList items = ele.getElementsByTagName("home_info");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- sDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- sHo = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ip"))
- sIP = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("type"))
- sType = trimquotation(attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
- items = ele.getElementsByTagName("device_info");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("alias"))
- sDevice_Name = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("twinid"))
- sTwinID = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
- sAuthNumber = trimquotation(attr.getNodeValue());
- }
- /**데이터 전달**/
- Log.d(TAG, "sDevice_Name :" + sDevice_Name);
- Log.d(TAG, "sTwinID :" + sTwinID);
- Log.d(TAG, "sAuthNumber :" + sAuthNumber);
- Intent intent = new Intent();
- intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
- intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
- intent.putExtra("AuthNumber", sAuthNumber);
- if (NewServerUse()) {
- getApplicationContext().sendBroadcast(intent);
- }
- } else {
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public String ProcMobileDevice_ADD_Finish(Element ele) {
- String retXML = "";
- String sDong = null;
- String sHo = null;
- String sIP = null;
- String sType = null;
- String sDevice_Name = null;
- String sTwinID = null;
- try {
- NodeList items = ele.getElementsByTagName("home_info");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- sDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- sHo = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ip"))
- sIP = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("type"))
- sType = trimquotation(attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
- (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
- (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
- items = ele.getElementsByTagName("device_info");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("alias"))
- sDevice_Name = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("twinid"))
- sTwinID = trimquotation(attr.getNodeValue());
- }
- /**데이터 전달**/
- Log.d(TAG, "sDevice_Name :" + sDevice_Name);
- Log.d(TAG, "sTwinID :" + sTwinID);
- Intent intent = new Intent();
- intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
- intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
- if (NewServerUse()) {
- getApplicationContext().sendBroadcast(intent);
- } else {
- retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- String tempType = "main";
- //DB에 저장 필요
- WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
- if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
- {
- wallpadMobileDeviceData.closeDB();
- retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
- wallpadMobileDeviceData.closeDB();
- retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"ok\">\r\n";
- retXML += " <home_info dong=\"" + addc.Dong + "\" ho=\"" + addc.Ho + "\" ip=\"" + addc.IPAddress + "\" type=\"" + tempType + "\"/>\r\n";
- retXML += " <device_info alias=\"" + sDevice_Name + "\" twinid=\"" + sTwinID + "\" />\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } else {
- retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"remote_register_new_device\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public void ProcMobileDevice_Delete(Element ele) {
- String sDong = null;
- String sHo = null;
- String sIP = null;
- String sType = null;
- String sDevice_Name = null;
- String sTwinID = null;
- Log.d(TAG, "ProcMobileDevice_Delete");
- try {
- NodeList items = ele.getElementsByTagName("home_info");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- sDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- sHo = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ip"))
- sIP = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("type"))
- sType = trimquotation(attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
- (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
- (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
- if (NewServerUse()) {
- WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
- items = ele.getElementsByTagName("device_info");
- for (int i = 0; i < items.getLength(); i++) {
- item = items.item(i);
- attrsParam = item.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("alias"))
- sDevice_Name = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("twinid"))
- sTwinID = trimquotation(attr.getNodeValue());
- }
- Log.d(TAG, "sDevice_Name :" + sDevice_Name);
- Log.d(TAG, "sTwinID :" + sTwinID);
- wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
- }
- wallpadMobileDeviceData.closeDB();
- Intent intent = new Intent();
- intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
- getApplicationContext().sendBroadcast(intent);
- }
- } else {
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public String ProcGetAppVersionInfo() {
- String retXML = "";
- MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
- int AppCount;
- AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
- retXML = XMLHeader + " <service type = \"reply\" name= \"get_app_version_info\" result = \"ok\">\r\n";
- retXML += " <home_info dong = \"" + AddrDong + "\" ho=\"" + AddrHo + "\" platform=\"Android\" count=\"" + AppCount + "\" />\r\n";
- for (int i = 0; i < AppCount; i++) {
- String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
- if (getString != null) {
- retXML += " <app_list name=\"" + getString[0] + "\" version=\"" + getString[1] + "\" />\r\n";
- }
- }
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- public String ProcIgateInitInfo(Element ele) {
- String retXML = "";
- String ctrl_baudrate = "";
- String ctrl_open = "";
- String ctrl_framecheck = "";
- String ctrl_message = "";
- String eth_mode = "";
- String eth_ip = "";
- String eth_mac = "";
- String eth_gw = "";
- String eth_sm = "";
- String noti_send = "";
- String noti_level = "";
- String noti_ip = "";
- String noti_port = "";
- try {
- NodeList items = ele.getElementsByTagName("ctrl_param");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
- ctrl_baudrate = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
- ctrl_open = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
- ctrl_framecheck = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
- ctrl_message = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("eth_param");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
- eth_mode = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
- eth_ip = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
- eth_mac = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
- eth_gw = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
- eth_sm = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("noti_param");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("noti_send"))
- noti_send = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
- noti_level = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
- noti_ip = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
- noti_port = trimquotation(attr.getNodeValue());
- }
- wallpaddbmgr WallpadDBMGR = null;
- WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
- int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
- if (RowCount_GatewayData > 100) {
- WallpadDBMGR.DeleteLH_GatewayData("50");
- }
- 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);
- WallpadDBMGR.closeDB();
- retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"ok\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"igate_init_info\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public String ProcElecCarChargeEventInfo(Element ele) {
- Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
- String retXML = "";
- String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
- String sStart_Time = "", sRemain_Time = "", sMessage = "";
- try {
- NodeList items = ele.getElementsByTagName("destination");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("name"))
- sName = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_high"))
- sId_High = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_low"))
- sId_Low = trimquotation(attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
- items = ele.getElementsByTagName("charging_info");
- item = items.item(0);
- attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
- (attr.getNodeName().equalsIgnoreCase("car_num")) ||
- (attr.getNodeName().equalsIgnoreCase("charger_num")) ||
- (attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
- (attr.getNodeName().equalsIgnoreCase("charging_status")) ||
- (attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
- (attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
- (attr.getNodeName().equalsIgnoreCase("start_time")) ||
- (attr.getNodeName().equalsIgnoreCase("remain_time")) ||
- (attr.getNodeName().equalsIgnoreCase("c_msg"))
- )) {
- Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- if (attr.getNodeName().equalsIgnoreCase("card_num"))
- sCard_Num = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("car_num"))
- sCar_Num = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
- sCharger_Num = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
- sCharger_Loc = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
- sCharging_Status = trimquotation(attr.getNodeValue());
- if (!((sCharging_Status.equalsIgnoreCase("start")) ||
- (sCharging_Status.equalsIgnoreCase("charging")) ||
- (sCharging_Status.equalsIgnoreCase("full")) ||
- (sCharging_Status.equalsIgnoreCase("charged")) ||
- (sCharging_Status.equalsIgnoreCase("stop")) ||
- (sCharging_Status.equalsIgnoreCase("service_out")) ||
- (sCharging_Status.equalsIgnoreCase("check")) ||
- (sCharging_Status.equalsIgnoreCase("commerror"))
- )) {
- Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
- sCharger_sort = trimquotation(attr.getNodeValue());
- if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
- (sCharger_sort.equalsIgnoreCase("fast")) ||
- (sCharger_sort.equalsIgnoreCase("no_info"))
- )) {
- Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
- sCharging_Ratio = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("start_time"))
- sStart_Time = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
- sRemain_Time = trimquotation(attr.getNodeValue());
- }
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- Node text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- /**데이터 전달**/
- Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
- Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
- intent.putExtra("sCard_Num", sCard_Num);
- intent.putExtra("sCar_Num", sCar_Num);
- intent.putExtra("sCharger_Num", sCharger_Num);
- intent.putExtra("sCharger_Loc", sCharger_Loc);
- intent.putExtra("sCharging_Status", sCharging_Status);
- intent.putExtra("sCharger_sort", sCharger_sort);
- intent.putExtra("sCharging_Ratio", sCharging_Ratio);
- intent.putExtra("sStart_Time", sStart_Time);
- intent.putExtra("sRemain_Time", sRemain_Time);
- intent.putExtra("sMessage", sMessage);
- WallpadDeviceSet devDB = null;
- devDB = new WallpadDeviceSet(getApplicationContext());
- int retInt = -1;
- retInt = devDB.GetDeviceSetted("전기차충전");
- devDB.closeDB();
- if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
- getApplicationContext().sendBroadcast(intent);
- }
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"ok\">\r\n";
- retXML += " <source name=\"homedev\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" />\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } else {
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"elec_car_charge_event\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public String ProcEnergyTargetInfoAlarm(Element ele) {
- String retXML = "";
- String sName = "";
- String sId_High = "";
- String sId_Low = "";
- String vName[];
- String vTarget[];
- String vTarget_Cost[];
- String vUsed[];
- String vUsed_Cost[];
- String vPredict[];
- String vPredict_Cost[];
- String vAlarm_info[];
- String vRead_Date[];
- String vRead_Day[];
- String vV_Msg[];
- String sMessage = "";
- try {
- NodeList items = ele.getElementsByTagName("source");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("name"))
- sName = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_high"))
- sId_High = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("id_low"))
- sId_Low = trimquotation(attr.getNodeValue());
- }
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- if ((sName.equalsIgnoreCase("home") == true) &&
- (sId_High.equalsIgnoreCase(addc.Dong) == true) &&
- (sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
- items = ele.getElementsByTagName("valuelist");
- Log.d(TAG, "items.getLength() :" + items.getLength());
- vName = new String[items.getLength()];
- vTarget = new String[items.getLength()];
- vTarget_Cost = new String[items.getLength()];
- vUsed = new String[items.getLength()];
- vUsed_Cost = new String[items.getLength()];
- vPredict = new String[items.getLength()];
- vPredict_Cost = new String[items.getLength()];
- vAlarm_info = new String[items.getLength()];
- vRead_Date = new String[items.getLength()];
- vRead_Day = new String[items.getLength()];
- vV_Msg = new String[items.getLength()];
- for (int j = 0; j < items.getLength(); j++) {
- Log.d(TAG, "j :" + j);
- item = items.item(j);
- attrsParam = item.getAttributes();
- Log.d(TAG, "attrsParam :" + attrsParam);
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
- (attr.getNodeName().equalsIgnoreCase("target") == true) ||
- (attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
- (attr.getNodeName().equalsIgnoreCase("used") == true) ||
- (attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
- (attr.getNodeName().equalsIgnoreCase("predict") == true) ||
- (attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
- (attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
- (attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
- (attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
- (attr.getNodeName().equalsIgnoreCase("v_msg") == true)
- )) {
- Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- if (attr.getNodeName().equalsIgnoreCase("name")) {
- vName[j] = trimquotation(attr.getNodeValue());
- if (!((vName[j].equalsIgnoreCase("elect") == true) ||
- (vName[j].equalsIgnoreCase("water") == true) ||
- (vName[j].equalsIgnoreCase("gas") == true) ||
- (vName[j].equalsIgnoreCase("heating") == true) ||
- (vName[j].equalsIgnoreCase("hotwater") == true)
- )) {
- Log.d(TAG, "vName[j] is wrong :" + vName[j]);
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } else if (attr.getNodeName().equalsIgnoreCase("target"))
- vTarget[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
- vTarget_Cost[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("used"))
- vUsed[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
- vUsed_Cost[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("predict"))
- vPredict[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
- vPredict_Cost[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
- vAlarm_info[j] = trimquotation(attr.getNodeValue());
- if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
- (vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
- (vAlarm_info[j].equalsIgnoreCase("over") == true)
- )) {
- Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
- vRead_Date[j] = trimquotation(attr.getNodeValue());
- if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
- (vRead_Date[j].equalsIgnoreCase("last_day") == true)
- )) {
- Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } else if (attr.getNodeName().equalsIgnoreCase("read_day"))
- vRead_Day[j] = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
- vV_Msg[j] = trimquotation(attr.getNodeValue());
- }
- }
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- Node text = item.getFirstChild();
- sMessage = trimquotation(text.getNodeValue());
- /**데이터 전달**/
- for (int i = 0; i < vName.length; i++) {
- Log.d(TAG, "vName[" + i + "]: " + vName[i]);
- Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
- Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
- Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
- Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
- Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
- Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
- Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
- Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
- Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
- Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
- }
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
- for (int i = 0; i < vName.length; i++) {
- if (vName[i].equals("elect")) {
- intent.putExtra("elect_target", vTarget[i]);
- intent.putExtra("elect_used", vUsed[i]);
- intent.putExtra("elect_info", vAlarm_info[i]);
- } else if (vName[i].equals("water")) {
- intent.putExtra("water_target", vTarget[i]);
- intent.putExtra("water_used", vUsed[i]);
- intent.putExtra("water_info", vAlarm_info[i]);
- } else if (vName[i].equals("gas")) {
- intent.putExtra("gas_target", vTarget[i]);
- intent.putExtra("gas_used", vUsed[i]);
- intent.putExtra("gas_info", vAlarm_info[i]);
- } else if (vName[i].equals("heating")) {
- intent.putExtra("heating_target", vTarget[i]);
- intent.putExtra("heating_used", vUsed[i]);
- intent.putExtra("heating_info", vAlarm_info[i]);
- } else if (vName[i].equals("hotwater")) {
- intent.putExtra("hotwater_target", vTarget[i]);
- intent.putExtra("hotwater_used", vUsed[i]);
- intent.putExtra("hotwater_info", vAlarm_info[i]);
- }
- }
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"ok\">\r\n";
- retXML += " <source name=\"home\" id_high=\"" + sId_High + "\" id_low=\"" + sId_Low + "\" count=\"" + vName.length + "\"" + " s_msg=\"null\" />\r\n";
- for (int i = 0; i < vName.length; i++) {
- retXML += " <valuelist name=\"" + vName[i] + "\" alarm_info=\"" + vAlarm_info[i] + "\" v_msg=\"null\" />\r\n";
- }
- retXML += " <message>\"null\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- String[] MetringDB = devSet.GetSettingData("에너지관리서버");
- devSet.closeDB();
- if (MetringDB != null) {
- try {
- String devInfo = MetringDB[1];
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] MetringInfo = devInfo.split("_");
- // MetringInfo[1] -> 회로수
- // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
- // MetringInfo[4] -> IP
- // MetringInfo[5] -> IP정보
- // MetringInfo[6] -> 검침일사용자설정
- // MetringInfo[7] -> 사용함 또는 사용안함
- if (MetringInfo[3].equals("사용함") == true) {
- getApplicationContext().sendBroadcast(intent);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- } else {
- }
- return retXML;
- } else {
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"energy_target_info_alarm\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public String ProcCheckCallOption() {
- int[] resultDB = {0, 0};
- String retXML = "";
- String sOption = "sip";
- String sMessage = "null";
- try {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- resultDB = devSet.Get_Handicapped_Mode();
- devSet.closeDB();
- if (resultDB[0] == 0) {
- //장애인모드 사용 안함
- } else if (resultDB[0] == 1) {
- //장애인모드 사용함
- }
- switch (resultDB[1]) {
- case 0: //일반모드
- sOption = "sip";
- break;
- case 1: //청각장애인
- sOption = "deaf";
- break;
- case 2: //시각장애인
- sOption = "blind";
- break;
- default:
- break;
- }
- if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
- {
- //본 구문에 들어올수 없음
- sOption = "none";
- }
- retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"ok\">\r\n";
- retXML += " <option>\"" + sOption + "\"</option>\r\n";
- retXML += " <message>\"" + sMessage + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"check_call_option\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public String ProcChatSequence(Element ele) {
- String retXML = "";
- String sFrom = "error";
- String sTo = "error";
- String sContact = "error";
- String sSequence = "error";
- String sStatus = "error";
- String sMessage = "error";
- String reply_Sequence = "error";
- String reply_Status = "error";
- String reply_Message = "null";
- try {
- NodeList items = ele.getElementsByTagName("sequence");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- sSequence = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- items = ele.getElementsByTagName("status");
- item = items.item(0);
- attrsParam = item.getAttributes();
- sStatus = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- attrsParam = item.getAttributes();
- sMessage = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- items = ele.getElementsByTagName("from");
- item = items.item(0);
- attrsParam = item.getAttributes();
- sFrom = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- items = ele.getElementsByTagName("to");
- item = items.item(0);
- attrsParam = item.getAttributes();
- sTo = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- items = ele.getElementsByTagName("contact");
- item = items.item(0);
- attrsParam = item.getAttributes();
- sContact = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- if (!((sSequence.equalsIgnoreCase("try") == true) ||
- (sSequence.equalsIgnoreCase("start") == true) ||
- (sSequence.equalsIgnoreCase("quit") == true) ||
- (sSequence.equalsIgnoreCase("cancel") == true) ||
- (sSequence.equalsIgnoreCase("ok") == true) ||
- (sSequence.equalsIgnoreCase("busy") == true) ||
- (sSequence.equalsIgnoreCase("busy_sip") == true) ||
- (sSequence.equalsIgnoreCase("reject") == true)
- )) {
- Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
- retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- if (!((sStatus.equalsIgnoreCase("idle") == true) ||
- (sStatus.equalsIgnoreCase("ringing") == true) ||
- (sStatus.equalsIgnoreCase("talking") == true)
- )) {
- Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
- retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- //입력값 처리 필요!!
- //김용성 과장님 작업필요
- //sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
- //확인 하시고 위 정보 확인해주세요.
- Log.d(TAG, "sFrom:" + sFrom);
- Log.d(TAG, "sTo:" + sTo);
- Log.d(TAG, "Contact:" + sContact);
- Log.d(TAG, "sSequence:" + sSequence);
- Log.d(TAG, "sStatus:" + sStatus);
- if (sSequence.equalsIgnoreCase("try") == true) {
- //채팅 요청
- } else if (sSequence.equalsIgnoreCase("start") == true) {
- //채팅 시작
- } else if (sSequence.equalsIgnoreCase("quit") == true) {
- //채팅 종료
- } else if (sSequence.equalsIgnoreCase("cancel") == true) {
- //취소
- } else if (sSequence.equalsIgnoreCase("ok") == true) {
- //요청확인
- } else if (sSequence.equalsIgnoreCase("busy") == true) {
- //통화중
- } else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
- //SIP 통화중
- } else if (sSequence.equalsIgnoreCase("reject") == true) {
- //거절
- }
- if (sStatus.equalsIgnoreCase("idle") == true) {
- //대기
- } else if (sStatus.equalsIgnoreCase("ringing") == true) {
- //연결중
- } else if (sStatus.equalsIgnoreCase("talking") == true) {
- //통화중
- }
- //응답값 입력 필요!!
- //김용성 과장님 작업필요
- reply_Message = "null";
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"ok\">\r\n";
- retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
- retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_sequence\" result = \"fail\">\r\n";
- retXML += " <message>\"" + reply_Message + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public String ProcChatMessage(Element ele) {
- String retXML = "";
- String sChatMessage = "error";
- String sMessage = "error";
- try {
- NodeList items = ele.getElementsByTagName("chat");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- sChatMessage = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- items = ele.getElementsByTagName("message");
- item = items.item(0);
- attrsParam = item.getAttributes();
- sMessage = trimquotation(item.getTextContent());
- ///////////////////////////////////////////////
- //test
- Log.d(TAG, "sChatMessage is " + sChatMessage);
- Log.d(TAG, "sMessage is " + sMessage);
- //test
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
- intent.putExtra("CHAT_MESSAGE", sChatMessage);
- intent.putExtra("ADD_MESSAGE", sMessage);
- getApplicationContext().sendBroadcast(intent);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"ok\">\r\n";
- retXML += " <message>\"" + "null" + "\"</message>\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"chat_message\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- public String ProcEvacuationLadderOpen(Element ele) {
- String retXML = "";
- try {
- String sDong = null;
- String sHo = null;
- NodeList items = ele.getElementsByTagName("home_info");
- Node item = items.item(0);
- NamedNodeMap attrsParam = item.getAttributes();
- for (int i = 0; i < attrsParam.getLength(); i++) {
- Node attr = attrsParam.item(i);
- if (attr.getNodeName().equalsIgnoreCase("dong"))
- sDong = trimquotation(attr.getNodeValue());
- else if (attr.getNodeName().equalsIgnoreCase("ho"))
- sHo = trimquotation(attr.getNodeValue());
- }
- WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
- int ladderDownSend = deviceSet.getEscapeLadderDownSend();
- deviceSet.closeDB();
- Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
- WallpadStatusData DBMGR = null;
- DBMGR = new WallpadStatusData(getApplicationContext());
- AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
- DBMGR.closeDB();
- String myIP = addc.IPAddress;
- String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
- String[] SplitedString = myIP.split("\\.");
- if (SplitedString != null) {
- if (SplitedString.length == 4) {
- int temp = Integer.parseInt(SplitedString[2]);
- if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
- temp = temp - 1;
- else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
- temp = temp + 1;
- String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
- Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
- temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
- DestStair = String.valueOf(temp);
- }
- }
- if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
- /**
- * 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
- * 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
- * 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
- * **/
- WallpadDeviceSet devset;
- devset = new WallpadDeviceSet(getApplicationContext());
- int StatusVal = devset.GetDeviceSetted("피난사다리");
- devset.closeDB();
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- /**
- * 피난사다리 알림!!!
- * **/
- ReceiveNetworkLadderBr(ladderDownSend);
- }
- retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"ok\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } else {
- retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"evacuation_ladder_open\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- private void ReceiveNetworkLadderBr(int val) {
- int base = 7000;
- int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
- int Menu_Start_Option = 1;
- WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
- int AlarmStatus = wdb.GetAlarmStatus();
- wdb.closeDB();
- boolean MgrAppRun = false;
- final String packageNameMgr = "com.artncore.managersetting";
- MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
- if (MgrAppRun)
- return;
- if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
- return;
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- int StatusVal = devset.GetDeviceSetted("피난사다리");
- devset.closeDB();
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- Common.SendAppFinishReqBR(getApplicationContext());
- Intent newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
- newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
- else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
- newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getApplicationContext().startActivity(newintent);
- }
- }
- /**
- * 스마트 분전반 상태 응답(서버 요청에 대한 응답)
- *
- * @param ele Element Xml 데이터
- * @return String 타입의 응답 메시지 생성
- **/
- public String SmartLightDetailInfo(Element ele) {
- iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
- return imapSmartLightInfo.SmartLightDetailInfo(ele);
- }
- /**
- * KNX 시스템 상태 응답(서버 요청에 대한 응답)
- *
- * @param ele Element Xml 데이터
- * @return String 타입의 응답 메시지 생성
- **/
- public String KNXDeviceDetailInfo(Element ele) {
- iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
- return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
- }
- public String ProcSetServerChange(Element ele) {
- String retXML = "";
- String versionTXT = null;
- try {
- boolean bRet = false;
- NodeList items = ele.getElementsByTagName("ver_server");
- Node item = items.item(0);
- Node text = item.getFirstChild();
- versionTXT = trimquotation(text.getNodeValue());
- if (versionTXT.equalsIgnoreCase("1.0")) {
- bRet = true;
- } else if (versionTXT.indexOf("2.") >= 0) {
- bRet = true;
- }
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- if (SetData != null && bRet == true) {
- SetData.SetServerVer(versionTXT);
- SetData.closeDB();
- }
- if (bRet == true) {
- try {
- iMapSverReload tSock = new iMapSverReload();
- tSock.start();
- } catch (IOException e) {
- Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 버전 체크해서
- // 응답하고 나서
- // 수신부 쓰레드 재 로딩..
- if (versionTXT != null && bRet == true) {
- retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"ok\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } else {
- retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- retXML = XMLHeader + " <service type = \"reply\" name= \"set_server_version\" result = \"fail\">\r\n";
- retXML += " </service>\r\n</imap>";
- return retXML;
- }
- }
- // 메인 서버 소켓 클래스
- public class iMapSverReload extends Thread {
- ServerSocket svr;
- public iMapSverReload() throws IOException {
- /////////////////////////////////////////////////////////////////////
- // 신형 단지서버 사용 유무를 가져온다.
- /////////////////////////////////////////////////////////////////////
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- if (SetData != null) {
- String serverVesionInfo = SetData.GetServerVer();
- SetData.closeDB();
- if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
- devset.closeDB();
- } else {
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
- devset.closeDB();
- }
- }
- try {
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
- wallpadDeviceSet.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- mNewDanjiServer = false;
- } catch (Exception e) {
- Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mNewDanjiServer = false;
- }
- Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
- // 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
- // 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
- // 관리 PC IP도 변경하도록 한다.
- if (mNewDanjiServer == true) {
- WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
- wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
- wallpadStatusData.closeDB();
- } else {
- WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
- wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
- wallpadStatusData.closeDB();
- }
- Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
- }
- public void run() {
- try {
- try {
- Thread.sleep(400);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- SvrSock.destoryThread();
- for (int i = 0; i < 20; i++) {
- if (SvrSock.isAlive() == false) {
- Log.d(TAG, " Receive Socket Reload i = : " + i);
- break;
- } else {
- Log.d(TAG, " is Live Socket Reload i = : " + i);
- }
- try {
- Thread.sleep(100);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- SvrSock = new iMapSverSocket();
- SvrSock.start();
- // 서버 교체 중에 처음으로 보내는 하트 비트 메세지
- try {
- Thread.sleep(3000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- try {
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
- getApplicationContext().sendBroadcast(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- } catch (IOException e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public static final int SCHEDULE_START_HEARTBEAT = 30000;
- public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
- public static final int SCHEDULE_START_STATUSBEAT = 30002;
- public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
- public static final int SCHEDULE_START_CALLAPP = 30004;
- public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
- public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
- public class SchedulerThread extends Thread {
- boolean doRun;
- AddressSet addr;
- String AddressStr;
- String IPaddr;
- String VerBSP = "";
- String VerAPP;
- String VerSetting;
- String VerNews;
- String VerWeather;
- int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
- List<ScheduleData> ScheduleList = new ArrayList<ScheduleData>();
- private jni mGleInterface = null;
- private final int LIVE_SIGNAL_TIME = 20;
- private int m_LiveSignalCount = 0;
- private int m_MainAppLiveCount = 0;
- Handler ScheDuleHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SCHEDULE_START_HEARTBEAT: {
- Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- heartbeatP = DBMGR.GetHeartbeatPeriod();
- DBMGR.closeDB();
- reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
- doSchedule(SCHEDULE_ACTION_HEARTBEAT);
- }
- break;
- case SCHEDULE_CHANGE_HEARTBEAT:
- Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
- synchronized (ScheduleList) {
- ScheduleData CheckData;
- for (int i = 0; i < ScheduleList.size(); i++) {
- CheckData = ScheduleList.get(i);
- if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
- Calendar cal = new GregorianCalendar();
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- heartbeatP = DBMGR.GetHeartbeatPeriod();
- DBMGR.closeDB();
- cal.add(Calendar.MINUTE, heartbeatP);
- CheckData.TData = cal;
- ScheduleList.set(i, CheckData);
- doSchedule(SCHEDULE_ACTION_HEARTBEAT);
- return;
- }
- }
- }
- reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
- doSchedule(SCHEDULE_ACTION_HEARTBEAT);
- break;
- case SCHEDULE_START_STATUSBEAT:
- Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
- doSchedule(SCHEDULE_ACTION_STATUSBEAT);
- break;
- case SCHEDULE_CHANGE_STATUSBEAT:
- Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
- synchronized (ScheduleList) {
- ScheduleData CheckData;
- for (int i = 0; i < ScheduleList.size(); i++) {
- CheckData = ScheduleList.get(i);
- if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
- Calendar cal = new GregorianCalendar();
- cal.add(Calendar.MINUTE, heartbeatP);
- CheckData.TData = cal;
- ScheduleList.set(i, CheckData);
- doSchedule(SCHEDULE_ACTION_STATUSBEAT);
- return;
- }
- }
- }
- break;
- case SCHEDULE_START_CALLAPP:
- // Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
- // Bundle bundle = new Bundle();
- // bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
- // Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
- // .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
- // .putExtra(ITEM_CALL_DATA, bundle);
- // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // iMAPstartActivity(intent);
- break;
- }
- }
- };
- Handler GetHandler() {
- return ScheDuleHandler;
- }
- public class ScheduleData {
- Calendar TData;
- String ActionSTR;
- public ScheduleData(Calendar tdata, String ActionStr) {
- TData = tdata;
- ActionSTR = ActionStr;
- }
- }
- public SchedulerThread() {
- doRun = true;
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- addr = DBMGR.getAddressMGR();
- VerAPP = DBMGR.GetAPPVer();
- VerSetting = DBMGR.GetSettingVer();
- VerNews = DBMGR.GetNoticeVer();
- VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
- DBMGR.closeDB();
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- try {
- mGleInterface = new jni();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
- }
- }
- if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
- VerAPP = GetAppVersion();
- }
- AddressStr = addr.Dong + "동" + addr.Ho + "호";
- IPaddr = addr.IPAddress;
- ScheDulerHandler = ScheDuleHandler;
- }
- public void reg_schedule(int min, String Action) {
- for (int i = 0; i < ScheduleList.size(); i++) {
- ScheduleData scdata = ScheduleList.get(i);
- if (scdata.ActionSTR.equals(Action)) {
- ScheduleList.remove(i);
- break;
- }
- }
- Calendar cal = new GregorianCalendar();
- cal.add(Calendar.MINUTE, min);
- ScheduleData regData = new ScheduleData(cal, Action);
- synchronized (ScheduleList) {
- ScheduleList.add(regData);
- }
- }
- private void doSchedule(String doing) {
- String[] doingData = doing.split(";");
- if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
- try {
- String SendingStr = MakeHeartbeat();
- SendToServer(SendingStr);
- Calendar cal = new GregorianCalendar();
- 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));
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- DBMGR.SetLastHeartbeat(timedata);
- heartbeatP = DBMGR.GetHeartbeatPeriod();
- DBMGR.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- } else if (doingData[0].equals("UPDATETIME")) {
- } else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
- // 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
- if (!Common.getDeviceServeiceLoadComplite()) return;
- String SendingStr = MakeStatusReport();
- if (SendingStr == null) return;
- SendToServer(SendingStr);
- Calendar cal = new GregorianCalendar();
- 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));
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- DBMGR.SetLastStatusbeat(timedata);
- DBMGR.closeDB();
- int StatusP = 720;
- try {
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- String[] StatusVal = devset.GetSettingData("statusbeat_time");
- devset.closeDB();
- if (StatusVal == null) StatusP = 720;
- else StatusP = Integer.parseInt(StatusVal[1]);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
- }
- }
- private String MakeHeartbeat() {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
- VerNews = DBMGR.GetNoticeVer();
- VerSetting = DBMGR.GetSettingVer();
- String VerServer = DBMGR.GetServerVer();
- DBMGR.closeDB();
- if (VerServer == null) {
- Log.d(TAG, "VerServer null");
- VerServer = "1.0";
- }
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
- wallpadDeviceSet.closeDB();
- if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
- // 스마트 분전반
- WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
- WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
- String retStr = XMLHeader +
- "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
- "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
- "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
- "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
- "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
- "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
- "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
- "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
- "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
- "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
- "<ver_server>" + VerServer + "</ver_server>\r\n" +
- "<smart_light_status>" + alarmClass.GetAlarm() + "</smart_light_status>\r\n" +
- "<smart_light_alarm_type>" + alarmClass.GetAlarmDevice() + "</smart_light_alarm_type>\r\n" +
- "</service>\r\n</imap>";
- return retStr;
- } else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
- // TODO KNX 분전반
- // String retStr = XMLHeader+
- // "<service type = \"notice\" name= \"heartbeat\" dev_type=\"homedev\">\r\n"+
- // "<ver_bsp> \""+Build.DISPLAY+"\" </ver_bsp>\r\n"+
- // "<ver_app> \""+GetAppVersion()+"\" </ver_app>\r\n"+
- // "<ver_setting>\""+VerSetting+"\"</ver_setting>\r\n"+
- // "<ver_news> \""+VerNews+"\" </ver_news>\r\n"+
- // "<ver_weather> \""+VerWeather+"\" </ver_weather>\r\n"+
- // "<ver_additional> \"0000.00.00.00\" </ver_additional>\r\n"+
- // "<ver_subboard> \"2727.00.01.07\" </ver_subboard>\r\n"+
- // "<ver_moip> \"0000.00.77.77\" </ver_moip>\r\n"+
- // "<ver_gateway> \"0000.00.01.133\" </ver_gateway>\r\n"+
- // "<ver_server>" + VerServer + "</ver_server>\r\n"+
- // "<master_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_MASTER_CONTROLLER) + "\" />\r\n" +
- // "<knx_gateway status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_KNX_GATEWAY) + "\" />\r\n" +
- // "<bedroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_BEDROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_BEDROOM_EM) + "\" />\r\n" +
- // "<network_switch status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_NETWORK_SWITCH) + "\" />\r\n" +
- // "<livingroom_em status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_LIVINGROOM_EM) + "\" />\r\n" +
- // "<valve_controller status=\"" + getKNXDeviceStatus(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" type=\"" + getKNXDeviceCause(WallPadKNX.DEVICE_VALVE_CONTROLLER) + "\" />\r\n" +
- // "</service>\r\n</imap>";
- String retStr = XMLHeader +
- "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
- "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
- "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
- "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
- "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
- "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
- "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
- "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
- "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
- "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
- "<ver_server>" + VerServer + "</ver_server>\r\n" +
- "</service>\r\n</imap>";
- return retStr;
- } else {
- String retStr = XMLHeader +
- "<service type=\"notice\" name=\"heartbeat\" dev_type=\"homedev\">\r\n" +
- "<ver_bsp>\"" + Build.DISPLAY + "\"</ver_bsp>\r\n" +
- "<ver_app>\"" + GetAppVersion() + "\"</ver_app>\r\n" +
- "<ver_setting>\"" + VerSetting + "\"</ver_setting>\r\n" +
- "<ver_news>\"" + VerNews + "\"</ver_news>\r\n" +
- "<ver_weather>\"" + VerWeather + "\"</ver_weather>\r\n" +
- "<ver_additional>\"0000.00.00.00\"</ver_additional>\r\n" +
- "<ver_subboard>\"2727.00.01.07\"</ver_subboard>\r\n" +
- "<ver_moip>\"0000.00.77.77\"</ver_moip>\r\n" +
- "<ver_gateway>\"0000.00.01.133\"</ver_gateway>\r\n" +
- "<ver_server>" + VerServer + "</ver_server>\r\n" +
- "</service>\r\n</imap>";
- return retStr;
- }
- }
- public String GetAppVersion() {
- PackageInfo pi = null;
- try {
- pi = getPackageManager().getPackageInfo(getPackageName(), 0);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- return pi.versionName;
- }
- boolean isAlawaysrun = true;
- public void run() {
- while (/*doRun*/ isAlawaysrun) {
- //Common.DebugLog("SchedulerThread ------ 10Sec");
- CheckHeartBeat();
- CheckStatusBeat();
- CheckWallPadLiveSignal();
- LiveCheckRebooting();
- try {
- Thread.sleep(10000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void SetLive() {
- m_MainAppLiveCount++;
- }
- private int CheckTime30Sec = 0;
- private void LiveCheckRebooting() {
- try {
- CheckTime30Sec++;
- if (CheckTime30Sec % 20 == 0) {
- // if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
- // // 10초마다 수행되는 함수이니....
- // // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
- // if (m_MainAppLiveCount == 0) {
- // //리셋
- // if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
- // {
- // Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
- // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
- // pm.userActivity(8, true);
- // }
- // else
- // {
- // Log.d(TAG, "Main App Down Reset IHN_750");
- // WallPadInterface wpdifc = new WallPadInterface();
- // wpdifc.WachdogSystemReset();
- // }
- // }
- // }
- CheckTime30Sec = 0;
- }
- if (CheckTime30Sec >= 30000) {
- CheckTime30Sec = 0;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void CheckWallPadLiveSignal() {
- try {
- int nTime = LIVE_SIGNAL_TIME / 10;
- m_LiveSignalCount++;
- if (m_LiveSignalCount >= nTime) {
- m_LiveSignalCount = 0;
- Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
- }
- }
- protected void CheckStatusBeat() {
- try {
- WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
- String statusbeatdata = WPD.GetLastStatusbeat();
- WPD.closeDB();
- int StatusP = 720;
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- String[] StatusVal = devset.GetSettingData("statusbeat_time");
- if (StatusVal == null) StatusP = 720;
- else
- StatusP = Integer.parseInt(StatusVal[1]);
- devset.closeDB();
- if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- protected void CheckHeartBeat() {
- try {
- WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
- String heartbeatdata = WPD.GetLastHeartbeat();
- int heartbeatPer = WPD.GetHeartbeatPeriod();
- WPD.closeDB();
- if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- protected boolean CheckTime(String CheckT, int period) {
- Calendar last = new GregorianCalendar();
- String[] timedata = CheckT.split("[.]");
- last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
- last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
- last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
- last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
- last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
- last.add(Calendar.MINUTE, period);
- Calendar checkCal = new GregorianCalendar();
- //Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
- if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
- return true;
- return false;
- }
- }
- class SendMSGToSVR extends Thread {
- String sendmsg;
- public SendMSGToSVR(String msg) {
- sendmsg = msg;
- }
- public void run() {
- Socket sock = null;
- DataOutputStream outstream = null;
- try {
- // 신형 단지서버 사용 유무를 가져온다.
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
- wallpadDeviceSet.closeDB();
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- SVRIP = DBMGR.GetServerIP();
- port = DBMGR.GetServerPort();
- DBMGR.closeDB();
- /////////////////////////////////////////////////////////////////////
- // 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
- // 사용중일 경우 암호화 소켓을 생성한다.
- /////////////////////////////////////////////////////////////////////
- if (!bNewDanjiServer) {
- sock = new Socket(SVRIP, port);
- } else {
- int setport = port + 1000;
- Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
- SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
- sock = sslClientSocket.getSocket();
- }
- /////////////////////////////////////////////////////////////////////
- if (sock != null) {
- sock.setSoLinger(true, 1000);
- outstream = new DataOutputStream(sock.getOutputStream());
- byte[] outBF = sendmsg.getBytes("euc-kr");
- outstream.write(outBF);
- outstream.flush();
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- } finally {
- if (outstream != null) {
- try {
- outstream.close();
- } catch (IOException e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- outstream = null;
- if (sock != null) {
- try {
- sock.close();
- } catch (IOException e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- sock = null;
- }
- }
- }
- private void SendToServer(String msg) {
- SendMSGToSVR msan = new SendMSGToSVR(msg);
- msan.start();
- }
- boolean StatusBeatRequested = false;
- private String MakeStatusReport() {
- try {
- String ServiceType = StatusBeatRequested ? "requested" : "notice";
- StatusBeatRequested = false;
- String RetData = XMLHeader + "<service type=\"" + ServiceType + "\" name=\"statusbeat\"> \r\n";
- WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
- String[] typeList = SettManager.GetTypeList();
- if (typeList == null || typeList.length == 0) {
- DefaultProcauscultateReq(SettManager);
- typeList = SettManager.GetTypeList();
- }
- SettManager.closeDB();
- String[] ControlList;
- String Vender = "null";
- String devid = "null";
- String Model = "null";
- String subunitcnt = "null";
- String statusRate = "null";
- String statusType = "null";
- String message = "null";
- int itemCNT = 0;
- int totalGroup = 0;
- int totalItem = 0;
- String ControlDEVList;
- String ContentList = " ";
- if (typeList != null) {
- for (int i = 0; i < typeList.length; i++) {
- if (typeList[i].equals("ctrl_device")) {
- SettManager = new WallpadDevStatus(getApplicationContext());
- ControlList = SettManager.GetSettingGroupData("ctrl_device");
- SettManager.closeDB();
- ControlDEVList = "";
- if (ControlList != null) {
- for (int k = 0; k < ControlList.length; k++) {
- if (ControlList[k].equals("light")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int[] lightinfo = devSet.Get_Light_info();
- devSet.closeDB();
- if (lightinfo[0] == 1) {
- if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
- subunitcnt = String.valueOf(lightinfo[2]);
- LightAPI lightCTR = mWallPadAPI.Get_LightController();
- devid = "0x11";
- Vender = "null";
- Model = "null";
- if (lightCTR != null) {
- lightCTR.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
- double surate = lightCTR.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- }
- } else {
- subunitcnt = String.valueOf(lightinfo[2]);
- MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
- if (MultiSW != null) {
- MultiSW.Refresh((byte) 0xFF, false);
- byte Bdevid = 0x51;
- for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
- devid = String.format("0x%02X", Bdevid + j);
- Vender = "null";
- Model = "null";
- MultiSW.TRInfo.GetTransactionList(j);
- statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
- double surate = MultiSW.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- ControlDEVList += " <unit type=\"light\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- }
- }
- }
- } else {
- Vender = "null";
- devid = "null";
- Model = "null";
- subunitcnt = "null";
- statusRate = "null";
- message = "null";
- }
- } else if (ControlList[k].equals("thermostat")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int ret = devSet.Get_Temper_Info();
- devSet.closeDB();
- if (ret == 1) {
- // 난방 종류를 얻어온다.
- int HeatingKind = mWallPadAPI.GetHeatingKind();
- HeatingV1API heatingV1API = null;
- HeatingV2API heatingV2API = null;
- // 종류별 API를 로딩한다.
- if (HeatingKind == 1) {
- heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
- if (heatingV1API != null) {
- subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
- devid = "0x21";
- Vender = "null";
- Model = "null";
- heatingV1API.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
- double surate = heatingV1API.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- }
- } else if (HeatingKind == 2) {
- heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
- if (heatingV2API != null) {
- subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
- devid = "0x28";
- Vender = "null";
- Model = "null";
- heatingV2API.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
- double surate = heatingV2API.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- }
- } else {
- subunitcnt = "null";
- devid = "null";
- Vender = "null";
- Model = "null";
- statusRate = "0/0";
- statusType = "bad";
- message = "null";
- }
- ControlDEVList += " <unit type=\"thermostat\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- } else {
- }
- } else if (ControlList[k].equals("gas")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- if (devSet.Get_GAS_Info() == 1) {
- //여기서 신우전자확인이 더 필요함
- GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
- CooktopAPI HybridCookTopCTR = null;
- subunitcnt = "1";
- devid = "0x31";
- Vender = "null";
- Model = "null";
- if (mWallPadAPI.GetGasKind() == 2) {
- HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
- if (HybridCookTopCTR != null) {
- HybridCookTopCTR.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
- double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- }
- } else {
- GasCTR = mWallPadAPI.Get_GasController();
- if (GasCTR != null) {
- GasCTR.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
- double surate = GasCTR.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- ControlDEVList += " <unit type=\"gas\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- }
- }
- } else {
- }
- devSet.closeDB();
- } else if (ControlList[k].equals("doorlock")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int[] doorlockInfo = devSet.Get_DoorLock_Info();
- if (doorlockInfo[0] == 1) {
- DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
- subunitcnt = "1";
- devid = "0x41";
- Vender = "null";
- Model = "null";
- if (DoorCTR != null) {
- DoorCTR.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
- double surate = DoorCTR.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- ControlDEVList += " <unit type=\"doorlock\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- }
- } else {
- }
- devSet.closeDB();
- } else if (ControlList[k].equals("ventil")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int[] ventilInfo = devSet.Get_Ventil_Info();
- if (ventilInfo[0] == 1) {
- VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
- subunitcnt = "1";
- devid = "0x61";
- Vender = "null";
- Model = "null";
- if (VentilCTR != null) {
- VentilCTR.TRInfo.GetTransactionList(0);
- statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
- double surate = VentilCTR.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- ControlDEVList += " <unit type=\"ventil\" id=\"" + devid + "\" vendor=\"" + Vender + "\" model=\"" + Model + "\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- }
- } else {
- }
- devSet.closeDB();
- } else if (ControlList[k].equals("aircon")) {
- } else if (ControlList[k].equals("curtain")) {
- }
- }
- if (itemCNT > 0) {
- ContentList += "<group type=\"ctrl_device\" count=\"" + itemCNT + "\">\r\n";
- ContentList += ControlDEVList;
- ContentList += "</group>\r\n";
- totalGroup++;
- totalItem += itemCNT;
- }
- }
- } else if (typeList[i].equals("talk_device")) {
- SettManager = new WallpadDevStatus(getApplicationContext());
- ControlList = SettManager.GetSettingGroupData("talk_device");
- SettManager.closeDB();
- itemCNT = 0;
- ControlDEVList = "";
- PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
- if (testAPI != null)
- testAPI.GetVersion();
- if (ControlList != null) {
- for (int k = 0; k < ControlList.length; k++) {
- if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
- 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";
- itemCNT++;
- //addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
- //addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
- } else if (ControlList[k].equals("bath_phone") && testAPI != null) {
- 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";
- itemCNT++;
- } else if (ControlList[k].equals("subhome_dev")) {
- }
- }
- if (itemCNT > 0) {
- ContentList += "<group type=\"talk_device\" count=\"" + itemCNT + "\">\r\n";
- ContentList += ControlDEVList;
- ContentList += "</group>\r\n";
- totalGroup++;
- totalItem += itemCNT;
- }
- }
- } else if (typeList[i].equals("sensor")) {
- SettManager = new WallpadDevStatus(getApplicationContext());
- ControlList = SettManager.GetSettingGroupData("sensor");
- SettManager.closeDB();
- itemCNT = 0;
- ControlDEVList = "";
- if (ControlList != null) {
- for (int k = 0; k < ControlList.length; k++) {
- if (ControlList[k].equals("magnetic")) {
- WallPadInterface wpifc = new WallPadInterface();
- int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
- String SenStateCom;
- String SenStateType;
- if (MagSen == 1) {
- SenStateCom = "1/1";
- SenStateType = "";
- } else {
- SenStateCom = "0/1";
- SenStateType = "perfect";
- }
- ControlDEVList += " <unit type=\"magnetic\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
- itemCNT++;
- } else if (ControlList[k].equals("bugout")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int sensor = devSet.Get_Sensor_Set();
- devSet.closeDB();
- if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
- WallPadInterface wpifc = new WallPadInterface();
- int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- String SenStateCom;
- String SenStateType;
- if (outSen == 1) {
- SenStateCom = "1/1";
- SenStateType = "bad";
- } else {
- SenStateCom = "0/1";
- SenStateType = "perfect";
- }
- ControlDEVList += " <unit type=\"bugout\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
- itemCNT++;
- }
- } else if (ControlList[k].equals("bugin")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int sensor = devSet.Get_Sensor_Set();
- devSet.closeDB();
- if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
- WallPadInterface wpifc = new WallPadInterface();
- int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- String SenStateCom;
- String SenStateType;
- if (InSen == 1) {
- SenStateCom = "1/1";
- SenStateType = "bad";
- } else {
- SenStateCom = "0/1";
- SenStateType = "perfect";
- }
- ControlDEVList += " <unit type=\"bugin\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"" + SenStateCom + "\" status_type=\"" + SenStateType + "\" message=\"null\"/>\r\n";
- itemCNT++;
- }
- } else if (ControlList[k].equals("fire")) {
- //SensorList+= "<unit type=\"fire\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
- } else if (ControlList[k].equals("gas")) {
- //SensorList+= "<unit type=\"gas\" id=\"null\" vendor=\"null\" model=\"null\" subunit_cnt=\"null\" status_com=\"0/0\" status_type=\"good\" message=\"null\"/>\r\n";
- }
- }
- if (itemCNT > 0) {
- ContentList += "<group type=\"sensor\" count=\"" + itemCNT + "\">\r\n";
- ContentList += ControlDEVList;
- ContentList += "</group>\r\n";
- totalGroup++;
- totalItem += itemCNT;
- }
- }
- } else if (typeList[i].equals("extended")) {
- SettManager = new WallpadDevStatus(getApplicationContext());
- ControlList = SettManager.GetSettingGroupData("extended");
- SettManager.closeDB();
- itemCNT = 0;
- ControlDEVList = "";
- if (ControlList != null) {
- for (int k = 0; k < ControlList.length; k++) {
- if (ControlList[k].equals("gateway")) {
- } else if (ControlList[k].equals("handy")) {
- } else if (ControlList[k].equals("smartswitch")) {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- int[] BatchInfo = devSet.Get_BatchSW_Info();
- devSet.closeDB();
- if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
- SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
- SmartSWCTR.TRInfo.GetTransactionList(0);
- subunitcnt = "1";
- statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
- double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
- statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
- message = "null";
- ControlDEVList += " <unit type=\"smartswitch\" id=\"0xC1\" vendor=\"null\" model=\"null\" subunit_cnt=\"" + subunitcnt + "\" status_com=\"" + statusRate + "\" status_type=\"" + statusType + "\" message=\"" + message + "\"/>\r\n";
- itemCNT++;
- } else {
- }
- } else if (ControlList[k].equals("energymeter")) {
- }
- }
- if (itemCNT > 0) {
- ContentList += "<group type=\"extended\" count=\"" + itemCNT + "\">\r\n";
- ContentList += ControlDEVList;
- ContentList += "</group>\r\n";
- totalGroup++;
- totalItem += itemCNT;
- }
- }
- }
- }
- SettManager.closeDB();
- ContentList += "</guidemap> \r\n";
- RetData += " <guidemap devtype=\"homedev\" msg_type=\"normal\" group_cnt=\"" + totalGroup + "\" device_cnt=\"" + totalItem + "\">\r\n";
- RetData += ContentList;
- String LogSet;
- LogSet = "<save_log enable=\"false\" ftp_info=\"null\" account=\"null\" period=\"null\" filesize=\"null\"/>\r\n";
- RetData += LogSet;
- try {
- WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
- String[] ResetData = WsDB.GetResetSchedule();
- WsDB.closeDB();
- if (!ResetData[0].equals("NONE")) {
- int type = Integer.parseInt(ResetData[0]);
- if (type == WallpadStatusData.RESET_MONTH)
- LogSet = "<reset_info enable=\"true\" type=\"month\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
- else if (type == WallpadStatusData.RESET_WEEK)
- LogSet = "<reset_info enable=\"true\" type=\"week\" cycle=\"" + ResetData[1] + "\" time=\"" + ResetData[2] + "\"/>\r\n";
- else
- LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
- } else
- LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- LogSet = "<reset_info enable=\"false\" type=\"null\" cycle=\"null\" time=\"null\"/>\r\n";
- }
- RetData += LogSet;
- RetData += "</service>\r\n</imap>\r\n";
- }
- return RetData;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private String getKNXDeviceStatus(int device) {
- WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
- WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
- String status = knxHeartbeat.getStatus();
- Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
- return status;
- }
- private String getKNXDeviceCause(int device) {
- WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
- WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
- String cause = knxHeartbeat.getCause();
- Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
- return cause;
- }
- //mWallPadAPI
- // private String TAG = "*yskim*";
- //private IGW200dAPI iGW200dAPI = null;
- /**
- * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
- * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
- * 본 딜레이 코드를 임시로 적용한다.
- */
- @SuppressLint("HandlerLeak")
- protected Handler IGW200APICheckHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- if (mWallPadAPI != null) {
- Common.DebugLog("handleMessage what 0 ");
- if (mWallPadAPI.Check_Connect())
- IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
- else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
- }
- } else if (msg.what == 1) {
- Common.DebugLog("handleMessage what 1 ");
- setIGE200Interface();
- }
- }
- };
- public void setIGE200Interface() {
- try {
- Common.DebugLog("setIGE200Interface");
- mIGW200 = new IGW200(this, mWallPadAPI);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setIGE200Interface()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * (임시코드) GW 초기생성시 Connect 에 시간이 걸리며, <br>
- * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
- * 본 딜레이 코드를 임시로 적용한다.
- */
- @SuppressLint("HandlerLeak")
- protected Handler IGW300APICheckHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- if (mWallPadAPI != null) {
- Common.DebugLog("handleMessage what 0 ");
- if (mWallPadAPI.Check_Connect())
- IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
- else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
- }
- } else if (msg.what == 1) {
- Common.DebugLog("handleMessage what 1 ");
- setIGE300Interface();
- }
- }
- };
- public void setIGE300Interface() {
- try {
- Common.DebugLog("setIGE300Interface");
- mIGW300 = new IGW300(this, mWallPadAPI);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setIGE300Interface()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 외출모드 연동
- private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
- try {
- bSmartSwitch485ComebackMode = false;
- String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
- WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
- String outLinkCtrl = wd.GetOutModeLinkDevice();
- if (BedMode == true)
- outLinkCtrl = wd.GetInBedLinkDevice();
- wd.closeDB();
- // 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
- if (WallpadUI == false) {
- if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
- {
- Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
- CallElevatorBtn(false);
- }
- }
- if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
- {
- Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
- }
- if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
- {
- Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
- }
- if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
- {
- Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
- }
- if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
- {
- Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e("YSKIM", e.toString());
- }
- }
- // 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
- // 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
- private boolean bSmartSwitch485ComebackMode = false;
- private void ModeReleaseCtrlWorking(boolean bBedMode) {
- try {
- if (bSmartSwitch485ComebackMode == true) return;
- String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
- WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
- String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
- if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
- wd.closeDB();
- if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
- // 일괄소등 해제
- Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
- }
- if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
- // 환기동작
- Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
- }
- if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
- // 난방 외출모드 해제
- Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
- }
- if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
- // 웰컴조명 켜기
- Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
- // 웰컴조명 Handler 실행
- WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private Handler WelcomeLightHandler = new Handler() {
- int LightOnCount = 0;
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- try {
- if (LightOnCount == 0) {
- Log.d("TAG", "[WelcomeLightHandler] - START !!!");
- }
- // 일괄소등 해제이면
- if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
- Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
- WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
- } else {
- WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
- LightOnCount++;
- Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
- if (LightOnCount > 10) {
- Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
- LightOnCount = 0;
- WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e1) {
- Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
- //e1.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e1);
- }
- } else if (msg.what == 1) {
- try {
- Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
- mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
- LightOnCount = 0;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e1) {
- Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
- //e1.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e1);
- }
- } else if (msg.what == 2) {
- // Do Nothing
- Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
- WelcomeLightHandler.removeMessages(0);
- }
- }
- };
- //방범 및 알람 상태 확인 Resume 시 처리
- private void CheckMainStatus() {
- //try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
- try {
- final String packageName = "com.artncore.apps.ic_wallpad";
- final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
- //CallAppRun = getForegroundAPK().equals(packageName);
- boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- int alarmstate = SetData.GetAlarmStatus();
- SetData.closeDB();
- Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
- if (alarmstate == WallpadStatusData.ALARM_NONE) {
- Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
- return;
- } else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
- if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
- int base = 7000;
- int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
- int Menu_Start_Id = 0;
- SetData = new WallpadStatusData(getApplicationContext());
- int alarmtype = SetData.GetAlarmType();
- SetData.closeDB();
- switch (alarmtype) {
- case WallpadStatusData.ALARM_ALERT:
- Menu_Start_Id = Menu_Id_List[1];
- break;
- case WallpadStatusData.ALARM_EMM:
- Menu_Start_Id = Menu_Id_List[0];
- break;
- case WallpadStatusData.ALARM_EVAC:
- Menu_Start_Id = Menu_Id_List[3];
- break;
- case WallpadStatusData.ALARM_INVADE:
- Menu_Start_Id = Menu_Id_List[2];
- break;
- case WallpadStatusData.ALARM_HEATING_LEAK:
- Menu_Start_Id = Menu_Id_List[4];
- break;
- default:
- Menu_Start_Id = Menu_Id_List[1];
- break;
- }
- if (Menu_Start_Id > 0) {
- /*
- * 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
- * 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
- * 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
- * "RESUME"을 전달한다.
- */
- Intent newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(newintent);
- return;
- }
- } else if (alarmstate == WallpadStatusData.GUARD_OUT) {
- if (OutModeRunAppRun == true) {
- Log.d(TAG, "already outmoderun app running !!!!");
- return;
- }
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- int sensor = devset.Get_Sensor_Set();
- devset.closeDB();
- int base = 7000;
- int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
- int Menu_Start_Id = 0;
- int Menu_Start_Option = 1;
- if (sensor > 0) {
- WallPadInterface wpifc = new WallPadInterface();
- int[] SensorInfoDB;
- int inSen = 0;
- int outSen = 0;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
- if (SensorInfoDB[0] == 1) {
- // 내부동체가 사용함이면 상태 검사
- inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- }
- if (SensorInfoDB[1] == 1) {
- // 외부동체가 사용함이면 상태 검사
- outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- }
- // int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
- // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
- ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
- ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
- Intent newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(newintent);
- return;
- }
- }
- base = 8000;
- Menu_Id_List = new int[]{base + 11};
- Menu_Start_Id = base + 11;
- Menu_Start_Option = -1;
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
- intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- } else if (alarmstate == WallpadStatusData.GUARD_IN) {
- WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- int sensor = devset.Get_Sensor_Set();
- devset.closeDB();
- int base = 7000;
- int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
- int Menu_Start_Option = 1;
- if (sensor > 0) {
- WallPadInterface wpifc = new WallPadInterface();
- int[] SensorInfoDB;
- int outSen = 0;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
- if (SensorInfoDB[1] == 1) {
- // 외부동체가 사용함이면 상태 검사
- outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- }
- // int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
- if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
- ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
- Intent newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- newintent.putExtra("MENU_DETAIL_INFO", "bugout");
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(newintent);
- return;
- }
- }
- } else if (alarmstate == WallpadStatusData.ALARM_STOP) {
- WallPadInterface wpifc = new WallPadInterface();
- wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
- return;
- } else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
- int base = 4000;
- int Menu_Start_Id = 0;
- int[] Menu_Id_List = new int[]{base + 11, base + 21};
- Menu_Start_Id = base + 11;
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
- intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
- intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- return;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] CheckMainStatus()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- // WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
- // int StatusVal = devset.GetDeviceSetted("피난사다리");
- // if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
- // {
- // WallPadInterface wpifc = new WallPadInterface();
- // int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
- //
- // if (fleeSensor > 0)
- // {
- // int base = 7000;
- // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
- // int Menu_Start_Option = 1;
- // Intent newintent = new Intent(Intent.ACTION_MAIN);
- // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- // newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
- // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- // newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
- // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- // startActivity(newintent);
- // devset.closeDB();
- // return;
- // }
- // }
- //
- // StatusVal = devset.GetDeviceSetted("알람발생");
- // if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
- // {
- // WallPadInterface wpifc = new WallPadInterface();
- // int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
- //
- // if (AlarmSensor > 0)
- // {
- // int base = 7000;
- // int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
- // int Menu_Start_Option = 1;
- // Intent newintent = new Intent(Intent.ACTION_MAIN);
- // newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
- // newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
- // newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
- // newintent.putExtra("MENU_DETAIL_INFO", "emergency");
- // newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- // newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
- // startActivity(newintent);
- // devset.closeDB();
- // return;
- // }
- //
- // }
- // devset.closeDB();
- }
- /**
- * 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
- *
- * @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
- */
- public boolean GetUseIlgalControlForAdmin() {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
- String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
- devSet.closeDB();
- boolean result = false;
- if (MetringDB != null) {
- try {
- String devInfo = MetringDB[1];
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] MetringInfo = devInfo.split("_");
- if (MetringInfo[3].equals("사용함") == true) {
- result = true;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- return result;
- }
- class SendLHGWCheck extends Thread {
- private iMAP_hn_config_read m_HnGWConfigRead = null;
- private iMAPEmptyMessage m_HnGWEmptyMsg = null;
- private boolean retSucces = false;
- private int retryCount = 0;
- public SendLHGWCheck() {
- m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
- m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
- retryCount = 0;
- }
- public void run() {
- try {
- try {
- Thread.sleep(2000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- for (int i = 0; i < 10; i++) {
- m_HnGWConfigRead.DoWork();
- m_HnGWConfigRead.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- retSucces = true;
- Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
- }
- @Override
- public void ProcError() {
- }
- @Override
- public void ProcDoing() {
- // TODO Auto-generated method stub
- }
- });
- if (retSucces == true)
- break;
- retryCount++;
- try {
- Thread.sleep(3000);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- m_HnGWEmptyMsg.DoWork();
- m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
- }
- @Override
- public void ProcError() {
- Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
- }
- @Override
- public void ProcDoing() {
- // TODO Auto-generated method stub
- Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
- }
- });
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- //Reset Handler
- private Handler mResetHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
- Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
- if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
- Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
- if (NowMainStatus == false) {
- Log.d(TAG, "[mResetHandler] ResetCount will be 1");
- ResetCount = 1;
- }
- ResetCount++;
- NowMainStatus = true;
- if (ResetCount == 30) {
- mResetHandler.sendEmptyMessageDelayed(1, 10);
- } else {
- mResetHandler.sendEmptyMessageDelayed(0, 1000);
- }
- } else {
- if (NowMainStatus == true) {
- Log.d(TAG, "[mResetHandler] ResetCount will be 1");
- ResetCount = 1;
- }
- ResetCount++;
- NowMainStatus = false;
- if (ResetCount == 180) {
- // 3분
- mResetHandler.sendEmptyMessageDelayed(1, 10);
- } else {
- mResetHandler.sendEmptyMessageDelayed(0, 1000);
- }
- }
- } else if (msg.what == 1) {
- Log.d(TAG, "[mResetHandler] Do Reset!!!");
- setDefaultLauncher();
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
- getApplicationContext().sendBroadcast(intent);
- }
- }
- };
- // 통화주체를 다루는 enum
- public enum CALLOWNER {
- NONE,
- WALLPAD,
- SUB_WALLPAD,
- KITCHEN_TV,
- BATH_PHONE,
- BATH_TV,
- UNIVERSAL_DEVICE,
- ERROR;
- }
- public enum CALLEVENTTYPE {
- RECEIVE_CALL, // 호출 수신 (호출 수신)
- TRYING_CALL, // 호출 시도중 (호출 발신)
- RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
- RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
- REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
- REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
- CONNECT_CALL, // 통화 시작
- TERMINATE_CALL, // 통화 종료
- CANCEL_CALL, // 호출 취소
- CANCEL_CALL_2ND, // 멀티콜 호출 취소
- REJECT_CALL, // 호출수신 거절
- REJECT_BUSY_CALL, // 통화중 호출수신 거절
- FORWARD_CALL, // 착신전환 설정
- CALLERID, // Caller ID
- TIMEOUT_1STCALL, // 1st Call Timeout
- TIMEOUT_2NDCALL, // 2nd Call Timeout
- TIMEOUT_3RDCALL, // 3rd Call Timeout
- MOIP_VIDEO_SET, // MoIP 영상통화 설정
- DOOR_OPEN, // 문열림 설정
- PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
- PSTN_DTMF, // PSTN DTMF 수신
- DETECT_STRANGER, // 거동수상자 발생
- NONE;
- public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
- try {
- if (value.equals(RECEIVE_CALL.toString())) {
- return RECEIVE_CALL;
- } else if (value.equals(TRYING_CALL.toString())) {
- return TRYING_CALL;
- } else if (value.equals(RECEIVE_CALL_2ND.toString())) {
- return RECEIVE_CALL_2ND;
- } else if (value.equals(RECEIVE_CALL_ACK.toString())) {
- return RECEIVE_CALL_ACK;
- } else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
- return REQUEST_FRONT_MONITORING;
- } else if (value.equals(CONNECT_CALL.toString())) {
- return CONNECT_CALL;
- } else if (value.equals(TERMINATE_CALL.toString())) {
- return TERMINATE_CALL;
- } else if (value.equals(CANCEL_CALL.toString())) {
- return CANCEL_CALL;
- } else if (value.equals(REJECT_CALL.toString())) {
- return REJECT_CALL;
- } else if (value.equals(REJECT_BUSY_CALL.toString())) {
- return REJECT_BUSY_CALL;
- } else if (value.equals(FORWARD_CALL.toString())) {
- return FORWARD_CALL;
- } else if (value.equals(CALLERID.toString())) {
- return CALLERID;
- } else if (value.equals(TIMEOUT_1STCALL.toString())) {
- return TIMEOUT_1STCALL;
- } else if (value.equals(TIMEOUT_2NDCALL.toString())) {
- return TIMEOUT_2NDCALL;
- } else if (value.equals(TIMEOUT_3RDCALL.toString())) {
- return TIMEOUT_3RDCALL;
- } else if (value.equals(MOIP_VIDEO_SET.toString())) {
- return MOIP_VIDEO_SET;
- } else if (value.equals(DOOR_OPEN.toString())) {
- return DOOR_OPEN;
- } else if (value.equals(PSTN_RING.toString())) {
- return PSTN_RING;
- } else if (value.equals(PSTN_DTMF.toString())) {
- return PSTN_DTMF;
- } else if (value.equals(DETECT_STRANGER.toString())) {
- return DETECT_STRANGER;
- } else if (value.equals(NONE.toString())) {
- return NONE;
- } else {
- return null;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", "", re);
- return null;
- } catch (Exception e) {
- Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", "", e);
- return null;
- }
- }
- }
- public enum CALLTYPE {
- NONE,
- FRONT,
- RESIDENCE,
- LOBBY,
- GUARD,
- PSTN,
- IHUB,
- ERROR,
- }
- public static class CALLTRIGGER {
- public static String CALLOWNER = "CALLOWNER";
- public static String CALLEVENTTYPE = "CALLEVENTTYPE";
- public static String CALLTYPE = "CALLTYPE";
- public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
- public enum SOURCE {
- USER,
- CALL_RECEIVE,
- SUBPHONE
- }
- public enum TYPE {
- MENU,
- FRONT,
- LOBBY,
- GUARD,
- RESIDENCE,
- PSTN
- }
- }
- String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
- int TAB_TALKFRONT = 130011;
- public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
- try {
- Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
- if (!bWallPadCallLive) {
- sendLCDBacklightStatus(true);
- // 통화어플을 실행시킨다.
- if (nAlramStatus != WallpadStatusData.GUARD_OUT)
- Common.SendAppFinishReqBR(getApplicationContext());
- ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
- Intent mIntent = new Intent(Intent.ACTION_MAIN);
- mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
- mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
- mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
- mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mIntent.setComponent(mComponentName);
- startActivity(mIntent);
- playFrontBell(eCallOwner, eEventType, eCallType);
- } else {
- Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
- // if (getUseSmartDoorCam()) {
- // sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
- // }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] runCallMainActivity()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- //add KSJ 2021.11.02
- public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
- try {
- if (!bWallPadCallLive || m_bWallpadCallScreen) {
- // 통화어플을 실행시킨다.
- Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
- sendLCDBacklightStatus(true);
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- if (nAlramStatus != WallpadStatusData.GUARD_OUT)
- Common.SendAppFinishReqBR(getApplicationContext());
- if(m_bWallpadCallScreen)
- Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
- ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
- Intent mIntent = new Intent(Intent.ACTION_MAIN);
- mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
- mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
- mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
- mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
- mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mIntent.setComponent(mComponentName);
- startActivity(mIntent);
- Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
- } else {
- Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] runCallMainActivity()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- //~add KSJ
- private String getTopActivity() {
- try {
- ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
- // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
- ComponentName mComponentName = mTaskInfo.get(0).topActivity;
- // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
- return mComponentName.getPackageName();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getTopActivity()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
- try {
- if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
- WallPadInterface Wiface = new WallPadInterface();
- Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
- Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private class AfterTransactionTodoListData {
- String Title;
- int Valueint;
- String ValueString;
- private AfterTransactionTodoListData(String title, int valueint, String valueString) {
- Title = title;
- Valueint = valueint;
- ValueString = valueString;
- }
- }
- /**
- * 주차정보 주차서버로부터 얻어오도록하는 intent 전송
- **/
- public void SendGetParkingInfoIntent() {
- Intent iIntent = new Intent();
- iIntent.setAction(define.NOTIFY_ACNAME);
- iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
- this.sendBroadcast(iIntent);
- }
- /**
- * 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
- **/
- public Handler SendParkingInfoIntentAfter20min = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- SendGetParkingInfoIntent();
- }
- }
- };
- /**
- * RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
- **/
- public Handler mWallPadOutmodeSleepHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
- }
- }
- };
- // Handler
- public final class HANDLERMSG {
- public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
- public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
- public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
- public final static int CALLAPP_FINISHING_END = 300;
- public final static int FRONTCAM_PLAY_DINGDONG = 400;
- }
- public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
- public void handleMessage(Message msg) {
- Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
- switch (msg.what) {
- case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
- bGlobalScreenRun = true;
- break;
- case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
- bGlobalScreenRun = false;
- break;
- case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
- break;
- case HANDLERMSG.CALLAPP_FINISHING_END:
- // bBlockCallEvent = false;
- break;
- case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
- int time = Sound().PlayMent(SND.call.DINGDONG);
- Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
- if (time < 0) time = 2088;
- mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
- break;
- default:
- Log.v(TAG, "iMAPServerHandler : " + msg.what);
- break;
- }
- }
- };
- public void sendHandlerMsg(int what, int arg1, int arg2) {
- try {
- Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
- Message HandleMsg = iMAPServerHandler.obtainMessage();
- HandleMsg.what = what;
- HandleMsg.arg1 = arg1;
- HandleMsg.arg2 = arg2;
- iMAPServerHandler.sendMessage(HandleMsg);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
- try {
- Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
- Message HandleMsg = iMAPServerHandler.obtainMessage();
- HandleMsg.what = what;
- HandleMsg.arg1 = arg1;
- HandleMsg.arg2 = arg2;
- iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- int mSensitivity = 0, mDuration = 0;
- int MIN_SENSOR_SENSITIVITY = 1;
- int MAX_SENSOR_SENSITIVITY = 5;
- int MIN_SENSOR_DURATION = 30;
- int MAX_SENSOR_DURATION = 250;
- int DEFAULT_SENSOR_SENSITIVITY = 3;
- int DEFAULT_SENSOR_DURATION = 60;
- private final int COMPONENT_USE = 1;
- /**
- * 스마트현관카메라 사용여부 판별
- */
- private boolean getUseSmartDoorCam() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
- mWallpadDeviceSet.closeDB();
- if (nFrontCam[0] == COMPONENT_USE) {
- if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
- Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
- return true;
- } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
- Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
- return true;
- } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
- Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
- return true;
- } else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
- Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
- return true;
- } else {
- Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
- return false;
- }
- } else {
- Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
- return false;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getUseSmartDoorCam()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- private int getSmartDoorCamType() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
- mWallpadDeviceSet.closeDB();
- if (nFrontCam[0] == COMPONENT_USE) {
- if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
- return nFrontCam[1];
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getSmartDoorCamType()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return -1;
- }
- /**
- * 방문객원격통화 솔루션 사용여부 판별
- */
- private boolean getRemoteCallUseInfo() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
- if (mWallpadDeviceSet != null) {
- String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
- if (astrRemoteCall != null) {
- if (astrRemoteCall[1].contains("사용함")) return true;
- } else {
- Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
- }
- }
- mWallpadDeviceSet.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- /*
- 에너지 사용량 화면을 위한 실시간 검침기 정보 관리
- */
- private RealTimeMeterAPI mRealTimeMeterAPI;
- private DataClasses.RealTimeMeter mRealTimeMeterData = null;
- private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
- public Thread saveRealmeterDataThread = null;
- private void startRealtimemeterInfo() {
- try {
- // 영업샘플 모드 판단
- if (Common.GetDeviceSampleMode(getApplicationContext())) {
- Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
- } else {
- Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
- // 실시간 검침기 사용유무 판단
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
- mWallpadDeviceSet.closeDB();
- boolean bRealtimemeterUsage = false;
- int nRealtimemeterCntDB = -99;
- if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
- // 실시간 검침 사용함
- bRealtimemeterUsage = true;
- nRealtimemeterCntDB = naRealtimemtInfo[1];
- initRealtimemeterFunctionHandler.sendEmptyMessage(0);
- } else {
- // 실시간 검침 사용하지 않음
- bRealtimemeterUsage = false;
- }
- Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] startRealtimemeterInfo()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void startSmartIoTCamInfo() {
- try {
- // 영업샘플 모드 판단
- if (Common.GetDeviceSampleMode(getApplicationContext())) {
- Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
- } else {
- Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
- if (getUseSmartDoorCam()) {
- initSmartIoTFunctionHandler.sendEmptyMessage(0);
- } else {
- Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void startDistributionPanel() {
- try {
- // 영업샘플 모드 판단
- if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
- mWallpadDeviceSet.closeDB();
- if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
- initSmartDistributionPanelHandler.sendEmptyMessage(0);
- if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
- initKNXDistributionPanelHandler.sendEmptyMessage(0);
- else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
- } else {
- Log.w(TAG, "[startDistributionPanel] Not supported!!!");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] startDistributionPanel()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // =================================================================================================
- // [[ Device ]] region
- // =================================================================================================
- /**
- * 디바이스 API 를 Load 한다.
- *
- * @param wpapi - 생성시 전달받은 WallPadAPI
- * @return (int) - >=0 : 성공, <0 : 실패
- */
- private int loadRealtimemeterAPI(WallPadAPI wpapi) {
- // 1. Mode Check
- if (Common.GetDeviceSampleMode(getApplicationContext())) {
- Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
- return -1;
- }
- Log.i(TAG, "[loadRealtimemeterAPI] - Start");
- // 2. wpapi Check
- if (wpapi == null) {
- Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
- return -2;
- }
- // 3. Load API
- Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
- try {
- mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -100;
- } catch (Exception e) {
- Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -100;
- }
- if (mRealTimeMeterAPI == null) {
- Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
- return -4;
- }
- Log.i(TAG, "[loadRealtimemeterAPI] - OK");
- return 0;
- }
- /**
- * 제어기 상태를 가져온다.
- *
- * @param real - (boolean) true : 실시간 , false : 가장최근
- * @return (int) - >=0 : 성공, <0 : 실패
- */
- @SuppressWarnings("unused")
- private int updateRealtimemeterData(boolean real) {
- try {
- // 1. Api Load Check
- if (mRealTimeMeterAPI == null) {
- Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
- return -1;
- }
- // 2. reflash
- try {
- int ret = mRealTimeMeterAPI.Refresh(real);
- if (ret < 0) {
- Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
- return -2;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -100;
- } catch (Exception e) {
- Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -100;
- }
- // 3. Range Check
- if (mRealTimeMeterAPI.data == null) {
- Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
- return -9;
- }
- if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
- Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
- return -10;
- }
- if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
- Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
- return -11;
- }
- if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
- Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
- return -12;
- }
- if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
- Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
- return -13;
- }
- if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
- Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
- return -14;
- }
- // 4. Data Copy
- mRealTimeMeterData = mRealTimeMeterAPI.data;
- // 5. Debug msg
- if (DEBUG_REALMETER_DATA_LOG_ON) {
- Log.i(TAG, mRealTimeMeterData.ToDebugString());
- Log.i(TAG, "[updateRealtimemeterData] - OK");
- }
- return 0;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -99;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -99;
- }
- }
- /**
- * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
- * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
- * 본 딜레이 코드를 임시로 적용한다.
- */
- @SuppressLint("HandlerLeak")
- protected Handler initRealtimemeterFunctionHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
- if (msg.what == 0) {
- if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
- if (updateRealtimemeterData(false) == 0) {
- initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
- } else {
- initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
- }
- } else {
- Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
- initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
- }
- } else if (msg.what == 1) {
- Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
- if (mRealTimeMeterAPI != null) {
- // Device_BrRegistration(true);
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
- mWallpadDeviceSet.closeDB();
- if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
- saveRealmeterDataThread = new saveRealmeterData();
- saveRealmeterDataThread.start();
- }
- // RemoveUsedData();
- // ShowUsedDataGraph();
- }
- }
- }
- };
- protected Handler initSmartDistributionPanelHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
- if (msg.what == 0) {
- if (mWallPadAPI.Check_Connect())
- initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
- else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
- } else if (msg.what == 1) {
- Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
- mSdbAPI = mWallPadAPI.Get_SdbController();
- mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
- mSdb_LivingRoomLightAPI.Refresh();
- }
- }
- };
- protected Handler initKNXDistributionPanelHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
- if (msg.what == 0) {
- if (mWallPadAPI.Check_Connect())
- initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
- else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
- } else if (msg.what == 1) {
- Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
- mKnxAPI = mWallPadAPI.Get_KnxController();
- mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
- mKnx_LivingRoomLightAPI.Refresh();
- }
- }
- };
- protected Handler initSmartIoTFunctionHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
- if (msg.what == 0) {
- if (mWallPadAPI.Check_Connect())
- initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
- else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
- } else if (msg.what == 1) {
- Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
- mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
- // 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
- String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
- Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
- // 거동수상자 녹화를 위한 자동 On 기능 비활성화
- ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
- ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
- }
- }
- };
- // 스마트현관카메라 MODE 제어
- private void ctrlSmartIOTCamStatusMode(byte mode) {
- try {
- Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
- if (mSmartKeyRfDoorAPI != null) {
- int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
- Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
- } else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 스마트현관카메라 LED 상태 제어
- private void ctrlSmartIOTCamLEDMode(byte mode) {
- try {
- Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
- if (mSmartKeyRfDoorAPI != null) {
- int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
- Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
- } else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 현관카메라 거동수상자 감지시간
- private byte getSmartDoorCamDuration() {
- try {
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
- byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
- wallpadDeviceSet.closeDB();
- Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
- return duration;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return (byte) 0x05;
- }
- // =================================================================================================
- // [[ Thread ]] region
- // =================================================================================================
- /**
- * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
- * 10분에 한번씩 저장
- */
- @SuppressLint("UseValueOf")
- class saveRealmeterData extends Thread {
- @Override
- public void run() {
- super.run();
- Log.i(TAG, "[saveRealmeterData] ========== START ==========");
- int ret;
- wallpaddbmgr WallpadDBMGRforThread = null;
- while (true) {
- try {
- Thread.sleep(1000 * 60 * 3); //3분마다
- if (mRealTimeMeterAPI != null) {
- ret = mRealTimeMeterAPI.Refresh(false);
- if (ret == 0) {
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
- WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
- WallpadDBMGRforThread.InsertRealTimeMeterData(
- new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
- new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
- new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
- new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
- new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
- new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
- new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
- new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
- new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
- new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
- );
- int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
- Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
- if (tempInt > 6000) {
- WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
- }
- WallpadDBMGRforThread.closeDB();
- } else {
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
- }
- } else {
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
- }
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- if (WallpadDBMGRforThread != null) {
- WallpadDBMGRforThread.closeDB();
- }
- Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
- //e1.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e1);
- }
- }
- }
- }
- /**
- * 단지서버 2.0 사용여부
- *
- * @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
- **/
- public boolean NewServerUse() {
- WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
- if (SetData != null) {
- String serverVesionInfo = SetData.GetServerVer();
- SetData.closeDB();
- if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
- return true;
- }
- }
- return false;
- }
- /**
- * 단지서버2.0 적용시에만 사용한다.
- * 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
- * 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
- * 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
- **/
- String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
- String REMOTETYPE_SVR2WEB = "danji_web_control";
- String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
- public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
- try {
- // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
- // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
- if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
- NodeList mNodeList = doc.getElementsByTagName("device_info");
- Node mNode = mNodeList.item(0);
- if (mNode != null) {
- String alias = "null", twinid = "null";
- NamedNodeMap attrsParam = mNode.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("alias"))
- alias = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("twinid"))
- twinid = attr.getNodeValue();
- }
- //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
- if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
- Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
- return MOBILE_USER_AUTH_PASSED;
- }
- WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
- int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
- mWallpadMobileDeviceData.closeDB();
- if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
- else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
- strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
- strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- NodeList mNodeList = doc.getElementsByTagName("password_info");
- Node mNode = mNodeList.item(0);
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
- mWallpadStatusData.closeDB();
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
- if (!checkPWValidation(strSavedWebCtrlPW)) {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
- strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- if (mNode != null) {
- String strReceivedPW = "000000";
- NamedNodeMap attrsParam = mNode.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("password"))
- strReceivedPW = attr.getNodeValue();
- }
- if (!checkPWValidation(strReceivedPW)) {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
- strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
- Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
- return WEB_USER_AUTH_PASSED;
- } else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
- strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
- strReplyMsg += " result=\"fail\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else {
- Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
- strReplyMsg += " result=\"deny\">\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
- try {
- // Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
- // Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
- if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
- NodeList mNodeList = ele.getElementsByTagName("device_info");
- Node mNode = mNodeList.item(0);
- if (mNode != null) {
- String alias = "null", twinid = "null";
- NamedNodeMap attrsParam = mNode.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("alias"))
- alias = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("twinid"))
- twinid = attr.getNodeValue();
- }
- //현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
- if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
- Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
- return MOBILE_USER_AUTH_PASSED;
- }
- WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
- int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
- mWallpadMobileDeviceData.closeDB();
- if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
- else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
- strReplyMsg += " \"none\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
- strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- NodeList mNodeList = ele.getElementsByTagName("password_info");
- Node mNode = mNodeList.item(0);
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
- mWallpadStatusData.closeDB();
- if (!checkPWValidation(strSavedWebCtrlPW)) {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
- strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- if (mNode != null) {
- String strReceivedPW = "000000";
- NamedNodeMap attrsParam = mNode.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("password"))
- strReceivedPW = attr.getNodeValue();
- }
- if (!checkPWValidation(strReceivedPW)) {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
- strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
- Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
- return WEB_USER_AUTH_PASSED;
- } else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
- strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else {
- Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
- strReplyMsg += " \"fail\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } else {
- Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
- strReplyMsg += " \"deny\" >\r\n </service>\r\n</imap>";
- return strReplyMsg;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
- private boolean checkPWValidation(String strPW) {
- try {
- // null 확인
- if (strPW == null) {
- Log.w(TAG, "[checkPWValidation] strPW is null!!");
- return false;
- }
- // 입력된 비밀번호 길이 확인
- if (strPW.length() != 6) {
- Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
- return false;
- }
- // 사전 금지된 비밀번호 확인
- for (int i = 0; i < astrPreventedPWs.length; i++) {
- if (strPW.contains(astrPreventedPWs[i])) {
- Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
- return false;
- }
- }
- /*// 연속된 비밀번호 확인
- int nSerialNoCnt = 0;
- int nCompareNo = 0;
- int[] naPW = new int[strPW.length()];
- for (int i = 0; i < naPW.length; i++)
- {
- naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
- Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
- if (i ==0) {
- nCompareNo = naPW[i];
- nCompareNo++;
- }
- else if (0 < i && i < 6) {
- if (nCompareNo == naPW[i]) nSerialNoCnt++;
- nCompareNo++;
- }
- else {
- Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
- }
- }
- if (nSerialNoCnt > 3) {
- Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
- return false;
- }*/
- // 동일한 번호 5회이상 입력 확인
- int nSameNoCnt = 0;
- for (int i = 0; i < strPW.length() - 1; i++) {
- if (strPW.charAt(i) == strPW.charAt(i + 1)) {
- nSameNoCnt++;
- }
- }
- if (nSameNoCnt > 4) {
- Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
- return false;
- }
- // 동, 호정보 확인
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
- DBMGR.closeDB();
- String strDong = addr.Dong;
- String strHo = addr.Ho;
- Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
- if (strPW.substring(0, 4).contains(strDong)) {
- Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
- return false;
- }
- if (strPW.substring(0, 4).contains(strHo)) {
- Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
- return false;
- }
- return true;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- public String iCMDProcOnePass(Element ele) {
- String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
- String[] strDeviceInfo = {"null", "null"}; // alias, twinid
- String strAction = "null", strTargetLobbyIP = "null";
- try {
- // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
- String retStr = CheckiCMDProc("remote_access_onepass");
- if (retStr != null)
- return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
- // 단지서버 2.0 사용여부 확인
- if (!NewServerUse()) {
- return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
- }
- // 메시지 송신지 구분
- NodeList items = ele.getElementsByTagName("target");
- Node item = items.item(0);
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("name"))
- strTarget[0] = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("id"))
- strTarget[1] = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
- strTarget[2] = attr.getNodeValue();
- }
- }
- // 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
- if (NewServerUse()) {
- String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
- if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
- if (ServerCheckResult.contains("fail"))
- return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
- else if (ServerCheckResult.contains("deny"))
- return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
- else if (ServerCheckResult.contains("none"))
- return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
- else
- return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
- }
- }
- NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
- Node itemDeviceParam = itemsDeviceParam.item(0);
- if (itemDeviceParam != null) {
- NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("alias"))
- strDeviceInfo[0] = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("twinid"))
- strDeviceInfo[1] = attr.getNodeValue();
- }
- } else {
- return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
- }
- // 명령어 구분
- NodeList itemsaction = ele.getElementsByTagName("action");
- Node itemaction = itemsaction.item(0);
- Node text = itemaction.getFirstChild();
- strAction = text.getNodeValue();
- strAction = trimquotation(strAction);
- // 문열림 타겟 로비폰 IP
- NodeList itemsParam = ele.getElementsByTagName("params");
- Node itemParam = itemsParam.item(0);
- if (itemParam != null) {
- NamedNodeMap attrsParam = itemParam.getAttributes();
- for (int j = 0; j < attrsParam.getLength(); j++) {
- Node attr = attrsParam.item(j);
- if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
- strTargetLobbyIP = attr.getNodeValue();
- }
- }
- Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
- if (strAction.equalsIgnoreCase("authorize_request")) {
- sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
- return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
- } else {
- return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
- }
- }
- public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
- try {
- String strReplyXml = XMLHeader;
- strReplyXml += " <service type=\"reply\" name=\"remote_access_onepass\" result=\"" + strResult + "\">\n";
- strReplyXml += " <target name=\"" + strTarget[0] + "\" id= \"" + strTarget[1] + "\" msg_no=\"" + strTarget[2] + "\"/>\n";
- strReplyXml += " <device_info alias=\"" + strDeviceInfo[0] + "\" twinid=\"" + strDeviceInfo[1] + "\"/>\n";
- strReplyXml += " <action>\"" + strAction + "\"</action>\n";
- strReplyXml += " </service>\n";
- strReplyXml += "</imap>";
- return strReplyXml;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return "ERROR";
- } catch (Exception e) {
- Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "ERROR";
- }
- }
- public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
- try {
- Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
- iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
- miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
- miMAPLobbyOnePass.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
- }
- @Override
- public void ProcError() {
- Log.i(TAG, "[sendLobbyOnePass.ProcError]");
- }
- @Override
- public void ProcDoing() {
- Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
- }
- });
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public String iCMDProcResidentSafety(Element ele) {
- try {
- // 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
- String retStr = CheckiCMDProc("check_resident_safety");
- if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
- // 단지서버 2.0 사용여부 확인
- if (!NewServerUse()) {
- return makeReply_check_resident_safety("deny", null, null, null);
- }
- // 거주자 안전 확인 사용 여부
- if (!bEnableResidentSafetyCheck) {
- return makeReply_check_resident_safety("deny", null, null, null);
- }
- String strSecurity = getSecurityMode();
- String strTouch = getTimeStamp_ScreenTouched();
- String strMagnetic = getTimeStamp_Magnetic();
- return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return makeReply_check_resident_safety("fail", null, null, null);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return makeReply_check_resident_safety("fail", null, null, null);
- }
- }
- public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
- try {
- String strReplyXml = XMLHeader;
- strReplyXml += " <service type=\"reply\" name=\"check_resident_safety\" result=\"" + strResult + "\">\n";
- if (strResult.equalsIgnoreCase("ok")) {
- strReplyXml += " <security>\"" + strSecurity + "\"</security>\n";
- strReplyXml += " <touch>\"" + strTouch + "\"</touch>\n";
- strReplyXml += " <magnetic>\"" + magnetic + "\"</magnetic>\n";
- }
- strReplyXml += " <message>\"null\"</message>\n";
- strReplyXml += " </service>\n";
- strReplyXml += "</imap>";
- return strReplyXml;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return "ERROR";
- } catch (Exception e) {
- Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "ERROR";
- }
- }
- private void saveBlackoutStatus(boolean bOccurred) {
- try {
- Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
- SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
- SharedPreferences.Editor mEditor = mSharedPreferences.edit();
- mEditor.putBoolean("status", bOccurred);
- mEditor.commit();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private boolean getBlackoutStatus() {
- try {
- SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
- return mSharedPreferences.getBoolean("status", false);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getBlackoutStatus()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- /**
- * JEFF, 2019.12.25
- * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
- * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
- * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
- * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
- */
- int MAX_WALLPADCALL_LIVE_CNT = 1;
- int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
- public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
- public static boolean m_bWallpadCallScreen = false;
- int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
- Handler handlerCheckWallPadCallLive = new Handler() {
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- sendWallPadCallLiveBR_Request();
- handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
- }
- };
- private void sendWallPadCallLiveBR_Request() {
- try {
- // Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
- Intent mIntent = new Intent();
- mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
- getApplicationContext().sendBroadcast(mIntent);
- if (nWallPadCallACKCnt >= 0) {
- nWallPadCallACKCnt--;
- } else {
- bWallPadCallLive = false;
- Common.bWallPadCallLive = bWallPadCallLive;
- }
- if (bWallPadCallLive != getCallAppRunning()) {
- setCallAppRunning(bWallPadCallLive);
- }
- //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public boolean getWallpadCallScrean(int iScreen)
- {
- boolean bRet = false;
- try {
- switch (iScreen) {
- case API_Menu.SubMenuCall.Door:
- bRet = false;
- break;
- case API_Menu.SubMenuCall.Lobby:
- bRet = false;
- break;
- case API_Menu.SubMenuCall.Guard:
- bRet = false;
- break;
- case API_Menu.SubMenuCall.Neighbor:
- bRet = false;
- break;
- case API_Menu.SubMenuCall.PSTN:
- bRet = false;
- break;
- case API_Menu.SubMenuCall.CallList:
- bRet = true;
- break;
- case API_Menu.SubMenuCall.Visitor:
- bRet = true;
- break;
- default:
- bRet = false;
- break;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- return bRet;
- }
- BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- try {
- String strActionName = intent.getAction();
- int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
- // Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
- if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
- bWallPadCallLive = true;
- Common.bWallPadCallLive = bWallPadCallLive;
- nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
- m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
- Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
- } else {
- Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- };
- static class CALLCTRLHANDLERMSG {
- static final int RELEASE_BLOCK_FRONTCALL = 100;
- }
- boolean bBlockFrontCall = false;
- Handler handlerCallCtrl = new Handler() {
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- int nMSG = msg.what;
- switch (nMSG) {
- case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
- bBlockFrontCall = false;
- break;
- }
- }
- };
- /**
- * JEFF, 2019.12.31
- * WallPadCall 실행여부를 DB에 저장한다.
- * WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
- * 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
- */
- public void setCallAppRunning(boolean bRunning) {
- try {
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- mWallpadStatusData.SetCallAPKStatus(bRunning);
- mWallpadStatusData.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private boolean getCallAppRunning() {
- boolean bRunning = false;
- try {
- WallpadStatusData WallpadStatusData = new WallpadStatusData(getApplicationContext());
- bRunning = WallpadStatusData.GetCallAPKStatusRunning();
- WallpadStatusData.closeDB();
- // Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
- return bRunning;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.d(TAG, "[Exception] getCallAppRunning()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- /**
- * 통화앱 종료코드
- */
- public void killWallPadCall() {
- try {
- Log.i(TAG, "[killWallPadCall] ===== START =====");
- // ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
- // mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
- Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
- // ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
- // aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
- // android.os.Process.killProcess(nWallPadCallPID);
- // List<ActivityManager.RunningAppProcessInfo> list = servMng.getRunningAppProcesses();
- // if(list != null){
- // for(int i=0;i<list.size();++i){
- // if("kr.co.icontrols.wallpadcall".matches(list.get(i).processName)){
- // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
- // android.os.Process.killProcess(pid);
- // }
- // }
- // }
- // ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
- // int pid = android.os.Process.getUidForName("kr.co.icontrols.wallpadcall");
- // Log.w(TAG,"[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], pid [" + pid + "]");
- // a.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
- // android.os.Process.killProcess(pid);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] killWallPadCall()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void checkForegroundActivity() {
- try {
- // 동작하는 것이 의미 없음 (WallPadMain이 최상이라고 나옴)
- ActivityManager mActivityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
- List<ActivityManager.RunningTaskInfo> mRunningTaskInfo = mActivityManager.getRunningTasks(1);
- ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
- Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkForegroundActivity()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * JEFF, 2020.01.04
- * IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
- * IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
- * - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
- * - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
- */
- static long lConnectionPeriod = 0;
- static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
- boolean bRingGeneratorRun = false;
- private void startIGW300RingGenerator() {
- try {
- Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
- if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
- bRingGeneratorRun = true;
- mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
- mIGW300RingGeneratorThread.start();
- } else
- Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] startIGW300RingGenerator()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void stopIGW300RingGenerator() {
- try {
- Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
- if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
- lConnectionPeriod = -999;
- bRingGeneratorRun = false;
- mIGW300RingGeneratorThread = null;
- } else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
- private class IGW300RingGeneratorThread extends Thread {
- public IGW300RingGeneratorThread() {
- Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
- }
- public void run() {
- try {
- Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
- if (bRingGeneratorRun)
- Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
- lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
- while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
- if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
- Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
- try {
- if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
- } catch (InterruptedException e) {
- Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- bRingGeneratorRun = false;
- Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- private void sendPSTNRingEvent(int nKeyCode) {
- try {
- Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
- KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
- Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
- intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
- intent.putExtra("keycode", nKeyCode);
- getApplicationContext().sendBroadcast(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendPSTNRingEvent()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 월패드 타입 판별
- *
- * @return bResult
- * false: 메인월패드
- * true: 서브월패드
- */
- public boolean getIsSubWallpad() {
- boolean bResult = false;
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
- String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
- mWallpadDeviceSet.closeDB();
- if (DBinfo != null) {
- if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
- else bResult = false;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getIsSubWallpad()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
- return bResult;
- }
- /**
- * JEFF, 2020.02.05
- * 월패드 비상접점 신호 사용 여부 확인
- */
- public boolean getEmergencyIOUsage() {
- boolean bResult = false;
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
- bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
- mWallpadDeviceSet.closeDB();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getEmergencyIOUsage()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
- return bResult;
- }
- /**
- * JEFF, 2020.02.05
- * 거동수상자 녹화기능 활성화 확인
- * 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
- * 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
- * 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
- */
- public boolean getStrangerRecordingManagerSetting() {
- boolean bResult = false;
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- try {
- int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
- boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
- mWallpadDeviceSet.closeDB();
- if (nFrontCam[0] == COMPONENT_USE) {
- if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
- if (bRecord) bResult = true;
- else bResult = false;
- } else bResult = false;
- } else bResult = false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- mWallpadDeviceSet.closeDB();
- } catch (Exception e) {
- mWallpadDeviceSet.closeDB();
- Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
- return bResult;
- }
- /**
- * Edited by jeff (2020.06.22)
- * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
- * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
- *
- * @param bOn
- */
- private void sendLCDBacklightStatus(boolean bOn) {
- try {
- Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
- Intent mIntent = new Intent();
- if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
- else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
- getApplicationContext().sendBroadcast(mIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 명칭 관련
- boolean bRoomNameLog = true;
- public static final int HEATING = 1;
- public static final int LIGHT = 2;
- private String[] mRoomNameList_Light = null; //조명 방 명칭
- private String[] mRoomNameList_Heating = null; //난방 방 명칭
- private String[] mDefaultRoomNameList = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
- private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
- private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
- private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
- private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
- /**
- * DB 에서 룸이름 정보를 가져온다.
- *
- * @return (String []) null - 실패, not null
- */
- private String[] getDBRoomName() {
- try {
- WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
- String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
- wallpadStatusData.closeDB();
- if (strRoomNameList == null) {
- Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
- return null;
- }
- if (bRoomNameLog) {
- for (int i = 0; i < strRoomNameList.length; i++)
- Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
- }
- return strRoomNameList;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getDBRoomName()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return null;
- }
- /**
- * DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
- *
- * @param nDeviceType - int
- * @return (String []) null - 실패, not null
- */
- private String[] getDBRoomName(int nDeviceType) {
- try {
- String[] strRoomNameList = null;
- WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
- if (nDeviceType == HEATING) {
- strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
- } else {
- strRoomNameList = wallpadStatusData.GetDevRoomName("light");
- }
- wallpadStatusData.closeDB();
- if (strRoomNameList == null) {
- Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
- return null;
- }
- if (bRoomNameLog) {
- for (int i = 0; i < strRoomNameList.length; i++)
- Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
- }
- return strRoomNameList;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return null;
- }
- /**
- * DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
- **/
- private void getRoomName() {
- try {
- Log.i(TAG, "[getRoomName] ====================");
- // WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- // boolean bRoomNameEach = wallpadDeviceSet.GetEachRoomNameInfo();
- // wallpadDeviceSet.closeDB();
- // Log.i(TAG, "[getRoomName] bRoomNameEach [" + bRoomNameEach + "]");
- //
- // if (bRoomNameEach) {
- // // 명칭 난방, 조명 분리 사용
- // mRoomNameList_Light = getDBRoomName(LIGHT);
- // if (mRoomNameList_Light == null) {
- // mRoomNameList_Light = mDefaultRoomNameList_Light;
- // }
- //
- // if (getEasyModeUXUsage()) {
- // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
- // }
- // else {
- // mRoomNameList_Heating = getDBRoomName(HEATING);
- // if (mRoomNameList_Heating == null) {
- // mRoomNameList_Heating = mDefaultRoomNameList_Heating;
- // }
- // }
- // }
- // else {
- // // 명칭 통합사용
- // mRoomNameList_Light = getDBRoomName();
- // if (mRoomNameList_Light == null) {
- // mRoomNameList_Light = mDefaultRoomNameList;
- // }
- //
- // if (getEasyModeUXUsage()) {
- // mRoomNameList_Heating = mDefaultRoomNameList_Heating_easymode;
- // }
- // else {
- // mRoomNameList_Heating = getDBRoomName();
- // if (mRoomNameList_Heating == null) {
- // mRoomNameList_Heating = mDefaultRoomNameList;
- // }
- // }
- // }
- //
- // if (bRoomNameLog) {
- // for (int i = 0; i < mRoomNameList_Light.length; i++) {
- // Log.i(TAG, "[getRoomName] mRoomNameList_Light[" + i + "] " + mRoomNameList_Light[i]);
- // }
- //
- // for (int i = 0; i < mRoomNameList_Heating.length; i++) {
- // Log.i(TAG, "[getRoomName] mRoomNameList_Heating[" + i + "] " + mRoomNameList_Heating[i]);
- // }
- // }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getRoomName()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public boolean getEasyModeUXUsage() {
- try {
- WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
- boolean bSupport = deviceSet.Get_EasyModeUX_Support();
- deviceSet.closeDB();
- WallpadStatusData data = new WallpadStatusData(getApplicationContext());
- boolean bUse = data.GetEasyModeUxUse();
- data.closeDB();
- Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
- return bSupport & bUse;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getEasyModeUXUsage()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- /**
- * 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
- * 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
- * 재설정 5초 후 월패드 재부팅을 실행한다.
- * 2020.11.18 SEULKI
- */
- public void checkDoorCamConfig() {
- try {
- if (Build.VERSION.SDK_INT > 23) {
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
- || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
- if (!checkAvailableBSPDoorCamConfig()) {
- Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
- return;
- }
- if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
- Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
- if (mIOInterface != null)
- mIOInterface.setCameraConfigure(getDBDoorCamConfig());
- // 재부팅
- setDefaultLauncher();
- Intent intent = new Intent();
- if (intent != null) {
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
- getApplicationContext().sendBroadcast(intent);
- }
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", "", re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkDoorCamConfig(");
- LogUtil.errorLogInfo("", "", e);
- }
- }
- /**
- * 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
- * BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
- * BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
- *
- * @return true: 지원, false: 미지원
- */
- int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
- private boolean checkAvailableBSPDoorCamConfig() {
- try {
- int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
- Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
- if (nCurrentVer >= nCriterionVer) {
- return true;
- } else return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- /**
- * BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
- *
- * @return 0 - 스마트현관카메라
- * 2 - 스마트현관카메라 좌우반전
- * 1 - 일반현관카메라
- * 2020.11.18 SEULKI
- */
- public int getBSPDoorCamConfig() {
- InputStreamReader is = null;
- try {
- Runtime mRuntime = Runtime.getRuntime();
- String cmd = "getprop camera.setting.value";
- if (mRuntime != null) {
- Process mProcess = mRuntime.exec(cmd);
- is = new InputStreamReader(mProcess.getInputStream());
- BufferedReader br = new BufferedReader(is);
- String line;
- String strResult = null;
- if (br != null) {
- while ((line = br.readLine()) != null) {
- strResult = line;
- }
- if (strResult != null) {
- Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
- if (strResult.equals("0")) {
- Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
- return 0;
- } else if (strResult.equals("1")) {
- Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
- return 1;
- } else if (strResult.equals("2")) {
- Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
- return 2;
- } else {
- Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
- return -1;
- }
- }
- }
- }
- return -1;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
- e.printStackTrace();
- return -1;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- is = null;
- }
- }
- }
- /**
- * 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
- *
- * @return 0 - 스마트현관카메라
- * 2 - 스마트현관카메라 좌우반전
- * 1 - 일반현관카메라
- * 2020.11.18 SEULKI
- */
- public int getDBDoorCamConfig() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- if (mWallpadDeviceSet != null) {
- int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
- boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
- mWallpadDeviceSet.closeDB();
- if (nType != null) {
- Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
- if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
- // Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
- if (bFlip) {
- Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
- return 0;
- } else {
- Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
- return 2;
- }
- } else {
- Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
- return 1;
- }
- }
- }
- return -1;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getDBDoorCamConfig()");
- e.printStackTrace();
- return -1;
- }
- }
- /**
- * 공기질 센서 사용여부 확인
- *
- * @return true - 사용함, false: 사용안함
- */
- boolean bAirQualityEnable = false;
- private boolean getAirQualityUsage() {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- try {
- int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
- mWallpadDeviceSet.closeDB();
- if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
- bAirQualityEnable = true;
- Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
- } else {
- bAirQualityEnable = false;
- Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
- }
- return bAirQualityEnable;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getAirQualityUsage()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
- return false;
- }
- }
- String strAirQualityFWVer = "";
- String strAirQualityProtocolVer = "";
- String strAirQualityInfo = "";
- private String getAirQualityInfo() {
- try {
- AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
- if (mAirQualitySensorAPI != null) {
- int nRet = mAirQualitySensorAPI.Refresh(false);
- if (nRet >= 0) {
- Log.i(TAG, "[getAirQualityInfo] ");
- DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
- strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
- strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
- strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
- return strAirQualityInfo;
- } else return "FAIL";
- } else return "NULL";
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return "ERROR";
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getAirQualityInfo()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "ERROR";
- }
- }
- private String getAOSVerCode() {
- try {
- int nOSVer = Build.VERSION.SDK_INT;
- switch (nOSVer) {
- case Build.VERSION_CODES.BASE:
- return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
- case Build.VERSION_CODES.BASE_1_1:
- return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
- case Build.VERSION_CODES.CUPCAKE:
- return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
- case Build.VERSION_CODES.DONUT:
- return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
- case Build.VERSION_CODES.ECLAIR:
- return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
- case Build.VERSION_CODES.ECLAIR_0_1:
- return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
- case Build.VERSION_CODES.ECLAIR_MR1:
- return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
- case Build.VERSION_CODES.FROYO:
- return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
- case Build.VERSION_CODES.GINGERBREAD:
- return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
- case Build.VERSION_CODES.GINGERBREAD_MR1:
- return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
- case Build.VERSION_CODES.HONEYCOMB:
- return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
- case Build.VERSION_CODES.HONEYCOMB_MR1:
- return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
- case Build.VERSION_CODES.HONEYCOMB_MR2:
- return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
- case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
- return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
- case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
- return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
- case Build.VERSION_CODES.JELLY_BEAN:
- return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
- case Build.VERSION_CODES.JELLY_BEAN_MR1:
- return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
- case Build.VERSION_CODES.JELLY_BEAN_MR2:
- return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
- case Build.VERSION_CODES.KITKAT:
- return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
- case Build.VERSION_CODES.KITKAT_WATCH:
- return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
- case Build.VERSION_CODES.LOLLIPOP:
- return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
- case Build.VERSION_CODES.LOLLIPOP_MR1:
- return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
- case Build.VERSION_CODES.M:
- return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
- case Build.VERSION_CODES.N:
- return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
- case Build.VERSION_CODES.N_MR1:
- return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
- case Build.VERSION_CODES.O:
- return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
- case Build.VERSION_CODES.O_MR1:
- return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
- case Build.VERSION_CODES.P:
- return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
- case Build.VERSION_CODES.CUR_DEVELOPMENT:
- return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
- default:
- return "SDK(" + nOSVer + ")/UNKNOWN";
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return "ERROR";
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getAirQualityInfo()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "ERROR";
- }
- }
- /**
- * 조명 ON/OFF 상태
- */
- public static class LIGHT_ONOFF {
- /**
- * ON
- */
- public static byte ON = (byte) 0x01;
- /**
- * OFF
- */
- public static byte OFF = (byte) 0x02;
- /**
- * OFF
- */
- public static byte DONTCARE = (byte) 0xFF;
- }
- private byte convertSmartLightPowerValue(String cmd) {
- try {
- if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
- else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
- else return LIGHT_ONOFF.DONTCARE;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -1;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -1;
- }
- }
- /** 거주자 안정 확인 서비스용 코드 시작 */
- /**
- * Edited by Jeff, 2021.06.15
- */
- public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
- public boolean bEnableResidentSafetyCheck = false;
- private void getResidentSafetyCheckSetting() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
- mWallpadDeviceSet.closeDB();
- Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
- if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
- bEnableResidentSafetyCheck = true;
- else bEnableResidentSafetyCheck = false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private String getSecurityMode() {
- try {
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int nStatus = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- String strSecurity = "null";
- if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
- else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
- else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
- else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
- else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
- else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
- return strSecurity;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getSecurityMode()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
- String Touch = "Touch";
- String Magnetic = "Magnetic";
- private void setTimeStamp_ScreenTouched() {
- try {
- Calendar mCal = Calendar.getInstance();
- String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
- // Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
- SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
- SharedPreferences.Editor mEditor = mSharedPreferences.edit();
- mEditor.putString(Touch, strTouchTime);
- mEditor.apply();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private String getTimeStamp_ScreenTouched() {
- try {
- SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
- String strTouchTime = mSharedPreferences.getString(Touch, null);
- // Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
- return strTouchTime;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private void setTimeStamp_Magnetic() {
- try {
- Calendar mCal = Calendar.getInstance();
- String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
- // Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
- SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
- SharedPreferences.Editor mEditor = mSharedPreferences.edit();
- mEditor.putString(Magnetic, strMagneticTime);
- mEditor.apply();
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private String getTimeStamp_Magnetic() {
- try {
- SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
- String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
- // Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
- return strMagneticTime;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- /** 거주자 안정 확인 서비스용 코드 종료 */
- /**
- * 가스밸브를 쿡탑콘센트로 사용
- */
- private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
- /** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
- /** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
- /**
- * false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
- */
- // iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
- private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
- /**
- * 기기 연동 제어 옵션 설정 확인
- */
- // 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
- // 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
- private void getDeviceCtrlOption() {
- int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
- boolean bUserSetting_SmartLightEnable = false;
- int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- try {
- bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
- nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
- nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
- mWallpadDeviceSet.closeDB();
- bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
- mWallpadStatusData.closeDB();
- if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
- // 스마트 분전반을 사용하는 경우에만
- // 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
- if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
- // 사용자선택인 경우
- if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
- else bLightCMDUseAsSmartLight = true;
- } else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
- // 스마트조명을 사용하는 경우
- bLightCMDUseAsSmartLight = false;
- } else {
- // 스마트조명을 사용하지 않는 경우
- bLightCMDUseAsSmartLight = true;
- }
- } else {
- // 스마트분전반을 사용하지 않는 경우
- bLightCMDUseAsSmartLight = true;
- }
- Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
- } catch (Exception e) {
- if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
- if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
- Log.e(TAG, "[Exception] getDeviceCtrlOption()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // private void demoPushMsg()
- // {
- // String urlStr1 = "";
- //
- // if(android.os.Build.VERSION.SDK_INT > 9 )
- // {
- // StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
- // StrictMode.setThreadPolicy(policy);
- // }
- //
- // String Msg ="";
- // try {
- // Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
- // } catch (UnsupportedEncodingException e1) {
- // // TODO Auto-generated catch block
- // e1.printStackTrace();
- // }
- //
- // urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
- // Log.d(TAG , "################ : " + urlStr1);
- // try
- // {
- // //URLEncoder.encode(s)
- // HttpClient client = new DefaultHttpClient();
- //
- // HttpGet get = new HttpGet();
- // //get.setURI(new URI("http://www.google.com/"));
- // get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
- // HttpResponse resp = client.execute(get);
- // BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
- // String str = null;
- // StringBuilder sb = new StringBuilder();
- // while((str = br.readLine()) != null)
- // {
- // sb.append(str).append("\n");
- // }
- // br.close();
- // //TextView txt = (TextView) findViewById(R.id.txt_get);
- // //txt.setText(sb.toString());
- // }catch(Exception e)
- // {
- //
- // e.printStackTrace();
- //
- // }
- //
- //
- // }
- //
- //
- // public static boolean checkForExternal(String str) {
- // int length = str.length();
- // for (int i = 0; i < length; i++) {
- // if (str.charAt(i) > 0x7F) {
- // return true;
- // }
- // }
- // return false;
- // }
- //
- // private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
- // private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
- // private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
- // private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
- // private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
- //
- // public static String encodeUrl(String url) {
- // if (checkForExternal(url)) {
- // try {
- // String value = URLEncoder.encode(url, "UTF-8");
- // value = COLON.matcher(value).replaceAll(":");
- // value = SLASH.matcher(value).replaceAll("/");
- // value = QUEST_MARK.matcher(value).replaceAll("?");
- // value = EQUAL.matcher(value).replaceAll("=");
- // return AMP.matcher(value).replaceAll("&");
- // } catch (UnsupportedEncodingException e) {
- // //throw LOGGER.getIllegalStateException(e);
- // return null;
- // }
- // } else {
- // return url;
- // }
- // }
- }
|