1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165 |
- 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.os.SystemClock;
- import android.provider.Settings;
- import android.util.Log;
- import android.view.KeyEvent;
- import android.view.View;
- 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 de.re.easymodbus.exceptions.ModbusException;
- import de.re.easymodbus.modbusclient.ModbusClient;
- 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;
- boolean m_CallAppRunDelay = false; //add KSJ
- 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) {
- 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";
- }
- if(m_CallAppRunDelay == false)
- {
- 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)) {
- m_CallAppRunDelay = true;
- runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
- }
- }
- else
- {
- 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 stop_talking msg 추가 (wallpadcall 종료)
- else if (cmd.equals("stop_talking")) {
- String sip_result = "ok";
- //sip_result = "ok";
- retXML = XMLHeader + "<service type=\"reply\" name=\"stop_talking\" result=\"" + sip_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
- Common.SendAppFinishReqBR(getApplicationContext());
- }
- //~add KSJ
- //add 2022.03.02 front_open msg 추가 (현관에서 문열림 요청)
- else if (cmd.equals("front_open")) {
- retXML = ProcFrontOpen();
- }
- //~add
- 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)-1;
- 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.devnum);
- HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum-1];
- 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-1] + "\" 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) {
- // 하이브리드 쿡탑
- // 쿡탑 최대로 연동 안됨
- strResult += " <devinfo name=\"gas\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- strResult += " <devinfo name=\"cooktop\" value=\"0\" order=\"1\" floor=\"" + ho + "\"/>\r\n";
- /*
- if (mCooktopAPI != null) {
- int ret = mCooktopAPI.Refresh((byte) 0xFF, false);
- int nGas = 0;
- int nOutlet = 0;
- if (ret >= 0) {
- for (int k = 0; k < mCooktopAPI.data.Device[0].circuit.length; k++) {
- if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
- nGas++;
- else if (mCooktopAPI.data.Device[0].circuit[k].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;
- }
- }
- /**
- * 현관 열림 명령을 내린다.
- *
- * @return (String) - > success : 성공, fail : 실패
- */
- private String Device_DoorOpen(final int address) {
- Log.i(TAG, "[Device_DoorOpen] - Start");
- final ModbusClient modbusClient = new ModbusClient("10.0.215.2", 502);
- modbusClient.setConnectionTimeout(5000);
- try {
- new Thread() {
- public void run() {
- try {
- modbusClient.Connect();
- modbusClient.WriteSingleCoil(address, true);
- Thread.sleep(600);
- modbusClient.WriteSingleCoil(address, false);
- modbusClient.Disconnect();
- } catch (IOException | ModbusException | InterruptedException e) {
- e.printStackTrace();
- try {
- modbusClient.Disconnect();
- } catch (IOException ioException) {
- ioException.printStackTrace();
- }
- }
- }
- }.start();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return "fail";
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "fail";
- }
- Log.i(TAG, "[Device_DoorOpen] - OK");
- return "ok";
- }
- /**
- * 현관 문열림 요청에 대한 응답
- * @return String 타입의 응답 메시지 생성
- **/
- private long mLastClickTime = 0;
- private final long MIN_CLICK_INTERVAL = 3000;
- public String ProcFrontOpen() {
- String oepn_result;
- long currentClickTime = SystemClock.uptimeMillis();
- long elapsedTime = currentClickTime - mLastClickTime;
- mLastClickTime = currentClickTime;
- // 연속으로 문열림 요청이 들어오는 경우를 방지하기 위한 처리. 3초안에 문열림 요청이 다시 들어오면 무시하고, fail 처리함.
- if (elapsedTime < MIN_CLICK_INTERVAL) {
- mLastClickTime = 0;
- oepn_result = "fail";
- }else{
- oepn_result = Device_DoorOpen(19);
- }
- String retXML = XMLHeader + "<service type=\"reply\" name=\"front_open\" result=\"" + oepn_result + "\">\r\n <message>\"null\"</message>\r\n</service>\r\n</imap>\r\n";
- 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==18) 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이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
- new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
- @Override
- public void run() {
- Log.w(TAG, "[runCallMainActivity_moip] m_CallAppRunDelay " + m_CallAppRunDelay);
- m_CallAppRunDelay = false;
- }
- }, 3000);
- } else {
- Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
- m_CallAppRunDelay = false;
- }
- } 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 = 2;
- int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
- public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
- public static boolean bWallPadCallLive_old = false;
- 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 != bWallPadCallLive_old) {
- if (bWallPadCallLive != getCallAppRunning()) {
- //Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
- setCallAppRunning(bWallPadCallLive);
- }
- }
- bWallPadCallLive_old = 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;
- // }
- // }
- }
|