12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050 |
- 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.Arrays;
- 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() == Version.MODEL_TYPE.IHN_D101_I_LX2
- || 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_D101_I_LX2
- || 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_D101_I_LX2
- || 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_D101_I_LX2
- || 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_D101_I_LX2
- || 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 || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
- 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 || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
- 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 || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
- 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_D101_I_LX2
- || 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;
- int skipCount = 0;
- /**
- * 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:
- break;
- }
- return false;
- }
- }));
- private void sendMsgToActivity(int sendValue) {
- try {
- Bundle bundle = new Bundle();
- bundle.putInt("fromService", sendValue);
- Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
- msg.setData(bundle);
- if(mClient!=null) {
- mClient.send(msg); // msg 보내기
- }
- } catch (Exception 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();
- }
- 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 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
- || 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_access_sysaircon")) {
- retXML = iCMDProcSysairconControl(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_D101_I_LX2
- || 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() == MODEL_TYPE.IHN_D101_I_LX2
- || 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 target = "null", tid = "null", msgno = "null";
- String retStr = CheckiCMDProc("remote_access_temper");
- if (retStr != null) return retStr;
- else
- retStr = XMLHeader + " <service type=\"reply\" name=\"remote_access_temper\" result=";
- 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);
- String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_HEATING);
- if(knxRoomNameList==null) knxRoomNameList = mDefaultRoomNameList_Heating;
- // 난방 종류를 얻어온다.
- 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 < knxRoomNameList.length; i++) {
- if (tempercmd.unitnum.equals(knxRoomNameList[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 {
- int nDevNum = Integer.parseInt(tempercmd.devnum);
- if (heatingV2API != null) {
- int ret = heatingV2API.SetEachRoomStatus((byte) nDevNum, 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((byte) nDevNum, 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=\"" + knxRoomNameList[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 < knxRoomNameList.length; i++) {
- if (tempercmd.unitnum.equals(knxRoomNameList[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=\"" + knxRoomNameList[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.devnum.equals("all"))) {
- 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;
- resultStr += " <status_map dev_num=\"" + (i+1) + "\" unit_cnt = \"1\"/>\r\n";
- if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
- resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\" room_name=\"" + knxRoomNameList[i] + "\"/>\r\n";
- } else {
- resultStr += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" unit_status=\"" + drvmode + "\"/>\r\n";
- }
- }
- resultStr += " </service>\r\n</imap>\r\n";
- retStr += ("\"ok\">\r\n" + resultStr);
- return retStr;
- }
- else {
- String drvmode = "off";
- int nDevNum = Integer.parseInt(tempercmd.unitnum);
- HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum];
- if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
- else drvmode = "off";
- drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
- resultStr += " <status_map dev_num=\"" + (nDevNum) + "\" unit_cnt=\"1\"/>\r\n";
- resultStr += " <status_info unit_num=\"" + knxRoomNameList[nDevNum] + "\" 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\" ";
- 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);
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int nResultPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
- String[] strDeviceSeqValue = mWallpadDeviceSet.GetSettingData("UI순서");
- int nConcentEnable = mWallpadDeviceSet.Get_Concent_Info(); // 콘센트 사용 유무
- mWallpadDeviceSet.closeDB();
- WallpadiCMDParser DevListCMD = new WallpadiCMDParser(ele);
- String[] devlist;
- if(nConcentEnable==1){
- devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "electric", "smartlight", "cooktop", "sysaircon"};
- } else {
- devlist = new String[]{"gas", "livinglight", "doorlock", "light", "ventil", "thermostat", "smartlight", "cooktop", "sysaircon"};
- }
- strResult += "result=\"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());
- 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() == MODEL_TYPE.IHN_D101_I_LX2
- || 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() == MODEL_TYPE.IHN_D101_I_LX2
- || 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.d(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() == MODEL_TYPE.IHN_D101_I_LX2
- || 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.d(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
- if (KnxApi.data.MasterController == null)
- Log.d(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.Light_SwitchCount; // + 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.d(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_D101_I_LX2
- || 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() == MODEL_TYPE.IHN_D101_I_LX2
- || 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;
- }
- //기준층 명칭
- String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
- "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
- String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_LIGHT);
- if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
- int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
- int SwitchCount = KnxApi.data.MasterController.Info.Light_SwitchCount;
- int totalLightCount = LivingLightCount + BadLightCount + SwitchCount;
- int emCount = 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 if(i>0 && i<emCount){
- 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";
- 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";
- } else{
- retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[i - emCount].Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
- 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 if(nDevNo>1 && nDevNo<emCount+1){
- 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";
- status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
- 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";
- } else{
- retStr += " <status_map dev_num=\"" + (nDevNo) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[nDevNo-1] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
- 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 if(i>0 && i<emCount){
- 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";
- 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";
- } else {
- retStr += " <status_map dev_num=\"" + (i + 1) + "\" dev_mode=\"null\" dev_name=\"" + knxRoomNameList[i] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[i - emCount].Info.LightCount + "\">\r\n";
- for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
- String status_power = "off", status_dim = "null", status_color = "null";
- status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
- 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 if(nDevNo>1 && nDevNo<emCount+1){
- // 각각 EM 조명 일괄제어일 경우
- if (!unit_status.equalsIgnoreCase("null")) {
- KnxApi.SetLightOnOff((byte) (nDevNo -2), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
- }
- if (!unit_dimming.equalsIgnoreCase("null")) {
- Log.d(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.d(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.d(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.d(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.d(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";
- }
- } else {
- // 각각 EM 스위치 일괄제어일 경우
- if (!unit_status.equalsIgnoreCase("null")) {
- KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), define.DEVICE_ALL_OR_NOTHING, (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.d(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-emCount-1] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount + "\">\r\n";
- nDevNo = Integer.parseInt(dev_num);
- for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
- //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
- String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
- String 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(nDevNo>1 && nDevNo<emCount+1){
- 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";
- }
- } else{
- if (!unit_status.equalsIgnoreCase("null")) {
- KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), (byte)(nUnitNo-1), (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.d(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-emCount-1] + "\" unit_cnt=\"" + KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount + "\">\r\n";
- nDevNo = Integer.parseInt(dev_num);
- for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
- //KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
- String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
- String 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 boolean airconTestMode = false;
- private boolean [] airconTestModeOnOff = {false, true, false, true, false, true, false, true, false, true, false};
- private String getTextSysAirconMode(byte in)
- {
- if( in == DataClasses.KnxSystemAircon.MODE.Auto)
- return "auto";
- else if( in == DataClasses.KnxSystemAircon.MODE.Cold)
- return "cool";
- else if( in == DataClasses.KnxSystemAircon.MODE.Dry)
- return "dehum";
- else if( in == DataClasses.KnxSystemAircon.MODE.Venti)
- return "blow";
- else if( in == DataClasses.KnxSystemAircon.MODE.Heat)
- return "heat";
- else
- return "null";
- }
- private String iCMDProcSysairconControl(Element ele) {
- try {
- String target= "null", tid= "null", msgno= "null", devnum = "null",ctraction = "null", ilgalstatus = "null";
- String retStr = CheckiCMDProc("remote_access_sysaircon");
- 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("dev_num")) devnum = attr.getNodeValue();
- 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_sysaircon\" result=";
- actionTXT = trimquotation(actionTXT);
- Log.d(TAG, "&&&&&&&&&&&&&&& : " + actionTXT);
- int ndeviceCount = 0;
- String sMode = "auto/cool/dehum/blow/heat"; // 자동, 냉방, 제습, 송풍, 난방
- String [] aMode = {"auto","cool","dehum","blow","heat"};
- String strResultStatus = "";
- //기준층 명칭
- String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
- "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
- String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_SYSTEMAIRCON);
- if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
- String [] mTextWindType = {"자동", "약", "중", "강"};
- String m_TextWindRange = "자동/약/중/강";
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
- int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
- mWallpadDeviceSet.closeDB();
- if (nResult != Version.DISTRIBUTION_MODEL.KNX_DIST) {
- String[] mAirconNmae = new String[]{"에어컨1", "에어컨2", "에어컨3", "에어컨4", "에어컨5", "에어컨6", "에어컨7", "에어컨8"};
- knxRoomNameList = mAirconNmae;
- }
- KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
- int nCount = 7;
- if( airconAPI != null )
- nCount = airconAPI.data.Device.info.InsideAirconCount;
- if( airconTestMode == true )nCount = 7;
- if( actionTXT.equalsIgnoreCase("status") ) {
- // 에어컨 상태조회
- int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
- if (devnum.equalsIgnoreCase("all")) {
- Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : airconTestMode : " + airconTestMode + " nCount : " + nCount );
- if (airconTestMode == false && ret < 0) {
- retStr += " \"fail\" >\r\n </service>\r\n</imap>";
- return retStr;
- } else {
- for (int i = 0; i < nCount; i++) {
- String sOnOff = "off";
- if( airconTestMode == true )
- {
- if( airconTestModeOnOff[i] == true )sOnOff = "on";
- strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
- //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
- }
- else {
- if (airconAPI.data.Device.Aircon[i].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
- sOnOff = "on";
- strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i]+ "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(airconAPI.data.Device.Aircon[i].Mode) + "/" + mTextWindType[airconAPI.data.Device.Aircon[i].Volume] + "/" + airconAPI.data.Device.Aircon[i].SetTemp + "/" + airconAPI.data.Device.Aircon[i].NowTemp + "\"/>\r\n";
- }
- }
- }
- }
- else
- {
- // 개별 상태 조회
- if (airconTestMode == false && ret < 0) {
- retStr += " \"fail\" >\r\n </service>\r\n</imap>";
- return retStr;
- } else {
- int reqDevNum = Integer.parseInt(devnum);
- String sOnOff = "off";
- if( airconTestMode == true )
- {
- if( airconTestModeOnOff[reqDevNum-1] == true )sOnOff = "on";
- strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
- //strResultStatus += " <status_info unit_num=\"" + "aircon" + (i+1) + "\" mode = \"" + sMode + "\" wind = \"" + sWind + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "1" + "/" + "22" + "/" + "33" + "\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
- }
- else {
- if (airconAPI.data.Device.Aircon[reqDevNum-1].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
- sOnOff = "on";
- strResultStatus += " <status_map dev_num=\"" + (reqDevNum) + "\" unit_cnt=\"1\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[reqDevNum-1]+ "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(airconAPI.data.Device.Aircon[reqDevNum-1].Mode) + "/" + mTextWindType[airconAPI.data.Device.Aircon[reqDevNum-1].Volume] + "/" + airconAPI.data.Device.Aircon[reqDevNum-1].SetTemp + "/" + airconAPI.data.Device.Aircon[reqDevNum-1].NowTemp + "\"/>\r\n";
- }
- }
- }
- }
- else if (actionTXT.equalsIgnoreCase("control")) {
- // 에어컨 제어
- String[] CtrList;
- CtrList = ctraction.split("/");
- for( int k = 0 ; k < CtrList.length; k++)
- {
- Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : CtrList[k] : " + k + " CtrList[k] : " + CtrList[k]);
- }
- strResultStatus = "";
- int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
- if (devnum.equalsIgnoreCase("all")) {
- // 일괄제어는 Off 밖에 없음
- if( airconTestMode == true )
- {
- for (int i = 0; i < nCount; i++) {
- String sOnOff = "off";
- //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
- if(CtrList[0].equalsIgnoreCase("off"))
- {
- airconTestModeOnOff[i] = false;
- }
- else
- {
- airconTestModeOnOff[i] = true;
- sOnOff = "on";
- }
- strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
- }
- }
- else
- {
- for (int i = 0; i < nCount; i++) {
- String sOnOff = "off";
- //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
- byte hOnOff = 0x00;
- if(CtrList[0].equalsIgnoreCase("off"))
- {
- hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
- sOnOff = "off";
- }
- else
- {
- hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
- sOnOff = "on";
- }
- double setTemp = airconAPI.data.Device.Aircon[i].SetTemp;
- byte volume = airconAPI.data.Device.Aircon[i].Volume;
- byte mode = airconAPI.data.Device.Aircon[i].Mode;
- int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
- ret = airconAPI.SetEachRoomStatus((byte)i, hMode, setTemp);
- strResultStatus += " <status_map dev_num=\"" + (i + 1) + "\" unit_cnt=\"1\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[i]+ "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume]+ "/" + setTemp + "/" + airconAPI.data.Device.Aircon[i].NowTemp + "\"/>\r\n";
- }
- }
- }
- else
- {
- // 개별 제어
- int nDevNum = Integer.parseInt(devnum);
- if( airconTestMode == true )
- {
- String sOnOff = "off";
- //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
- if(CtrList[0].equalsIgnoreCase("off"))
- {
- airconTestModeOnOff[nDevNum-1] = false;
- }
- else
- {
- airconTestModeOnOff[nDevNum-1] = true;
- sOnOff = "on";
- }
- strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + "cool" + "/" + "약" + "/" + "22" + "/" + "33" + "\"/>\r\n";
- }
- else
- {
- String sOnOff = "off";
- //CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
- byte hOnOff = 0x00;
- if(CtrList[0].equalsIgnoreCase("off"))
- {
- hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
- sOnOff = "off";
- }
- else
- {
- hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
- sOnOff = "on";
- }
- //String [] aMode = {"auto","cool","dehum","blow","heat"};
- byte mode = 0x00;
- if(CtrList[1].equalsIgnoreCase("auto"))
- mode = DataClasses.KnxSystemAircon.MODE.Auto;
- else if(CtrList[1].equalsIgnoreCase("cool"))
- mode = DataClasses.KnxSystemAircon.MODE.Cold;
- else if(CtrList[1].equalsIgnoreCase("dehum"))
- mode = DataClasses.KnxSystemAircon.MODE.Dry;
- else if(CtrList[1].equalsIgnoreCase("blow"))
- mode = DataClasses.KnxSystemAircon.MODE.Venti;
- else if(CtrList[1].equalsIgnoreCase("heat"))
- mode = DataClasses.KnxSystemAircon.MODE.Heat;
- else
- mode = airconAPI.data.Device.Aircon[nDevNum-1].Mode;
- byte volume = 0x00;
- if(CtrList[2].equalsIgnoreCase(mTextWindType[0]))
- volume = DataClasses.KnxSystemAircon.VOLUME.Auto;
- else if(CtrList[2].equalsIgnoreCase(mTextWindType[1]))
- volume = DataClasses.KnxSystemAircon.VOLUME.Weak;
- else if(CtrList[2].equalsIgnoreCase(mTextWindType[2]))
- volume = DataClasses.KnxSystemAircon.VOLUME.Medium;
- else if(CtrList[2].equalsIgnoreCase(mTextWindType[3]))
- volume = DataClasses.KnxSystemAircon.VOLUME.Strong;
- else
- volume = airconAPI.data.Device.Aircon[nDevNum-1].Volume;
- double setTemp = 0;
- if( CtrList[3].equalsIgnoreCase("null"))
- setTemp = airconAPI.data.Device.Aircon[nDevNum-1].SetTemp;
- else
- setTemp = Double.parseDouble(CtrList[3]);
- int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
- ret = airconAPI.SetEachRoomStatus((byte)(nDevNum-1), hMode, setTemp);
- if( ret >= 0 ) {
- ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
- }
- double curTemp = airconAPI.data.Device.Aircon[nDevNum-1].NowTemp;
- strResultStatus += " <status_map dev_num=\"" + nDevNum + "\" unit_cnt=\"1\"/>\r\n";
- strResultStatus += " <status_info unit_num=\"" + knxRoomNameList[nDevNum-1] + "\" mode = \"" + sMode + "\" wind = \"" + m_TextWindRange + "\" unit_status=\"" + sOnOff + "/" + getTextSysAirconMode(mode) + "/" + mTextWindType[volume] + "/" + setTemp + "/" + curTemp + "\"/>\r\n";
- }
- }
- }
- 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 += strResultStatus;
- retStr += " </service>\r\n";
- retStr += "</imap> ";
- return retStr;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] iCMDProcSysairconControl(Document ele)");
- e.printStackTrace();
- 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();
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
- || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
- //다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
- if(skipCount==0) {
- sendMsgToActivity(1234);
- Log.d(TAG, "sendMsgToActivity!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
- }
- skipCount++;
- if(skipCount==3) skipCount = 0 ;
- }
- 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_D101_I_LX2
- || 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) + "]");
- //닫은 DB에 접근하여서 수정.
- Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + nCheckResult + "]");
- 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[] 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[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
- "복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
- 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] ====================");
- } 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() == MODEL_TYPE.IHN_D101_I_LX2
- || 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 String[] getRoomNameFromDBV2(String strDeviceType) {
- try {
- String[] RoomNameList = null;
- WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
- RoomNameList = wallpadStatusData.GetDevRoomNameList(strDeviceType);
- wallpadStatusData.closeDB();
- if (RoomNameList == null) {
- Log.e(TAG, "[getRoomNameFromDBV2] - RoomNameList is null !!!");
- return null;
- }
- Log.i(TAG, "[getRoomNameFromDBV2] RoomNameList " + Arrays.toString(RoomNameList));
- return RoomNameList;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getRoomNameFromDBV2(int Device)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return null;
- }
- // 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;
- // }
- // }
- }
|